繁体   English   中英

Three.js是否具有等效的背面可见性?

[英]Is there a backface-visibility equivalent for three.js?

我有一个带有使用半透明png纹理的网格物体。

MeshBasicMaterial是否有一个标志或选项,以便可以从正面看到对象的背面?

这是一些示例代码:

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
        })
   ]);

这样可以准确地渲染球体,但背面仍然不可见。

做到这一点的新方法是利用materialside特性。

例:

new THREE.MeshPhongMaterial( { map: texture, side: THREE.BackSide } )

可能的值为THREE.FrontSideTHREE.BackSideTHREE.DoubleSide

参见: https : //github.com/mrdoob/three.js/wiki/Migration

backface属性是在网格物体本身中设置的:

sphere.doubleSided = true;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM