threejs当物体旋转到一定角度后消失或者背面消失不见
场景:当你渲染一个几何体的时候发现背部不可见,旋转到移动角度又会莫名消失
原代码:
...
for(let i = 0; i < tlen; i ++){
...
const material = new THREE.MeshBasicMaterial( { map: texture} );
const plane = new THREE.Mesh( geometry, material );
this.scene.add( plane );
this.objects.push( plane)
}
原因:在某些情况下,是因为材质默认是单面渲染。
使用:side: THREE.DoubleSide.所以在转到有些面的背面后,面就不再能看到了。
修改后代码:
...
for(let i = 0; i < tlen; i ++){
...
//在传入材质参数的对象上把材质渲染设置为双面渲染 side: THREE.DoubleSide
const material = new THREE.MeshBasicMaterial( { map: texture,side: THREE.DoubleSide} );
const plane = new THREE.Mesh( geometry, material );
this.scene.add( plane );
this.objects.push( plane)
}
注: 仅为个人遇到情况以及解决方法