@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.
60 lines (59 loc) • 2.29 kB
TypeScript
import type { NeedleXREventArgs } from "../../../engine/engine_xr.js";
import { Behaviour } from "../../Component.js";
/**
* Add this script to an object and set `side` to make the object follow a specific controller.
*
* This can be useful to attach objects to controllers, for example a laser pointer or a 3D model of a tool.
*
* @example Make an object follow the right controller
* ```ts
* import { onStart, XRControllerFollow } from "@needle-tools/engine";
* onStart(context => {
* const obj = context.scene.getObjectByName("MyObject");
* obj?.addComponent(XRControllerFollow, { side: "right", controller: true, hands: true });
* });
* ```
*
* @summary Makes the object follow a specific XR controller or hand
* @category XR
* @group Components
* */
export declare class XRControllerFollow extends Behaviour {
get activeAndEnabled(): boolean;
/** Should this object follow a right hand/controller or left hand/controller.
* When a number is provided, the controller with that index is followed.
* @default "none"
**/
side: XRHandedness | number;
/** should it follow controllers (the physics controller)
* @default true
*/
controller: boolean;
/** should it follow hands (when using hand tracking in WebXR)
* @default false
*/
hands: boolean;
/** Disable if you don't want this script to modify the object's visibility
* If enabled the object will be hidden when the configured controller or hand is not available
* If disabled this script will not modify the object's visibility
* @default true
*/
controlVisibility: boolean;
/** when true it will use the grip space, otherwise the ray space
* @default false
*/
useGripSpace: boolean;
/** when enabled the position, rotation and scale of this object will be set to the position it was at when it entered the XR session
* @default true
*/
resetTransformAfterXRSession: boolean;
private readonly _startPosition;
private readonly _startRotation;
private readonly _startScale;
/** @internal */
onEnterXR(_args: NeedleXREventArgs): void;
/** @internal */
onUpdateXR(args: NeedleXREventArgs): void;
/** @internal */
onLeaveXR(_args: NeedleXREventArgs): void;
}