@iwsdk/xr-input 1.1.0 → 1.2.0-rc.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-pointer.d.ts.map +1 -1
- package/dist/pointer/gaze-pointer.js +2 -0
- package/dist/pointer/gaze-pointer.js.map +1 -1
- package/dist/pointer/multi-pointer.d.ts +2 -0
- package/dist/pointer/multi-pointer.d.ts.map +1 -1
- package/dist/pointer/multi-pointer.js +16 -2
- package/dist/pointer/multi-pointer.js.map +1 -1
- package/dist/pointer/ray-pointer.d.ts.map +1 -1
- package/dist/pointer/ray-pointer.js +3 -0
- package/dist/pointer/ray-pointer.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gaze-pointer.d.ts","sourceRoot":"","sources":["../../src/pointer/gaze-pointer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,OAAO,EAGR,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,KAAK,EAGL,IAAI,EACJ,iBAAiB,EACjB,QAAQ,EACR,iBAAiB,EAEjB,KAAK,EACL,OAAO,EACR,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EACL,eAAe,EACf,sBAAsB,EACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAEV,qBAAqB,EAEtB,MAAM,8BAA8B,CAAC;AAItC,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AAExC,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8DAA8D;IAC9D,UAAU,EAAE,aA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;;;OAUG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAavC,6EAA6E;IAC7E,SAAS,IAAI,OAAO;IAIpB;;;OAGG;IACH,oBAAoB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI;IAK3D,MAAM,CACJ,kBAAkB,EAAE,OAAO,EAC3B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,GACtB,IAAI;IA0FP,4EAA4E;IAC5E,OAAO,CAAC,kBAAkB;IAa1B,2EAA2E;IAC3E,OAAO,CAAC,SAAS;IAUjB,0EAA0E;IAC1E,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,yBAAyB;IAiBjC,OAAO,CAAC,oBAAoB;IAM5B,kFAAkF;IAClF,OAAO,CAAC,eAAe;IAUvB,0DAA0D;IAC1D,OAAO,CAAC,mBAAmB;IAY3B,qEAAqE;IACrE,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,eAAe;IAwEvB,OAAO,CAAC,gBAAgB;IAoCxB,OAAO,CAAC,qBAAqB;IAO7B,OAAO,CAAC,aAAa;IAmCrB,sEAAsE;IACtE,gBAAgB,IAAI,QAAQ,GAAG,IAAI;IAInC,yDAAyD;IACzD,aAAa,IAAI,QAAQ,GAAG,IAAI;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"}
|
|
@@ -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 * 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();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EAAE;IAC1B;IAEA,OAAO,GAAA;QACL,IAAI,CAAC,iBAAiB,EAAE;AACxB,QAAA,IAAI,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; camera?: PerspectiveCamera };\n }\n ).raycaster;\n if (raycaster) {\n raycaster.firstHitOnly = true;\n // Sprite.raycast needs the viewing camera (see RayPointer).\n raycaster.camera = camera;\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,YA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Aa,GAAA;AACX,QAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,UAAU;IACjC;AAEA;;;;AAIG;IACH,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;AACxB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE;AACrB,QAAA,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;AACnB,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI;AACtB,QAAA,IAAI,CAAC,sBAAsB,GAAG,KAAK;AACnC,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI;AACtB,QAAA,IAAI,CAAC,iBAAiB,GAAG,KAAK;AAC9B,QAAA,IAAI,CAAC,mBAAmB,GAAG,MAAM,CAAC,iBAAiB;AACnD,QAAA,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK;QAC5B,IAAI,CAAC,iBAAiB,EAAE;IAC1B;IAEA,OAAO,GAAA;QACL,IAAI,CAAC,iBAAiB,EAAE;AACxB,QAAA,IAAI,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;;;;"}
|
|
@@ -124,6 +124,8 @@ export declare class MultiPointer {
|
|
|
124
124
|
/**
|
|
125
125
|
* Get the policy for ray visual rendering
|
|
126
126
|
*/
|
|
127
|
+
/** Objects this hand may poke: its own list when the scene has one. */
|
|
128
|
+
private touchCandidates;
|
|
127
129
|
getPolicyForRay(): {
|
|
128
130
|
forceHideRay: boolean;
|
|
129
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-pointer.d.ts","sourceRoot":"","sources":["../../src/pointer/multi-pointer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,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AAG,QAAQ,EACrC,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,EACjC,WAAW,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE;IAUpC;;OAEG;IACH,OAAO,CAAC,UAAU;IAuBlB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAahB;;;OAGG;IACH,OAAO,IAAI,IAAI;CAWhB"}
|
|
@@ -234,7 +234,7 @@ class MultiPointer {
|
|
|
234
234
|
// Touch pointer
|
|
235
235
|
if (this.pointerStates.get('touch') !== InteractorState.DISABLED) {
|
|
236
236
|
this.sceneWithDescendants.interactableDescendants =
|
|
237
|
-
this.
|
|
237
|
+
this.touchCandidates();
|
|
238
238
|
this.touch.pointer.move(this.scene, this.nativeEvent);
|
|
239
239
|
this.markPointerMoved('touch', this.touch.pointer);
|
|
240
240
|
}
|
|
@@ -258,7 +258,7 @@ class MultiPointer {
|
|
|
258
258
|
break;
|
|
259
259
|
case 'touch':
|
|
260
260
|
this.sceneWithDescendants.interactableDescendants =
|
|
261
|
-
this.
|
|
261
|
+
this.touchCandidates();
|
|
262
262
|
break;
|
|
263
263
|
}
|
|
264
264
|
pointer.move(this.scene, this.nativeEvent);
|
|
@@ -411,6 +411,15 @@ class MultiPointer {
|
|
|
411
411
|
if (state === InteractorState.HOVER) {
|
|
412
412
|
this.pointerStates.set(this.activeKind, InteractorState.NORMAL);
|
|
413
413
|
}
|
|
414
|
+
// The selected object went away (e.g. the app disposed it) and the
|
|
415
|
+
// button was released off any target. Release anyway, as the touch
|
|
416
|
+
// lifecycle does, or the selection lock never ends.
|
|
417
|
+
if (state === InteractorState.SELECT && buttonUp) {
|
|
418
|
+
this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;
|
|
419
|
+
this.buttonEvent.button = button;
|
|
420
|
+
entry.pointer.up(this.buttonEvent);
|
|
421
|
+
this.pointerStates.set(this.activeKind, InteractorState.NORMAL);
|
|
422
|
+
}
|
|
414
423
|
return;
|
|
415
424
|
}
|
|
416
425
|
// HOVER → SELECT on button down
|
|
@@ -435,6 +444,11 @@ class MultiPointer {
|
|
|
435
444
|
/**
|
|
436
445
|
* Get the policy for ray visual rendering
|
|
437
446
|
*/
|
|
447
|
+
/** Objects this hand may poke: its own list when the scene has one. */
|
|
448
|
+
touchCandidates() {
|
|
449
|
+
var _a, _b;
|
|
450
|
+
return ((_b = (_a = this.sceneWithDescendants.touchDescendantsByHand) === null || _a === void 0 ? void 0 : _a[this.handedness]) !== null && _b !== void 0 ? _b : this.sceneWithDescendants.touchDescendants);
|
|
451
|
+
}
|
|
438
452
|
getPolicyForRay() {
|
|
439
453
|
return { forceHideRay: this.shouldHideRay() };
|
|
440
454
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multi-pointer.js","sources":["../../src/pointer/multi-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 { Pointer } from '@pmndrs/pointer-events';\nimport { Vector3, type Object3D, type PerspectiveCamera } from 'three';\nimport type { XROrigin } from '../rig/xr-origin.js';\nimport { CursorVisual } from './cursor-visual.js';\nimport { GrabPointer } from './grab-pointer.js';\nimport { RayPointer } from './ray-pointer.js';\nimport { TouchPointer } from './touch-pointer.js';\n\nexport type PointerKind = 'ray' | 'grab' | 'touch';\n\nexport interface MultiPointerInput {\n selectStart?: boolean;\n selectEnd?: boolean;\n squeezeStart?: boolean;\n squeezeEnd?: boolean;\n /**\n * Temporarily disable the far ray without changing its registration.\n * Gaze mode uses this to make the hand/controller ray a fallback while\n * leaving near touch and grab interaction available.\n */\n suppressRay?: boolean;\n}\n\n/**\n * Interactor state machine states\n */\nexport enum InteractorState {\n /** Pointer not registered or not enabled */\n DISABLED = 'disabled',\n /** Pointer enabled, no candidate */\n NORMAL = 'normal',\n /** Pointer has candidate, hovering over object */\n HOVER = 'hover',\n /** Pointer actively selecting object */\n SELECT = 'select',\n}\n\n/**\n * Priority order for pointer types (lower index = higher priority)\n */\nconst PRIORITY_ORDER: PointerKind[] = ['touch', 'grab', 'ray'];\n\n/**\n * Hysteresis thresholds for touch pointer (in meters)\n */\nconst TOUCH_HYSTERESIS = {\n enterHoverDistance: 0.15, // 15cm - distance to start hover\n exitHoverDistance: 0.2, // 20cm - distance to end hover\n};\n\nconst TOUCH_VISUAL_OFFSET_EPSILON_SQ = 0.000001;\n\ntype PointerEntry<T> = {\n pointer: Pointer;\n visual: T;\n registered: boolean;\n};\n\n/**\n * MultiPointer orchestrates multiple pointer types using priority-based selection.\n *\n * @remarks\n * - Priority order: Touch > Grab > Ray\n * - Uses state machine: DISABLED ↔ NORMAL ↔ HOVER ↔ SELECT\n * - Selection lock: Once a pointer starts selecting, it stays locked until release\n * - Hysteresis: Touch pointer uses separate enter/exit thresholds to prevent flickering\n *\n * @category Pointer\n */\nexport class MultiPointer {\n private ray: PointerEntry<RayPointer>;\n private grab: PointerEntry<GrabPointer>;\n private touch: PointerEntry<TouchPointer>;\n private cursorVisual: CursorVisual;\n\n /** Current active pointer kind (winner of priority selection) */\n private activeKind: PointerKind | null = null;\n\n /** State for each pointer type */\n private pointerStates: Map<PointerKind, InteractorState> = new Map();\n\n /** Hysteresis tracking: whether touch is currently in hover state */\n private touchHoverActive = false;\n\n /** Cached scene reference with type-specific descendants */\n private sceneWithDescendants: {\n interactableDescendants?: Object3D[];\n rayDescendants?: Object3D[];\n touchDescendants?: Object3D[];\n grabDescendants?: Object3D[];\n };\n\n /** Reusable native event object to avoid per-frame allocations */\n private readonly nativeEvent = { timeStamp: 0 };\n\n /** Reusable policy object for ray rendering */\n private readonly rayPolicy = { forceHideRay: false };\n\n /**\n * Pointers that completed the upstream library's first ready move. Mirrors\n * its private `wasMoved` latch; neither latch is reset because MultiPointer\n * never calls `Pointer.exit()` on these long-lived instances.\n */\n private readonly movedPointers = new Set<PointerKind>();\n\n /** Reusable event object for pointer down/up with button */\n private readonly buttonEvent = { timeStamp: 0, button: 0 };\n\n constructor(\n private readonly handedness: 'left' | 'right',\n private readonly scene: Object3D,\n private readonly camera: PerspectiveCamera,\n private readonly xrOrigin: XROrigin,\n ) {\n // Create all pointer instances\n const rayVisual = new RayPointer(\n this.camera,\n this.xrOrigin,\n this.handedness,\n );\n const grabVisual = new GrabPointer(\n this.camera,\n this.xrOrigin,\n this.handedness,\n );\n const touchVisual = new TouchPointer(\n this.camera,\n this.xrOrigin,\n this.handedness,\n );\n\n this.ray = {\n pointer: rayVisual.pointer,\n visual: rayVisual,\n registered: false,\n };\n this.grab = {\n pointer: grabVisual.pointer,\n visual: grabVisual,\n registered: false,\n };\n this.touch = {\n pointer: touchVisual.pointer,\n visual: touchVisual,\n registered: false,\n };\n\n // Cache scene reference for descendant swapping (avoids repeated casts)\n this.sceneWithDescendants = this.scene as typeof this.sceneWithDescendants;\n\n // Create shared cursor visual\n this.cursorVisual = new CursorVisual(\n xrOrigin,\n handedness === 'left' ? 0 : 1,\n );\n\n // Initialize states\n PRIORITY_ORDER.forEach((kind) => {\n this.pointerStates.set(kind, InteractorState.DISABLED);\n });\n\n // Enable ray and touch by default\n this.toggleSubPointer('ray', true);\n this.toggleSubPointer('touch', true);\n }\n\n /**\n * Main update loop - implements priority-based pointer selection\n */\n update(\n connected: boolean,\n delta: number,\n time: number,\n input?: MultiPointerInput,\n ) {\n // Reuse nativeEvent object to avoid allocation\n this.nativeEvent.timeStamp = time * 1000;\n\n // Phase 1: Update enabled state for all registered pointers\n const rayConnected = connected && !input?.suppressRay;\n this.updatePointerEnabled(connected, rayConnected);\n\n // Phase 2: Check selection lock - if active pointer is selecting, stay locked\n const activePointer = this.getActivePointer();\n const activeState = activePointer\n ? this.pointerStates.get(this.activeKind!)\n : null;\n const isSelecting = activeState === InteractorState.SELECT;\n\n if (!isSelecting) {\n // Phase 3: Compute intersections for all enabled pointers\n this.computeAllIntersections();\n\n // Phase 4: Pick winner by priority\n this.pickActiveByPriority();\n } else {\n // Selection locked - only update the active pointer's intersection\n // Still use type-specific descendants for the locked pointer\n if (activePointer && this.activeKind) {\n this.movePointerWithDescendants(this.activeKind, activePointer);\n }\n }\n\n // Phase 5: Process lifecycle (state transitions)\n this.processLifecycle(input);\n\n // Phase 6: Update shared cursor from active pointer\n const anyPointerHasCapture =\n !!this.ray.pointer.getPointerCapture?.() ||\n !!this.grab.pointer.getPointerCapture?.() ||\n !!this.touch.pointer.getPointerCapture?.();\n\n if (this.activeKind && !anyPointerHasCapture) {\n const activeEntry = this.getEntry(this.activeKind);\n const intersection = activeEntry.pointer.getIntersection();\n const focused =\n this.pointerStates.get(this.activeKind) === InteractorState.SELECT;\n const visible = !!intersection && !intersection.object.isVoidObject;\n\n this.cursorVisual.setVisible(visible);\n if (visible && intersection) {\n this.cursorVisual.updateFromIntersection(intersection, delta, focused);\n }\n } else {\n this.cursorVisual.setVisible(false);\n }\n\n // Phase 7: Update visuals - reuse rayPolicy object\n this.rayPolicy.forceHideRay = this.shouldHideRay();\n this.ray.visual.update(\n rayConnected && this.ray.registered,\n delta,\n time,\n !!input?.selectStart,\n !!input?.selectEnd,\n this.rayPolicy,\n );\n this.grab.visual.update(\n connected && this.grab.registered,\n delta,\n time,\n !!input?.squeezeStart,\n !!input?.squeezeEnd,\n );\n this.touch.visual.update(\n connected && this.touch.registered,\n delta,\n time,\n false,\n false,\n );\n }\n\n /**\n * Update enabled state for all registered pointers\n */\n private updatePointerEnabled(connected: boolean, rayConnected: boolean) {\n // Process ray pointer\n this.updateSinglePointerEnabled('ray', this.ray, rayConnected);\n // Process grab pointer\n this.updateSinglePointerEnabled('grab', this.grab, connected);\n // Process touch pointer\n this.updateSinglePointerEnabled('touch', this.touch, connected);\n }\n\n /**\n * Update enabled state for a single pointer (avoids array allocation)\n */\n private updateSinglePointerEnabled(\n kind: PointerKind,\n entry: PointerEntry<RayPointer | GrabPointer | TouchPointer>,\n connected: boolean,\n ) {\n const shouldBeEnabled = connected && entry.registered;\n const currentState = this.pointerStates.get(kind)!;\n const isEnabled = currentState !== InteractorState.DISABLED;\n\n if (shouldBeEnabled && !isEnabled) {\n entry.pointer.setEnabled(true, this.nativeEvent, false);\n this.pointerStates.set(kind, InteractorState.NORMAL);\n } else if (!shouldBeEnabled) {\n // Pointer instances start enabled upstream, so also consult the pointer\n // itself. This makes first-frame gaze suppression a real disable rather\n // than merely skipping the ray's intersection pass.\n if (entry.pointer.getEnabled()) {\n const buttonsDown = [...entry.pointer.getButtonsDown()];\n if (buttonsDown.length > 0) {\n // Mode switches terminate an in-flight far selection instead of\n // leaving a stale button/capture that could revive with ray fallback.\n if (!this.movedPointers.has(kind)) {\n // Flush an upstream down queued before the pointer's first move so\n // its matching cancel cannot be stranded in the same queue. In\n // normal updates move() has already run, avoiding callback\n // re-entry on this disable path.\n entry.pointer.commit(this.nativeEvent, false);\n this.movedPointers.add(kind);\n }\n entry.pointer.cancel(this.nativeEvent);\n }\n entry.pointer.setEnabled(false, this.nativeEvent, true);\n for (const button of buttonsDown) {\n entry.pointer.up({ button, timeStamp: this.nativeEvent.timeStamp });\n }\n }\n this.pointerStates.set(kind, InteractorState.DISABLED);\n // Clear active if this was the active pointer\n if (this.activeKind === kind) {\n this.activeKind = null;\n }\n }\n }\n\n /**\n * Compute intersections for all enabled pointers using type-specific descendant arrays.\n * Swaps scene.interactableDescendants per pointer type for optimized traversal.\n */\n private computeAllIntersections() {\n // Store original descendants once\n const originalDescendants =\n this.sceneWithDescendants.interactableDescendants;\n\n // Process each pointer with its type-specific descendants\n // Ray pointer\n if (this.pointerStates.get('ray') !== InteractorState.DISABLED) {\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.rayDescendants;\n this.ray.pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved('ray', this.ray.pointer);\n }\n\n // Grab pointer\n if (this.pointerStates.get('grab') !== InteractorState.DISABLED) {\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.grabDescendants;\n this.grab.pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved('grab', this.grab.pointer);\n }\n\n // Touch pointer\n if (this.pointerStates.get('touch') !== InteractorState.DISABLED) {\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.touchDescendants;\n this.touch.pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved('touch', this.touch.pointer);\n }\n\n // Restore original descendants\n this.sceneWithDescendants.interactableDescendants = originalDescendants;\n }\n\n /**\n * Move a single pointer using its type-specific descendants.\n * Used when selection is locked to avoid unnecessary traversal.\n */\n private movePointerWithDescendants(kind: PointerKind, pointer: Pointer) {\n const originalDescendants =\n this.sceneWithDescendants.interactableDescendants;\n\n switch (kind) {\n case 'ray':\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.rayDescendants;\n break;\n case 'grab':\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.grabDescendants;\n break;\n case 'touch':\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.touchDescendants;\n break;\n }\n\n pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved(kind, pointer);\n this.sceneWithDescendants.interactableDescendants = originalDescendants;\n }\n\n private markPointerMoved(kind: PointerKind, pointer: Pointer): void {\n if (pointer.intersector.isReady()) {\n this.movedPointers.add(kind);\n }\n }\n\n /**\n * Pick active pointer by priority - first with valid candidate wins\n */\n private pickActiveByPriority() {\n let newActiveKind: PointerKind | null = null;\n\n for (const kind of PRIORITY_ORDER) {\n const state = this.pointerStates.get(kind)!;\n if (state === InteractorState.DISABLED) {\n continue;\n }\n\n if (this.hasValidCandidate(kind)) {\n newActiveKind = kind;\n break;\n }\n }\n\n // Switch active pointer if changed\n if (newActiveKind !== this.activeKind) {\n this.switchActivePointer(newActiveKind);\n }\n }\n\n /**\n * Check if a pointer has a valid candidate (intersection)\n */\n private hasValidCandidate(kind: PointerKind): boolean {\n const entry = this.getEntry(kind);\n const intersection = entry.pointer.getIntersection();\n\n // No intersection or void object = no candidate\n if (!intersection || intersection.object.isVoidObject) {\n // For touch, update hysteresis state\n if (kind === 'touch') {\n this.touchHoverActive = false;\n }\n return false;\n }\n\n // For touch pointer, apply hysteresis\n if (kind === 'touch') {\n const threshold = this.touchHoverActive\n ? TOUCH_HYSTERESIS.exitHoverDistance\n : TOUCH_HYSTERESIS.enterHoverDistance;\n\n if (intersection.distance > threshold) {\n // Outside threshold\n if (!this.touchHoverActive) {\n return false;\n }\n // Was hovering but now outside exit threshold\n this.touchHoverActive = false;\n return false;\n }\n\n // Within threshold\n this.touchHoverActive = true;\n return true;\n }\n\n // For ray and grab, any valid intersection is a candidate\n return true;\n }\n\n /**\n * Switch active pointer to a new kind\n */\n private switchActivePointer(newKind: PointerKind | null) {\n // Disable previous active pointer (but keep it enabled in the pointer system)\n if (this.activeKind && this.activeKind !== newKind) {\n const prevState = this.pointerStates.get(this.activeKind)!;\n if (prevState === InteractorState.HOVER) {\n this.pointerStates.set(this.activeKind, InteractorState.NORMAL);\n }\n }\n\n this.activeKind = newKind;\n\n // Update new active pointer state\n if (newKind) {\n const state = this.pointerStates.get(newKind)!;\n if (state === InteractorState.NORMAL) {\n this.pointerStates.set(newKind, InteractorState.HOVER);\n }\n }\n }\n\n /**\n * Process lifecycle transitions based on input\n */\n private processLifecycle(input?: MultiPointerInput) {\n if (!this.activeKind) {\n return;\n }\n\n const entry = this.getEntry(this.activeKind);\n const state = this.pointerStates.get(this.activeKind)!;\n\n switch (this.activeKind) {\n case 'touch':\n // Touch auto-selects based on distance\n this.processTouchLifecycle(entry, state);\n break;\n\n case 'grab':\n // Grab uses squeeze button\n this.processButtonLifecycle(\n entry,\n state,\n !!input?.squeezeStart,\n !!input?.squeezeEnd,\n 2, // button 2 for squeeze\n );\n break;\n\n case 'ray':\n // Ray uses select button\n this.processButtonLifecycle(\n entry,\n state,\n !!input?.selectStart,\n !!input?.selectEnd,\n 0, // button 0 for select\n );\n break;\n }\n }\n\n /**\n * Process touch pointer lifecycle - auto-selects based on distance\n */\n private processTouchLifecycle(\n entry: PointerEntry<TouchPointer>,\n state: InteractorState,\n ) {\n const intersection = entry.pointer.getIntersection();\n if (!intersection || intersection.object.isVoidObject) {\n // Lost candidate - transition to NORMAL\n if (state === InteractorState.SELECT) {\n // Force release if touch was selecting when intersection was lost\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = 0;\n entry.pointer.up(this.buttonEvent);\n }\n if (state === InteractorState.HOVER || state === InteractorState.SELECT) {\n this.pointerStates.set('touch', InteractorState.NORMAL);\n }\n return;\n }\n\n // Touch auto-selection is handled by the pointer's onMoveCommited callback\n // (createTouchPointer sets this up). We just need to track the state.\n\n // Check if pointer is currently selecting (has buttons down)\n const isSelecting = entry.pointer.getButtonsDown().size > 0;\n\n if (state === InteractorState.HOVER && isSelecting) {\n this.pointerStates.set('touch', InteractorState.SELECT);\n } else if (state === InteractorState.SELECT && !isSelecting) {\n this.pointerStates.set('touch', InteractorState.HOVER);\n } else if (state === InteractorState.NORMAL) {\n this.pointerStates.set('touch', InteractorState.HOVER);\n }\n }\n\n /**\n * Process button-based pointer lifecycle (ray/grab)\n */\n private processButtonLifecycle(\n entry: PointerEntry<RayPointer | GrabPointer>,\n state: InteractorState,\n buttonDown: boolean,\n buttonUp: boolean,\n button: number,\n ) {\n const intersection = entry.pointer.getIntersection();\n if (!intersection || intersection.object.isVoidObject) {\n // Lost candidate - can happen during selection (pointer capture handles this)\n if (state === InteractorState.HOVER) {\n this.pointerStates.set(this.activeKind!, InteractorState.NORMAL);\n }\n return;\n }\n\n // HOVER → SELECT on button down\n if (state === InteractorState.HOVER && buttonDown) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = button;\n entry.pointer.down(this.buttonEvent);\n this.pointerStates.set(this.activeKind!, InteractorState.SELECT);\n }\n // SELECT → HOVER on button up\n else if (state === InteractorState.SELECT && buttonUp) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = button;\n entry.pointer.up(this.buttonEvent);\n this.pointerStates.set(this.activeKind!, InteractorState.HOVER);\n }\n // NORMAL → HOVER when we have a candidate\n else if (state === InteractorState.NORMAL) {\n this.pointerStates.set(this.activeKind!, InteractorState.HOVER);\n }\n }\n\n /**\n * Get the policy for ray visual rendering\n */\n getPolicyForRay() {\n return { forceHideRay: this.shouldHideRay() };\n }\n\n private shouldHideRay(): boolean {\n // Hide the visual whenever the ray is disabled or a near pointer owns the\n // hand, including gaze-mode suppression.\n return (\n this.pointerStates.get('ray') === InteractorState.DISABLED ||\n (this.activeKind !== 'ray' && this.activeKind !== null)\n );\n }\n\n /**\n * Check if ray is busy (has intersection)\n */\n getRayBusy(): boolean {\n return !!this.ray.visual.busy;\n }\n\n /**\n * Toggle a sub-pointer on/off\n */\n toggleSubPointer(kind: PointerKind, enabled: boolean): boolean {\n const entry = this.getEntry(kind);\n if (entry.registered === enabled) {\n return false;\n }\n entry.registered = enabled;\n if (!enabled) {\n this.pointerStates.set(kind, InteractorState.DISABLED);\n if (this.activeKind === kind) {\n this.activeKind = null;\n }\n if (kind === 'touch') {\n this.touchHoverActive = false;\n }\n }\n return true;\n }\n\n /**\n * Get the registration state of a sub-pointer\n */\n getSubPointerState(kind: PointerKind): { registered: boolean } {\n const entry = this.getEntry(kind);\n return { registered: entry.registered };\n }\n\n /**\n * Get the currently active pointer kind\n */\n getActiveKind(): PointerKind | null {\n return this.activeKind;\n }\n\n /**\n * Computes a world-space offset that keeps the hand visual's fingertip on the\n * touched surface while the touch pointer is actively selecting.\n */\n getTouchSurfaceVisualOffset(target: Vector3 = new Vector3()): Vector3 | null {\n if (this.activeKind !== 'touch') {\n return null;\n }\n\n if (this.pointerStates.get('touch') !== InteractorState.SELECT) {\n return null;\n }\n\n const intersection = this.touch.pointer.getIntersection();\n if (\n !intersection ||\n intersection.object.isVoidObject ||\n intersection.details.type !== 'sphere'\n ) {\n return null;\n }\n\n target.copy(intersection.pointOnFace).sub(intersection.pointerPosition);\n if (target.lengthSq() < TOUCH_VISUAL_OFFSET_EPSILON_SQ) {\n return null;\n }\n\n return target;\n }\n\n /**\n * Get the currently active pointer\n */\n getActivePointer(): Pointer | null {\n if (!this.activeKind) {\n return null;\n }\n return this.getEntry(this.activeKind).pointer;\n }\n\n /**\n * Get a specific pointer by kind\n */\n getPointer(kind: PointerKind): Pointer {\n return this.getEntry(kind).pointer;\n }\n\n /**\n * Route a down event to a specific pointer target.\n * Used by grab-system for hand pinch gestures.\n */\n routeDown(\n kind: 'select' | 'squeeze' | 'custom',\n target: 'ray' | 'grab' | 'active',\n nativeEvent: { timeStamp: number },\n ) {\n const ptr = this.pickTarget(target);\n if (!ptr) {\n return;\n }\n const button = kind === 'select' ? 0 : 2;\n ptr.down({ button, timeStamp: nativeEvent.timeStamp });\n }\n\n /**\n * Route an up event to a specific pointer target.\n * Used by grab-system for hand pinch gestures.\n */\n routeUp(\n kind: 'select' | 'squeeze' | 'custom',\n target: 'ray' | 'grab' | 'active',\n nativeEvent: { timeStamp: number },\n ) {\n const ptr = this.pickTarget(target);\n if (!ptr) {\n return;\n }\n const button = kind === 'select' ? 0 : 2;\n ptr.up({ button, timeStamp: nativeEvent.timeStamp });\n }\n\n /**\n * Pick pointer by target type.\n */\n private pickTarget(target: 'ray' | 'grab' | 'active'): Pointer | undefined {\n if (target === 'active') {\n // Prefer captured pointer if any, else fall back to active or ray\n if (this.ray.pointer.getPointerCapture?.()) {\n return this.ray.pointer;\n }\n if (this.grab.pointer.getPointerCapture?.()) {\n return this.grab.pointer;\n }\n if (this.touch.pointer.getPointerCapture?.()) {\n return this.touch.pointer;\n }\n // Fall back to active pointer or ray\n return this.activeKind\n ? this.getEntry(this.activeKind).pointer\n : this.ray.pointer;\n }\n if (target === 'ray') {\n return this.ray.pointer;\n }\n return this.grab.pointer;\n }\n\n /**\n * Get the entry for a pointer kind\n */\n private getEntry(\n kind: PointerKind,\n ): PointerEntry<RayPointer | GrabPointer | TouchPointer> {\n switch (kind) {\n case 'ray':\n return this.ray;\n case 'grab':\n return this.grab;\n case 'touch':\n return this.touch;\n }\n }\n\n /**\n * Dispose of all pointer resources.\n * Call this when the MultiPointer is no longer needed.\n */\n dispose(): void {\n // Dispose cursor visual\n this.cursorVisual.dispose();\n\n // Dispose ray pointer (has geometry/material)\n this.ray.visual.dispose();\n\n // Clear state\n this.pointerStates.clear();\n this.activeKind = null;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAyBH;;AAEG;IACS;AAAZ,CAAA,UAAY,eAAe,EAAA;;AAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;;AAErB,IAAA,eAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,OAAe;;AAEf,IAAA,eAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EATW,eAAe,KAAf,eAAe,GAAA,EAAA,CAAA,CAAA;AAW3B;;AAEG;AACH,MAAM,cAAc,GAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC;AAE9D;;AAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,GAAG;CACvB;AAED,MAAM,8BAA8B,GAAG,QAAQ;AAQ/C;;;;;;;;;;AAUG;MACU,YAAY,CAAA;AAuCvB,IAAA,WAAA,CACmB,UAA4B,EAC5B,KAAe,EACf,MAAyB,EACzB,QAAkB,EAAA;QAHlB,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,KAAK,GAAL,KAAK;QACL,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,QAAQ,GAAR,QAAQ;;QApCnB,IAAA,CAAA,UAAU,GAAuB,IAAI;;AAGrC,QAAA,IAAA,CAAA,aAAa,GAAsC,IAAI,GAAG,EAAE;;QAG5D,IAAA,CAAA,gBAAgB,GAAG,KAAK;;AAWf,QAAA,IAAA,CAAA,WAAW,GAAG,EAAE,SAAS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
|
1
|
+
{"version":3,"file":"multi-pointer.js","sources":["../../src/pointer/multi-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 { Pointer } from '@pmndrs/pointer-events';\nimport { Vector3, type Object3D, type PerspectiveCamera } from 'three';\nimport type { XROrigin } from '../rig/xr-origin.js';\nimport { CursorVisual } from './cursor-visual.js';\nimport { GrabPointer } from './grab-pointer.js';\nimport { RayPointer } from './ray-pointer.js';\nimport { TouchPointer } from './touch-pointer.js';\n\nexport type PointerKind = 'ray' | 'grab' | 'touch';\n\nexport interface MultiPointerInput {\n selectStart?: boolean;\n selectEnd?: boolean;\n squeezeStart?: boolean;\n squeezeEnd?: boolean;\n /**\n * Temporarily disable the far ray without changing its registration.\n * Gaze mode uses this to make the hand/controller ray a fallback while\n * leaving near touch and grab interaction available.\n */\n suppressRay?: boolean;\n}\n\n/**\n * Interactor state machine states\n */\nexport enum InteractorState {\n /** Pointer not registered or not enabled */\n DISABLED = 'disabled',\n /** Pointer enabled, no candidate */\n NORMAL = 'normal',\n /** Pointer has candidate, hovering over object */\n HOVER = 'hover',\n /** Pointer actively selecting object */\n SELECT = 'select',\n}\n\n/**\n * Priority order for pointer types (lower index = higher priority)\n */\nconst PRIORITY_ORDER: PointerKind[] = ['touch', 'grab', 'ray'];\n\n/**\n * Hysteresis thresholds for touch pointer (in meters)\n */\nconst TOUCH_HYSTERESIS = {\n enterHoverDistance: 0.15, // 15cm - distance to start hover\n exitHoverDistance: 0.2, // 20cm - distance to end hover\n};\n\nconst TOUCH_VISUAL_OFFSET_EPSILON_SQ = 0.000001;\n\ntype PointerEntry<T> = {\n pointer: Pointer;\n visual: T;\n registered: boolean;\n};\n\n/**\n * MultiPointer orchestrates multiple pointer types using priority-based selection.\n *\n * @remarks\n * - Priority order: Touch > Grab > Ray\n * - Uses state machine: DISABLED ↔ NORMAL ↔ HOVER ↔ SELECT\n * - Selection lock: Once a pointer starts selecting, it stays locked until release\n * - Hysteresis: Touch pointer uses separate enter/exit thresholds to prevent flickering\n *\n * @category Pointer\n */\nexport class MultiPointer {\n private ray: PointerEntry<RayPointer>;\n private grab: PointerEntry<GrabPointer>;\n private touch: PointerEntry<TouchPointer>;\n private cursorVisual: CursorVisual;\n\n /** Current active pointer kind (winner of priority selection) */\n private activeKind: PointerKind | null = null;\n\n /** State for each pointer type */\n private pointerStates: Map<PointerKind, InteractorState> = new Map();\n\n /** Hysteresis tracking: whether touch is currently in hover state */\n private touchHoverActive = false;\n\n /** Cached scene reference with type-specific descendants */\n private sceneWithDescendants: {\n interactableDescendants?: Object3D[];\n rayDescendants?: Object3D[];\n touchDescendants?: Object3D[];\n /** Touch descendants per hand; preferred over touchDescendants when set. */\n touchDescendantsByHand?: { left: Object3D[]; right: Object3D[] };\n grabDescendants?: Object3D[];\n };\n\n /** Reusable native event object to avoid per-frame allocations */\n private readonly nativeEvent = { timeStamp: 0 };\n\n /** Reusable policy object for ray rendering */\n private readonly rayPolicy = { forceHideRay: false };\n\n /**\n * Pointers that completed the upstream library's first ready move. Mirrors\n * its private `wasMoved` latch; neither latch is reset because MultiPointer\n * never calls `Pointer.exit()` on these long-lived instances.\n */\n private readonly movedPointers = new Set<PointerKind>();\n\n /** Reusable event object for pointer down/up with button */\n private readonly buttonEvent = { timeStamp: 0, button: 0 };\n\n constructor(\n private readonly handedness: 'left' | 'right',\n private readonly scene: Object3D,\n private readonly camera: PerspectiveCamera,\n private readonly xrOrigin: XROrigin,\n ) {\n // Create all pointer instances\n const rayVisual = new RayPointer(\n this.camera,\n this.xrOrigin,\n this.handedness,\n );\n const grabVisual = new GrabPointer(\n this.camera,\n this.xrOrigin,\n this.handedness,\n );\n const touchVisual = new TouchPointer(\n this.camera,\n this.xrOrigin,\n this.handedness,\n );\n\n this.ray = {\n pointer: rayVisual.pointer,\n visual: rayVisual,\n registered: false,\n };\n this.grab = {\n pointer: grabVisual.pointer,\n visual: grabVisual,\n registered: false,\n };\n this.touch = {\n pointer: touchVisual.pointer,\n visual: touchVisual,\n registered: false,\n };\n\n // Cache scene reference for descendant swapping (avoids repeated casts)\n this.sceneWithDescendants = this.scene as typeof this.sceneWithDescendants;\n\n // Create shared cursor visual\n this.cursorVisual = new CursorVisual(\n xrOrigin,\n handedness === 'left' ? 0 : 1,\n );\n\n // Initialize states\n PRIORITY_ORDER.forEach((kind) => {\n this.pointerStates.set(kind, InteractorState.DISABLED);\n });\n\n // Enable ray and touch by default\n this.toggleSubPointer('ray', true);\n this.toggleSubPointer('touch', true);\n }\n\n /**\n * Main update loop - implements priority-based pointer selection\n */\n update(\n connected: boolean,\n delta: number,\n time: number,\n input?: MultiPointerInput,\n ) {\n // Reuse nativeEvent object to avoid allocation\n this.nativeEvent.timeStamp = time * 1000;\n\n // Phase 1: Update enabled state for all registered pointers\n const rayConnected = connected && !input?.suppressRay;\n this.updatePointerEnabled(connected, rayConnected);\n\n // Phase 2: Check selection lock - if active pointer is selecting, stay locked\n const activePointer = this.getActivePointer();\n const activeState = activePointer\n ? this.pointerStates.get(this.activeKind!)\n : null;\n const isSelecting = activeState === InteractorState.SELECT;\n\n if (!isSelecting) {\n // Phase 3: Compute intersections for all enabled pointers\n this.computeAllIntersections();\n\n // Phase 4: Pick winner by priority\n this.pickActiveByPriority();\n } else {\n // Selection locked - only update the active pointer's intersection\n // Still use type-specific descendants for the locked pointer\n if (activePointer && this.activeKind) {\n this.movePointerWithDescendants(this.activeKind, activePointer);\n }\n }\n\n // Phase 5: Process lifecycle (state transitions)\n this.processLifecycle(input);\n\n // Phase 6: Update shared cursor from active pointer\n const anyPointerHasCapture =\n !!this.ray.pointer.getPointerCapture?.() ||\n !!this.grab.pointer.getPointerCapture?.() ||\n !!this.touch.pointer.getPointerCapture?.();\n\n if (this.activeKind && !anyPointerHasCapture) {\n const activeEntry = this.getEntry(this.activeKind);\n const intersection = activeEntry.pointer.getIntersection();\n const focused =\n this.pointerStates.get(this.activeKind) === InteractorState.SELECT;\n const visible = !!intersection && !intersection.object.isVoidObject;\n\n this.cursorVisual.setVisible(visible);\n if (visible && intersection) {\n this.cursorVisual.updateFromIntersection(intersection, delta, focused);\n }\n } else {\n this.cursorVisual.setVisible(false);\n }\n\n // Phase 7: Update visuals - reuse rayPolicy object\n this.rayPolicy.forceHideRay = this.shouldHideRay();\n this.ray.visual.update(\n rayConnected && this.ray.registered,\n delta,\n time,\n !!input?.selectStart,\n !!input?.selectEnd,\n this.rayPolicy,\n );\n this.grab.visual.update(\n connected && this.grab.registered,\n delta,\n time,\n !!input?.squeezeStart,\n !!input?.squeezeEnd,\n );\n this.touch.visual.update(\n connected && this.touch.registered,\n delta,\n time,\n false,\n false,\n );\n }\n\n /**\n * Update enabled state for all registered pointers\n */\n private updatePointerEnabled(connected: boolean, rayConnected: boolean) {\n // Process ray pointer\n this.updateSinglePointerEnabled('ray', this.ray, rayConnected);\n // Process grab pointer\n this.updateSinglePointerEnabled('grab', this.grab, connected);\n // Process touch pointer\n this.updateSinglePointerEnabled('touch', this.touch, connected);\n }\n\n /**\n * Update enabled state for a single pointer (avoids array allocation)\n */\n private updateSinglePointerEnabled(\n kind: PointerKind,\n entry: PointerEntry<RayPointer | GrabPointer | TouchPointer>,\n connected: boolean,\n ) {\n const shouldBeEnabled = connected && entry.registered;\n const currentState = this.pointerStates.get(kind)!;\n const isEnabled = currentState !== InteractorState.DISABLED;\n\n if (shouldBeEnabled && !isEnabled) {\n entry.pointer.setEnabled(true, this.nativeEvent, false);\n this.pointerStates.set(kind, InteractorState.NORMAL);\n } else if (!shouldBeEnabled) {\n // Pointer instances start enabled upstream, so also consult the pointer\n // itself. This makes first-frame gaze suppression a real disable rather\n // than merely skipping the ray's intersection pass.\n if (entry.pointer.getEnabled()) {\n const buttonsDown = [...entry.pointer.getButtonsDown()];\n if (buttonsDown.length > 0) {\n // Mode switches terminate an in-flight far selection instead of\n // leaving a stale button/capture that could revive with ray fallback.\n if (!this.movedPointers.has(kind)) {\n // Flush an upstream down queued before the pointer's first move so\n // its matching cancel cannot be stranded in the same queue. In\n // normal updates move() has already run, avoiding callback\n // re-entry on this disable path.\n entry.pointer.commit(this.nativeEvent, false);\n this.movedPointers.add(kind);\n }\n entry.pointer.cancel(this.nativeEvent);\n }\n entry.pointer.setEnabled(false, this.nativeEvent, true);\n for (const button of buttonsDown) {\n entry.pointer.up({ button, timeStamp: this.nativeEvent.timeStamp });\n }\n }\n this.pointerStates.set(kind, InteractorState.DISABLED);\n // Clear active if this was the active pointer\n if (this.activeKind === kind) {\n this.activeKind = null;\n }\n }\n }\n\n /**\n * Compute intersections for all enabled pointers using type-specific descendant arrays.\n * Swaps scene.interactableDescendants per pointer type for optimized traversal.\n */\n private computeAllIntersections() {\n // Store original descendants once\n const originalDescendants =\n this.sceneWithDescendants.interactableDescendants;\n\n // Process each pointer with its type-specific descendants\n // Ray pointer\n if (this.pointerStates.get('ray') !== InteractorState.DISABLED) {\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.rayDescendants;\n this.ray.pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved('ray', this.ray.pointer);\n }\n\n // Grab pointer\n if (this.pointerStates.get('grab') !== InteractorState.DISABLED) {\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.grabDescendants;\n this.grab.pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved('grab', this.grab.pointer);\n }\n\n // Touch pointer\n if (this.pointerStates.get('touch') !== InteractorState.DISABLED) {\n this.sceneWithDescendants.interactableDescendants =\n this.touchCandidates();\n this.touch.pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved('touch', this.touch.pointer);\n }\n\n // Restore original descendants\n this.sceneWithDescendants.interactableDescendants = originalDescendants;\n }\n\n /**\n * Move a single pointer using its type-specific descendants.\n * Used when selection is locked to avoid unnecessary traversal.\n */\n private movePointerWithDescendants(kind: PointerKind, pointer: Pointer) {\n const originalDescendants =\n this.sceneWithDescendants.interactableDescendants;\n\n switch (kind) {\n case 'ray':\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.rayDescendants;\n break;\n case 'grab':\n this.sceneWithDescendants.interactableDescendants =\n this.sceneWithDescendants.grabDescendants;\n break;\n case 'touch':\n this.sceneWithDescendants.interactableDescendants =\n this.touchCandidates();\n break;\n }\n\n pointer.move(this.scene, this.nativeEvent);\n this.markPointerMoved(kind, pointer);\n this.sceneWithDescendants.interactableDescendants = originalDescendants;\n }\n\n private markPointerMoved(kind: PointerKind, pointer: Pointer): void {\n if (pointer.intersector.isReady()) {\n this.movedPointers.add(kind);\n }\n }\n\n /**\n * Pick active pointer by priority - first with valid candidate wins\n */\n private pickActiveByPriority() {\n let newActiveKind: PointerKind | null = null;\n\n for (const kind of PRIORITY_ORDER) {\n const state = this.pointerStates.get(kind)!;\n if (state === InteractorState.DISABLED) {\n continue;\n }\n\n if (this.hasValidCandidate(kind)) {\n newActiveKind = kind;\n break;\n }\n }\n\n // Switch active pointer if changed\n if (newActiveKind !== this.activeKind) {\n this.switchActivePointer(newActiveKind);\n }\n }\n\n /**\n * Check if a pointer has a valid candidate (intersection)\n */\n private hasValidCandidate(kind: PointerKind): boolean {\n const entry = this.getEntry(kind);\n const intersection = entry.pointer.getIntersection();\n\n // No intersection or void object = no candidate\n if (!intersection || intersection.object.isVoidObject) {\n // For touch, update hysteresis state\n if (kind === 'touch') {\n this.touchHoverActive = false;\n }\n return false;\n }\n\n // For touch pointer, apply hysteresis\n if (kind === 'touch') {\n const threshold = this.touchHoverActive\n ? TOUCH_HYSTERESIS.exitHoverDistance\n : TOUCH_HYSTERESIS.enterHoverDistance;\n\n if (intersection.distance > threshold) {\n // Outside threshold\n if (!this.touchHoverActive) {\n return false;\n }\n // Was hovering but now outside exit threshold\n this.touchHoverActive = false;\n return false;\n }\n\n // Within threshold\n this.touchHoverActive = true;\n return true;\n }\n\n // For ray and grab, any valid intersection is a candidate\n return true;\n }\n\n /**\n * Switch active pointer to a new kind\n */\n private switchActivePointer(newKind: PointerKind | null) {\n // Disable previous active pointer (but keep it enabled in the pointer system)\n if (this.activeKind && this.activeKind !== newKind) {\n const prevState = this.pointerStates.get(this.activeKind)!;\n if (prevState === InteractorState.HOVER) {\n this.pointerStates.set(this.activeKind, InteractorState.NORMAL);\n }\n }\n\n this.activeKind = newKind;\n\n // Update new active pointer state\n if (newKind) {\n const state = this.pointerStates.get(newKind)!;\n if (state === InteractorState.NORMAL) {\n this.pointerStates.set(newKind, InteractorState.HOVER);\n }\n }\n }\n\n /**\n * Process lifecycle transitions based on input\n */\n private processLifecycle(input?: MultiPointerInput) {\n if (!this.activeKind) {\n return;\n }\n\n const entry = this.getEntry(this.activeKind);\n const state = this.pointerStates.get(this.activeKind)!;\n\n switch (this.activeKind) {\n case 'touch':\n // Touch auto-selects based on distance\n this.processTouchLifecycle(entry, state);\n break;\n\n case 'grab':\n // Grab uses squeeze button\n this.processButtonLifecycle(\n entry,\n state,\n !!input?.squeezeStart,\n !!input?.squeezeEnd,\n 2, // button 2 for squeeze\n );\n break;\n\n case 'ray':\n // Ray uses select button\n this.processButtonLifecycle(\n entry,\n state,\n !!input?.selectStart,\n !!input?.selectEnd,\n 0, // button 0 for select\n );\n break;\n }\n }\n\n /**\n * Process touch pointer lifecycle - auto-selects based on distance\n */\n private processTouchLifecycle(\n entry: PointerEntry<TouchPointer>,\n state: InteractorState,\n ) {\n const intersection = entry.pointer.getIntersection();\n if (!intersection || intersection.object.isVoidObject) {\n // Lost candidate - transition to NORMAL\n if (state === InteractorState.SELECT) {\n // Force release if touch was selecting when intersection was lost\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = 0;\n entry.pointer.up(this.buttonEvent);\n }\n if (state === InteractorState.HOVER || state === InteractorState.SELECT) {\n this.pointerStates.set('touch', InteractorState.NORMAL);\n }\n return;\n }\n\n // Touch auto-selection is handled by the pointer's onMoveCommited callback\n // (createTouchPointer sets this up). We just need to track the state.\n\n // Check if pointer is currently selecting (has buttons down)\n const isSelecting = entry.pointer.getButtonsDown().size > 0;\n\n if (state === InteractorState.HOVER && isSelecting) {\n this.pointerStates.set('touch', InteractorState.SELECT);\n } else if (state === InteractorState.SELECT && !isSelecting) {\n this.pointerStates.set('touch', InteractorState.HOVER);\n } else if (state === InteractorState.NORMAL) {\n this.pointerStates.set('touch', InteractorState.HOVER);\n }\n }\n\n /**\n * Process button-based pointer lifecycle (ray/grab)\n */\n private processButtonLifecycle(\n entry: PointerEntry<RayPointer | GrabPointer>,\n state: InteractorState,\n buttonDown: boolean,\n buttonUp: boolean,\n button: number,\n ) {\n const intersection = entry.pointer.getIntersection();\n if (!intersection || intersection.object.isVoidObject) {\n // Lost candidate - can happen during selection (pointer capture handles this)\n if (state === InteractorState.HOVER) {\n this.pointerStates.set(this.activeKind!, InteractorState.NORMAL);\n }\n // The selected object went away (e.g. the app disposed it) and the\n // button was released off any target. Release anyway, as the touch\n // lifecycle does, or the selection lock never ends.\n if (state === InteractorState.SELECT && buttonUp) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = button;\n entry.pointer.up(this.buttonEvent);\n this.pointerStates.set(this.activeKind!, InteractorState.NORMAL);\n }\n return;\n }\n\n // HOVER → SELECT on button down\n if (state === InteractorState.HOVER && buttonDown) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = button;\n entry.pointer.down(this.buttonEvent);\n this.pointerStates.set(this.activeKind!, InteractorState.SELECT);\n }\n // SELECT → HOVER on button up\n else if (state === InteractorState.SELECT && buttonUp) {\n this.buttonEvent.timeStamp = this.nativeEvent.timeStamp;\n this.buttonEvent.button = button;\n entry.pointer.up(this.buttonEvent);\n this.pointerStates.set(this.activeKind!, InteractorState.HOVER);\n }\n // NORMAL → HOVER when we have a candidate\n else if (state === InteractorState.NORMAL) {\n this.pointerStates.set(this.activeKind!, InteractorState.HOVER);\n }\n }\n\n /**\n * Get the policy for ray visual rendering\n */\n /** Objects this hand may poke: its own list when the scene has one. */\n private touchCandidates(): Object3D[] | undefined {\n return (\n this.sceneWithDescendants.touchDescendantsByHand?.[this.handedness] ??\n this.sceneWithDescendants.touchDescendants\n );\n }\n\n getPolicyForRay() {\n return { forceHideRay: this.shouldHideRay() };\n }\n\n private shouldHideRay(): boolean {\n // Hide the visual whenever the ray is disabled or a near pointer owns the\n // hand, including gaze-mode suppression.\n return (\n this.pointerStates.get('ray') === InteractorState.DISABLED ||\n (this.activeKind !== 'ray' && this.activeKind !== null)\n );\n }\n\n /**\n * Check if ray is busy (has intersection)\n */\n getRayBusy(): boolean {\n return !!this.ray.visual.busy;\n }\n\n /**\n * Toggle a sub-pointer on/off\n */\n toggleSubPointer(kind: PointerKind, enabled: boolean): boolean {\n const entry = this.getEntry(kind);\n if (entry.registered === enabled) {\n return false;\n }\n entry.registered = enabled;\n if (!enabled) {\n this.pointerStates.set(kind, InteractorState.DISABLED);\n if (this.activeKind === kind) {\n this.activeKind = null;\n }\n if (kind === 'touch') {\n this.touchHoverActive = false;\n }\n }\n return true;\n }\n\n /**\n * Get the registration state of a sub-pointer\n */\n getSubPointerState(kind: PointerKind): { registered: boolean } {\n const entry = this.getEntry(kind);\n return { registered: entry.registered };\n }\n\n /**\n * Get the currently active pointer kind\n */\n getActiveKind(): PointerKind | null {\n return this.activeKind;\n }\n\n /**\n * Computes a world-space offset that keeps the hand visual's fingertip on the\n * touched surface while the touch pointer is actively selecting.\n */\n getTouchSurfaceVisualOffset(target: Vector3 = new Vector3()): Vector3 | null {\n if (this.activeKind !== 'touch') {\n return null;\n }\n\n if (this.pointerStates.get('touch') !== InteractorState.SELECT) {\n return null;\n }\n\n const intersection = this.touch.pointer.getIntersection();\n if (\n !intersection ||\n intersection.object.isVoidObject ||\n intersection.details.type !== 'sphere'\n ) {\n return null;\n }\n\n target.copy(intersection.pointOnFace).sub(intersection.pointerPosition);\n if (target.lengthSq() < TOUCH_VISUAL_OFFSET_EPSILON_SQ) {\n return null;\n }\n\n return target;\n }\n\n /**\n * Get the currently active pointer\n */\n getActivePointer(): Pointer | null {\n if (!this.activeKind) {\n return null;\n }\n return this.getEntry(this.activeKind).pointer;\n }\n\n /**\n * Get a specific pointer by kind\n */\n getPointer(kind: PointerKind): Pointer {\n return this.getEntry(kind).pointer;\n }\n\n /**\n * Route a down event to a specific pointer target.\n * Used by grab-system for hand pinch gestures.\n */\n routeDown(\n kind: 'select' | 'squeeze' | 'custom',\n target: 'ray' | 'grab' | 'active',\n nativeEvent: { timeStamp: number },\n ) {\n const ptr = this.pickTarget(target);\n if (!ptr) {\n return;\n }\n const button = kind === 'select' ? 0 : 2;\n ptr.down({ button, timeStamp: nativeEvent.timeStamp });\n }\n\n /**\n * Route an up event to a specific pointer target.\n * Used by grab-system for hand pinch gestures.\n */\n routeUp(\n kind: 'select' | 'squeeze' | 'custom',\n target: 'ray' | 'grab' | 'active',\n nativeEvent: { timeStamp: number },\n ) {\n const ptr = this.pickTarget(target);\n if (!ptr) {\n return;\n }\n const button = kind === 'select' ? 0 : 2;\n ptr.up({ button, timeStamp: nativeEvent.timeStamp });\n }\n\n /**\n * Pick pointer by target type.\n */\n private pickTarget(target: 'ray' | 'grab' | 'active'): Pointer | undefined {\n if (target === 'active') {\n // Prefer captured pointer if any, else fall back to active or ray\n if (this.ray.pointer.getPointerCapture?.()) {\n return this.ray.pointer;\n }\n if (this.grab.pointer.getPointerCapture?.()) {\n return this.grab.pointer;\n }\n if (this.touch.pointer.getPointerCapture?.()) {\n return this.touch.pointer;\n }\n // Fall back to active pointer or ray\n return this.activeKind\n ? this.getEntry(this.activeKind).pointer\n : this.ray.pointer;\n }\n if (target === 'ray') {\n return this.ray.pointer;\n }\n return this.grab.pointer;\n }\n\n /**\n * Get the entry for a pointer kind\n */\n private getEntry(\n kind: PointerKind,\n ): PointerEntry<RayPointer | GrabPointer | TouchPointer> {\n switch (kind) {\n case 'ray':\n return this.ray;\n case 'grab':\n return this.grab;\n case 'touch':\n return this.touch;\n }\n }\n\n /**\n * Dispose of all pointer resources.\n * Call this when the MultiPointer is no longer needed.\n */\n dispose(): void {\n // Dispose cursor visual\n this.cursorVisual.dispose();\n\n // Dispose ray pointer (has geometry/material)\n this.ray.visual.dispose();\n\n // Clear state\n this.pointerStates.clear();\n this.activeKind = null;\n }\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;AAKG;AAyBH;;AAEG;IACS;AAAZ,CAAA,UAAY,eAAe,EAAA;;AAEzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,UAAqB;;AAErB,IAAA,eAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;;AAEjB,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,OAAe;;AAEf,IAAA,eAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACnB,CAAC,EATW,eAAe,KAAf,eAAe,GAAA,EAAA,CAAA,CAAA;AAW3B;;AAEG;AACH,MAAM,cAAc,GAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC;AAE9D;;AAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,kBAAkB,EAAE,IAAI;IACxB,iBAAiB,EAAE,GAAG;CACvB;AAED,MAAM,8BAA8B,GAAG,QAAQ;AAQ/C;;;;;;;;;;AAUG;MACU,YAAY,CAAA;AAyCvB,IAAA,WAAA,CACmB,UAA4B,EAC5B,KAAe,EACf,MAAyB,EACzB,QAAkB,EAAA;QAHlB,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,KAAK,GAAL,KAAK;QACL,IAAA,CAAA,MAAM,GAAN,MAAM;QACN,IAAA,CAAA,QAAQ,GAAR,QAAQ;;QAtCnB,IAAA,CAAA,UAAU,GAAuB,IAAI;;AAGrC,QAAA,IAAA,CAAA,aAAa,GAAsC,IAAI,GAAG,EAAE;;QAG5D,IAAA,CAAA,gBAAgB,GAAG,KAAK;;AAaf,QAAA,IAAA,CAAA,WAAW,GAAG,EAAE,SAAS,EAAE,CAAC,EAAE;;AAG9B,QAAA,I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
|
|
1
|
+
{"version":3,"file":"ray-pointer.d.ts","sourceRoot":"","sources":["../../src/pointer/ray-pointer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,EAAoB,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAEL,gBAAgB,EAChB,YAAY,EAEZ,IAAI,EACJ,iBAAiB,EACjB,cAAc,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AA6B/C,oBAAY,cAAc;IACxB,OAAO,IAAI;IACX,qBAAqB,IAAI;IACzB,SAAS,IAAI;CACd;AAED,qBAAa,UAAU;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;IAC5C,OAAO,UAAQ;IACf,eAAe,EAAE,YAAY,GAAG,SAAS,CAAC;IAC1C,cAAc,EAAE,cAAc,CAAwC;gBAG3E,MAAM,EAAE,iBAAiB,EACzB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,MAAM,GAAG,OAAO;IA8C9B,MAAM,CACJ,SAAS,EAAE,OAAO,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,OAAO,EAClB,MAAM,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE;IAmBrC,OAAO,CAAC,sBAAsB;IAgC9B,IAAI,IAAI,YAEP;IAED;;OAEG;IACH,OAAO,IAAI,IAAI;CAKhB"}
|
|
@@ -53,6 +53,9 @@ class RayPointer {
|
|
|
53
53
|
const raycaster = this.pointer.intersector.raycaster;
|
|
54
54
|
if (raycaster) {
|
|
55
55
|
raycaster.firstHitOnly = true;
|
|
56
|
+
// Sprite.raycast needs the viewing camera, and the XR ray intersector
|
|
57
|
+
// never sets one (the screen intersector does, via setFromCamera).
|
|
58
|
+
raycaster.camera = camera;
|
|
56
59
|
}
|
|
57
60
|
this.ray = new Mesh(new CylinderGeometry(0.001, 0.001, 1, 6, 1, true)
|
|
58
61
|
.translate(0, 0.5, 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ray-pointer.js","sources":["../../src/pointer/ray-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 { Pointer, createRayPointer } from '@pmndrs/pointer-events';\nimport {\n Color,\n CylinderGeometry,\n Intersection,\n MathUtils,\n Mesh,\n PerspectiveCamera,\n ShaderMaterial,\n} from 'three';\nimport { XROrigin } from '../rig/xr-origin.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\nconst { lerp } = MathUtils;\n\nconst vertexShader = `\n varying float vPosition;\n void main() {\n vPosition = (position.z + 1.0) / 1.0;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n`;\n\nconst fragmentShader = `\n uniform float endValue;\n uniform float opacity;\n uniform vec3 color;\n varying float vPosition;\n void main() {\n float alpha = vPosition < endValue ? smoothstep(endValue-0.05, endValue, vPosition) :\n vPosition < 0.97 ? 1.0 :\n 1.0 - smoothstep(0.97, 1.0, vPosition);\n gl_FragColor = vec4(color, alpha * opacity);\n }\n`;\n\nconst rayPressedColor = new Color(0x3383e6);\nconst rayDefaultColor = new Color(0xffffff);\n\nexport enum RayDisplayMode {\n Visible = 1,\n VisibleOnIntersection = 2,\n Invisible = 3,\n}\n\nexport class RayPointer {\n public pointer: Pointer;\n public ray: Mesh<CylinderGeometry, ShaderMaterial>;\n public enabled = true;\n public rayIntersection: Intersection | undefined;\n public rayDisplayMode: RayDisplayMode = RayDisplayMode.VisibleOnIntersection;\n\n constructor(\n camera: PerspectiveCamera,\n xrOrigin: XROrigin,\n handedness: 'left' | 'right',\n ) {\n this.pointer = createRayPointer(\n () => camera,\n { current: xrOrigin.raySpaces[handedness] },\n {},\n {\n filter: isObjectTreeVisible,\n // XR trigger presses are commonly longer than a mouse click, especially\n // through controller emulation. Match the poke pointer's forgiving\n // activation window so a normal select gesture reaches child UI clicks.\n clickThresholdMs: 800,\n // Disable contextmenu on button 2 (squeeze) to avoid spurious events\n contextMenuButton: -1,\n },\n );\n\n // Optimize raycaster for BVH acceleration - only get first hit for better performance\n const raycaster = (this.pointer.intersector as any).raycaster;\n if (raycaster) {\n raycaster.firstHitOnly = true;\n }\n this.ray = new Mesh(\n new CylinderGeometry(0.001, 0.001, 1, 6, 1, true)\n .translate(0, 0.5, 0)\n .rotateX(-Math.PI / 2),\n new ShaderMaterial({\n vertexShader: vertexShader,\n fragmentShader: fragmentShader,\n transparent: true,\n depthWrite: false,\n uniforms: {\n endValue: { value: 0.75 },\n color: { value: new Color().copy(rayDefaultColor) },\n opacity: { value: 0 },\n },\n }),\n );\n this.ray.visible = false;\n this.ray.renderOrder = 0;\n xrOrigin.raySpaces[handedness].add(this.ray);\n }\n\n update(\n connected: boolean,\n delta: number,\n _time: number,\n selectStart: boolean,\n selectEnd: boolean,\n policy?: { forceHideRay?: boolean },\n ) {\n // CombinedPointer is responsible for moving/enabling; we only render visuals\n // CombinedPointer controls actual pointer enablement; reflect that in visuals\n const pointerEnabled = this.pointer.getEnabled();\n const active = pointerEnabled && connected && this.enabled;\n this.ray.visible = active && !policy?.forceHideRay;\n\n if (active) {\n if (pointerEnabled && selectStart) {\n this.ray.material.uniforms.color.value.copy(rayPressedColor);\n } else if (pointerEnabled && selectEnd) {\n this.ray.material.uniforms.color.value.copy(rayDefaultColor);\n }\n // Movement is handled by the owning CombinedPointer aggregator\n }\n this.updatePointerRendering(active, delta);\n }\n\n private updatePointerRendering(pointerActive: boolean, delta = 1) {\n let rayOpacityTarget = 0;\n if (pointerActive) {\n const intersection = this.pointer.getIntersection();\n const intersectionValid = !!(\n intersection && !intersection.object.isVoidObject\n );\n this.rayIntersection = intersectionValid ? intersection : undefined;\n switch (this.rayDisplayMode) {\n case RayDisplayMode.Visible:\n rayOpacityTarget = 1;\n break;\n case RayDisplayMode.Invisible:\n rayOpacityTarget = 0;\n break;\n default:\n rayOpacityTarget = intersectionValid ? 1 : 0;\n }\n if (intersectionValid) {\n this.ray.material.uniforms.endValue.value =\n 1.05 - Math.min(0.3, intersection.distance);\n }\n } else {\n this.rayIntersection = undefined;\n }\n this.ray.material.uniforms.opacity.value = lerp(\n this.ray.material.uniforms.opacity.value,\n rayOpacityTarget,\n delta * 10,\n );\n }\n\n get busy() {\n return !!this.rayIntersection;\n }\n\n /**\n * Dispose of ray pointer resources.\n */\n dispose(): void {\n this.ray.geometry.dispose();\n this.ray.material.dispose();\n this.ray.removeFromParent();\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAeH,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS;AAE1B,MAAM,YAAY,GAAG;;;;;;CAMpB;AAED,MAAM,cAAc,GAAG;;;;;;;;;;;CAWtB;AAED,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC;AAC3C,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC;IAE/B;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,cAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACX,IAAA,cAAA,CAAA,cAAA,CAAA,uBAAA,CAAA,GAAA,CAAA,CAAA,GAAA,uBAAyB;AACzB,IAAA,cAAA,CAAA,cAAA,CAAA,WAAA,CAAA,GAAA,CAAA,CAAA,GAAA,WAAa;AACf,CAAC,EAJW,cAAc,KAAd,cAAc,GAAA,EAAA,CAAA,CAAA;MAMb,UAAU,CAAA;AAOrB,IAAA,WAAA,CACE,MAAyB,EACzB,QAAkB,EAClB,UAA4B,EAAA;QAPvB,IAAA,CAAA,OAAO,GAAG,IAAI;AAEd,QAAA,IAAA,CAAA,cAAc,GAAmB,cAAc,CAAC,qBAAqB;QAO1E,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAC7B,MAAM,MAAM,EACZ,EAAE,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,EAC3C,EAAE,EACF;AACE,YAAA,MAAM,EAAE,mBAAmB;;;;AAI3B,YAAA,gBAAgB,EAAE,GAAG;;YAErB,iBAAiB,EAAE,EAAE;AACtB,SAAA,CACF;;QAGD,MAAM,SAAS,GAAI,IAAI,CAAC,OAAO,CAAC,WAAmB,CAAC,SAAS;QAC7D,IAAI,SAAS,EAAE;AACb,YAAA,SAAS,CAAC,YAAY,GAAG,IAAI;
|
|
1
|
+
{"version":3,"file":"ray-pointer.js","sources":["../../src/pointer/ray-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 { Pointer, createRayPointer } from '@pmndrs/pointer-events';\nimport {\n Color,\n CylinderGeometry,\n Intersection,\n MathUtils,\n Mesh,\n PerspectiveCamera,\n ShaderMaterial,\n} from 'three';\nimport { XROrigin } from '../rig/xr-origin.js';\nimport { isObjectTreeVisible } from './visibility.js';\n\nconst { lerp } = MathUtils;\n\nconst vertexShader = `\n varying float vPosition;\n void main() {\n vPosition = (position.z + 1.0) / 1.0;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n`;\n\nconst fragmentShader = `\n uniform float endValue;\n uniform float opacity;\n uniform vec3 color;\n varying float vPosition;\n void main() {\n float alpha = vPosition < endValue ? smoothstep(endValue-0.05, endValue, vPosition) :\n vPosition < 0.97 ? 1.0 :\n 1.0 - smoothstep(0.97, 1.0, vPosition);\n gl_FragColor = vec4(color, alpha * opacity);\n }\n`;\n\nconst rayPressedColor = new Color(0x3383e6);\nconst rayDefaultColor = new Color(0xffffff);\n\nexport enum RayDisplayMode {\n Visible = 1,\n VisibleOnIntersection = 2,\n Invisible = 3,\n}\n\nexport class RayPointer {\n public pointer: Pointer;\n public ray: Mesh<CylinderGeometry, ShaderMaterial>;\n public enabled = true;\n public rayIntersection: Intersection | undefined;\n public rayDisplayMode: RayDisplayMode = RayDisplayMode.VisibleOnIntersection;\n\n constructor(\n camera: PerspectiveCamera,\n xrOrigin: XROrigin,\n handedness: 'left' | 'right',\n ) {\n this.pointer = createRayPointer(\n () => camera,\n { current: xrOrigin.raySpaces[handedness] },\n {},\n {\n filter: isObjectTreeVisible,\n // XR trigger presses are commonly longer than a mouse click, especially\n // through controller emulation. Match the poke pointer's forgiving\n // activation window so a normal select gesture reaches child UI clicks.\n clickThresholdMs: 800,\n // Disable contextmenu on button 2 (squeeze) to avoid spurious events\n contextMenuButton: -1,\n },\n );\n\n // Optimize raycaster for BVH acceleration - only get first hit for better performance\n const raycaster = (this.pointer.intersector as any).raycaster;\n if (raycaster) {\n raycaster.firstHitOnly = true;\n // Sprite.raycast needs the viewing camera, and the XR ray intersector\n // never sets one (the screen intersector does, via setFromCamera).\n raycaster.camera = camera;\n }\n this.ray = new Mesh(\n new CylinderGeometry(0.001, 0.001, 1, 6, 1, true)\n .translate(0, 0.5, 0)\n .rotateX(-Math.PI / 2),\n new ShaderMaterial({\n vertexShader: vertexShader,\n fragmentShader: fragmentShader,\n transparent: true,\n depthWrite: false,\n uniforms: {\n endValue: { value: 0.75 },\n color: { value: new Color().copy(rayDefaultColor) },\n opacity: { value: 0 },\n },\n }),\n );\n this.ray.visible = false;\n this.ray.renderOrder = 0;\n xrOrigin.raySpaces[handedness].add(this.ray);\n }\n\n update(\n connected: boolean,\n delta: number,\n _time: number,\n selectStart: boolean,\n selectEnd: boolean,\n policy?: { forceHideRay?: boolean },\n ) {\n // CombinedPointer is responsible for moving/enabling; we only render visuals\n // CombinedPointer controls actual pointer enablement; reflect that in visuals\n const pointerEnabled = this.pointer.getEnabled();\n const active = pointerEnabled && connected && this.enabled;\n this.ray.visible = active && !policy?.forceHideRay;\n\n if (active) {\n if (pointerEnabled && selectStart) {\n this.ray.material.uniforms.color.value.copy(rayPressedColor);\n } else if (pointerEnabled && selectEnd) {\n this.ray.material.uniforms.color.value.copy(rayDefaultColor);\n }\n // Movement is handled by the owning CombinedPointer aggregator\n }\n this.updatePointerRendering(active, delta);\n }\n\n private updatePointerRendering(pointerActive: boolean, delta = 1) {\n let rayOpacityTarget = 0;\n if (pointerActive) {\n const intersection = this.pointer.getIntersection();\n const intersectionValid = !!(\n intersection && !intersection.object.isVoidObject\n );\n this.rayIntersection = intersectionValid ? intersection : undefined;\n switch (this.rayDisplayMode) {\n case RayDisplayMode.Visible:\n rayOpacityTarget = 1;\n break;\n case RayDisplayMode.Invisible:\n rayOpacityTarget = 0;\n break;\n default:\n rayOpacityTarget = intersectionValid ? 1 : 0;\n }\n if (intersectionValid) {\n this.ray.material.uniforms.endValue.value =\n 1.05 - Math.min(0.3, intersection.distance);\n }\n } else {\n this.rayIntersection = undefined;\n }\n this.ray.material.uniforms.opacity.value = lerp(\n this.ray.material.uniforms.opacity.value,\n rayOpacityTarget,\n delta * 10,\n );\n }\n\n get busy() {\n return !!this.rayIntersection;\n }\n\n /**\n * Dispose of ray pointer resources.\n */\n dispose(): void {\n this.ray.geometry.dispose();\n this.ray.material.dispose();\n this.ray.removeFromParent();\n }\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAeH,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS;AAE1B,MAAM,YAAY,GAAG;;;;;;CAMpB;AAED,MAAM,cAAc,GAAG;;;;;;;;;;;CAWtB;AAED,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC;AAC3C,MAAM,eAAe,GAAG,IAAI,KAAK,CAAC,QAAQ,CAAC;IAE/B;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,cAAA,CAAA,SAAA,CAAA,GAAA,CAAA,CAAA,GAAA,SAAW;AACX,IAAA,cAAA,CAAA,cAAA,CAAA,uBAAA,CAAA,GAAA,CAAA,CAAA,G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AC,OAAO,EAAE;AAC3B,QAAA,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE;IAC7B;AACD;;;;"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.2.0-rc.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iwsdk/xr-input",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-rc.0",
|
|
4
4
|
"description": "WebXR input system with controller and hand tracking support, visual adapters, and input profiles for Three.js applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|