For the latest version 74!
function SPOT_CLASS(pointIntensity) { ROOT.sunLight= new THREE.SpotLight(0x0000ff,pointIntensity,2000,Math.PI,1); ROOT.sunLight.position.set( 100, 200 , 0 ); // HERE ROOT.PILOT = new THREE.Object3D( 0, 0, 0 ); ROOT.sunLight.target = ROOT.PILOT; ROOT.sunLight.castShadow = true; ROOT.sunLight.shadow.bias = 1; ROOT.sunLight.shadow.camera.far =5000; ROOT.sunLight.shadow.camera.near = 800; ROOT.sunLight.shadow.camera.fov = 70; // SHADOW CAMERA HELPER var shadowCameraHelper = new THREE.CameraHelper( ROOT.sunLight.shadow.camera ); shadowCameraHelper.visible = true; ROOT.sunLight.add( shadowCameraHelper ); // try other combination scene.add( ROOT.sunLight ); scene.add( ROOT.PILOT ); }
Make such instances:
var LIGHTS = new SPOT_CLASS (15);
then try in the console: LIGHTS.PILOT.position.x = 200;
Make this object -> LIGHTS.PILOT.position for rotation in the update or rendering cycle ...
ROOT.sunLight.target = LIGHTS.PILOT; or maybe better ROOT.sunLight.lookAt (LIGHTS.PILOT);
source share