Class AbstractMaterialContentAbstract

Abstract base class for material content that provides common functionality for material rendering. This class handles shader semantics, rendering setup, and GPU parameter management for materials.

Hierarchy (view full)

Constructors

  • Constructs a new AbstractMaterialContent instance.

    Parameters

    • materialName: string

      The unique name identifier for this material

    • options: {
          isLighting: undefined | boolean;
          isMorphing: undefined | boolean;
          isSkinning: undefined | boolean;
      } = {}

      Configuration options for the material

      • isLighting: undefined | boolean

        Whether this material supports lighting calculations

      • isMorphing: undefined | boolean

        Whether this material supports morph target animation

      • isSkinning: undefined | boolean

        Whether this material supports skeletal animation

    • OptionalvertexShaderityObject: ShaderityObject

      Optional vertex shader object

    • OptionalpixelShaderityObject: ShaderityObject

      Optional pixel shader object

    Returns AbstractMaterialContent

Properties

__definitions: string = ''
__materialName: string
__semantics: ShaderSemanticsInfo[] = []
_tags: RnTags = {}

Collection of tags associated with this object

shaderType: EnumIO = ShaderType.VertexAndPixelShader
InvalidObjectUID: -1 = -1

Invalid object UID constant

__gl?: WebGLRenderingContext
__tmp_vector2: MutableVector2 = ...
__tmp_vector4: MutableVector4 = ...
currentMaxObjectCount: number = 0

Current maximum object count for UID generation

materialNodes: AbstractMaterialContent[] = []

Accessors

  • 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

  • Sets internal setting parameters to GPU for WebGL per material. This method should be overridden by derived classes to provide specific parameter handling.

    Parameters

    • params: {
          args: RenderingArgWebGL;
          firstTime: boolean;
          material: Material;
          shaderProgram: WebGLProgram;
      }

      Object containing material, shader program, firstTime flag, and rendering arguments

    Returns void

  • Sets internal setting parameters to GPU for WebGL per primitive. This method should be overridden by derived classes to provide specific parameter handling.

    Parameters

    • params: {
          args: RenderingArgWebGL;
          firstTime: boolean;
          material: Material;
          shaderProgram: WebGLProgram;
      }

      Object containing material, shader program, firstTime flag, and rendering arguments

    Returns void

  • Sets internal setting parameters to GPU for WebGL per shader program. This method should be overridden by derived classes to provide specific parameter handling.

    Parameters

    • params: {
          args: RenderingArgWebGL;
          firstTime: boolean;
          material: Material;
          shaderProgram: WebGLProgram;
      }

      Object containing material, shader program, firstTime flag, and rendering arguments

    Returns void

  • Performs shader reflection to extract semantics information from vertex and pixel shaders.

    Parameters

    • vertexShader: ShaderityObject

      The vertex shader object for WebGL

    • pixelShader: ShaderityObject

      The pixel shader object for WebGL

    • vertexShaderWebGpu: ShaderityObject

      The vertex shader object for WebGPU

    • pixelShaderWebGpu: ShaderityObject

      The pixel shader object for WebGPU

    • definitions: string[]

      Array of shader definitions

    Returns ShaderSemanticsInfo[]

    Array of shader semantics information

  • 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

  • Generates a unique variant name for this material based on its shader semantics. This name is used to differentiate materials with different semantic configurations.

    Returns void

  • 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

  • Sets the billboard flag uniform in the shader.

    Parameters

    • shaderProgram: WebGLProgram

      The WebGL shader program

    • isBillboard: boolean

      Whether the object should be rendered as a billboard

    Returns void

  • Sets lighting information uniforms in the shader.

    Parameters

    • shaderProgram: WebGLProgram

      The WebGL shader program

    • lightComponents: LightComponent[]

      Array of light components

    • material: Material

      The material instance

    • setUniform: boolean

      Whether to set uniform values

    Returns void

  • Sets the projection matrix uniform in the shader.

    Parameters

    • shaderProgram: WebGLProgram

      The WebGL shader program

    • cameraComponent: CameraComponent

      The camera component

    • isVr: boolean

      Whether rendering in VR mode

    • displayIdx: number

      The display index for VR rendering

    Returns void

  • Sets skeletal animation uniforms in the shader.

    Parameters

    • shaderProgram: WebGLProgram

      The WebGL shader program

    • setUniform: boolean

      Whether to set uniform values

    • OptionalskeletalComponent: SkeletalComponent

      The skeletal component containing bone data

    Returns void

  • Sets view-related uniforms including view matrix and camera position.

    Parameters

    • shaderProgram: WebGLProgram

      The WebGL shader program

    • cameraComponent: CameraComponent

      The camera component

    • isVr: boolean

      Whether rendering in VR mode

    • displayIdx: number

      The display index for VR rendering

    Returns void

  • Sets up basic rendering information including matrices, camera, and lighting.

    Parameters

    • args: RenderingArgWebGL

      WebGL rendering arguments

    • shaderProgram: WebGLProgram

      The WebGL shader program

    • firstTime: boolean

      Whether this is the first time setup

    • material: Material

      The material instance

    • CameraComponentClass: typeof CameraComponent

      The camera component class

    Returns void

  • 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 undefined | RnObject

    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 undefined | WeakRef<RnObject>

    WeakRef to the first matching object, or undefined if not found