use*_*845 5 javascript webgl three.js
我正在尝试创建一个透明的圆柱体。我尝试过设置透明、不透明度等,但似乎无法使其工作。有什么办法可以做到这一点吗?我需要加载带有 Alpha 通道的虚拟纹理吗?有没有更简单的方法?
material = new THREE.MeshBasicMaterial({wireframe: true});
material.transparent = true;
mesh = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 50, 8, 1, true), material);
scene.add(mesh);
Run Code Online (Sandbox Code Playgroud)
更新:我已将代码更改为以下内容,但以这种方式使用 ShaderMaterial 似乎是错误的。但它有效...
material = new THREE.ShaderMaterial({wireframe: true, transparent: true});
mesh = new THREE.Mesh(new THREE.CylinderGeometry(4, 4, 50, 8, 1, true), material);
scene.add(mesh);
Run Code Online (Sandbox Code Playgroud)
更新:这是图像。
ttp://img692.imageshack.us/img692/6412/shadermaterial.png 使用 ShaderMaterial,您可以看到由透明圆柱体包围的矩形灰色精灵。
http://img855.imageshack.us/img855/3988/opacity00.png 使用具有不透明度 0.0 的 MeshBasicMaterial。
http://img27.imageshack.us/img27/6087/opacity05.png 使用不透明度为 0.5 的 MeshBasicMaterial。
http://img837.imageshack.us/img837/8043/opacity10.png 使用具有不透明度 1.0 的 MeshBasicMaterial。
不应该是这个吗?
material = new THREE.MeshBasicMaterial( { wireframe: true, opacity: 0.5 } );
Run Code Online (Sandbox Code Playgroud)