Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

106
Vistas
One direction SpotLight with PointerLockControls in Threejs

I'm trying to attach a directional flashlight to the camera (controls object) so the beam is always where center of the screen is aiming at. This is my code:

controls = new PointerLockControls( camera, document.body );
var flashlight = new THREE.SpotLight(0xffffff, 7, 50, 0.8*Math.PI);
controls.getObject().add(flashlight);
controls.getObject().add(flashlight.target);

but the result is the light around camera, not a straight beam. (see pic below)

Flashlight beam

so how can I achieve a directional beam?

//edit, added Group.

controls = new PointerLockControls( camera, document.body );
var flashlight = new THREE.SpotLight(0xffffff, 7, 50, 0.8*Math.PI);
// camera.add(flashlight);
// camera.add(flashlight.target);
const group = new THREE.Group();
group.add(camera);
group.add(flashlight);  
scene.add(group);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You could use a THREE.Group to group objects together

const group = new THREE.Group();
group.add(camera);
group.add(flashlight);

// Finally, we add the group to our controls
controls = new PointerLockControls( group, document.body );

Then you can add the group to your scene, and control the group as a whole. The camera and flashlight will rotate and translate together.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda