@lightningjs/renderer
    Preparing search index...

    Class RendererMain

    The Renderer Main API

    This is the primary class used to configure and operate the Renderer.

    It is used to create and destroy Nodes, as well as Texture and Shader references.

    Example:

    import { RendererMain, MainCoreDriver } from '@lightningjs/renderer';

    // Initialize the Renderer
    const renderer = new RendererMain(
    {
    appWidth: 1920,
    appHeight: 1080
    },
    'app',
    new MainCoreDriver(),
    );

    Listen to events using the standard EventEmitter API:

    renderer.on('fpsUpdate', (data: RendererMainFpsUpdateEvent) => {
    console.log(`FPS: ${data.fps}`);
    });

    renderer.on('idle', (data: RendererMainIdleEvent) => {
    // Renderer is idle - no scene changes
    });

    RendererMain#fpsUpdate

    RendererMain#frameTick

    RendererMain#quadsUpdate

    RendererMain#idle

    RendererMain#criticalCleanup

    RendererMain#criticalCleanupFailed

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    canvas: HTMLCanvasElement
    root: INode
    stage: Stage

    Accessors

    • get targetFPS(): number

      Gets the target FPS for the global render loop

      Returns number

      The current target FPS (0 means no throttling)

      This controls the maximum frame rate of the entire rendering system. When 0, the system runs at display refresh rate.

    • set targetFPS(fps: number): void

      Sets the target FPS for the global render loop

      Parameters

      • fps: number

        The target FPS to set for the global render loop. Set to 0 or a negative value to disable throttling.

      Returns void

      This setting affects the entire rendering system immediately. All animations, rendering, and frame updates will be throttled to this target FPS. Provides global performance control.

      // Set global target to 30fps for better performance
      renderer.targetFPS = 30;

      // Disable global throttling (use display refresh rate)
      renderer.targetFPS = 0;

    Methods

    • Cleanup textures that are not being used

      Returns void

      This can be used to free up GFX memory used by textures that are no longer being displayed.

      This routine is also called automatically when the memory used by textures exceeds the critical threshold on frame generation OR when the renderer is idle and the memory used by textures exceeds the target threshold.

      NOTE: This is a heavy operation and should be used sparingly. NOTE2: This will not cleanup textures that are currently being displayed. NOTE3: This will not cleanup textures that are marked as preventCleanup. NOTE4: This has nothing to do with the garbage collection of JavaScript.

    • Create a new shader controller for a shader type

      Type Parameters

      • ShType extends string

      Parameters

      • shType: ShType
      • Optionalprops: OptionalShaderProps<T>

      Returns CoreShaderNode<ExtractProps<ShaderProps<any>>>

      This method creates a new Shader Controller for a specific shader type.

      If the shader has not been loaded yet, it will be loaded. Otherwise, the existing shader will be reused.

      It can be assigned to a Node's shader property.

    • Create a new scene graph text node

      Parameters

      Returns ITextNode

      A text node is the second graphical building block of the Renderer scene graph. It renders text using a specific text renderer that is automatically chosen based on the font requested and what type of fonts are installed into an app.

      See ITextNode for more details.

    • Parameters

      • event: string
      • Optionallistener: (target: any, data: any) => void

      Returns void

    • Re-render the current frame without advancing any running animations.

      Returns void

      Any state changes will be reflected in the re-rendered frame. Useful for debugging.

      May not do anything if the render loop is running on a separate worker.

    • Sets the clear color for the stage.

      Parameters

      • color: number

        The color to set as the clear color.

      Returns void