@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 ​
new StreamingComponent(options?): StreamingComponent;Defined in: components/Streaming.ts:53
Parameters ​
| Parameter | Type |
|---|---|
options | StreamingOptions |
Returns ​
StreamingComponent
Overrides ​
Properties ​
| Property | Type | Default value | Description | Defined in |
|---|---|---|---|---|
enabled | boolean | true | Off: always loaded, like an entity without the component. | components/Streaming.ts:32 |
loadDistance | number | 60 | Load within this many metres of the player (the camera unless a script picks something else). | components/Streaming.ts:34 |
unloadDistance | number | 0 | Free beyond this many metres. 0 means a quarter further than loadDistance. Never less than it. | components/Streaming.ts:39 |
radius | number | 0 | Metres 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 |
priority | number | 0 | Higher loads first when several are waiting at the same distance. | components/Streaming.ts:47 |
hideWhenUnloaded | boolean | true | Don't draw anything under this entity while it's out of range. | components/Streaming.ts:49 |
state | StreamingState | undefined | Runtime only: where it is. Never saved. | components/Streaming.ts:51 |

