PhysicsController

@three-blocks/proControllerUpdateInputEntityProxy
new PhysicsController(physicsAPI : Physics, options : Object)

PhysicsController - Main Thread Physics Orchestrator

High-level controller that manages physics entity access, interpolation, and input routing. This is the primary class for integrating physics into your render loop.

Features

  • EntityProxy access for reading physics state with interpolation
  • Automatic input handling from keyboard/gamepad
  • Frame timing and interpolation alpha calculation
  • Camera mode and offset control

Key Responsibilities

Responsibility Method
Entity access getDynamic(), getKinematic() → EntityProxy
Frame updates update()
Input routing applyInput() (auto or manual)
Camera control setCameraMode(), setCameraDrag()
Lifecycle pause(), resume(), dispose()
Constructor Parameters
Initialized Physics instance
optionsoptionalObject
Configuration options
Default is {}.
  • enableInputoptionalboolean
    Enable automatic input handling
    Default is true.
  • playerBodyIndexoptionalnumber
    Body index to apply input to
    Default is 0.
  • inputOptionsoptionalObject
    Options to pass to InputController
    Default is {}.
Example
const physics = new Physics();
await physics.init();
await physics.start();

// Input is handled automatically
const controller = new PhysicsController( physics );

// In render loop
function animate() {
  controller.update( delta );
  renderer.render( scene, camera );
}