Guest User

Untitled

a guest
Jan 18th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. var l = {
  2. colour: 0xffffff,
  3. intensity: 1,
  4. distance: 0,
  5. angle: 10 * (Math.PI/180),
  6. penumbra: 0.8,
  7. decay: 1
  8. };
  9.  
  10. var light = new THREE.SpotLight( l.colour, l.intensity, l.distance, l.angle, l.penumbra, l.decay);
  11. light.position.set(0, 0, 5);
  12. light.target.position.set(0, 0, 1);
  13. scene.add(light.target);
  14. scene.add(light);
  15.  
  16. var m = { x: 0, y: 0 };
  17. var pos = { x: 0, y: 0 };
  18.  
  19. window.addEventListener('mousemove', function (e) {
  20. m.x = e.clientX;
  21. m.y = e.clientY;
  22. pos.x = ((m.x / window.innerWidth) * 2) - 1
  23. pos.y = (((m.y / window.innerHeight) * 2) - 1) * -1;
  24. light.target.position.set( pos.x * lightZoom, pos.y * lightZoom, lightZoom );
  25. light.target.updateMatrixWorld();
  26. });
Add Comment
Please, Sign In to add comment