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

63
Views
animation with tree.js does not accept my torus

I am new to Three.js and cannot work out why this animation does not accept the torus as a parameter. Without setting 'torusToBeMoved' as a parameter it works just perfectly fine..

const geometry = new THREE.TorusGeometry(25, 0.2, 26, 100);
const material = new THREE.MeshStandardMaterial({ color: 0xccaa55 });
const torus = new THREE.Mesh(geometry, material);
torus.position.set(-15, -15, -15);

scene.add(torus);

function animate(torusToBeMoved) {
  requestAnimationFrame(animate(torusToBeMoved));

  torusToBeMoved.rotation.x += 0.01;
  torusToBeMoved.rotation.y += 0.005;
  torusToBeMoved.rotation.z += 0.01;
  controls.update();

  renderer.render(scene, camera);
}

animate(torus);```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are running into a "Maximum call stack size exceeded" error since you are passing the return value of the function as parameter instead of passing the function as parameter. Utilizing a callback as parameter should solve the issue:

const animate = (torusToBeMoved) => {
  torusToBeMoved.rotation.x += 0.01;
  torusToBeMoved.rotation.y += 0.005;
  torusToBeMoved.rotation.z += 0.01;

  controls.update();
  renderer.render(scene, camera);

  requestAnimationFrame(() => animate(torusToBeMoved));
}
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!