ProtoTwin API
    Preparing search index...

    Class CreatorComponentAbstract

    Base class for all entity creator components.

    Must be extended by any custom creator components. The creator copies the entity to which it is attached at initialization and then removes all components except for the creator itself and any graphics components. Upon calling the create method, the entity is pasted, with all components restored except for the creator component itself.

    Hierarchy (View Summary)

    Index

    Constructors

    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 world(): World

      The virtual world to which the owning entity belongs.

      Returns World

    Methods

    • Called when the component is added to an entity.

      Returns void

      Must be called from the added method of derived classes if overridden.

    • Create a copy of the entity to which the component is attached.

      Returns null | Entity

      The created entity, or null if the operation failed.

    • Creates a customized copy of the entity to which the component is attached.

      Parameters

      • customizer: CreatorCustomizer

        The customization function, which is passed the created entity.

      Returns null | Entity

      The created entity.

      The customization function is executed before any subscribers are notified that the entity has been created.

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

    • Initializes the creator component.

      Returns void

      Must be called from the initialize method of derived classes if overridden.

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

      Returns Promise<void>

    • Notifies subscribers that an entity has been created.

      Parameters

      • entity: Entity

        The entity that was created.

      Returns void

      This method is called automatically by create and createCustom, but can be used by derived classes that override the create method.

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

    • Called when the component is removed from an entity.

      Returns void

      Must be called from the removed method of derived classes if overridden.

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