是否有相当于三.js的背面可见性

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

本文关键字:背面 可见性 js 相当于 是否      更新时间:2023-09-26

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

是否有网格基本材质的标志或选项,以便通过正面可以看到对象的背面?

下面是一些示例代码:

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

背面属性在网格本身中设置:

sphere.doubleSided = true;