Skip to content

@bendyline/molen-client/vehicles ​

Molen rendering client: three.js wrapper, snapshot sync, interpolation.

ts
import { /* … */ } from '@bendyline/molen-client/vehicles';

Interfaces ​

RailVehicleProxyDimensions ​

What a rail vehicle stand-in is built from (a rail VehicleSpec satisfies it).

Properties ​

height ​
ts
height: number;
length ​
ts
length: number;
rail? ​
ts
optional rail?: object;
profile? ​
ts
optional profile?: RailVehicleProfile;
truckCenters ​
ts
truckCenters: number;
wheelRadius ​
ts
wheelRadius: number;
width ​
ts
width: number;

VehicleCameraOptions ​

Properties ​

lookPitch? ​
ts
optional lookPitch?: number;
lookYaw? ​
ts
optional lookYaw?: number;
motion? ​
ts
optional motion?: PilotMotionPose;

The pilot's body under load, from a PilotMotion (@bendyline/molen-client/aircraft): the eye moves off the authored eye point and the head turns a little with it. Aircraft cockpit views only; chase views stay steady.

obstructionDistance? ​
ts
optional obstructionDistance?: (from, to) => number | undefined;

Distance to the first static obstruction between two absolute world points.

Parameters ​
from ​

[number, number, number]

to ​

[number, number, number]

Returns ​

number | undefined

shake? ​
ts
optional shake?: object;

Shake the seated view of an aircraft: amount 0–1 (its aircraftState.buffet) at time seconds on any steadily advancing clock. The eye moves about a centimeter and the view a few tenths of a degree, about ten times a second. Chase views stay steady.

amount ​
ts
amount: number;
time ​
ts
time: number;
view ​
ts
view: "cockpit" | "chase";

VehicleCameraPose ​

Extended by ​

Properties ​

lookAt ​
ts
lookAt: [number, number, number];
pitch ​
ts
pitch: number;
position ​
ts
position: [number, number, number];
yaw ​
ts
yaw: number;

VehicleProxyDimensions ​

The dimensions a vehicle proxy is built from (a VehicleSpec satisfies it).

Properties ​

height ​
ts
height: number;
length ​
ts
length: number;
wheelbase ​
ts
wheelbase: number;
wheelRadius ​
ts
wheelRadius: number;
wheelTrack ​
ts
wheelTrack: number;
width ​
ts
width: number;

VehicleVisual ​

Properties ​

animation? ​
ts
optional animation?: ModelSignalVisual;

The visual's exterior animation bindings, posed from the same signals as the interior.

glass? ​
ts
optional glass?: GlassVisual;
interior? ​
ts
optional interior?: ModelSignalVisual;
object ​
ts
object: Object3D;

Methods ​

dispose() ​
ts
dispose(): void;
Returns ​

void

setLivery() ​
ts
setLivery(data): void;
Parameters ​
data ​

LiveryData | undefined

Returns ​

void

update() ​
ts
update(
   steer, 
   wheelAngle, 
   signals?, 
   timeSeconds?, 
   glassState?, 
   damageState?
): void;
Parameters ​
steer ​

number

wheelAngle ​

number

signals? ​

Readonly<Record<string, number | undefined>>

timeSeconds? ​

number

glassState? ​

GlassStateData

damageState? ​

VehicleDamageState

Returns ​

void

updateShadows() ​
ts
updateShadows(texel): void;

The sun shadow map's texel size in meters (Renderer.shadowTexelSize) while the view is from one of this vehicle's own seats. Hosts pass undefined for every other vehicle and view. While texels are coarser than SEAT_SHADOW_TEXEL the vehicle casts no sun shadow, until they are SEAT_SHADOW_RETURN or finer. It still receives shadows from terrain, buildings, trees, other vehicles and clouds.

Parameters ​
texel ​

number | undefined

Returns ​

void

Type Aliases ​

VehicleInteriorSignals ​

ts
type VehicleInteriorSignals = ModelSignals;

VehicleInteriorVisual ​

ts
type VehicleInteriorVisual = ModelSignalVisual;

Variables ​

vehicleProxyMaterial ​

ts
const vehicleProxyMaterial: THREE.MeshStandardMaterial;

The shared vertex-coloured material of parked and proxy vehicles.

Functions ​

createParkedVehicleBatch() ​

ts
function createParkedVehicleBatch(placements, origin?): Group;

Dormant terrain-owned cars merged into one static mesh per tile. A plain mesh shares its compiled shader with every other tile; an instanced batch per model and paint would build one of its own. userData.vehicleIds[i] owns vertex range userData.vehicleRanges[2i..2i+1]; hide and restore a car with setParkedVehicleHidden.

Parameters ​

placements ​

readonly VehiclePlacement[]

origin? ​

[number, number]

Returns ​

Group


createParkedVehicleInstances() ​

ts
function createParkedVehicleInstances(placements, origin?): Group;

Dormant cars as one instanced mesh per body size, for a car park of hundreds where a merged batch would cost more than the building. Each mesh keeps the batch's vehicleIds contract: instance i belongs to userData.vehicleIds[i], and setParkedVehicleHidden hides it.

Parameters ​

placements ​

readonly VehiclePlacement[]

origin? ​

[number, number]

Returns ​

Group


createVehicleInteriorVisual() ​

ts
function createVehicleInteriorVisual(model, spec): ModelSignalVisual;

Vehicle convenience wrapper around the platform's model-signal binding system.

Parameters ​

model ​

Object3D

spec ​

VehicleInteriorSpec

Returns ​

ModelSignalVisual


createVehicleVisual() ​

ts
function createVehicleVisual(
   model, 
   vehicle, 
   livery?, 
   glassData?
): VehicleVisual;

Bind a loaded entity GLB to generic wheel/steering animation using external node names.

The simulation leans the whole model with its sprung body (vehicleState.bodyRoll and bodyPitch). Given those as signals, the wheels take up the lean as suspension travel instead: each moves along the body's up axis to keep its centre at its resting height, so the outside wheels stay on the road in a turn rather than sinking into it.

Parameters ​

model ​

Object3D

vehicle ​

Pick<VehicleData, "visual"> & object

livery? ​

LiveryData

glassData? ​

GlassData

Returns ​

VehicleVisual


isParkedVehicleHidden() ​

ts
function isParkedVehicleHidden(batch, index): boolean;

Whether setParkedVehicleHidden currently hides car index of a parked batch.

Parameters ​

batch ​

Mesh

index ​

number

Returns ​

boolean


railVehicleProxyGeometry() ​

ts
function railVehicleProxyGeometry(spec): BufferGeometry;

Low-detail stand-in for a rail vehicle seen from a distance: a parked cut of cars in a yard, or far traffic. One silhouette per rail.profile (boxcar, covered hopper, tank car, gondola, flatcar with a load, double-stack well car, autorack, road locomotive, bilevel coach, light-rail car) over two dark trucks. Front +Z, +X the left side, y = 0 the top of rail. The painted faces come first (userData.bodyVertices) so a batch tints the body and never the running gear. A few dozen triangles, one material, no textures. Never dispose the cached result.

Parameters ​

spec ​

RailVehicleProxyDimensions

Returns ​

BufferGeometry


setParkedVehicleHidden() ​

ts
function setParkedVehicleHidden(
   batch, 
   index, 
   hidden
): boolean;

Hide (collapse to a point) or restore one car of a parked batch, e.g. while its detailed model or a driven entity stands in for it. Returns whether the geometry changed.

Parameters ​

batch ​

Mesh

index ​

number

hidden ​

boolean

Returns ​

boolean


threeWheelerProxyGeometry() ​

ts
function threeWheelerProxyGeometry(spec): BufferGeometry;

Street-distance silhouette of a parked auto-rickshaw: a body tapering to the nose under a canvas canopy on four posts, a windscreen, one front and two rear tyres. About 170 triangles, one material, painted faces first. Never dispose the cached result.

Parameters ​

spec ​

VehicleProxyDimensions

Returns ​

BufferGeometry


twoWheelerProxyGeometry() ​

ts
function twoWheelerProxyGeometry(spec): BufferGeometry;

Street-distance silhouette of a parked motorcycle, scooter or moped: two tyres in line, a painted body and front shield, seat and bars. About 110 triangles, one material, painted faces first. Never dispose the cached result.

Parameters ​

spec ​

VehicleProxyDimensions

Returns ​

BufferGeometry


vehicleCameraPose() ​

ts
function vehicleCameraPose(
   transform, 
   spec, 
   options
): VehicleCameraPose;

Seat-space cockpit and collision-shortened chase views for any vehicle host.

Parameters ​

transform ​
pos ​

[number, number, number]

rot ​

[number, number, number, number]

spec ​

Pick<VehicleSpec, "driverEye" | "length">

options ​

VehicleCameraOptions

Returns ​

VehicleCameraPose


vehicleObstacleContacts() ​

ts
function vehicleObstacleContacts(probes, scene): AircraftContact[];

Contact normals from streamed geometry and nearby parked vehicles, in absolute coordinates.

Parameters ​

probes ​

readonly AircraftCollisionProbe[]

scene ​

AircraftObstacleScene

Returns ​

AircraftContact[]


vehicleProxyGeometry() ​

ts
function vehicleProxyGeometry(spec): BufferGeometry;

Shared street-distance silhouette for parked cars and instanced traffic. Painted faces come first so a static batch can tint the body and roof without tinting the glass, tyres or lamps. 148 triangles, one material, no textures or model downloads. Never dispose the cached result.

Parameters ​

spec ​

VehicleProxyDimensions

Returns ​

BufferGeometry

50 guides · 44 schema formats · 51 API entry points · 11 samples. API, CLI and schema pages are generated from the shipped build.