@woosh/meep-engine 3.35.0 → 3.36.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.
Files changed (72) hide show
  1. package/package.json +1 -1
  2. package/src/engine/Engine.d.ts +2 -0
  3. package/src/engine/Engine.d.ts.map +1 -1
  4. package/src/engine/Engine.js +5 -1
  5. package/src/engine/input/devices/XRInputDevice.d.ts +63 -0
  6. package/src/engine/input/devices/XRInputDevice.d.ts.map +1 -0
  7. package/src/engine/input/devices/XRInputDevice.js +386 -0
  8. package/src/engine/input/devices/xr/XRInputAction.d.ts +37 -0
  9. package/src/engine/input/devices/xr/XRInputAction.d.ts.map +1 -0
  10. package/src/engine/input/devices/xr/XRInputAction.js +85 -0
  11. package/src/engine/input/devices/xr/XRInputButton.d.ts +28 -0
  12. package/src/engine/input/devices/xr/XRInputButton.d.ts.map +1 -0
  13. package/src/engine/input/devices/xr/XRInputButton.js +43 -0
  14. package/src/engine/input/devices/xr/XRInputCoordinates.d.ts +15 -0
  15. package/src/engine/input/devices/xr/XRInputCoordinates.d.ts.map +1 -0
  16. package/src/engine/input/devices/xr/XRInputCoordinates.js +21 -0
  17. package/src/engine/input/devices/xr/XRInputHandle.d.ts +63 -0
  18. package/src/engine/input/devices/xr/XRInputHandle.d.ts.map +1 -0
  19. package/src/engine/input/devices/xr/XRInputHandle.js +171 -0
  20. package/src/engine/input/devices/xr/XRInputPose.d.ts +23 -0
  21. package/src/engine/input/devices/xr/XRInputPose.d.ts.map +1 -0
  22. package/src/engine/input/devices/xr/XRInputPose.js +36 -0
  23. package/src/engine/input/devices/xr/XRInputTypes.d.ts +76 -0
  24. package/src/engine/input/devices/xr/XRInputTypes.d.ts.map +1 -0
  25. package/src/engine/input/devices/xr/XRInputTypes.js +31 -0
  26. package/src/engine/input/devices/xr/XRInputValueSource.d.ts +11 -0
  27. package/src/engine/input/devices/xr/XRInputValueSource.d.ts.map +1 -0
  28. package/src/engine/input/devices/xr/XRInputValueSource.js +11 -0
  29. package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.d.ts +15 -1
  30. package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.d.ts.map +1 -1
  31. package/src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.js +9 -0
  32. package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.d.ts +15 -4
  33. package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.d.ts.map +1 -1
  34. package/src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js +22 -0
  35. package/src/engine/input/ecs/ism/coordinate/InputCoordinateSwitches.d.ts +17 -2
  36. package/src/engine/input/ecs/ism/coordinate/InputCoordinateSwitches.d.ts.map +1 -1
  37. package/src/engine/input/ecs/ism/device/GamepadInputDeviceAdapter.d.ts +5 -0
  38. package/src/engine/input/ecs/ism/device/GamepadInputDeviceAdapter.d.ts.map +1 -1
  39. package/src/engine/input/ecs/ism/device/InputDeviceAdapter.d.ts +2 -0
  40. package/src/engine/input/ecs/ism/device/InputDeviceAdapter.d.ts.map +1 -1
  41. package/src/engine/input/ecs/ism/device/InputDeviceAdapter.js +2 -0
  42. package/src/engine/input/ecs/ism/device/KeyboardInputDeviceAdapter.d.ts +7 -0
  43. package/src/engine/input/ecs/ism/device/KeyboardInputDeviceAdapter.d.ts.map +1 -1
  44. package/src/engine/input/ecs/ism/device/ManualInputDeviceAdapter.d.ts +5 -0
  45. package/src/engine/input/ecs/ism/device/ManualInputDeviceAdapter.d.ts.map +1 -1
  46. package/src/engine/input/ecs/ism/device/PointerInputDeviceAdapter.d.ts +5 -0
  47. package/src/engine/input/ecs/ism/device/PointerInputDeviceAdapter.d.ts.map +1 -1
  48. package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.d.ts +16 -0
  49. package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.d.ts.map +1 -0
  50. package/src/engine/input/ecs/ism/device/XRInputDeviceAdapter.js +54 -0
  51. package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.d.ts +9 -0
  52. package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.d.ts.map +1 -0
  53. package/src/engine/input/ecs/ism/device/XR_INPUT_DEVICE_IDS.js +12 -0
  54. package/src/engine/input/ecs/ism/trigger/InputTrigger.d.ts +11 -1
  55. package/src/engine/input/ecs/ism/trigger/InputTrigger.d.ts.map +1 -1
  56. package/src/engine/input/ecs/ism/trigger/InputTrigger.js +7 -0
  57. package/src/engine/input/ecs/ism/trigger/InputTriggerChord.d.ts +16 -2
  58. package/src/engine/input/ecs/ism/trigger/InputTriggerChord.d.ts.map +1 -1
  59. package/src/engine/input/ecs/ism/trigger/InputTriggerHold.d.ts +22 -2
  60. package/src/engine/input/ecs/ism/trigger/InputTriggerHold.d.ts.map +1 -1
  61. package/src/engine/input/ecs/ism/trigger/InputTriggerRelease.d.ts +16 -2
  62. package/src/engine/input/ecs/ism/trigger/InputTriggerRelease.d.ts.map +1 -1
  63. package/src/engine/input/ecs/ism/trigger/InputTriggerSequence.d.ts +24 -4
  64. package/src/engine/input/ecs/ism/trigger/InputTriggerSequence.d.ts.map +1 -1
  65. package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.d.ts +6 -8
  66. package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.d.ts.map +1 -1
  67. package/src/engine/input/ecs/ism/trigger/InputTriggerSwitch.js +5 -0
  68. package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.d.ts +7 -0
  69. package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.d.ts.map +1 -0
  70. package/src/engine/input/ecs/ism/trigger/InputTriggerXRButton.js +15 -0
  71. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  72. package/src/shade/renderer/loader/gltf/tiny-gltf.d.ts +1 -1
@@ -0,0 +1,43 @@
1
+ import { Vector1 } from "../../../../core/geom/Vector1.js";
2
+ import { InputDeviceSwitch } from "../InputDeviceSwitch.js";
3
+
4
+ /**
5
+ * One raw GamepadButton: its scalar amount and the two binary facts reported by the browser.
6
+ * pressed is not inferred from x; a partially depressed trigger need not be pressed.
7
+ * The device owns mutation. Switches and onChanged keep their identity across source replacement.
8
+ */
9
+ export class XRInputButton extends Vector1 {
10
+ /** @readonly */
11
+ pressed = new InputDeviceSwitch();
12
+ /** @readonly */
13
+ touched = new InputDeviceSwitch();
14
+
15
+ #pressed = false;
16
+ #touched = false;
17
+
18
+ /**
19
+ * Stage binary state while updating the scalar. All numeric channels and poses are sampled before
20
+ * the device calls flushSwitches, so an input-map action can read the corresponding amount.
21
+ * @internal
22
+ * @param {{value: number, pressed: boolean, touched: boolean}|undefined} button
23
+ */
24
+ update(button) {
25
+ this.#pressed = button !== undefined && button.pressed;
26
+ this.#touched = button !== undefined && button.touched;
27
+ this.set(button === undefined ? 0 : button.value);
28
+ }
29
+
30
+ /** @internal */
31
+ flushSwitches() {
32
+ if (this.#pressed) {
33
+ this.pressed.press();
34
+ } else {
35
+ this.pressed.release();
36
+ }
37
+ if (this.#touched) {
38
+ this.touched.press();
39
+ } else {
40
+ this.touched.release();
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,15 @@
1
+ /** @param {number} index Native button index. @returns {number} Scalar amount, not pressed/touched. */
2
+ export function xr_input_button_coordinate(index: number): number;
3
+ /** @param {number} index Native axis index. @returns {number} */
4
+ export function xr_input_axis_coordinate(index: number): number;
5
+ /**
6
+ * Stable codes used in serialized input maps.
7
+ */
8
+ export type XRInputCoordinates = number;
9
+ export namespace XRInputCoordinates {
10
+ let select: number;
11
+ let squeeze: number;
12
+ let thumbstick: number;
13
+ let touchpad: number;
14
+ }
15
+ //# sourceMappingURL=XRInputCoordinates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRInputCoordinates.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputCoordinates.js"],"names":[],"mappings":"AAUA,uGAAuG;AACvG,kDADY,MAAM,GAAuC,MAAM,CAI9D;AAED,iEAAiE;AACjE,gDADY,MAAM,GAAqC,MAAM,CAI5D;;;;iCAlBoB,MAAM"}
@@ -0,0 +1,21 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+
3
+ /** @readonly @enum {number} Stable codes used in serialized input maps. */
4
+ export const XRInputCoordinates = {
5
+ select: 0,
6
+ squeeze: 1,
7
+ thumbstick: 2,
8
+ touchpad: 3
9
+ };
10
+
11
+ /** @param {number} index Native button index. @returns {number} Scalar amount, not pressed/touched. */
12
+ export function xr_input_button_coordinate(index) {
13
+ assert.isNonNegativeInteger(index, 'index');
14
+ return 4 + index * 2;
15
+ }
16
+
17
+ /** @param {number} index Native axis index. @returns {number} */
18
+ export function xr_input_axis_coordinate(index) {
19
+ assert.isNonNegativeInteger(index, 'index');
20
+ return 5 + index * 2;
21
+ }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * One XR input source, or a persistent handedness slot owned by XRInputDevice.
3
+ * All control objects survive disconnection. Consumers read them; the device owns mutation.
4
+ * Only xr-standard supplies known button/axis semantics. Other mappings remain available through
5
+ * buttons/axes, while select/squeeze use the explicitly identified binary action fallback.
6
+ *
7
+ * Button indices 0/1 are select/squeeze; axes 0/1 are touchpad and 2/3 thumbstick in xr-standard.
8
+ * Placeholder entries are allowed by WebXR: a zero entry does not prove that a control exists.
9
+ */
10
+ export class XRInputHandle {
11
+ /** @readonly */
12
+ readonly select: XRInputAction;
13
+ /** @readonly */
14
+ readonly squeeze: XRInputAction;
15
+ /** @readonly @type {XRInputButton[]} Use getButton for an index that may not exist yet. */
16
+ readonly buttons: XRInputButton[];
17
+ /** @readonly @type {Vector1[]} Use getAxis for an index that may not exist yet. */
18
+ readonly axes: Vector1[];
19
+ /** @readonly */
20
+ readonly thumbstick: GamepadStick;
21
+ /** @readonly Uncalibrated pad coordinates, +x right, +y down. */
22
+ readonly touchpad: Vector2;
23
+ /** @readonly */
24
+ readonly targetRay: XRInputPose;
25
+ /** @readonly */
26
+ readonly grip: XRInputPose;
27
+ /** @readonly @type {import('./XRInputTypes.js').XRInputSource|null} Set by the device. */
28
+ readonly nativeSource: import('./XRInputTypes.js').XRInputSource | null;
29
+ /** Number of native entries, excluding controls materialised for bindings. */
30
+ buttonCount: number;
31
+ axisCount: number;
32
+ get connected(): boolean;
33
+ get handedness(): string;
34
+ get targetRayMode(): string;
35
+ /** @returns {ReadonlyArray<string>} */
36
+ get profiles(): readonly string[];
37
+ /** @param {number} index @returns {XRInputButton} */
38
+ getButton(index: number): XRInputButton;
39
+ /** @param {number} index @returns {Vector1} */
40
+ getAxis(index: number): Vector1;
41
+ /** @internal @param {import('./XRInputTypes.js').XRInputSource|null} source */
42
+ bind(source: import('./XRInputTypes.js').XRInputSource | null): void;
43
+ /**
44
+ * @internal Sample values and poses before publishing raw switch edges.
45
+ * @param {import('./XRInputTypes.js').XRFrame|null} frame
46
+ * @param {EventTarget|null} referenceSpace
47
+ */
48
+ sample(frame: import('./XRInputTypes.js').XRFrame | null, referenceSpace: EventTarget | null): void;
49
+ /** @internal Tracking loss does not imply release or cancellation. */
50
+ invalidatePoses(): void;
51
+ /** @internal Neutralise everything before switch releases and cancellation callbacks. */
52
+ clear(): void;
53
+ /** @internal */
54
+ flush(): void;
55
+ #private;
56
+ }
57
+ import { XRInputAction } from "./XRInputAction.js";
58
+ import { XRInputButton } from "./XRInputButton.js";
59
+ import { Vector1 } from "../../../../core/geom/Vector1.js";
60
+ import { GamepadStick } from "../gamepad/GamepadStick.js";
61
+ import Vector2 from "../../../../core/geom/Vector2.js";
62
+ import { XRInputPose } from "./XRInputPose.js";
63
+ //# sourceMappingURL=XRInputHandle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRInputHandle.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputHandle.js"],"names":[],"mappings":"AAYA;;;;;;;;GAQG;AACH;IACI,gBAAgB;IAChB,+BAA6B;IAC7B,gBAAgB;IAChB,gCAA8B;IAC9B,2FAA2F;IAC3F,kBADqB,aAAa,EAAE,CACvB;IACb,mFAAmF;IACnF,eADqB,OAAO,EAAE,CACpB;IACV,gBAAgB;IAChB,kCAAoC;IACpC,iEAAiE;IACjE,2BAAyB;IACzB,gBAAgB;IAChB,gCAA8B;IAC9B,gBAAgB;IAChB,2BAAyB;IAEzB,0FAA0F;IAC1F,uBADqB,OAAO,mBAAmB,EAAE,aAAa,GAAC,IAAI,CAC/C;IAIpB,8EAA8E;IAC9E,oBAAgB;IAChB,kBAAc;IAOd,yBAAsD;IACtD,yBAA+F;IAC/F,4BAAiG;IACjG,uCAAuC;IACvC,kCAAgG;IAEhG,qDAAqD;IACrD,iBADY,MAAM,GAAkB,aAAa,CAOhD;IAED,+CAA+C;IAC/C,eADY,MAAM,GAAkB,OAAO,CAO1C;IAED,+EAA+E;IAC/E,aADsB,OAAO,mBAAmB,EAAE,aAAa,GAAC,IAAI,QAUnE;IAED;;;;OAIG;IACH,cAHW,OAAO,mBAAmB,EAAE,OAAO,GAAC,IAAI,kBACxC,WAAW,GAAC,IAAI,QA4C1B;IAED,sEAAsE;IACtE,wBAGC;IAED,yFAAyF;IACzF,cAeC;IAED,gBAAgB;IAChB,cAMC;;CACJ;8BAtK6B,oBAAoB;8BACpB,oBAAoB;wBAJ1B,kCAAkC;6BAE7B,4BAA4B;oBADrC,kCAAkC;4BAI1B,kBAAkB"}
@@ -0,0 +1,171 @@
1
+ import { assert } from "../../../../core/assert.js";
2
+ import { Vector1 } from "../../../../core/geom/Vector1.js";
3
+ import Vector2 from "../../../../core/geom/Vector2.js";
4
+ import { GamepadStick } from "../gamepad/GamepadStick.js";
5
+ import { XRInputAction } from "./XRInputAction.js";
6
+ import { XRInputButton } from "./XRInputButton.js";
7
+ import { XRInputPose } from "./XRInputPose.js";
8
+ import { XRInputValueSource } from "./XRInputValueSource.js";
9
+
10
+ /** @type {ReadonlyArray<string>} */
11
+ const NO_PROFILES = Object.freeze([]);
12
+
13
+ /**
14
+ * One XR input source, or a persistent handedness slot owned by XRInputDevice.
15
+ * All control objects survive disconnection. Consumers read them; the device owns mutation.
16
+ * Only xr-standard supplies known button/axis semantics. Other mappings remain available through
17
+ * buttons/axes, while select/squeeze use the explicitly identified binary action fallback.
18
+ *
19
+ * Button indices 0/1 are select/squeeze; axes 0/1 are touchpad and 2/3 thumbstick in xr-standard.
20
+ * Placeholder entries are allowed by WebXR: a zero entry does not prove that a control exists.
21
+ */
22
+ export class XRInputHandle {
23
+ /** @readonly */
24
+ select = new XRInputAction();
25
+ /** @readonly */
26
+ squeeze = new XRInputAction();
27
+ /** @readonly @type {XRInputButton[]} Use getButton for an index that may not exist yet. */
28
+ buttons = [];
29
+ /** @readonly @type {Vector1[]} Use getAxis for an index that may not exist yet. */
30
+ axes = [];
31
+ /** @readonly */
32
+ thumbstick = new GamepadStick(2, 3);
33
+ /** @readonly Uncalibrated pad coordinates, +x right, +y down. */
34
+ touchpad = new Vector2();
35
+ /** @readonly */
36
+ targetRay = new XRInputPose();
37
+ /** @readonly */
38
+ grip = new XRInputPose();
39
+
40
+ /** @readonly @type {import('./XRInputTypes.js').XRInputSource|null} Set by the device. */
41
+ nativeSource = null;
42
+ /** @type {number[]} */
43
+ #axisValues = [0, 0, 0, 0];
44
+
45
+ /** Number of native entries, excluding controls materialised for bindings. */
46
+ buttonCount = 0;
47
+ axisCount = 0;
48
+
49
+ constructor() {
50
+ this.getButton(3);
51
+ this.getAxis(3);
52
+ }
53
+
54
+ get connected() { return this.nativeSource !== null; }
55
+ get handedness() { return this.nativeSource === null ? 'none' : this.nativeSource.handedness; }
56
+ get targetRayMode() { return this.nativeSource === null ? '' : this.nativeSource.targetRayMode; }
57
+ /** @returns {ReadonlyArray<string>} */
58
+ get profiles() { return this.nativeSource === null ? NO_PROFILES : this.nativeSource.profiles; }
59
+
60
+ /** @param {number} index @returns {XRInputButton} */
61
+ getButton(index) {
62
+ assert.isNonNegativeInteger(index, 'index');
63
+ while (this.buttons.length <= index) {
64
+ this.buttons.push(new XRInputButton());
65
+ }
66
+ return this.buttons[index];
67
+ }
68
+
69
+ /** @param {number} index @returns {Vector1} */
70
+ getAxis(index) {
71
+ assert.isNonNegativeInteger(index, 'index');
72
+ while (this.axes.length <= index) {
73
+ this.axes.push(new Vector1());
74
+ }
75
+ return this.axes[index];
76
+ }
77
+
78
+ /** @internal @param {import('./XRInputTypes.js').XRInputSource|null} source */
79
+ bind(source) {
80
+ if (this.nativeSource === source) {
81
+ return;
82
+ }
83
+ this.nativeSource = null;
84
+ this.clear();
85
+ this.flush();
86
+ this.thumbstick.forgetCalibration();
87
+ this.nativeSource = source;
88
+ }
89
+
90
+ /**
91
+ * @internal Sample values and poses before publishing raw switch edges.
92
+ * @param {import('./XRInputTypes.js').XRFrame|null} frame
93
+ * @param {EventTarget|null} referenceSpace
94
+ */
95
+ sample(frame, referenceSpace) {
96
+ const source = this.nativeSource;
97
+ if (source === null) {
98
+ return;
99
+ }
100
+ // A source/visibility notification has no pose frame. Preserve the last sample in that case;
101
+ // only an actual unavailable pose, a reference-space change or cleanup invalidates it.
102
+ if (frame !== null) {
103
+ const ray = referenceSpace !== null ? frame.getPose(source.targetRaySpace, referenceSpace) ?? null : null;
104
+ const grip = referenceSpace !== null && source.gripSpace != null
105
+ ? frame.getPose(source.gripSpace, referenceSpace) ?? null : null;
106
+ this.targetRay.update(ray);
107
+ this.grip.update(grip);
108
+ }
109
+
110
+ const gamepad = source.gamepad;
111
+ const mapped = gamepad != null && gamepad.mapping === 'xr-standard';
112
+ this.buttonCount = gamepad == null ? 0 : gamepad.buttons.length;
113
+ this.axisCount = gamepad == null ? 0 : gamepad.axes.length;
114
+ if (this.buttonCount > 0) {
115
+ this.getButton(this.buttonCount - 1);
116
+ }
117
+ if (this.axisCount > 0) {
118
+ this.getAxis(this.axisCount - 1);
119
+ }
120
+ for (let i = 0; i < this.buttons.length; i++) {
121
+ this.buttons[i].update(i < this.buttonCount ? gamepad.buttons[i] : undefined);
122
+ }
123
+ for (let i = 0; i < this.axes.length; i++) {
124
+ const value = i < this.axisCount ? gamepad.axes[i] : 0;
125
+ this.#axisValues[i] = value;
126
+ this.axes[i].set(value);
127
+ }
128
+ if (mapped) {
129
+ this.touchpad.set(this.#axisValues[0], this.#axisValues[1]);
130
+ this.thumbstick.update(this.#axisValues);
131
+ } else {
132
+ this.touchpad.set(0, 0);
133
+ this.thumbstick.reset();
134
+ }
135
+ this.select.update(mapped && this.buttonCount > 0 ? XRInputValueSource.Gamepad : XRInputValueSource.Action, this.buttons[0].x);
136
+ this.squeeze.update(mapped && this.buttonCount > 1 ? XRInputValueSource.Gamepad : XRInputValueSource.Action, this.buttons[1].x);
137
+ }
138
+
139
+ /** @internal Tracking loss does not imply release or cancellation. */
140
+ invalidatePoses() {
141
+ this.targetRay.update(null);
142
+ this.grip.update(null);
143
+ }
144
+
145
+ /** @internal Neutralise everything before switch releases and cancellation callbacks. */
146
+ clear() {
147
+ this.invalidatePoses();
148
+ this.buttonCount = 0;
149
+ this.axisCount = 0;
150
+ for (let i = 0; i < this.buttons.length; i++) {
151
+ this.buttons[i].update(undefined);
152
+ }
153
+ for (let i = 0; i < this.axes.length; i++) {
154
+ this.axes[i].set(0);
155
+ this.#axisValues[i] = 0;
156
+ }
157
+ this.touchpad.set(0, 0);
158
+ this.thumbstick.reset();
159
+ this.select.reset();
160
+ this.squeeze.reset();
161
+ }
162
+
163
+ /** @internal */
164
+ flush() {
165
+ for (let i = 0; i < this.buttons.length; i++) {
166
+ this.buttons[i].flushSwitches();
167
+ }
168
+ this.select.flushCancellation();
169
+ this.squeeze.flushCancellation();
170
+ }
171
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * A copied pose in the device's configured reference space. The device owns mutation.
3
+ * valid must be checked before use; an unavailable pose is cleared, not presented as valid identity.
4
+ * Target-ray forward is local -Z, regardless of a game's own forward convention.
5
+ */
6
+ export class XRInputPose {
7
+ /** @readonly */
8
+ readonly position: Vector3;
9
+ /** @readonly */
10
+ readonly rotation: Quaternion;
11
+ /** @type {boolean} */
12
+ valid: boolean;
13
+ /** @type {boolean} */
14
+ emulatedPosition: boolean;
15
+ /**
16
+ * @internal
17
+ * @param {import("./XRInputTypes.js").XRPose|null} pose
18
+ */
19
+ update(pose: import("./XRInputTypes.js").XRPose | null): void;
20
+ }
21
+ import Vector3 from "../../../../core/geom/Vector3.js";
22
+ import Quaternion from "../../../../core/geom/Quaternion.js";
23
+ //# sourceMappingURL=XRInputPose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRInputPose.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputPose.js"],"names":[],"mappings":"AAGA;;;;GAIG;AACH;IACI,gBAAgB;IAChB,2BAAyB;IACzB,gBAAgB;IAChB,8BAA4B;IAC5B,sBAAsB;IACtB,OADW,OAAO,CACJ;IACd,sBAAsB;IACtB,kBADW,OAAO,CACO;IAEzB;;;OAGG;IACH,aAFW,OAAO,mBAAmB,EAAE,MAAM,GAAC,IAAI,QAcjD;CACJ;oBAlCmB,kCAAkC;uBAD/B,qCAAqC"}
@@ -0,0 +1,36 @@
1
+ import Quaternion from "../../../../core/geom/Quaternion.js";
2
+ import Vector3 from "../../../../core/geom/Vector3.js";
3
+
4
+ /**
5
+ * A copied pose in the device's configured reference space. The device owns mutation.
6
+ * valid must be checked before use; an unavailable pose is cleared, not presented as valid identity.
7
+ * Target-ray forward is local -Z, regardless of a game's own forward convention.
8
+ */
9
+ export class XRInputPose {
10
+ /** @readonly */
11
+ position = new Vector3();
12
+ /** @readonly */
13
+ rotation = new Quaternion();
14
+ /** @type {boolean} */
15
+ valid = false;
16
+ /** @type {boolean} */
17
+ emulatedPosition = false;
18
+
19
+ /**
20
+ * @internal
21
+ * @param {import("./XRInputTypes.js").XRPose|null} pose
22
+ */
23
+ update(pose) {
24
+ this.valid = pose !== null;
25
+ this.emulatedPosition = pose !== null && pose.emulatedPosition;
26
+ if (pose === null) {
27
+ this.position.set(0, 0, 0);
28
+ this.rotation.set(0, 0, 0, 1);
29
+ } else {
30
+ const p = pose.transform.position;
31
+ const q = pose.transform.orientation;
32
+ this.position.set(p.x, p.y, p.z);
33
+ this.rotation.set(q.x, q.y, q.z, q.w);
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
3
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
4
+ * in every consumer of Engine's generated declarations.
5
+ */
6
+ export type XRGamepad = {
7
+ mapping: string;
8
+ buttons: ReadonlyArray<{
9
+ value: number;
10
+ pressed: boolean;
11
+ touched: boolean;
12
+ }>;
13
+ axes: ReadonlyArray<number>;
14
+ };
15
+ /**
16
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
17
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
18
+ * in every consumer of Engine's generated declarations.
19
+ */
20
+ export type XRInputSource = {
21
+ handedness: string;
22
+ targetRayMode: string;
23
+ profiles: ReadonlyArray<string>;
24
+ targetRaySpace: EventTarget;
25
+ gripSpace?: EventTarget | null;
26
+ gamepad?: XRGamepad | null;
27
+ };
28
+ /**
29
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
30
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
31
+ * in every consumer of Engine's generated declarations.
32
+ */
33
+ export type XRSession = EventTarget & {
34
+ readonly inputSources: ArrayLike<XRInputSource>;
35
+ readonly visibilityState: string;
36
+ };
37
+ /**
38
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
39
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
40
+ * in every consumer of Engine's generated declarations.
41
+ */
42
+ export type XRPose = {
43
+ transform: {
44
+ position: {
45
+ x: number;
46
+ y: number;
47
+ z: number;
48
+ };
49
+ orientation: {
50
+ x: number;
51
+ y: number;
52
+ z: number;
53
+ w: number;
54
+ };
55
+ };
56
+ emulatedPosition: boolean;
57
+ };
58
+ /**
59
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
60
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
61
+ * in every consumer of Engine's generated declarations.
62
+ */
63
+ export type XRFrame = {
64
+ session: XRSession;
65
+ getPose: (space: EventTarget, baseSpace: EventTarget) => XRPose | null | undefined;
66
+ };
67
+ /**
68
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
69
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
70
+ * in every consumer of Engine's generated declarations.
71
+ */
72
+ export type XRSessionInputEvent = Event & {
73
+ inputSource?: XRInputSource;
74
+ frame?: XRFrame;
75
+ };
76
+ //# sourceMappingURL=XRInputTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRInputTypes.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputTypes.js"],"names":[],"mappings":";;;;;;aAMc,MAAM;aACN,cAAc;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAC,CAAC;UAClE,cAAc,MAAM,CAAC;;;;;;;;gBAGrB,MAAM;mBACN,MAAM;cACN,cAAc,MAAM,CAAC;oBACrB,WAAW;gBACX,WAAW,GAAC,IAAI;cAChB,SAAS,GAAC,IAAI;;;;;;;wBAEf,WAAW,GAAG;IAAC,QAAQ,CAAC,YAAY,EAAE,UAAU,aAAa,CAAC,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CAAC;;;;;;;eAGhG;QAAC,QAAQ,EAAE;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAC,CAAC;QAAC,WAAW,EAAE;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAC;YAAC,CAAC,EAAE,MAAM,CAAA;SAAC,CAAA;KAAC;sBACxG,OAAO;;;;;;;;aAGP,SAAS;aACT,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,KAAK,MAAM,GAAC,IAAI,GAAC,SAAS;;;;;;;kCAEtE,KAAK,GAAG;IAAC,WAAW,CAAC,EAAE,aAAa,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Structural subsets of WebXR used by the input boundary. Native WebXR objects satisfy these types;
3
+ * keeping the boundary structural also permits headless hosts and avoids requiring ambient XR globals
4
+ * in every consumer of Engine's generated declarations.
5
+ *
6
+ * @typedef {object} XRGamepad
7
+ * @property {string} mapping
8
+ * @property {ReadonlyArray<{value: number, pressed: boolean, touched: boolean}>} buttons
9
+ * @property {ReadonlyArray<number>} axes
10
+ *
11
+ * @typedef {object} XRInputSource
12
+ * @property {string} handedness
13
+ * @property {string} targetRayMode
14
+ * @property {ReadonlyArray<string>} profiles
15
+ * @property {EventTarget} targetRaySpace
16
+ * @property {EventTarget|null} [gripSpace]
17
+ * @property {XRGamepad|null} [gamepad]
18
+ *
19
+ * @typedef {EventTarget & {readonly inputSources: ArrayLike<XRInputSource>, readonly visibilityState: string}} XRSession
20
+ *
21
+ * @typedef {object} XRPose
22
+ * @property {{position: {x: number, y: number, z: number}, orientation: {x: number, y: number, z: number, w: number}}} transform
23
+ * @property {boolean} emulatedPosition
24
+ *
25
+ * @typedef {object} XRFrame
26
+ * @property {XRSession} session
27
+ * @property {(space: EventTarget, baseSpace: EventTarget) => XRPose|null|undefined} getPose
28
+ *
29
+ * @typedef {Event & {inputSource?: XRInputSource, frame?: XRFrame}} XRSessionInputEvent
30
+ */
31
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Where an XR action's scalar comes from. Gamepad means a native button value, which may itself be
3
+ * digital. Action means an event-derived 0/1 value, not a measurement of pressure.
4
+ */
5
+ export type XRInputValueSource = number;
6
+ export namespace XRInputValueSource {
7
+ let Unavailable: number;
8
+ let Gamepad: number;
9
+ let Action: number;
10
+ }
11
+ //# sourceMappingURL=XRInputValueSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XRInputValueSource.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/input/devices/xr/XRInputValueSource.js"],"names":[],"mappings":";;;;iCAIU,MAAM"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Where an XR action's scalar comes from. Gamepad means a native button value, which may itself be
3
+ * digital. Action means an event-derived 0/1 value, not a measurement of pressure.
4
+ * @readonly
5
+ * @enum {number}
6
+ */
7
+ export const XRInputValueSource = {
8
+ Unavailable: 0,
9
+ Gamepad: 1,
10
+ Action: 2
11
+ };
@@ -1,3 +1,11 @@
1
+ /**
2
+ * @typedef {import('./InputCoordinateChannelType.js').InputCoordinateChannelType} InputCoordinateChannelType
3
+ * @typedef {import('../InputSourceTable.js').InputSourceTable} InputSourceTable
4
+ * @typedef {import('../device/InputDeviceAdapter.js').InputDeviceAdapter} InputDeviceAdapter
5
+ * @typedef {import('../InputSource.js').InputSource} InputSource
6
+ * @typedef {import('../trigger/InputTrigger.js').InputTrigger} InputTrigger
7
+ * @typedef {import('../../../../../core/binary/BitSet.js').BitSet} BitSet
8
+ */
1
9
  /**
2
10
  * An N-dimensional analog channel an action can be bound to.
3
11
  *
@@ -16,7 +24,7 @@ export class InputCoordinateChannel {
16
24
  /**
17
25
  * @returns {InputCoordinateChannelType}
18
26
  */
19
- get type(): InputCoordinateChannelType;
27
+ get type(): number;
20
28
  /**
21
29
  * Component count.
22
30
  * @returns {number}
@@ -64,4 +72,10 @@ export class InputCoordinateChannel {
64
72
  */
65
73
  hash(): number;
66
74
  }
75
+ export type InputCoordinateChannelType = import('./InputCoordinateChannelType.js').InputCoordinateChannelType;
76
+ export type InputSourceTable = import('../InputSourceTable.js').InputSourceTable;
77
+ export type InputDeviceAdapter = import('../device/InputDeviceAdapter.js').InputDeviceAdapter;
78
+ export type InputSource = import('../InputSource.js').InputSource;
79
+ export type InputTrigger = import('../trigger/InputTrigger.js').InputTrigger;
80
+ export type BitSet = import('../../../../../core/binary/BitSet.js').BitSet;
67
81
  //# sourceMappingURL=InputCoordinateChannel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputCoordinateChannel.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH;IAEI;;OAEG;IACH,uCAEC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;;;OAMG;IACH,2CAFW,IAAI,MAAM,qBAAqB,QAIzC;IAED;;OAEG;IACH,uBAFW,aAAa,QAIvB;IAED;;;;;;;;OAQG;IACH,wBAFW,cAAc,QAIxB;IAED;;;;OAIG;IACH,aAJW,MAAM,EAAE,GAAC,YAAY,UACrB,MAAM,sBAKhB;IAED;;OAEG;IACH,SAFa,sBAAsB,CAIlC;IAED;;;OAGG;IACH,cAHW,sBAAsB,GACpB,OAAO,CAInB;IAED;;OAEG;IACH,QAFa,MAAM,CAIlB;CACJ"}
1
+ {"version":3,"file":"InputCoordinateChannel.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/coordinate/InputCoordinateChannel.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;GAaG;AACH;IAEI;;OAEG;IACH,mBAEC;IAED;;;OAGG;IACH,yBAEC;IAED;;;;;;OAMG;IACH,eAHW,gBAAgB,YAChB,IAAI,MAAM,EAAE,kBAAkB,CAAC,QAIzC;IAED;;OAEG;IACH,uBAFW,WAAW,EAAE,QAIvB;IAED;;;;;;;;OAQG;IACH,wBAFW,YAAY,EAAE,QAIxB;IAED;;;;OAIG;IACH,aAJW,MAAM,EAAE,GAAC,YAAY,UACrB,MAAM,QACN,MAAM,QAIhB;IAED;;OAEG;IACH,SAFa,sBAAsB,CAIlC;IAED;;;OAGG;IACH,cAHW,sBAAsB,GACpB,OAAO,CAInB;IAED;;OAEG;IACH,QAFa,MAAM,CAIlB;CACJ;yCApGY,OAAO,iCAAiC,EAAE,0BAA0B;+BACpE,OAAO,wBAAwB,EAAE,gBAAgB;iCACjD,OAAO,iCAAiC,EAAE,kBAAkB;0BAC5D,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,4BAA4B,EAAE,YAAY;qBACjD,OAAO,sCAAsC,EAAE,MAAM"}
@@ -1,3 +1,12 @@
1
+ /**
2
+ * @typedef {import('./InputCoordinateChannelType.js').InputCoordinateChannelType} InputCoordinateChannelType
3
+ * @typedef {import('../InputSourceTable.js').InputSourceTable} InputSourceTable
4
+ * @typedef {import('../device/InputDeviceAdapter.js').InputDeviceAdapter} InputDeviceAdapter
5
+ * @typedef {import('../InputSource.js').InputSource} InputSource
6
+ * @typedef {import('../trigger/InputTrigger.js').InputTrigger} InputTrigger
7
+ * @typedef {import('../../../../../core/binary/BitSet.js').BitSet} BitSet
8
+ */
9
+
1
10
  /**
2
11
  * An N-dimensional analog channel an action can be bound to.
3
12
  *
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @typedef {import('../InputSourceTable.js').InputSourceTable} InputSourceTable
3
+ * @typedef {import('../device/InputDeviceAdapter.js').InputDeviceAdapter} InputDeviceAdapter
4
+ * @typedef {import('../../../../../core/binary/BitSet.js').BitSet} BitSet
5
+ */
1
6
  /**
2
7
  * A channel read straight from a device.
3
8
  *
@@ -23,6 +28,13 @@ export class InputCoordinateDevice extends InputCoordinateChannel {
23
28
  * @returns {InputCoordinateDevice}
24
29
  */
25
30
  static fromGamepad(code: number): InputCoordinateDevice;
31
+ /**
32
+ * Select/squeeze and raw buttons/axes are scalar; thumbstick/touchpad have two components.
33
+ * @param {'left'|'right'|'none'} handedness
34
+ * @param {number} code XRInputCoordinates or xr_input_button_coordinate/xr_input_axis_coordinate.
35
+ * @returns {InputCoordinateDevice}
36
+ */
37
+ static fromXR(handedness: 'left' | 'right' | 'none', code: number): InputCoordinateDevice;
26
38
  /**
27
39
  * A pointer channel. `position` is 2-D absolute; `move` is 2-D and `wheel` is 3-D, both relative and
28
40
  * both LATCHED once per frame - a reader sees the total that arrived since the previous frame, and sees
@@ -36,16 +48,15 @@ export class InputCoordinateDevice extends InputCoordinateChannel {
36
48
  * @type {InputCoordinateSource}
37
49
  */
38
50
  source: InputCoordinateSource;
39
- /**
40
- * @returns {InputCoordinateChannelType}
41
- */
42
- get type(): number;
43
51
  /**
44
52
  * @returns {InputCoordinateDevice}
45
53
  */
46
54
  clone(): InputCoordinateDevice;
47
55
  #private;
48
56
  }
57
+ export type InputSourceTable = import('../InputSourceTable.js').InputSourceTable;
58
+ export type InputDeviceAdapter = import('../device/InputDeviceAdapter.js').InputDeviceAdapter;
59
+ export type BitSet = import('../../../../../core/binary/BitSet.js').BitSet;
49
60
  import { InputCoordinateChannel } from "./InputCoordinateChannel.js";
50
61
  import { InputCoordinateSource } from "../InputCoordinateSource.js";
51
62
  //# sourceMappingURL=InputCoordinateDevice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputCoordinateDevice.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;GAWG;AACH;IA2BI;;;OAGG;IACH,0BAHW,qBAAqB,GACnB,qBAAqB,CAUjC;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAQjC;IAED;;;;;;;OAOG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAajC;IAxED;;OAEG;IACH,QAFU,qBAAqB,CAEM;IAQrC;;OAEG;IACH,mBAEC;IAyFD;;OAEG;IACH,SAFa,qBAAqB,CAIjC;;CAiBJ;uCAjJsC,6BAA6B;sCAD9B,6BAA6B"}
1
+ {"version":3,"file":"InputCoordinateDevice.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/input/ecs/ism/coordinate/InputCoordinateDevice.js"],"names":[],"mappings":"AAaA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH;IA2BI;;;OAGG;IACH,0BAHW,qBAAqB,GACnB,qBAAqB,CAUjC;IAED;;;;;OAKG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAQjC;IAED;;;;;OAKG;IACH,0BAJW,MAAM,GAAC,OAAO,GAAC,MAAM,QACrB,MAAM,GACJ,qBAAqB,CAQjC;IAED;;;;;;;OAOG;IACH,yBAHW,MAAM,GACJ,qBAAqB,CAajC;IAtFD;;OAEG;IACH,QAFU,qBAAqB,CAEM;IAoHrC;;OAEG;IACH,SAFa,qBAAqB,CAIjC;;CAiBJ;+BAhKY,OAAO,wBAAwB,EAAE,gBAAgB;iCACjD,OAAO,iCAAiC,EAAE,kBAAkB;qBAC5D,OAAO,sCAAsC,EAAE,MAAM;uCAP3B,6BAA6B;sCAD9B,6BAA6B"}