我有一个3D模型,我想对它应用海洋着色器。我想结合"shaders / ocean“和"loader / gltf”示例场景。我想在我的自定义3D模型上看到海洋着色器,我很抱歉,因为我的知识很少。
const waterMat = new THREE.MeshStandardMaterial({color: 0xff0000});
const loader = new GLTFLoader().setPath( 'models/gltf/DamagedHelmet/glTF/' );
loader.load( 'DamagedHelmet.gltf', function ( gltf ) {
gltf.scene.traverse( function ( child ) {
if ( child.isMesh ) {
waterGeo = child;
}
} );
water = new Water(
waterGeo,
{
textureWidth: 512,
textureHeight: 512,
waterNormals: new THREE.TextureLoader().load( 'textures/waternormals.jpg', function ( texture ) {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
} ),
sunDirection: new THREE.Vector3(),
sunColor: 0xffffff,
waterColor: 0x001e0f,
distortionScale: 3.7,
fog: scene.fog !== undefined
}
);
water.rotation.x = - Math.PI / 2;
scene.add( water );发布于 2021-10-24 22:15:40
您必须将water = new Water(waterGeo,{您拥有的一些代码})更改为new Water(waterGeo.geometry,{您拥有的一些代码})
https://stackoverflow.com/questions/69441998
复制相似问题