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

161
Views
Tiempo en animación three.js

Soy bastante nuevo en Javascript y no entiendo cómo funciona el argumento de tiempo en la función de animación a continuación. Puedo ver que la función de animación requiere un argumento llamado tiempo, pero cuando se llama a la función como devolución de llamada en setAnimationLoop, no se pasa ningún argumento. ¿Alguien puede explicar cómo funciona esto?

 import * as THREE from './js/three.module.js'; let camera, scene, renderer; let geometry, material, mesh; init(); function init() { camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 ); camera.position.z = 1; scene = new THREE.Scene(); geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 ); material = new THREE.MeshNormalMaterial(); mesh = new THREE.Mesh( geometry, material ); scene.add( mesh ); renderer = new THREE.WebGLRenderer( { antialias: true } ); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setAnimationLoop( animation ); document.body.appendChild( renderer.domElement ); } function animation( time ) { mesh.rotation.x = time / 2000; mesh.rotation.y = time / 1000; renderer.render( scene, camera ); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

pero cuando se llama a la función como devolución de llamada en setAnimationLoop, no se pasa ningún argumento en

El ciclo de animación definido por WebGLRenderer.setAnimationLoop() se usa internamente con requestAnimationFrame() . Si pasa una devolución de llamada a requestAnimationFrame() , la función tiene acceso automático a DOMHighResTimeStamp .

Por favor lea la documentación respectiva para más detalles:

https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame

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!