Skip to content

@bendyline/molen-ambient/client ​

Molen ambient-life capability: transport networks built from roads, rail and paths, with lane-following NPC cars, trains, aircraft and pedestrians spawned around an observer (kernel) and instanced rendering (client).

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

Classes ​

AmbientFigures ​

Constructors ​

Constructor ​
ts
new AmbientFigures(prepare?): AmbientFigures;
Parameters ​
prepare? ​

(object) => void

Returns ​

AmbientFigures

Properties ​

group ​
ts
readonly group: Group;

Accessors ​

count ​
Get Signature ​
ts
get count(): number;
Returns ​

number

Methods ​

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

void

setBudget() ​
ts
setBudget(budget): void;
Parameters ​
budget ​

Partial<FigureBudget>

Returns ​

void

update() ​
ts
update(
   walkers, 
   camera, 
   tick, 
   tickRate
): void;

Update every walker for this frame.

Parameters ​
walkers ​

readonly WalkerView[]

camera ​

readonly [number, number, number]

tick ​

number

tickRate ​

number

Returns ​

void


ProxyBatches ​

Constructors ​

Constructor ​
ts
new ProxyBatches(prepare?, initialCapacity?): ProxyBatches;
Parameters ​
prepare? ​

(object) => void

initialCapacity? ​

number

Returns ​

ProxyBatches

Properties ​

group ​
ts
readonly group: Group;

Accessors ​

meshCount ​
Get Signature ​
ts
get meshCount(): number;

Number of instanced meshes (draw calls when all are populated).

Returns ​

number

Methods ​

add() ​
ts
add(instance): void;
Parameters ​
instance ​

ProxyInstance

Returns ​

void

begin() ​
ts
begin(camera): void;

Start a frame: keep the anchor within a few hundred metres of the camera.

Parameters ​
camera ​

readonly [number, number, number]

Returns ​

void

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

void

end() ​
ts
end(): number;

Finish a frame: upload what changed and cull empty batches from drawing.

Returns ​

number

Interfaces ​

AmbientAircraftModels ​

Methods ​

aircraft() ​
ts
aircraft(type): AircraftSpec | undefined;

The aircraft spec (rotor and gear bindings) of a type, if it is an aircraft type.

Parameters ​
type ​

string

Returns ​

AircraftSpec | undefined

load() ​
ts
load(type): Promise<Object3D<Object3DEventMap> | undefined>;
Parameters ​
type ​

string

Returns ​

Promise&lt;Object3D&lt;Object3DEventMap&gt; | undefined&gt;


AmbientRenderBudget ​

Properties ​

detailedCars ​
ts
detailedCars: number;

Cars drawn with their full model at most.

figureRadius ​
ts
figureRadius: number;

Pedestrians beyond this distance (m) are not drawn.

posesPerFrame ​
ts
posesPerFrame: number;

Pedestrian pose evaluations per frame.

skinnedFigures ​
ts
skinnedFigures: number;

Animated (skinned) pedestrians at most.


AmbientRenderer ​

Properties ​

object ​
ts
readonly object: Group;

Methods ​

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

void

setBudget() ​
ts
setBudget(budget): void;
Parameters ​
budget ​

Partial&lt;AmbientRenderBudget&gt;

Returns ​

void

setVisible() ​
ts
setVisible(visible): void;
Parameters ​
visible ​

boolean

Returns ​

void

stats() ​
ts
stats(): AmbientRenderStats;
Returns ​

AmbientRenderStats

update() ​
ts
update(camera, dt): void;

Draw the current world state; camera is the absolute camera position.

Parameters ​
camera ​

readonly [number, number, number]

dt ​

number

Returns ​

void


AmbientRendererOptions ​

Properties ​

aircraft? ​
ts
optional aircraft?: AmbientAircraftModels;

Aircraft models (absent: proxies only).

budget? ​
ts
optional budget?: Partial<AmbientRenderBudget>;
heights? ​
ts
optional heights?: Readonly<Record<string, number>>;

Body heights by type id, for proxies (the kernel stores length and width only).

parent ​
ts
parent: Object3D;

Parent in absolute world coordinates (e.g. the terrain stream object).

prepare? ​
ts
optional prepare?: (object) => void | Promise<void>;

Shader warm-up for new objects (e.g. renderer.prepareObject).

Parameters ​
object ​

Object3D

Returns ​

void | Promise&lt;void&gt;

vehicles? ​
ts
optional vehicles?: AmbientVehicleModels;

Full vehicle models for nearby cars (absent: proxies only).

world ​
ts
world: World;

AmbientRenderStats ​

Properties ​

aircraft ​
ts
aircraft: number;
cars ​
ts
cars: number;
detailedCars ​
ts
detailedCars: number;
drawBatches ​
ts
drawBatches: number;
figures ​
ts
figures: number;
pedestrians ​
ts
pedestrians: number;
proxies ​
ts
proxies: number;
trains ​
ts
trains: number;

AmbientVehicleKindOptions ​

Properties ​

heights? ​
ts
optional heights?: Readonly<Record<string, number>>;

Body heights by type id (default: from the shape).


AmbientVehicleModels ​

Where full vehicle models come from (absent: every car stays a proxy).

Methods ​

load() ​
ts
load(type): Promise<Object3D<Object3DEventMap> | undefined>;

A fresh model instance for a type, or undefined when the type has no model.

Parameters ​
type ​

string

Returns ​

Promise&lt;Object3D&lt;Object3DEventMap&gt; | undefined&gt;

vehicle() ​
ts
vehicle(type): VehicleData | undefined;

The vehicle data (wheel nodes, paint material, spec) of a type, if it is a vehicle type.

Parameters ​
type ​

string

Returns ​

VehicleData | undefined


DetailCandidate ​

Properties ​

color ​
ts
color: string;
distance ​
ts
distance: number;
id ​
ts
id: string;
type ​
ts
type: string;

FigureBudget ​

Properties ​

posesPerFrame ​
ts
posesPerFrame: number;

Pose evaluations per frame (nearest first, the rest round-robin).

radius ​
ts
radius: number;

Figures beyond this radius (m) are not drawn.

skinned ​
ts
skinned: number;

Skinned (animated) figures at most.


ProxyDimensions ​

Properties ​

height ​
ts
height: number;
length ​
ts
length: number;
width ​
ts
width: number;

ProxyInstance ​

Properties ​

color ​
ts
color: Color;
dims ​
ts
dims: ProxyDimensions;
pos ​
ts
pos: readonly [number, number, number];
rot ​
ts
rot: readonly [number, number, number, number];
scale ​
ts
scale: number;
shape ​
ts
shape: ProxyShape;

WalkerView ​

Properties ​

figure ​
ts
figure: FigureData;
hidden ​
ts
hidden: boolean;
id ​
ts
id: string;
pos ​
ts
pos: readonly [number, number, number];
rot ​
ts
rot: readonly [number, number, number, number];
since ​
ts
since: number;
speed ​
ts
speed: number;

Type Aliases ​

ProxyShape ​

ts
type ProxyShape = "car" | "bus" | "rail" | "aircraft";

Functions ​

ambientVehicleKind() ​

ts
function ambientVehicleKind(options?): RenderableKind;

The ambient-vehicle renderable kind (proxy meshes) for Worker-hosted scenes.

Parameters ​

options? ​

AmbientVehicleKindOptions

Returns ​

RenderableKind


createAmbientRenderer() ​

ts
function createAmbientRenderer(options): AmbientRenderer;

Parameters ​

options ​

AmbientRendererOptions

Returns ​

AmbientRenderer


proxyGeometry() ​

ts
function proxyGeometry(shape, dims): BufferGeometry;

Cached geometry for a shape at given dimensions (rounded to 10 cm). Never dispose it.

Parameters ​

shape ​

ProxyShape

dims ​

ProxyDimensions

Returns ​

BufferGeometry


proxyHeight() ​

ts
function proxyHeight(
   shape, 
   length, 
   width, 
   type
): number;

Default body height for a proxy when the type gives none.

Parameters ​

shape ​

ProxyShape

length ​

number

width ​

number

type ​

string

Returns ​

number


proxyShapeFor() ​

ts
function proxyShapeFor(kind, length): ProxyShape;

The shape to draw for an agent kind and its dimensions.

Parameters ​

kind ​

string

length ​

number

Returns ​

ProxyShape

37 guides · 36 schema formats · 41 API entry points · 10 samples. API, CLI and schema pages are generated from the shipped build.