I don’t really know if i’m doing something wrong, but something weird happens when i try to display the SpotLight shadow camera helper.
var ambienLight = new THREE.AmbientLight(0xffffff);
scene.add(ambienLight);
var SpotLight = new THREE.SpotLight(0xffffff,1);
SpotLight.position.set(0,15,35);
SpotLight.angle = Math.PI/8;
SpotLight.distance = 15;
SpotLight.penumbra = 0.05;
SpotLight.distance = 50;
SpotLight.decay = 0;
SpotLight.castShadow = true;
//SpotLight.shadow.update(SpotLight);
SpotLight.shadow.mapSize.width = 1024;
SpotLight.shadow.mapSize.height = 1024;
SpotLight.shadow.camera.near = 0.5;
SpotLight.shadow.camera.far = 50;
scene.add(SpotLight);
SpotLightHelper = new THREE.SpotLightHelper(SpotLight);
scene.add(SpotLightHelper);
cameraHelper = new THREE.CameraHelper(SpotLight.shadow.camera);
scene.add(cameraHelper)
and and gives me this result:
The camera for the shadows is way off no clue why. Also this are my update and render methods.
function update(){
render();
requestAnimationFrame(update);
}
function render(){
SpotLightHelper.update();
cameraHelper.update();
renderer.render(scene,camera);
}
I saw a post with this issue or a similar issue i guess, and i try to put those methods in the render, but didn’t work.
Sorry if the code looks messy i was working on a tetris kinda game