rhodonite
    Preparing search index...

    Class CameraComponent

    The Component that represents a camera.

    The camera is defined such that the local +X axis is to the right, the "lens" looks towards the local -Z axis, and the top of the camera is aligned with the local +Y axis.

    Hierarchy (View Summary)

    Index
    • Creates a new CameraComponent instance.

      Parameters

      • engine: Engine

        The engine instance

      • entityUid: number

        The unique identifier of the entity this component belongs to

      • componentSid: number

        The component system identifier

      • entityRepository: EntityRepository

        The entity repository instance

      • isReUse: boolean

        Whether this component is being reused from a pool

      Returns CameraComponent

    __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

    _xrLeft: boolean = false
    _xrRight: boolean = false
    isSyncToLight: boolean = false
    _processStages: ProcessStageEnum[] = ...
    _variableLengthLocationRadix: 65536

    The radix used to split the location of a variable-length array member into two floats (location = x * radix + y), so that both are exactly representable as 32-bit floats.

    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    InvalidObjectUID: -1

    Invalid object UID constant

    • get _componentMemoryRegistry(): ComponentMemoryRegistry

      Gets the ComponentMemoryRegistry for this component's engine.

      Returns ComponentMemoryRegistry

    • get aspect(): number

      Gets the aspect ratio.

      Returns number

      The aspect ratio

    • set aspect(val: number): void

      Sets the aspect ratio and adjusts the film width accordingly.

      Parameters

      • val: number

        The aspect ratio (width/height)

      Returns void

    • get aspectInner(): number

      Gets the internal aspect ratio.

      Returns number

      The internal aspect ratio

    • set aspectInner(val: number): void

      Sets the internal aspect ratio.

      Parameters

      • val: number

        The internal aspect ratio

      Returns void

    • get biasViewProjectionMatrix(): MutableMatrix44

      Gets the bias view-projection matrix for shadow mapping.

      Returns MutableMatrix44

      The bias view-projection matrix adjusted for the current graphics API

    • get bottom(): number

      Gets the bottom clipping plane position.

      Returns number

      The bottom clipping plane position

    • set bottom(value: number): void

      Sets the bottom clipping plane position.

      Parameters

      • value: number

        The bottom clipping plane position

      Returns void

    • set bottomInner(value: number): void

      Sets the internal bottom clipping plane position.

      Parameters

      • value: number

        The internal bottom clipping plane position

      Returns void

    • 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 componentTID(): number

      Gets the component type identifier for this camera component.

      Returns number

      The camera component type identifier

    • get corner(): Vector4

      Gets the corner parameters.

      Returns Vector4

      A copy of the corner vector

    • set corner(vec: Vector4): void

      Sets the corner parameters (left, right, top, bottom) for frustum camera.

      Parameters

      • vec: Vector4

        The corner vector (x: left, y: right, z: top, w: bottom)

      Returns void

    • get cornerInner(): Vector4

      Gets the internal corner parameters.

      Returns Vector4

      The internal corner vector

    • set cornerInner(vec: Vector4): void

      Sets the internal corner parameters.

      Parameters

      • vec: Vector4

        The internal corner vector

      Returns void

    • get currentProcessStage(): ProcessStageEnum

      Gets the current process stage of the component. This determines which update methods are currently being called.

      Returns ProcessStageEnum

      The current process stage

    • get direction(): Vector3

      Gets the direction vector of the camera.

      Returns Vector3

      A copy of the direction vector

    • set direction(vec: Vector3): void

      Sets the direction vector of the camera and automatically adjusts the up vector to remain orthogonal.

      Parameters

      • vec: Vector3

        The new direction vector for the camera

      Returns void

    • get directionInner(): Vector3

      Gets the internal direction vector.

      Returns Vector3

      The internal direction vector

    • set directionInner(vec: Vector3): void

      Sets the internal direction vector.

      Parameters

      • vec: Vector3

        The vector to set as the internal direction

      Returns void

    • get entity(): ICameraEntity

      Gets the entity which has this camera component.

      Returns ICameraEntity

      The entity which has this component

    • get entityUID(): number

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

      Returns number

      The entity unique ID

    • get eye(): Vector3

      Gets the camera eye position (always (0,0,0) in Rhodonite).

      Returns Vector3

      The eye position vector (always zero)

    • set eye(_noUseVec: Vector3): void

      Attempts to set the eye position (throws error as this is not supported).

      Parameters

      Returns void

      Always throws an error as eye positioning should use TransformComponent

    • get eyeInner(): Vector3

      Gets the internal eye position.

      Returns Vector3

      The internal eye position vector

    • set eyeInner(vec: Vector3): void
      Internal

      Sets the internal eye position.

      Parameters

      • vec: Vector3

        The vector to set as the internal eye position

      Returns void

    • get focalLength(): number

      Gets the focal length.

      Returns number

      The focal length in millimeters

    • set focalLength(val: number): void

      Sets the focal length and automatically calculates the field of view.

      Parameters

      • val: number

        The focal length in millimeters

      Returns void

    • get focalLengthInner(): number

      Gets the internal focal length.

      Returns number

      The internal focal length

    • set focalLengthInner(val: number): void

      Sets the internal focal length and calculates the field of view.

      Parameters

      • val: number

        The internal focal length

      Returns void

    • get fovy(): number

      Gets the field of view.

      Returns number

      The field of view in degrees

    • set fovyInner(val: number): void

      Sets the internal field of view.

      Parameters

      • val: number

        The internal field of view in degrees

      Returns void

    • get frustum(): Frustum

      Gets the camera frustum for culling operations.

      Returns Frustum

      The camera frustum

    • get left(): number

      Gets the left clipping plane position.

      Returns number

      The left clipping plane position

    • set left(value: number): void

      Sets the left clipping plane position.

      Parameters

      • value: number

        The left clipping plane position

      Returns void

    • set leftInner(value: number): void

      Sets the internal left clipping plane position.

      Parameters

      • value: number

        The internal left clipping plane position

      Returns void

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get parameters(): Vector4

      Gets the camera parameters.

      Returns Vector4

      A copy of the parameters vector

    • get parametersInner(): Vector4

      Gets the internal camera parameters.

      Returns Vector4

      The internal parameters vector

    • set parametersInner(vec: Vector4): void

      Sets the internal camera parameters.

      Parameters

      • vec: Vector4

        The internal parameters vector

      Returns void

    • get projectionMatrix(): Matrix44

      Gets the projection matrix, considering XR mode if applicable.

      Returns Matrix44

      The projection matrix (may be XR-specific matrix if in XR mode)

    • set projectionMatrix(projectionMatrix: Matrix44): void

      Sets the projection matrix.

      Parameters

      • projectionMatrix: Matrix44

        The projection matrix to set

      Returns void

    • get right(): number

      Gets the right clipping plane position.

      Returns number

      The right clipping plane position

    • set right(value: number): void

      Sets the right clipping plane position.

      Parameters

      • value: number

        The right clipping plane position

      Returns void

    • set rightInner(value: number): void

      Sets the internal right clipping plane position.

      Parameters

      • value: number

        The internal right clipping plane position

      Returns void

    • get top(): number

      Gets the top clipping plane position.

      Returns number

      The top clipping plane position

    • set top(value: number): void

      Sets the top clipping plane position.

      Parameters

      • value: number

        The top clipping plane position

      Returns void

    • set topInner(value: number): void

      Sets the internal top clipping plane position.

      Parameters

      • value: number

        The internal top clipping plane position

      Returns void

    • get type(): EnumIO

      Gets the camera type.

      Returns EnumIO

      The current camera type

    • set type(type: EnumIO): void

      Sets the camera type (perspective, orthographic, or frustum).

      Parameters

      • type: EnumIO

        The camera type to set

      Returns void

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • get up(): Vector3

      Gets the up vector of the camera.

      Returns Vector3

      A copy of the up vector

    • set up(vec: Vector3): void

      Sets the up vector of the camera.

      Parameters

      • vec: Vector3

        The vector to set as the up direction

      Returns void

    • get updateCount(): number

      Gets the update count for this camera component.

      Returns number

      The number of times this camera has been updated

    • get upInner(): Vector3

      Gets the internal up vector.

      Returns Vector3

      The internal up vector

    • set upInner(vec: Vector3): void

      Sets the internal up vector.

      Parameters

      • vec: Vector3

        The vector to set as the internal up direction

      Returns void

    • get viewMatrix(): Matrix44

      Gets the view matrix.

      Returns Matrix44

      The view matrix

    • set viewMatrix(viewMatrix: Matrix44): void

      Sets the view matrix.

      Parameters

      • viewMatrix: Matrix44

        The view matrix to set

      Returns void

    • get viewProjectionMatrix(): MutableMatrix44

      Gets the combined view-projection matrix.

      Returns MutableMatrix44

      The view-projection matrix

    • get worldPosition(): MutableVector3

      Gets the world position of the camera.

      Returns MutableVector3

      The world position vector

    • get xMag(): number

      Gets the X magnification for orthographic projection.

      Returns number

      The X magnification value

    • set xMag(val: number): void

      Sets the X magnification for orthographic projection.

      Parameters

      • val: number

        The X magnification value

      Returns void

    • get yMag(): number

      Gets the Y magnification for orthographic projection.

      Returns number

      The Y magnification value

    • set yMag(val: number): void

      Sets the Y magnification for orthographic projection.

      Parameters

      • val: number

        The Y magnification value

      Returns void

    • get zFar(): number

      Gets the far clipping plane distance.

      Returns number

      The far clipping plane distance

    • set zFar(val: number): void

      Sets the far clipping plane distance.

      Parameters

      • val: number

        The far clipping plane distance

      Returns void

    • get zFarInner(): number

      Gets the internal far clipping plane distance.

      Returns number

      The internal far clipping plane distance

    • set zFarInner(val: number): void

      Sets the internal far clipping plane distance.

      Parameters

      • val: number

        The internal far clipping plane distance

      Returns void

    • get zNear(): number

      Gets the near clipping plane distance.

      Returns number

      The near clipping plane distance

    • set zNear(val: number): void

      Sets the near clipping plane distance.

      Parameters

      • val: number

        The near clipping plane distance

      Returns void

    • get zNearInner(): number

      Gets the internal near clipping plane distance.

      Returns number

      The internal near clipping plane distance

    • set zNearInner(val: number): void

      Sets the internal near clipping plane distance.

      Parameters

      • val: number

        The internal near clipping plane distance

      Returns void

    • get componentTID(): 9

      Gets the component type identifier for camera components.

      Returns 9

      The camera component type identifier

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Internal

      Marks this component as destroyed and no longer alive. This is used internally to manage component lifecycle.

      Returns void

    • Returns the array length to allocate for a variable-length array member of this component instance (see registerMember). Override this to allocate a per-instance size. When undefined is returned, the maximum array length registered for the component class is used.

      Parameters

      • _memberName: string

        The name of the variable-length array member

      Returns number | undefined

      The array length, or undefined to use the class-wide value

    • Performs a shallow copy of data from another component of the same type. This method should be implemented by concrete component classes as needed.

      Parameters

      Returns void

    • Internal

      Loads the camera component and moves it to the logic stage.

      Returns void

    • Internal

      Executes the logic update for the camera component. Updates view and projection matrices, handles light synchronization, and manages XR mode.

      Returns void

    • Calculates and returns the projection matrix based on camera parameters.

      Returns MutableMatrix44

      The calculated projection matrix

    • Calculates and returns the view matrix based on camera position and orientation.

      Returns MutableMatrix44

      The calculated view matrix

    • 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 whether the specified ProcessStage method exists in this Component instance. This is used to determine if this component can handle a particular process stage.

      Parameters

      Returns boolean

      True if the method exists, 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

    • Transitions the component to a different process stage. This affects which update methods will be called during the frame processing.

      Parameters

      Returns void

    • 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

    • Removes a tag from this object

      Parameters

      • tagName: string

        The name of the tag to remove

      Returns void

    • Sets the field of view and adjusts the film size accordingly.

      Parameters

      • degree: number

        The field of view in degrees

      Returns void

    • Sets the field of view and adjusts the focal length accordingly.

      Parameters

      • degree: number

        The field of view in degrees

      Returns void

    • 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

    • Unregisters this object from all tracking collections. Should be called when the object is being destroyed.

      Returns void

    • Updates the camera frustum based on current view and projection matrices.

      Returns void

    • 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

    • Internal

      Cleans up static resources associated with the specified engine.

      Parameters

      • engine: Engine

        The engine instance to clean up resources for

      Returns void

    • Gets the name of the member which holds the location of a variable-length array member.

      Parameters

      • memberName: string

        The name of the variable-length array member

      Returns string

      The name of the location member

    • Internal

      Resets all static object tracking data. Used primarily for testing.

      Returns void

    • Checks whether the specified ProcessStage method exists in the given Component class. This is used to determine if a component can handle a particular process stage.

      Parameters

      Returns boolean

      True if the method exists, false otherwise

    • Gets the array length of a specific member field in a component class.

      Parameters

      Returns Map<typeof Component, Map<string, number>>

      The array length map of the component

    • Gets the number of components per buffer view for the component.

      Parameters

      Returns Map<typeof Component, number>

      The number of components per buffer view for the component

    • Gets the ComponentType of a specific member field in a component class. This is useful for understanding the primitive data type of component members.

      Parameters

      • _engine: Engine
      • memberName: string

        The name of the member field

      • componentClass: typeof Component

        The component class to query

      Returns ComponentTypeEnum | undefined

      The ComponentType of the member or undefined if not found

    • Gets the CompositionType of a specific member field in a component class. This is useful for understanding the data structure of component members.

      Parameters

      • _engine: Engine
      • memberName: string

        The name of the member field

      • componentClass: typeof Component

        The component class to query

      Returns CompositionTypeEnum | undefined

      The CompositionType of the member or undefined if not found

    • Gets the current active camera component ID for a specific engine.

      Parameters

      • engine: Engine

        The engine instance

      Returns number

      The component system identifier of the current active camera for the engine

    • Gets the update count of the current active camera.

      Parameters

      • engine: Engine

        The engine instance

      Returns number

      The update count of the current camera, or 0 if no camera is active

    • 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

    • Gets the member info of the component. This is useful for getting the member info of the component.

      Parameters

      Returns Map<typeof Component, Map<string, MemberInfo>>

      The member info of the component

    • 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

    • Retrieves an RnObject instance by its unique name

      Parameters

      • uniqueName: string

        The unique name of the object to retrieve

      Returns RnObject | undefined

      The RnObject instance or undefined if not found or garbage collected

    • Gets the state version of the component memory layout. This is incremented whenever the component's memory layout changes.

      Parameters

      • engine: Engine

        The engine instance

      Returns number

      The state version number

    • 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.

      Variable-length array members (isVariableLength: true) are allocated per instance with the length returned by _getArrayLengthForAllocation, instead of the fixed slot layout shared by the components of a buffer view. Shaders find the data through a Vec4 member named ${memberName}Location, which must be registered before the variable-length member.

      Parameters

      • this: typeof Component
      • bufferUse: {
            arrayLength?: number;
            bufferUse: EnumIO;
            componentSID?: number;
            componentType: ComponentTypeEnum;
            compositionType: CompositionTypeEnum;
            convertToBool?: boolean;
            dataClassType: DataClassType;
            initValues: number[] | VectorN;
            isVariableLength?: boolean;
            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

    • Sets the current active camera component for a specific engine.

      Parameters

      • engine: Engine

        The engine instance

      • componentSID: number

        The component system identifier of the camera to set as current

      Returns void

    • Updates components specifically for the render stage with render pass context. This method calls the sort_$render method of the component class to handle render-specific processing and sorting.

      Parameters

      Returns any

      The result of the sort_$render method