Even though I’ve tried castShadow = true and receiveShadow = true for the appropriate objects, a model I imported as an obj + mil file will not cast a shadow on anything else in the scene, not even on a plane that is successfully receiving a shadow from another object. Here’s the code ( the “pin” is not casting a shadow on the pedestal [“boxMesh”] ):
var boxGeometry = new THREE.BoxGeometry( 0.7, 1.7, 0.7 );
var boxMesh = new THREE.Mesh( boxGeometry, cubeMat );
boxMesh.position.set( -1.3, 0.85, 0.3 );
boxMesh.castShadow = true;
boxMesh.needsUpdate = true;
scene.add( boxMesh );
// load pin
var loader = new THREE.MTLLoader()
loader.setPath( '/dentoncontemporary/models/' )
loader.load( 'pinGreen.mtl', function ( materials ) {
materials.preload();
var objLoader = new THREE.OBJLoader()
objLoader.setMaterials( materials )
objLoader.setPath( '/dentoncontemporary/models/' )
objLoader.load( 'pinGreen.obj', function ( pin ) {
pin.scale.x = pin.scale.y = pin.scale.z = 0.04;
pin.position.y = 1.65;
pin.position.x = -1.6;
pin.position.z = 0.3;
pin.rotation.x = 0.15;
pin.castShadow = true;
// this traverse didn't work either
/*
pin.traverse( function ( child )
{
child.castShadow = true;
});*/
scene.add( pin );
});
} );
Because the non-casting obj in question (pin) has 2 materials, I tried traversing it like the commented-out part above, but it didn’t work.
Any light-shedding advice I can get would be great! Thx!