agent driver

How an agent drives: with the controls, never by moving things. An AgentDriver turns a command into ControlInput each frame, which the controllable in focus merges in place of the player's (see agents). So an agent's car obeys the same grip, walls and traffic as yours, and anything it can do, a player could.

Two commands:

Any deliberate input from the player cancels the command: the player's own hands always win. Pure: no Babylon, no clock (time is the dt it is given).

import { AgentDriver } from 'tosijs-3d/agent-driver'
const d = new AgentDriver()
d.go({ x: 30, z: 40 }, { place: 'harbour', speed: 12 })
const input = d.step(dt, { x, z, heading, speed })   // each frame
d.status   // { state: 'running', distance: 41.2, … } → 'arrived'