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

203
Vistas
not able to understand scene position importance

I am trying to write some sample code of three.js where i have a plane and i want that plane to rotate around.

This is my camera:

var camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1,  1000);
camera.position.set(50, 50, 60);
camera.lookAt(scene.position);

and this is my plane:

var planeGeometry = new THREE.PlaneGeometry(70, 30, 1, 1);
var planeMaterial = new THREE.MeshBasicMaterial({ color: green });
var plane = new THREE.Mesh(planeGeometry, planeMaterial);
plane.rotation.x = -0.5 * Math.PI;
scene.add(plane);

i have other code too but this is my render and animationframe code:

renderScene();

function cameraUpdate() {
  camera.position.x = cameraRadius * Math.cos(step);
  camera.position.z = cameraRadius * Math.sin(step);
  camera.lookAt(scene.position);
}

function renderScene() {
 //make update to position, rotation of objects in the scene
  step += 0.05;
  cameraUpdate();
  requestAnimationFrame(renderScene);
  renderer.render(scene, camera);
}

My question is that inside cameraUpdate function if dont put

  camera.lookAt(scene.position);

the rotation become very wierd and when i put this inside cameraUpdate, i get rotation of the plane in own axis which is desired !!!

My question is

  1. what does scene.position mean
  2. Why do i need to make camera lookat at every animation frame? i dont understand how its value get changed when camera is rotated

Thank you in advance !!!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you want the plane to rotate on its own, you should just use plane.rotation.y += 0.1 on each frame, or something simple like that. What you’re doing instead is that you’re making the camera move around in circles around the plane. Think of it as walking in a circle around a coffee table. If you keep your head looking forward, you won’t see the table as you walk past it. That’s what camera.lookAt() fixes. It makes the camera look at a point in space. You can read about it in the docs.

scene.position is by default at (0, 0, 0) so it’s just another way of telling the camera to look at the center of the scene.

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