@galacean/engine-xr 1.2.0-alpha.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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -0
  3. package/dist/browser.js +1573 -0
  4. package/dist/browser.min.js +1 -0
  5. package/dist/main.js +1570 -0
  6. package/dist/main.js.map +1 -0
  7. package/dist/miniprogram.js +1570 -0
  8. package/dist/module.js +1555 -0
  9. package/dist/module.js.map +1 -0
  10. package/package.json +35 -0
  11. package/types/XRManagerExtended.d.ts +119 -0
  12. package/types/XRPose.d.ts +15 -0
  13. package/types/feature/XRFeature.d.ts +16 -0
  14. package/types/feature/XRFeatureType.d.ts +6 -0
  15. package/types/feature/camera/XRCameraManager.d.ts +26 -0
  16. package/types/feature/hitTest/TrackableType.d.ts +10 -0
  17. package/types/feature/hitTest/XRHitResult.d.ts +19 -0
  18. package/types/feature/hitTest/XRHitTest.d.ts +40 -0
  19. package/types/feature/trackable/XRRequestTracking.d.ts +1 -0
  20. package/types/feature/trackable/XRRequestTrackingState.d.ts +8 -0
  21. package/types/feature/trackable/XRTrackableFeature.d.ts +36 -0
  22. package/types/feature/trackable/XRTracked.d.ts +14 -0
  23. package/types/feature/trackable/anchor/XRAnchor.d.ts +6 -0
  24. package/types/feature/trackable/anchor/XRAnchorTracking.d.ts +38 -0
  25. package/types/feature/trackable/anchor/XRRequestAnchor.d.ts +16 -0
  26. package/types/feature/trackable/image/XRImageTracking.d.ts +25 -0
  27. package/types/feature/trackable/image/XRReferenceImage.d.ts +16 -0
  28. package/types/feature/trackable/image/XRRequestImage.d.ts +14 -0
  29. package/types/feature/trackable/image/XRTrackedImage.d.ts +12 -0
  30. package/types/feature/trackable/plane/XRPlaneMode.d.ts +13 -0
  31. package/types/feature/trackable/plane/XRPlaneTracking.d.ts +24 -0
  32. package/types/feature/trackable/plane/XRRequestPlane.d.ts +13 -0
  33. package/types/feature/trackable/plane/XRTrackedPlane.d.ts +21 -0
  34. package/types/index.d.ts +28 -0
  35. package/types/input/XRCamera.d.ts +15 -0
  36. package/types/input/XRController.d.ts +38 -0
  37. package/types/input/XRInput.d.ts +8 -0
  38. package/types/input/XRInputButton.d.ts +19 -0
  39. package/types/input/XRInputEventType.d.ts +8 -0
  40. package/types/input/XRInputManager.d.ts +32 -0
  41. package/types/input/XRTargetRayMode.d.ts +5 -0
  42. package/types/input/XRTrackedInputDevice.d.ts +21 -0
  43. package/types/input/XRTrackingState.d.ts +11 -0
  44. package/types/session/XRSessionManager.d.ts +45 -0
  45. package/types/session/XRSessionMode.d.ts +8 -0
  46. package/types/session/XRSessionState.d.ts +13 -0
@@ -0,0 +1,1573 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@galacean/engine')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@galacean/engine'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.Galacean = global.Galacean || {}, global.Galacean.XR = {}), global.Galacean));
5
+ })(this, (function (exports, engine) { 'use strict';
6
+
7
+ function _is_native_reflect_construct() {
8
+ if (typeof Reflect === "undefined" || !Reflect.construct) return false;
9
+ if (Reflect.construct.sham) return false;
10
+ if (typeof Proxy === "function") return true;
11
+
12
+ try {
13
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
14
+
15
+ return true;
16
+ } catch (e) {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ function _set_prototype_of(o, p) {
22
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
23
+ o.__proto__ = p;
24
+
25
+ return o;
26
+ };
27
+
28
+ return _set_prototype_of(o, p);
29
+ }
30
+
31
+ function _construct(Parent, args, Class) {
32
+ if (_is_native_reflect_construct()) _construct = Reflect.construct;
33
+ else {
34
+ _construct = function construct(Parent, args, Class) {
35
+ var a = [null];
36
+ a.push.apply(a, args);
37
+ var Constructor = Function.bind.apply(Parent, a);
38
+ var instance = new Constructor();
39
+
40
+ if (Class) _set_prototype_of(instance, Class.prototype);
41
+
42
+ return instance;
43
+ };
44
+ }
45
+
46
+ return _construct.apply(null, arguments);
47
+ }
48
+
49
+ function _defineProperties(target, props) {
50
+ for (var i = 0; i < props.length; i++) {
51
+ var descriptor = props[i];
52
+ descriptor.enumerable = descriptor.enumerable || false;
53
+ descriptor.configurable = true;
54
+
55
+ if ("value" in descriptor) descriptor.writable = true;
56
+
57
+ Object.defineProperty(target, descriptor.key, descriptor);
58
+ }
59
+ }
60
+ function _create_class(Constructor, protoProps, staticProps) {
61
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
62
+ if (staticProps) _defineProperties(Constructor, staticProps);
63
+
64
+ return Constructor;
65
+ }
66
+
67
+ function _inherits(subClass, superClass) {
68
+ if (typeof superClass !== "function" && superClass !== null) {
69
+ throw new TypeError("Super expression must either be null or a function");
70
+ }
71
+
72
+ subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });
73
+
74
+ if (superClass) _set_prototype_of(subClass, superClass);
75
+ }
76
+
77
+ function _instanceof(left, right) {
78
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
79
+ return !!right[Symbol.hasInstance](left);
80
+ } else return left instanceof right;
81
+ }
82
+
83
+ /**
84
+ * Enumerates some input devices that can be tracked.(including status, posture and other information)
85
+ */ exports.XRTrackedInputDevice = void 0;
86
+ (function(XRTrackedInputDevice) {
87
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Controller */ "Controller"] = 0] = "Controller";
88
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Left controller */ "LeftController"] = 1] = "LeftController";
89
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Right controller */ "RightController"] = 2] = "RightController";
90
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Camera */ "Camera"] = 3] = "Camera";
91
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Left camera */ "LeftCamera"] = 4] = "LeftCamera";
92
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Right camera */ "RightCamera"] = 5] = "RightCamera";
93
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Head */ "LeftHand"] = 6] = "LeftHand";
94
+ XRTrackedInputDevice[XRTrackedInputDevice[/** Right hand */ "RightHand"] = 7] = "RightHand";
95
+ })(exports.XRTrackedInputDevice || (exports.XRTrackedInputDevice = {}));
96
+
97
+ /**
98
+ * The state of an XRSession.
99
+ */ exports.XRSessionState = void 0;
100
+ (function(XRSessionState) {
101
+ XRSessionState[XRSessionState[/** Not initialized. */ "None"] = 0] = "None";
102
+ XRSessionState[XRSessionState[/** Initialized but not started. */ "Initialized"] = 1] = "Initialized";
103
+ XRSessionState[XRSessionState[/** Running. */ "Running"] = 2] = "Running";
104
+ XRSessionState[XRSessionState[/** Paused. */ "Paused"] = 3] = "Paused";
105
+ })(exports.XRSessionState || (exports.XRSessionState = {}));
106
+
107
+ /**
108
+ * The manager of XR camera.
109
+ */ var XRCameraManager = /*#__PURE__*/ function() {
110
+ function XRCameraManager(_xrManager) {
111
+ this._xrManager = _xrManager;
112
+ }
113
+ var _proto = XRCameraManager.prototype;
114
+ /**
115
+ * Attach the camera to the specified input type(Camera, LeftCamera or RightCamera).
116
+ * The camera entity need to be moved to the XROrigin entity.
117
+ * @param type - The input type
118
+ * @param camera - The camera to be attached
119
+ */ _proto.attachCamera = function attachCamera(type, camera) {
120
+ var xrCamera = this._xrManager.inputManager.getTrackedDevice(type);
121
+ var preCamera = xrCamera._camera;
122
+ if (preCamera !== camera) {
123
+ // @ts-ignore
124
+ preCamera && (preCamera._cameraType = engine.CameraType.Normal);
125
+ switch(type){
126
+ case exports.XRTrackedInputDevice.Camera:
127
+ // @ts-ignore
128
+ camera._cameraType = engine.CameraType.XRCenterCamera;
129
+ break;
130
+ case exports.XRTrackedInputDevice.LeftCamera:
131
+ // @ts-ignore
132
+ camera._cameraType = engine.CameraType.XRLeftCamera;
133
+ break;
134
+ case exports.XRTrackedInputDevice.RightCamera:
135
+ // @ts-ignore
136
+ camera._cameraType = engine.CameraType.XRRightCamera;
137
+ break;
138
+ }
139
+ xrCamera._camera = camera;
140
+ }
141
+ };
142
+ /**
143
+ * Detach the camera from the specified input type.
144
+ * @param type - The input type
145
+ * @returns The camera that was detached
146
+ */ _proto.detachCamera = function detachCamera(type) {
147
+ var xrCamera = this._xrManager.inputManager.getTrackedDevice(type);
148
+ var preCamera = xrCamera._camera;
149
+ // @ts-ignore
150
+ preCamera && (preCamera._cameraType = engine.CameraType.Normal);
151
+ xrCamera._camera = null;
152
+ return preCamera;
153
+ };
154
+ /**
155
+ * @internal
156
+ */ _proto._onSessionStart = function _onSessionStart() {};
157
+ /**
158
+ * @internal
159
+ */ _proto._onUpdate = function _onUpdate() {
160
+ var _this__xrManager_inputManager = this._xrManager.inputManager, cameras = _this__xrManager_inputManager._cameras;
161
+ for(var i = 0, n = cameras.length; i < n; i++){
162
+ var cameraDevice = cameras[i];
163
+ var camera = cameraDevice._camera;
164
+ if (!camera) continue;
165
+ // sync position and rotation
166
+ var transform = camera.entity.transform;
167
+ var pose = cameraDevice.pose;
168
+ transform.position = pose.position;
169
+ transform.rotationQuaternion = pose.rotation;
170
+ // sync viewport
171
+ var viewport = camera.viewport;
172
+ var _cameraDevice_viewport = cameraDevice.viewport, x = _cameraDevice_viewport.x, y = _cameraDevice_viewport.y, width = _cameraDevice_viewport.width, height = _cameraDevice_viewport.height;
173
+ if (!(x === viewport.x && y === viewport.y && width === viewport.z && height === viewport.w)) {
174
+ camera.viewport = viewport.set(x, y, width, height);
175
+ }
176
+ // sync project matrix
177
+ if (!engine.Matrix.equals(camera.projectionMatrix, cameraDevice.projectionMatrix)) {
178
+ camera.projectionMatrix = cameraDevice.projectionMatrix;
179
+ }
180
+ }
181
+ };
182
+ /**
183
+ * @internal
184
+ */ _proto._onSessionExit = function _onSessionExit() {};
185
+ /**
186
+ * @internal
187
+ */ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(cameraType) {
188
+ if (cameraType === engine.CameraType.XRCenterCamera) {
189
+ if (this._xrManager.sessionManager.state === exports.XRSessionState.Running) {
190
+ return engine.CameraClearFlags.Color;
191
+ } else {
192
+ return engine.CameraClearFlags.None;
193
+ }
194
+ } else {
195
+ return engine.CameraClearFlags.None;
196
+ }
197
+ };
198
+ /**
199
+ * @internal
200
+ */ _proto._onDestroy = function _onDestroy() {};
201
+ _create_class(XRCameraManager, [
202
+ {
203
+ key: "fixedFoveation",
204
+ get: /**
205
+ * The fixed foveation of the camera.
206
+ */ function get() {
207
+ var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
208
+ if (platformSession) {
209
+ return platformSession.getFixedFoveation();
210
+ } else {
211
+ throw new Error("XR session is not available.");
212
+ }
213
+ },
214
+ set: function set(value) {
215
+ var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
216
+ if (platformSession) {
217
+ platformSession.setFixedFoveation(value);
218
+ } else {
219
+ throw new Error("XR session is not available.");
220
+ }
221
+ }
222
+ }
223
+ ]);
224
+ return XRCameraManager;
225
+ }();
226
+
227
+ /**
228
+ * Data for describing pose in the XR space.
229
+ */ var XRPose = function XRPose() {
230
+ /** The position of the pose in XR space. */ this.position = new engine.Vector3();
231
+ /** The rotation of the pose in XR space. */ this.rotation = new engine.Quaternion();
232
+ /** The matrix of the pose in XR space. */ this.matrix = new engine.Matrix();
233
+ /** The inverse matrix of the pose in XR space. */ this.inverseMatrix = new engine.Matrix();
234
+ };
235
+
236
+ /**
237
+ * Enum for XR tracking state.
238
+ */ exports.XRTrackingState = void 0;
239
+ (function(XRTrackingState) {
240
+ XRTrackingState[XRTrackingState[/** Not tracking */ "NotTracking"] = 0] = "NotTracking";
241
+ XRTrackingState[XRTrackingState[/** Tracking */ "Tracking"] = 1] = "Tracking";
242
+ XRTrackingState[XRTrackingState[/** Lost track */ "TrackingLost"] = 2] = "TrackingLost";
243
+ })(exports.XRTrackingState || (exports.XRTrackingState = {}));
244
+
245
+ var XRInput = function XRInput(type) {
246
+ this.type = type;
247
+ this./** The tracking state of xr input. */ trackingState = exports.XRTrackingState.NotTracking;
248
+ };
249
+
250
+ /**
251
+ * The XR camera.
252
+ */ var XRCamera = /*#__PURE__*/ function(XRInput1) {
253
+ _inherits(XRCamera, XRInput1);
254
+ function XRCamera() {
255
+ var _this;
256
+ _this = XRInput1.apply(this, arguments) || this;
257
+ /** The pose of the camera in XR space. */ _this.pose = new XRPose();
258
+ /** The viewport of the camera. */ _this.viewport = new engine.Rect();
259
+ /** The projection matrix of the camera. */ _this.projectionMatrix = new engine.Matrix();
260
+ return _this;
261
+ }
262
+ return XRCamera;
263
+ }(XRInput);
264
+
265
+ /**
266
+ * Enum for XR input button.
267
+ */ exports.XRInputButton = void 0;
268
+ (function(XRInputButton) {
269
+ XRInputButton[XRInputButton[/** None */ "None"] = 0x0] = "None";
270
+ XRInputButton[XRInputButton[/** Select */ "Select"] = 0x1] = "Select";
271
+ XRInputButton[XRInputButton[/** Select */ "Trigger"] = 0x1] = "Trigger";
272
+ XRInputButton[XRInputButton[/** Squeeze */ "Squeeze"] = 0x2] = "Squeeze";
273
+ XRInputButton[XRInputButton[/** TouchPad */ "TouchPad"] = 0x4] = "TouchPad";
274
+ XRInputButton[XRInputButton[/** A */ "AButton"] = 0x8] = "AButton";
275
+ XRInputButton[XRInputButton[/** B */ "BButton"] = 0x10] = "BButton";
276
+ })(exports.XRInputButton || (exports.XRInputButton = {}));
277
+
278
+ /**
279
+ * The XR controller.
280
+ */ var XRController = /*#__PURE__*/ function(XRInput1) {
281
+ _inherits(XRController, XRInput1);
282
+ function XRController() {
283
+ var _this;
284
+ _this = XRInput1.apply(this, arguments) || this;
285
+ /** The grip space pose of the controller in XR space. */ _this.gripPose = new XRPose();
286
+ /** The target ray space pose of the controller in XR space. */ _this.targetRayPose = new XRPose();
287
+ /** The currently pressed buttons of this controller. */ _this.pressedButtons = exports.XRInputButton.None;
288
+ /** Record button lifted. */ _this.down = exports.XRInputButton.None;
289
+ /** Record button pressed. */ _this.up = exports.XRInputButton.None;
290
+ return _this;
291
+ }
292
+ var _proto = XRController.prototype;
293
+ /**
294
+ *
295
+ * Returns whether the button is pressed.
296
+ * @param button - The button to check
297
+ * @returns Whether the button is pressed
298
+ */ _proto.isButtonDown = function isButtonDown(button) {
299
+ return (this.down & button) !== 0;
300
+ };
301
+ /**
302
+ * Returns whether the button is lifted.
303
+ * @param button - The button to check
304
+ * @returns Whether the button is lifted
305
+ */ _proto.isButtonUp = function isButtonUp(button) {
306
+ return (this.up & button) !== 0;
307
+ };
308
+ /**
309
+ * Returns whether the button is held down.
310
+ * @param button - The button to check
311
+ * @returns Whether the button is held down
312
+ */ _proto.isButtonHeldDown = function isButtonHeldDown(button) {
313
+ return (this.pressedButtons & button) !== 0;
314
+ };
315
+ return XRController;
316
+ }(XRInput);
317
+
318
+ exports.XRInputEventType = void 0;
319
+ (function(XRInputEventType) {
320
+ XRInputEventType[XRInputEventType["SelectStart"] = 0] = "SelectStart";
321
+ XRInputEventType[XRInputEventType["Select"] = 1] = "Select";
322
+ XRInputEventType[XRInputEventType["SelectEnd"] = 2] = "SelectEnd";
323
+ XRInputEventType[XRInputEventType["SqueezeStart"] = 3] = "SqueezeStart";
324
+ XRInputEventType[XRInputEventType["Squeeze"] = 4] = "Squeeze";
325
+ XRInputEventType[XRInputEventType["SqueezeEnd"] = 5] = "SqueezeEnd";
326
+ })(exports.XRInputEventType || (exports.XRInputEventType = {}));
327
+
328
+ exports.XRTargetRayMode = void 0;
329
+ (function(XRTargetRayMode) {
330
+ XRTargetRayMode[XRTargetRayMode["Gaze"] = 0] = "Gaze";
331
+ XRTargetRayMode[XRTargetRayMode["TrackedPointer"] = 1] = "TrackedPointer";
332
+ XRTargetRayMode[XRTargetRayMode["Screen"] = 2] = "Screen";
333
+ })(exports.XRTargetRayMode || (exports.XRTargetRayMode = {}));
334
+
335
+ /**
336
+ * The manager of XR input.
337
+ */ var XRInputManager = /*#__PURE__*/ function() {
338
+ function XRInputManager(_xrManager, _engine) {
339
+ this._xrManager = _xrManager;
340
+ this._engine = _engine;
341
+ this./** @internal */ _cameras = [];
342
+ this./** @internal */ _controllers = [];
343
+ this._added = [];
344
+ this._removed = [];
345
+ this._trackedDevices = [];
346
+ this._statusSnapshot = [];
347
+ this._listeners = [];
348
+ var _this = this, trackedDevices = _this._trackedDevices, controllers = _this._controllers, cameras = _this._cameras;
349
+ for(var i = 0; i < 6; i++){
350
+ switch(i){
351
+ case exports.XRTrackedInputDevice.Camera:
352
+ case exports.XRTrackedInputDevice.LeftCamera:
353
+ case exports.XRTrackedInputDevice.RightCamera:
354
+ cameras.push(trackedDevices[i] = new XRCamera(i));
355
+ break;
356
+ case exports.XRTrackedInputDevice.Controller:
357
+ case exports.XRTrackedInputDevice.LeftController:
358
+ case exports.XRTrackedInputDevice.RightController:
359
+ controllers.push(trackedDevices[i] = new XRController(i));
360
+ break;
361
+ }
362
+ }
363
+ this._statusSnapshot.fill(exports.XRTrackingState.NotTracking, 0, trackedDevices.length);
364
+ }
365
+ var _proto = XRInputManager.prototype;
366
+ /**
367
+ * Returns the tracked device instance.
368
+ * @param type - The tracked input device type
369
+ * @returns The input instance
370
+ */ _proto.getTrackedDevice = function getTrackedDevice(type) {
371
+ return this._trackedDevices[type];
372
+ };
373
+ /**
374
+ * Add a listener for tracked device changes.
375
+ * @param listener - The listener to add
376
+ */ _proto.addTrackedDeviceChangedListener = function addTrackedDeviceChangedListener(listener) {
377
+ this._listeners.push(listener);
378
+ };
379
+ /**
380
+ * Remove a listener of tracked device changes.
381
+ * @param listener - The listener to remove
382
+ */ _proto.removeTrackedDeviceChangedListener = function removeTrackedDeviceChangedListener(listener) {
383
+ var _this = this, listeners = _this._listeners;
384
+ var index = listeners.indexOf(listener);
385
+ if (index >= 0) {
386
+ listeners.splice(index, 1);
387
+ }
388
+ };
389
+ /**
390
+ * @internal
391
+ */ _proto._onUpdate = function _onUpdate() {
392
+ var _this = this, added = _this._added, removed = _this._removed, listeners = _this._listeners, statusSnapshot = _this._statusSnapshot;
393
+ var _this1 = this, trackedDevices = _this1._trackedDevices, controllers = _this1._controllers;
394
+ // Reset data
395
+ added.length = removed.length = 0;
396
+ for(var i = 0, n = controllers.length; i < n; i++){
397
+ var controller = controllers[i];
398
+ controller.down = controller.up = 0;
399
+ }
400
+ // Handle events and update tracked devices
401
+ var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
402
+ var platformEvents = platformSession.events;
403
+ for(var i1 = 0, n1 = platformEvents.length; i1 < n1; i1++){
404
+ this._handleEvent(platformEvents[i1]);
405
+ }
406
+ platformSession.resetEvents();
407
+ platformSession.frame.updateInputs(trackedDevices);
408
+ for(var i2 = 0, n2 = trackedDevices.length; i2 < n2; i2++){
409
+ var input = trackedDevices[i2];
410
+ if (!input) continue;
411
+ var nowState = input.trackingState;
412
+ if (statusSnapshot[i2] === exports.XRTrackingState.Tracking) {
413
+ if (nowState !== exports.XRTrackingState.Tracking) {
414
+ removed.push(input);
415
+ }
416
+ } else {
417
+ if (nowState === exports.XRTrackingState.Tracking) {
418
+ added.push(input);
419
+ }
420
+ }
421
+ statusSnapshot[i2] = nowState;
422
+ }
423
+ // Dispatch change event
424
+ if (added.length > 0 || removed.length > 0) {
425
+ for(var i3 = 0, n3 = listeners.length; i3 < n3; i3++){
426
+ listeners[i3](added, removed);
427
+ }
428
+ }
429
+ };
430
+ /**
431
+ * @internal
432
+ */ _proto._onDestroy = function _onDestroy() {
433
+ this._listeners.length = 0;
434
+ };
435
+ _proto._handleEvent = function _handleEvent(event) {
436
+ var input = this._trackedDevices[event.input];
437
+ switch(event.targetRayMode){
438
+ case exports.XRTargetRayMode.TrackedPointer:
439
+ switch(event.type){
440
+ case exports.XRInputEventType.SelectStart:
441
+ input.down |= exports.XRInputButton.Select;
442
+ input.pressedButtons |= exports.XRInputButton.Select;
443
+ break;
444
+ case exports.XRInputEventType.SelectEnd:
445
+ input.up |= exports.XRInputButton.Select;
446
+ input.pressedButtons &= ~exports.XRInputButton.Select;
447
+ break;
448
+ case exports.XRInputEventType.SqueezeStart:
449
+ input.down |= exports.XRInputButton.Squeeze;
450
+ input.pressedButtons |= exports.XRInputButton.Squeeze;
451
+ break;
452
+ case exports.XRInputEventType.SqueezeEnd:
453
+ input.up |= exports.XRInputButton.Squeeze;
454
+ input.pressedButtons &= ~exports.XRInputButton.Squeeze;
455
+ break;
456
+ }
457
+ break;
458
+ case exports.XRTargetRayMode.Screen:
459
+ // @ts-ignore
460
+ var canvas = this._engine.canvas._webCanvas;
461
+ var clientWidth = canvas.clientWidth, clientHeight = canvas.clientHeight;
462
+ var clientX = clientWidth * (event.x + 1) * 0.5;
463
+ var clientY = clientHeight * (event.y + 1) * 0.5;
464
+ switch(event.type){
465
+ case exports.XRInputEventType.SelectStart:
466
+ canvas.dispatchEvent(this._makeUpPointerEvent("pointerdown", event.id, clientX, clientY));
467
+ break;
468
+ case exports.XRInputEventType.Select:
469
+ canvas.dispatchEvent(this._makeUpPointerEvent("pointermove", event.id, clientX, clientY));
470
+ break;
471
+ case exports.XRInputEventType.SelectEnd:
472
+ canvas.dispatchEvent(this._makeUpPointerEvent("pointerup", event.id, clientX, clientY));
473
+ canvas.dispatchEvent(this._makeUpPointerEvent("pointerleave", event.id, clientX, clientY));
474
+ break;
475
+ }
476
+ break;
477
+ }
478
+ };
479
+ _proto._makeUpPointerEvent = function _makeUpPointerEvent(type, pointerId, clientX, clientY) {
480
+ var eventInitDict = {
481
+ pointerId: pointerId,
482
+ clientX: clientX,
483
+ clientY: clientY
484
+ };
485
+ switch(type){
486
+ case "pointerdown":
487
+ eventInitDict.button = 0;
488
+ eventInitDict.buttons = 1;
489
+ break;
490
+ case "pointermove":
491
+ eventInitDict.button = -1;
492
+ eventInitDict.buttons = 1;
493
+ break;
494
+ case "pointerup":
495
+ eventInitDict.button = 0;
496
+ eventInitDict.buttons = 0;
497
+ break;
498
+ case "pointerleave":
499
+ eventInitDict.button = 0;
500
+ eventInitDict.buttons = 0;
501
+ break;
502
+ }
503
+ return new PointerEvent(type, eventInitDict);
504
+ };
505
+ return XRInputManager;
506
+ }();
507
+
508
+ /**
509
+ * The type of XR session.
510
+ */ exports.XRSessionMode = void 0;
511
+ (function(XRSessionMode) {
512
+ XRSessionMode[XRSessionMode["None"] = 0] = "None";
513
+ XRSessionMode[XRSessionMode["AR"] = 1] = "AR";
514
+ XRSessionMode[XRSessionMode["VR"] = 2] = "VR";
515
+ })(exports.XRSessionMode || (exports.XRSessionMode = {}));
516
+
517
+ /**
518
+ * XRSessionManager manages the life cycle of XR sessions.
519
+ */ var XRSessionManager = /*#__PURE__*/ function() {
520
+ function XRSessionManager(_xrManager, _engine) {
521
+ this._xrManager = _xrManager;
522
+ this._engine = _engine;
523
+ this._mode = exports.XRSessionMode.None;
524
+ this._state = exports.XRSessionState.None;
525
+ // @ts-ignore
526
+ this._rhi = _engine._hardwareRenderer;
527
+ this._raf = requestAnimationFrame.bind(window);
528
+ this._caf = cancelAnimationFrame.bind(window);
529
+ this._onSessionExit = this._onSessionExit.bind(this);
530
+ }
531
+ var _proto = XRSessionManager.prototype;
532
+ /**
533
+ * Check if the specified mode is supported.
534
+ * @param mode - The mode to check
535
+ * @returns A promise that resolves if the mode is supported, otherwise rejects
536
+ */ _proto.isSupportedMode = function isSupportedMode(mode) {
537
+ return this._xrManager._platformDevice.isSupportedSessionMode(mode);
538
+ };
539
+ /**
540
+ * Run the session.
541
+ */ _proto.run = function run() {
542
+ var _this = this, platformSession = _this._platformSession, engine = _this._engine;
543
+ if (!platformSession) {
544
+ throw new Error("Without session to run.");
545
+ }
546
+ platformSession.start();
547
+ this._state = exports.XRSessionState.Running;
548
+ this._xrManager._onSessionStart();
549
+ if (!engine.isPaused) {
550
+ engine.pause();
551
+ engine.resume();
552
+ }
553
+ };
554
+ /**
555
+ * Stop the session.
556
+ */ _proto.stop = function stop() {
557
+ var _this = this, platformSession = _this._platformSession, engine = _this._engine, rhi = _this._rhi;
558
+ if (!platformSession) {
559
+ throw new Error("Without session to stop.");
560
+ }
561
+ if (this._state !== exports.XRSessionState.Running) {
562
+ throw new Error("Session is not running.");
563
+ }
564
+ rhi._mainFrameBuffer = null;
565
+ rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
566
+ platformSession.stop();
567
+ this._state = exports.XRSessionState.Paused;
568
+ this._xrManager._onSessionStop();
569
+ if (!engine.isPaused) {
570
+ engine.pause();
571
+ engine.resume();
572
+ }
573
+ };
574
+ /**
575
+ * @internal
576
+ */ _proto._initialize = function _initialize(mode, features) {
577
+ var _this = this;
578
+ return new Promise(function(resolve, reject) {
579
+ var xrManager = _this._xrManager;
580
+ // Initialize all features
581
+ var platformFeatures = [];
582
+ for(var i = 0, n = features.length; i < n; i++){
583
+ var _features_i = features[i], platformFeature = _features_i._platformFeature;
584
+ platformFeature && platformFeatures.push(platformFeature);
585
+ }
586
+ xrManager._platformDevice.requestSession(_this._rhi, mode, platformFeatures).then(function(platformSession) {
587
+ _this._mode = mode;
588
+ _this._platformSession = platformSession;
589
+ _this._state = exports.XRSessionState.Initialized;
590
+ platformSession.setSessionExitCallBack(_this._onSessionExit);
591
+ platformSession.addEventListener();
592
+ xrManager._onSessionInit();
593
+ resolve();
594
+ }, reject);
595
+ });
596
+ };
597
+ /**
598
+ * @internal
599
+ */ _proto._onUpdate = function _onUpdate() {
600
+ var _this = this, rhi = _this._rhi, platformSession = _this._platformSession;
601
+ rhi._mainFrameBuffer = platformSession.framebuffer;
602
+ rhi._mainFrameWidth = platformSession.framebufferWidth;
603
+ rhi._mainFrameHeight = platformSession.framebufferHeight;
604
+ };
605
+ /**
606
+ * @internal
607
+ */ _proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
608
+ if (this._state === exports.XRSessionState.Running) {
609
+ return this._platformSession.requestAnimationFrame;
610
+ } else {
611
+ return this._raf;
612
+ }
613
+ };
614
+ /**
615
+ * @internal
616
+ */ _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
617
+ if (this._state === exports.XRSessionState.Running) {
618
+ return this._platformSession.cancelAnimationFrame;
619
+ } else {
620
+ return this._caf;
621
+ }
622
+ };
623
+ /**
624
+ * @internal
625
+ */ _proto._exit = function _exit() {
626
+ var _this = this, platformSession = _this._platformSession;
627
+ if (!platformSession) {
628
+ return Promise.reject("Without session to stop.");
629
+ }
630
+ return platformSession.end();
631
+ };
632
+ _proto._onSessionExit = function _onSessionExit() {
633
+ var _this = this, rhi = _this._rhi, platformSession = _this._platformSession, engine = _this._engine;
634
+ rhi._mainFrameBuffer = null;
635
+ rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
636
+ platformSession.removeEventListener();
637
+ this._platformSession = null;
638
+ this._state = exports.XRSessionState.None;
639
+ this._xrManager._onSessionExit();
640
+ if (!engine.isPaused) {
641
+ engine.pause();
642
+ engine.resume();
643
+ }
644
+ };
645
+ /**
646
+ * @internal
647
+ */ _proto._onDestroy = function _onDestroy() {};
648
+ _create_class(XRSessionManager, [
649
+ {
650
+ key: "mode",
651
+ get: /**
652
+ * The current session mode( AR or VR ).
653
+ */ function get() {
654
+ return this._mode;
655
+ }
656
+ },
657
+ {
658
+ key: "state",
659
+ get: /**
660
+ * Return the current session state.
661
+ */ function get() {
662
+ return this._state;
663
+ }
664
+ },
665
+ {
666
+ key: "supportedFrameRate",
667
+ get: /**
668
+ * Return a list of supported frame rates.(only available in-session)
669
+ */ function get() {
670
+ return this._platformSession.supportedFrameRates;
671
+ }
672
+ },
673
+ {
674
+ key: "frameRate",
675
+ get: /**
676
+ * Return the current frame rate as reported by the device.
677
+ */ function get() {
678
+ return this._platformSession.frameRate;
679
+ }
680
+ }
681
+ ]);
682
+ return XRSessionManager;
683
+ }();
684
+
685
+ /**
686
+ * XRManager is the entry point of the XR system.
687
+ */ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
688
+ _inherits(XRManagerExtended, XRManager1);
689
+ function XRManagerExtended() {
690
+ return XRManager1.apply(this, arguments);
691
+ }
692
+ var _proto = XRManagerExtended.prototype;
693
+ /**
694
+ * Check if the specified feature is supported.
695
+ * @param type - The type of the feature
696
+ * @returns If the feature is supported
697
+ */ _proto.isSupportedFeature = function isSupportedFeature(feature) {
698
+ return this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(feature));
699
+ };
700
+ /**
701
+ * Add feature based on the xr feature type.
702
+ * @param type - The type of the feature
703
+ * @param args - The constructor params of the feature
704
+ * @returns The feature which has been added
705
+ */ _proto.addFeature = function addFeature(type) {
706
+ for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
707
+ args[_key - 1] = arguments[_key];
708
+ }
709
+ if (this.sessionManager._platformSession) {
710
+ throw new Error("Cannot add feature when the session is initialized.");
711
+ }
712
+ var _this = this, features = _this._features;
713
+ for(var i = 0, n = features.length; i < n; i++){
714
+ var feature = features[i];
715
+ if (_instanceof(feature, type)) throw new Error("The feature has been added");
716
+ }
717
+ var feature1 = _construct(type, [].concat(this, args));
718
+ this._features.push(feature1);
719
+ return feature1;
720
+ };
721
+ /**
722
+ * Get feature which match the type.
723
+ * @param type - The type of the feature
724
+ * @returns The feature which match type
725
+ */ _proto.getFeature = function getFeature(type) {
726
+ var _this = this, features = _this._features;
727
+ for(var i = 0, n = features.length; i < n; i++){
728
+ var feature = features[i];
729
+ if (_instanceof(feature, type)) {
730
+ return feature;
731
+ }
732
+ }
733
+ };
734
+ _proto.getFeatures = function getFeatures(type, out) {
735
+ if (out) {
736
+ out.length = 0;
737
+ } else {
738
+ out = [];
739
+ }
740
+ var _this = this, features = _this._features;
741
+ for(var i = 0, n = features.length; i < n; i--){
742
+ var feature = features[i];
743
+ _instanceof(feature, type) && out.push(feature);
744
+ }
745
+ return out;
746
+ };
747
+ /**
748
+ * Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
749
+ * @param sessionMode - The mode of the session
750
+ * @param autoRun - Whether to automatically run the session, when `autoRun` is set to true, xr will start working immediately after initialization. Otherwise, you need to call `sessionManager.run` later to work.
751
+ * @returns A promise that resolves if the XR virtual world is entered, otherwise rejects
752
+ */ _proto.enterXR = function enterXR(sessionMode, autoRun) {
753
+ if (autoRun === void 0) autoRun = true;
754
+ var _this = this;
755
+ var sessionManager = this.sessionManager;
756
+ if (sessionManager._platformSession) {
757
+ throw new Error("Please exit XR immersive mode first.");
758
+ }
759
+ if (!this._origin) {
760
+ throw new Error("Please set origin before enter XR.");
761
+ }
762
+ return new Promise(function(resolve, reject) {
763
+ // 1. Check if this xr mode is supported
764
+ sessionManager.isSupportedMode(sessionMode).then(function() {
765
+ // 2. Initialize session
766
+ sessionManager._initialize(sessionMode, _this._features).then(function() {
767
+ autoRun && sessionManager.run();
768
+ resolve();
769
+ }, reject);
770
+ }, reject);
771
+ });
772
+ };
773
+ /**
774
+ * Exit XR immersive mode, when you call this method, it will destroy the XR virtual world.
775
+ * @returns A promise that resolves if the XR virtual world is destroyed, otherwise rejects
776
+ */ _proto.exitXR = function exitXR() {
777
+ var _this = this;
778
+ return new Promise(function(resolve, reject) {
779
+ _this.sessionManager._exit().then(function() {
780
+ resolve();
781
+ }, reject);
782
+ });
783
+ };
784
+ /**
785
+ * @internal
786
+ */ _proto._initialize = function _initialize(engine, xrDevice) {
787
+ this._features = [];
788
+ this._platformDevice = xrDevice;
789
+ this.sessionManager = new XRSessionManager(this, engine);
790
+ this.inputManager = new XRInputManager(this, engine);
791
+ this.cameraManager = new XRCameraManager(this);
792
+ };
793
+ /**
794
+ * @internal
795
+ */ _proto._update = function _update() {
796
+ var sessionManager = this.sessionManager;
797
+ if (sessionManager.state !== exports.XRSessionState.Running) return;
798
+ sessionManager._onUpdate();
799
+ this.inputManager._onUpdate();
800
+ this.cameraManager._onUpdate();
801
+ var _this = this, features = _this._features;
802
+ for(var i = 0, n = features.length; i < n; i++){
803
+ var feature = features[i];
804
+ feature.enabled && feature._onUpdate();
805
+ }
806
+ };
807
+ /**
808
+ * @internal
809
+ */ _proto._destroy = function _destroy() {
810
+ var _this = this;
811
+ if (this.sessionManager._platformSession) {
812
+ this.exitXR().then(function() {
813
+ _this.sessionManager._onDestroy();
814
+ _this.inputManager._onDestroy();
815
+ _this.cameraManager._onDestroy();
816
+ });
817
+ } else {
818
+ this.sessionManager._onDestroy();
819
+ this.inputManager._onDestroy();
820
+ this.cameraManager._onDestroy();
821
+ }
822
+ };
823
+ /**
824
+ * @internal
825
+ */ _proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
826
+ return this.sessionManager._getRequestAnimationFrame();
827
+ };
828
+ /**
829
+ * @internal
830
+ */ _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
831
+ return this.sessionManager._getCancelAnimationFrame();
832
+ };
833
+ /**
834
+ * @internal
835
+ */ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
836
+ return this.cameraManager._getCameraClearFlagsMask(type);
837
+ };
838
+ /**
839
+ * @internal
840
+ */ _proto._onSessionStop = function _onSessionStop() {
841
+ var _this = this, features = _this._features;
842
+ for(var i = 0, n = features.length; i < n; i++){
843
+ var feature = features[i];
844
+ feature.enabled && feature._onSessionStop();
845
+ }
846
+ };
847
+ /**
848
+ * @internal
849
+ */ _proto._onSessionInit = function _onSessionInit() {
850
+ var _this = this, features = _this._features;
851
+ for(var i = 0, n = features.length; i < n; i++){
852
+ var feature = features[i];
853
+ feature.enabled && feature._onSessionInit();
854
+ }
855
+ };
856
+ /**
857
+ * @internal
858
+ */ _proto._onSessionStart = function _onSessionStart() {
859
+ this.cameraManager._onSessionStart();
860
+ var _this = this, features = _this._features;
861
+ for(var i = 0, n = features.length; i < n; i++){
862
+ var feature = features[i];
863
+ feature.enabled && feature._onSessionStart();
864
+ }
865
+ };
866
+ /**
867
+ * @internal
868
+ */ _proto._onSessionExit = function _onSessionExit() {
869
+ this.cameraManager._onSessionExit();
870
+ var _this = this, features = _this._features;
871
+ for(var i = 0, n = features.length; i < n; i++){
872
+ var feature = features[i];
873
+ feature.enabled && feature._onSessionExit();
874
+ feature._onDestroy();
875
+ }
876
+ features.length = 0;
877
+ };
878
+ _create_class(XRManagerExtended, [
879
+ {
880
+ key: "origin",
881
+ get: /**
882
+ * The current origin of XR space.
883
+ * @remarks The connection point between the virtual world and the real world ( XR Space )
884
+ */ function get() {
885
+ return this._origin;
886
+ },
887
+ set: function set(value) {
888
+ if (this.sessionManager._platformSession) {
889
+ throw new Error("Cannot set origin when the session is initialized.");
890
+ }
891
+ this._origin = value;
892
+ }
893
+ }
894
+ ]);
895
+ return XRManagerExtended;
896
+ }(engine.XRManager);
897
+ (function() {
898
+ /** @internal */ XRManagerExtended._featureMap = new Map();
899
+ })();
900
+ /**
901
+ * @internal
902
+ */ function registerXRFeature(type) {
903
+ return function(feature) {
904
+ XRManagerExtended._featureMap.set(feature, type);
905
+ };
906
+ }
907
+ // 实现混入的函数
908
+ function ApplyMixins(derivedCtor, baseCtors) {
909
+ baseCtors.forEach(function(baseCtor) {
910
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach(function(name) {
911
+ Object.defineProperty(derivedCtor.prototype, name, Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || Object.create(null));
912
+ });
913
+ });
914
+ }
915
+ ApplyMixins(engine.XRManager, [
916
+ XRManagerExtended
917
+ ]);
918
+
919
+ /**
920
+ * The base class of XR feature manager.
921
+ */ var XRFeature = /*#__PURE__*/ function() {
922
+ function XRFeature(_xrManager, _type) {
923
+ for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
924
+ args[_key - 2] = arguments[_key];
925
+ }
926
+ var _xrManager__platformDevice;
927
+ this._xrManager = _xrManager;
928
+ this._type = _type;
929
+ this._enabled = true;
930
+ this._platformFeature = (_xrManager__platformDevice = _xrManager._platformDevice).createPlatformFeature.apply(_xrManager__platformDevice, [].concat(_type, args));
931
+ this._onEnable();
932
+ }
933
+ var _proto = XRFeature.prototype;
934
+ /**
935
+ * @internal
936
+ */ _proto._onEnable = function _onEnable() {};
937
+ /**
938
+ * @internal
939
+ */ _proto._onDisable = function _onDisable() {};
940
+ /**
941
+ * @internal
942
+ */ _proto._onUpdate = function _onUpdate() {};
943
+ /**
944
+ * @internal
945
+ */ _proto._onSessionInit = function _onSessionInit() {};
946
+ /**
947
+ * @internal
948
+ */ _proto._onSessionStart = function _onSessionStart() {};
949
+ /**
950
+ * @internal
951
+ */ _proto._onSessionStop = function _onSessionStop() {};
952
+ /**
953
+ * @internal
954
+ */ _proto._onSessionExit = function _onSessionExit() {};
955
+ /**
956
+ * @internal
957
+ */ _proto._onDestroy = function _onDestroy() {};
958
+ _create_class(XRFeature, [
959
+ {
960
+ key: "enabled",
961
+ get: /**
962
+ * Returns whether the feature is enabled.
963
+ */ function get() {
964
+ return this._enabled;
965
+ },
966
+ set: function set(value) {
967
+ if (this.enabled !== value) {
968
+ this._enabled = value;
969
+ value ? this._onEnable() : this._onDisable();
970
+ }
971
+ }
972
+ }
973
+ ]);
974
+ return XRFeature;
975
+ }();
976
+
977
+ /**
978
+ * Enum for the types of hit test that can be performed.
979
+ * Note: currently only supports plane.
980
+ */ exports.TrackableType = void 0;
981
+ (function(TrackableType) {
982
+ TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
983
+ TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
984
+ })(exports.TrackableType || (exports.TrackableType = {}));
985
+
986
+ /**
987
+ * XR hit result.
988
+ * It is the detection result returned by using XR HitTest feature.
989
+ */ var XRHitResult = function XRHitResult() {
990
+ /** The position of the hit point. */ this.point = new engine.Vector3();
991
+ /** The normal of the hit point. */ this.normal = new engine.Vector3();
992
+ };
993
+
994
+ /******************************************************************************
995
+ Copyright (c) Microsoft Corporation.
996
+
997
+ Permission to use, copy, modify, and/or distribute this software for any
998
+ purpose with or without fee is hereby granted.
999
+
1000
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1001
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1002
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1003
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1004
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1005
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1006
+ PERFORMANCE OF THIS SOFTWARE.
1007
+ ***************************************************************************** */
1008
+
1009
+ function __decorate(decorators, target, key, desc) {
1010
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1011
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1012
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1013
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1014
+ }
1015
+
1016
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1017
+ var e = new Error(message);
1018
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1019
+ };
1020
+
1021
+ exports.XRFeatureType = void 0;
1022
+ (function(XRFeatureType) {
1023
+ XRFeatureType[XRFeatureType["AnchorTracking"] = 0] = "AnchorTracking";
1024
+ XRFeatureType[XRFeatureType["ImageTracking"] = 1] = "ImageTracking";
1025
+ XRFeatureType[XRFeatureType["PlaneTracking"] = 2] = "PlaneTracking";
1026
+ XRFeatureType[XRFeatureType["HitTest"] = 3] = "HitTest";
1027
+ })(exports.XRFeatureType || (exports.XRFeatureType = {}));
1028
+
1029
+ exports.XRRequestTrackingState = void 0;
1030
+ (function(XRRequestTrackingState) {
1031
+ XRRequestTrackingState[XRRequestTrackingState["None"] = 0] = "None";
1032
+ XRRequestTrackingState[XRRequestTrackingState["Submitted"] = 1] = "Submitted";
1033
+ XRRequestTrackingState[XRRequestTrackingState["Resolved"] = 2] = "Resolved";
1034
+ XRRequestTrackingState[XRRequestTrackingState["Rejected"] = 3] = "Rejected";
1035
+ XRRequestTrackingState[XRRequestTrackingState["Destroyed"] = 4] = "Destroyed";
1036
+ XRRequestTrackingState[XRRequestTrackingState["WaitingDestroy"] = 5] = "WaitingDestroy";
1037
+ })(exports.XRRequestTrackingState || (exports.XRRequestTrackingState = {}));
1038
+
1039
+ /**
1040
+ * The base class of XR trackable manager.
1041
+ */ var XRTrackableFeature = /*#__PURE__*/ function(XRFeature1) {
1042
+ _inherits(XRTrackableFeature, XRFeature1);
1043
+ function XRTrackableFeature() {
1044
+ var _this;
1045
+ _this = XRFeature1.apply(this, arguments) || this;
1046
+ _this._requestTrackings = [];
1047
+ _this._tracked = [];
1048
+ _this._added = [];
1049
+ _this._updated = [];
1050
+ _this._removed = [];
1051
+ _this._statusSnapshot = {};
1052
+ _this._listeners = [];
1053
+ return _this;
1054
+ }
1055
+ var _proto = XRTrackableFeature.prototype;
1056
+ /**
1057
+ * Add a listening function for tracked object changes.
1058
+ * @param listener - The listening function
1059
+ */ _proto.addChangedListener = function addChangedListener(listener) {
1060
+ this._listeners.push(listener);
1061
+ };
1062
+ /**
1063
+ * Remove a listening function of tracked object changes.
1064
+ * @param listener - The listening function
1065
+ */ _proto.removeChangedListener = function removeChangedListener(listener) {
1066
+ var _this = this, listeners = _this._listeners;
1067
+ var index = listeners.indexOf(listener);
1068
+ if (index >= 0) {
1069
+ listeners.splice(index, 1);
1070
+ }
1071
+ };
1072
+ _proto._onUpdate = function _onUpdate() {
1073
+ var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
1074
+ var platformFrame = platformSession.frame;
1075
+ var _this = this, platformFeature = _this._platformFeature, listeners = _this._listeners, requestTrackings = _this._requestTrackings, statusSnapshot = _this._statusSnapshot, allTracked = _this._tracked, added = _this._added, updated = _this._updated, removed = _this._removed;
1076
+ if (!platformFrame || !requestTrackings.length) {
1077
+ return;
1078
+ }
1079
+ if (!platformFeature.checkAvailable(platformSession, platformFrame, requestTrackings)) {
1080
+ return;
1081
+ }
1082
+ added.length = updated.length = removed.length = 0;
1083
+ platformFeature.getTrackedResult(platformSession, platformFrame, requestTrackings, this._generateTracked);
1084
+ for(var i = 0, n = requestTrackings.length; i < n; i++){
1085
+ var requestTracking = requestTrackings[i];
1086
+ switch(requestTracking.state){
1087
+ case exports.XRRequestTrackingState.Destroyed:
1088
+ var destroyedTracked = requestTracking.tracked;
1089
+ for(var j = 0, n1 = destroyedTracked.length; j < n1; j++){
1090
+ var tracked = destroyedTracked[j];
1091
+ var trackId = tracked.id;
1092
+ if (statusSnapshot[trackId] === exports.XRTrackingState.Tracking) {
1093
+ removed.push(tracked);
1094
+ allTracked.splice(allTracked.indexOf(tracked), 1);
1095
+ }
1096
+ statusSnapshot[trackId] = exports.XRTrackingState.NotTracking;
1097
+ }
1098
+ break;
1099
+ case exports.XRRequestTrackingState.Resolved:
1100
+ var tracked1 = requestTracking.tracked;
1101
+ for(var j1 = 0, n2 = tracked1.length; j1 < n2; j1++){
1102
+ var trackedObject = tracked1[j1];
1103
+ var trackId1 = trackedObject.id;
1104
+ if (trackedObject.state === exports.XRTrackingState.Tracking) {
1105
+ if (statusSnapshot[trackId1] === exports.XRTrackingState.Tracking) {
1106
+ updated.push(trackedObject);
1107
+ } else {
1108
+ added.push(trackedObject);
1109
+ statusSnapshot[trackId1] = exports.XRTrackingState.Tracking;
1110
+ allTracked.push(trackedObject);
1111
+ }
1112
+ } else {
1113
+ if (statusSnapshot[trackId1] === exports.XRTrackingState.Tracking) {
1114
+ removed.push(trackedObject);
1115
+ allTracked.splice(allTracked.indexOf(trackedObject), 1);
1116
+ }
1117
+ statusSnapshot[trackId1] = trackedObject.state;
1118
+ }
1119
+ }
1120
+ break;
1121
+ }
1122
+ }
1123
+ for(var i1 = requestTrackings.length - 1; i1 >= 0; i1--){
1124
+ requestTrackings[i1].state === exports.XRRequestTrackingState.Destroyed && requestTrackings.splice(i1, 1);
1125
+ }
1126
+ if (added.length > 0 || updated.length > 0 || removed.length > 0) {
1127
+ for(var i2 = 0, n3 = listeners.length; i2 < n3; i2++){
1128
+ listeners[i2](added, updated, removed);
1129
+ }
1130
+ }
1131
+ };
1132
+ _proto._onSessionStop = function _onSessionStop() {
1133
+ this._added.length = this._updated.length = this._removed.length = 0;
1134
+ };
1135
+ _proto._onSessionExit = function _onSessionExit() {
1136
+ // prettier-ignore
1137
+ this._requestTrackings.length = this._tracked.length = this._added.length = this._updated.length = this._removed.length = 0;
1138
+ };
1139
+ _proto._onDestroy = function _onDestroy() {
1140
+ // prettier-ignore
1141
+ this._requestTrackings.length = this._tracked.length = this._added.length = this._updated.length = this._removed.length = 0;
1142
+ };
1143
+ _proto._addRequestTracking = function _addRequestTracking(requestTracking) {
1144
+ var _this = this, platformFeature = _this._platformFeature;
1145
+ if (this._xrManager.sessionManager._platformSession && !platformFeature.canModifyRequestTrackingAfterInit) {
1146
+ throw new Error(exports.XRFeatureType[this._type] + " request tracking cannot be modified after initialization.");
1147
+ }
1148
+ this._requestTrackings.push(requestTracking);
1149
+ platformFeature.onAddRequestTracking(requestTracking);
1150
+ };
1151
+ _proto._removeRequestTracking = function _removeRequestTracking(requestTracking) {
1152
+ var _this = this, platformFeature = _this._platformFeature;
1153
+ if (this._xrManager.sessionManager._platformSession && !platformFeature.canModifyRequestTrackingAfterInit) {
1154
+ throw new Error(exports.XRFeatureType[this._type] + " request tracking cannot be modified after initialization.");
1155
+ }
1156
+ platformFeature.onDelRequestTracking(requestTracking);
1157
+ };
1158
+ _proto._removeAllRequestTrackings = function _removeAllRequestTrackings() {
1159
+ var _this = this, platformFeature = _this._platformFeature;
1160
+ if (this._xrManager.sessionManager._platformSession && !platformFeature.canModifyRequestTrackingAfterInit) {
1161
+ throw new Error(exports.XRFeatureType[this._type] + " request tracking cannot be modified after initialization.");
1162
+ }
1163
+ var _this1 = this, requestTrackings = _this1._requestTrackings;
1164
+ for(var i = 0, n = requestTrackings.length; i < n; i++){
1165
+ platformFeature.onDelRequestTracking(requestTrackings[i]);
1166
+ }
1167
+ };
1168
+ return XRTrackableFeature;
1169
+ }(XRFeature);
1170
+ (function() {
1171
+ XRTrackableFeature._uuid = 0;
1172
+ })();
1173
+
1174
+ /**
1175
+ * Enumerates modes of plane in XR.
1176
+ */ exports.XRPlaneMode = void 0;
1177
+ (function(XRPlaneMode) {
1178
+ XRPlaneMode[XRPlaneMode[/** None. */ "None"] = 0] = "None";
1179
+ XRPlaneMode[XRPlaneMode[/** Horizontal */ "Horizontal"] = 1] = "Horizontal";
1180
+ XRPlaneMode[XRPlaneMode[/** Vertical */ "Vertical"] = 2] = "Vertical";
1181
+ XRPlaneMode[XRPlaneMode[/** Includes horizontal and vertical. */ "EveryThing"] = 3] = "EveryThing";
1182
+ })(exports.XRPlaneMode || (exports.XRPlaneMode = {}));
1183
+
1184
+ /**
1185
+ * @internal
1186
+ */ var XRRequestTracking = function XRRequestTracking() {
1187
+ /** The status of the current request tracking. */ this.state = exports.XRRequestTrackingState.None;
1188
+ /** Tracked instances, make up from the tracking data returned by Session. */ this.tracked = [];
1189
+ };
1190
+
1191
+ /**
1192
+ * The request plane in XR space.
1193
+ */ var XRRequestPlane = /*#__PURE__*/ function(XRRequestTracking1) {
1194
+ _inherits(XRRequestPlane, XRRequestTracking1);
1195
+ function XRRequestPlane(detectionMode) {
1196
+ var _this;
1197
+ _this = XRRequestTracking1.call(this) || this;
1198
+ _this.detectionMode = detectionMode;
1199
+ return _this;
1200
+ }
1201
+ return XRRequestPlane;
1202
+ }(XRRequestTracking);
1203
+
1204
+ /**
1205
+ * The base class of XR tracked object.
1206
+ */ var XRTracked = function XRTracked() {
1207
+ /** The pose of the trackable in XR space. */ this.pose = new XRPose();
1208
+ /** The tracking state of the trackable. */ this.state = exports.XRTrackingState.NotTracking;
1209
+ };
1210
+
1211
+ /**
1212
+ * The tracked plane in XR space.
1213
+ */ var XRTrackedPlane = /*#__PURE__*/ function(XRTracked1) {
1214
+ _inherits(XRTrackedPlane, XRTracked1);
1215
+ function XRTrackedPlane() {
1216
+ var _this;
1217
+ _this = XRTracked1.apply(this, arguments) || this;
1218
+ /** The points that make up this plane.
1219
+ * Note: These points are in the plane coordinate system,
1220
+ * and their Y coordinates are all zero.
1221
+ */ _this.polygon = [];
1222
+ /**
1223
+ * Whether this frame changes the attributes of the plane.
1224
+ * Note: Includes `polygon` but no `pose`.
1225
+ */ _this.attributesDirty = false;
1226
+ return _this;
1227
+ }
1228
+ return XRTrackedPlane;
1229
+ }(XRTracked);
1230
+
1231
+ exports.XRPlaneTracking = /*#__PURE__*/ function(XRTrackableFeature1) {
1232
+ _inherits(XRPlaneTracking, XRTrackableFeature1);
1233
+ function XRPlaneTracking(xrManager, detectionMode) {
1234
+ if (detectionMode === void 0) detectionMode = exports.XRPlaneMode.EveryThing;
1235
+ var _this;
1236
+ _this = XRTrackableFeature1.call(this, xrManager, exports.XRFeatureType.PlaneTracking, detectionMode) || this;
1237
+ _this._addRequestTracking(new XRRequestPlane(detectionMode));
1238
+ return _this;
1239
+ }
1240
+ var _proto = XRPlaneTracking.prototype;
1241
+ _proto._generateTracked = function _generateTracked() {
1242
+ var plane = new XRTrackedPlane();
1243
+ plane.id = XRTrackableFeature._uuid++;
1244
+ return plane;
1245
+ };
1246
+ _create_class(XRPlaneTracking, [
1247
+ {
1248
+ key: "detectionMode",
1249
+ get: /**
1250
+ * The plane detection mode.
1251
+ */ function get() {
1252
+ return this._requestTrackings[0].detectionMode;
1253
+ }
1254
+ },
1255
+ {
1256
+ key: "trackedPlanes",
1257
+ get: /**
1258
+ * The tracked planes.
1259
+ */ function get() {
1260
+ return this._tracked;
1261
+ }
1262
+ }
1263
+ ]);
1264
+ return XRPlaneTracking;
1265
+ }(XRTrackableFeature);
1266
+ exports.XRPlaneTracking = __decorate([
1267
+ registerXRFeature(exports.XRFeatureType.PlaneTracking)
1268
+ ], exports.XRPlaneTracking);
1269
+
1270
+ exports.XRHitTest = /*#__PURE__*/ function(XRFeature1) {
1271
+ _inherits(XRHitTest, XRFeature1);
1272
+ function XRHitTest(xrManager) {
1273
+ var _this;
1274
+ _this = XRFeature1.call(this, xrManager, exports.XRFeatureType.HitTest) || this;
1275
+ _this._tempRay = new engine.Ray();
1276
+ _this._tempPlane = new engine.Plane();
1277
+ _this._tempVec2 = new engine.Vector2();
1278
+ _this._tempVec30 = new engine.Vector3();
1279
+ _this._tempVec31 = new engine.Vector3();
1280
+ _this._tempVec32 = new engine.Vector3();
1281
+ _this._tempVec33 = new engine.Vector3();
1282
+ _this._tempVec34 = new engine.Vector3();
1283
+ _this._tempVec35 = new engine.Vector3();
1284
+ return _this;
1285
+ }
1286
+ var _proto = XRHitTest.prototype;
1287
+ /**
1288
+ * Hit test.
1289
+ * @param ray - The ray to test
1290
+ * @param type - The type of hit test
1291
+ * @returns The hit result
1292
+ */ _proto.hitTest = function hitTest(ray, type) {
1293
+ var result = [];
1294
+ if (type & exports.TrackableType.Plane) {
1295
+ this._hitTestPlane(ray, result);
1296
+ }
1297
+ return result;
1298
+ };
1299
+ /**
1300
+ * Screen hit test.
1301
+ * @param x - The x coordinate of the screen point
1302
+ * @param y - The y coordinate of the screen point
1303
+ * @param type - The type of hit test
1304
+ * @returns The hit result
1305
+ */ _proto.screenHitTest = function screenHitTest(x, y, type) {
1306
+ var _this = this, xrManager = _this._xrManager;
1307
+ if (xrManager.sessionManager.mode !== exports.XRSessionMode.AR) {
1308
+ throw new Error("Only AR mode supports using screen ray hit test.");
1309
+ }
1310
+ var _xrManager_inputManager_getTrackedDevice = xrManager.inputManager.getTrackedDevice(exports.XRTrackedInputDevice.Camera), camera = _xrManager_inputManager_getTrackedDevice._camera;
1311
+ if (!camera) {
1312
+ throw new Error("No camera available.");
1313
+ }
1314
+ var ray = camera.screenPointToRay(this._tempVec2.set(x, y), this._tempRay);
1315
+ return this.hitTest(ray, type);
1316
+ };
1317
+ _proto._hitTestPlane = function _hitTestPlane(ray, result) {
1318
+ var planeManager = this._xrManager.getFeature(exports.XRPlaneTracking);
1319
+ if (!planeManager || !planeManager.enabled) {
1320
+ throw new Error("The plane estimation function needs to be turned on for plane hit test.");
1321
+ }
1322
+ var _this = this, plane = _this._tempPlane, normal = _this._tempVec30, hitPoint = _this._tempVec31, hitPointInPlane = _this._tempVec32;
1323
+ var trackedPlanes = planeManager.trackedPlanes;
1324
+ for(var i = 0, n = trackedPlanes.length; i < n; i++){
1325
+ var trackedPlane = trackedPlanes[i];
1326
+ normal.set(0, 1, 0).transformNormal(trackedPlane.pose.matrix);
1327
+ plane.normal.copyFrom(normal);
1328
+ plane.distance = -engine.Vector3.dot(normal, trackedPlane.pose.position);
1329
+ var distance = ray.intersectPlane(plane);
1330
+ if (distance >= 0) {
1331
+ ray.getPoint(distance, hitPoint);
1332
+ engine.Vector3.transformToVec3(hitPoint, trackedPlane.pose.inverseMatrix, hitPointInPlane);
1333
+ // Check if the hit position is within the plane boundary.
1334
+ if (this._checkPointerWithinPlane(hitPointInPlane, trackedPlane)) {
1335
+ var hitResult = new XRHitResult();
1336
+ hitResult.point.copyFrom(hitPoint);
1337
+ hitResult.normal.copyFrom(normal);
1338
+ hitResult.distance = distance;
1339
+ hitResult.trackedObject = trackedPlane;
1340
+ hitResult.trackableType = exports.TrackableType.Plane;
1341
+ result.push(hitResult);
1342
+ }
1343
+ }
1344
+ }
1345
+ };
1346
+ _proto._checkPointerWithinPlane = function _checkPointerWithinPlane(pointer, plane) {
1347
+ var _this = this, preToCur = _this._tempVec33, preToPointer = _this._tempVec34, cross = _this._tempVec35;
1348
+ var polygon = plane.polygon;
1349
+ var length = polygon.length;
1350
+ var prePoint = polygon[length - 1];
1351
+ var side = 0;
1352
+ for(var i = 0; i < length; i++){
1353
+ var curPoint = polygon[i];
1354
+ engine.Vector3.subtract(curPoint, prePoint, preToCur);
1355
+ engine.Vector3.subtract(pointer, prePoint, preToPointer);
1356
+ engine.Vector3.cross(preToCur, preToPointer, cross);
1357
+ var y = cross.y;
1358
+ if (side === 0) {
1359
+ if (y > 0) {
1360
+ side = 1;
1361
+ } else if (y < 0) {
1362
+ side = -1;
1363
+ }
1364
+ } else {
1365
+ if (y > 0 && side < 0 || y < 0 && side > 0) {
1366
+ return false;
1367
+ }
1368
+ }
1369
+ prePoint = curPoint;
1370
+ }
1371
+ return true;
1372
+ };
1373
+ return XRHitTest;
1374
+ }(XRFeature);
1375
+ exports.XRHitTest = __decorate([
1376
+ registerXRFeature(exports.XRFeatureType.HitTest)
1377
+ ], exports.XRHitTest);
1378
+
1379
+ /**
1380
+ * The anchor in XR space.
1381
+ */ var XRAnchor = /*#__PURE__*/ function(XRTracked1) {
1382
+ _inherits(XRAnchor, XRTracked1);
1383
+ function XRAnchor() {
1384
+ return XRTracked1.apply(this, arguments);
1385
+ }
1386
+ return XRAnchor;
1387
+ }(XRTracked);
1388
+
1389
+ /**
1390
+ * The request anchor in XR space.
1391
+ */ var XRRequestAnchor = /*#__PURE__*/ function(XRRequestTracking1) {
1392
+ _inherits(XRRequestAnchor, XRRequestTracking1);
1393
+ function XRRequestAnchor(position, rotation) {
1394
+ var _this;
1395
+ _this = XRRequestTracking1.call(this) || this;
1396
+ _this.position = position;
1397
+ _this.rotation = rotation;
1398
+ return _this;
1399
+ }
1400
+ return XRRequestAnchor;
1401
+ }(XRRequestTracking);
1402
+
1403
+ exports.XRAnchorTracking = /*#__PURE__*/ function(XRTrackableFeature1) {
1404
+ _inherits(XRAnchorTracking, XRTrackableFeature1);
1405
+ function XRAnchorTracking(xrManager) {
1406
+ var _this;
1407
+ _this = XRTrackableFeature1.call(this, xrManager, exports.XRFeatureType.AnchorTracking) || this;
1408
+ _this._anchors = [];
1409
+ return _this;
1410
+ }
1411
+ var _proto = XRAnchorTracking.prototype;
1412
+ /**
1413
+ * Add a anchor in XR space.
1414
+ * @param anchor - The anchor to be added
1415
+ */ _proto.addAnchor = function addAnchor(position, rotation) {
1416
+ if (!this._enabled) {
1417
+ throw new Error("Cannot add an anchor from a disabled anchor manager.");
1418
+ }
1419
+ var _this = this, anchors = _this._anchors;
1420
+ var requestAnchor = new XRRequestAnchor(position, rotation);
1421
+ var xrAnchor = this._generateTracked();
1422
+ requestAnchor.tracked[0] = xrAnchor;
1423
+ this._addRequestTracking(requestAnchor);
1424
+ anchors.push(xrAnchor);
1425
+ return xrAnchor;
1426
+ };
1427
+ /**
1428
+ * Remove a anchor in XR space.
1429
+ * @param anchor - The anchor to be removed
1430
+ */ _proto.removeAnchor = function removeAnchor(anchor) {
1431
+ if (!this._enabled) {
1432
+ throw new Error("Cannot remove an anchor from a disabled anchor manager.");
1433
+ }
1434
+ var _this = this, requestTrackings = _this._requestTrackings, anchors = _this._anchors;
1435
+ for(var i = 0, n = requestTrackings.length; i < n; i++){
1436
+ var requestAnchor = requestTrackings[i];
1437
+ if (requestAnchor.tracked[0] === anchor) {
1438
+ this._removeRequestTracking(requestAnchor);
1439
+ break;
1440
+ }
1441
+ }
1442
+ anchors.splice(anchors.indexOf(anchor), 1);
1443
+ };
1444
+ /**
1445
+ * Remove all tracking anchors.
1446
+ */ _proto.clearAnchors = function clearAnchors() {
1447
+ if (!this._enabled) {
1448
+ throw new Error("Cannot remove anchors from a disabled anchor manager.");
1449
+ }
1450
+ this._removeAllRequestTrackings();
1451
+ };
1452
+ _proto._generateTracked = function _generateTracked() {
1453
+ var anchor = new XRAnchor();
1454
+ anchor.id = XRTrackableFeature._uuid++;
1455
+ return anchor;
1456
+ };
1457
+ _create_class(XRAnchorTracking, [
1458
+ {
1459
+ key: "trackingAnchors",
1460
+ get: /**
1461
+ * The anchors to tracking.
1462
+ */ function get() {
1463
+ return this._anchors;
1464
+ }
1465
+ },
1466
+ {
1467
+ key: "trackedAnchors",
1468
+ get: /**
1469
+ * The tracked anchors.
1470
+ */ function get() {
1471
+ return this._tracked;
1472
+ }
1473
+ }
1474
+ ]);
1475
+ return XRAnchorTracking;
1476
+ }(XRTrackableFeature);
1477
+ exports.XRAnchorTracking = __decorate([
1478
+ registerXRFeature(exports.XRFeatureType.AnchorTracking)
1479
+ ], exports.XRAnchorTracking);
1480
+
1481
+ /**
1482
+ * The request image in XR space.
1483
+ */ var XRRequestImage = /*#__PURE__*/ function(XRRequestTracking1) {
1484
+ _inherits(XRRequestImage, XRRequestTracking1);
1485
+ function XRRequestImage(image) {
1486
+ var _this;
1487
+ _this = XRRequestTracking1.call(this) || this;
1488
+ _this.image = image;
1489
+ return _this;
1490
+ }
1491
+ return XRRequestImage;
1492
+ }(XRRequestTracking);
1493
+
1494
+ /**
1495
+ * A tracked image in XR space.
1496
+ */ var XRTrackedImage = /*#__PURE__*/ function(XRTracked1) {
1497
+ _inherits(XRTrackedImage, XRTracked1);
1498
+ function XRTrackedImage() {
1499
+ return XRTracked1.apply(this, arguments);
1500
+ }
1501
+ return XRTrackedImage;
1502
+ }(XRTracked);
1503
+
1504
+ exports.XRImageTracking = /*#__PURE__*/ function(XRTrackableFeature1) {
1505
+ _inherits(XRImageTracking, XRTrackableFeature1);
1506
+ function XRImageTracking(xrManager, trackingImages) {
1507
+ var _this;
1508
+ _this = XRTrackableFeature1.call(this, xrManager, exports.XRFeatureType.ImageTracking, trackingImages) || this;
1509
+ _this._trackingImages = trackingImages;
1510
+ var imageLength = trackingImages ? trackingImages.length : 0;
1511
+ if (imageLength > 0) {
1512
+ for(var i = 0, n = trackingImages.length; i < n; i++){
1513
+ _this._addRequestTracking(new XRRequestImage(trackingImages[i]));
1514
+ }
1515
+ } else {
1516
+ console.warn("No image to be tracked.");
1517
+ }
1518
+ return _this;
1519
+ }
1520
+ var _proto = XRImageTracking.prototype;
1521
+ _proto._generateTracked = function _generateTracked() {
1522
+ var image = new XRTrackedImage();
1523
+ image.id = XRTrackableFeature._uuid++;
1524
+ return image;
1525
+ };
1526
+ _create_class(XRImageTracking, [
1527
+ {
1528
+ key: "trackingImages",
1529
+ get: /**
1530
+ * The image to tracking.
1531
+ */ function get() {
1532
+ return this._trackingImages;
1533
+ }
1534
+ },
1535
+ {
1536
+ key: "trackedImages",
1537
+ get: /**
1538
+ * The tracked images.
1539
+ */ function get() {
1540
+ return this._tracked;
1541
+ }
1542
+ }
1543
+ ]);
1544
+ return XRImageTracking;
1545
+ }(XRTrackableFeature);
1546
+ exports.XRImageTracking = __decorate([
1547
+ registerXRFeature(exports.XRFeatureType.ImageTracking)
1548
+ ], exports.XRImageTracking);
1549
+
1550
+ /**
1551
+ * A reference image is an image to look for in the physical environment.
1552
+ */ var XRReferenceImage = function XRReferenceImage(name, imageSource, physicalWidth) {
1553
+ this.name = name;
1554
+ this.imageSource = imageSource;
1555
+ this.physicalWidth = physicalWidth;
1556
+ };
1557
+
1558
+ exports.XRAnchor = XRAnchor;
1559
+ exports.XRCamera = XRCamera;
1560
+ exports.XRCameraManager = XRCameraManager;
1561
+ exports.XRController = XRController;
1562
+ exports.XRFeature = XRFeature;
1563
+ exports.XRHitResult = XRHitResult;
1564
+ exports.XRInputManager = XRInputManager;
1565
+ exports.XRPose = XRPose;
1566
+ exports.XRReferenceImage = XRReferenceImage;
1567
+ exports.XRSessionManager = XRSessionManager;
1568
+ exports.XRTrackedImage = XRTrackedImage;
1569
+ exports.XRTrackedPlane = XRTrackedPlane;
1570
+
1571
+ Object.defineProperty(exports, '__esModule', { value: true });
1572
+
1573
+ }));