voxel-control
manipulate voxel-physical objects using
a state object. implements basic FPS controls. is a through stream of sorts -- it relies
on voxel-engine to call control.tick(dt) to start producing events. it will buffer events
when paused.
options
{ speed: Number(0.0032)
, walkMaxSpeed: Number(0.0056)
, runMaxSpeed: Number(0.0112)
, jumpMaxSpeed: Number(0.016)
, jumpMaxTimer: Number(200)
, jumpSpeed: Number(0.004)
, jumpSpeedMove: Number(0.1)
, accelTimer: Number(200)
, accelerationCurve: Function()
, airControl: Boolean(true)
, fireRate: Number(0)
, discreteFire: Boolean(false)
, onfire: Function()
, rotationXMax: Number(33)
, rotationYMax: Number(33)
, rotationZMax: Number(33)
, rotationMax: Number(33)
, rotationXClamp: Number(Math.PI / 2)
, rotationYClamp: Number(Infinity)
, rotationZClamp: Number(0)
, rotationScale: Number(0.002) }
api
control(state, opts) -> Control
state is a state object (probably supplied by kb-controls).
opts is an object optionally containing any of the above.
Control#target(target?) -> target
target is the object to be manipulated. Assumed to have .acceleration, .velocity, and .atRestY() -> -1, 0, 1.
if a target is passed, set control to target that argument.
return the current target.
Control#tick(dt) -> undefined
advance the simulation. if there are any listeners for 'data', it will either buffer or emit a data event containing the control state at this tick.
interactStream.pipe(controls) -> controls
the interact module emits dx/dy/dz modifications from mouse movements / pointer lock; it can be piped to this stream.
license
MIT