rhodonite
    Preparing search index...

    Class LightComponent

    The Component that represents a light.

    the light looks towards the local -Z axis in right hand coordinate system.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    __currentProcessStage: ProcessStageEnum = ProcessStage.Load
    __engine: Engine
    __entityRepository: EntityRepository

    the instance of EntityRepository

    __entityUid: number

    the entity unique Id which this component belongs to

    __isReUse: boolean = false
    __memoryManager: MemoryManager

    the instance of MemoryManager

    _isAlive: boolean = true
    _tags: RnTags = {}

    Collection of tags associated with this object

    castShadow: boolean = false
    enable: boolean = true
    innerConeAngle: number = 0.0
    outerConeAngle: number = ...
    type: EnumIO = LightType.Point
    _processStages: ProcessStageEnum[] = ...
    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    Accessors

    • get _componentMemoryRegistry(): ComponentMemoryRegistry

      Gets the ComponentMemoryRegistry for this component's engine.

      Returns ComponentMemoryRegistry

    • get componentSID(): number

      Gets the Scoped ID of this Component instance. The SID is unique within the component type and represents the instance index.

      Returns number

      The component scoped ID

    • get entityUID(): number

      Gets the unique ID of the entity that owns this component.

      Returns number

      The entity unique ID

    • get isLightGizmoVisible(): boolean

      Gets the visibility state of the light gizmo.

      Returns boolean

      True if the gizmo is visible, false otherwise

    • set isLightGizmoVisible(flg: boolean): void

      Sets the visibility of the light gizmo in the editor. When enabled, creates and shows a visual representation of the light.

      Parameters

      • flg: boolean

        True to show the gizmo, false to hide it

      Returns void

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get range(): number

      Gets the effective range of the light.

      Returns number

    • set range(value: number): void

      Sets the effective range of the light.

      Parameters

      • value: number

      Returns void

      This value is used for:

      • SpotLight shadow camera zFar (when shadow mapping is enabled)
      • DirectionalLight shadow camera zFar fallback (when range !== -1)
      • Shading attenuation / light property uniforms

      Updating this property increments updateCount so dependent systems can react.

    • get shadowAreaSizeForDirectionalLight(): number

      Gets the orthographic half-size used for DirectionalLight shadow camera.

      Returns number

    • set shadowAreaSizeForDirectionalLight(value: number): void

      Sets the orthographic half-size used for DirectionalLight shadow camera.

      Parameters

      • value: number

      Returns void

      CameraComponent syncs to light each frame and uses this to set orthographic extents. Updating this property increments updateCount so camera sync is refreshed.

    • get shadowZNearForDirectionalLight(): number

      Gets the zNear value used for DirectionalLight shadow camera.

      Returns number

    • set shadowZNearForDirectionalLight(value: number): void

      Sets the zNear value used for DirectionalLight shadow camera.

      Parameters

      • value: number

      Returns void

      CameraComponent syncs to light each frame and uses this to set zNear. Updating this property increments updateCount so camera sync is refreshed.

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • get updateCount(): number

      Gets the current update count of this light component. The update count is incremented whenever the light properties change.

      Returns number

      The current update count

    Methods

    • Updates the light component's state and uploads data to the GPU. This method calculates the light direction, position, and properties, then stores them in global data arrays for shader access.

      Returns void

      This method implements performance optimization by checking update counts to avoid unnecessary recalculations when nothing has changed.

    • 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

    • Registers a dependency relationship with another component. This method is intended for future use in managing component dependencies.

      Parameters

      Returns void

      This method is not used yet and needs implementation

    • Allocates memory for all member fields of this component instance. This method is called during component initialization to set up memory layout and allocate space for the specified number of entities.

      Parameters

      • componentCountPerBufferView: number

        The number of components per buffer view

      • isReUse: boolean

        Whether to reuse existing memory allocations

      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

    • Common logic update method that runs once per frame for all light components. Updates the global light count for the shader system.

      Parameters

      • __namedParameters: { engine: Engine }

      Returns void

    • Gets the pixel location offset in the buffer for a specific member of a component type. This is useful for GPU texture-based data access where locations are measured in pixels.

      Parameters

      • engine: Engine

        The engine instance

      • componentType: typeof Component

        The component class type

      • memberName: string

        The name of the member field

      Returns number[]

      The pixel location offset in the buffer

    • 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

    • Processes all components of a given type for a specific process stage. This method iterates through all components of the specified type and calls their corresponding process stage method if they are in that stage.

      Parameters

      Returns void

    • Registers a member field of the component class for memory allocation. This method defines the memory layout and characteristics of component data members.

      Parameters

      • this: typeof Component
      • bufferUse: {
            arrayLength?: number;
            bufferUse: EnumIO;
            componentSID?: number;
            componentType: ComponentTypeEnum;
            compositionType: CompositionTypeEnum;
            convertToBool?: boolean;
            dataClassType: DataClassType;
            initValues: number[] | VectorN;
            memberName: string;
            shaderType: EnumIO;
        }

        The intended purpose/type of buffer use

      Returns void

    • 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