I'm trying to rotate a spotlight. My code is:
var light = new THREE.SpotLight( color, intensity, distance );
light.position.set( 0, 100, 0 );
light.rotation.set( 0, Math.PI, 0 );
light.shadowCameraFar = 50;
light.shadowCameraNear = 0.01;
light.castShadow = true;
light.shadowDarkness = 0.5;
light.shadowCameraVisible = true;
light.shadowCameraFar = 800;
light.shadowCameraFov = 15;
scene.add( light );
I want to know what I'm doing wrong. The spotlight doesn't change its rotation independent the value I put.
light.target
determines the spotlight's shadow camera orientation. If, for example, you have an object in your scene called myObject, you could do something like this:
light.target = myObject;
Remember, light.target
is an Object3D
, not a position vector.
Three.js r.49
So you would position the light target either by direct assignment:
myLight.target.position = new THREE.Object3D( 10, 20, 30 );
Or by defining the light target object properties:
myLight.target.position.x = 10;
myLight.target.position.y = 20;
myLight.target.position.z = 30;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With