three.js how to make double sided object
Asked Answered
C

2

31

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);
});
Cognizable answered 16/4, 2013 at 1:6 Comment(0)
A
78

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

Ambsace answered 16/4, 2013 at 2:56 Comment(0)
G
6

2022

Future readers! Just add the side option to the material constructor:

const material = new THREE.MeshLambertMaterial({
  color: 0xff0000,
  side: THREE.DoubleSide
  //           ^ this line here
});

Gregggreggory answered 28/8, 2022 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.