是否有与three.js 等效的背面可见性? [英] Is there a backface-visibility equivalent for three.js?
本文介绍了是否有与three.js 等效的背面可见性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个使用半透明 png 纹理的网格物体.
I have an object with a mesh that uses a semi-transparent png texture.
MeshBasicMaterial 是否有标志或选项,以便从正面可以看到物体的背面?
Is there a flag or option for the MeshBasicMaterial so that the back of the object is visible through the front?
这是一些示例代码:
var texture = THREE.ImageUtils.loadTexture('world.png');
// create the sphere's material
var sphereMaterial = new THREE.MeshBasicMaterial({
map: texture,
transparent: true,
blending: THREE.AdditiveAlpha
});
sphereMaterial.depthTest = false;
// set up the sphere vars
var radius = 50, segments = 20, rings = 20;
// create a new mesh with sphere geometry -
var sphere = new THREE.SceneUtils.createMultiMaterialObject(
new THREE.SphereGeometry(radius, segments, rings),[
sphereMaterial,
new THREE.MeshBasicMaterial({
color: 0xa7f1ff,
opacity: 0.6,
wireframe: true
})
]);
这将准确地渲染球体,但背面仍然不可见.
This will accurately render the sphere but the back remains invisible.
推荐答案
新的方法是使用 material
的 side
属性.
The new way to do this is by using the side
property of material
.
示例:
new THREE.MeshPhongMaterial( { map: texture, side: THREE.BackSide } )
可能的值为 THREE.FrontSide
、THREE.BackSide
和 THREE.DoubleSide
.
Possible values are THREE.FrontSide
, THREE.BackSide
and THREE.DoubleSide
.
参见:https://github.com/mrdoob/three.js/wiki/Migration
这篇关于是否有与three.js 等效的背面可见性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文