Search code examples
three.jsloader

How can I make an OBJ + MTL loaded doublesided?


with the loader bellow the obj and mtl files are loaded, so how can I access the material and make it doublesided? If I use mtlLoader.setMaterialOptions({side: THREE.DoubleSide}) as in the following threejs.org documentation page, it doesn't work -and I'm not getting any hinting from VScode about the .setMaterialOptions either.

https://threejs.org/docs/#examples/loaders/MTLLoader

Here's the main part of the obj+mtl loader:

            var mtlLoader = new THREE.MTLLoader();
            mtlLoader.setPath( 'female02/' );
            //mtlloader.setMaterialOptions(side:THREE.DoubleSide)               
            mtlLoader.load( 'female02.mtl', function( materials ) {                 
                materials.preload();                    

                var objLoader = new THREE.OBJLoader();
                objLoader.setMaterials( materials );
                objLoader.setPath( 'female02/' );
                objLoader.load( 'female02.obj', function ( object ) {
                    object.position.set( 0, -95, 0 );                   
                    sceneRTT.add( object );
                }, onProgress, onError );

            });

[and I can't add the main keyword "doublesided" because I lack... reputation]


Solution

  • In MTLLoader.setMaterialOptions( options ), the options argument is an object, so you must pass it as such.

    loader.setMaterialOptions( { side: THREE.DoubleSide } );
    

    three.js r.89