rhodonite
    Preparing search index...

    Class Entity

    The class that represents an entity.

    The Rhodonite Entity Class which are an entities that exists in space. Entities can acquire various functions by having components on themselves.

    Hierarchy (View Summary)

    Implements

    Index
    • Creates a new Entity instance.

      Parameters

      • engine: Engine
      • entityUID: number

        The unique identifier for this entity

      • isAlive: boolean

        Whether this entity is alive or not

      • Optionalcomponents: Map<number, Component>

        Optional map of existing components to initialize with

      Returns Entity

      When creating an Entity, use the createEntity method of the EntityRepository class instead of directly calling this constructor.

    __components: Map<number, Component>

    The Map of components. All components must be managed in this map

    _isAlive: boolean

    No use yet

    _myLatestCopyEntityUID: number = Entity.invalidEntityUID
    _tags: RnTags = {}

    Collection of tags associated with this object

    currentMaxObjectCount: number = 0

    Current maximum object count for UID generation

    invalidEntityUID: -1

    Invalid Entity UID constant value

    InvalidObjectUID: -1

    Invalid object UID constant

    • get engine(): Engine

      Gets the engine instance.

      Returns Engine

      The engine instance

    • get entityUID(): number

      Gets the unique identifier of this entity.

      Returns number

      The entity's unique ID

    • 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

    • Internal

      Copies tag data from another RnObject instance to this object

      Parameters

      • rnObject: RnObject

        The source RnObject to copy tags from

      Returns void

    • Destroys this entity and releases all associated resources.

      Returns void

      This method calls the destroy method on all components attached to this entity, unregisters the entity from the RnObject tracking system (to clean up unique names), and marks the entity as no longer alive. After calling this method, the entity should not be used.

    • Internal

      Removes a component from this entity by its component type identifier.

      Parameters

      • componentTID: number

        The component type identifier of the component to remove

      Returns void

    • Internal

      Sets a component on this entity.

      Parameters

      • componentType: typeof Component

        The constructor/class of the component to set

      • component: Component

        The component instance to attach to this entity

      Returns void

      This method associates a component instance with this entity using the component's type ID. If a component of the same type already exists, it will be replaced.

    • Retrieves a component of the specified type from this entity.

      Parameters

      • componentType: typeof Component

        The constructor/class of the component to retrieve

      Returns Component | undefined

      The component instance if found, undefined if the entity doesn't have this component type

    • Retrieves a component by its unique component type identifier.

      Parameters

      • componentTID: number

        The component type identifier to look up

      Returns Component | undefined

      The component instance if found, undefined otherwise

    • 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 entity has a component of the specified type.

      Parameters

      • componentType: typeof Component

        The constructor/class of the component to check for

      Returns boolean

      True if the entity has a component of the specified type, false otherwise

    • 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

    • Removes a tag from this object

      Parameters

      • tagName: string

        The name of the tag to remove

      Returns void

    • Attempts to retrieve the AnimationComponent from this entity.

      Returns AnimationComponent | undefined

      The AnimationComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the AnimationComponent without requiring explicit type casting.

    • Attempts to retrieve the AnimationStateComponent from this entity.

      Returns AnimationStateComponent | undefined

      The AnimationStateComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the AnimationStateComponent without requiring explicit type casting.

    • Attempts to retrieve the BlendShapeComponent from this entity.

      Returns BlendShapeComponent | undefined

      The BlendShapeComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the BlendShapeComponent without requiring explicit type casting.

    • Attempts to retrieve the CameraComponent from this entity.

      Returns CameraComponent | undefined

      The CameraComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the CameraComponent without requiring explicit type casting.

    • Attempts to retrieve the CameraControllerComponent from this entity.

      Returns CameraControllerComponent | undefined

      The CameraControllerComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the CameraControllerComponent without requiring explicit type casting.

    • Attempts to retrieve the ConstraintComponent from this entity.

      Returns ConstraintComponent | undefined

      The ConstraintComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the ConstraintComponent without requiring explicit type casting.

    • Attempts to retrieve the EffekseerComponent from this entity.

      Returns EffekseerComponent | undefined

      The EffekseerComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the EffekseerComponent without requiring explicit type casting.

    • Attempts to retrieve the LightComponent from this entity.

      Returns LightComponent | undefined

      The LightComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the LightComponent without requiring explicit type casting.

    • Attempts to retrieve the MeshComponent from this entity.

      Returns MeshComponent | undefined

      The MeshComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the MeshComponent without requiring explicit type casting.

    • Attempts to retrieve the MeshRendererComponent from this entity.

      Returns MeshRendererComponent | undefined

      The MeshRendererComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the MeshRendererComponent without requiring explicit type casting.

    • Attempts to retrieve the PhysicsComponent from this entity.

      Returns PhysicsComponent | undefined

      The PhysicsComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the PhysicsComponent without requiring explicit type casting.

    • Attempts to retrieve the RaymarchingComponent from this entity.

      Returns RaymarchingComponent | undefined

      The RaymarchingComponent if present, undefined otherwise

      This is a convenience method that provides type-safe access to the RaymarchingComponent without requiring explicit type casting.

    • Attempts to retrieve the SceneGraphComponent from this entity.

      Returns SceneGraphComponent | undefined

      The SceneGraphComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the SceneGraphComponent without requiring explicit type casting.

    • Attempts to retrieve the SkeletalComponent from this entity.

      Returns SkeletalComponent | undefined

      The SkeletalComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the SkeletalComponent without requiring explicit type casting.

    • Attempts to retrieve the TransformComponent from this entity.

      Returns TransformComponent | undefined

      The TransformComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the TransformComponent without requiring explicit type casting.

    • Attempts to retrieve the VrmComponent from this entity.

      Returns VrmComponent | undefined

      The VrmComponent if this entity has one, undefined otherwise

      This is a convenience method that provides type-safe access to the VrmComponent without requiring explicit type casting.

    • 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

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

      Returns void

    • 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

    • 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