dacha
    Preparing search index...

    Class World

    A world is the root container for all scenes and actors. It is also provide an access to system APIs.

    Hierarchy (View Summary)

    Index
    children: Scene[]

    Children of the entity

    data: Record<string, unknown>

    Custom data storage for world-related information

    id: string

    Id of the entity

    name: string

    Name of the entity

    parent: null

    Parent of the entity

    systemApi: SystemAPIRegistry

    Registry of system APIs

    • Adds an event listener to the event target.

      Type Parameters

      Parameters

      • type: T

        Type of event to listen for

      • callback: WorldListenerFn<T>

        Function to call when the event is triggered

      Returns void

    • Adds a child to the entity.

      Parameters

      • child: Scene

        Child to add

      Returns void

    • Dispatches an event to the event target.

      Events are processed in the engine event queue at the beginning of each frame in order that they were dispatched.

      Type Parameters

      Parameters

      • type: T

        Type of event to dispatch

      • ...payload: EventPayload<WorldEventMap, T>

        Payload of the event

      Returns void

    • Dispatches an event to the event target immediately.

      Events are processed immediately and not added to the engine event queue.

      Type Parameters

      Parameters

      • type: T

        Type of event to dispatch

      • ...payload: EventPayload<WorldEventMap, T>

        Payload of the event

      Returns void

    • Finds a child entity by a predicate function.

      Parameters

      • predicate: (child: Scene | Actor) => boolean

        A function that runs on each child entity and should return true if the child entity matches the predicate or false otherwise

      • recursive: boolean = true

        Whether to search recursively through the children

      Returns Scene | Actor | undefined

      Child entity or undefined

    • Finds a child entity by its id.

      Parameters

      • id: string

        Id of the child entity

      • recursive: boolean = true

        Whether to search recursively through the children

      Returns Scene | Actor | undefined

      Child entity or undefined

    • Finds a child entity by its name.

      Parameters

      • name: string

        Name of the child entity

      • recursive: boolean = true

        Whether to search recursively through the children

      Returns Scene | Actor | undefined

      Child entity or undefined

    • Removes the entity from its parent.

      Returns void

    • Removes all event listeners from the event target.

      Returns void

    • Removes a child from the entity.

      Parameters

      • child: Scene

        Child to remove

      Returns void

    • Removes an event listener from the event target.

      Type Parameters

      Parameters

      • type: T

        Type of event to remove the listener for

      • callback: WorldListenerFn<T>

        Function to remove the listener for

      Returns void