Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js how to make double sided object

Tags:

three.js

webgl

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

const 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);
});
like image 746
user2244365 Avatar asked Sep 02 '25 15:09

user2244365


1 Answers

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

like image 172
WestLangley Avatar answered Sep 05 '25 14:09

WestLangley