I'm having trouble getting my racecar to cast a shadow on the floor. While the cube is successfully casting a shadow, the imported json mesh object racecar is not. I'm wondering if this has something to do with the json file baking on the materials. Should I add the code obj.castShadow = true;
to a child of the obj? If so, which child should it be placed on? What mistake am I making here?
Here's the link to the json file and you can also find a demo here
Below is the relevant code snippet:
var loader = new THREE.ObjectLoader();
loader.load("models/ferrari-f1-race-car.json", function (obj) {
obj.castShadow = true;
obj.scale.set(50,50,50);
obj.position.x = 30;
obj.rotation.y = Math.PI/1;
scene.add(obj);
});
boxgeometry = new THREE.BoxGeometry(100, 100, 100);
boxmaterial = new THREE.MeshLambertMaterial({
color: 0x0aeedf
});
var cube = new THREE.Mesh(boxgeometry, boxmaterial);
cube.castShadow = true;
cube.position.x = -80;
cube.position.y = 50;
cube.position.z = 0;
scene.add(cube);
function createFloor(){
floor = new THREE.Mesh(new THREE.PlaneBufferGeometry(1000,500), new THREE.MeshBasicMaterial({color: 0x8594a2}));
floor.rotation.x = -Math.PI/2;
floor.position.y = -0;
floor.castShadow = false;
floor.receiveShadow = true;
scene.add(floor);
}