@lightningjs/renderer
    Preparing search index...

    Class Stage

    Index

    Constructors

    Properties

    animationManager: AnimationManager
    boundsMargin: [number, number, number, number]
    bufferMemory: number = 2e6
    calculateTextureCoord: boolean
    contextSpy: null | ContextSpy = null
    currentFrameTime: number = 0
    defaultTexture: null | Texture = null
    defShaderNode: null | CoreShaderNode<Record<string, unknown>> = null
    deltaTime: number = 0
    elapsedTime: number = 0
    eventBus: EventEmitter

    Renderer Event Bus for the Stage to emit events onto

    In reality this is just the RendererMain instance, which is an EventEmitter. this allows us to directly emit events from the Stage to RendererMain without having to set up forwarding handlers.

    fontHandlers: Record<string, FontHandler> = {}
    interactiveNodes: Set<CoreNode> = ...
    lastFrameTime: number = 0
    options: StageOptions
    pixelRatio: number
    platform: Platform | WebPlatform
    preloadBound: Bound
    renderer: CoreRenderer
    root: CoreNode
    shManager: CoreShaderManager
    startTime: number = 0
    strictBound: Bound
    targetFrameTime: number = 0

    Target frame time in milliseconds (calculated from targetFPS)

    This is pre-calculated to avoid recalculating on every frame.

    • 0 means no throttling (use display refresh rate)
    • 0 means throttle to this frame time (1000 / targetFPS)

    textRenderers: Record<string, TextRenderer> = {}
    txMemManager: TextureMemoryManager

    Accessors

    Methods

    • Cleanup Orphaned Textures

      Parameters

      • full: boolean = false

      Returns void

      This method is used to cleanup orphaned textures that are no longer in use.

    • Emit all queued frame events

      Returns void

      This method should be called after the frame has been rendered to emit all events that were queued during the frame.

      See queueFrameEvent for more information.

    • Load a font using a specific text renderer type

      Parameters

      • rendererType: TextRenderers

        The type of text renderer ('canvas', 'sdf', etc.)

      • options: FontLoadOptions

        Font loading options specific to the renderer type

      Returns Promise<void>

      Promise that resolves when the font is loaded

      This method allows consumers to explicitly load fonts for a specific text renderer type (e.g., 'canvas', 'sdf'). Consumers must specify the renderer type to ensure fonts are loaded with the correct pipeline.

      For Canvas fonts, provide fontUrl (e.g., .ttf, .woff, .woff2) For SDF fonts, provide atlasUrl (image) and atlasDataUrl (JSON glyph data)

    • Queue an event to be emitted after the current/next frame is rendered

      Parameters

      • name: string
      • data: unknown

      Returns void

      When we are operating in the context of the render loop, we may want to emit events that are related to the current frame. However, we generally do NOT want to emit events directly in the middle of the render loop, since this could enable event handlers to modify the scene graph and cause unexpected behavior. Instead, we queue up events to be emitted and then flush the queue after the frame has been rendered.

    • Request a render pass without forcing an update

      Returns void

    • Resolves the default property values for a Node

      Parameters

      Returns CoreNodeProps

      This method is used internally by the RendererMain to resolve the default property values for a Node. It is exposed publicly so that it can be used by Core Driver implementations.

    • Given a font name, and possible renderer override, return the best compatible text renderer.

      Parameters

      • trProps: TrProps
      • textRendererOverride:
            | null
            | number
            | typeof iterator
            | "length"
            | "toString"
            | "charAt"
            | "charCodeAt"
            | "concat"
            | "indexOf"
            | "lastIndexOf"
            | "localeCompare"
            | "match"
            | "replace"
            | "search"
            | "slice"
            | "split"
            | "substring"
            | "toLowerCase"
            | "toLocaleLowerCase"
            | "toUpperCase"
            | "toLocaleUpperCase"
            | "trim"
            | "substr"
            | "valueOf"
            | "codePointAt"
            | "includes"
            | "endsWith"
            | "normalize"
            | "repeat"
            | "startsWith"
            | "anchor"
            | "big"
            | "blink"
            | "bold"
            | "fixed"
            | "fontcolor"
            | "fontsize"
            | "italics"
            | "link"
            | "small"
            | "strike"
            | "sub"
            | "sup"
            | "padStart"
            | "padEnd"
            | "trimEnd"
            | "trimStart"
            | "trimLeft"
            | "trimRight"
            | "matchAll"
            | "replaceAll"
            | "at" = null

      Returns null | TextRenderer

      Will try to return a canvas renderer if no other suitable renderer can be resolved.

    • Parameters

      • value: number | [number, number, number, number]

      Returns void

    • Update the target frame time based on the current targetFPS setting

      Returns void

      This should be called whenever the targetFPS option is changed to ensure targetFrameTime stays in sync. targetFPS of 0 means no throttling (targetFrameTime = 0) targetFPS > 0 means throttle to 1000/targetFPS milliseconds