three设置透明度var doorGeometry = new THREEBoxGeometry05 2 05;var doorMaterial = new THREEMeshLambertMaterial color 0x00ff00 ;var door = new THREEMeshdoorGeometry doorMaterial;doorpositionx = 025;sceneaddd
要设置透明度,可以使用Material的opacity属性。例如,将doorMaterial的opacity设置为0.5,将门材质变为半透明:
var doorMaterial = new THREE.MeshLambertMaterial({ color: 0x00ff00, opacity: 0.5 }); doorMaterial.transparent = true; // 需要将transparent设置为true才能生效
另外,如果要在渲染时将门后面的物体显示出来,需要将渲染器的alpha属性设置为true:
renderer.alpha = true;
这样就可以显示半透明的门了。
原文地址: https://www.cveoy.top/t/topic/f25z 著作权归作者所有。请勿转载和采集!