@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
102 lines (101 loc) • 5.53 kB
TypeScript
/// <reference types="webxr" />
import { AssetReference } from "../../engine/engine_addressables.js";
import { type NeedleXREventArgs, NeedleXRSession } from "../../engine/engine_xr.js";
import { WebXRButtonFactory } from "../../engine/webcomponents/WebXRButtons.js";
import { Behaviour } from "../Component.js";
import { XRControllerModel } from "./controllers/XRControllerModel.js";
import { XRControllerMovement } from "./controllers/XRControllerMovement.js";
/**
* WebXR component to enable VR, AR and Quicklook on iOS in your scene.
* It provides a simple wrapper around the {@link NeedleXRSession} API and adds some additional features like creating buttons or enabling default movement behaviour.
* @category XR
* @group Components
*/
export declare class WebXR extends Behaviour {
/** When enabled a button will be added to the UI to enter VR */
createVRButton: boolean;
/** When enabled a button will be added to the UI to enter AR */
createARButton: boolean;
/** When enabled a send to quest button will be shown if the device does not support VR */
createSendToQuestButton: boolean;
/** When enabled a QRCode will be created to open the website on a mobile device */
createQRCode: boolean;
/** When enabled default movement behaviour will be added */
useDefaultControls: boolean;
/** When enabled controller models will automatically be created and updated when you are using controllers in WebXR */
showControllerModels: boolean;
/** When enabled hand models will automatically be created and updated when you are using hands in WebXR */
showHandModels: boolean;
/** When enabled the scene must be placed in AR */
usePlacementReticle: boolean;
/** When assigned this object will be used as the AR placement reticle */
customARPlacementReticle?: AssetReference;
/** When enabled you can position, rotate or scale your AR scene with one or two fingers */
usePlacementAdjustment: boolean;
/** Used when `usePlacementReticle` is enabled. This is the scale of the user in the scene in AR. Larger values make the 3D content appear smaller */
arScale: number;
/** Experimental: When enabled an XRAnchor will be created for the AR scene and the position will be updated to the anchor position every few frames */
useXRAnchor: boolean;
/**
* When enabled the scene will be placed automatically when a point in the real world is found
*/
autoPlace: boolean;
/** When enabled the AR session root center will be automatically adjusted to place the center of the scene */
autoCenter: boolean;
/** When enabled a USDZExporter component will be added to the scene (if none is found) */
useQuicklookExport: boolean;
/** Preview feature enabling occlusion (when available: https://github.com/cabanier/three.js/commit/b6ee92bcd8f20718c186120b7f19a3b68a1d4e47)
* Enables the 'depth-sensing' WebXR feature to provide realtime depth occlusion. Only supported on Oculus Quest right now.
*/
useDepthSensing: boolean;
/**
* When enabled the spatial grab raycaster will be added or enabled in the scene
* @default true
*/
useSpatialGrab: boolean;
/** This avatar representation will be spawned when you enter a webxr session */
defaultAvatar?: AssetReference | boolean;
private _playerSync?;
/** these components were created by the WebXR component on session start and will be cleaned up again in session end */
private readonly _createdComponentsInSession;
private _usdzExporter?;
static activeWebXRComponent: WebXR | null;
awake(): void;
onEnable(): void;
onDisable(): void;
private handleOfferSession;
/** the currently active webxr input session */
get session(): NeedleXRSession | null;
/** immersive-vr or immersive-ar */
get sessionMode(): XRSessionMode | null;
/** Call to start an WebVR session */
enterVR(init?: XRSessionInit): Promise<NeedleXRSession | null>;
/** Call to start an WebAR session */
enterAR(init?: XRSessionInit): Promise<NeedleXRSession | null>;
/** Call to end a WebXR (AR or VR) session */
exitXR(): void;
private _exitXRMenuButton?;
private _previousXRState;
private _spatialGrabRaycaster?;
private get isActiveWebXR();
onBeforeXR(_mode: XRSessionMode, args: XRSessionInit): void;
onEnterXR(args: NeedleXREventArgs): Promise<void>;
onUpdateXR(_args: NeedleXREventArgs): void;
onLeaveXR(_: NeedleXREventArgs): void;
/** Call to enable or disable default controller behaviour */
setDefaultMovementEnabled(enabled: boolean): XRControllerMovement | null;
/** Call to enable or disable default controller rendering */
setDefaultControllerRenderingEnabled(enabled: boolean): XRControllerModel | null;
protected createLocalAvatar(xr: NeedleXRSession): Promise<void>;
private onAvatarSpawned;
/** @deprecated use `getButtonsFactory()` or access `WebXRButtonFactory.getOrCreate()` directory */
getButtonsContainer(): WebXRButtonFactory;
/** Calling this function will get the Needle WebXR button factory (it will be created if it doesnt exist yet)
* @returns the Needle WebXR button factory */
getButtonsFactory(): WebXRButtonFactory;
private _buttonFactory?;
private handleCreatingHTML;
private readonly _buttons;
private addButton;
private removeButtons;
}