I have found out the reason for this behavior. The FreeCamera
(as well as other cameras) calculates the move speed from the engine’s delta time and FPS. If no render loop has ever been registered to the engine, then the engine’s delta time and FPS will be invalid, so the speed for the camera will always be zero.
// targetCamera.ts
// Methods
/** @internal */
public _computeLocalCameraSpeed(): number {
const engine = this.getEngine();
return this.speed * Math.sqrt(engine.getDeltaTime() / (engine.getFps() * 100.0));
}
So the exact behavior is, for all cameras, if engine.runRenderLoop()
has never been called, then the movement input will be inactive.
As @Tricotou said, we can register an empty function to bypass this problem.
engine.runRenderLoop(() => {});
I personally think this behavior is a little bit confusing. Delta time and FPS should also be available if the user chooses to trigger scene.render()
or camera.update()
on their own. (e.g. the render on demand thread)
Let’s see if other experts have any suggestions for this.