Class WebGLStrategyUniform

WebGL rendering strategy implementation using uniform-based approach. This strategy uses uniforms to pass per-object data to shaders instead of vertex attributes, which is more suitable for rendering multiple objects with different properties.

Implements

Methods

  • Loads and prepares mesh data for rendering. Sets up VBO (Vertex Buffer Object) and VAO (Vertex Array Object) if not already done.

    Parameters

    • meshComponent: MeshComponent

      The mesh component containing the mesh to load

    Returns boolean

    True if the mesh was loaded successfully, false otherwise

  • Re-sets up shader program for the material using updated shader sources from Spector.js. This method is specifically designed for shader debugging and live editing scenarios.

    Parameters

    • material: Material

      The material to re-setup shader program for

    • primitive: Primitive

      The primitive geometry associated with the shader

    • updatedShaderSources: ShaderSources

      The updated shader source code

    • onError: ((message: string) => void)

      Callback function to handle compilation errors

        • (message): void
        • Parameters

          • message: string

          Returns void

    Returns number

    The CGAPIResourceHandle of the updated shader program, or InvalidCGAPIResourceUid on failure

  • Attaches GPU data for the primitive. This method is part of the CGAPIStrategy interface but is a no-op in uniform strategy as GPU data is handled differently through data textures.

    Parameters

    • primitive: Primitive

      The primitive to attach GPU data for

    Returns void

  • Attaches vertex data for rendering. This method is part of the CGAPIStrategy interface but is a no-op in uniform strategy as vertex data attachment is handled in attachVertexDataInner.

    Parameters

    • i: number

      Index parameter (unused in uniform strategy)

    • primitive: Primitive

      The primitive containing vertex data

    • glw: WebGLContextWrapper

      WebGL context wrapper

    • instanceIDBufferUid: number

      Instance ID buffer handle (unused in uniform strategy)

    Returns void

  • Internal method to attach vertex data for a specific mesh and primitive. Binds the appropriate VAO or sets up vertex data pipeline for rendering.

    Parameters

    • mesh: Mesh

      The mesh containing vertex data

    • primitive: Primitive

      The primitive geometry to render

    • primitiveUid: number

      Unique identifier for the primitive

    • glw: WebGLContextWrapper

      WebGL context wrapper

    • instanceIDBufferUid: number

      Instance ID buffer handle (unused in uniform strategy)

    Returns void

  • Common rendering method that handles the main rendering pipeline. Processes primitives in different rendering phases: opaque, translucent, blend with/without Z-write. Supports buffer-less rendering mode for special cases like post-processing effects.

    Parameters

    • primitiveUids: number[]

      Array of primitive UIDs to render, sorted by rendering order

    • renderPass: RenderPass

      The render pass configuration containing rendering settings

    • renderPassTickCount: number

      Current tick count for the render pass

    Returns boolean

    True if any primitives were rendered, false otherwise

  • Detaches vertex data and cleans up OpenGL state after rendering. Unbinds VAO, element array buffer, and array buffer to prevent state leakage.

    Parameters

    Returns void

  • Performs pre-rendering setup operations. Initializes light components, sets up data texture for GPU vertex data, and prepares global rendering state.

    Returns void

  • Internal rendering method for processing individual primitives. Handles shader setup, material parameters, lighting, VR rendering, and draw calls for each mesh entity associated with the primitive.

    Parameters

    • primitiveUid: number

      Unique identifier of the primitive to render

    • glw: WebGLContextWrapper

      WebGL context wrapper

    • renderPass: RenderPass

      The render pass configuration

    • renderPassTickCount: number

      Current tick count for the render pass

    Returns boolean

    True if the primitive was rendered successfully, false otherwise

  • Sets up shader program for the given material and primitive in this WebGL strategy. Creates a new shader program if needed and configures uniform locations for rendering.

    Parameters

    • material: Material

      The material to setup shader program for

    • primitive: Primitive

      The primitive geometry to associate with the shader

    Returns number

    The CGAPIResourceHandle of the created or existing shader program