是否有三个.js的背面可见性?

时间:2012-04-23 19:46:01

标签: javascript canvas 3d webgl 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
        })
   ]);

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

2 个答案:

答案 0 :(得分:23)

执行此操作的新方法是使用side的{​​{1}}属性。

示例:

material

可能的值包括new THREE.MeshPhongMaterial( { map: texture, side: THREE.BackSide } ) THREE.FrontSideTHREE.BackSide

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

答案 1 :(得分:7)

背面属性在网格物体中设置:

sphere.doubleSided = true;