rhodonite
    Preparing search index...

    Class TransformComponent

    TransformComponent is a component that manages the transform of an entity. It handles position, rotation, scale, and transformation matrices for 3D objects. This component provides both current transform state and rest pose functionality.

    Hierarchy (View Summary)

    Index
    • The constructor of the Component class. When creating a Component, use the createComponent method of the ComponentRepository class instead of directly calling this constructor.

      Parameters

      • engine: Engine

        The engine instance

      • entityUid: number

        Unique ID of the corresponding entity

      • componentSid: number

        Scoped ID of the Component

      • entityRepository: EntityRepository

        The instance of the EntityRepository class (Dependency Injection)

      • isReUse: boolean

        Whether this component is being reused from a pool

      Returns TransformComponent

    __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

    _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 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 instance.

      Returns number

      The transform component type ID

    • 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 entity(): ITransformEntity

      Gets the entity that owns this component.

      Returns ITransformEntity

      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 localEulerAngles(): IVector3

      Gets a copy of the local Euler angles vector.

      Returns IVector3

      A copy of the local rotation as Euler angles (XYZ order)

    • set localEulerAngles(vec: IVector3): void

      Sets the local rotation using Euler angles and updates physics if applicable.

      Parameters

      • vec: IVector3

        The Euler angles vector (XYZ order)

      Returns void

    • get localEulerAnglesInner(): Vector3

      Gets the internal mutable local Euler angles vector.

      Returns Vector3

      The internal mutable Euler angles vector

    • get localEulerAnglesRest(): IVector3

      Gets a copy of the local Euler angles rest vector.

      Returns IVector3

      A copy of the rest rotation as Euler angles (XYZ order)

    • set localEulerAnglesRest(vec: IVector3): void

      Sets the local Euler angles as rest pose.

      Parameters

      • vec: IVector3

        The Euler angles vector to set as rest (XYZ order)

      Returns void

    • get localEulerAnglesRestInner(): Vector3

      Gets the internal mutable local Euler angles rest vector.

      Returns Vector3

      The internal mutable rest Euler angles vector

    • set localEulerAnglesWithoutPhysics(vec: IVector3): void

      Sets the local Euler angles without updating physics simulation.

      Parameters

      • vec: IVector3

        The Euler angles vector (XYZ order)

      Returns void

    • get localMatrix(): IMatrix44

      Gets a copy of the local transformation matrix.

      Returns IMatrix44

      A copy of the local transform matrix

    • set localMatrix(mat: IMatrix44): void

      Sets the local transformation matrix.

      Parameters

      • mat: IMatrix44

        The new transformation matrix

      Returns void

    • get localMatrixInner(): MutableMatrix44

      Gets the internal local transformation matrix.

      Returns MutableMatrix44

      The internal local transform matrix

    • get localMatrixRest(): IMatrix44

      Gets a copy of the local transformation matrix rest pose.

      Returns IMatrix44

      A copy of the rest transform matrix

    • set localMatrixRest(mat: IMatrix44): void

      Sets the local transformation matrix as rest pose.

      Parameters

      • mat: IMatrix44

        The transformation matrix to set as rest

      Returns void

    • get localMatrixRestInner(): MutableMatrix44

      Gets the internal local transformation matrix rest pose.

      Returns MutableMatrix44

      The internal rest transform matrix

    • set localMatrixWithoutPhysics(mat: IMatrix44): void

      Parameters

      Returns void

    • get localPosition(): IVector3

      Gets a copy of the local position vector.

      Returns IVector3

      A copy of the local position

    • set localPosition(vec: IVector3): void

      Sets the local position of this entity and updates physics if applicable.

      Parameters

      Returns void

    • get localPositionInner(): MutableVector3

      Gets the internal mutable local position vector.

      Returns MutableVector3

      The internal mutable position vector

    • get localPositionRest(): IVector3

      Gets a copy of the local position rest vector.

      Returns IVector3

      A copy of the rest position

    • set localPositionRest(vec: IVector3): void

      Sets the local position as rest pose.

      Parameters

      • vec: IVector3

        The position vector to set as rest

      Returns void

    • get localPositionRestInner(): MutableVector3

      Gets the internal mutable local position rest vector.

      Returns MutableVector3

      The internal mutable rest position vector

    • set localPositionWithoutPhysics(vec: IVector3): void

      Sets the local position without updating physics simulation.

      Parameters

      Returns void

    • get localRotation(): IQuaternion

      Gets a copy of the local rotation quaternion.

      Returns IQuaternion

      A copy of the local rotation quaternion

    • set localRotation(quat: IQuaternion): void

      Sets the local rotation using a quaternion and updates physics if applicable.

      Parameters

      Returns void

    • get localRotationInner(): Quaternion

      Gets the internal local rotation quaternion.

      Returns Quaternion

      The internal rotation quaternion

    • get localRotationRest(): IQuaternion

      Gets a copy of the local rotation rest quaternion.

      Returns IQuaternion

      A copy of the rest rotation quaternion

    • set localRotationRest(quat: IQuaternion): void

      Sets the local rotation as rest pose.

      Parameters

      • quat: IQuaternion

        The rotation quaternion to set as rest

      Returns void

    • get localRotationRestInner(): Quaternion

      Gets the internal local rotation rest quaternion.

      Returns Quaternion

      The internal rest rotation quaternion

    • set localRotationWithoutPhysics(quat: IQuaternion): void

      Sets the local rotation without updating physics simulation.

      Parameters

      Returns void

    • get localScale(): IVector3

      Gets a copy of the local scale vector.

      Returns IVector3

      A copy of the local scale

    • set localScale(vec: IVector3): void

      Sets the local scale and updates physics if applicable.

      Parameters

      Returns void

    • get localScaleInner(): MutableVector3

      Gets the internal mutable local scale vector.

      Returns MutableVector3

      The internal mutable scale vector

    • get localScaleRest(): IVector3

      Gets a copy of the local scale rest vector.

      Returns IVector3

      A copy of the rest scale

    • set localScaleRest(vec: IVector3): void

      Sets the local scale as rest pose.

      Parameters

      • vec: IVector3

        The scale vector to set as rest

      Returns void

    • get localScaleRestInner(): MutableVector3

      Gets the internal mutable local scale rest vector.

      Returns MutableVector3

      The internal mutable rest scale vector

    • set localScaleWithoutPhysics(vec: IVector3): void

      Sets the local scale without updating physics simulation.

      Parameters

      Returns void

    • get localTransform(): Transform3D

      Gets the local transform of this entity.

      Returns Transform3D

      The current local transform

    • set localTransform(transform: Transform3D): void

      Sets the local transform of this entity.

      Parameters

      Returns void

    • get localTransformRest(): Transform3D

      Gets the local transform rest pose.

      Returns Transform3D

      The rest pose or current pose if no rest pose is set

    • set localTransformRest(transform: Transform3D): void

      Sets the local transform rest pose.

      Parameters

      • transform: Transform3D

        The transform to set as rest pose

      Returns void

    • get objectUID(): number

      Gets the unique object identifier

      Returns number

      The object's UID

    • get restOrPose(): Transform3D

      Gets the rest transform if available, otherwise returns the current pose.

      Returns Transform3D

      The rest transform or current pose

    • get uniqueName(): string

      Gets the unique name of this object

      Returns string

      The unique name string

    • get componentTID(): 3

      Gets the component type identifier for TransformComponent.

      Returns 3

      The transform component type ID

    • get renderedPropertyCount(): null

      Gets the number of rendered properties for this component type.

      Returns null

      null as this component doesn't have rendered properties

    • Internal

      Backs up the current transform as the rest pose. Creates a rest pose snapshot and marks the scene graph world matrix as dirty.

      Returns void

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Internal

      Destroys the component and cleans up resources.

      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

    • Internal

      Restores the transform from the previously backed up rest pose.

      Returns void

    • Internal

      Performs a shallow copy from another TransformComponent.

      Parameters

      • component_: Component

        The source component to copy from

      Returns void

    • Internal

      Loads the component and moves it to the Logic processing stage.

      Returns void

    • Internal

      Executes logic processing for the component. Checks if the transform has been updated and marks the world matrix as dirty if needed.

      Returns void

    • Copies the local transformation matrix to the provided matrix object.

      Parameters

      Returns void

    • 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 local position using a 3-element array.

      Parameters

      • array: Array3<number>

        Array containing [x, y, z] position values

      Returns void

    • Sets the local rotation using a 4-element array.

      Parameters

      • array: Array4<number>

        Array containing [x, y, z, w] quaternion values

      Returns void

    • Sets the local scale using a 3-element array.

      Parameters

      • array: Array3<number>

        Array containing [x, y, z] scale values

      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

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

    • Gets the update counter for transform components of the specified engine.

      Parameters

      • engine: Engine

        The engine instance to get the update count for

      Returns number

      The current update count for the specified engine

    • 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

    • 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