簡體   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