@lightningjs/renderer
    Preparing search index...

    Class Stage

    Index

    Constructors

    Properties

    activeAnimationCount: number = 0

    Global count of active animations (internal + external).

    Incremented by AnimationManager when an internal animation starts, decremented when it stops. External animation libraries (e.g. AnimeJS, GSAP) increment/decrement this counter via RendererMain.registerAnimation / RendererMain.unregisterAnimation.

    Used by the render loop to throttle texture uploads during animations: while > 0, at most maxTextureUploadsDuringAnimation textures are uploaded per frame to preserve the frame budget. When zero, the full time budget is used.

    animationManager: AnimationManager
    boundsMargin: [number, number, number, number]
    bufferMemory: number = 2e6
    calculateTextureCoord: boolean
    contextSpy: null | ContextSpy = null
    currentFrameCounter: null | FrameCounter = 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
    quadsPayload: QuadsUpdatePayload = ...
    renderer: CoreRenderer
    renderListLen: number = 0
    renderListNodes: CoreNode[] = []
    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

    • Walk a node's subtree and feed quads + stencil clip ops to the active renderer without touching the cached render list.

      Parameters

      • node: CoreNode

        Root of the subtree to render

      Returns void

      Used by the render-to-texture path, which draws each RTT subtree to its own framebuffer immediately and then flushes the renderer's operation queue.

    • Cleanup Orphaned Textures

      Parameters

      • full: boolean = false

      Returns void

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

    • Destroy the stage and release all resources.

      Returns void

      This method stops the render loop, destroys all nodes, releases all textures and GPU resources, and terminates any background workers.

    • 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

    • Mark the render list as dirty, triggering a rebuild on the next frame.

      Returns void

      Called by CoreNode when the scene structure changes (child add/remove, visibility toggle, z-index re-sort). Deduplicated: if the list is already dirty, this is a no-op.

    • 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

    • Parameters

      • newBoundaries: number[]

      Returns void

    • Parameters

      • newInterval: 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