While working with the code snippet below, I was advised to use the controls.update(); command. However, I encountered an error
Uncaught TypeError: controls.update is not a function at animate
After examining PointerLockControls.js and OrbitControls.js, I realized that Orbit has an update() function while Pointer does not. Considering the importance of updating controls every frame, how can I resolve this issue?
var dt = 1/60;
function animate() {
requestAnimationFrame(animate);
if(controls.enabled) {
world.step(dt);
//update ball positions
for(var i=0; i<balls.length; i++) {
ballMeshes[i].position.copy(balls[i].position);
ballMeshes[i].quaternion.copy(balls[i].quaternion);
}
//update box positions
for(var i=0; i<boxes.length; i++) {
boxMeshes[i].position.copy(boxes[i].position);
boxMeshes[i].quaternion.copy(boxes[i].position);
}
}
controls.update(Date.now()-time);
renderer.render(scene, camera);
time = Date.now();
}