rhodonite
    Preparing search index...

    Class Frame

    Frame manages expressions and their input/output dependencies in the rendering pipeline.

    The Frame class serves as a container for multiple rendering expressions and handles the complex relationships between render passes, including input dependencies and output framebuffer assignments. It provides mechanisms for querying color attachments from input render passes and resolving dependencies between expressions.

    const frame = new Frame();
    frame.addExpression(myExpression, {
    inputRenderPasses: [shadowPass, geometryPass],
    outputs: [{
    renderPass: { index: 0 },
    frameBuffer: myFrameBuffer
    }]
    });
    frame.resolve();

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _tags: RnTags = {}

    Collection of tags associated with this object

    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    FrameBuffer: "FrameBuffer" = 'FrameBuffer'

    Constant identifier for standard framebuffer type

    InvalidObjectUID: -1

    Invalid object UID constant

    ResolveFrameBuffer: "ResolveFrameBuffer" = 'ResolveFrameBuffer'

    Constant identifier for resolve framebuffer type

    ResolveFrameBuffer2: "ResolveFrameBuffer2" = 'ResolveFrameBuffer2'

    Constant identifier for secondary resolve framebuffer type

    Accessors

    • get expressions(): Expression[]

      Gets a read-only array of all expressions currently registered in this frame.

      Returns Expression[]

      Array of Expression objects in the order they were added

      const allExpressions = frame.expressions;
      console.log(`Frame contains ${allExpressions.length} expressions`);
    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    Methods

    • Adds a rendering expression to this frame with optional input dependencies and output configurations.

      This method registers an expression within the frame and establishes its relationships with input render passes and output framebuffers. The expression will be executed in the order it was added to the frame.

      Parameters

      • expression: Expression

        The rendering expression to add to this frame

      • options: {
            inputRenderPasses?: RenderPass[];
            outputs?: {
                frameBuffer: FrameBuffer;
                renderPass: RequireOne<
                    { index?: number; instance?: RenderPass; uniqueName?: string },
                >;
            }[];
        } = ...

        Configuration object for input dependencies and outputs

        • OptionalinputRenderPasses?: RenderPass[]

          Array of render passes that this expression depends on

        • Optionaloutputs?: {
              frameBuffer: FrameBuffer;
              renderPass: RequireOne<
                  { index?: number; instance?: RenderPass; uniqueName?: string },
              >;
          }[]

          Array of output configurations specifying which render passes should render to which framebuffers

      Returns void

      frame.addExpression(lightingExpression, {
      inputRenderPasses: [geometryPass, shadowPass],
      outputs: [{
      renderPass: { index: 0 },
      frameBuffer: screenFrameBuffer
      }]
      });
    • Removes all expressions from this frame and clears associated caches.

      This method resets the frame to its initial empty state, removing all registered expressions and clearing internal caches. Any pending expression queries will also be implicitly cleared.

      Returns void

      frame.clearExpressions();
      // Frame is now empty and ready for new expressions
    • Retrieves a color attachment render target texture from an input render pass of the specified expression.

      This method creates a promise-based query system that allows expressions to access color attachment textures from their input render passes. The actual texture retrieval is deferred until the resolve() method is called, enabling proper dependency resolution.

      Parameters

      • inputFrom: Expression

        The expression from which to retrieve the color attachment

      • renderPassArg: {
            colorAttachmentIndex: number;
            framebufferType:
                | "FrameBuffer"
                | "ResolveFrameBuffer"
                | "ResolveFrameBuffer2";
            renderPass: RequireOne<
                { index?: number; instance?: RenderPass; uniqueName?: string },
            >;
        } = ...

        Configuration object specifying the render pass and attachment details

        • colorAttachmentIndex: number

          Index of the color attachment to retrieve (default: 0)

        • framebufferType: "FrameBuffer" | "ResolveFrameBuffer" | "ResolveFrameBuffer2"

          Type of framebuffer to query (default: 'FrameBuffer')

        • renderPass: RequireOne<{ index?: number; instance?: RenderPass; uniqueName?: string }>

          Identifier for the target render pass (by index, name, or instance)

      Returns Promise<RenderTargetTexture>

      Promise that resolves to the requested RenderTargetTexture

      const colorTexture = await frame.getColorAttachmentFromInputOf(geometryExpression, {
      renderPass: { index: 0 },
      colorAttachmentIndex: 0,
      framebufferType: Frame.FrameBuffer
      });
    • 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

    • Resolves all pending expression queries and establishes texture dependencies.

      This method processes all queued color attachment queries created by getColorAttachmentFromInputOf() calls. It matches expressions with their corresponding render passes and retrieves the requested color attachment textures, fulfilling the associated promises.

      This method should be called after all expressions have been added and all color attachment queries have been registered, typically before beginning the actual rendering process.

      Returns void

      // Add all expressions and set up queries
      frame.addExpression(expr1);
      frame.addExpression(expr2);
      await frame.getColorAttachmentFromInputOf(expr1, {...});

      // Resolve all dependencies
      frame.resolve();
    • Sets the viewport for all expressions in this frame.

      This method propagates the viewport settings to all registered expressions, ensuring consistent rendering dimensions across the entire frame.

      Parameters

      • viewport: IVector4

        4D vector defining the viewport (x, y, width, height)

      Returns void

      frame.setViewport(Vector4.fromCopyArray([0, 0, 1920, 1080]));
      
    • 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

    • 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

    • 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

    • 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