Class SensorComponent

The base type for all components.

Hierarchy (view full)

Properties

entity: Entity

The entity to which the component is attached.

Accessors

  • get blockedMaterial(): null | Material
  • The material used when the sensor is blocked. If blocked is null, then use the initial material of the entity.

    Returns null | Material

  • set blockedMaterial(value): void
  • Parameters

    Returns void

  • get clearedMaterial(): null | Material
  • The material used when the sensor is cleared. If cleared is null, then use the initial material of the entity.

    Returns null | Material

  • set clearedMaterial(value): void
  • Parameters

    Returns void

  • get initialized(): boolean
  • Whether the component has been initialized.

    Returns boolean

  • get io(): SensorIO
  • The IO signals provided by the sensor.

    Returns SensorIO

  • get kinematics(): boolean
  • Whether to detect entities with kinematic physics bodies.

    Returns boolean

  • set kinematics(value): void
  • Parameters

    • value: boolean

    Returns void

  • get layer(): string
  • The collision layer.

    Returns string

  • set layer(value): void
  • Parameters

    • value: string

    Returns void

  • get name(): string
  • The component name.

    Returns string

  • set name(value): void
  • Parameters

    • value: string

    Returns void

  • get object(): null | Entity
  • The detected entity.

    Returns null | Entity

  • get state(): boolean
  • Whether the sensor is blocked.

    Returns boolean

  • get world(): World
  • The virtual world to which the owning entity belongs.

    Returns World

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: 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<InstanceType<(new () => never) & T>>

    A handle to a trackable object.

    Remarks

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

    Example: Creating a handle to an entity.

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

    Example: Creating a handle to a scripted component of a specific type.

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

    Returns Promise<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>

    Remarks

    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

    Remarks

    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>

Generated using TypeDoc