[英]Is there a backface-visibility equivalent for three.js?
I have an object with a mesh that uses a semi-transparent png texture. 我有一个带有使用半透明png纹理的网格物体。
Is there a flag or option for the MeshBasicMaterial so that the back of the object is visible through the front? MeshBasicMaterial是否有一个标志或选项,以便可以从正面看到对象的背面?
Here is some sample code: 这是一些示例代码:
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. 这样可以准确地渲染球体,但背面仍然不可见。
The new way to do this is by using the side
property of material
. 做到这一点的新方法是利用
material
的side
特性。
Example: 例:
new THREE.MeshPhongMaterial( { map: texture, side: THREE.BackSide } )
Possible values are THREE.FrontSide
, THREE.BackSide
and THREE.DoubleSide
. 可能的值为
THREE.FrontSide
, THREE.BackSide
和THREE.DoubleSide
。
See: https://github.com/mrdoob/three.js/wiki/Migration 参见: https : //github.com/mrdoob/three.js/wiki/Migration
backface属性是在网格物体本身中设置的:
sphere.doubleSided = true;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.