Skip to content

@relu-interactives/spatial-ecs


@relu-interactives/spatial-ecs / components / StreamingComponent

Class: StreamingComponent ​

Defined in: components/Streaming.ts:30

Streams an entity and everything under it: its models load when the player comes within loadDistance and are freed from memory (geometry, textures, GPU) once they're further than unloadDistance. Put it on a model, or on a group to stream a whole region (a "cell") at once.

The gap between the two distances keeps a player standing on the edge from loading and freeing the same files over and over. The entity itself stays: its transform, physics (a trimesh collider keeps its shape), audio and scripts carry on, and while it's out of range it isn't drawn.

The editor always shows everything; streaming runs in Preview and in the published game. See the "Big Worlds and Performance" guide.

Extends ​

Constructors ​

Constructor ​

ts
new StreamingComponent(options?): StreamingComponent;

Defined in: components/Streaming.ts:53

Parameters ​

ParameterType
optionsStreamingOptions

Returns ​

StreamingComponent

Overrides ​

Component.constructor

Properties ​

PropertyTypeDefault valueDescriptionDefined in
enabledbooleantrueOff: always loaded, like an entity without the component.components/Streaming.ts:32
loadDistancenumber60Load within this many metres of the player (the camera unless a script picks something else).components/Streaming.ts:34
unloadDistancenumber0Free beyond this many metres. 0 means a quarter further than loadDistance. Never less than it.components/Streaming.ts:39
radiusnumber0Metres around the entity's origin that count as "here": distance is measured to this sphere's edge, so a big region loads before the player reaches its centre. The editor sets it from the region's bounds.components/Streaming.ts:45
prioritynumber0Higher loads first when several are waiting at the same distance.components/Streaming.ts:47
hideWhenUnloadedbooleantrueDon't draw anything under this entity while it's out of range.components/Streaming.ts:49
stateStreamingStateundefinedRuntime only: where it is. Never saved.components/Streaming.ts:51