ProtoTwin API
    Preparing search index...

    Class TransformComponent

    A core component that provides an entity with a 3D orientation, position and scale.

    All entities have a transform component. Transform components cannot be detached from entities.

    Hierarchy (View Summary)

    Index

    Properties

    entity: Entity

    The entity to which the component is attached.

    Accessors

    • get initialized(): boolean

      Whether the component has been initialized.

      Returns boolean

    • get io(): null | IO

      The IO signals provided by the component.

      Returns null | IO

    • get name(): string

      The component name.

      Returns string

    • set name(value: string): void

      Parameters

      • value: string

      Returns void

    • get position(): Vec3

      The local position.

      Returns Vec3

    • set position(value: IVec3): void

      Parameters

      Returns void

    • get rotation(): Quat

      The local rotation.

      Returns Quat

    • set rotation(value: IQuat): void

      Parameters

      Returns void

    • get scale(): number

      The local scale.

      Returns number

    • set scale(value: number): void

      Parameters

      • value: number

      Returns void

    • get world(): World

      The virtual world to which the owning entity belongs.

      Returns World

    • get worldPosition(): Vec3

      The world position.

      Returns Vec3

    • set worldPosition(value: IVec3): void

      Parameters

      Returns void

    • get worldRotation(): Quat

      The world rotation.

      Returns Quat

    • set worldRotation(value: IQuat): void

      Parameters

      Returns void

    • get worldScale(): number

      The world scale.

      Returns number

    • set worldScale(value: number): void

      Parameters

      • value: number

      Returns void

    Methods

    • Added function called immediately after the component is attached to an entity.

      Returns void

    • Creates a handle (weak reference) to a trackable object.

      Type Parameters

      Parameters

      • type: TrackableType<T>

        The type of object that is to be referenced.

      • value: null | T = null

        The object that is initially referenced by the handle.

      Returns Handle<T>

      A handle to a trackable object.

      Handles created through this function are automatically cleared when the component is detached/removed.

      const handle = this.handle(Entity, this.world.find("Some Entity"));
      

      const handle = this.handle(MyScriptComponent);
      
    • Initialization function called immediately before simulating when the model is initialized.

      Returns void

    • Asynchronous initialization function called immediately before simulating when the model is initialized.

      Returns Promise<void>

    • Transforms a point from local-space to world-space.

      Parameters

      • localPoint: IVec3

        The point in local-space.

      Returns Vec3

      The point in world-space.

    • Post-update function called after physics has been updated.

      Parameters

      • dt: number

        The timestep (seconds).

      Returns void

    • Asynchronous post-update function called after physics has been updated.

      Parameters

      • dt: number

        The timestep (seconds).

      Returns Promise<void>

    • Removed function called immediately after the component is detached from an entity.

      Returns void

    • Immediately triggers asynchronous initialization if the component hasn't already been initialized.

      Returns Promise<void>

      This can be used in cases where one component references another in its asynchronous initialize function, but it is required that the referenced component has already been asynchronously initialized.

    • Immediately triggers initialization if the component hasn't already been initialized.

      Returns void

      This can be used in cases where one component references another in its initialize function, but it is required that the referenced component has already been initialized.

    • Subscribes to a subscribable object.

      Subscriptions created through this function are automatically unsubscribed when the component is detached/removed.

      Type Parameters

      • T

      Parameters

      • object: Subscribable<T>

        The subscribable object for which to subscribe.

      • subscriber: Subscriber<T>

        The callback function that is triggered when the object's value is updated.

      Returns void

    • Unsubscribes from a subscribable object.

      Type Parameters

      • T

      Parameters

      • object: Subscribable<T>

        The object from which to unsubscribe.

      • subscriber: Subscriber<T>

        The callback function for the subscription.

      Returns boolean

      True if the subscription was canceled, false otherwise.

    • Update function called every timestep when simulating.

      Parameters

      • dt: number

        The timestep (seconds).

      Returns void

    • Asynchronous update function called every timestep when simulating.

      Parameters

      • dt: number

        The timestep (seconds).

      Returns Promise<void>

    • Transforms a point from world-space to local-space.

      Parameters

      • worldPoint: IVec3

        The point in world-space.

      Returns Vec3

      The point in local-space.