0
votes

I've imported an obj with this load function:

    // called when resource is loaded
    function ( object ) {

        // For any meshes in the model, add our material.
        object.traverse( function ( node ) {

            if ( node instanceof THREE.Mesh ){
                //node.material = material;
                //node.geometry.computeVertexNormals(); 
                node.castShadow = true; 
                node.receiveShadow = true;
            }
        } );


        object.scale.set(0.5,0.5,0.5);
        scene.add( object );
        parts[partName] = object;

    }

The object loads fine and has shadows from the spotlights in the scene. The issue is that when I apply a material to the mesh(hence why that is commented out in the above code) the model no longer receives shadow.

The materials are applied node by node and the materials are mapped jpg's like this.

if ( node.isMesh ) node.material = material;

new THREE.MeshBasicMaterial( { map: new THREE.TextureLoader().load( 'materials/orange.jpg' ), shininess: 50, shading: THREE.SmoothShading }),

Thanks for any help, Ed.

1

1 Answers

1
votes

Relised I was using

MeshBasicMaterial

Should use

MeshLambertMaterial

So the material can receive shadows.