@iwsdk/xr-input 1.0.0-rc.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gamepad/generated-profiles.js.map +1 -1
- package/dist/gamepad/input-profiles.js.map +1 -1
- package/dist/gamepad/stateful-button-axes-device.js.map +1 -1
- package/dist/gamepad/stateful-gamepad.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/pointer/cursor-visual.js.map +1 -1
- package/dist/pointer/filtered-eye-gaze.d.ts +48 -0
- package/dist/pointer/filtered-eye-gaze.d.ts.map +1 -0
- package/dist/pointer/filtered-eye-gaze.js +118 -0
- package/dist/pointer/filtered-eye-gaze.js.map +1 -0
- package/dist/pointer/gaze-candidate-provider.d.ts +58 -0
- package/dist/pointer/gaze-candidate-provider.d.ts.map +1 -0
- package/dist/pointer/gaze-conecaster.d.ts +130 -0
- package/dist/pointer/gaze-conecaster.d.ts.map +1 -0
- package/dist/pointer/gaze-conecaster.js +456 -0
- package/dist/pointer/gaze-conecaster.js.map +1 -0
- package/dist/pointer/gaze-pointer.d.ts +266 -0
- package/dist/pointer/gaze-pointer.d.ts.map +1 -0
- package/dist/pointer/gaze-pointer.js +865 -0
- package/dist/pointer/gaze-pointer.js.map +1 -0
- package/dist/pointer/grab-pointer.js.map +1 -1
- package/dist/pointer/multi-pointer.d.ts +21 -6
- package/dist/pointer/multi-pointer.d.ts.map +1 -1
- package/dist/pointer/multi-pointer.js +52 -12
- package/dist/pointer/multi-pointer.js.map +1 -1
- package/dist/pointer/ray-pointer.js.map +1 -1
- package/dist/pointer/touch-pointer.js.map +1 -1
- package/dist/pointer/visibility.js.map +1 -1
- package/dist/rig/xr-origin.d.ts +26 -0
- package/dist/rig/xr-origin.d.ts.map +1 -1
- package/dist/rig/xr-origin.js +25 -1
- package/dist/rig/xr-origin.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/visual/adapter/base-visual-adapter.js.map +1 -1
- package/dist/visual/adapter/controller-visual-adapter.js.map +1 -1
- package/dist/visual/adapter/hand-visual-adapter.d.ts +9 -0
- package/dist/visual/adapter/hand-visual-adapter.d.ts.map +1 -1
- package/dist/visual/adapter/hand-visual-adapter.js +47 -9
- package/dist/visual/adapter/hand-visual-adapter.js.map +1 -1
- package/dist/visual/impl/animated-controller-hand.js.map +1 -1
- package/dist/visual/impl/animated-controller.js.map +1 -1
- package/dist/visual/impl/animated-hand.js.map +1 -1
- package/dist/visual/impl/base-impl.js.map +1 -1
- package/dist/visual/utils/flex-batched-mesh.js.map +1 -1
- package/dist/visual/utils/simple-batched-mesh.js.map +1 -1
- package/dist/xr-input-manager.d.ts +57 -1
- package/dist/xr-input-manager.d.ts.map +1 -1
- package/dist/xr-input-manager.js +285 -15
- package/dist/xr-input-manager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-batched-mesh.js","sources":["../../../src/visual/utils/simple-batched-mesh.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;AAKG;AAEH;;;;;;;;;;;AAWG;AAeH,MAAM,YAAY,GAAG,SAAS;AAC9B,MAAM,eAAe,GAAG,IAAI,OAAO,EAAE;AAErC;AACA,SAAS,iBAAiB,CACxB,GAAoB,EACpB,MAAuB,EACvB,YAAY,GAAG,CAAC,EAAA;AAEhB,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ;AAChC,IAAA,IAAI,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE;AACtD,QAAA,MAAM,WAAW,GAAG,GAAG,CAAC,KAAK;AAC7B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE;AACpC,YAAA,KAAK,IAAI,CAAC,GAAG,CAA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A,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,OAAO,EAAE;IAClC;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"simple-batched-mesh.js","sources":["../../../src/visual/utils/simple-batched-mesh.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n/**\n * SimpleBatchedMesh - A multiview-compatible batched mesh implementation\n *\n * This is based on the THREE.js r165 BatchedMesh approach which uses a vertex\n * attribute for batch IDs instead of gl_DrawID. This works correctly with\n * multiview rendering on Quest, where the gl_DrawID-based approach fails.\n *\n * Key differences from modern THREE.js BatchedMesh:\n * - Uses `attribute float batchId` instead of `gl_DrawID`\n * - Simpler API: each geometry is its own instance\n * - No dependency on WEBGL_multi_draw extension\n */\n\nimport {\n Box3,\n BufferAttribute,\n BufferGeometry,\n DataTexture,\n FloatType,\n Material,\n Matrix4,\n Mesh,\n RGBAFormat,\n Sphere,\n} from 'three';\n\nconst ID_ATTR_NAME = 'batchId';\nconst _identityMatrix = new Matrix4();\n\n// Helper to copy attribute data\nfunction copyAttributeData(\n src: BufferAttribute,\n target: BufferAttribute,\n targetOffset = 0,\n) {\n const itemSize = target.itemSize;\n if (src.array.constructor !== target.array.constructor) {\n const vertexCount = src.count;\n for (let i = 0; i < vertexCount; i++) {\n for (let c = 0; c < itemSize; c++) {\n target.setComponent(i + targetOffset, c, src.getComponent(i, c));\n }\n }\n } else {\n target.array.set(src.array, targetOffset * itemSize);\n }\n target.needsUpdate = true;\n}\n\nexport class SimpleBatchedMesh extends Mesh {\n // Do NOT set isBatchedMesh = true - that triggers THREE.js's multi-draw path\n // which we don't support. Instead we handle batching entirely through material patching.\n readonly isSimpleBatchedMesh = true;\n\n private _drawRanges: Array<{ start: number; count: number }> = [];\n private _reservedRanges: Array<{\n vertexStart: number;\n vertexCount: number;\n indexStart: number;\n indexCount: number;\n }> = [];\n private _visibility: boolean[] = [];\n private _active: boolean[] = [];\n private _bounds: Array<{\n boxInitialized: boolean;\n box: Box3;\n sphereInitialized: boolean;\n sphere: Sphere;\n }> = [];\n\n private _maxGeometryCount: number;\n private _maxVertexCount: number;\n private _maxIndexCount: number;\n\n private _geometryInitialized = false;\n private _geometryCount = 0;\n\n // Matrices texture for batch transforms\n private _matricesTexture: DataTexture | null = null;\n\n constructor(\n maxGeometryCount: number,\n maxVertexCount: number,\n maxIndexCount: number = maxVertexCount * 2,\n material: Material,\n ) {\n super(new BufferGeometry(), material);\n\n this._maxGeometryCount = maxGeometryCount;\n this._maxVertexCount = maxVertexCount;\n this._maxIndexCount = maxIndexCount;\n\n this._initMatricesTexture();\n\n // Patch the material to use batchId attribute\n this._patchMaterial(material);\n }\n\n get maxGeometryCount() {\n return this._maxGeometryCount;\n }\n\n private _initMatricesTexture() {\n // Layout: 1 matrix = 4 pixels (RGBA each column)\n let size = Math.sqrt(this._maxGeometryCount * 4);\n size = Math.ceil(size / 4) * 4;\n size = Math.max(size, 4);\n\n const matricesArray = new Float32Array(size * size * 4);\n const matricesTexture = new DataTexture(\n matricesArray,\n size,\n size,\n RGBAFormat,\n FloatType,\n );\n\n this._matricesTexture = matricesTexture;\n }\n\n private _patchMaterial(material: Material) {\n // Add the batchingTexture uniform and onBeforeCompile hook\n const self = this;\n\n material.onBeforeCompile = (shader) => {\n // Add uniforms\n shader.uniforms.batchingTexture = { value: self._matricesTexture };\n\n // Inject USE_BATCHING define at the start of vertex shader\n // (THREE.js won't add it since we don't set isBatchedMesh = true)\n shader.vertexShader = '#define USE_BATCHING\\n' + shader.vertexShader;\n\n // Add batching pars to vertex shader (r165 style with attribute)\n // Includes both matrix lookup and color lookup functions\n const batchingParsVertex = `\n #ifdef USE_BATCHING\n attribute float batchId;\n uniform highp sampler2D batchingTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n #endif\n #ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec3 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;\n }\n #endif\n `;\n\n // Replace THREE.js batching_pars_vertex\n shader.vertexShader = shader.vertexShader.replace(\n '#include <batching_pars_vertex>',\n batchingParsVertex,\n );\n\n // Replace batching_vertex to use batchId attribute\n const batchingVertex = `\n #ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( batchId );\n #endif\n `;\n\n shader.vertexShader = shader.vertexShader.replace(\n '#include <batching_vertex>',\n batchingVertex,\n );\n\n // Replace color_vertex to use batchId for batching color (r165 style)\n // The r181 version uses getIndirectIndex(gl_DrawID) which we don't support\n const colorVertex = `\n #if defined( USE_COLOR_ALPHA )\n vColor = vec4( 1.0 );\n #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec3( 1.0 );\n #endif\n #ifdef USE_COLOR\n vColor *= color;\n #endif\n #ifdef USE_INSTANCING_COLOR\n vColor.xyz *= instanceColor.xyz;\n #endif\n #ifdef USE_BATCHING_COLOR\n vec3 batchingColor = getBatchingColor( batchId );\n vColor.xyz *= batchingColor.xyz;\n #endif\n `;\n\n shader.vertexShader = shader.vertexShader.replace(\n '#include <color_vertex>',\n colorVertex,\n );\n };\n\n // Force material to use batching\n (material as any).batching = true;\n material.needsUpdate = true;\n }\n\n private _initializeGeometry(reference: BufferGeometry) {\n const geometry = this.geometry as BufferGeometry;\n const maxVertexCount = this._maxVertexCount;\n const maxGeometryCount = this._maxGeometryCount;\n const maxIndexCount = this._maxIndexCount;\n\n if (this._geometryInitialized === false) {\n for (const attributeName in reference.attributes) {\n const srcAttribute = reference.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const { array, itemSize, normalized } = srcAttribute;\n\n const dstArray = new (array.constructor as any)(\n maxVertexCount * itemSize,\n );\n const dstAttribute = new BufferAttribute(\n dstArray,\n itemSize,\n normalized,\n );\n\n geometry.setAttribute(attributeName, dstAttribute);\n }\n\n if (reference.getIndex() !== null) {\n const indexArray =\n maxVertexCount > 65536\n ? new Uint32Array(maxIndexCount)\n : new Uint16Array(maxIndexCount);\n\n geometry.setIndex(new BufferAttribute(indexArray, 1));\n }\n\n // Add batchId attribute (the key difference from r181)\n const idArray =\n maxGeometryCount > 65536\n ? new Uint32Array(maxVertexCount)\n : new Uint16Array(maxVertexCount);\n geometry.setAttribute(ID_ATTR_NAME, new BufferAttribute(idArray, 1));\n\n this._geometryInitialized = true;\n }\n }\n\n private _validateGeometry(geometry: BufferGeometry) {\n if (geometry.getAttribute(ID_ATTR_NAME)) {\n throw new Error(\n `SimpleBatchedMesh: Geometry cannot use attribute \"${ID_ATTR_NAME}\"`,\n );\n }\n\n const batchGeometry = this.geometry as BufferGeometry;\n if (Boolean(geometry.getIndex()) !== Boolean(batchGeometry.getIndex())) {\n throw new Error(\n 'SimpleBatchedMesh: All geometries must consistently have \"index\".',\n );\n }\n\n for (const attributeName in batchGeometry.attributes) {\n if (attributeName === ID_ATTR_NAME) {\n continue;\n }\n\n if (!geometry.hasAttribute(attributeName)) {\n throw new Error(\n `SimpleBatchedMesh: Added geometry missing \"${attributeName}\".`,\n );\n }\n\n const srcAttribute = geometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const dstAttribute = batchGeometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n if (\n srcAttribute.itemSize !== dstAttribute.itemSize ||\n srcAttribute.normalized !== dstAttribute.normalized\n ) {\n throw new Error(\n 'SimpleBatchedMesh: All attributes must have consistent itemSize and normalized value.',\n );\n }\n }\n }\n\n addGeometry(\n geometry: BufferGeometry,\n vertexCount = -1,\n indexCount = -1,\n ): number {\n this._initializeGeometry(geometry);\n this._validateGeometry(geometry);\n\n if (this._geometryCount >= this._maxGeometryCount) {\n throw new Error('SimpleBatchedMesh: Maximum geometry count reached.');\n }\n\n const reservedRange = {\n vertexStart: -1,\n vertexCount: -1,\n indexStart: -1,\n indexCount: -1,\n };\n\n let lastRange = null;\n const reservedRanges = this._reservedRanges;\n if (this._geometryCount !== 0) {\n lastRange = reservedRanges[reservedRanges.length - 1];\n }\n\n if (vertexCount === -1) {\n reservedRange.vertexCount = (\n geometry.getAttribute('position') as BufferAttribute\n ).count;\n } else {\n reservedRange.vertexCount = vertexCount;\n }\n\n if (lastRange === null) {\n reservedRange.vertexStart = 0;\n } else {\n reservedRange.vertexStart = lastRange.vertexStart + lastRange.vertexCount;\n }\n\n const index = geometry.getIndex();\n const hasIndex = index !== null;\n if (hasIndex) {\n if (indexCount === -1) {\n reservedRange.indexCount = index!.count;\n } else {\n reservedRange.indexCount = indexCount;\n }\n\n if (lastRange === null) {\n reservedRange.indexStart = 0;\n } else {\n reservedRange.indexStart = lastRange.indexStart + lastRange.indexCount;\n }\n }\n\n if (\n (reservedRange.indexStart !== -1 &&\n reservedRange.indexStart + reservedRange.indexCount >\n this._maxIndexCount) ||\n reservedRange.vertexStart + reservedRange.vertexCount >\n this._maxVertexCount\n ) {\n throw new Error(\n 'SimpleBatchedMesh: Reserved space request exceeds maximum buffer size.',\n );\n }\n\n this._visibility.push(true);\n this._active.push(true);\n\n const geometryId = this._geometryCount;\n this._geometryCount++;\n\n // Initialize matrix to identity\n const matricesArray = this._matricesTexture!.image.data as Float32Array;\n _identityMatrix.toArray(matricesArray, geometryId * 16);\n this._matricesTexture!.needsUpdate = true;\n\n reservedRanges.push(reservedRange);\n this._drawRanges.push({\n start: hasIndex ? reservedRange.indexStart : reservedRange.vertexStart,\n count: -1,\n });\n this._bounds.push({\n boxInitialized: false,\n box: new Box3(),\n sphereInitialized: false,\n sphere: new Sphere(),\n });\n\n // Set the batchId for all vertices of this geometry\n const idAttribute = (this.geometry as BufferGeometry).getAttribute(\n ID_ATTR_NAME,\n ) as BufferAttribute;\n for (let i = 0; i < reservedRange.vertexCount; i++) {\n idAttribute.setX(reservedRange.vertexStart + i, geometryId);\n }\n idAttribute.needsUpdate = true;\n\n // Copy geometry data\n this.setGeometryAt(geometryId, geometry);\n\n return geometryId;\n }\n\n setGeometryAt(id: number, geometry: BufferGeometry): number {\n if (id >= this._geometryCount) {\n throw new Error('SimpleBatchedMesh: Maximum geometry count reached.');\n }\n\n this._validateGeometry(geometry);\n\n const batchGeometry = this.geometry as BufferGeometry;\n const hasIndex = batchGeometry.getIndex() !== null;\n const dstIndex = batchGeometry.getIndex();\n const srcIndex = geometry.getIndex();\n const reservedRange = this._reservedRanges[id];\n\n if (\n (hasIndex && srcIndex!.count > reservedRange.indexCount) ||\n (geometry.getAttribute('position') as BufferAttribute).count >\n reservedRange.vertexCount\n ) {\n throw new Error(\n 'SimpleBatchedMesh: Reserved space not large enough for provided geometry.',\n );\n }\n\n const vertexStart = reservedRange.vertexStart;\n const vertexCount = reservedRange.vertexCount;\n\n for (const attributeName in batchGeometry.attributes) {\n if (attributeName === ID_ATTR_NAME) {\n continue;\n }\n\n const srcAttribute = geometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n const dstAttribute = batchGeometry.getAttribute(\n attributeName,\n ) as BufferAttribute;\n copyAttributeData(srcAttribute, dstAttribute, vertexStart);\n\n // Fill rest with zeroes\n const itemSize = srcAttribute.itemSize;\n for (let i = srcAttribute.count; i < vertexCount; i++) {\n const index = vertexStart + i;\n for (let c = 0; c < itemSize; c++) {\n dstAttribute.setComponent(index, c, 0);\n }\n }\n\n dstAttribute.needsUpdate = true;\n }\n\n // Copy index\n if (hasIndex && dstIndex && srcIndex) {\n const indexStart = reservedRange.indexStart;\n\n for (let i = 0; i < srcIndex.count; i++) {\n dstIndex.setX(indexStart + i, vertexStart + srcIndex.getX(i));\n }\n\n for (let i = srcIndex.count; i < reservedRange.indexCount; i++) {\n dstIndex.setX(indexStart + i, vertexStart);\n }\n\n dstIndex.needsUpdate = true;\n }\n\n // Store bounding info\n const bound = this._bounds[id];\n if (geometry.boundingBox !== null) {\n bound.box.copy(geometry.boundingBox);\n bound.boxInitialized = true;\n } else {\n bound.boxInitialized = false;\n }\n\n if (geometry.boundingSphere !== null) {\n bound.sphere.copy(geometry.boundingSphere);\n bound.sphereInitialized = true;\n } else {\n bound.sphereInitialized = false;\n }\n\n // Set draw range count\n const drawRange = this._drawRanges[id];\n const posAttr = geometry.getAttribute('position') as BufferAttribute;\n drawRange.count = hasIndex ? srcIndex!.count : posAttr.count;\n\n return id;\n }\n\n setMatrixAt(geometryId: number, matrix: Matrix4): this {\n const active = this._active;\n const matricesTexture = this._matricesTexture!;\n const matricesArray = matricesTexture.image.data as Float32Array;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return this;\n }\n\n matrix.toArray(matricesArray, geometryId * 16);\n matricesTexture.needsUpdate = true;\n\n return this;\n }\n\n getMatrixAt(geometryId: number, matrix: Matrix4): Matrix4 | null {\n const active = this._active;\n const matricesArray = this._matricesTexture!.image.data as Float32Array;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return null;\n }\n\n return matrix.fromArray(matricesArray, geometryId * 16);\n }\n\n setVisibleAt(geometryId: number, value: boolean): this {\n const visibility = this._visibility;\n const active = this._active;\n\n if (\n geometryId >= this._geometryCount ||\n active[geometryId] === false ||\n visibility[geometryId] === value\n ) {\n return this;\n }\n\n visibility[geometryId] = value;\n return this;\n }\n\n getVisibleAt(geometryId: number): boolean {\n const visibility = this._visibility;\n const active = this._active;\n\n if (geometryId >= this._geometryCount || active[geometryId] === false) {\n return false;\n }\n\n return visibility[geometryId];\n }\n\n dispose() {\n this.geometry.dispose();\n this._matricesTexture?.dispose();\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AI;QACb;AAEA,QAAA,UAAU,CAAC,UAAU,CAAC,GAAG,KAAK;AAC9B,QAAA,OAAO,IAAI;IACb;AAEA,IAAA,YAAY,CAAC,UAAkB,EAAA;AAC7B,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW;AACnC,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO;AAE3B,QAAA,IAAI,UAAU,IAAI,IAAI,CAAC,cAAc,IAAI,MAAM,CAAC,UAAU,CAAC,KAAK,KAAK,EAAE;AACrE,YAAA,OAAO,KAAK;QACd;AAEA,QAAA,OAAO,UAAU,CAAC,UAAU,CAAC;IAC/B;IAEA,OAAO,GAAA;;AACL,QAAA,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;AACvB,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,gBAAgB,MAAA,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,MAAA,GAAA,EAAA,CAAE,OAAO,EAAE;IAClC;AACD;;;;"}
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { Signal } from '@preact/signals-core';
|
|
8
|
-
import { PerspectiveCamera, Scene, WebXRManager } from 'three';
|
|
8
|
+
import { Object3D, PerspectiveCamera, Scene, WebXRManager } from 'three';
|
|
9
9
|
import { GLTF, GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
10
10
|
import { StatefulGamepad } from './gamepad/stateful-gamepad.js';
|
|
11
|
+
import { GazePointer } from './pointer/gaze-pointer.js';
|
|
11
12
|
import { MultiPointer } from './pointer/multi-pointer.js';
|
|
12
13
|
import { XROrigin } from './rig/xr-origin.js';
|
|
13
14
|
import { XRInputVisualAdapter } from './visual/adapter/base-visual-adapter.js';
|
|
@@ -44,6 +45,32 @@ export interface XRInputOptions {
|
|
|
44
45
|
export declare class XRInputManager {
|
|
45
46
|
readonly xrOrigin: XROrigin;
|
|
46
47
|
readonly multiPointers: Record<'left' | 'right', MultiPointer>;
|
|
48
|
+
/**
|
|
49
|
+
* Single global gaze pointer — gaze has no handedness, so it sits beside
|
|
50
|
+
* {@link XRInputManager.multiPointers} rather than inside them.
|
|
51
|
+
*
|
|
52
|
+
* Constructed unconditionally so systems (`GrabSystem`, `GazeSystem`) can
|
|
53
|
+
* hold a stable reference, but idle until {@link XRInputManager.gazeEnabled}
|
|
54
|
+
* is set. Nothing here costs a frame while gaze is off.
|
|
55
|
+
*/
|
|
56
|
+
readonly gazePointer: GazePointer;
|
|
57
|
+
/**
|
|
58
|
+
* Master switch for the gaze pipeline, flipped on by `GazeSystem` when the
|
|
59
|
+
* project opts into the gaze XR feature. While `false`, the gaze pose is
|
|
60
|
+
* never sampled, no cone cast runs, no pointer events are dispatched, and
|
|
61
|
+
* the pointer's reticle and ray space stay out of the rig entirely.
|
|
62
|
+
*/
|
|
63
|
+
get gazeEnabled(): boolean;
|
|
64
|
+
set gazeEnabled(enabled: boolean);
|
|
65
|
+
private gazeEnabledFlag;
|
|
66
|
+
/**
|
|
67
|
+
* Gaze-eligible Object3D roots, republished by the host every frame before
|
|
68
|
+
* {@link XRInputManager.update}. Gaze deliberately uses an explicit
|
|
69
|
+
* candidate list rather than raycasting the scene: the cone cast is
|
|
70
|
+
* O(candidates), and gaze should only consider objects that opted in.
|
|
71
|
+
*/
|
|
72
|
+
gazeCandidates: ReadonlyArray<Object3D>;
|
|
73
|
+
private readonly gazeInput;
|
|
47
74
|
readonly gamepads: Record<"left" | "right", StatefulGamepad | undefined>;
|
|
48
75
|
readonly visualAdapters: {
|
|
49
76
|
controller: {
|
|
@@ -63,10 +90,18 @@ export declare class XRInputManager {
|
|
|
63
90
|
private hadSession;
|
|
64
91
|
private readonly touchSurfaceVisualOffsets;
|
|
65
92
|
private processedInputSourceKeys;
|
|
93
|
+
private selectEventSession;
|
|
94
|
+
private readonly handSelectEvents;
|
|
95
|
+
private readonly handSelectFrameState;
|
|
96
|
+
private readonly gazeHandSelectionArmed;
|
|
97
|
+
private readonly pointerDisableWarnings;
|
|
98
|
+
private readonly selectStartHandler;
|
|
99
|
+
private readonly selectEndHandler;
|
|
66
100
|
constructor(options: XRInputOptions);
|
|
67
101
|
update(xrManager: WebXRManager, delta: number, time: number): void;
|
|
68
102
|
private onSessionEnded;
|
|
69
103
|
private disablePointers;
|
|
104
|
+
private warnPointerDisableFailure;
|
|
70
105
|
isPrimary(deviceType: 'controller' | 'hand', handedness: 'left' | 'right'): boolean;
|
|
71
106
|
/**
|
|
72
107
|
* Get the primary input source for a given handedness.
|
|
@@ -74,6 +109,18 @@ export declare class XRInputManager {
|
|
|
74
109
|
*/
|
|
75
110
|
getPrimaryInputSource(handedness: 'left' | 'right'): XRInputSource | undefined;
|
|
76
111
|
private resetActiveInputSources;
|
|
112
|
+
private syncSelectEventSession;
|
|
113
|
+
private updateHandSelectEvent;
|
|
114
|
+
private resetHandSelectEvents;
|
|
115
|
+
private resetHandSelectFrameState;
|
|
116
|
+
private resetGazeHandSelectionArming;
|
|
117
|
+
/**
|
|
118
|
+
* Snapshot each hand's selection once per render frame. Native hand sources
|
|
119
|
+
* expose WebXR select events but no Gamepad, and both the hand pointer and
|
|
120
|
+
* gaze pointer must observe the same edge without consuming it twice.
|
|
121
|
+
*/
|
|
122
|
+
private updateHandSelectFrameState;
|
|
123
|
+
private readHandSelectState;
|
|
77
124
|
/**
|
|
78
125
|
* Updates the active input sources from the XR session.
|
|
79
126
|
*
|
|
@@ -95,5 +142,14 @@ export declare class XRInputManager {
|
|
|
95
142
|
private assignInputSource;
|
|
96
143
|
private updateControllersAndHands;
|
|
97
144
|
private updatePointers;
|
|
145
|
+
/**
|
|
146
|
+
* Drive the global gaze pointer from this frame's candidates and pinch state.
|
|
147
|
+
*
|
|
148
|
+
* Either hand's pinch can commit a gaze selection, so both are sampled and
|
|
149
|
+
* the pointer applies its own hand mutual-exclusion. Direct touch/grab state
|
|
150
|
+
* feeds the pointer's suppression rule; it's read after
|
|
151
|
+
* {@link XRInputManager.updatePointers} so it reflects this frame, not last.
|
|
152
|
+
*/
|
|
153
|
+
private updateGazePointer;
|
|
98
154
|
}
|
|
99
155
|
//# sourceMappingURL=xr-input-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xr-input-manager.d.ts","sourceRoot":"","sources":["../src/xr-input-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAU,MAAM,sBAAsB,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"xr-input-manager.d.ts","sourceRoot":"","sources":["../src/xr-input-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAU,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAEL,QAAQ,EACR,iBAAiB,EACjB,KAAK,EAEL,YAAY,EACb,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,WAAW,EAAoB,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAG9E,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAqBpC,oBAAY,iBAAiB;IAC3B,UAAU,eAAe;IACzB,IAAI,SAAS;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,e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,CAAC,yBAAyB;IASjC,OAAO,CAAC,4BAA4B;IAKpC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAUlC,OAAO,CAAC,mBAAmB;IAsC3B;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,yBAAyB;IA2FjC,OAAO,CAAC,cAAc;IA0CtB;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;CA8B1B"}
|
package/dist/xr-input-manager.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Vector3 } from 'three';
|
|
|
3
3
|
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
4
4
|
import { loadInputProfile } from './gamepad/input-profiles.js';
|
|
5
5
|
import { StatefulGamepad } from './gamepad/stateful-gamepad.js';
|
|
6
|
+
import { GazePointer } from './pointer/gaze-pointer.js';
|
|
6
7
|
import { MultiPointer } from './pointer/multi-pointer.js';
|
|
7
8
|
import { XROrigin } from './rig/xr-origin.js';
|
|
8
9
|
import { XRControllerVisualAdapter } from './visual/adapter/controller-visual-adapter.js';
|
|
@@ -16,6 +17,7 @@ import { AnimatedHand } from './visual/impl/animated-hand.js';
|
|
|
16
17
|
* This source code is licensed under the MIT license found in the
|
|
17
18
|
* LICENSE file in the root directory of this source tree.
|
|
18
19
|
*/
|
|
20
|
+
const MAX_HAND_SELECT_TRANSITIONS = 4;
|
|
19
21
|
var XRInputDeviceType;
|
|
20
22
|
(function (XRInputDeviceType) {
|
|
21
23
|
XRInputDeviceType["Controller"] = "controller";
|
|
@@ -28,7 +30,43 @@ const DefaultXRAssetLoader = {
|
|
|
28
30
|
},
|
|
29
31
|
};
|
|
30
32
|
class XRInputManager {
|
|
33
|
+
/**
|
|
34
|
+
* Master switch for the gaze pipeline, flipped on by `GazeSystem` when the
|
|
35
|
+
* project opts into the gaze XR feature. While `false`, the gaze pose is
|
|
36
|
+
* never sampled, no cone cast runs, no pointer events are dispatched, and
|
|
37
|
+
* the pointer's reticle and ray space stay out of the rig entirely.
|
|
38
|
+
*/
|
|
39
|
+
get gazeEnabled() {
|
|
40
|
+
return this.gazeEnabledFlag;
|
|
41
|
+
}
|
|
42
|
+
set gazeEnabled(enabled) {
|
|
43
|
+
if (enabled === this.gazeEnabledFlag) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
this.gazeEnabledFlag = enabled;
|
|
47
|
+
this.resetGazeHandSelectionArming();
|
|
48
|
+
if (!enabled) {
|
|
49
|
+
this.gazePointer.reset();
|
|
50
|
+
this.xrOrigin.clearGaze();
|
|
51
|
+
}
|
|
52
|
+
this.gazePointer.setAttached(enabled);
|
|
53
|
+
}
|
|
31
54
|
constructor(options) {
|
|
55
|
+
this.gazeEnabledFlag = false;
|
|
56
|
+
/**
|
|
57
|
+
* Gaze-eligible Object3D roots, republished by the host every frame before
|
|
58
|
+
* {@link XRInputManager.update}. Gaze deliberately uses an explicit
|
|
59
|
+
* candidate list rather than raycasting the scene: the cone cast is
|
|
60
|
+
* O(candidates), and gaze should only consider objects that opted in.
|
|
61
|
+
*/
|
|
62
|
+
this.gazeCandidates = [];
|
|
63
|
+
this.gazeInput = {
|
|
64
|
+
candidates: [],
|
|
65
|
+
pinchStart: { left: false, right: false },
|
|
66
|
+
pinchEnd: { left: false, right: false },
|
|
67
|
+
pinchActive: { left: false, right: false },
|
|
68
|
+
directPointerActive: { left: false, right: false },
|
|
69
|
+
};
|
|
32
70
|
this.gamepads = {
|
|
33
71
|
left: undefined,
|
|
34
72
|
right: undefined,
|
|
@@ -47,6 +85,35 @@ class XRInputManager {
|
|
|
47
85
|
right: new Vector3(),
|
|
48
86
|
};
|
|
49
87
|
this.processedInputSourceKeys = new Set();
|
|
88
|
+
this.handSelectEvents = {
|
|
89
|
+
left: {
|
|
90
|
+
inputSource: undefined,
|
|
91
|
+
actualActive: false,
|
|
92
|
+
reportedActive: false,
|
|
93
|
+
transitions: [],
|
|
94
|
+
},
|
|
95
|
+
right: {
|
|
96
|
+
inputSource: undefined,
|
|
97
|
+
actualActive: false,
|
|
98
|
+
reportedActive: false,
|
|
99
|
+
transitions: [],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
this.handSelectFrameState = {
|
|
103
|
+
left: { start: false, end: false, active: false },
|
|
104
|
+
right: { start: false, end: false, active: false },
|
|
105
|
+
};
|
|
106
|
+
this.gazeHandSelectionArmed = {
|
|
107
|
+
left: false,
|
|
108
|
+
right: false,
|
|
109
|
+
};
|
|
110
|
+
this.pointerDisableWarnings = new Set();
|
|
111
|
+
this.selectStartHandler = (event) => {
|
|
112
|
+
this.updateHandSelectEvent(event, true);
|
|
113
|
+
};
|
|
114
|
+
this.selectEndHandler = (event) => {
|
|
115
|
+
this.updateHandSelectEvent(event, false);
|
|
116
|
+
};
|
|
50
117
|
const { scene, camera, assetLoader } = options;
|
|
51
118
|
this.xrOrigin = new XROrigin();
|
|
52
119
|
this.scene = scene; // used implicitly by MultiPointer via constructor
|
|
@@ -70,10 +137,12 @@ class XRInputManager {
|
|
|
70
137
|
left: new MultiPointer('left', this.scene, camera, this.xrOrigin),
|
|
71
138
|
right: new MultiPointer('right', this.scene, camera, this.xrOrigin),
|
|
72
139
|
};
|
|
140
|
+
this.gazePointer = new GazePointer(this.xrOrigin, this.scene, camera);
|
|
73
141
|
}
|
|
74
142
|
update(xrManager, delta, time) {
|
|
75
143
|
const session = xrManager.getSession();
|
|
76
144
|
if (!session) {
|
|
145
|
+
this.syncSelectEventSession(undefined);
|
|
77
146
|
if (this.hadSession) {
|
|
78
147
|
this.onSessionEnded();
|
|
79
148
|
}
|
|
@@ -84,6 +153,7 @@ class XRInputManager {
|
|
|
84
153
|
return;
|
|
85
154
|
}
|
|
86
155
|
this.hadSession = true;
|
|
156
|
+
this.syncSelectEventSession(session);
|
|
87
157
|
const refSpace = xrManager.getReferenceSpace();
|
|
88
158
|
const frame = xrManager.getFrame();
|
|
89
159
|
if (!refSpace || !frame) {
|
|
@@ -96,11 +166,25 @@ class XRInputManager {
|
|
|
96
166
|
this.updateActiveInputSources(session);
|
|
97
167
|
// Update controllers and hands (poses + visuals + gamepads)
|
|
98
168
|
this.updateControllersAndHands(frame, refSpace, delta);
|
|
169
|
+
this.updateHandSelectFrameState();
|
|
99
170
|
// Update head tracking
|
|
100
171
|
this.xrOrigin.updateHead(frame, refSpace);
|
|
172
|
+
// Probe the real gaze target ray while frame/refSpace are in hand, and
|
|
173
|
+
// before the matrix flush below, so eyeSpace's world matrix is current by
|
|
174
|
+
// the time the pointer reads it.
|
|
175
|
+
if (this.gazeEnabled) {
|
|
176
|
+
this.gazePointer.sampleGazePose(time, {
|
|
177
|
+
frame,
|
|
178
|
+
referenceSpace: refSpace,
|
|
179
|
+
session,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
101
182
|
// Force matrix update for xrOrigin, and then update pointers
|
|
102
183
|
this.xrOrigin.updateMatrixWorld(true);
|
|
103
184
|
this.updatePointers(delta, time);
|
|
185
|
+
// Gaze runs after the hand pointers so it can read their active state for
|
|
186
|
+
// suppression — direct manipulation always wins over gaze.
|
|
187
|
+
this.updateGazePointer(delta, time);
|
|
104
188
|
}
|
|
105
189
|
onSessionEnded() {
|
|
106
190
|
// Clear active sources and visuals
|
|
@@ -118,15 +202,48 @@ class XRInputManager {
|
|
|
118
202
|
});
|
|
119
203
|
this.visualAdapters.left.value = undefined;
|
|
120
204
|
this.visualAdapters.right.value = undefined;
|
|
205
|
+
// Gaze has no per-frame source outside a session; drop it back to 'none'
|
|
206
|
+
// so consumers don't read a stale tracked origin.
|
|
207
|
+
this.xrOrigin.clearGaze();
|
|
208
|
+
// Full reset (not just disable) so the next session re-runs the gaze
|
|
209
|
+
// diagnostics from scratch instead of reporting the previous one's verdict.
|
|
210
|
+
this.gazePointer.reset();
|
|
121
211
|
// Hide pointer visuals and disable combined pointers
|
|
122
212
|
this.disablePointers();
|
|
123
213
|
}
|
|
124
214
|
disablePointers(time = 0) {
|
|
215
|
+
this.resetHandSelectEvents();
|
|
216
|
+
this.resetHandSelectFrameState();
|
|
217
|
+
this.resetGazeHandSelectionArming();
|
|
218
|
+
for (const handedness of ['left', 'right']) {
|
|
219
|
+
try {
|
|
220
|
+
this.multiPointers[handedness].update(false, 0, time);
|
|
221
|
+
this.pointerDisableWarnings.delete(handedness);
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
this.warnPointerDisableFailure(handedness, error);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
125
227
|
try {
|
|
126
|
-
this.
|
|
127
|
-
|
|
228
|
+
this.gazeInput.candidates = [];
|
|
229
|
+
for (const handedness of ['left', 'right']) {
|
|
230
|
+
this.gazeInput.pinchStart[handedness] = false;
|
|
231
|
+
this.gazeInput.pinchEnd[handedness] = false;
|
|
232
|
+
this.gazeInput.pinchActive[handedness] = false;
|
|
233
|
+
this.gazeInput.directPointerActive[handedness] = false;
|
|
234
|
+
}
|
|
235
|
+
this.gazePointer.update(false, 0, time, this.gazeInput);
|
|
236
|
+
this.pointerDisableWarnings.delete('gaze');
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
this.warnPointerDisableFailure('gaze', error);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
warnPointerDisableFailure(pointer, error) {
|
|
243
|
+
if (!this.pointerDisableWarnings.has(pointer)) {
|
|
244
|
+
this.pointerDisableWarnings.add(pointer);
|
|
245
|
+
console.warn(`[IWSDK] Failed to disable ${pointer} pointer:`, error);
|
|
128
246
|
}
|
|
129
|
-
catch (_a) { }
|
|
130
247
|
}
|
|
131
248
|
isPrimary(deviceType, handedness) {
|
|
132
249
|
var _a;
|
|
@@ -147,6 +264,119 @@ class XRInputManager {
|
|
|
147
264
|
this.primaryInputSources.left = undefined;
|
|
148
265
|
this.primaryInputSources.right = undefined;
|
|
149
266
|
}
|
|
267
|
+
syncSelectEventSession(session) {
|
|
268
|
+
if (this.selectEventSession === session) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (this.selectEventSession) {
|
|
272
|
+
this.selectEventSession.removeEventListener('selectstart', this.selectStartHandler);
|
|
273
|
+
this.selectEventSession.removeEventListener('selectend', this.selectEndHandler);
|
|
274
|
+
}
|
|
275
|
+
this.resetHandSelectEvents();
|
|
276
|
+
this.resetHandSelectFrameState();
|
|
277
|
+
this.resetGazeHandSelectionArming();
|
|
278
|
+
this.selectEventSession = session;
|
|
279
|
+
if (session) {
|
|
280
|
+
session.addEventListener('selectstart', this.selectStartHandler);
|
|
281
|
+
session.addEventListener('selectend', this.selectEndHandler);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
updateHandSelectEvent(event, active) {
|
|
285
|
+
const inputSource = event.inputSource;
|
|
286
|
+
const handedness = inputSource.handedness;
|
|
287
|
+
if (!inputSource.hand ||
|
|
288
|
+
(handedness !== 'left' && handedness !== 'right')) {
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const state = this.handSelectEvents[handedness];
|
|
292
|
+
if (state.inputSource !== inputSource) {
|
|
293
|
+
state.inputSource = inputSource;
|
|
294
|
+
state.actualActive = false;
|
|
295
|
+
state.reportedActive = false;
|
|
296
|
+
state.transitions.length = 0;
|
|
297
|
+
}
|
|
298
|
+
if (state.actualActive === active) {
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
state.actualActive = active;
|
|
302
|
+
// Keep the newest complete gesture cycles if a suspended renderer lets
|
|
303
|
+
// events outrun frames. Removing two alternating edges preserves both the
|
|
304
|
+
// current reported state and the final physical state.
|
|
305
|
+
if (state.transitions.length >= MAX_HAND_SELECT_TRANSITIONS) {
|
|
306
|
+
state.transitions.splice(0, 2);
|
|
307
|
+
}
|
|
308
|
+
state.transitions.push(active ? 'start' : 'end');
|
|
309
|
+
}
|
|
310
|
+
resetHandSelectEvents(handedness) {
|
|
311
|
+
const hands = handedness ? [handedness] : ['left', 'right'];
|
|
312
|
+
for (const hand of hands) {
|
|
313
|
+
const state = this.handSelectEvents[hand];
|
|
314
|
+
state.inputSource = undefined;
|
|
315
|
+
state.actualActive = false;
|
|
316
|
+
state.reportedActive = false;
|
|
317
|
+
state.transitions.length = 0;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
resetHandSelectFrameState() {
|
|
321
|
+
for (const handedness of ['left', 'right']) {
|
|
322
|
+
const state = this.handSelectFrameState[handedness];
|
|
323
|
+
state.start = false;
|
|
324
|
+
state.end = false;
|
|
325
|
+
state.active = false;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
resetGazeHandSelectionArming() {
|
|
329
|
+
this.gazeHandSelectionArmed.left = false;
|
|
330
|
+
this.gazeHandSelectionArmed.right = false;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Snapshot each hand's selection once per render frame. Native hand sources
|
|
334
|
+
* expose WebXR select events but no Gamepad, and both the hand pointer and
|
|
335
|
+
* gaze pointer must observe the same edge without consuming it twice.
|
|
336
|
+
*/
|
|
337
|
+
updateHandSelectFrameState() {
|
|
338
|
+
for (const handedness of ['left', 'right']) {
|
|
339
|
+
const next = this.readHandSelectState(handedness);
|
|
340
|
+
const state = this.handSelectFrameState[handedness];
|
|
341
|
+
state.start = next.start;
|
|
342
|
+
state.end = next.end;
|
|
343
|
+
state.active = next.active;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
readHandSelectState(handedness) {
|
|
347
|
+
const gamepad = this.gamepads[handedness];
|
|
348
|
+
if (gamepad) {
|
|
349
|
+
this.resetHandSelectEvents(handedness);
|
|
350
|
+
return {
|
|
351
|
+
start: gamepad.getSelectStart(),
|
|
352
|
+
end: gamepad.getSelectEnd(),
|
|
353
|
+
active: gamepad.getSelecting(),
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
const inputSource = this.primaryInputSources[handedness];
|
|
357
|
+
const state = this.handSelectEvents[handedness];
|
|
358
|
+
const matches = Boolean((inputSource === null || inputSource === void 0 ? void 0 : inputSource.hand) && state.inputSource === inputSource);
|
|
359
|
+
if (!matches) {
|
|
360
|
+
this.resetHandSelectEvents(handedness);
|
|
361
|
+
return { start: false, end: false, active: false };
|
|
362
|
+
}
|
|
363
|
+
// Deliver at most one edge per render frame. A short native pinch can
|
|
364
|
+
// produce selectstart and selectend between two app frames; preserving
|
|
365
|
+
// their order guarantees a down frame followed by an up/click frame.
|
|
366
|
+
const transition = state.transitions.shift();
|
|
367
|
+
if (transition === 'start') {
|
|
368
|
+
state.reportedActive = true;
|
|
369
|
+
}
|
|
370
|
+
else if (transition === 'end') {
|
|
371
|
+
state.reportedActive = false;
|
|
372
|
+
}
|
|
373
|
+
const result = {
|
|
374
|
+
start: transition === 'start',
|
|
375
|
+
end: transition === 'end',
|
|
376
|
+
active: state.reportedActive,
|
|
377
|
+
};
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
150
380
|
/**
|
|
151
381
|
* Updates the active input sources from the XR session.
|
|
152
382
|
*
|
|
@@ -273,21 +503,21 @@ class XRInputManager {
|
|
|
273
503
|
});
|
|
274
504
|
}
|
|
275
505
|
updatePointers(delta, time) {
|
|
506
|
+
// Gaze and hand/controller rays are alternative far-targeting modes in
|
|
507
|
+
// ISDK. Once gaze mode has acquired a valid source, disable far rays rather than
|
|
508
|
+
// letting their incidental hits compete with gaze. An invalid frame clears
|
|
509
|
+
// gaze hover but does not flash the ray mode; near touch/grab stays enabled.
|
|
510
|
+
const suppressFarRay = this.gazeEnabled && this.gazePointer.ownsFarTargeting(time);
|
|
276
511
|
['left', 'right'].forEach((handedness) => {
|
|
277
|
-
var _a, _b;
|
|
278
512
|
const inputSource = this.primaryInputSources[handedness];
|
|
279
|
-
const hasGamepad = !!(inputSource && inputSource.gamepad);
|
|
280
|
-
const connected = !!(inputSource &&
|
|
281
|
-
hasGamepad &&
|
|
282
|
-
this.gamepads[handedness]);
|
|
283
|
-
const selectStart = connected
|
|
284
|
-
? !!((_a = this.gamepads[handedness]) === null || _a === void 0 ? void 0 : _a.getSelectStart())
|
|
285
|
-
: false;
|
|
286
|
-
const selectEnd = connected
|
|
287
|
-
? !!((_b = this.gamepads[handedness]) === null || _b === void 0 ? void 0 : _b.getSelectEnd())
|
|
288
|
-
: false;
|
|
289
|
-
// First: move all registered pointers (ray + grab) via the combined pointer
|
|
290
513
|
const gp = this.gamepads[handedness];
|
|
514
|
+
// WebXR Hand Input requires hand sources to expose no Gamepad. Their
|
|
515
|
+
// select edges come from the session-level event snapshot above.
|
|
516
|
+
const connected = !!(inputSource && (gp || inputSource.hand));
|
|
517
|
+
const select = this.handSelectFrameState[handedness];
|
|
518
|
+
const selectStart = connected ? select.start : false;
|
|
519
|
+
const selectEnd = connected ? select.end : false;
|
|
520
|
+
// First: move all registered pointers (ray + grab) via the combined pointer
|
|
291
521
|
const squeezeStart = connected
|
|
292
522
|
? !!(gp === null || gp === void 0 ? void 0 : gp.getButtonDown('xr-standard-squeeze'))
|
|
293
523
|
: false;
|
|
@@ -299,6 +529,7 @@ class XRInputManager {
|
|
|
299
529
|
selectEnd,
|
|
300
530
|
squeezeStart,
|
|
301
531
|
squeezeEnd,
|
|
532
|
+
suppressRay: suppressFarRay,
|
|
302
533
|
});
|
|
303
534
|
const touchSurfaceVisualOffset = this.multiPointers[handedness].getTouchSurfaceVisualOffset(this.touchSurfaceVisualOffsets[handedness]);
|
|
304
535
|
const handAdapter = this.visualAdapters.hand[handedness];
|
|
@@ -307,6 +538,45 @@ class XRInputManager {
|
|
|
307
538
|
}
|
|
308
539
|
});
|
|
309
540
|
}
|
|
541
|
+
/**
|
|
542
|
+
* Drive the global gaze pointer from this frame's candidates and pinch state.
|
|
543
|
+
*
|
|
544
|
+
* Either hand's pinch can commit a gaze selection, so both are sampled and
|
|
545
|
+
* the pointer applies its own hand mutual-exclusion. Direct touch/grab state
|
|
546
|
+
* feeds the pointer's suppression rule; it's read after
|
|
547
|
+
* {@link XRInputManager.updatePointers} so it reflects this frame, not last.
|
|
548
|
+
*/
|
|
549
|
+
updateGazePointer(delta, time) {
|
|
550
|
+
if (!this.gazeEnabled) {
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
const input = this.gazeInput;
|
|
554
|
+
input.candidates = this.gazeCandidates;
|
|
555
|
+
['left', 'right'].forEach((handedness) => {
|
|
556
|
+
const select = this.handSelectFrameState[handedness];
|
|
557
|
+
if (!this.gazeHandSelectionArmed[handedness]) {
|
|
558
|
+
// Enabling gaze while a pinch is held or queued must not turn input
|
|
559
|
+
// that occurred while gaze was off into a synthetic gaze click. Arm
|
|
560
|
+
// only after the event bridge reaches a fully released baseline.
|
|
561
|
+
const events = this.handSelectEvents[handedness];
|
|
562
|
+
if (!select.active && events.transitions.length === 0) {
|
|
563
|
+
this.gazeHandSelectionArmed[handedness] = true;
|
|
564
|
+
}
|
|
565
|
+
input.pinchStart[handedness] = false;
|
|
566
|
+
input.pinchEnd[handedness] = false;
|
|
567
|
+
input.pinchActive[handedness] = false;
|
|
568
|
+
}
|
|
569
|
+
else {
|
|
570
|
+
input.pinchStart[handedness] = select.start;
|
|
571
|
+
input.pinchEnd[handedness] = select.end;
|
|
572
|
+
input.pinchActive[handedness] = select.active;
|
|
573
|
+
}
|
|
574
|
+
const activeKind = this.multiPointers[handedness].getActiveKind();
|
|
575
|
+
input.directPointerActive[handedness] =
|
|
576
|
+
activeKind === 'touch' || activeKind === 'grab';
|
|
577
|
+
});
|
|
578
|
+
this.gazePointer.update(this.gazePointer.canTarget(), delta, time, input);
|
|
579
|
+
}
|
|
310
580
|
}
|
|
311
581
|
function updatePose(frame, xrSpace, refSpace, group) {
|
|
312
582
|
const xrPose = frame.getPose(xrSpace, refSpace);
|