Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!