Class LazyWidgetsInputGuardComponent

Hierarchy

  • Component
    • LazyWidgetsInputGuardComponent

Constructors

  • Create a new instance

    Parameters

    • engine: WonderlandEngine

      The engine instance.

    • Optional manager: number

      Index of the manager.

    • Optional id: number

      WASM component instance index.

    Returns LazyWidgetsInputGuardComponent

    Hidden

Properties

_engine: WonderlandEngine

Wonderland Engine instance.

Hidden

_id: number

Instance index.

Hidden

_manager: number

Manager index.

Hidden

_object: null | Object3D

Object containing this object.

Note: This is cached for faster retrieval.

Hidden

cursorComponentName: string

(optional) Name of cursor component. Shouldn't be changed if the official cursor component is being used

cursorObject: null | Object3D

(optional) Object which has a cursor component. Required if pointerObject is set, else, ignored

keyboardComponent: null | Component
keyboardComponentName: string

(optional) Name of component to disable if keyboard is in use

keyboardObject: null | Object3D

(optional) Object containing component to disable if keyboard is in use. Required if keyboardComponentName is set, else, ignored

pointer: null | number
pointerComponent: null | Component
pointerComponentName: string

(optional) Name of component to disable if pointer is hovering a UI root is in use

pointerObject: null | Object3D

(optional) Object containing component to disable if pointer is hovering a UI root. Required if pointerComponentName is set, else, ignored

InheritProperties?: boolean

When set to true, the child class inherits from the parent properties, as shown in the following example:

import {Component, Property} from '@wonderlandengine/api';

class Parent extends Component {
static TypeName = 'parent';
static Properties = {parentName: Property.string('parent')}
}

class Child extends Parent {
static TypeName = 'child';
static Properties = {name: Property.string('child')}
static InheritProperties = true;

start() {
// Works because `InheritProperties` is `true`.
console.log(`${this.name} inherits from ${this.parentName}`);
}
}

Note

Properties defined in descendant classes will override properties with the same name defined in ancestor classes.

Defaults to true.

Properties: Record<string, ComponentProperty>

Properties of this component class.

Properties are public attributes that can be configured via the Wonderland Editor.

Example:

import { Component, Type } from '@wonderlandengine/api';
class MyComponent extends Component {
static TypeName = 'my-component';
static Properties = {
myBoolean: { type: Type.Boolean, default: false },
myFloat: { type: Type.Float, default: false },
myTexture: { type: Type.Texture, default: null },
};
}

Properties are automatically added to each component instance, and are accessible like any JS attribute:

// Creates a new component and set each properties value:
const myComponent = object.addComponent(MyComponent, {
myBoolean: true,
myFloat: 42.0,
myTexture: null
});

// You can also override the properties on the instance:
myComponent.myBoolean = false;
myComponent.myFloat = -42.0;

References

Reference types (i.e., mesh, object, etc...) can also be listed as required:

import {Component, Property} from '@wonderlandengine/api';

class MyComponent extends Component {
static Properties = {
myObject: Property.object({required: true}),
myAnimation: Property.animation({required: true}),
myTexture: Property.texture({required: true}),
myMesh: Property.mesh({required: true}),
}
}

Please note that references are validated once before the call to Component.start only, via the Component.validateProperties method.

TypeName: string = 'lazy-widgets-input-guard'
_isBaseComponent: true = true

true for every class inheriting from this class.

Note

This is a workaround for instanceof to prevent issues that could arise when an application ends up using multiple API versions.

Hidden

onRegister?: ((engine) => void)

Type declaration

    • (engine): void
    • Called when this component class is registered.

      Parameters

      • engine: WonderlandEngine

      Returns void

      Example

      This callback can be used to register dependencies of a component, e.g., component classes that need to be registered in order to add them at runtime with Object3D.addComponent, independent of whether they are used in the editor.

      class Spawner extends Component {
      static TypeName = 'spawner';

      static onRegister(engine) {
      engine.registerComponent(SpawnedComponent);
      }

      // You can now use addComponent with SpawnedComponent
      }

      Example

      This callback can be used to register different implementations of a component depending on client features or API versions.

      // Properties need to be the same for all implementations!
      const SharedProperties = {};

      class Anchor extends Component {
      static TypeName = 'spawner';
      static Properties = SharedProperties;

      static onRegister(engine) {
      if(navigator.xr === undefined) {
      /* WebXR unsupported, keep this dummy component */
      return;
      }
      /* WebXR supported! Override already registered dummy implementation
      * with one depending on hit-test API support */
      engine.registerComponent(window.HitTestSource === undefined ?
      AnchorWithoutHitTest : AnchorWithHitTest);
      }

      // This one implements no functions
      }

Accessors

  • get active(): boolean
  • Whether this component is active

    Returns boolean

  • set active(active): void
  • Set whether this component is active.

    Activating/deactivating a component comes at a small cost of reordering components in the respective component manager. This function therefore is not a trivial assignment.

    Does nothing if the component is already activated/deactivated.

    Parameters

    • active: boolean

      New active state.

    Returns void

  • get engine(): WonderlandEngine
  • Hosting engine instance.

    Returns WonderlandEngine

  • get isDestroyed(): boolean
  • true if the component is destroyed, false otherwise.

    If WonderlandEngine.erasePrototypeOnDestroy is true, reading a custom property will not work:

    engine.erasePrototypeOnDestroy = true;

    const comp = obj.addComponent('mesh');
    comp.customParam = 'Hello World!';

    console.log(comp.isDestroyed); // Prints `false`
    comp.destroy();
    console.log(comp.isDestroyed); // Prints `true`
    console.log(comp.customParam); // Throws an error

    Returns boolean

    Since

    1.1.1

  • get object(): Object3D
  • The object this component is attached to.

    Returns Object3D

  • get type(): string
  • The name of this component's type

    Returns string

Methods

  • Trigger the component Component.init method.

    Returns void

    Note

    Use this method instead of directly calling Component.init, because this method creates an handler for the Component.start.

    Note

    This api is meant to be used internally.

    Hidden

  • Trigger the component Component.onActivate method.

    Returns void

    Note

    This api is meant to be used internally.

    Hidden

  • Trigger the component Component.onDeactivate method.

    Returns void

    Note

    This api is meant to be used internally.

    Hidden

  • Trigger the component Component.onDestroy method.

    Returns void

    Note

    This api is meant to be used internally.

    Hidden

  • Trigger the component Component.update method.

    Parameters

    • dt: number

    Returns void

    Note

    This api is meant to be used internally.

    Hidden

  • Copy all the properties from src into this instance.

    Parameters

    • src: Record<string, any>

      The source component to copy from.

    Returns LazyWidgetsInputGuardComponent

    Reference to self (for method chaining).

    Note

    Only properties are copied. If a component needs to copy extra data, it needs to override this method.

    Example

    class MyComponent extends Component {
    nonPropertyData = 'Hello World';

    copy(src) {
    super.copy(src);
    this.nonPropertyData = src.nonPropertyData;
    return this;
    }
    }

    Note

    This method is called by Object3D.clone. Do not attempt to: - Create new component - Read references to other objects

    When cloning via Object3D.clone, this method will be called before Component.start.

    Note

    JavaScript component properties aren't retargeted. Thus, references inside the source object will not be retargeted to the destination object, at the exception of the skin data on MeshComponent and AnimationComponent.

  • Remove this component from its objects and destroy it.

    It is best practice to set the component to null after, to ensure it does not get used later.

       c.destroy();
    c = null;

    Returns void

    Since

    0.9.0

  • Checks equality by comparing whether the wrapped native component ids and component manager types are equal.

    Parameters

    • otherComponent: undefined | null | Component

      Component to check equality with.

    Returns boolean

    Whether this component equals the given component.

  • Triggered when the component goes from an inactive state to an active state.

    Returns void

    Note

    You can manually activate or deactivate a component using: :setter.

  • Triggered when the component is removed from its object.

    Returns void

    Note

    You can remove a component using: Component.destroy.

    Since

    0.9.0

  • Reset the component properties to default.

    Returns LazyWidgetsInputGuardComponent

    Reference to self (for method chaining).

    Note

    This is automatically called during the component instantiation.

  • Validate the properties on this instance.

    Returns void

    Throws

    If any of the required properties isn't initialized on this instance.

  • Allows to inherit properties directly inside the editor.

    Returns void

    Note

    Do not use directly, prefer using inheritProperties.

    Hidden

Generated using TypeDoc