ocean
This commit is contained in:
32
src/utils/plane_ocean2.js
Normal file
32
src/utils/plane_ocean2.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import * as THREE from 'three';
|
||||
import { Water } from 'three/examples/jsm/objects/Water.js';
|
||||
|
||||
const waterGeometry = new THREE.PlaneGeometry(50, 50);
|
||||
|
||||
const ocean = new Water(
|
||||
waterGeometry,
|
||||
{
|
||||
textureWidth: 512,
|
||||
textureHeight: 512,
|
||||
waterNormals: new THREE.TextureLoader().load(`https://z2586300277.github.io/3d-file-server/images/texture/waternormals.jpg`, function (texture) {
|
||||
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
||||
}),
|
||||
sunDirection: new THREE.Vector3(0, 1, 0), // 设置太阳方向为垂直向下
|
||||
sunColor: 0xffffff,
|
||||
waterColor: 'rgb(15,187,194)',
|
||||
distortionScale: 3.7,
|
||||
fog: false, // 关闭雾效果
|
||||
alpha: 1.0, // 设置透明度
|
||||
}
|
||||
);
|
||||
|
||||
ocean.rotation.x = -Math.PI / 2;
|
||||
|
||||
function animate() {
|
||||
ocean.material.uniforms['time'].value += 1.0 / 60.0;
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
|
||||
export { ocean };
|
||||
Reference in New Issue
Block a user