Define the interface of XrController.

interface IXrController {
    handedness: string;
    inputSource: null | XrInputSource;
    modelEntity: null | Entity;
    off<T>(event: T, listener: IXrControllerEvents[T]): EventHandler;
    on<T>(event: T, listener: IXrControllerEvents[T]): EventHandle;
    resetModelAsset(): void;
    setModelAsset(asset: Asset, options?: {
        castShadows?: boolean;
        onCompleted?: ((entity: Entity) => void);
        receiveShadows?: boolean;
    }): void;
}

Properties

handedness: string

The handedness of the controller. The value should be either 'left' or 'right'.

inputSource: null | XrInputSource

The XrInputSource of the controller.

modelEntity: null | Entity

The entity of the XR controller model.

Methods

  • Unsubscribe from a specific event.

    Type Parameters

    Parameters

    Returns EventHandler

  • Subscribe to a specific event.

    Type Parameters

    Parameters

    Returns EventHandle

  • Revert to the default controller model in VIVERSE CREATE.

    Returns void

  • Set the controller model asset.

    Parameters

    • asset: Asset

      The controller model asset. The asset type can be either template or container.

    • Optionaloptions: {
          castShadows?: boolean;
          onCompleted?: ((entity: Entity) => void);
          receiveShadows?: boolean;
      }

      Optional parameters.

      • OptionalcastShadows?: boolean

        Determine whether the model casts shadows. Default is false. Only applicable when the asset type is container.

      • OptionalonCompleted?: ((entity: Entity) => void)

        Callback function triggered when the model entity is created.

          • (entity): void
          • Parameters

            • entity: Entity

            Returns void

      • OptionalreceiveShadows?: boolean

        Determine whether the model receives shadows. Default is false. Only applicable when the asset type is container.

    Returns void