UNPKG

@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.

87 lines (86 loc) 3.9 kB
/// <reference types="webxr" /> import { Object3D, Quaternion, Vector3 } from "three"; import { AssetReference } from "../../engine/engine_addressables.js"; import { type NeedleXREventArgs } from "../../engine/xr/api.js"; import { Behaviour } from "../Component.js"; export declare class WebXRTrackedImage { get url(): string; get widthInMeters(): number; get bitmap(): ImageBitmap; get model(): WebXRImageTrackingModel; readonly measuredSize: number; readonly state: "tracked" | "emulated"; /** Copy the image position to a vector */ getPosition(vec: Vector3): Vector3; /** Copy the image rotation to a quaternion */ getQuaternion(quat: Quaternion): Quaternion; applyToObject(object: Object3D, t01?: number | undefined): void; private static _positionBuffer; private static _rotationBuffer; private _position; private _rotation; private ensureTransformData; private readonly _trackingComponent; private readonly _trackedImage; private readonly _bitmap; private readonly _pose; constructor(context: WebXRImageTracking, trackedImage: WebXRImageTrackingModel, bitmap: ImageBitmap, measuredSize: number, state: "tracked" | "emulated", pose: any); } /** * WebXRImageTracking allows you to track images in the real world and place objects on top of them. * This component is only available in WebXR sessions. * The WebXRImageTrackingModel contains the image to track, the object to place on top of the image, and the size of the image as well as settings for the tracking. * Used by the {@link WebXRImageTracking} component */ export declare class WebXRImageTrackingModel { /** * Tracked image marker url. Make sure the image has good contrast and unique features to improve the tracking quality. */ image?: string; /** Make sure this matches your physical marker size! Otherwise the tracked object will \"swim\" above or below the marker. * @default 0.25 which is equivalent to 25cm */ widthInMeters: number; /** * The object moved around by the image. Make sure the size matches WidthInMeters. */ object?: AssetReference; /** * If true, a new instance of the referenced object will be created for each tracked image. Enable this if you're re-using objects for multiple markers. */ createObjectInstance: boolean; /** Use this for static images (e.g. markers on the floor). Only the first few frames of new poses will be applied to the model. This will result in more stable tracking. * @default false */ imageDoesNotMove: boolean; /** * Enable to hide the tracked object when the image is not tracked anymore. When disabled the tracked object will stay at the position it was last tracked at. * @default true */ hideWhenTrackingIsLost: boolean; } /** * @category XR * @group Components */ export declare class WebXRImageTracking extends Behaviour { trackedImages?: WebXRImageTrackingModel[]; /** Applies smoothing based on detected jitter to the tracked image. */ smooth: boolean; private readonly trackedImageIndexMap; private static _imageElements; /** @returns true if image tracking is supported on this device. This may return false at runtime if the user's browser did not enable webxr incubations */ get supported(): boolean; private _supported; awake(): void; onBeforeXR(_mode: XRSessionMode, args: XRSessionInit & { trackedImages: Array<any>; }): void; onEnterXR(_args: NeedleXREventArgs): void; onLeaveXR(_args: NeedleXREventArgs): void; private readonly imageToObjectMap; private readonly currentImages; private readonly webXRIncubationsWarning; onUpdateXR(args: NeedleXREventArgs): void; private onImageTrackingUpdate; }