Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

webgl - three.js how to make double sided object

Blender export obj don't export double sided objects. How can I render objects in double sided mode. I tried this without succes:

var loader = new THREE.OBJMTLLoader();
    loader.load('models/test.obj');
    loader.addEventListener( 'load', function ( event ) {
        objects = event.content;
        objects.position.set(0,5,0);
        objects.scale.set(1.5,1.5,1.5);
        objects.mesh.doubleSided = true;
        scene.add(objects);
    });
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In your case, you add the following to your callback function:

objects.traverse( function( node ) {
    if( node.material ) {
        node.material.side = THREE.DoubleSide;
    }
});

The doubleSided property of Mesh is deprecated. It was replaced with the side property of Material

Also, it is best to learn from three.js examples that work with the current version of the library.

three.js r.57


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...