Mesh not reacting to light

I do not usually ask questions in forums. I pride myself in looking though already answered questions but this has me beat. I am sure it is a setting or something that I have missed but the more i stare at it the less I am seeing.

I have a mesh that is the result of a obj import and a PointLight.

The pointLight will hit other objects in the scene and the MeshPhongMaterial reacts accordingly. However the imported mesh which has the same material does not react.

It is acting strange, I also have it set to wire-frame but it is not showing as such. There is something interfering with how the mesh is appearing.

I have tried:-

  • setting the skinning to true as this is something that was mentioned earlier today in a different question.
  • simplifying the model.
  • different light sources.
  • stopping the animation.

The code for the model and the material is below.

Any help would be greatly appreciated.
Kind Regards,
Samantha

var meMaterial = new THREE.MeshPhongMaterial( { color: 0xdeafdb, specular: 0x9E4424 } );
meMaterial.skinning = true

// model
// instantiate a loader
var loader2 = new OBJLoader();

loader2.load('./model/0009scanofmeOBJsimples.obj',
        	function ( object1 ) {
                //traverse through the options if it is the mesh option then set the material
                //display the mesh
                object1.traverse( function ( child ) {
        					if ( child.isMesh ) {
                                child.material = meMaterial; 
                                //child.material.map = metexture;
                                child.scale.set(0.03,0.03,0.03);
                                child.position.set(0,22,-2);
                                child.name = "sam";            
                                child.castShadow = true;
                                child.wireframe = true;
                                child.receiveShadow = true;
                                child.renderOrder = 0; 
                                scene.add( child);                               
                                }
        		          } );
		          //scene.add( object1 );    
	           },
	// called when loading is in progresses
	function ( xhr ) {console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );	},
	// called when loading has errors
	function ( error ) {console.log( 'An error happened' );}
);
// end model

Hi!
If I see it correctly, your “Sam” mesh’s geometry doesn’t have normal attribute (it has just position attribute).


So, in the object1.traverse() try to add child.geometry.computeVertexNormals();

2 Likes

Amazing.

Thank you so much. This is all new to me, I have enjoyed getting my head around how it all works but i just couldn’t get to the bottom of this one.

Kind Regards,
Samantha

@Samantha
You’re welcome :beers:

1 Like