@iwsdk/xr-input 1.1.0-rc.1 → 1.1.0
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/pointer/gaze-conecaster.d.ts.map +1 -1
- package/dist/pointer/gaze-conecaster.js +7 -1
- package/dist/pointer/gaze-conecaster.js.map +1 -1
- package/dist/pointer/gaze-pointer.d.ts.map +1 -1
- package/dist/pointer/gaze-pointer.js +19 -1
- package/dist/pointer/gaze-pointer.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/visual/impl/animated-controller-hand.js +3 -2
- package/dist/visual/impl/animated-controller-hand.js.map +1 -1
- package/dist/visual/impl/animated-controller.d.ts.map +1 -1
- package/dist/visual/impl/animated-controller.js +10 -3
- package/dist/visual/impl/animated-controller.js.map +1 -1
- package/dist/xr-input-manager.d.ts +20 -0
- package/dist/xr-input-manager.d.ts.map +1 -1
- package/dist/xr-input-manager.js +54 -6
- package/dist/xr-input-manager.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaze-conecaster.d.ts","sourceRoot":"","sources":["../../src/pointer/gaze-conecaster.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,oBAAoB,EACpB,qBAAqB,EACrB,OAAO,EACR,MAAM,8BAA8B,CAAC;AAGtC;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;AAQ9D;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAMjC,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,kCAAkC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gEAAgE;IAChE,QAA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9E,OAAO,CAAC,kBAAkB;IA0C1B,OAAO,CAAC,iBAAiB;IAwBzB,OAAO,CAAC,cAAc;IAOtB,qCAAqC;IACrC,cAAc,IAAI,OAAO,GAAG,IAAI;CAGjC"}
|
|
@@ -263,6 +263,12 @@ class GazeConecaster {
|
|
|
263
263
|
* fallback) in the same traversal.
|
|
264
264
|
*/
|
|
265
265
|
expandSafely(obj, worldBox, localBox) {
|
|
266
|
+
var _a;
|
|
267
|
+
// IWSDK runtime-only meshes (ContactShadow and ShadowCatcher planes) take
|
|
268
|
+
// no pointer hits, so they must not widen the candidate either.
|
|
269
|
+
if (((_a = obj.userData) === null || _a === void 0 ? void 0 : _a.iwsdkRuntimeOnly) === true) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
266
272
|
const candidate = obj;
|
|
267
273
|
const geometry = candidate.geometry;
|
|
268
274
|
if (geometry) {
|
|
@@ -284,7 +290,7 @@ class GazeConecaster {
|
|
|
284
290
|
}
|
|
285
291
|
}
|
|
286
292
|
}
|
|
287
|
-
catch (
|
|
293
|
+
catch (_b) {
|
|
288
294
|
// ignore: degenerate geometry shouldn't disqualify the candidate
|
|
289
295
|
}
|
|
290
296
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaze-conecaster.js","sources":["../../src/pointer/gaze-conecaster.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\nimport { Box3, Matrix4, Object3D, Sphere, Vector3 } from 'three';\nimport type {\n GazeCandidateContext,\n GazeCandidateProvider,\n GazeHit,\n} from './gaze-candidate-provider.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\n/**\n * Comparator over two `GazeHit` candidates. Return < 0 if `a` wins, > 0 if `b`\n * wins, 0 for unchanged. The conecaster keeps the running best by comparing\n * each new candidate against the current winner.\n */\nexport type GazeComparer = (a: GazeHit, b: GazeHit) => number;\n\nconst ANGLE_EPSILON = 0.5 * (Math.PI / 180); // 0.5°\n// Rays aimed at an exact triangle/quad edge are numerically ambiguous. Move a\n// cone-assisted aim point a visually negligible distance inside the OBB before\n// falling back to its center, so boundary jitter cannot make the reticle jump.\nconst OBB_EDGE_INSET_FRACTION = 1e-3;\n\n/**\n * Default comparer: closer-by-angle wins, then closer-by-distance.\n */\nexport const defaultGazeComparer: GazeComparer = (a, b) => {\n const dAngle = a.angularDistance - b.angularDistance;\n if (Math.abs(dAngle) > ANGLE_EPSILON) {\n return dAngle;\n }\n return a.intersection.distance - b.intersection.distance;\n};\n\nexport interface GazeConecasterOptions {\n /** Cone half-angle in radians. */\n coneAngle?: number;\n /** Cone length in meters. */\n coneLength?: number;\n /** Dwell-consensus window in seconds. */\n dwellWindowSeconds?: number;\n /** Custom comparer; defaults to {@link defaultGazeComparer}. */\n comparer?: GazeComparer;\n}\n\ninterface DwellSample {\n object: Object3D | null;\n time: number;\n dt: number;\n}\n\n/**\n * Default candidate provider: cone-membership filter + pointer-compatible\n * surface resolution + time-weighted dwell consensus.\n *\n * @remarks\n * - **Membership**: a coarse sphere distance reject prunes far candidates,\n * then a precise OBB closest-point test admits the candidate iff the angle\n * from the gaze direction to the closest point on its oriented bounding\n * box (its local AABB transformed by `matrixWorld`) is within `coneAngle`.\n * This avoids the bounding-sphere overestimation that would let large flat\n * panels register hover from far past their visible silhouette.\n * - **Geometry**: survivors are resolved by the callback supplied in\n * {@link GazeCandidateContext}, so the exact same pointer-event eligibility\n * and ordering rules are used for acquisition and dispatch.\n * - **Comparer**: per-frame best is chosen by `comparer` (default angle ->\n * distance).\n * - **Dwell**: per-frame winners are appended to a ring buffer; samples older\n * than `dwellWindowSeconds` are dropped; the object with the largest\n * cumulative dt inside the window wins.\n *\n * @category Pointer\n */\nexport class GazeConecaster implements GazeCandidateProvider {\n public coneAngle: number;\n public coneLength: number;\n public dwellWindowSeconds: number;\n public comparer: GazeComparer;\n\n private readonly sphere = new Sphere();\n private readonly box = new Box3();\n private readonly localBox = new Box3();\n private readonly invWorld = new Matrix4();\n private readonly tmpMat = new Matrix4();\n private readonly tmpBox = new Box3();\n private readonly toCandidate = new Vector3();\n private readonly sphereCenter = new Vector3();\n private readonly localOrigin = new Vector3();\n private readonly localDirection = new Vector3();\n private readonly localBoxClosest = new Vector3();\n private readonly localRayClosest = new Vector3();\n private readonly worldBoxClosest = new Vector3();\n private readonly worldBoxCenter = new Vector3();\n private readonly localBoxCenter = new Vector3();\n private pointBoundsFallback = false;\n\n /** Ring of dwell samples (reused). */\n private readonly dwellRing: DwellSample[] = [];\n private dwellHead = 0;\n private dwellSize = 0;\n private readonly dwellCapacity: number;\n\n /** Last reported dwell winner for the public `getDwellWinner()`. */\n private currentDwellWinner: GazeHit | null = null;\n\n constructor(opts: GazeConecasterOptions = {}) {\n this.coneAngle = opts.coneAngle ?? 5 * (Math.PI / 180);\n this.coneLength = opts.coneLength ?? 30;\n this.dwellWindowSeconds = opts.dwellWindowSeconds ?? 0.15;\n this.comparer = opts.comparer ?? defaultGazeComparer;\n\n // Preallocate ring capacity for ~120 Hz over ~1 second of dwell history.\n // Window-based pruning keeps the *used* size small; this is just an upper\n // bound to avoid reallocation.\n this.dwellCapacity = 256;\n for (let i = 0; i < this.dwellCapacity; i++) {\n this.dwellRing.push({\n object: null,\n time: 0,\n dt: 0,\n });\n }\n }\n\n update(time: number, dt: number, ctx: GazeCandidateContext): GazeHit | null {\n const frameBest = this.findFrameBest(ctx);\n if (frameBest) {\n this.recordDwell(frameBest.object, time, dt);\n }\n this.pruneDwell(time);\n this.currentDwellWinner = this.resolveDwellWinner(ctx);\n return this.currentDwellWinner;\n }\n\n reset(): void {\n for (let i = 0; i < this.dwellSize; i++) {\n this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);\n }\n this.dwellHead = 0;\n this.dwellSize = 0;\n this.currentDwellWinner = null;\n }\n\n /** Internal: scan all candidates and return the best in-cone hit, or null. */\n private findFrameBest(ctx: GazeCandidateContext): GazeHit | null {\n const { origin, direction, candidates } = ctx;\n const cosCone = Math.cos(this.coneAngle);\n let bestHit: GazeHit | null = null;\n\n for (let i = 0; i < candidates.length; i++) {\n const obj = candidates[i];\n if (!obj || !isObjectTreeVisible(obj)) {\n continue;\n }\n\n this.computeBounds(obj);\n if (this.sphere.radius < 0) {\n continue;\n }\n\n // Coarse distance reject (sphere radius is the only cheap upper bound).\n this.sphereCenter.copy(this.sphere.center);\n this.toCandidate.copy(this.sphereCenter).sub(origin);\n const distToCenter = this.toCandidate.length();\n if (distToCenter <= 1e-6) {\n continue;\n }\n if (distToCenter - this.sphere.radius > this.coneLength) {\n continue;\n }\n\n // Precise cone-membership test against the candidate's OBB instead of\n // its enclosing sphere. A 0.5 m UIKit panel has a sphere radius of\n // ~0.35 m and so would qualify ~16° off-axis even at arm's length —\n // the panel ended up \"dominating\" gaze from far past where it's\n // actually being looked at. OBB closest-point gives the true angular\n // distance from the gaze axis to the object's silhouette (~0 when the\n // ray passes through the panel area, growing with off-axis offset).\n this.closestPointOnObb(obj, origin, direction, this.worldBoxClosest);\n this.toCandidate.copy(this.worldBoxClosest).sub(origin);\n const distToObb = this.toCandidate.length();\n if (distToObb <= 1e-6) {\n // Gaze origin sits inside the OBB — treat as fully on-axis.\n this.toCandidate.copy(direction);\n } else {\n this.toCandidate.divideScalar(distToObb);\n }\n const cosObbAngle = this.toCandidate.dot(direction);\n if (cosObbAngle < cosCone) {\n continue;\n }\n const obbAngle = Math.acos(Math.max(-1, Math.min(1, cosObbAngle)));\n\n const hit = this.resolveSurface(obj, ctx, obbAngle);\n if (hit && (!bestHit || this.comparer(hit, bestHit) < 0)) {\n bestHit = hit;\n }\n }\n\n return bestHit;\n }\n\n /**\n * Resolve a real pointer-events intersection for one in-cone target. The raw\n * gaze ray wins when it already hits. Otherwise the ray bends first just\n * inside the closest point on the candidate OBB, then tries the exact point,\n * and finally its center.\n */\n private resolveSurface(\n object: Object3D,\n ctx: GazeCandidateContext,\n angularDistance: number,\n ): GazeHit | null {\n let intersection = ctx.intersectCandidate(object, ctx.direction);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance: 0 };\n }\n\n this.localBox.getCenter(this.localBoxCenter);\n this.worldBoxCenter\n .copy(this.localBoxCenter)\n .applyMatrix4(object.matrixWorld);\n\n // The closest point commonly lies exactly on a flat target's edge. A\n // triangle raycast can accept or reject that boundary across adjacent\n // floating-point poses, which previously alternated between the edge hit\n // and the center fallback. Try a sub-pixel inset first so the assisted\n // intersection remains close to the gaze while landing inside the face.\n this.toCandidate\n .copy(this.worldBoxClosest)\n .lerp(this.worldBoxCenter, OBB_EDGE_INSET_FRACTION)\n .sub(ctx.origin);\n if (this.toCandidate.lengthSq() > 1e-12) {\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance };\n }\n }\n\n this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);\n if (this.toCandidate.lengthSq() > 1e-12) {\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance };\n }\n }\n\n this.toCandidate.copy(this.worldBoxCenter).sub(ctx.origin);\n if (this.toCandidate.lengthSq() <= 1e-12) {\n return null;\n }\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n return intersection && intersection.distance <= this.coneLength\n ? { object, intersection, angularDistance }\n : null;\n }\n\n /**\n * Build both the world-space enclosing sphere (used for cone-membership)\n * and a candidate-local AABB (used by the OBB fallback) in a single subtree\n * walk. The local AABB is tighter than the world AABB for rotated objects:\n * the cone-ring + OBB fallback uses it to produce a much better silhouette\n * point than a sphere when the on-axis raycast misses.\n *\n * Results land on `this.sphere` and `this.localBox`. The local AABB is\n * meaningful in `obj`'s local frame and must be transformed by\n * `obj.matrixWorld` to land in world space.\n */\n private computeBounds(obj: Object3D): void {\n this.box.makeEmpty();\n this.localBox.makeEmpty();\n this.pointBoundsFallback = false;\n obj.updateWorldMatrix(true, true);\n const determinant = obj.matrixWorld.determinant();\n if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-12) {\n // A singular candidate transform cannot be inverted into candidate-local\n // space. Treat it as a tiny point at its world origin instead of letting\n // NaNs make cone ordering non-deterministic.\n this.invWorld.identity();\n obj.getWorldPosition(this.sphereCenter);\n if (\n !Number.isFinite(this.sphereCenter.x) ||\n !Number.isFinite(this.sphereCenter.y) ||\n !Number.isFinite(this.sphereCenter.z)\n ) {\n this.sphere.makeEmpty();\n return;\n }\n this.sphere.center.copy(this.sphereCenter);\n this.sphere.radius = 0.001;\n this.localBox.min.setScalar(-0.0005);\n this.localBox.max.setScalar(0.0005);\n this.pointBoundsFallback = true;\n return;\n }\n this.invWorld.copy(obj.matrixWorld).invert();\n this.expandSafely(obj, this.box, this.localBox);\n if (this.box.isEmpty()) {\n // Last-resort fallback: treat the candidate as a point sphere at its\n // world origin so the conecaster still considers it for hover. Mirror\n // the empty-box guard with a tiny local AABB centered on the origin.\n obj.getWorldPosition(this.sphereCenter);\n this.sphere.center.copy(this.sphereCenter);\n this.sphere.radius = 0.001;\n this.localBox.min.setScalar(-0.0005);\n this.localBox.max.setScalar(0.0005);\n return;\n }\n this.box.getBoundingSphere(this.sphere);\n }\n\n /**\n * Manual `expandByObject` that swallows per-node failures (missing\n * position attribute, null bounding box, etc.) instead of letting one bad\n * descendant abort the whole subtree. Accumulates BOTH the world-space\n * AABB (for cone-membership) and the candidate-local AABB (for the OBB\n * fallback) in the same traversal.\n */\n private expandSafely(obj: Object3D, worldBox: Box3, localBox: Box3): void {\n const candidate = obj as Object3D & {\n geometry?: {\n boundingBox: Box3 | null;\n getAttribute?: (name: string) => unknown;\n computeBoundingBox?: () => void;\n };\n };\n const geometry = candidate.geometry;\n if (geometry) {\n try {\n if (\n geometry.getAttribute &&\n geometry.getAttribute('position') !== undefined\n ) {\n if (geometry.boundingBox === null && geometry.computeBoundingBox) {\n geometry.computeBoundingBox();\n }\n if (geometry.boundingBox) {\n // World AABB: geometry-local -> world via the leaf's own matrix.\n this.tmpBox.copy(geometry.boundingBox);\n this.tmpBox.applyMatrix4(obj.matrixWorld);\n worldBox.union(this.tmpBox);\n // Candidate-local AABB: geometry-local -> world -> candidate-local.\n this.tmpMat.copy(this.invWorld).multiply(obj.matrixWorld);\n this.tmpBox.copy(geometry.boundingBox).applyMatrix4(this.tmpMat);\n localBox.union(this.tmpBox);\n }\n }\n } catch {\n // ignore: degenerate geometry shouldn't disqualify the candidate\n }\n }\n const children = obj.children;\n for (let i = 0; i < children.length; i++) {\n this.expandSafely(children[i], worldBox, localBox);\n }\n }\n\n /**\n * Closest point on the candidate's oriented bounding box (its local AABB\n * transformed by `obj.matrixWorld`) to the gaze ray, in world space.\n *\n * Works in local space to avoid building 12 oriented edges in world: bring\n * the ray into the candidate's frame, run iterative AABB-vs-line refinement\n * (a few passes is plenty — it converges quadratically), then map the point\n * back to world.\n */\n private closestPointOnObb(\n obj: Object3D,\n origin: Vector3,\n direction: Vector3,\n out: Vector3,\n ): void {\n if (this.pointBoundsFallback) {\n out.copy(this.sphere.center);\n return;\n }\n // Ray -> local space. invWorld was just refreshed in `computeBounds`.\n this.localOrigin.copy(origin).applyMatrix4(this.invWorld);\n // transformDirection normalizes and ignores translation; preserves\n // rotation. Scale baked into the world matrix is lost — that's fine for a\n // closest-point query (we re-measure in world afterwards).\n this.localDirection.copy(direction).transformDirection(this.invWorld);\n\n // Seed with the box center, projected onto the ray.\n this.localBox.getCenter(this.localBoxCenter);\n this.localBoxClosest.copy(this.localBoxCenter);\n for (let iter = 0; iter < 3; iter++) {\n // Closest point on ray to current box-point estimate (t clamped to >= 0\n // so we never march behind the gaze origin).\n const t = Math.max(\n 0,\n this.localRayClosest\n .copy(this.localBoxClosest)\n .sub(this.localOrigin)\n .dot(this.localDirection),\n );\n this.localRayClosest\n .copy(this.localDirection)\n .multiplyScalar(t)\n .add(this.localOrigin);\n // Closest point on box to that ray point.\n this.localBoxClosest\n .copy(this.localRayClosest)\n .clamp(this.localBox.min, this.localBox.max);\n }\n out.copy(this.localBoxClosest).applyMatrix4(obj.matrixWorld);\n }\n\n private recordDwell(object: Object3D, time: number, dt: number): void {\n const slot =\n this.dwellRing[(this.dwellHead + this.dwellSize) % this.dwellCapacity];\n slot.object = object;\n slot.time = time;\n slot.dt = dt;\n if (this.dwellSize < this.dwellCapacity) {\n this.dwellSize++;\n } else {\n // Ring full — advance head and overwrite the oldest slot in-place.\n this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;\n }\n }\n\n private pruneDwell(now: number): void {\n const cutoff = now - this.dwellWindowSeconds;\n while (this.dwellSize > 0) {\n const head = this.dwellRing[this.dwellHead];\n if (head.time >= cutoff) {\n break;\n }\n this.clearDwellSlot(this.dwellHead);\n this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;\n this.dwellSize--;\n }\n }\n\n private electDwellWinner(): Object3D | null {\n if (this.dwellSize === 0) {\n return null;\n }\n\n // Find max-cumulative-dt object. Ring is short (~9 at 60 Hz), so\n // O(N^2) over the window stays cheap and avoids a Map allocation.\n let bestObject: Object3D | null = null;\n let bestDt = -1;\n for (let i = 0; i < this.dwellSize; i++) {\n const idx = (this.dwellHead + i) % this.dwellCapacity;\n const sample = this.dwellRing[idx];\n const obj = sample.object;\n if (!obj) {\n continue;\n }\n\n let sumDt = 0;\n for (let j = i; j < this.dwellSize; j++) {\n const jIdx = (this.dwellHead + j) % this.dwellCapacity;\n const s = this.dwellRing[jIdx];\n if (s.object === obj) {\n sumDt += s.dt;\n }\n }\n\n if (sumDt > bestDt) {\n bestDt = sumDt;\n bestObject = obj;\n }\n }\n return bestObject;\n }\n\n /** Resolve the elected object against the current pose, never a stale hit. */\n private resolveDwellWinner(ctx: GazeCandidateContext): GazeHit | null {\n while (this.dwellSize > 0) {\n const object = this.electDwellWinner();\n if (!object) {\n return null;\n }\n if (isObjectTreeVisible(object) && ctx.candidates.includes(object)) {\n this.computeBounds(object);\n if (this.sphere.radius >= 0) {\n this.closestPointOnObb(\n object,\n ctx.origin,\n ctx.direction,\n this.worldBoxClosest,\n );\n this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);\n const distance = this.toCandidate.length();\n const angularDistance =\n distance <= 1e-6\n ? 0\n : Math.acos(\n Math.max(\n -1,\n Math.min(\n 1,\n this.toCandidate\n .divideScalar(distance)\n .dot(ctx.direction),\n ),\n ),\n );\n const hit = this.resolveSurface(object, ctx, angularDistance);\n if (hit) {\n return hit;\n }\n }\n }\n this.removeDwellObject(object);\n }\n return null;\n }\n\n private removeDwellObject(object: Object3D): void {\n const previousSize = this.dwellSize;\n let write = 0;\n for (let read = 0; read < this.dwellSize; read++) {\n const readIndex = (this.dwellHead + read) % this.dwellCapacity;\n const sample = this.dwellRing[readIndex];\n if (sample.object === object) {\n continue;\n }\n const writeIndex = (this.dwellHead + write) % this.dwellCapacity;\n if (writeIndex !== readIndex) {\n const destination = this.dwellRing[writeIndex];\n destination.object = sample.object;\n destination.time = sample.time;\n destination.dt = sample.dt;\n }\n write++;\n }\n for (let i = write; i < previousSize; i++) {\n this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);\n }\n this.dwellSize = write;\n }\n\n private clearDwellSlot(index: number): void {\n const slot = this.dwellRing[index];\n slot.object = null;\n slot.time = 0;\n slot.dt = 0;\n }\n\n /** Current dwell winner, or null. */\n getDwellWinner(): GazeHit | null {\n return this.currentDwellWinner;\n }\n}\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAiBH,MAAM,aAAa,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;AAC5C;AACA;AACA;AACA,MAAM,uBAAuB,GAAG,IAAI;AAEpC;;AAEG;MACU,mBAAmB,GAAiB,CAAC,CAAC,EAAE,CAAC,KAAI;IACxD,MAAM,MAAM,GAAG,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,eAAe;IACpD,I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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\nimport { Box3, Matrix4, Object3D, Sphere, Vector3 } from 'three';\nimport type {\n GazeCandidateContext,\n GazeCandidateProvider,\n GazeHit,\n} from './gaze-candidate-provider.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\n/**\n * Comparator over two `GazeHit` candidates. Return < 0 if `a` wins, > 0 if `b`\n * wins, 0 for unchanged. The conecaster keeps the running best by comparing\n * each new candidate against the current winner.\n */\nexport type GazeComparer = (a: GazeHit, b: GazeHit) => number;\n\nconst ANGLE_EPSILON = 0.5 * (Math.PI / 180); // 0.5°\n// Rays aimed at an exact triangle/quad edge are numerically ambiguous. Move a\n// cone-assisted aim point a visually negligible distance inside the OBB before\n// falling back to its center, so boundary jitter cannot make the reticle jump.\nconst OBB_EDGE_INSET_FRACTION = 1e-3;\n\n/**\n * Default comparer: closer-by-angle wins, then closer-by-distance.\n */\nexport const defaultGazeComparer: GazeComparer = (a, b) => {\n const dAngle = a.angularDistance - b.angularDistance;\n if (Math.abs(dAngle) > ANGLE_EPSILON) {\n return dAngle;\n }\n return a.intersection.distance - b.intersection.distance;\n};\n\nexport interface GazeConecasterOptions {\n /** Cone half-angle in radians. */\n coneAngle?: number;\n /** Cone length in meters. */\n coneLength?: number;\n /** Dwell-consensus window in seconds. */\n dwellWindowSeconds?: number;\n /** Custom comparer; defaults to {@link defaultGazeComparer}. */\n comparer?: GazeComparer;\n}\n\ninterface DwellSample {\n object: Object3D | null;\n time: number;\n dt: number;\n}\n\n/**\n * Default candidate provider: cone-membership filter + pointer-compatible\n * surface resolution + time-weighted dwell consensus.\n *\n * @remarks\n * - **Membership**: a coarse sphere distance reject prunes far candidates,\n * then a precise OBB closest-point test admits the candidate iff the angle\n * from the gaze direction to the closest point on its oriented bounding\n * box (its local AABB transformed by `matrixWorld`) is within `coneAngle`.\n * This avoids the bounding-sphere overestimation that would let large flat\n * panels register hover from far past their visible silhouette.\n * - **Geometry**: survivors are resolved by the callback supplied in\n * {@link GazeCandidateContext}, so the exact same pointer-event eligibility\n * and ordering rules are used for acquisition and dispatch.\n * - **Comparer**: per-frame best is chosen by `comparer` (default angle ->\n * distance).\n * - **Dwell**: per-frame winners are appended to a ring buffer; samples older\n * than `dwellWindowSeconds` are dropped; the object with the largest\n * cumulative dt inside the window wins.\n *\n * @category Pointer\n */\nexport class GazeConecaster implements GazeCandidateProvider {\n public coneAngle: number;\n public coneLength: number;\n public dwellWindowSeconds: number;\n public comparer: GazeComparer;\n\n private readonly sphere = new Sphere();\n private readonly box = new Box3();\n private readonly localBox = new Box3();\n private readonly invWorld = new Matrix4();\n private readonly tmpMat = new Matrix4();\n private readonly tmpBox = new Box3();\n private readonly toCandidate = new Vector3();\n private readonly sphereCenter = new Vector3();\n private readonly localOrigin = new Vector3();\n private readonly localDirection = new Vector3();\n private readonly localBoxClosest = new Vector3();\n private readonly localRayClosest = new Vector3();\n private readonly worldBoxClosest = new Vector3();\n private readonly worldBoxCenter = new Vector3();\n private readonly localBoxCenter = new Vector3();\n private pointBoundsFallback = false;\n\n /** Ring of dwell samples (reused). */\n private readonly dwellRing: DwellSample[] = [];\n private dwellHead = 0;\n private dwellSize = 0;\n private readonly dwellCapacity: number;\n\n /** Last reported dwell winner for the public `getDwellWinner()`. */\n private currentDwellWinner: GazeHit | null = null;\n\n constructor(opts: GazeConecasterOptions = {}) {\n this.coneAngle = opts.coneAngle ?? 5 * (Math.PI / 180);\n this.coneLength = opts.coneLength ?? 30;\n this.dwellWindowSeconds = opts.dwellWindowSeconds ?? 0.15;\n this.comparer = opts.comparer ?? defaultGazeComparer;\n\n // Preallocate ring capacity for ~120 Hz over ~1 second of dwell history.\n // Window-based pruning keeps the *used* size small; this is just an upper\n // bound to avoid reallocation.\n this.dwellCapacity = 256;\n for (let i = 0; i < this.dwellCapacity; i++) {\n this.dwellRing.push({\n object: null,\n time: 0,\n dt: 0,\n });\n }\n }\n\n update(time: number, dt: number, ctx: GazeCandidateContext): GazeHit | null {\n const frameBest = this.findFrameBest(ctx);\n if (frameBest) {\n this.recordDwell(frameBest.object, time, dt);\n }\n this.pruneDwell(time);\n this.currentDwellWinner = this.resolveDwellWinner(ctx);\n return this.currentDwellWinner;\n }\n\n reset(): void {\n for (let i = 0; i < this.dwellSize; i++) {\n this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);\n }\n this.dwellHead = 0;\n this.dwellSize = 0;\n this.currentDwellWinner = null;\n }\n\n /** Internal: scan all candidates and return the best in-cone hit, or null. */\n private findFrameBest(ctx: GazeCandidateContext): GazeHit | null {\n const { origin, direction, candidates } = ctx;\n const cosCone = Math.cos(this.coneAngle);\n let bestHit: GazeHit | null = null;\n\n for (let i = 0; i < candidates.length; i++) {\n const obj = candidates[i];\n if (!obj || !isObjectTreeVisible(obj)) {\n continue;\n }\n\n this.computeBounds(obj);\n if (this.sphere.radius < 0) {\n continue;\n }\n\n // Coarse distance reject (sphere radius is the only cheap upper bound).\n this.sphereCenter.copy(this.sphere.center);\n this.toCandidate.copy(this.sphereCenter).sub(origin);\n const distToCenter = this.toCandidate.length();\n if (distToCenter <= 1e-6) {\n continue;\n }\n if (distToCenter - this.sphere.radius > this.coneLength) {\n continue;\n }\n\n // Precise cone-membership test against the candidate's OBB instead of\n // its enclosing sphere. A 0.5 m UIKit panel has a sphere radius of\n // ~0.35 m and so would qualify ~16° off-axis even at arm's length —\n // the panel ended up \"dominating\" gaze from far past where it's\n // actually being looked at. OBB closest-point gives the true angular\n // distance from the gaze axis to the object's silhouette (~0 when the\n // ray passes through the panel area, growing with off-axis offset).\n this.closestPointOnObb(obj, origin, direction, this.worldBoxClosest);\n this.toCandidate.copy(this.worldBoxClosest).sub(origin);\n const distToObb = this.toCandidate.length();\n if (distToObb <= 1e-6) {\n // Gaze origin sits inside the OBB — treat as fully on-axis.\n this.toCandidate.copy(direction);\n } else {\n this.toCandidate.divideScalar(distToObb);\n }\n const cosObbAngle = this.toCandidate.dot(direction);\n if (cosObbAngle < cosCone) {\n continue;\n }\n const obbAngle = Math.acos(Math.max(-1, Math.min(1, cosObbAngle)));\n\n const hit = this.resolveSurface(obj, ctx, obbAngle);\n if (hit && (!bestHit || this.comparer(hit, bestHit) < 0)) {\n bestHit = hit;\n }\n }\n\n return bestHit;\n }\n\n /**\n * Resolve a real pointer-events intersection for one in-cone target. The raw\n * gaze ray wins when it already hits. Otherwise the ray bends first just\n * inside the closest point on the candidate OBB, then tries the exact point,\n * and finally its center.\n */\n private resolveSurface(\n object: Object3D,\n ctx: GazeCandidateContext,\n angularDistance: number,\n ): GazeHit | null {\n let intersection = ctx.intersectCandidate(object, ctx.direction);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance: 0 };\n }\n\n this.localBox.getCenter(this.localBoxCenter);\n this.worldBoxCenter\n .copy(this.localBoxCenter)\n .applyMatrix4(object.matrixWorld);\n\n // The closest point commonly lies exactly on a flat target's edge. A\n // triangle raycast can accept or reject that boundary across adjacent\n // floating-point poses, which previously alternated between the edge hit\n // and the center fallback. Try a sub-pixel inset first so the assisted\n // intersection remains close to the gaze while landing inside the face.\n this.toCandidate\n .copy(this.worldBoxClosest)\n .lerp(this.worldBoxCenter, OBB_EDGE_INSET_FRACTION)\n .sub(ctx.origin);\n if (this.toCandidate.lengthSq() > 1e-12) {\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance };\n }\n }\n\n this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);\n if (this.toCandidate.lengthSq() > 1e-12) {\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n if (intersection && intersection.distance <= this.coneLength) {\n return { object, intersection, angularDistance };\n }\n }\n\n this.toCandidate.copy(this.worldBoxCenter).sub(ctx.origin);\n if (this.toCandidate.lengthSq() <= 1e-12) {\n return null;\n }\n this.toCandidate.normalize();\n intersection = ctx.intersectCandidate(object, this.toCandidate);\n return intersection && intersection.distance <= this.coneLength\n ? { object, intersection, angularDistance }\n : null;\n }\n\n /**\n * Build both the world-space enclosing sphere (used for cone-membership)\n * and a candidate-local AABB (used by the OBB fallback) in a single subtree\n * walk. The local AABB is tighter than the world AABB for rotated objects:\n * the cone-ring + OBB fallback uses it to produce a much better silhouette\n * point than a sphere when the on-axis raycast misses.\n *\n * Results land on `this.sphere` and `this.localBox`. The local AABB is\n * meaningful in `obj`'s local frame and must be transformed by\n * `obj.matrixWorld` to land in world space.\n */\n private computeBounds(obj: Object3D): void {\n this.box.makeEmpty();\n this.localBox.makeEmpty();\n this.pointBoundsFallback = false;\n obj.updateWorldMatrix(true, true);\n const determinant = obj.matrixWorld.determinant();\n if (!Number.isFinite(determinant) || Math.abs(determinant) < 1e-12) {\n // A singular candidate transform cannot be inverted into candidate-local\n // space. Treat it as a tiny point at its world origin instead of letting\n // NaNs make cone ordering non-deterministic.\n this.invWorld.identity();\n obj.getWorldPosition(this.sphereCenter);\n if (\n !Number.isFinite(this.sphereCenter.x) ||\n !Number.isFinite(this.sphereCenter.y) ||\n !Number.isFinite(this.sphereCenter.z)\n ) {\n this.sphere.makeEmpty();\n return;\n }\n this.sphere.center.copy(this.sphereCenter);\n this.sphere.radius = 0.001;\n this.localBox.min.setScalar(-0.0005);\n this.localBox.max.setScalar(0.0005);\n this.pointBoundsFallback = true;\n return;\n }\n this.invWorld.copy(obj.matrixWorld).invert();\n this.expandSafely(obj, this.box, this.localBox);\n if (this.box.isEmpty()) {\n // Last-resort fallback: treat the candidate as a point sphere at its\n // world origin so the conecaster still considers it for hover. Mirror\n // the empty-box guard with a tiny local AABB centered on the origin.\n obj.getWorldPosition(this.sphereCenter);\n this.sphere.center.copy(this.sphereCenter);\n this.sphere.radius = 0.001;\n this.localBox.min.setScalar(-0.0005);\n this.localBox.max.setScalar(0.0005);\n return;\n }\n this.box.getBoundingSphere(this.sphere);\n }\n\n /**\n * Manual `expandByObject` that swallows per-node failures (missing\n * position attribute, null bounding box, etc.) instead of letting one bad\n * descendant abort the whole subtree. Accumulates BOTH the world-space\n * AABB (for cone-membership) and the candidate-local AABB (for the OBB\n * fallback) in the same traversal.\n */\n private expandSafely(obj: Object3D, worldBox: Box3, localBox: Box3): void {\n // IWSDK runtime-only meshes (ContactShadow and ShadowCatcher planes) take\n // no pointer hits, so they must not widen the candidate either.\n if (obj.userData?.iwsdkRuntimeOnly === true) {\n return;\n }\n const candidate = obj as Object3D & {\n geometry?: {\n boundingBox: Box3 | null;\n getAttribute?: (name: string) => unknown;\n computeBoundingBox?: () => void;\n };\n };\n const geometry = candidate.geometry;\n if (geometry) {\n try {\n if (\n geometry.getAttribute &&\n geometry.getAttribute('position') !== undefined\n ) {\n if (geometry.boundingBox === null && geometry.computeBoundingBox) {\n geometry.computeBoundingBox();\n }\n if (geometry.boundingBox) {\n // World AABB: geometry-local -> world via the leaf's own matrix.\n this.tmpBox.copy(geometry.boundingBox);\n this.tmpBox.applyMatrix4(obj.matrixWorld);\n worldBox.union(this.tmpBox);\n // Candidate-local AABB: geometry-local -> world -> candidate-local.\n this.tmpMat.copy(this.invWorld).multiply(obj.matrixWorld);\n this.tmpBox.copy(geometry.boundingBox).applyMatrix4(this.tmpMat);\n localBox.union(this.tmpBox);\n }\n }\n } catch {\n // ignore: degenerate geometry shouldn't disqualify the candidate\n }\n }\n const children = obj.children;\n for (let i = 0; i < children.length; i++) {\n this.expandSafely(children[i], worldBox, localBox);\n }\n }\n\n /**\n * Closest point on the candidate's oriented bounding box (its local AABB\n * transformed by `obj.matrixWorld`) to the gaze ray, in world space.\n *\n * Works in local space to avoid building 12 oriented edges in world: bring\n * the ray into the candidate's frame, run iterative AABB-vs-line refinement\n * (a few passes is plenty — it converges quadratically), then map the point\n * back to world.\n */\n private closestPointOnObb(\n obj: Object3D,\n origin: Vector3,\n direction: Vector3,\n out: Vector3,\n ): void {\n if (this.pointBoundsFallback) {\n out.copy(this.sphere.center);\n return;\n }\n // Ray -> local space. invWorld was just refreshed in `computeBounds`.\n this.localOrigin.copy(origin).applyMatrix4(this.invWorld);\n // transformDirection normalizes and ignores translation; preserves\n // rotation. Scale baked into the world matrix is lost — that's fine for a\n // closest-point query (we re-measure in world afterwards).\n this.localDirection.copy(direction).transformDirection(this.invWorld);\n\n // Seed with the box center, projected onto the ray.\n this.localBox.getCenter(this.localBoxCenter);\n this.localBoxClosest.copy(this.localBoxCenter);\n for (let iter = 0; iter < 3; iter++) {\n // Closest point on ray to current box-point estimate (t clamped to >= 0\n // so we never march behind the gaze origin).\n const t = Math.max(\n 0,\n this.localRayClosest\n .copy(this.localBoxClosest)\n .sub(this.localOrigin)\n .dot(this.localDirection),\n );\n this.localRayClosest\n .copy(this.localDirection)\n .multiplyScalar(t)\n .add(this.localOrigin);\n // Closest point on box to that ray point.\n this.localBoxClosest\n .copy(this.localRayClosest)\n .clamp(this.localBox.min, this.localBox.max);\n }\n out.copy(this.localBoxClosest).applyMatrix4(obj.matrixWorld);\n }\n\n private recordDwell(object: Object3D, time: number, dt: number): void {\n const slot =\n this.dwellRing[(this.dwellHead + this.dwellSize) % this.dwellCapacity];\n slot.object = object;\n slot.time = time;\n slot.dt = dt;\n if (this.dwellSize < this.dwellCapacity) {\n this.dwellSize++;\n } else {\n // Ring full — advance head and overwrite the oldest slot in-place.\n this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;\n }\n }\n\n private pruneDwell(now: number): void {\n const cutoff = now - this.dwellWindowSeconds;\n while (this.dwellSize > 0) {\n const head = this.dwellRing[this.dwellHead];\n if (head.time >= cutoff) {\n break;\n }\n this.clearDwellSlot(this.dwellHead);\n this.dwellHead = (this.dwellHead + 1) % this.dwellCapacity;\n this.dwellSize--;\n }\n }\n\n private electDwellWinner(): Object3D | null {\n if (this.dwellSize === 0) {\n return null;\n }\n\n // Find max-cumulative-dt object. Ring is short (~9 at 60 Hz), so\n // O(N^2) over the window stays cheap and avoids a Map allocation.\n let bestObject: Object3D | null = null;\n let bestDt = -1;\n for (let i = 0; i < this.dwellSize; i++) {\n const idx = (this.dwellHead + i) % this.dwellCapacity;\n const sample = this.dwellRing[idx];\n const obj = sample.object;\n if (!obj) {\n continue;\n }\n\n let sumDt = 0;\n for (let j = i; j < this.dwellSize; j++) {\n const jIdx = (this.dwellHead + j) % this.dwellCapacity;\n const s = this.dwellRing[jIdx];\n if (s.object === obj) {\n sumDt += s.dt;\n }\n }\n\n if (sumDt > bestDt) {\n bestDt = sumDt;\n bestObject = obj;\n }\n }\n return bestObject;\n }\n\n /** Resolve the elected object against the current pose, never a stale hit. */\n private resolveDwellWinner(ctx: GazeCandidateContext): GazeHit | null {\n while (this.dwellSize > 0) {\n const object = this.electDwellWinner();\n if (!object) {\n return null;\n }\n if (isObjectTreeVisible(object) && ctx.candidates.includes(object)) {\n this.computeBounds(object);\n if (this.sphere.radius >= 0) {\n this.closestPointOnObb(\n object,\n ctx.origin,\n ctx.direction,\n this.worldBoxClosest,\n );\n this.toCandidate.copy(this.worldBoxClosest).sub(ctx.origin);\n const distance = this.toCandidate.length();\n const angularDistance =\n distance <= 1e-6\n ? 0\n : Math.acos(\n Math.max(\n -1,\n Math.min(\n 1,\n this.toCandidate\n .divideScalar(distance)\n .dot(ctx.direction),\n ),\n ),\n );\n const hit = this.resolveSurface(object, ctx, angularDistance);\n if (hit) {\n return hit;\n }\n }\n }\n this.removeDwellObject(object);\n }\n return null;\n }\n\n private removeDwellObject(object: Object3D): void {\n const previousSize = this.dwellSize;\n let write = 0;\n for (let read = 0; read < this.dwellSize; read++) {\n const readIndex = (this.dwellHead + read) % this.dwellCapacity;\n const sample = this.dwellRing[readIndex];\n if (sample.object === object) {\n continue;\n }\n const writeIndex = (this.dwellHead + write) % this.dwellCapacity;\n if (writeIndex !== readIndex) {\n const destination = this.dwellRing[writeIndex];\n destination.object = sample.object;\n destination.time = sample.time;\n destination.dt = sample.dt;\n }\n write++;\n }\n for (let i = write; i < previousSize; i++) {\n this.clearDwellSlot((this.dwellHead + i) % this.dwellCapacity);\n }\n this.dwellSize = write;\n }\n\n private clearDwellSlot(index: number): void {\n const slot = this.dwellRing[index];\n slot.object = null;\n slot.time = 0;\n slot.dt = 0;\n }\n\n /** Current dwell winner, or null. */\n getDwellWinner(): GazeHit | null {\n return this.currentDwellWinner;\n }\n}\n"],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAiBH,MAAM,aAAa,GAAG,GAAG,IAAI,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC;AAC5C;AACA;AACA;AACA,MAAM,uBAAuB,GAAG,IAAI;AAEpC;;AAEG;MACU,mBAAmB,GAAiB,CAAC,CAAC,EAAE,CAAC,KAAI;IACxD,MAAM,MAAM,GAAG,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,eAAe;IACpD,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,aAAa,EAAE;AACpC,QAAA,OAAO,MAAM;IACf;IACA,OAAO,CAAC,CAAC,YAAY,CAAC,QAAQ,GAAG,CAAC,CAAC,YAAY,CAAC,QAAQ;AAC1D;AAmBA;;;;;;;;;;;;;;;;;;;;;AAqBG;MACU,cAAc,CAAA;AAgCzB,IAAA,WAAA,CAAY,OAA8B,EAAE,EAAA;;AA1B3B,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,MAAM,EAAE;AACrB,QAAA,IAAA,CAAA,GAAG,GAAG,IAAI,IAAI,EAAE;AAChB,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,IAAI,EAAE;AACrB,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,OAAO,EAAE;AACxB,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,OAAO,EAAE;AACtB,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,IAAI,EAAE;AACnB,QAAA,IAAA,CAAA,WAAW,GAAG,IAAI,OAAO,EAAE;AAC3B,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,OAAO,EAAE;AAC5B,QAAA,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AI;IAIhC,8CAA8C;IAC9C,WAAW,IAAI,OAAO;IAItB,6CAA6C;IAC7C,SAAS,IAAI,OAAO;IAIpB,6DAA6D;IAC7D,YAAY,IAAI,OAAO;IAIvB;;OAEG;IACH,aAAa,IAAI,UAAU;IAI3B;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAab,OAAO,IAAI,IAAI;CAOhB"}
|
|
@@ -61,6 +61,15 @@ function isIntentionalHeadDirectedPreview() {
|
|
|
61
61
|
const preview = globalThis.__IWSDK_TARGET_DEVICE_PREVIEW__;
|
|
62
62
|
return (preview === null || preview === void 0 ? void 0 : preview.active) === true && preview.gazeSimulation === 'head';
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* The development emulator (desktop IWER or a native override) supplies gaze
|
|
66
|
+
* that only moves when aimed, so it starts out matching the head and must not
|
|
67
|
+
* be reported as real eye data or as a head-locked runtime.
|
|
68
|
+
*/
|
|
69
|
+
function isEmulatedGaze() {
|
|
70
|
+
const profile = globalThis.__IWSDK_EMULATION_PROFILE;
|
|
71
|
+
return (profile === null || profile === void 0 ? void 0 : profile.active) === true;
|
|
72
|
+
}
|
|
64
73
|
/**
|
|
65
74
|
* One-shot console diagnostics for the gaze pipeline.
|
|
66
75
|
*
|
|
@@ -184,6 +193,8 @@ class GazeDiagnostics {
|
|
|
184
193
|
this.sourcePresent = present;
|
|
185
194
|
this.poseValid = null;
|
|
186
195
|
if (present) {
|
|
196
|
+
// A later disconnect is "showed up then left", never "never appeared".
|
|
197
|
+
this.loggedMissingSource = true;
|
|
187
198
|
console.info('[iwsdk][gaze] gaze XRInputSource appeared.', {
|
|
188
199
|
profiles: Array.from(gazeSource.profiles),
|
|
189
200
|
handedness: gazeSource.handedness,
|
|
@@ -214,7 +225,9 @@ class GazeDiagnostics {
|
|
|
214
225
|
}
|
|
215
226
|
this.poseValid = posed;
|
|
216
227
|
if (posed) {
|
|
217
|
-
console.info(
|
|
228
|
+
console.info(isEmulatedGaze()
|
|
229
|
+
? '[iwsdk][gaze] emulated gaze pose is valid (synthetic, not eye tracking).'
|
|
230
|
+
: '[iwsdk][gaze] eye pose is valid — real gaze data is flowing.');
|
|
218
231
|
}
|
|
219
232
|
else {
|
|
220
233
|
console.warn('[iwsdk][gaze] the gaze input source is present but ' +
|
|
@@ -269,6 +282,11 @@ class GazeDiagnostics {
|
|
|
269
282
|
'providing head-directed synthetic gaze.');
|
|
270
283
|
return;
|
|
271
284
|
}
|
|
285
|
+
if (isEmulatedGaze()) {
|
|
286
|
+
console.info('[iwsdk][gaze] emulated gaze still points where the head does; ' +
|
|
287
|
+
'aim it (for example with xr look-at on "gaze") to test targeting.');
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
272
290
|
console.warn('[iwsdk][gaze] the gaze target-ray pose matched the head pose on ' +
|
|
273
291
|
`${(identicalRatio * 100).toFixed(0)}% of ${this.comparisonFrames} ` +
|
|
274
292
|
`frames (max separation ${this.maxAngleDeg.toFixed(3)}°). Eye ` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaze-pointer.js","sources":["../../src/pointer/gaze-pointer.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\nimport {\n Pointer,\n createRayPointer,\n type Intersection,\n} from '@pmndrs/pointer-events';\nimport {\n CircleGeometry,\n Color,\n Matrix3,\n Matrix4,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n PerspectiveCamera,\n Quaternion,\n Scene,\n Vector3,\n} from 'three';\nimport type { GazeOrigin, XROrigin } from '../rig/xr-origin.js';\nimport {\n FilteredEyeGaze,\n FilteredEyeGazeOptions,\n} from './filtered-eye-gaze.js';\nimport type {\n GazeCandidateContext,\n GazeCandidateProvider,\n GazeHit,\n} from './gaze-candidate-provider.js';\nimport { GazeConecaster } from './gaze-conecaster.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\nexport type GazeHand = 'left' | 'right';\n\n/** Metadata exposed as `PointerEvent.pointerState` for the gaze ray. */\nexport interface GazePointerState {\n source: 'gaze';\n handedness: GazeHand | null;\n}\n\n/**\n * Per-frame input context passed into {@link GazePointer.update}.\n */\nexport interface GazePointerInput {\n /** Candidate Object3D roots (gaze-eligible interactables). */\n candidates: ReadonlyArray<Object3D>;\n /** Whether each hand's pinch went down this frame. */\n pinchStart: { left: boolean; right: boolean };\n /** Whether each hand's pinch was released this frame. */\n pinchEnd: { left: boolean; right: boolean };\n /** Whether each hand is currently pinching. */\n pinchActive: { left: boolean; right: boolean };\n /** Whether either hand has an active near touch/grab pointer. */\n directPointerActive: { left: boolean; right: boolean };\n}\n\n/**\n * The live WebXR state {@link GazePointer.sampleGazePose} needs to read the\n * gaze target ray itself, rather than trusting another system to have\n * refreshed the rig first.\n */\nexport interface GazeFrameContext {\n /** The frame currently being rendered. */\n frame: XRFrame;\n /**\n * Reference space the pose is resolved against. Must be the same space\n * {@link XROrigin.updateHead} used, since the result is written into\n * {@link XROrigin.eyeSpace}, which lives in that space.\n */\n referenceSpace: XRReferenceSpace;\n /** Session to scan for the gaze input source. */\n session: XRSession;\n}\n\nexport interface GazePointerOptions {\n /** Suppress hover/select while a near touch/grab pointer is active. @default true */\n suppressWhenDirectPointerActive?: boolean;\n /**\n * On select commit, move the effective pointer origin to the pinching\n * hand's ray space so captured drags track the hand, not the eyes.\n * @default true\n */\n pointerTransformFollowsHand?: boolean;\n /** Reticle color while gaze is genuinely tracked. @default 0xffffff */\n reticleColor?: Color | number;\n /** Reticle radius in meters. @default 0.012 */\n reticleRadius?: number;\n /** Show the developer-only gaze hit reticle. @default false */\n showDebugReticle?: boolean;\n /** Keep gaze mode active briefly after tracking becomes invalid. @default 5 */\n trackingLossGraceSeconds?: number;\n /** OneEuro filter parameters applied to the gaze pose. */\n filter?: FilteredEyeGazeOptions;\n /**\n * Emit `[iwsdk][gaze]` console diagnostics explaining why gaze is (or isn't)\n * tracked, and whether the runtime's gaze ray actually separates from the\n * head ray. Eye tracking has several silent failure modes that are otherwise\n * indistinguishable from a missing source.\n * @default true\n */\n diagnostics?: boolean;\n}\n\n/**\n * Locate the eye-tracking input source.\n *\n * The primary scan is the one the standalone WebXR eye-gaze diagnostic page\n * uses verbatim — the gaze source is whichever entry of `session.inputSources`\n * reports `targetRayMode === 'gaze'`. `trackedSources` is checked afterwards\n * because some runtimes surface non-primary sources only there; the\n * diagnostics log says which list produced the hit.\n */\nfunction findGazeSource(session: XRSession): {\n source: XRInputSource | undefined;\n fromTrackedSources: boolean;\n} {\n for (const source of session.inputSources) {\n if (source.targetRayMode === 'gaze') {\n return { source, fromTrackedSources: false };\n }\n }\n if (session.trackedSources) {\n for (const source of session.trackedSources) {\n if (source.targetRayMode === 'gaze') {\n return { source, fromTrackedSources: true };\n }\n }\n }\n return { source: undefined, fromTrackedSources: false };\n}\n\n/**\n * Thresholds lifted from the standalone WebXR eye-gaze diagnostic page, so a\n * verdict logged here means the same thing as a verdict shown there.\n */\nconst GAZE_VERDICT = {\n /** Gaze/head separation that proves the eye ray is genuinely independent. */\n passAngleDeg: 1.5,\n /** Below this, one frame's gaze and head rays count as \"the same ray\". */\n identicalAngleDeg: 0.05,\n /** Below this (millimetres), one frame's gaze and head origins coincide. */\n identicalPositionMm: 0.5,\n /** Ratio of identical frames that indicates a head-pose mapping bug. */\n headLockedRatio: 0.95,\n /** Max separation still counted as head-locked. */\n headLockedAngleDeg: 0.1,\n /** Minimum evidence before any negative verdict is logged. */\n minSeconds: 3,\n minFrames: 90,\n} as const;\n\nconst RAD_TO_DEG = 180 / Math.PI;\nconst diagForward = new Vector3();\nconst diagHeadForward = new Vector3();\n\nconst RETICLE_FORWARD = new Vector3(0, 0, 1);\n\nfunction isIntentionalHeadDirectedPreview(): boolean {\n const preview = (\n globalThis as typeof globalThis & {\n __IWSDK_TARGET_DEVICE_PREVIEW__?: {\n active?: boolean;\n gazeSimulation?: 'head' | false;\n };\n }\n ).__IWSDK_TARGET_DEVICE_PREVIEW__;\n return preview?.active === true && preview.gazeSimulation === 'head';\n}\n\n/**\n * One-shot console diagnostics for the gaze pipeline.\n *\n * Eye tracking fails silently in several distinct ways — feature not granted,\n * no gaze input source, source present but posed null, or a runtime that maps\n * the gaze target ray onto the head pose. These can otherwise look like either\n * missing or head-locked gaze, so each gets its own message with the\n * remediation that actually applies. Every message fires at most once per\n * state transition, so this is safe to leave on in a per-frame path.\n */\nclass GazeDiagnostics {\n private sessionStart = -1;\n private loggedFeature = false;\n private loggedMissingSource = false;\n private loggedTrackedSourcesFallback = false;\n private loggedPoseThrow = false;\n private loggedNoTargets = false;\n private loggedVerdict = false;\n private loggedInconclusive = false;\n private sourcePresent = false;\n /** Tri-state so the very first sample always logs its pose validity. */\n private poseValid: boolean | null = null;\n\n // Head-versus-gaze separation stats, accumulated over valid poses only.\n private firstValidPoseAt = -1;\n private comparisonFrames = 0;\n private identicalFrames = 0;\n private maxAngleDeg = 0;\n private maxPositionMm = 0;\n\n reset(): void {\n this.sessionStart = -1;\n this.loggedFeature = false;\n this.loggedMissingSource = false;\n this.loggedTrackedSourcesFallback = false;\n this.loggedPoseThrow = false;\n this.loggedNoTargets = false;\n this.loggedVerdict = false;\n this.loggedInconclusive = false;\n this.sourcePresent = false;\n this.poseValid = null;\n this.firstValidPoseAt = -1;\n this.comparisonFrames = 0;\n this.identicalFrames = 0;\n this.maxAngleDeg = 0;\n this.maxPositionMm = 0;\n }\n\n /**\n * @param time Monotonic seconds, matching {@link GazePointer.update}.\n * @param xrOrigin Rig whose `eyeSpace`/`head` hold this frame's poses.\n */\n frame(\n time: number,\n xrOrigin: XROrigin,\n session: XRSession,\n gazeSource: XRInputSource | undefined,\n fromTrackedSources: boolean,\n posed: boolean,\n ): void {\n if (this.sessionStart < 0) {\n this.sessionStart = time;\n }\n this.logFeature(session);\n this.logSource(time, gazeSource, fromTrackedSources);\n this.logPose(gazeSource, posed);\n if (posed) {\n this.compareWithHead(time, xrOrigin);\n }\n }\n\n /** Nothing is gaze-eligible, so gaze can never hit anything. */\n targets(count: number): void {\n if (count > 0) {\n this.loggedNoTargets = false;\n return;\n }\n if (this.loggedNoTargets) {\n return;\n }\n this.loggedNoTargets = true;\n console.info(\n '[iwsdk][gaze] no ray-interactable targets are available, so the gaze ' +\n 'cone has nothing to hit.',\n );\n }\n\n poseThrew(error: unknown): void {\n if (this.loggedPoseThrow) {\n return;\n }\n this.loggedPoseThrow = true;\n console.warn(\n '[iwsdk][gaze] frame.getPose(gazeSource.targetRaySpace) threw; tracked ' +\n 'gaze is unavailable for this frame.',\n error,\n );\n }\n\n /** Report whether the runtime actually granted `gaze-tracking`. */\n private logFeature(session: XRSession): void {\n if (this.loggedFeature) {\n return;\n }\n this.loggedFeature = true;\n // `enabledFeatures` is not in every UA's lib.dom typing yet.\n const enabled = (session as XRSession & { enabledFeatures?: string[] })\n .enabledFeatures;\n if (!enabled) {\n console.info(\n \"[iwsdk][gaze] this browser doesn't expose session.enabledFeatures, \" +\n \"so whether 'gaze-tracking' was granted can't be confirmed here. \" +\n 'Watch for the gaze XRInputSource message below instead.',\n );\n return;\n }\n const enabledFeatures = Array.from(enabled);\n if (\n enabledFeatures.includes('gaze-tracking') ||\n enabledFeatures.includes('eye-tracking')\n ) {\n console.info(\"[iwsdk][gaze] 'gaze-tracking' granted for this session.\", {\n enabledFeatures,\n });\n return;\n }\n console.warn(\n \"[iwsdk][gaze] 'gaze-tracking' was NOT granted for this session, so \" +\n 'tracked gaze is unavailable. Check that the project requests ' +\n 'xr.features.gazeTracking, that this browser build exposes eye ' +\n \"tracking, and that the page's permissions policy allows \" +\n 'xr-spatial-tracking.',\n { enabledFeatures },\n );\n }\n\n private logSource(\n time: number,\n gazeSource: XRInputSource | undefined,\n fromTrackedSources: boolean,\n ): void {\n const present = !!gazeSource;\n\n if (present && fromTrackedSources && !this.loggedTrackedSourcesFallback) {\n this.loggedTrackedSourcesFallback = true;\n console.info(\n '[iwsdk][gaze] gaze source found in session.trackedSources rather ' +\n 'than session.inputSources.',\n );\n }\n\n if (present !== this.sourcePresent) {\n this.sourcePresent = present;\n this.poseValid = null;\n if (present) {\n console.info('[iwsdk][gaze] gaze XRInputSource appeared.', {\n profiles: Array.from(gazeSource!.profiles),\n handedness: gazeSource!.handedness,\n });\n } else {\n console.warn(\n '[iwsdk][gaze] the gaze XRInputSource disappeared; ' +\n 'ordinary hand/controller far targeting is now active.',\n );\n }\n return;\n }\n\n // Never showed up at all — distinct failure from \"showed up then left\".\n if (\n !present &&\n !this.loggedMissingSource &&\n time - this.sessionStart >= GAZE_VERDICT.minSeconds\n ) {\n this.loggedMissingSource = true;\n console.warn(\n '[iwsdk][gaze] no XRInputSource with targetRayMode === \"gaze\" ' +\n `appeared within ${GAZE_VERDICT.minSeconds}s of session start. ` +\n 'Ordinary hand/controller far targeting remains active. Common causes: the ' +\n 'feature was not granted, eye tracking is disabled in system ' +\n 'settings, the headset has not been calibrated for this user, or ' +\n 'the hardware has no eye tracking.',\n );\n }\n }\n\n private logPose(gazeSource: XRInputSource | undefined, posed: boolean): void {\n if (!gazeSource || posed === this.poseValid) {\n return;\n }\n this.poseValid = posed;\n if (posed) {\n console.info(\n '[iwsdk][gaze] eye pose is valid — real gaze data is flowing.',\n );\n } else {\n console.warn(\n '[iwsdk][gaze] the gaze input source is present but ' +\n 'frame.getPose(targetRaySpace) returned null, so tracked gaze is ' +\n 'temporarily unavailable. Common causes: OS eye-tracking permission ' +\n 'not granted, headset not calibrated, or hardware without eye tracking.',\n );\n }\n }\n\n /**\n * Compare the tracked gaze ray against the head ray. A runtime can hand back\n * a perfectly valid gaze pose that is just a copy of the viewer pose; that\n * is indistinguishable from the fallback unless the two are measured.\n */\n private compareWithHead(time: number, xrOrigin: XROrigin): void {\n if (this.loggedVerdict) {\n return;\n }\n const eye = xrOrigin.eyeSpace;\n const head = xrOrigin.head;\n diagForward.set(0, 0, -1).applyQuaternion(eye.quaternion);\n diagHeadForward.set(0, 0, -1).applyQuaternion(head.quaternion);\n const dot = Math.min(1, Math.max(-1, diagForward.dot(diagHeadForward)));\n const angleDeg = Math.acos(dot) * RAD_TO_DEG;\n const positionMm = eye.position.distanceTo(head.position) * 1000;\n\n if (this.firstValidPoseAt < 0) {\n this.firstValidPoseAt = time;\n }\n this.comparisonFrames++;\n this.maxAngleDeg = Math.max(this.maxAngleDeg, angleDeg);\n this.maxPositionMm = Math.max(this.maxPositionMm, positionMm);\n if (\n angleDeg < GAZE_VERDICT.identicalAngleDeg &&\n positionMm < GAZE_VERDICT.identicalPositionMm\n ) {\n this.identicalFrames++;\n }\n\n if (this.maxAngleDeg >= GAZE_VERDICT.passAngleDeg) {\n this.loggedVerdict = true;\n console.info(\n '[iwsdk][gaze] real eye movement observed — the gaze ray separates ' +\n `from the head ray by up to ${this.maxAngleDeg.toFixed(2)}°.`,\n );\n return;\n }\n\n if (\n time - this.firstValidPoseAt < GAZE_VERDICT.minSeconds ||\n this.comparisonFrames < GAZE_VERDICT.minFrames\n ) {\n return;\n }\n\n const identicalRatio = this.identicalFrames / this.comparisonFrames;\n if (\n identicalRatio >= GAZE_VERDICT.headLockedRatio &&\n this.maxAngleDeg < GAZE_VERDICT.headLockedAngleDeg &&\n this.maxPositionMm < GAZE_VERDICT.identicalPositionMm\n ) {\n this.loggedVerdict = true;\n if (isIntentionalHeadDirectedPreview()) {\n console.info(\n '[iwsdk][gaze] target-device preview is intentionally ' +\n 'providing head-directed synthetic gaze.',\n );\n return;\n }\n console.warn(\n '[iwsdk][gaze] the gaze target-ray pose matched the head pose on ' +\n `${(identicalRatio * 100).toFixed(0)}% of ${this.comparisonFrames} ` +\n `frames (max separation ${this.maxAngleDeg.toFixed(3)}°). Eye ` +\n 'tracking is reporting poses, but the runtime is mapping ' +\n 'XRTargetRaySpace onto the head pose, so gaze behaves as ' +\n 'head-pointing. This is a runtime/build issue, not an app one.',\n );\n return;\n }\n\n if (!this.loggedInconclusive) {\n this.loggedInconclusive = true;\n console.info(\n `[iwsdk][gaze] inconclusive: only ${this.maxAngleDeg.toFixed(2)}° of ` +\n `gaze/head separation over ${this.comparisonFrames} frames. Hold ` +\n 'your head still and look far left and right to confirm real gaze.',\n );\n }\n }\n}\n\n/**\n * Singleton gaze pointer. Peer of {@link MultiPointer} in\n * {@link XRInputManager}.\n *\n * @remarks\n * - One global instance — gaze has no handedness.\n * - Samples the WebXR gaze target ray itself via\n * {@link GazePointer.sampleGazePose}, publishing the result to\n * {@link XROrigin.eyeSpace}. The hand/controller ray owns far targeting when\n * a gaze source is unavailable. {@link GazePointerOptions.diagnostics}\n * explains the silent failure modes.\n * - Candidate selection is delegated to a {@link GazeCandidateProvider};\n * the default {@link GazeConecaster} does OBB cone membership and\n * time-weighted dwell consensus while this pointer resolves surfaces with\n * the same pmndrs ray intersector used for event delivery.\n * - Selector composes either hand's pinch; once selecting, the other hand\n * is ignored until release (per-hand mutual exclusion, matching Meta\n * Interaction SDK's `HandGazeInteractor` semantics).\n * - Drives a real `@pmndrs/pointer-events` pointer so UIKit panels click\n * naturally on gaze-pinch.\n * - Keeps its optional debug reticle hidden by default. Production feedback\n * belongs on the hovered target, matching Meta Interaction SDK.\n *\n * @category Pointer\n */\nexport class GazePointer {\n public readonly reticle: Mesh<CircleGeometry, MeshBasicMaterial>;\n\n public provider: GazeCandidateProvider;\n public suppressWhenDirectPointerActive: boolean;\n public pointerTransformFollowsHand: boolean;\n public showDebugReticle: boolean;\n\n private _trackingLossGraceSeconds = 5;\n\n public get trackingLossGraceSeconds(): number {\n return this._trackingLossGraceSeconds;\n }\n\n public set trackingLossGraceSeconds(value: number) {\n this._trackingLossGraceSeconds = Number.isFinite(value)\n ? Math.max(0, value)\n : 0;\n }\n\n /** See {@link GazePointerOptions.diagnostics}. */\n public diagnosticsEnabled: boolean;\n\n /**\n * OneEuro smoother applied to the raw gaze pose. Public so hosts can retune\n * `minCutoff`/`beta` from config without rebuilding the pointer.\n */\n public readonly filter: FilteredEyeGaze;\n\n /**\n * Real `@pmndrs/pointer-events` Pointer driven by the filtered gaze ray.\n * Each frame: pose-update + `pointer.move(scene)` raycasts from the gaze\n * origin so UIKit and any other pointer-events listeners see enter/leave/\n * move events from the gaze just like they do from the hand ray. On pinch\n * we forward `down`/`up` with `button: 0` so `click` fires naturally.\n */\n public readonly pointer: Pointer;\n public readonly pointerState: GazePointerState = {\n source: 'gaze',\n handedness: null,\n };\n\n private readonly filteredOrigin = new Vector3();\n private readonly filteredQuaternion = new Quaternion();\n private readonly rawOrigin = new Vector3();\n private readonly rawQuaternion = new Quaternion();\n private readonly direction = new Vector3();\n private readonly aimDirection = new Vector3();\n private readonly reticleOffset = new Vector3();\n private readonly rayTarget = new Vector3();\n private readonly rayUp = new Vector3();\n private readonly handOrigin = new Vector3();\n private readonly handQuaternion = new Quaternion();\n private readonly worldRayQuaternion = new Quaternion();\n private readonly handRelativeRayQuaternion = new Quaternion();\n private readonly tmpQuat = new Quaternion();\n private readonly lookMatrix = new Matrix4();\n private readonly normalMatrix = new Matrix3();\n\n /** Reticle tint while gaze is genuinely tracked. */\n private readonly reticleTrackedColor: Color;\n\n /**\n * Synthetic `Object3D` whose world transform mirrors the *filtered* gaze\n * pose. Lives under `xrOrigin` so it inherits rig motion; the @pmndrs ray\n * intersector reads its position/quaternion to cast from.\n */\n private readonly gazeRaySpace: Object3D;\n\n private readonly conecasterCtx: GazeCandidateContext = {\n origin: this.filteredOrigin,\n direction: this.direction,\n candidates: [] as ReadonlyArray<Object3D>,\n intersectCandidate: (candidate, direction) =>\n this.intersectCandidate(candidate, direction),\n };\n\n private readonly nativeEvent = { timeStamp: 0 };\n private readonly buttonEvent = { timeStamp: 0, button: 0 };\n\n private currentHit: GazeHit | null = null;\n private heldHit: GazeHit | null = null;\n private heldByHand: GazeHand | null = null;\n private wasSelecting = false;\n private buttonDown = false;\n private heldFollowsHand = false;\n private hasAcquiredTrackedGaze = false;\n private gazeSource: XRInputSource | null = null;\n private gazeSourcePresent = false;\n private lastTrackedPoseTime = Number.NEGATIVE_INFINITY;\n\n private readonly diagnostics = new GazeDiagnostics();\n\n constructor(\n private readonly xrOrigin: XROrigin,\n private readonly scene: Scene,\n camera: PerspectiveCamera,\n options: GazePointerOptions = {},\n ) {\n this.provider = new GazeConecaster();\n this.suppressWhenDirectPointerActive =\n options.suppressWhenDirectPointerActive ?? true;\n this.pointerTransformFollowsHand =\n options.pointerTransformFollowsHand ?? true;\n this.showDebugReticle = options.showDebugReticle ?? false;\n this.trackingLossGraceSeconds = options.trackingLossGraceSeconds ?? 5;\n this.diagnosticsEnabled = options.diagnostics ?? true;\n this.filter = new FilteredEyeGaze(options.filter);\n\n this.reticleTrackedColor =\n options.reticleColor instanceof Color\n ? options.reticleColor.clone()\n : new Color(options.reticleColor ?? 0xffffff);\n const radius = options.reticleRadius ?? 0.012;\n this.reticle = new Mesh(\n new CircleGeometry(radius, 32),\n new MeshBasicMaterial({\n color: this.reticleTrackedColor.clone(),\n transparent: true,\n opacity: 0.85,\n depthWrite: false,\n depthTest: false,\n }),\n );\n this.reticle.renderOrder = Infinity;\n this.reticle.visible = false;\n this.reticle.name = 'gaze-reticle';\n\n // Synthetic ray source for the @pmndrs Pointer. We can't use eyeSpace\n // directly because we want the *filtered* pose, not the raw per-frame\n // gaze. Manual matrix updates: we drive position/quaternion explicitly\n // each frame from the filter output.\n this.gazeRaySpace = new Object3D();\n this.gazeRaySpace.name = 'gaze-ray-space';\n this.gazeRaySpace.matrixAutoUpdate = false;\n\n this.pointer = createRayPointer(\n () => camera,\n { current: this.gazeRaySpace },\n this.pointerState,\n // contextMenu lives on button 2; gaze never produces it. Disable to\n // avoid spurious contextmenu events.\n {\n contextMenuButton: -1,\n filter: isObjectTreeVisible,\n },\n );\n // BVH-accelerated firstHitOnly raycast (matches hand RayPointer).\n const raycaster = (\n this.pointer.intersector as unknown as {\n raycaster?: { firstHitOnly?: boolean };\n }\n ).raycaster;\n if (raycaster) {\n raycaster.firstHitOnly = true;\n }\n }\n\n /**\n * Add or remove the pointer's rig nodes (debug reticle and ray space).\n *\n * The pointer is constructed eagerly by {@link XRInputManager} so systems can\n * hold a stable reference, but an app that never uses gaze shouldn't pay for\n * gaze geometry in every rig matrix walk — so nothing is parented until gaze\n * is actually switched on.\n */\n setAttached(attached: boolean): void {\n if (attached) {\n this.xrOrigin.add(this.reticle, this.gazeRaySpace);\n } else {\n this.reticle.removeFromParent();\n this.gazeRaySpace.removeFromParent();\n }\n }\n\n /**\n * Read the gaze target ray off the live frame and write it into\n * {@link XROrigin.eyeSpace}.\n *\n * This mirrors the standalone WebXR eye-gaze diagnostic page's probe: find\n * the input source whose `targetRayMode` is `'gaze'`, then pose its\n * `targetRaySpace` against the frame's reference space, tolerating a throw.\n * The source can exist while `getPose` returns null (uncalibrated headset,\n * withheld permission), so source presence and pose validity are tracked\n * separately. A missing or invalid pose clears the current gaze pose so stale\n * tracking can never be used for targeting.\n *\n * Call once per frame before {@link GazePointer.update}.\n */\n sampleGazePose(time: number, context: GazeFrameContext): void {\n const { frame, referenceSpace, session } = context;\n const { source, fromTrackedSources } = findGazeSource(session);\n const nextGazeSource = source ?? null;\n if (nextGazeSource !== this.gazeSource) {\n // Grace belongs to one uninterrupted source lifetime. A source that is\n // removed or replaced must earn ownership again with a valid pose.\n this.hasAcquiredTrackedGaze = false;\n this.lastTrackedPoseTime = Number.NEGATIVE_INFINITY;\n this.gazeSource = nextGazeSource;\n }\n this.gazeSourcePresent = source != null;\n this.xrOrigin.clearGaze();\n let pose: XRPose | null = null;\n if (source) {\n try {\n pose = frame.getPose(source.targetRaySpace, referenceSpace) ?? null;\n } catch (error) {\n if (this.diagnosticsEnabled) {\n this.diagnostics.poseThrew(error);\n }\n }\n }\n\n if (pose) {\n this.xrOrigin.applyTrackedEyePose(pose.transform);\n this.hasAcquiredTrackedGaze = true;\n this.lastTrackedPoseTime = time;\n }\n\n if (this.diagnosticsEnabled) {\n this.diagnostics.frame(\n time,\n this.xrOrigin,\n session,\n source,\n fromTrackedSources,\n !!pose,\n );\n }\n }\n\n /**\n * Whether gaze mode should own far targeting this frame.\n *\n * This mirrors ISDK's mode/source distinction: a valid pose activates gaze;\n * then a short grace period keeps the mode active when a frame's pose is\n * invalid (for example, a blink), while targeting itself clears. WebXR does\n * not expose a separate pose-validity signal, so source enumeration defines\n * the lifetime of that grace period. Removing the source hands far targeting\n * back to hands/controllers immediately; the grace period applies only to\n * temporary pose invalidity (for example, a blink).\n */\n ownsFarTargeting(time: number): boolean {\n if (!this.gazeSourcePresent) {\n return false;\n }\n if (this.xrOrigin.gazeOrigin === 'tracked') {\n return true;\n }\n return (\n this.hasAcquiredTrackedGaze &&\n time - this.lastTrackedPoseTime <= this.trackingLossGraceSeconds\n );\n }\n\n /** Whether this frame has a pose that is safe to use for fresh targeting. */\n canTarget(): boolean {\n return this.xrOrigin.gazeOrigin === 'tracked';\n }\n\n /**\n * Swap the candidate provider at runtime (e.g. a multi-cone or dwell-only\n * provider). The previous provider is reset and detached.\n */\n setCandidateProvider(provider: GazeCandidateProvider): void {\n this.provider.reset();\n this.provider = provider;\n }\n\n update(\n targetingAvailable: boolean,\n dt: number,\n time: number,\n input: GazePointerInput,\n ): void {\n this.nativeEvent.timeStamp = time * 1000;\n\n // Source removal is a mode transition, not transient tracking loss. End a\n // gaze-started gesture before hand/controller far targeting resumes.\n if (!this.gazeSourcePresent && !targetingAvailable && this.heldByHand) {\n this.releaseSelect(true);\n }\n\n if (!targetingAvailable && !this.heldByHand) {\n this.provider.reset();\n this.filter.reset();\n this.currentHit = null;\n this.reticle.visible = false;\n this.releaseAndDisable();\n return;\n }\n\n let releasedSelect = false;\n if (this.heldByHand) {\n const hand = this.heldByHand;\n const pinchEnded = input.pinchEnd[hand];\n const targetAvailable = this.isHeldTargetAvailable(input.candidates);\n if (pinchEnded || !input.pinchActive[hand] || !targetAvailable) {\n // A real pinch-end is an up/click. Tracking loss, reset, removal, or\n // semantic invisibility interrupts the gesture and must cancel it.\n this.releaseSelect(!pinchEnded || !targetAvailable);\n releasedSelect = true;\n } else {\n this.driveHeldPointer();\n this.updateReticle();\n return;\n }\n }\n\n // A transient invalid eye pose clears hover immediately, matching ISDK,\n // but does not interrupt a selection that was already handed off to the\n // pinching hand. Once that gesture ends there is no stale pose from which\n // to start a new selection.\n if (!targetingAvailable) {\n this.provider.reset();\n this.filter.reset();\n this.currentHit = null;\n this.reticle.visible = false;\n this.releaseAndDisable();\n return;\n }\n\n if (this.diagnosticsEnabled) {\n this.diagnostics.targets(input.candidates.length);\n }\n\n // World-space pose of the (raw) gaze, then smoothed in-place. This runs\n // only with a current targeting pose, so a transient invalid frame cannot\n // contaminate the eye filter with the previous valid gaze pose.\n this.xrOrigin.eyeSpace.getWorldPosition(this.rawOrigin);\n this.xrOrigin.eyeSpace.getWorldQuaternion(this.rawQuaternion);\n this.filter.filter(\n this.rawOrigin,\n this.rawQuaternion,\n Math.max(dt, 1 / 240),\n this.filteredOrigin,\n this.filteredQuaternion,\n );\n this.direction.set(0, 0, -1).applyQuaternion(this.filteredQuaternion);\n\n const externallySuppressed =\n this.suppressWhenDirectPointerActive &&\n (input.directPointerActive.left || input.directPointerActive.right);\n\n if (externallySuppressed) {\n this.currentHit = null;\n this.reticle.visible = false;\n this.commitNoTarget();\n } else {\n this.conecasterCtx.candidates = input.candidates;\n this.currentHit = this.provider.update(time, dt, this.conecasterCtx);\n if (this.currentHit) {\n this.commitHit(this.currentHit);\n } else {\n this.commitNoTarget();\n }\n }\n\n if (!releasedSelect) {\n this.processSelector(input);\n }\n this.updateReticle();\n }\n\n /** Resolve one candidate through the same intersector used for dispatch. */\n private intersectCandidate(\n candidate: Object3D,\n direction: Vector3,\n ): Intersection | null {\n this.setRayFromDirection(\n this.filteredOrigin,\n direction,\n this.filteredQuaternion,\n );\n const intersection = this.computeScopedIntersection([candidate]);\n return intersection.object.isVoidObject ? null : intersection;\n }\n\n /** Install the provider's authoritative intersection and emit one move. */\n private commitHit(hit: GazeHit): void {\n this.ensurePointerEnabled();\n this.setRayWorldPose(\n hit.intersection.pointerPosition,\n hit.intersection.pointerQuaternion,\n );\n this.pointer.setIntersection(hit.intersection);\n this.pointer.commit(this.nativeEvent, true);\n }\n\n /** Commit a void hit so the previous target receives out/leave events. */\n private commitNoTarget(): void {\n this.currentHit = null;\n this.ensurePointerEnabled();\n this.setRayFromDirection(\n this.filteredOrigin,\n this.direction,\n this.filteredQuaternion,\n );\n const intersection = this.computeScopedIntersection([]);\n this.pointer.setIntersection(intersection);\n this.pointer.commit(this.nativeEvent, true);\n }\n\n private computeScopedIntersection(descendants: Object3D[]): Intersection {\n const scene = this.scene as Scene & {\n interactableDescendants?: Object3D[];\n };\n const previous = scene.interactableDescendants;\n scene.interactableDescendants = descendants;\n try {\n return this.pointer.computeIntersection(\n 'pointer',\n this.scene,\n this.nativeEvent,\n );\n } finally {\n scene.interactableDescendants = previous;\n }\n }\n\n private ensurePointerEnabled(): void {\n if (!this.pointer.getEnabled()) {\n this.pointer.setEnabled(true, this.nativeEvent, false);\n }\n }\n\n /** Pose the synthetic ray in world space while it remains parented to the rig. */\n private setRayWorldPose(origin: Vector3, quaternion: Quaternion): void {\n this.xrOrigin.updateWorldMatrix(true, false);\n this.gazeRaySpace.position.copy(origin);\n this.xrOrigin.worldToLocal(this.gazeRaySpace.position);\n this.xrOrigin.getWorldQuaternion(this.tmpQuat).invert();\n this.gazeRaySpace.quaternion.copy(this.tmpQuat).multiply(quaternion);\n this.gazeRaySpace.updateMatrix();\n this.gazeRaySpace.updateMatrixWorld(true);\n }\n\n /** Build a ray pose whose -Z axis follows `direction`. */\n private setRayFromDirection(\n origin: Vector3,\n direction: Vector3,\n upQuaternion: Quaternion,\n ): void {\n this.rayTarget.copy(origin).add(direction);\n this.rayUp.set(0, 1, 0).applyQuaternion(upQuaternion);\n this.lookMatrix.lookAt(origin, this.rayTarget, this.rayUp);\n this.worldRayQuaternion.setFromRotationMatrix(this.lookMatrix);\n this.setRayWorldPose(origin, this.worldRayQuaternion);\n }\n\n /** Release event state before disabling or detaching the pointer. */\n private releaseAndDisable(): void {\n this.releaseSelect(true);\n if (!this.pointer.getEnabled()) {\n return;\n }\n this.pointer.exit(this.nativeEvent);\n this.pointer.setEnabled(false, this.nativeEvent, false);\n }\n\n private updateReticle(): void {\n if (!this.showDebugReticle) {\n this.reticle.visible = false;\n return;\n }\n const intersection = this.pointer.getIntersection();\n if (!intersection || intersection.object.isVoidObject) {\n this.reticle.visible = false;\n return;\n }\n if (\n this.reticle.material.color.getHex() !== this.reticleTrackedColor.getHex()\n ) {\n this.reticle.material.color.copy(this.reticleTrackedColor);\n }\n this.reticleOffset.copy(intersection.point);\n this.xrOrigin.worldToLocal(this.reticleOffset);\n this.reticle.position.copy(this.reticleOffset);\n\n const normal = intersection.normal ?? intersection.face?.normal;\n if (normal) {\n this.normalMatrix.getNormalMatrix(intersection.object.matrixWorld);\n this.rayUp.copy(normal).applyNormalMatrix(this.normalMatrix).normalize();\n this.reticle.quaternion.setFromUnitVectors(RETICLE_FORWARD, this.rayUp);\n this.xrOrigin.getWorldQuaternion(this.tmpQuat).invert();\n this.reticle.quaternion.premultiply(this.tmpQuat);\n }\n // Scale reticle gently with distance for legibility.\n const s = Math.max(0.6, Math.min(2, intersection.distance));\n this.reticle.scale.setScalar(s);\n this.reticle.visible = true;\n }\n\n private processSelector(input: GazePointerInput): void {\n const hand: GazeHand | null = input.pinchStart.left\n ? 'left'\n : input.pinchStart.right\n ? 'right'\n : null;\n if (!hand || !this.currentHit) {\n return;\n }\n\n const gazeHit = this.currentHit;\n this.heldByHand = hand;\n this.pointerState.handedness = hand;\n this.heldFollowsHand = false;\n\n let selectIntersection = gazeHit.intersection;\n if (this.pointerTransformFollowsHand) {\n const handSpace = this.xrOrigin.raySpaces[hand];\n handSpace.updateWorldMatrix(true, false);\n handSpace.getWorldPosition(this.handOrigin);\n handSpace.getWorldQuaternion(this.handQuaternion);\n this.aimDirection.copy(gazeHit.intersection.point).sub(this.handOrigin);\n if (this.aimDirection.lengthSq() > 1e-12) {\n this.aimDirection.normalize();\n this.setRayFromDirection(\n this.handOrigin,\n this.aimDirection,\n this.handQuaternion,\n );\n const handIntersection = this.computeScopedIntersection([\n gazeHit.object,\n ]);\n if (\n !handIntersection.object.isVoidObject &&\n handIntersection.object === gazeHit.intersection.object\n ) {\n selectIntersection = handIntersection;\n this.handRelativeRayQuaternion\n .copy(this.handQuaternion)\n .invert()\n .multiply(handIntersection.pointerQuaternion);\n this.heldFollowsHand = true;\n } else {\n this.setRayWorldPose(\n gazeHit.intersection.pointerPosition,\n gazeHit.intersection.pointerQuaternion,\n );\n }\n }\n }\n\n this.heldHit = {\n object: gazeHit.object,\n intersection: selectIntersection,\n angularDistance: gazeHit.angularDistance,\n };\n this.wasSelecting = true;\n this.pointer.setIntersection(selectIntersection);\n // The hover path already emitted this frame's move. This commit only needs\n // to install the hand-origin intersection before a synchronous capture in\n // `down()`; enter/leave bookkeeping still runs if the leaf changed.\n this.pointer.commit(this.nativeEvent, false);\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = 0;\n this.buttonDown = true;\n try {\n this.pointer.down(this.buttonEvent);\n } catch {\n this.releaseSelect(true);\n }\n }\n\n private driveHeldPointer(): void {\n if (!this.heldHit || !this.heldByHand) {\n return;\n }\n\n if (this.pointer.getPointerCapture()) {\n if (this.heldFollowsHand) {\n const handSpace = this.xrOrigin.raySpaces[this.heldByHand];\n handSpace.updateWorldMatrix(true, false);\n handSpace.getWorldPosition(this.handOrigin);\n handSpace.getWorldQuaternion(this.handQuaternion);\n this.worldRayQuaternion\n .copy(this.handQuaternion)\n .multiply(this.handRelativeRayQuaternion);\n this.setRayWorldPose(this.handOrigin, this.worldRayQuaternion);\n } else {\n this.setRayWorldPose(\n this.heldHit.intersection.pointerPosition,\n this.heldHit.intersection.pointerQuaternion,\n );\n }\n this.pointer.move(this.scene, this.nativeEvent);\n return;\n }\n\n // Plain clickable targets generally do not capture. Keep their select-time\n // intersection stable so small hand motion during the pinch cannot turn a\n // valid down into an up on the void object.\n this.setRayWorldPose(\n this.heldHit.intersection.pointerPosition,\n this.heldHit.intersection.pointerQuaternion,\n );\n this.pointer.setIntersection(this.heldHit.intersection);\n this.pointer.commit(this.nativeEvent, true);\n }\n\n private isHeldTargetAvailable(candidates: ReadonlyArray<Object3D>): boolean {\n const object = this.heldHit?.object;\n return (\n !!object && isObjectTreeVisible(object) && candidates.includes(object)\n );\n }\n\n private releaseSelect(cancelled = false): void {\n if (this.buttonDown) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = 0;\n if (cancelled) {\n try {\n this.pointer.cancel(this.nativeEvent);\n } catch {}\n // Pointer.cancel emits the correct event but the upstream pointer\n // keeps its button/capture bookkeeping. Clear it while disabled so no\n // pointerup or click is dispatched for an interrupted gesture.\n const wasEnabled = this.pointer.getEnabled();\n if (wasEnabled) {\n this.pointer.setEnabled(false, this.nativeEvent, true);\n }\n try {\n this.pointer.up(this.buttonEvent);\n } catch {}\n if (wasEnabled) {\n this.pointer.setEnabled(true, this.nativeEvent, false);\n }\n } else {\n try {\n this.pointer.up(this.buttonEvent);\n } catch {}\n }\n this.buttonDown = false;\n }\n this.heldHit = null;\n this.heldByHand = null;\n this.pointerState.handedness = null;\n this.heldFollowsHand = false;\n this.wasSelecting = false;\n }\n\n /** Current dwell winner's root Object3D (null if none/suppressed). */\n getCurrentTarget(): Object3D | null {\n return this.currentHit?.object ?? null;\n }\n\n /** Which hand initiated the active gaze-pinch select. */\n getHeldByHand(): GazeHand | null {\n return this.heldByHand;\n }\n\n /** True while a gaze-pinch select is held. */\n isSelecting(): boolean {\n return this.wasSelecting;\n }\n\n /** World-space gaze origin (post-filter). */\n getOrigin(): Vector3 {\n return this.filteredOrigin;\n }\n\n /** World-space gaze direction (post-filter, unit length). */\n getDirection(): Vector3 {\n return this.direction;\n }\n\n /**\n * Whether a valid gaze pose is available this frame.\n */\n getGazeOrigin(): GazeOrigin {\n return this.xrOrigin.gazeOrigin;\n }\n\n /**\n * Reset filter, provider, selector and diagnostic state. Call when gaze\n * becomes invalid (session ended, eye tracking lost) so we don't carry stale\n * samples, and so the next session re-reports its gaze verdict.\n */\n reset(): void {\n this.diagnostics.reset();\n this.provider.reset();\n this.filter.reset();\n this.currentHit = null;\n this.hasAcquiredTrackedGaze = false;\n this.gazeSource = null;\n this.gazeSourcePresent = false;\n this.lastTrackedPoseTime = Number.NEGATIVE_INFINITY;\n this.reticle.visible = false;\n this.releaseAndDisable();\n }\n\n dispose(): void {\n this.releaseAndDisable();\n this.reticle.geometry.dispose();\n this.reticle.material.dispose();\n this.reticle.removeFromParent();\n this.gazeRaySpace.removeFromParent();\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAwGH;;;;;;;;AAQG;AACH,SAAS,cAAc,CAAC,OAAkB,EAAA;AAIxC,IAAA,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE;AACzC,QAAA,IAAI,MAAM,CAAC,aAAa,KAAK,MAAM,EAAE;AACnC,YAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE;QAC9C;IACF;AACA,IAAA,IAAI,OAAO,CAAC,cAAc,EAAE;AAC1B,QAAA,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,cAAc,EAAE;AAC3C,YAAA,IAAI,MAAM,CAAC,aAAa,KAAK,MAAM,EAAE;AACnC,gBAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE;YAC7C;QACF;IACF;IACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE;AACzD;AAEA;;;AAGG;AACH,MAAM,YAAY,GAAG;;AAEnB,IAAA,YAAY,EAAE,GAAG;;AAEjB,IAAA,iBAAiB,EAAE,IAAI;;AAEvB,IAAA,mBAAmB,EAAE,GAAG;;AAExB,IAAA,eAAe,EAAE,IAAI;;AAErB,IAAA,kBAAkB,EAAE,GAAG;;AAEvB,IAAA,UAAU,EAAE,CAAC;AACb,IAAA,SAAS,EAAE,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I,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC/B,QAAA,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE;AAC/B,QAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE;AAC/B,QAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,EAAE;IACtC;AACD;;;;"}
|
|
1
|
+
{"version":3,"file":"gaze-pointer.js","sources":["../../src/pointer/gaze-pointer.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\nimport {\n Pointer,\n createRayPointer,\n type Intersection,\n} from '@pmndrs/pointer-events';\nimport {\n CircleGeometry,\n Color,\n Matrix3,\n Matrix4,\n Mesh,\n MeshBasicMaterial,\n Object3D,\n PerspectiveCamera,\n Quaternion,\n Scene,\n Vector3,\n} from 'three';\nimport type { GazeOrigin, XROrigin } from '../rig/xr-origin.js';\nimport {\n FilteredEyeGaze,\n FilteredEyeGazeOptions,\n} from './filtered-eye-gaze.js';\nimport type {\n GazeCandidateContext,\n GazeCandidateProvider,\n GazeHit,\n} from './gaze-candidate-provider.js';\nimport { GazeConecaster } from './gaze-conecaster.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\nexport type GazeHand = 'left' | 'right';\n\n/** Metadata exposed as `PointerEvent.pointerState` for the gaze ray. */\nexport interface GazePointerState {\n source: 'gaze';\n handedness: GazeHand | null;\n}\n\n/**\n * Per-frame input context passed into {@link GazePointer.update}.\n */\nexport interface GazePointerInput {\n /** Candidate Object3D roots (gaze-eligible interactables). */\n candidates: ReadonlyArray<Object3D>;\n /** Whether each hand's pinch went down this frame. */\n pinchStart: { left: boolean; right: boolean };\n /** Whether each hand's pinch was released this frame. */\n pinchEnd: { left: boolean; right: boolean };\n /** Whether each hand is currently pinching. */\n pinchActive: { left: boolean; right: boolean };\n /** Whether either hand has an active near touch/grab pointer. */\n directPointerActive: { left: boolean; right: boolean };\n}\n\n/**\n * The live WebXR state {@link GazePointer.sampleGazePose} needs to read the\n * gaze target ray itself, rather than trusting another system to have\n * refreshed the rig first.\n */\nexport interface GazeFrameContext {\n /** The frame currently being rendered. */\n frame: XRFrame;\n /**\n * Reference space the pose is resolved against. Must be the same space\n * {@link XROrigin.updateHead} used, since the result is written into\n * {@link XROrigin.eyeSpace}, which lives in that space.\n */\n referenceSpace: XRReferenceSpace;\n /** Session to scan for the gaze input source. */\n session: XRSession;\n}\n\nexport interface GazePointerOptions {\n /** Suppress hover/select while a near touch/grab pointer is active. @default true */\n suppressWhenDirectPointerActive?: boolean;\n /**\n * On select commit, move the effective pointer origin to the pinching\n * hand's ray space so captured drags track the hand, not the eyes.\n * @default true\n */\n pointerTransformFollowsHand?: boolean;\n /** Reticle color while gaze is genuinely tracked. @default 0xffffff */\n reticleColor?: Color | number;\n /** Reticle radius in meters. @default 0.012 */\n reticleRadius?: number;\n /** Show the developer-only gaze hit reticle. @default false */\n showDebugReticle?: boolean;\n /** Keep gaze mode active briefly after tracking becomes invalid. @default 5 */\n trackingLossGraceSeconds?: number;\n /** OneEuro filter parameters applied to the gaze pose. */\n filter?: FilteredEyeGazeOptions;\n /**\n * Emit `[iwsdk][gaze]` console diagnostics explaining why gaze is (or isn't)\n * tracked, and whether the runtime's gaze ray actually separates from the\n * head ray. Eye tracking has several silent failure modes that are otherwise\n * indistinguishable from a missing source.\n * @default true\n */\n diagnostics?: boolean;\n}\n\n/**\n * Locate the eye-tracking input source.\n *\n * The primary scan is the one the standalone WebXR eye-gaze diagnostic page\n * uses verbatim — the gaze source is whichever entry of `session.inputSources`\n * reports `targetRayMode === 'gaze'`. `trackedSources` is checked afterwards\n * because some runtimes surface non-primary sources only there; the\n * diagnostics log says which list produced the hit.\n */\nfunction findGazeSource(session: XRSession): {\n source: XRInputSource | undefined;\n fromTrackedSources: boolean;\n} {\n for (const source of session.inputSources) {\n if (source.targetRayMode === 'gaze') {\n return { source, fromTrackedSources: false };\n }\n }\n if (session.trackedSources) {\n for (const source of session.trackedSources) {\n if (source.targetRayMode === 'gaze') {\n return { source, fromTrackedSources: true };\n }\n }\n }\n return { source: undefined, fromTrackedSources: false };\n}\n\n/**\n * Thresholds lifted from the standalone WebXR eye-gaze diagnostic page, so a\n * verdict logged here means the same thing as a verdict shown there.\n */\nconst GAZE_VERDICT = {\n /** Gaze/head separation that proves the eye ray is genuinely independent. */\n passAngleDeg: 1.5,\n /** Below this, one frame's gaze and head rays count as \"the same ray\". */\n identicalAngleDeg: 0.05,\n /** Below this (millimetres), one frame's gaze and head origins coincide. */\n identicalPositionMm: 0.5,\n /** Ratio of identical frames that indicates a head-pose mapping bug. */\n headLockedRatio: 0.95,\n /** Max separation still counted as head-locked. */\n headLockedAngleDeg: 0.1,\n /** Minimum evidence before any negative verdict is logged. */\n minSeconds: 3,\n minFrames: 90,\n} as const;\n\nconst RAD_TO_DEG = 180 / Math.PI;\nconst diagForward = new Vector3();\nconst diagHeadForward = new Vector3();\n\nconst RETICLE_FORWARD = new Vector3(0, 0, 1);\n\nfunction isIntentionalHeadDirectedPreview(): boolean {\n const preview = (\n globalThis as typeof globalThis & {\n __IWSDK_TARGET_DEVICE_PREVIEW__?: {\n active?: boolean;\n gazeSimulation?: 'head' | false;\n };\n }\n ).__IWSDK_TARGET_DEVICE_PREVIEW__;\n return preview?.active === true && preview.gazeSimulation === 'head';\n}\n\n/**\n * The development emulator (desktop IWER or a native override) supplies gaze\n * that only moves when aimed, so it starts out matching the head and must not\n * be reported as real eye data or as a head-locked runtime.\n */\nfunction isEmulatedGaze(): boolean {\n const profile = (\n globalThis as typeof globalThis & {\n __IWSDK_EMULATION_PROFILE?: { active?: boolean };\n }\n ).__IWSDK_EMULATION_PROFILE;\n return profile?.active === true;\n}\n\n/**\n * One-shot console diagnostics for the gaze pipeline.\n *\n * Eye tracking fails silently in several distinct ways — feature not granted,\n * no gaze input source, source present but posed null, or a runtime that maps\n * the gaze target ray onto the head pose. These can otherwise look like either\n * missing or head-locked gaze, so each gets its own message with the\n * remediation that actually applies. Every message fires at most once per\n * state transition, so this is safe to leave on in a per-frame path.\n */\nclass GazeDiagnostics {\n private sessionStart = -1;\n private loggedFeature = false;\n private loggedMissingSource = false;\n private loggedTrackedSourcesFallback = false;\n private loggedPoseThrow = false;\n private loggedNoTargets = false;\n private loggedVerdict = false;\n private loggedInconclusive = false;\n private sourcePresent = false;\n /** Tri-state so the very first sample always logs its pose validity. */\n private poseValid: boolean | null = null;\n\n // Head-versus-gaze separation stats, accumulated over valid poses only.\n private firstValidPoseAt = -1;\n private comparisonFrames = 0;\n private identicalFrames = 0;\n private maxAngleDeg = 0;\n private maxPositionMm = 0;\n\n reset(): void {\n this.sessionStart = -1;\n this.loggedFeature = false;\n this.loggedMissingSource = false;\n this.loggedTrackedSourcesFallback = false;\n this.loggedPoseThrow = false;\n this.loggedNoTargets = false;\n this.loggedVerdict = false;\n this.loggedInconclusive = false;\n this.sourcePresent = false;\n this.poseValid = null;\n this.firstValidPoseAt = -1;\n this.comparisonFrames = 0;\n this.identicalFrames = 0;\n this.maxAngleDeg = 0;\n this.maxPositionMm = 0;\n }\n\n /**\n * @param time Monotonic seconds, matching {@link GazePointer.update}.\n * @param xrOrigin Rig whose `eyeSpace`/`head` hold this frame's poses.\n */\n frame(\n time: number,\n xrOrigin: XROrigin,\n session: XRSession,\n gazeSource: XRInputSource | undefined,\n fromTrackedSources: boolean,\n posed: boolean,\n ): void {\n if (this.sessionStart < 0) {\n this.sessionStart = time;\n }\n this.logFeature(session);\n this.logSource(time, gazeSource, fromTrackedSources);\n this.logPose(gazeSource, posed);\n if (posed) {\n this.compareWithHead(time, xrOrigin);\n }\n }\n\n /** Nothing is gaze-eligible, so gaze can never hit anything. */\n targets(count: number): void {\n if (count > 0) {\n this.loggedNoTargets = false;\n return;\n }\n if (this.loggedNoTargets) {\n return;\n }\n this.loggedNoTargets = true;\n console.info(\n '[iwsdk][gaze] no ray-interactable targets are available, so the gaze ' +\n 'cone has nothing to hit.',\n );\n }\n\n poseThrew(error: unknown): void {\n if (this.loggedPoseThrow) {\n return;\n }\n this.loggedPoseThrow = true;\n console.warn(\n '[iwsdk][gaze] frame.getPose(gazeSource.targetRaySpace) threw; tracked ' +\n 'gaze is unavailable for this frame.',\n error,\n );\n }\n\n /** Report whether the runtime actually granted `gaze-tracking`. */\n private logFeature(session: XRSession): void {\n if (this.loggedFeature) {\n return;\n }\n this.loggedFeature = true;\n // `enabledFeatures` is not in every UA's lib.dom typing yet.\n const enabled = (session as XRSession & { enabledFeatures?: string[] })\n .enabledFeatures;\n if (!enabled) {\n console.info(\n \"[iwsdk][gaze] this browser doesn't expose session.enabledFeatures, \" +\n \"so whether 'gaze-tracking' was granted can't be confirmed here. \" +\n 'Watch for the gaze XRInputSource message below instead.',\n );\n return;\n }\n const enabledFeatures = Array.from(enabled);\n if (\n enabledFeatures.includes('gaze-tracking') ||\n enabledFeatures.includes('eye-tracking')\n ) {\n console.info(\"[iwsdk][gaze] 'gaze-tracking' granted for this session.\", {\n enabledFeatures,\n });\n return;\n }\n console.warn(\n \"[iwsdk][gaze] 'gaze-tracking' was NOT granted for this session, so \" +\n 'tracked gaze is unavailable. Check that the project requests ' +\n 'xr.features.gazeTracking, that this browser build exposes eye ' +\n \"tracking, and that the page's permissions policy allows \" +\n 'xr-spatial-tracking.',\n { enabledFeatures },\n );\n }\n\n private logSource(\n time: number,\n gazeSource: XRInputSource | undefined,\n fromTrackedSources: boolean,\n ): void {\n const present = !!gazeSource;\n\n if (present && fromTrackedSources && !this.loggedTrackedSourcesFallback) {\n this.loggedTrackedSourcesFallback = true;\n console.info(\n '[iwsdk][gaze] gaze source found in session.trackedSources rather ' +\n 'than session.inputSources.',\n );\n }\n\n if (present !== this.sourcePresent) {\n this.sourcePresent = present;\n this.poseValid = null;\n if (present) {\n // A later disconnect is \"showed up then left\", never \"never appeared\".\n this.loggedMissingSource = true;\n console.info('[iwsdk][gaze] gaze XRInputSource appeared.', {\n profiles: Array.from(gazeSource!.profiles),\n handedness: gazeSource!.handedness,\n });\n } else {\n console.warn(\n '[iwsdk][gaze] the gaze XRInputSource disappeared; ' +\n 'ordinary hand/controller far targeting is now active.',\n );\n }\n return;\n }\n\n // Never showed up at all — distinct failure from \"showed up then left\".\n if (\n !present &&\n !this.loggedMissingSource &&\n time - this.sessionStart >= GAZE_VERDICT.minSeconds\n ) {\n this.loggedMissingSource = true;\n console.warn(\n '[iwsdk][gaze] no XRInputSource with targetRayMode === \"gaze\" ' +\n `appeared within ${GAZE_VERDICT.minSeconds}s of session start. ` +\n 'Ordinary hand/controller far targeting remains active. Common causes: the ' +\n 'feature was not granted, eye tracking is disabled in system ' +\n 'settings, the headset has not been calibrated for this user, or ' +\n 'the hardware has no eye tracking.',\n );\n }\n }\n\n private logPose(gazeSource: XRInputSource | undefined, posed: boolean): void {\n if (!gazeSource || posed === this.poseValid) {\n return;\n }\n this.poseValid = posed;\n if (posed) {\n console.info(\n isEmulatedGaze()\n ? '[iwsdk][gaze] emulated gaze pose is valid (synthetic, not eye tracking).'\n : '[iwsdk][gaze] eye pose is valid — real gaze data is flowing.',\n );\n } else {\n console.warn(\n '[iwsdk][gaze] the gaze input source is present but ' +\n 'frame.getPose(targetRaySpace) returned null, so tracked gaze is ' +\n 'temporarily unavailable. Common causes: OS eye-tracking permission ' +\n 'not granted, headset not calibrated, or hardware without eye tracking.',\n );\n }\n }\n\n /**\n * Compare the tracked gaze ray against the head ray. A runtime can hand back\n * a perfectly valid gaze pose that is just a copy of the viewer pose; that\n * is indistinguishable from the fallback unless the two are measured.\n */\n private compareWithHead(time: number, xrOrigin: XROrigin): void {\n if (this.loggedVerdict) {\n return;\n }\n const eye = xrOrigin.eyeSpace;\n const head = xrOrigin.head;\n diagForward.set(0, 0, -1).applyQuaternion(eye.quaternion);\n diagHeadForward.set(0, 0, -1).applyQuaternion(head.quaternion);\n const dot = Math.min(1, Math.max(-1, diagForward.dot(diagHeadForward)));\n const angleDeg = Math.acos(dot) * RAD_TO_DEG;\n const positionMm = eye.position.distanceTo(head.position) * 1000;\n\n if (this.firstValidPoseAt < 0) {\n this.firstValidPoseAt = time;\n }\n this.comparisonFrames++;\n this.maxAngleDeg = Math.max(this.maxAngleDeg, angleDeg);\n this.maxPositionMm = Math.max(this.maxPositionMm, positionMm);\n if (\n angleDeg < GAZE_VERDICT.identicalAngleDeg &&\n positionMm < GAZE_VERDICT.identicalPositionMm\n ) {\n this.identicalFrames++;\n }\n\n if (this.maxAngleDeg >= GAZE_VERDICT.passAngleDeg) {\n this.loggedVerdict = true;\n console.info(\n '[iwsdk][gaze] real eye movement observed — the gaze ray separates ' +\n `from the head ray by up to ${this.maxAngleDeg.toFixed(2)}°.`,\n );\n return;\n }\n\n if (\n time - this.firstValidPoseAt < GAZE_VERDICT.minSeconds ||\n this.comparisonFrames < GAZE_VERDICT.minFrames\n ) {\n return;\n }\n\n const identicalRatio = this.identicalFrames / this.comparisonFrames;\n if (\n identicalRatio >= GAZE_VERDICT.headLockedRatio &&\n this.maxAngleDeg < GAZE_VERDICT.headLockedAngleDeg &&\n this.maxPositionMm < GAZE_VERDICT.identicalPositionMm\n ) {\n this.loggedVerdict = true;\n if (isIntentionalHeadDirectedPreview()) {\n console.info(\n '[iwsdk][gaze] target-device preview is intentionally ' +\n 'providing head-directed synthetic gaze.',\n );\n return;\n }\n if (isEmulatedGaze()) {\n console.info(\n '[iwsdk][gaze] emulated gaze still points where the head does; ' +\n 'aim it (for example with xr look-at on \"gaze\") to test targeting.',\n );\n return;\n }\n console.warn(\n '[iwsdk][gaze] the gaze target-ray pose matched the head pose on ' +\n `${(identicalRatio * 100).toFixed(0)}% of ${this.comparisonFrames} ` +\n `frames (max separation ${this.maxAngleDeg.toFixed(3)}°). Eye ` +\n 'tracking is reporting poses, but the runtime is mapping ' +\n 'XRTargetRaySpace onto the head pose, so gaze behaves as ' +\n 'head-pointing. This is a runtime/build issue, not an app one.',\n );\n return;\n }\n\n if (!this.loggedInconclusive) {\n this.loggedInconclusive = true;\n console.info(\n `[iwsdk][gaze] inconclusive: only ${this.maxAngleDeg.toFixed(2)}° of ` +\n `gaze/head separation over ${this.comparisonFrames} frames. Hold ` +\n 'your head still and look far left and right to confirm real gaze.',\n );\n }\n }\n}\n\n/**\n * Singleton gaze pointer. Peer of {@link MultiPointer} in\n * {@link XRInputManager}.\n *\n * @remarks\n * - One global instance — gaze has no handedness.\n * - Samples the WebXR gaze target ray itself via\n * {@link GazePointer.sampleGazePose}, publishing the result to\n * {@link XROrigin.eyeSpace}. The hand/controller ray owns far targeting when\n * a gaze source is unavailable. {@link GazePointerOptions.diagnostics}\n * explains the silent failure modes.\n * - Candidate selection is delegated to a {@link GazeCandidateProvider};\n * the default {@link GazeConecaster} does OBB cone membership and\n * time-weighted dwell consensus while this pointer resolves surfaces with\n * the same pmndrs ray intersector used for event delivery.\n * - Selector composes either hand's pinch; once selecting, the other hand\n * is ignored until release (per-hand mutual exclusion, matching Meta\n * Interaction SDK's `HandGazeInteractor` semantics).\n * - Drives a real `@pmndrs/pointer-events` pointer so UIKit panels click\n * naturally on gaze-pinch.\n * - Keeps its optional debug reticle hidden by default. Production feedback\n * belongs on the hovered target, matching Meta Interaction SDK.\n *\n * @category Pointer\n */\nexport class GazePointer {\n public readonly reticle: Mesh<CircleGeometry, MeshBasicMaterial>;\n\n public provider: GazeCandidateProvider;\n public suppressWhenDirectPointerActive: boolean;\n public pointerTransformFollowsHand: boolean;\n public showDebugReticle: boolean;\n\n private _trackingLossGraceSeconds = 5;\n\n public get trackingLossGraceSeconds(): number {\n return this._trackingLossGraceSeconds;\n }\n\n public set trackingLossGraceSeconds(value: number) {\n this._trackingLossGraceSeconds = Number.isFinite(value)\n ? Math.max(0, value)\n : 0;\n }\n\n /** See {@link GazePointerOptions.diagnostics}. */\n public diagnosticsEnabled: boolean;\n\n /**\n * OneEuro smoother applied to the raw gaze pose. Public so hosts can retune\n * `minCutoff`/`beta` from config without rebuilding the pointer.\n */\n public readonly filter: FilteredEyeGaze;\n\n /**\n * Real `@pmndrs/pointer-events` Pointer driven by the filtered gaze ray.\n * Each frame: pose-update + `pointer.move(scene)` raycasts from the gaze\n * origin so UIKit and any other pointer-events listeners see enter/leave/\n * move events from the gaze just like they do from the hand ray. On pinch\n * we forward `down`/`up` with `button: 0` so `click` fires naturally.\n */\n public readonly pointer: Pointer;\n public readonly pointerState: GazePointerState = {\n source: 'gaze',\n handedness: null,\n };\n\n private readonly filteredOrigin = new Vector3();\n private readonly filteredQuaternion = new Quaternion();\n private readonly rawOrigin = new Vector3();\n private readonly rawQuaternion = new Quaternion();\n private readonly direction = new Vector3();\n private readonly aimDirection = new Vector3();\n private readonly reticleOffset = new Vector3();\n private readonly rayTarget = new Vector3();\n private readonly rayUp = new Vector3();\n private readonly handOrigin = new Vector3();\n private readonly handQuaternion = new Quaternion();\n private readonly worldRayQuaternion = new Quaternion();\n private readonly handRelativeRayQuaternion = new Quaternion();\n private readonly tmpQuat = new Quaternion();\n private readonly lookMatrix = new Matrix4();\n private readonly normalMatrix = new Matrix3();\n\n /** Reticle tint while gaze is genuinely tracked. */\n private readonly reticleTrackedColor: Color;\n\n /**\n * Synthetic `Object3D` whose world transform mirrors the *filtered* gaze\n * pose. Lives under `xrOrigin` so it inherits rig motion; the @pmndrs ray\n * intersector reads its position/quaternion to cast from.\n */\n private readonly gazeRaySpace: Object3D;\n\n private readonly conecasterCtx: GazeCandidateContext = {\n origin: this.filteredOrigin,\n direction: this.direction,\n candidates: [] as ReadonlyArray<Object3D>,\n intersectCandidate: (candidate, direction) =>\n this.intersectCandidate(candidate, direction),\n };\n\n private readonly nativeEvent = { timeStamp: 0 };\n private readonly buttonEvent = { timeStamp: 0, button: 0 };\n\n private currentHit: GazeHit | null = null;\n private heldHit: GazeHit | null = null;\n private heldByHand: GazeHand | null = null;\n private wasSelecting = false;\n private buttonDown = false;\n private heldFollowsHand = false;\n private hasAcquiredTrackedGaze = false;\n private gazeSource: XRInputSource | null = null;\n private gazeSourcePresent = false;\n private lastTrackedPoseTime = Number.NEGATIVE_INFINITY;\n\n private readonly diagnostics = new GazeDiagnostics();\n\n constructor(\n private readonly xrOrigin: XROrigin,\n private readonly scene: Scene,\n camera: PerspectiveCamera,\n options: GazePointerOptions = {},\n ) {\n this.provider = new GazeConecaster();\n this.suppressWhenDirectPointerActive =\n options.suppressWhenDirectPointerActive ?? true;\n this.pointerTransformFollowsHand =\n options.pointerTransformFollowsHand ?? true;\n this.showDebugReticle = options.showDebugReticle ?? false;\n this.trackingLossGraceSeconds = options.trackingLossGraceSeconds ?? 5;\n this.diagnosticsEnabled = options.diagnostics ?? true;\n this.filter = new FilteredEyeGaze(options.filter);\n\n this.reticleTrackedColor =\n options.reticleColor instanceof Color\n ? options.reticleColor.clone()\n : new Color(options.reticleColor ?? 0xffffff);\n const radius = options.reticleRadius ?? 0.012;\n this.reticle = new Mesh(\n new CircleGeometry(radius, 32),\n new MeshBasicMaterial({\n color: this.reticleTrackedColor.clone(),\n transparent: true,\n opacity: 0.85,\n depthWrite: false,\n depthTest: false,\n }),\n );\n this.reticle.renderOrder = Infinity;\n this.reticle.visible = false;\n this.reticle.name = 'gaze-reticle';\n\n // Synthetic ray source for the @pmndrs Pointer. We can't use eyeSpace\n // directly because we want the *filtered* pose, not the raw per-frame\n // gaze. Manual matrix updates: we drive position/quaternion explicitly\n // each frame from the filter output.\n this.gazeRaySpace = new Object3D();\n this.gazeRaySpace.name = 'gaze-ray-space';\n this.gazeRaySpace.matrixAutoUpdate = false;\n\n this.pointer = createRayPointer(\n () => camera,\n { current: this.gazeRaySpace },\n this.pointerState,\n // contextMenu lives on button 2; gaze never produces it. Disable to\n // avoid spurious contextmenu events.\n {\n contextMenuButton: -1,\n filter: isObjectTreeVisible,\n },\n );\n // BVH-accelerated firstHitOnly raycast (matches hand RayPointer).\n const raycaster = (\n this.pointer.intersector as unknown as {\n raycaster?: { firstHitOnly?: boolean };\n }\n ).raycaster;\n if (raycaster) {\n raycaster.firstHitOnly = true;\n }\n }\n\n /**\n * Add or remove the pointer's rig nodes (debug reticle and ray space).\n *\n * The pointer is constructed eagerly by {@link XRInputManager} so systems can\n * hold a stable reference, but an app that never uses gaze shouldn't pay for\n * gaze geometry in every rig matrix walk — so nothing is parented until gaze\n * is actually switched on.\n */\n setAttached(attached: boolean): void {\n if (attached) {\n this.xrOrigin.add(this.reticle, this.gazeRaySpace);\n } else {\n this.reticle.removeFromParent();\n this.gazeRaySpace.removeFromParent();\n }\n }\n\n /**\n * Read the gaze target ray off the live frame and write it into\n * {@link XROrigin.eyeSpace}.\n *\n * This mirrors the standalone WebXR eye-gaze diagnostic page's probe: find\n * the input source whose `targetRayMode` is `'gaze'`, then pose its\n * `targetRaySpace` against the frame's reference space, tolerating a throw.\n * The source can exist while `getPose` returns null (uncalibrated headset,\n * withheld permission), so source presence and pose validity are tracked\n * separately. A missing or invalid pose clears the current gaze pose so stale\n * tracking can never be used for targeting.\n *\n * Call once per frame before {@link GazePointer.update}.\n */\n sampleGazePose(time: number, context: GazeFrameContext): void {\n const { frame, referenceSpace, session } = context;\n const { source, fromTrackedSources } = findGazeSource(session);\n const nextGazeSource = source ?? null;\n if (nextGazeSource !== this.gazeSource) {\n // Grace belongs to one uninterrupted source lifetime. A source that is\n // removed or replaced must earn ownership again with a valid pose.\n this.hasAcquiredTrackedGaze = false;\n this.lastTrackedPoseTime = Number.NEGATIVE_INFINITY;\n this.gazeSource = nextGazeSource;\n }\n this.gazeSourcePresent = source != null;\n this.xrOrigin.clearGaze();\n let pose: XRPose | null = null;\n if (source) {\n try {\n pose = frame.getPose(source.targetRaySpace, referenceSpace) ?? null;\n } catch (error) {\n if (this.diagnosticsEnabled) {\n this.diagnostics.poseThrew(error);\n }\n }\n }\n\n if (pose) {\n this.xrOrigin.applyTrackedEyePose(pose.transform);\n this.hasAcquiredTrackedGaze = true;\n this.lastTrackedPoseTime = time;\n }\n\n if (this.diagnosticsEnabled) {\n this.diagnostics.frame(\n time,\n this.xrOrigin,\n session,\n source,\n fromTrackedSources,\n !!pose,\n );\n }\n }\n\n /**\n * Whether gaze mode should own far targeting this frame.\n *\n * This mirrors ISDK's mode/source distinction: a valid pose activates gaze;\n * then a short grace period keeps the mode active when a frame's pose is\n * invalid (for example, a blink), while targeting itself clears. WebXR does\n * not expose a separate pose-validity signal, so source enumeration defines\n * the lifetime of that grace period. Removing the source hands far targeting\n * back to hands/controllers immediately; the grace period applies only to\n * temporary pose invalidity (for example, a blink).\n */\n ownsFarTargeting(time: number): boolean {\n if (!this.gazeSourcePresent) {\n return false;\n }\n if (this.xrOrigin.gazeOrigin === 'tracked') {\n return true;\n }\n return (\n this.hasAcquiredTrackedGaze &&\n time - this.lastTrackedPoseTime <= this.trackingLossGraceSeconds\n );\n }\n\n /** Whether this frame has a pose that is safe to use for fresh targeting. */\n canTarget(): boolean {\n return this.xrOrigin.gazeOrigin === 'tracked';\n }\n\n /**\n * Swap the candidate provider at runtime (e.g. a multi-cone or dwell-only\n * provider). The previous provider is reset and detached.\n */\n setCandidateProvider(provider: GazeCandidateProvider): void {\n this.provider.reset();\n this.provider = provider;\n }\n\n update(\n targetingAvailable: boolean,\n dt: number,\n time: number,\n input: GazePointerInput,\n ): void {\n this.nativeEvent.timeStamp = time * 1000;\n\n // Source removal is a mode transition, not transient tracking loss. End a\n // gaze-started gesture before hand/controller far targeting resumes.\n if (!this.gazeSourcePresent && !targetingAvailable && this.heldByHand) {\n this.releaseSelect(true);\n }\n\n if (!targetingAvailable && !this.heldByHand) {\n this.provider.reset();\n this.filter.reset();\n this.currentHit = null;\n this.reticle.visible = false;\n this.releaseAndDisable();\n return;\n }\n\n let releasedSelect = false;\n if (this.heldByHand) {\n const hand = this.heldByHand;\n const pinchEnded = input.pinchEnd[hand];\n const targetAvailable = this.isHeldTargetAvailable(input.candidates);\n if (pinchEnded || !input.pinchActive[hand] || !targetAvailable) {\n // A real pinch-end is an up/click. Tracking loss, reset, removal, or\n // semantic invisibility interrupts the gesture and must cancel it.\n this.releaseSelect(!pinchEnded || !targetAvailable);\n releasedSelect = true;\n } else {\n this.driveHeldPointer();\n this.updateReticle();\n return;\n }\n }\n\n // A transient invalid eye pose clears hover immediately, matching ISDK,\n // but does not interrupt a selection that was already handed off to the\n // pinching hand. Once that gesture ends there is no stale pose from which\n // to start a new selection.\n if (!targetingAvailable) {\n this.provider.reset();\n this.filter.reset();\n this.currentHit = null;\n this.reticle.visible = false;\n this.releaseAndDisable();\n return;\n }\n\n if (this.diagnosticsEnabled) {\n this.diagnostics.targets(input.candidates.length);\n }\n\n // World-space pose of the (raw) gaze, then smoothed in-place. This runs\n // only with a current targeting pose, so a transient invalid frame cannot\n // contaminate the eye filter with the previous valid gaze pose.\n this.xrOrigin.eyeSpace.getWorldPosition(this.rawOrigin);\n this.xrOrigin.eyeSpace.getWorldQuaternion(this.rawQuaternion);\n this.filter.filter(\n this.rawOrigin,\n this.rawQuaternion,\n Math.max(dt, 1 / 240),\n this.filteredOrigin,\n this.filteredQuaternion,\n );\n this.direction.set(0, 0, -1).applyQuaternion(this.filteredQuaternion);\n\n const externallySuppressed =\n this.suppressWhenDirectPointerActive &&\n (input.directPointerActive.left || input.directPointerActive.right);\n\n if (externallySuppressed) {\n this.currentHit = null;\n this.reticle.visible = false;\n this.commitNoTarget();\n } else {\n this.conecasterCtx.candidates = input.candidates;\n this.currentHit = this.provider.update(time, dt, this.conecasterCtx);\n if (this.currentHit) {\n this.commitHit(this.currentHit);\n } else {\n this.commitNoTarget();\n }\n }\n\n if (!releasedSelect) {\n this.processSelector(input);\n }\n this.updateReticle();\n }\n\n /** Resolve one candidate through the same intersector used for dispatch. */\n private intersectCandidate(\n candidate: Object3D,\n direction: Vector3,\n ): Intersection | null {\n this.setRayFromDirection(\n this.filteredOrigin,\n direction,\n this.filteredQuaternion,\n );\n const intersection = this.computeScopedIntersection([candidate]);\n return intersection.object.isVoidObject ? null : intersection;\n }\n\n /** Install the provider's authoritative intersection and emit one move. */\n private commitHit(hit: GazeHit): void {\n this.ensurePointerEnabled();\n this.setRayWorldPose(\n hit.intersection.pointerPosition,\n hit.intersection.pointerQuaternion,\n );\n this.pointer.setIntersection(hit.intersection);\n this.pointer.commit(this.nativeEvent, true);\n }\n\n /** Commit a void hit so the previous target receives out/leave events. */\n private commitNoTarget(): void {\n this.currentHit = null;\n this.ensurePointerEnabled();\n this.setRayFromDirection(\n this.filteredOrigin,\n this.direction,\n this.filteredQuaternion,\n );\n const intersection = this.computeScopedIntersection([]);\n this.pointer.setIntersection(intersection);\n this.pointer.commit(this.nativeEvent, true);\n }\n\n private computeScopedIntersection(descendants: Object3D[]): Intersection {\n const scene = this.scene as Scene & {\n interactableDescendants?: Object3D[];\n };\n const previous = scene.interactableDescendants;\n scene.interactableDescendants = descendants;\n try {\n return this.pointer.computeIntersection(\n 'pointer',\n this.scene,\n this.nativeEvent,\n );\n } finally {\n scene.interactableDescendants = previous;\n }\n }\n\n private ensurePointerEnabled(): void {\n if (!this.pointer.getEnabled()) {\n this.pointer.setEnabled(true, this.nativeEvent, false);\n }\n }\n\n /** Pose the synthetic ray in world space while it remains parented to the rig. */\n private setRayWorldPose(origin: Vector3, quaternion: Quaternion): void {\n this.xrOrigin.updateWorldMatrix(true, false);\n this.gazeRaySpace.position.copy(origin);\n this.xrOrigin.worldToLocal(this.gazeRaySpace.position);\n this.xrOrigin.getWorldQuaternion(this.tmpQuat).invert();\n this.gazeRaySpace.quaternion.copy(this.tmpQuat).multiply(quaternion);\n this.gazeRaySpace.updateMatrix();\n this.gazeRaySpace.updateMatrixWorld(true);\n }\n\n /** Build a ray pose whose -Z axis follows `direction`. */\n private setRayFromDirection(\n origin: Vector3,\n direction: Vector3,\n upQuaternion: Quaternion,\n ): void {\n this.rayTarget.copy(origin).add(direction);\n this.rayUp.set(0, 1, 0).applyQuaternion(upQuaternion);\n this.lookMatrix.lookAt(origin, this.rayTarget, this.rayUp);\n this.worldRayQuaternion.setFromRotationMatrix(this.lookMatrix);\n this.setRayWorldPose(origin, this.worldRayQuaternion);\n }\n\n /** Release event state before disabling or detaching the pointer. */\n private releaseAndDisable(): void {\n this.releaseSelect(true);\n if (!this.pointer.getEnabled()) {\n return;\n }\n this.pointer.exit(this.nativeEvent);\n this.pointer.setEnabled(false, this.nativeEvent, false);\n }\n\n private updateReticle(): void {\n if (!this.showDebugReticle) {\n this.reticle.visible = false;\n return;\n }\n const intersection = this.pointer.getIntersection();\n if (!intersection || intersection.object.isVoidObject) {\n this.reticle.visible = false;\n return;\n }\n if (\n this.reticle.material.color.getHex() !== this.reticleTrackedColor.getHex()\n ) {\n this.reticle.material.color.copy(this.reticleTrackedColor);\n }\n this.reticleOffset.copy(intersection.point);\n this.xrOrigin.worldToLocal(this.reticleOffset);\n this.reticle.position.copy(this.reticleOffset);\n\n const normal = intersection.normal ?? intersection.face?.normal;\n if (normal) {\n this.normalMatrix.getNormalMatrix(intersection.object.matrixWorld);\n this.rayUp.copy(normal).applyNormalMatrix(this.normalMatrix).normalize();\n this.reticle.quaternion.setFromUnitVectors(RETICLE_FORWARD, this.rayUp);\n this.xrOrigin.getWorldQuaternion(this.tmpQuat).invert();\n this.reticle.quaternion.premultiply(this.tmpQuat);\n }\n // Scale reticle gently with distance for legibility.\n const s = Math.max(0.6, Math.min(2, intersection.distance));\n this.reticle.scale.setScalar(s);\n this.reticle.visible = true;\n }\n\n private processSelector(input: GazePointerInput): void {\n const hand: GazeHand | null = input.pinchStart.left\n ? 'left'\n : input.pinchStart.right\n ? 'right'\n : null;\n if (!hand || !this.currentHit) {\n return;\n }\n\n const gazeHit = this.currentHit;\n this.heldByHand = hand;\n this.pointerState.handedness = hand;\n this.heldFollowsHand = false;\n\n let selectIntersection = gazeHit.intersection;\n if (this.pointerTransformFollowsHand) {\n const handSpace = this.xrOrigin.raySpaces[hand];\n handSpace.updateWorldMatrix(true, false);\n handSpace.getWorldPosition(this.handOrigin);\n handSpace.getWorldQuaternion(this.handQuaternion);\n this.aimDirection.copy(gazeHit.intersection.point).sub(this.handOrigin);\n if (this.aimDirection.lengthSq() > 1e-12) {\n this.aimDirection.normalize();\n this.setRayFromDirection(\n this.handOrigin,\n this.aimDirection,\n this.handQuaternion,\n );\n const handIntersection = this.computeScopedIntersection([\n gazeHit.object,\n ]);\n if (\n !handIntersection.object.isVoidObject &&\n handIntersection.object === gazeHit.intersection.object\n ) {\n selectIntersection = handIntersection;\n this.handRelativeRayQuaternion\n .copy(this.handQuaternion)\n .invert()\n .multiply(handIntersection.pointerQuaternion);\n this.heldFollowsHand = true;\n } else {\n this.setRayWorldPose(\n gazeHit.intersection.pointerPosition,\n gazeHit.intersection.pointerQuaternion,\n );\n }\n }\n }\n\n this.heldHit = {\n object: gazeHit.object,\n intersection: selectIntersection,\n angularDistance: gazeHit.angularDistance,\n };\n this.wasSelecting = true;\n this.pointer.setIntersection(selectIntersection);\n // The hover path already emitted this frame's move. This commit only needs\n // to install the hand-origin intersection before a synchronous capture in\n // `down()`; enter/leave bookkeeping still runs if the leaf changed.\n this.pointer.commit(this.nativeEvent, false);\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = 0;\n this.buttonDown = true;\n try {\n this.pointer.down(this.buttonEvent);\n } catch {\n this.releaseSelect(true);\n }\n }\n\n private driveHeldPointer(): void {\n if (!this.heldHit || !this.heldByHand) {\n return;\n }\n\n if (this.pointer.getPointerCapture()) {\n if (this.heldFollowsHand) {\n const handSpace = this.xrOrigin.raySpaces[this.heldByHand];\n handSpace.updateWorldMatrix(true, false);\n handSpace.getWorldPosition(this.handOrigin);\n handSpace.getWorldQuaternion(this.handQuaternion);\n this.worldRayQuaternion\n .copy(this.handQuaternion)\n .multiply(this.handRelativeRayQuaternion);\n this.setRayWorldPose(this.handOrigin, this.worldRayQuaternion);\n } else {\n this.setRayWorldPose(\n this.heldHit.intersection.pointerPosition,\n this.heldHit.intersection.pointerQuaternion,\n );\n }\n this.pointer.move(this.scene, this.nativeEvent);\n return;\n }\n\n // Plain clickable targets generally do not capture. Keep their select-time\n // intersection stable so small hand motion during the pinch cannot turn a\n // valid down into an up on the void object.\n this.setRayWorldPose(\n this.heldHit.intersection.pointerPosition,\n this.heldHit.intersection.pointerQuaternion,\n );\n this.pointer.setIntersection(this.heldHit.intersection);\n this.pointer.commit(this.nativeEvent, true);\n }\n\n private isHeldTargetAvailable(candidates: ReadonlyArray<Object3D>): boolean {\n const object = this.heldHit?.object;\n return (\n !!object && isObjectTreeVisible(object) && candidates.includes(object)\n );\n }\n\n private releaseSelect(cancelled = false): void {\n if (this.buttonDown) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = 0;\n if (cancelled) {\n try {\n this.pointer.cancel(this.nativeEvent);\n } catch {}\n // Pointer.cancel emits the correct event but the upstream pointer\n // keeps its button/capture bookkeeping. Clear it while disabled so no\n // pointerup or click is dispatched for an interrupted gesture.\n const wasEnabled = this.pointer.getEnabled();\n if (wasEnabled) {\n this.pointer.setEnabled(false, this.nativeEvent, true);\n }\n try {\n this.pointer.up(this.buttonEvent);\n } catch {}\n if (wasEnabled) {\n this.pointer.setEnabled(true, this.nativeEvent, false);\n }\n } else {\n try {\n this.pointer.up(this.buttonEvent);\n } catch {}\n }\n this.buttonDown = false;\n }\n this.heldHit = null;\n this.heldByHand = null;\n this.pointerState.handedness = null;\n this.heldFollowsHand = false;\n this.wasSelecting = false;\n }\n\n /** Current dwell winner's root Object3D (null if none/suppressed). */\n getCurrentTarget(): Object3D | null {\n return this.currentHit?.object ?? null;\n }\n\n /** Which hand initiated the active gaze-pinch select. */\n getHeldByHand(): GazeHand | null {\n return this.heldByHand;\n }\n\n /** True while a gaze-pinch select is held. */\n isSelecting(): boolean {\n return this.wasSelecting;\n }\n\n /** World-space gaze origin (post-filter). */\n getOrigin(): Vector3 {\n return this.filteredOrigin;\n }\n\n /** World-space gaze direction (post-filter, unit length). */\n getDirection(): Vector3 {\n return this.direction;\n }\n\n /**\n * Whether a valid gaze pose is available this frame.\n */\n getGazeOrigin(): GazeOrigin {\n return this.xrOrigin.gazeOrigin;\n }\n\n /**\n * Reset filter, provider, selector and diagnostic state. Call when gaze\n * becomes invalid (session ended, eye tracking lost) so we don't carry stale\n * samples, and so the next session re-reports its gaze verdict.\n */\n reset(): void {\n this.diagnostics.reset();\n this.provider.reset();\n this.filter.reset();\n this.currentHit = null;\n this.hasAcquiredTrackedGaze = false;\n this.gazeSource = null;\n this.gazeSourcePresent = false;\n this.lastTrackedPoseTime = Number.NEGATIVE_INFINITY;\n this.reticle.visible = false;\n this.releaseAndDisable();\n }\n\n dispose(): void {\n this.releaseAndDisable();\n this.reticle.geometry.dispose();\n this.reticle.material.dispose();\n this.reticle.removeFromParent();\n this.gazeRaySpace.removeFromParent();\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAwGH;;;;;;;;AAQG;AACH,SAAS,cAAc,CAAC,OAAkB,EAAA;AAIxC,IAAA,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,YAAY,EAAE;AACzC,QAAA,IAAI,MAAM,CAAC,aAAa,KAAK,MAAM,EAAE;AACnC,YAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,KAAK,EAAE;QAC9C;IACF;AACA,IAAA,IAAI,OAAO,CAAC,cAAc,EAAE;AAC1B,QAAA,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,cAAc,EAAE;AAC3C,YAAA,IAAI,MAAM,CAAC,aAAa,KAAK,MAAM,EAAE;AACnC,gBAAA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE;YAC7C;QACF;IACF;IACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,KAAK,EAAE;AACzD;AAEA;;;AAGG;AACH,MAAM,YAAY,GAAG;;AAEnB,IAAA,YAAY,EAAE,GAAG;;AAEjB,IAAA,iBAAiB,EAAE,IAAI;;AAEvB,IAAA,mBAAmB,EAAE,GAAG;;AAExB,IAAA,eAAe,EAAE,IAAI;;AAErB,IAAA,kBAAkB,EAAE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