Skip to content

@tmrw-realityos/worldDocs


@tmrw-realityos/world / World

Class: World

World is a collection of Entities and Components. The nodes of the entities are managed in a scene hierachy.

Example

Populate the world from a json file

ts
// Construct an empty world
const world = new World();
// Load entities
world.load("room.json");

Constructors

new World()

new World(): World

Create a new world with and empty entity.

Returns

World

Defined in

world/world.ts:41

Properties

boundNodes

boundNodes: Map<string, BaseComponent[]>

Defined in

world/world.ts:36


fx

fx: FXStack

Defined in

world/world.ts:34


rendererInterface?

optional rendererInterface: RendererInterface

Defined in

world/world.ts:33


root

root: Entity

Defined in

world/world.ts:31


scene

scene: Scene

Defined in

world/world.ts:32

Methods

add()

add(e): void

Adds an entity to the root node

Parameters

e: Entity

Returns

void

Defined in

world/world.ts:79


captureInput()

captureInput(node, component): void

Parameters

node: string

component: BaseComponent

Returns

void

Defined in

world/world.ts:103


configure()

configure(data): void

Parameters

data: WorldDescriptor

Returns

void

Defined in

world/world.ts:56


findComponent()

findComponent<Type>(ctor): undefined | Type

Search a component in this entity and its children

Type Parameters

Type extends BaseComponent

Parameters

ctor

Returns

undefined | Type

Defined in

world/world.ts:84


findEntityById()

findEntityById(name): undefined | Entity

Parameters

name: string

Returns

undefined | Entity

Defined in

world/world.ts:90


findEntityByName()

findEntityByName(name): undefined | Entity

Parameters

name: string

Returns

undefined | Entity

Defined in

world/world.ts:94


getBoundNodes()

getBoundNodes(node): undefined | BaseComponent[]

used to connect components with nodes hosted by other entities

Parameters

node: string

Returns

undefined | BaseComponent[]

Defined in

world/world.ts:99


load()

load(url): Promise<unknown>

loads one room

Parameters

url: string

Returns

Promise<unknown>

Defined in

world/world.ts:121


releaseInput()

releaseInput(node, component): void

Parameters

node: string

component: BaseComponent

Returns

void

Defined in

world/world.ts:112


update()

update(dt): void

Parameters

dt: number

Returns

void

Defined in

world/world.ts:52