|
@@ -16583,7 +16583,7 @@ declare module BABYLON {
|
|
|
* @param useInstances specifies that instances should be used
|
|
|
* @returns a boolean indicating that the submesh is ready or not
|
|
|
*/
|
|
|
- isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
|
|
|
+ isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
|
|
|
/**
|
|
|
* Checks if the material is ready to render the requested mesh
|
|
|
* @param mesh Define the mesh to render
|
|
@@ -20006,8 +20006,10 @@ declare module BABYLON {
|
|
|
* @param defines specifies the list of active defines
|
|
|
* @param useInstances defines if instances have to be turned on
|
|
|
* @param useClipPlane defines if clip plane have to be turned on
|
|
|
+ * @param useInstances defines if instances have to be turned on
|
|
|
+ * @param useThinInstances defines if thin instances have to be turned on
|
|
|
*/
|
|
|
- static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
|
|
|
+ static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
|
|
|
/**
|
|
|
* Prepares the defines for bones
|
|
|
* @param mesh The mesh containing the geometry data we will draw
|
|
@@ -21464,8 +21466,9 @@ declare module BABYLON {
|
|
|
* @param nodeMaterial defines the node material requesting the update
|
|
|
* @param defines defines the material defines to update
|
|
|
* @param useInstances specifies that instances should be used
|
|
|
+ * @param subMesh defines which submesh to render
|
|
|
*/
|
|
|
- prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
|
|
|
+ prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
|
|
|
/**
|
|
|
* Lets the block try to connect some inputs automatically
|
|
|
* @param material defines the hosting NodeMaterial
|
|
@@ -24054,7 +24057,7 @@ declare module BABYLON {
|
|
|
* @param useInstances specifies that instances should be used
|
|
|
* @returns a boolean indicating that the submesh is ready or not
|
|
|
*/
|
|
|
- isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
|
|
|
+ isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
|
|
|
/**
|
|
|
* Returns the material effect
|
|
|
* @returns the effect associated with the material
|
|
@@ -24339,7 +24342,7 @@ declare module BABYLON {
|
|
|
* @param useInstances Define whether or not the material is used with instances
|
|
|
* @returns true if ready, otherwise false
|
|
|
*/
|
|
|
- isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
|
|
|
+ isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
|
|
|
/**
|
|
|
* Clones the current material and its related sub materials
|
|
|
* @param name Define the name of the newly cloned material
|
|
@@ -24370,9 +24373,19 @@ declare module BABYLON {
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
/**
|
|
|
- * Base class for submeshes
|
|
|
+ * Defines a subdivision inside a mesh
|
|
|
*/
|
|
|
- export class BaseSubMesh {
|
|
|
+ export class SubMesh implements ICullable {
|
|
|
+ /** the material index to use */
|
|
|
+ materialIndex: number;
|
|
|
+ /** vertex index start */
|
|
|
+ verticesStart: number;
|
|
|
+ /** vertices count */
|
|
|
+ verticesCount: number;
|
|
|
+ /** index start */
|
|
|
+ indexStart: number;
|
|
|
+ /** indices count */
|
|
|
+ indexCount: number;
|
|
|
/** @hidden */
|
|
|
_materialDefines: Nullable<MaterialDefines>;
|
|
|
/** @hidden */
|
|
@@ -24397,21 +24410,6 @@ declare module BABYLON {
|
|
|
* @param defines defines the set of defines used to compile this effect
|
|
|
*/
|
|
|
setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
|
|
|
- }
|
|
|
- /**
|
|
|
- * Defines a subdivision inside a mesh
|
|
|
- */
|
|
|
- export class SubMesh extends BaseSubMesh implements ICullable {
|
|
|
- /** the material index to use */
|
|
|
- materialIndex: number;
|
|
|
- /** vertex index start */
|
|
|
- verticesStart: number;
|
|
|
- /** vertices count */
|
|
|
- verticesCount: number;
|
|
|
- /** index start */
|
|
|
- indexStart: number;
|
|
|
- /** indices count */
|
|
|
- indexCount: number;
|
|
|
/** @hidden */
|
|
|
_linesIndexCount: number;
|
|
|
private _mesh;
|
|
@@ -24495,6 +24493,16 @@ declare module BABYLON {
|
|
|
*/
|
|
|
getRenderingMesh(): Mesh;
|
|
|
/**
|
|
|
+ * Returns the replacement mesh of the submesh
|
|
|
+ * @returns the replacement mesh (could be different from parent mesh)
|
|
|
+ */
|
|
|
+ getReplacementMesh(): Nullable<AbstractMesh>;
|
|
|
+ /**
|
|
|
+ * Returns the effective mesh of the submesh
|
|
|
+ * @returns the effective mesh (could be different from parent mesh)
|
|
|
+ */
|
|
|
+ getEffectiveMesh(): AbstractMesh;
|
|
|
+ /**
|
|
|
* Returns the submesh material
|
|
|
* @returns null or the current material
|
|
|
*/
|
|
@@ -27162,6 +27170,16 @@ declare module BABYLON {
|
|
|
hardwareInstancedRendering: boolean[];
|
|
|
}
|
|
|
/**
|
|
|
+ * @hidden
|
|
|
+ **/
|
|
|
+ class _ThinInstanceDataStorage {
|
|
|
+ instancesCount: number;
|
|
|
+ matrixBuffer: Nullable<Buffer>;
|
|
|
+ matrixBufferSize: number;
|
|
|
+ matrixData: Nullable<Float32Array>;
|
|
|
+ boundingVectors: Array<Vector3>;
|
|
|
+ }
|
|
|
+ /**
|
|
|
* Class used to represent renderable models
|
|
|
*/
|
|
|
export class Mesh extends AbstractMesh implements IGetSetVerticesData {
|
|
@@ -27275,6 +27293,7 @@ declare module BABYLON {
|
|
|
*/
|
|
|
set onBeforeDraw(callback: () => void);
|
|
|
get hasInstances(): boolean;
|
|
|
+ get hasThinInstances(): boolean;
|
|
|
/**
|
|
|
* Gets the delay loading state of the mesh (when delay loading is turned on)
|
|
|
* @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
|
|
@@ -27314,6 +27333,8 @@ declare module BABYLON {
|
|
|
_delayLoadingFunction: (any: any, mesh: Mesh) => void;
|
|
|
/** @hidden */
|
|
|
_instanceDataStorage: _InstanceDataStorage;
|
|
|
+ /** @hidden */
|
|
|
+ _thinInstanceDataStorage: _ThinInstanceDataStorage;
|
|
|
private _effectiveMaterial;
|
|
|
/** @hidden */
|
|
|
_shouldGenerateFlatShading: boolean;
|
|
@@ -27555,6 +27576,7 @@ declare module BABYLON {
|
|
|
_preActivateForIntermediateRendering(renderId: number): Mesh;
|
|
|
/** @hidden */
|
|
|
_registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
|
|
|
+ protected _afterComputeWorldMatrix(): void;
|
|
|
/**
|
|
|
* This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
|
|
|
* This means the mesh underlying bounding box and sphere are recomputed.
|
|
@@ -27719,6 +27741,8 @@ declare module BABYLON {
|
|
|
/** @hidden */
|
|
|
_renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
|
|
|
/** @hidden */
|
|
|
+ _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
|
|
|
+ /** @hidden */
|
|
|
_processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
|
|
|
/** @hidden */
|
|
|
_processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
|
|
@@ -27822,6 +27846,8 @@ declare module BABYLON {
|
|
|
dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
|
|
|
/** @hidden */
|
|
|
_disposeInstanceSpecificData(): void;
|
|
|
+ /** @hidden */
|
|
|
+ _disposeThinInstanceSpecificData(): void;
|
|
|
/**
|
|
|
* Modifies the mesh geometry according to a displacement map.
|
|
|
* A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
|
|
@@ -29314,6 +29340,7 @@ declare module BABYLON {
|
|
|
BonesPerMesh: number;
|
|
|
BONETEXTURE: boolean;
|
|
|
INSTANCES: boolean;
|
|
|
+ THIN_INSTANCES: boolean;
|
|
|
GLOSSINESS: boolean;
|
|
|
ROUGHNESS: boolean;
|
|
|
EMISSIVEASILLUMINATION: boolean;
|
|
@@ -31320,6 +31347,10 @@ declare module BABYLON {
|
|
|
*/
|
|
|
get hasInstances(): boolean;
|
|
|
/**
|
|
|
+ * Gets a boolean indicating if this mesh has thin instances
|
|
|
+ */
|
|
|
+ get hasThinInstances(): boolean;
|
|
|
+ /**
|
|
|
* Perform relative position change from the point of view of behind the front of the mesh.
|
|
|
* This is performed taking into account the meshes current rotation, so you do not have to care.
|
|
|
* Supports definition of mesh facing forward or backward
|
|
@@ -49750,11 +49781,13 @@ declare module BABYLON {
|
|
|
private _gamepadDisconnectedEvent;
|
|
|
private static _MAX_KEYCODES;
|
|
|
private static _MAX_POINTER_INPUTS;
|
|
|
+ private constructor();
|
|
|
/**
|
|
|
- * Default Constructor
|
|
|
- * @param engine - engine to pull input element from
|
|
|
+ * Creates a new DeviceInputSystem instance
|
|
|
+ * @param engine Engine to pull input element from
|
|
|
+ * @returns The new instance
|
|
|
*/
|
|
|
- constructor(engine: Engine);
|
|
|
+ static Create(engine: Engine): DeviceInputSystem;
|
|
|
/**
|
|
|
* Checks for current device input value, given an id and input index
|
|
|
* @param deviceName Id of connected device
|
|
@@ -54568,6 +54601,7 @@ declare module BABYLON {
|
|
|
RADIANCEOCCLUSION: boolean;
|
|
|
HORIZONOCCLUSION: boolean;
|
|
|
INSTANCES: boolean;
|
|
|
+ THIN_INSTANCES: boolean;
|
|
|
NUM_BONE_INFLUENCERS: number;
|
|
|
BonesPerMesh: number;
|
|
|
BONETEXTURE: boolean;
|
|
@@ -60688,7 +60722,7 @@ declare module BABYLON {
|
|
|
*/
|
|
|
get instanceID(): NodeMaterialConnectionPoint;
|
|
|
autoConfigure(material: NodeMaterial): void;
|
|
|
- prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
|
|
|
+ prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
|
|
|
protected _buildBlock(state: NodeMaterialBuildState): this;
|
|
|
}
|
|
|
}
|
|
@@ -64895,6 +64929,85 @@ declare module BABYLON {
|
|
|
}
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
+ interface Mesh {
|
|
|
+ /**
|
|
|
+ * Creates a new thin instance
|
|
|
+ * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
|
|
|
+ * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
|
|
|
+ * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
|
|
|
+ */
|
|
|
+ thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
|
|
|
+ /**
|
|
|
+ * Adds the transformation (matrix) of the current mesh as a thin instance
|
|
|
+ * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
|
|
|
+ * @returns the thin instance index number
|
|
|
+ */
|
|
|
+ thinInstanceAddSelf(refresh: boolean): number;
|
|
|
+ /**
|
|
|
+ * Registers a custom attribute to be used with thin instances
|
|
|
+ * @param kind name of the attribute
|
|
|
+ * @param stride size in floats of the attribute
|
|
|
+ */
|
|
|
+ thinInstanceRegisterAttribute(kind: string, stride: number): void;
|
|
|
+ /**
|
|
|
+ * Sets the matrix of a thin instance
|
|
|
+ * @param index index of the thin instance
|
|
|
+ * @param matrix matrix to set
|
|
|
+ * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
|
|
|
+ */
|
|
|
+ thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
|
|
|
+ /**
|
|
|
+ * Sets the value of a custom attribute for a thin instance
|
|
|
+ * @param kind name of the attribute
|
|
|
+ * @param index index of the thin instance
|
|
|
+ * @param value value to set
|
|
|
+ * @param refresh true to refresh the underlying gpu buffer (default: true). If you do multiple calls to this method in a row, set refresh to true only for the last call to save performance
|
|
|
+ */
|
|
|
+ thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
|
|
|
+ /**
|
|
|
+ * Gets / sets the number of thin instances to display. Note that you can't set a number higher than what the underlying buffer can handle.
|
|
|
+ */
|
|
|
+ thinInstanceCount: number;
|
|
|
+ /**
|
|
|
+ * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
|
|
|
+ * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
|
|
|
+ * @param buffer buffer to set
|
|
|
+ * @param stride size in floats of each value of the buffer
|
|
|
+ * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
|
|
|
+ */
|
|
|
+ thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
|
|
|
+ /**
|
|
|
+ * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
|
|
|
+ * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
|
|
|
+ */
|
|
|
+ thinInstanceBufferUpdated(kind: string): void;
|
|
|
+ /**
|
|
|
+ * Refreshes the bounding info, taking into account all the thin instances defined
|
|
|
+ * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
|
|
|
+ */
|
|
|
+ thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
|
|
|
+ /** @hidden */
|
|
|
+ _thinInstanceInitializeUserStorage(): void;
|
|
|
+ /** @hidden */
|
|
|
+ _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
|
|
|
+ /** @hidden */
|
|
|
+ _userThinInstanceBuffersStorage: {
|
|
|
+ data: {
|
|
|
+ [key: string]: Float32Array;
|
|
|
+ };
|
|
|
+ sizes: {
|
|
|
+ [key: string]: number;
|
|
|
+ };
|
|
|
+ vertexBuffers: {
|
|
|
+ [key: string]: Nullable<VertexBuffer>;
|
|
|
+ };
|
|
|
+ strides: {
|
|
|
+ [key: string]: number;
|
|
|
+ };
|
|
|
+ };
|
|
|
+ }
|
|
|
+}
|
|
|
+declare module BABYLON {
|
|
|
/**
|
|
|
* Navigation plugin interface to add navigation constrained by a navigation mesh
|
|
|
*/
|
|
@@ -66114,10 +66227,6 @@ declare module BABYLON {
|
|
|
*/
|
|
|
getHierarchyEmittedParticleSystems(): IParticleSystem[];
|
|
|
}
|
|
|
- /**
|
|
|
- * @hidden
|
|
|
- */
|
|
|
- export var _IDoNeedToBeInTheBuild: number;
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
/** Defines the 4 color options */
|
|
@@ -71982,6 +72091,15 @@ declare module BABYLON {
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
/**
|
|
|
+ * An interface for all Hit test features
|
|
|
+ */
|
|
|
+ export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
|
|
|
+ /**
|
|
|
+ * Triggered when new babylon (transformed) hit test results are available
|
|
|
+ */
|
|
|
+ onHitTestResultObservable: Observable<T[]>;
|
|
|
+ }
|
|
|
+ /**
|
|
|
* Options used for hit testing
|
|
|
*/
|
|
|
export interface IWebXRLegacyHitTestOptions {
|
|
@@ -72012,7 +72130,7 @@ declare module BABYLON {
|
|
|
* Hit test (or Ray-casting) is used to interact with the real world.
|
|
|
* For further information read here - https://github.com/immersive-web/hit-test
|
|
|
*/
|
|
|
- export class WebXRHitTestLegacy extends WebXRAbstractFeature {
|
|
|
+ export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
|
|
|
/**
|
|
|
* options to use when constructing this feature
|
|
|
*/
|
|
@@ -72091,48 +72209,74 @@ declare module BABYLON {
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
/**
|
|
|
- * Options used in the plane detector module
|
|
|
+ * Options used for hit testing (version 2)
|
|
|
*/
|
|
|
- export interface IWebXRPlaneDetectorOptions {
|
|
|
+ export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
|
|
|
/**
|
|
|
- * The node to use to transform the local results to world coordinates
|
|
|
+ * Do not create a permanent hit test. Will usually be used when only
|
|
|
+ * transient inputs are needed.
|
|
|
*/
|
|
|
- worldParentNode?: TransformNode;
|
|
|
+ disablePermanentHitTest?: boolean;
|
|
|
+ /**
|
|
|
+ * Enable transient (for example touch-based) hit test inspections
|
|
|
+ */
|
|
|
+ enableTransientHitTest?: boolean;
|
|
|
+ /**
|
|
|
+ * Offset ray for the permanent hit test
|
|
|
+ */
|
|
|
+ offsetRay?: Vector3;
|
|
|
+ /**
|
|
|
+ * Offset ray for the transient hit test
|
|
|
+ */
|
|
|
+ transientOffsetRay?: Vector3;
|
|
|
+ /**
|
|
|
+ * Instead of using viewer space for hit tests, use the reference space defined in the session manager
|
|
|
+ */
|
|
|
+ useReferenceSpace?: boolean;
|
|
|
}
|
|
|
/**
|
|
|
- * A babylon interface for a WebXR plane.
|
|
|
- * A Plane is actually a polygon, built from N points in space
|
|
|
- *
|
|
|
- * Supported in chrome 79, not supported in canary 81 ATM
|
|
|
+ * Interface defining the babylon result of hit-test
|
|
|
*/
|
|
|
- export interface IWebXRPlane {
|
|
|
+ export interface IWebXRHitResult extends IWebXRLegacyHitResult {
|
|
|
/**
|
|
|
- * a babylon-assigned ID for this polygon
|
|
|
+ * The input source that generated this hit test (if transient)
|
|
|
*/
|
|
|
- id: number;
|
|
|
+ inputSource?: XRInputSource;
|
|
|
/**
|
|
|
- * an array of vector3 points in babylon space. right/left hand system is taken into account.
|
|
|
+ * Is this a transient hit test
|
|
|
*/
|
|
|
- polygonDefinition: Array<Vector3>;
|
|
|
+ isTransient?: boolean;
|
|
|
/**
|
|
|
- * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
|
|
|
- * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
|
|
|
+ * Position of the hit test result
|
|
|
*/
|
|
|
- transformationMatrix: Matrix;
|
|
|
+ position: Vector3;
|
|
|
/**
|
|
|
- * the native xr-plane object
|
|
|
+ * Rotation of the hit test result
|
|
|
*/
|
|
|
- xrPlane: XRPlane;
|
|
|
+ rotationQuaternion: Quaternion;
|
|
|
+ /**
|
|
|
+ * The native hit test result
|
|
|
+ */
|
|
|
+ xrHitResult: XRHitTestResult;
|
|
|
}
|
|
|
/**
|
|
|
- * The plane detector is used to detect planes in the real world when in AR
|
|
|
- * For more information see https://github.com/immersive-web/real-world-geometry/
|
|
|
+ * The currently-working hit-test module.
|
|
|
+ * Hit test (or Ray-casting) is used to interact with the real world.
|
|
|
+ * For further information read here - https://github.com/immersive-web/hit-test
|
|
|
+ *
|
|
|
+ * Tested on chrome (mobile) 80.
|
|
|
*/
|
|
|
- export class WebXRPlaneDetector extends WebXRAbstractFeature {
|
|
|
- private _options;
|
|
|
- private _detectedPlanes;
|
|
|
- private _enabled;
|
|
|
- private _lastFrameDetected;
|
|
|
+ export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
|
|
|
+ /**
|
|
|
+ * options to use when constructing this feature
|
|
|
+ */
|
|
|
+ readonly options: IWebXRHitTestOptions;
|
|
|
+ private _tmpMat;
|
|
|
+ private _tmpPos;
|
|
|
+ private _tmpQuat;
|
|
|
+ private _transientXrHitTestSource;
|
|
|
+ private _xrHitTestSource;
|
|
|
+ private initHitTestSource;
|
|
|
/**
|
|
|
* The module's name
|
|
|
*/
|
|
@@ -72144,36 +72288,49 @@ declare module BABYLON {
|
|
|
*/
|
|
|
static readonly Version: number;
|
|
|
/**
|
|
|
- * Observers registered here will be executed when a new plane was added to the session
|
|
|
+ * When set to true, each hit test will have its own position/rotation objects
|
|
|
+ * When set to false, position and rotation objects will be reused for each hit test. It is expected that
|
|
|
+ * the developers will clone them or copy them as they see fit.
|
|
|
*/
|
|
|
- onPlaneAddedObservable: Observable<IWebXRPlane>;
|
|
|
+ autoCloneTransformation: boolean;
|
|
|
/**
|
|
|
- * Observers registered here will be executed when a plane is no longer detected in the session
|
|
|
+ * Triggered when new babylon (transformed) hit test results are available
|
|
|
*/
|
|
|
- onPlaneRemovedObservable: Observable<IWebXRPlane>;
|
|
|
+ onHitTestResultObservable: Observable<IWebXRHitResult[]>;
|
|
|
/**
|
|
|
- * Observers registered here will be executed when an existing plane updates (for example - expanded)
|
|
|
- * This can execute N times every frame
|
|
|
+ * Use this to temporarily pause hit test checks.
|
|
|
*/
|
|
|
- onPlaneUpdatedObservable: Observable<IWebXRPlane>;
|
|
|
+ paused: boolean;
|
|
|
/**
|
|
|
- * construct a new Plane Detector
|
|
|
- * @param _xrSessionManager an instance of xr Session manager
|
|
|
- * @param _options configuration to use when constructing this feature
|
|
|
+ * Creates a new instance of the hit test feature
|
|
|
+ * @param _xrSessionManager an instance of WebXRSessionManager
|
|
|
+ * @param options options to use when constructing this feature
|
|
|
*/
|
|
|
- constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
|
|
|
+ constructor(_xrSessionManager: WebXRSessionManager,
|
|
|
+ /**
|
|
|
+ * options to use when constructing this feature
|
|
|
+ */
|
|
|
+ options?: IWebXRHitTestOptions);
|
|
|
+ /**
|
|
|
+ * attach this feature
|
|
|
+ * Will usually be called by the features manager
|
|
|
+ *
|
|
|
+ * @returns true if successful.
|
|
|
+ */
|
|
|
+ attach(): boolean;
|
|
|
+ /**
|
|
|
+ * detach this feature.
|
|
|
+ * Will usually be called by the features manager
|
|
|
+ *
|
|
|
+ * @returns true if successful.
|
|
|
+ */
|
|
|
+ detach(): boolean;
|
|
|
/**
|
|
|
* Dispose this feature and all of the resources attached
|
|
|
*/
|
|
|
dispose(): void;
|
|
|
protected _onXRFrame(frame: XRFrame): void;
|
|
|
- private _init;
|
|
|
- private _updatePlaneWithXRPlane;
|
|
|
- /**
|
|
|
- * avoiding using Array.find for global support.
|
|
|
- * @param xrPlane the plane to find in the array
|
|
|
- */
|
|
|
- private findIndexInPlaneArray;
|
|
|
+ private _processWebXRHitTestResult;
|
|
|
}
|
|
|
}
|
|
|
declare module BABYLON {
|
|
@@ -72182,18 +72339,14 @@ declare module BABYLON {
|
|
|
*/
|
|
|
export interface IWebXRAnchorSystemOptions {
|
|
|
/**
|
|
|
- * Should a new anchor be added every time a select event is triggered
|
|
|
- */
|
|
|
- addAnchorOnSelect?: boolean;
|
|
|
- /**
|
|
|
- * should the anchor system use plane detection.
|
|
|
- * If set to true, the plane-detection feature should be set using setPlaneDetector
|
|
|
- */
|
|
|
- usePlaneDetection?: boolean;
|
|
|
- /**
|
|
|
* a node that will be used to convert local to world coordinates
|
|
|
*/
|
|
|
worldParentNode?: TransformNode;
|
|
|
+ /**
|
|
|
+ * If set to true a reference of the created anchors will be kept until the next session starts
|
|
|
+ * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
|
|
|
+ */
|
|
|
+ doNotRemoveAnchorsOnSessionEnded?: boolean;
|
|
|
}
|
|
|
/**
|
|
|
* A babylon container for an XR Anchor
|
|
@@ -72211,21 +72364,21 @@ declare module BABYLON {
|
|
|
* The native anchor object
|
|
|
*/
|
|
|
xrAnchor: XRAnchor;
|
|
|
+ /**
|
|
|
+ * if defined, this object will be constantly updated by the anchor's position and rotation
|
|
|
+ */
|
|
|
+ attachedNode?: TransformNode;
|
|
|
}
|
|
|
/**
|
|
|
- * An implementation of the anchor system of WebXR.
|
|
|
- * Note that the current documented implementation is not available in any browser. Future implementations
|
|
|
- * will use the frame to create an anchor and not the session or a detected plane
|
|
|
+ * An implementation of the anchor system for WebXR.
|
|
|
* For further information see https://github.com/immersive-web/anchors/
|
|
|
*/
|
|
|
export class WebXRAnchorSystem extends WebXRAbstractFeature {
|
|
|
private _options;
|
|
|
- private _enabled;
|
|
|
- private _hitTestModule;
|
|
|
private _lastFrameDetected;
|
|
|
- private _onSelect;
|
|
|
- private _planeDetector;
|
|
|
private _trackedAnchors;
|
|
|
+ private _referenceSpaceForFrameAnchors;
|
|
|
+ private _futureAnchors;
|
|
|
/**
|
|
|
* The module's name
|
|
|
*/
|
|
@@ -72250,26 +72403,43 @@ declare module BABYLON {
|
|
|
*/
|
|
|
onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
|
|
|
/**
|
|
|
+ * Set the reference space to use for anchor creation, when not using a hit test.
|
|
|
+ * Will default to the session's reference space if not defined
|
|
|
+ */
|
|
|
+ set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
|
|
|
+ /**
|
|
|
* constructs a new anchor system
|
|
|
* @param _xrSessionManager an instance of WebXRSessionManager
|
|
|
* @param _options configuration object for this feature
|
|
|
*/
|
|
|
constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
|
|
|
+ private _tmpVector;
|
|
|
+ private _tmpQuaternion;
|
|
|
+ private _populateTmpTransformation;
|
|
|
/**
|
|
|
- * Add anchor at a specific XR point.
|
|
|
+ * Create a new anchor point using a hit test result at a specific point in the scene
|
|
|
+ * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
|
|
|
+ * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
|
|
|
*
|
|
|
- * @param xrRigidTransformation xr-coordinates where a new anchor should be added
|
|
|
- * @param anchorCreator the object o use to create an anchor with. either a session or a plane
|
|
|
- * @returns a promise the fulfills when the anchor was created
|
|
|
- */
|
|
|
- addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
|
|
|
- /**
|
|
|
- * attach this feature
|
|
|
- * Will usually be called by the features manager
|
|
|
+ * @param hitTestResult The hit test result to use for this anchor creation
|
|
|
+ * @param position an optional position offset for this anchor
|
|
|
+ * @param rotationQuaternion an optional rotation offset for this anchor
|
|
|
+ * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
|
|
|
+ */
|
|
|
+ addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
|
|
|
+ /**
|
|
|
+ * Add a new anchor at a specific position and rotation
|
|
|
+ * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
|
|
|
+ * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
|
|
|
+ * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
|
|
|
+ * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
|
|
|
*
|
|
|
- * @returns true if successful.
|
|
|
+ * @param position the position in which to add an anchor
|
|
|
+ * @param rotationQuaternion an optional rotation for the anchor transformation
|
|
|
+ * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
|
|
|
+ * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
|
|
|
*/
|
|
|
- attach(): boolean;
|
|
|
+ addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
|
|
|
/**
|
|
|
* detach this feature.
|
|
|
* Will usually be called by the features manager
|
|
@@ -72281,24 +72451,113 @@ declare module BABYLON {
|
|
|
* Dispose this feature and all of the resources attached
|
|
|
*/
|
|
|
dispose(): void;
|
|
|
+ protected _onXRFrame(frame: XRFrame): void;
|
|
|
+ /**
|
|
|
+ * avoiding using Array.find for global support.
|
|
|
+ * @param xrAnchor the plane to find in the array
|
|
|
+ */
|
|
|
+ private _findIndexInAnchorArray;
|
|
|
+ private _updateAnchorWithXRFrame;
|
|
|
+ private _createAnchorAtTransformation;
|
|
|
+ }
|
|
|
+}
|
|
|
+declare module BABYLON {
|
|
|
+ /**
|
|
|
+ * Options used in the plane detector module
|
|
|
+ */
|
|
|
+ export interface IWebXRPlaneDetectorOptions {
|
|
|
+ /**
|
|
|
+ * The node to use to transform the local results to world coordinates
|
|
|
+ */
|
|
|
+ worldParentNode?: TransformNode;
|
|
|
+ /**
|
|
|
+ * If set to true a reference of the created planes will be kept until the next session starts
|
|
|
+ * If not defined, planes will be removed from the array when the feature is detached or the session ended.
|
|
|
+ */
|
|
|
+ doNotRemovePlanesOnSessionEnded?: boolean;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * A babylon interface for a WebXR plane.
|
|
|
+ * A Plane is actually a polygon, built from N points in space
|
|
|
+ *
|
|
|
+ * Supported in chrome 79, not supported in canary 81 ATM
|
|
|
+ */
|
|
|
+ export interface IWebXRPlane {
|
|
|
+ /**
|
|
|
+ * a babylon-assigned ID for this polygon
|
|
|
+ */
|
|
|
+ id: number;
|
|
|
+ /**
|
|
|
+ * an array of vector3 points in babylon space. right/left hand system is taken into account.
|
|
|
+ */
|
|
|
+ polygonDefinition: Array<Vector3>;
|
|
|
+ /**
|
|
|
+ * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
|
|
|
+ * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
|
|
|
+ */
|
|
|
+ transformationMatrix: Matrix;
|
|
|
+ /**
|
|
|
+ * the native xr-plane object
|
|
|
+ */
|
|
|
+ xrPlane: XRPlane;
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * The plane detector is used to detect planes in the real world when in AR
|
|
|
+ * For more information see https://github.com/immersive-web/real-world-geometry/
|
|
|
+ */
|
|
|
+ export class WebXRPlaneDetector extends WebXRAbstractFeature {
|
|
|
+ private _options;
|
|
|
+ private _detectedPlanes;
|
|
|
+ private _enabled;
|
|
|
+ private _lastFrameDetected;
|
|
|
+ /**
|
|
|
+ * The module's name
|
|
|
+ */
|
|
|
+ static readonly Name: string;
|
|
|
+ /**
|
|
|
+ * The (Babylon) version of this module.
|
|
|
+ * This is an integer representing the implementation version.
|
|
|
+ * This number does not correspond to the WebXR specs version
|
|
|
+ */
|
|
|
+ static readonly Version: number;
|
|
|
+ /**
|
|
|
+ * Observers registered here will be executed when a new plane was added to the session
|
|
|
+ */
|
|
|
+ onPlaneAddedObservable: Observable<IWebXRPlane>;
|
|
|
+ /**
|
|
|
+ * Observers registered here will be executed when a plane is no longer detected in the session
|
|
|
+ */
|
|
|
+ onPlaneRemovedObservable: Observable<IWebXRPlane>;
|
|
|
+ /**
|
|
|
+ * Observers registered here will be executed when an existing plane updates (for example - expanded)
|
|
|
+ * This can execute N times every frame
|
|
|
+ */
|
|
|
+ onPlaneUpdatedObservable: Observable<IWebXRPlane>;
|
|
|
+ /**
|
|
|
+ * construct a new Plane Detector
|
|
|
+ * @param _xrSessionManager an instance of xr Session manager
|
|
|
+ * @param _options configuration to use when constructing this feature
|
|
|
+ */
|
|
|
+ constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
|
|
|
/**
|
|
|
- * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
|
|
|
- * @param hitTestModule the hit-test module to use.
|
|
|
+ * detach this feature.
|
|
|
+ * Will usually be called by the features manager
|
|
|
+ *
|
|
|
+ * @returns true if successful.
|
|
|
*/
|
|
|
- setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
|
|
|
+ detach(): boolean;
|
|
|
/**
|
|
|
- * set the plane detector to use in order to create anchors from frames
|
|
|
- * @param planeDetector the plane-detector module to use
|
|
|
- * @param enable enable plane-anchors. default is true
|
|
|
+ * Dispose this feature and all of the resources attached
|
|
|
*/
|
|
|
- setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
|
|
|
+ dispose(): void;
|
|
|
protected _onXRFrame(frame: XRFrame): void;
|
|
|
+ private _init;
|
|
|
+ private _updatePlaneWithXRPlane;
|
|
|
/**
|
|
|
* avoiding using Array.find for global support.
|
|
|
- * @param xrAnchor the plane to find in the array
|
|
|
+ * @param xrPlane the plane to find in the array
|
|
|
*/
|
|
|
- private _findIndexInAnchorArray;
|
|
|
- private _updateAnchorWithXRFrame;
|
|
|
+ private findIndexInPlaneArray;
|
|
|
}
|
|
|
}
|
|
|
declare module BABYLON {
|
|
@@ -72539,132 +72798,6 @@ declare module BABYLON {
|
|
|
}
|
|
|
declare module BABYLON {
|
|
|
/**
|
|
|
- * Options used for hit testing (version 2)
|
|
|
- */
|
|
|
- export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
|
|
|
- /**
|
|
|
- * Do not create a permanent hit test. Will usually be used when only
|
|
|
- * transient inputs are needed.
|
|
|
- */
|
|
|
- disablePermanentHitTest?: boolean;
|
|
|
- /**
|
|
|
- * Enable transient (for example touch-based) hit test inspections
|
|
|
- */
|
|
|
- enableTransientHitTest?: boolean;
|
|
|
- /**
|
|
|
- * Offset ray for the permanent hit test
|
|
|
- */
|
|
|
- offsetRay?: Vector3;
|
|
|
- /**
|
|
|
- * Offset ray for the transient hit test
|
|
|
- */
|
|
|
- transientOffsetRay?: Vector3;
|
|
|
- /**
|
|
|
- * Instead of using viewer space for hit tests, use the reference space defined in the session manager
|
|
|
- */
|
|
|
- useReferenceSpace?: boolean;
|
|
|
- }
|
|
|
- /**
|
|
|
- * Interface defining the babylon result of hit-test
|
|
|
- */
|
|
|
- export interface IWebXRHitResult extends IWebXRLegacyHitResult {
|
|
|
- /**
|
|
|
- * The input source that generated this hit test (if transient)
|
|
|
- */
|
|
|
- inputSource?: XRInputSource;
|
|
|
- /**
|
|
|
- * Is this a transient hit test
|
|
|
- */
|
|
|
- isTransient?: boolean;
|
|
|
- /**
|
|
|
- * Position of the hit test result
|
|
|
- */
|
|
|
- position: Vector3;
|
|
|
- /**
|
|
|
- * Rotation of the hit test result
|
|
|
- */
|
|
|
- rotationQuaternion: Quaternion;
|
|
|
- }
|
|
|
- /**
|
|
|
- * The currently-working hit-test module.
|
|
|
- * Hit test (or Ray-casting) is used to interact with the real world.
|
|
|
- * For further information read here - https://github.com/immersive-web/hit-test
|
|
|
- *
|
|
|
- * Tested on chrome (mobile) 80.
|
|
|
- */
|
|
|
- export class WebXRHitTest extends WebXRAbstractFeature {
|
|
|
- /**
|
|
|
- * options to use when constructing this feature
|
|
|
- */
|
|
|
- readonly options: IWebXRHitTestOptions;
|
|
|
- private _tmpMat;
|
|
|
- private _tmpPos;
|
|
|
- private _tmpQuat;
|
|
|
- private _transientXrHitTestSource;
|
|
|
- private _xrHitTestSource;
|
|
|
- private initHitTestSource;
|
|
|
- /**
|
|
|
- * The module's name
|
|
|
- */
|
|
|
- static readonly Name: string;
|
|
|
- /**
|
|
|
- * The (Babylon) version of this module.
|
|
|
- * This is an integer representing the implementation version.
|
|
|
- * This number does not correspond to the WebXR specs version
|
|
|
- */
|
|
|
- static readonly Version: number;
|
|
|
- /**
|
|
|
- * When set to true, each hit test will have its own position/rotation objects
|
|
|
- * When set to false, position and rotation objects will be reused for each hit test. It is expected that
|
|
|
- * the developers will clone them or copy them as they see fit.
|
|
|
- */
|
|
|
- autoCloneTransformation: boolean;
|
|
|
- /**
|
|
|
- * Populated with the last native XR Hit Results
|
|
|
- */
|
|
|
- lastNativeXRHitResults: XRHitResult[];
|
|
|
- /**
|
|
|
- * Triggered when new babylon (transformed) hit test results are available
|
|
|
- */
|
|
|
- onHitTestResultObservable: Observable<IWebXRHitResult[]>;
|
|
|
- /**
|
|
|
- * Use this to temporarily pause hit test checks.
|
|
|
- */
|
|
|
- paused: boolean;
|
|
|
- /**
|
|
|
- * Creates a new instance of the hit test feature
|
|
|
- * @param _xrSessionManager an instance of WebXRSessionManager
|
|
|
- * @param options options to use when constructing this feature
|
|
|
- */
|
|
|
- constructor(_xrSessionManager: WebXRSessionManager,
|
|
|
- /**
|
|
|
- * options to use when constructing this feature
|
|
|
- */
|
|
|
- options?: IWebXRHitTestOptions);
|
|
|
- /**
|
|
|
- * attach this feature
|
|
|
- * Will usually be called by the features manager
|
|
|
- *
|
|
|
- * @returns true if successful.
|
|
|
- */
|
|
|
- attach(): boolean;
|
|
|
- /**
|
|
|
- * detach this feature.
|
|
|
- * Will usually be called by the features manager
|
|
|
- *
|
|
|
- * @returns true if successful.
|
|
|
- */
|
|
|
- detach(): boolean;
|
|
|
- /**
|
|
|
- * Dispose this feature and all of the resources attached
|
|
|
- */
|
|
|
- dispose(): void;
|
|
|
- protected _onXRFrame(frame: XRFrame): void;
|
|
|
- private _processWebXRHitTestResult;
|
|
|
- }
|
|
|
-}
|
|
|
-declare module BABYLON {
|
|
|
- /**
|
|
|
* The motion controller class for all microsoft mixed reality controllers
|
|
|
*/
|
|
|
export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
|
|
@@ -73468,7 +73601,7 @@ interface XRSessionInit {
|
|
|
requiredFeatures?: string[];
|
|
|
}
|
|
|
|
|
|
-interface XRSession extends XRAnchorCreator {
|
|
|
+interface XRSession {
|
|
|
addEventListener: Function;
|
|
|
removeEventListener: Function;
|
|
|
requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
|
|
@@ -73509,6 +73642,7 @@ interface XRFrame {
|
|
|
getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
|
|
|
// Anchors
|
|
|
trackedAnchors?: XRAnchorSet;
|
|
|
+ createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
|
|
|
// Planes
|
|
|
worldInformation: {
|
|
|
detectedPlanes?: XRPlaneSet;
|
|
@@ -73593,6 +73727,8 @@ interface XRTransientInputHitTestResult {
|
|
|
|
|
|
interface XRHitTestResult {
|
|
|
getPose(baseSpace: XRSpace): XRPose | undefined;
|
|
|
+ // When anchor system is enabled
|
|
|
+ createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
|
|
|
}
|
|
|
|
|
|
interface XRHitTestSource {
|
|
@@ -73616,21 +73752,13 @@ interface XRTransientInputHitTestOptionsInit {
|
|
|
}
|
|
|
|
|
|
interface XRAnchor {
|
|
|
- // remove?
|
|
|
- id?: string;
|
|
|
anchorSpace: XRSpace;
|
|
|
- lastChangedTime: number;
|
|
|
- detach(): void;
|
|
|
+ delete(): void;
|
|
|
}
|
|
|
|
|
|
-interface XRPlane extends XRAnchorCreator {
|
|
|
+interface XRPlane {
|
|
|
orientation: "Horizontal" | "Vertical";
|
|
|
planeSpace: XRSpace;
|
|
|
polygon: Array<DOMPointReadOnly>;
|
|
|
lastChangedTime: number;
|
|
|
-}
|
|
|
-
|
|
|
-interface XRAnchorCreator {
|
|
|
- // AR Anchors
|
|
|
- createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
|
|
|
}
|