rhodonite
    Preparing search index...

    Class Engine

    The system class is the entry point of the Rhodonite library.

    const engine = await Rn.Engine.init({
    approach: Rn.ProcessApproach.WebGL2,
    canvas: document.getElementById('world') as HTMLCanvasElement,
    });

    ... (create something) ...

    engine.startRenderLoop((time, _myArg1, _myArg2) => {
    Rn.Engine.process([expression]);
    }, myArg1, myArg2);

    Hierarchy (View Summary)

    Index
    _tags: RnTags = {}

    Collection of tags associated with this object

    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    • get componentMemoryRegistry(): ComponentMemoryRegistry

      Returns ComponentMemoryRegistry

    • get config(): Config

      Returns Config

    • get engineUid(): number

      Returns number

    • get gpuTimeMilliseconds(): number | undefined

      The GPU time spent on the latest measured process() call, in milliseconds.

      Returns number | undefined

      Undefined until a result is available, or when gpuTimerEnabled is false or the environment does not support GPU timer queries. GPU results arrive asynchronously, so the value lags behind by a few frames. In WebGPU it is the sum of the durations of the render passes; in WebGL2 it is the time the GPU spent on all the commands issued during process().

    • get gpuTimerEnabled(): boolean

      Whether the GPU time of each process() call is measured.

      Returns boolean

      Disabled by default. Measuring uses GPU timer queries (EXT_disjoint_timer_query_webgl2 in WebGL2, the timestamp-query feature in WebGPU), which add a small overhead. See gpuTimeMilliseconds.

    • set gpuTimerEnabled(flag: boolean): void

      Parameters

      • flag: boolean

      Returns void

    • get isGpuTimerSupported(): boolean

      Whether the GPU time can be measured in this environment. Browsers may not expose GPU timer queries (e.g. for privacy reasons or on some platforms).

      Returns boolean

    • get logger(): Logger

      Returns Logger

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get shaderProgramCache(): Map<string, number>
      Internal

      Gets the shader program cache for this engine instance. This cache maps shader text to compiled shader program UIDs. Each engine has its own cache to prevent cross-contamination between WebGL contexts.

      Returns Map<string, number>

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • get webARSystem(): WebARSystem

      Returns WebARSystem

    • get processTime(): number

      Returns number

    • get timeAtProcessBegin(): number

      Returns number

    • get timeAtProcessEnd(): number

      Returns number

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Destroys the engine and releases all associated resources.

      Returns void

      This method performs a comprehensive cleanup of all engine resources including:

      • Stopping the render loop
      • Invalidating all shader caches in materials
      • Deleting all entities and their components
      • Destroying all textures (including dummy textures)
      • Clearing material repository data
      • Releasing GPU resources (WebGL/WebGPU)
      • Clearing memory manager buffers

      After calling this method, the engine instance should not be used.

    • Returns [number, number]

    • Retrieves a complete tag object (name and value) for the specified tag name

      Parameters

      • tagName: string

        The name of the tag to retrieve

      Returns Tag

      A Tag object containing the name and value

    • Retrieves the value associated with a specific tag name

      Parameters

      • tagName: string

        The name of the tag whose value to retrieve

      Returns any

      The tag value, or undefined if the tag doesn't exist

    • Checks whether this object has a tag with the specified name

      Parameters

      • tagName: string

        The name of the tag to check for

      Returns boolean

      True if the tag exists (value is not null/undefined), false otherwise

    • Checks if this object has a tag with the specified name and value

      Parameters

      • tagName: string

        The tag name to match

      • tagValue: string

        The tag value to match

      Returns boolean

      True if the object has a matching tag, false otherwise

    • Checks if this object has all the specified tags with exactly matching values

      Parameters

      • tags: RnTags

        Object containing tag names as keys and expected values

      Returns boolean

      True if all specified tags exist with matching values, false otherwise

    • Checks if the object's combined tag string contains all the provided search strings. This allows for flexible searching within tag names and values.

      Parameters

      • stringArray: string[]

        Array of strings that must all be present in the combined tag string

      Returns boolean

      True if all strings are found in the combined tag string, false otherwise

    • A process method to render a scene

      Parameters

      Returns void

      You need to call this method for rendering.

    • A process method to render a scene

      Parameters

      Returns void

      You need to call this method for rendering.

    • A Simple version of process method

      Parameters

      • clearColor: Vector4 = ...

        color to clear the canvas

      Returns void

      No need to create expressions and renderPasses and to register entities, etc... It's suitable for simple use cases like sample apps.

    • Removes a tag from this object

      Parameters

      • tagName: string

        The name of the tag to remove

      Returns void

    • Parameters

      • width: number
      • height: number

      Returns void

    • Restart a render loop.

      Returns void

    • Starts a render loop.

      Parameters

      • renderLoopFunc: (time: number, ...args: any[]) => void

        function to be called in each frame

      • ...args: any[]

        arguments you want to be passed to renderLoopFunc

      Returns void

      Rn.Engine.startRenderLoop((time, _myArg1, _myArg2) => {
      Rn.Engine.process([expression]);
      }, myArg1, myArg2);
    • Stops a existing render loop.

      Returns void

    • Attempts to set a tag on this object. If the tag already exists, it will be replaced.

      Parameters

      • tag: Tag

        The tag object containing the name and value to set

      Returns boolean

      True if the tag was successfully set, false if the tag name contains invalid characters

    • Attempts to set a unique name for this object

      Parameters

      • name: string

        The desired unique name

      • toAddNameIfConflict: boolean

        If true, appends UID to make name unique when conflicts occur; if false, fails on conflict

      Returns boolean

      True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false

    • Unregisters this object from all tracking collections. Should be called when the object is being destroyed.

      Returns void

    • Validates that a tag string contains only allowed characters (alphanumeric and underscore)

      Parameters

      • val: string

        The string to validate

      Returns boolean

      True if the string contains only valid characters, false if it contains invalid characters

    • Internal

      Resets all static object tracking data. Used primarily for testing.

      Returns void

    • Parameters

      Returns void

    • Parameters

      • objectUid: number

      Returns Engine | undefined

    • Retrieves an RnObject instance by its unique identifier

      Parameters

      • objectUid: number

        The unique identifier of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Retrieves an RnObject instance by its unique name

      Parameters

      • uniqueName: string

        The unique name of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Initialize the Rhodonite system.

      Parameters

      • desc: EngineInitDescription

      Returns Promise<Engine>

      Don't forget await to use this method.

      const engine = await Rn.Engine.init({
      approach: Rn.ProcessApproach.WebGL2,
      canvas: document.getElementById('world') as HTMLCanvasElement,
      });
    • Searches for the first object that has a specific tag with the given value

      Parameters

      • tag: string

        The tag name to search for

      • value: string

        The tag value to match

      Returns WeakRef<RnObject> | undefined

      WeakRef to the first matching object, or undefined if not found