@galacean/engine-xr 0.0.0-experimental-1.3-xr.4 → 0.0.0-experimental-1.3-xr.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +64 -309
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +64 -309
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +64 -309
- package/dist/module.js +66 -311
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/XRManagerExtended.d.ts +6 -51
- package/types/feature/trackable/XRTrackableFeature.d.ts +1 -1
- package/types/index.d.ts +0 -1
- package/types/session/XRSessionManager.d.ts +2 -2
- package/types/session/XRSessionState.d.ts +5 -3
package/dist/module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CameraType, Matrix, CameraClearFlags, Vector3, Quaternion, Rect, XRManager, Ray, Plane, Vector2, decoder, resourceLoader, AssetPromise, decode, Loader
|
|
1
|
+
import { CameraType, Matrix, CameraClearFlags, Vector3, Quaternion, Rect, SafeLoopArray, XRManager, Ray, Plane, Vector2, decoder, resourceLoader, AssetPromise, decode, Loader } from '@galacean/engine';
|
|
2
2
|
|
|
3
3
|
function _is_native_reflect_construct() {
|
|
4
4
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
@@ -95,9 +95,10 @@ function _instanceof(left, right) {
|
|
|
95
95
|
*/ var XRSessionState;
|
|
96
96
|
(function(XRSessionState) {
|
|
97
97
|
XRSessionState[XRSessionState[/** Not initialized. */ "None"] = 0] = "None";
|
|
98
|
-
XRSessionState[XRSessionState[/**
|
|
99
|
-
XRSessionState[XRSessionState[/**
|
|
100
|
-
XRSessionState[XRSessionState[/**
|
|
98
|
+
XRSessionState[XRSessionState[/** Initializing session. */ "Initializing"] = 1] = "Initializing";
|
|
99
|
+
XRSessionState[XRSessionState[/** Initialized but not started. */ "Initialized"] = 2] = "Initialized";
|
|
100
|
+
XRSessionState[XRSessionState[/** Running. */ "Running"] = 3] = "Running";
|
|
101
|
+
XRSessionState[XRSessionState[/** Paused. */ "Paused"] = 4] = "Paused";
|
|
101
102
|
})(XRSessionState || (XRSessionState = {}));
|
|
102
103
|
|
|
103
104
|
/**
|
|
@@ -522,7 +523,7 @@ var XRTargetRayMode;
|
|
|
522
523
|
this._engine = _engine;
|
|
523
524
|
this._mode = XRSessionMode.None;
|
|
524
525
|
this._state = XRSessionState.None;
|
|
525
|
-
this._listeners =
|
|
526
|
+
this._listeners = new SafeLoopArray();
|
|
526
527
|
// @ts-ignore
|
|
527
528
|
this._rhi = _engine._hardwareRenderer;
|
|
528
529
|
this._raf = requestAnimationFrame.bind(window);
|
|
@@ -545,7 +546,7 @@ var XRTargetRayMode;
|
|
|
545
546
|
throw new Error("Without session to run.");
|
|
546
547
|
}
|
|
547
548
|
platformSession.start();
|
|
548
|
-
this.
|
|
549
|
+
this._setState(XRSessionState.Running);
|
|
549
550
|
this._xrManager._onSessionStart();
|
|
550
551
|
if (!engine.isPaused) {
|
|
551
552
|
engine.pause();
|
|
@@ -565,7 +566,7 @@ var XRTargetRayMode;
|
|
|
565
566
|
rhi._mainFrameBuffer = null;
|
|
566
567
|
rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
|
|
567
568
|
platformSession.stop();
|
|
568
|
-
this.
|
|
569
|
+
this._setState(XRSessionState.Paused);
|
|
569
570
|
this._xrManager._onSessionStop();
|
|
570
571
|
if (!engine.isPaused) {
|
|
571
572
|
engine.pause();
|
|
@@ -575,17 +576,27 @@ var XRTargetRayMode;
|
|
|
575
576
|
/**
|
|
576
577
|
* Add a listening function for session state changes.
|
|
577
578
|
* @param listener - The listening function
|
|
578
|
-
*/ _proto.
|
|
579
|
-
this._listeners.push(
|
|
579
|
+
*/ _proto.addStateChangedListener = function addStateChangedListener(listener) {
|
|
580
|
+
this._listeners.push({
|
|
581
|
+
fn: listener
|
|
582
|
+
});
|
|
580
583
|
};
|
|
581
584
|
/**
|
|
582
585
|
* Remove a listening function of session state changes.
|
|
583
586
|
* @param listener - The listening function
|
|
584
|
-
*/ _proto.
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
587
|
+
*/ _proto.removeStateChangedListener = function removeStateChangedListener(listener) {
|
|
588
|
+
this._listeners.findAndRemove(function(value) {
|
|
589
|
+
return value.fn === listener ? value.destroyed = true : false;
|
|
590
|
+
});
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* @internal
|
|
594
|
+
*/ _proto._setState = function _setState(value) {
|
|
595
|
+
this._state = value;
|
|
596
|
+
var listeners = this._listeners.getLoopArray();
|
|
597
|
+
for(var i = 0, n = listeners.length; i < n; i++){
|
|
598
|
+
var listener = listeners[i];
|
|
599
|
+
!listener.destroyed && listener.fn(value);
|
|
589
600
|
}
|
|
590
601
|
};
|
|
591
602
|
/**
|
|
@@ -603,7 +614,7 @@ var XRTargetRayMode;
|
|
|
603
614
|
xrManager._platformDevice.requestSession(_this._rhi, mode, platformFeatures).then(function(platformSession) {
|
|
604
615
|
_this._mode = mode;
|
|
605
616
|
_this._platformSession = platformSession;
|
|
606
|
-
_this.
|
|
617
|
+
_this._setState(XRSessionState.Initialized);
|
|
607
618
|
platformSession.setSessionExitCallBack(_this._onSessionExit);
|
|
608
619
|
platformSession.addEventListener();
|
|
609
620
|
xrManager._onSessionInit();
|
|
@@ -652,7 +663,7 @@ var XRTargetRayMode;
|
|
|
652
663
|
rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
|
|
653
664
|
platformSession.removeEventListener();
|
|
654
665
|
this._platformSession = null;
|
|
655
|
-
this.
|
|
666
|
+
this._setState(XRSessionState.None);
|
|
656
667
|
this._xrManager._onSessionExit();
|
|
657
668
|
if (!engine.isPaused) {
|
|
658
669
|
engine.pause();
|
|
@@ -661,7 +672,12 @@ var XRTargetRayMode;
|
|
|
661
672
|
};
|
|
662
673
|
/**
|
|
663
674
|
* @internal
|
|
664
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
675
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
676
|
+
this._listeners.findAndRemove(function(value) {
|
|
677
|
+
return value.destroyed = true;
|
|
678
|
+
});
|
|
679
|
+
this._raf = this._caf = null;
|
|
680
|
+
};
|
|
665
681
|
_create_class(XRSessionManager, [
|
|
666
682
|
{
|
|
667
683
|
key: "mode",
|
|
@@ -677,15 +693,6 @@ var XRTargetRayMode;
|
|
|
677
693
|
* Return the current session state.
|
|
678
694
|
*/ function get() {
|
|
679
695
|
return this._state;
|
|
680
|
-
},
|
|
681
|
-
set: /**
|
|
682
|
-
* @internal
|
|
683
|
-
*/ function set(value) {
|
|
684
|
-
this._state = value;
|
|
685
|
-
var listeners = this._listeners;
|
|
686
|
-
for(var i = 0, n = listeners.length; i < n; i++){
|
|
687
|
-
listeners[i](value);
|
|
688
|
-
}
|
|
689
696
|
}
|
|
690
697
|
},
|
|
691
698
|
{
|
|
@@ -709,26 +716,20 @@ var XRTargetRayMode;
|
|
|
709
716
|
}();
|
|
710
717
|
|
|
711
718
|
/**
|
|
712
|
-
*
|
|
719
|
+
* @internal
|
|
713
720
|
*/ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
|
|
714
721
|
_inherits(XRManagerExtended, XRManager1);
|
|
715
722
|
function XRManagerExtended() {
|
|
716
|
-
|
|
723
|
+
var _this;
|
|
724
|
+
_this = XRManager1.apply(this, arguments) || this;
|
|
725
|
+
_this.features = [];
|
|
726
|
+
return _this;
|
|
717
727
|
}
|
|
718
728
|
var _proto = XRManagerExtended.prototype;
|
|
719
|
-
|
|
720
|
-
* Check if the specified feature is supported.
|
|
721
|
-
* @param type - The type of the feature
|
|
722
|
-
* @returns If the feature is supported
|
|
723
|
-
*/ _proto.isSupportedFeature = function isSupportedFeature(feature) {
|
|
729
|
+
_proto.isSupportedFeature = function isSupportedFeature(feature) {
|
|
724
730
|
return this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(feature));
|
|
725
731
|
};
|
|
726
|
-
|
|
727
|
-
* Add feature based on the xr feature type.
|
|
728
|
-
* @param type - The type of the feature
|
|
729
|
-
* @param args - The constructor params of the feature
|
|
730
|
-
* @returns The feature which has been added
|
|
731
|
-
*/ _proto.addFeature = function addFeature(type) {
|
|
732
|
+
_proto.addFeature = function addFeature(type) {
|
|
732
733
|
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
733
734
|
args[_key - 1] = arguments[_key];
|
|
734
735
|
}
|
|
@@ -746,11 +747,7 @@ var XRTargetRayMode;
|
|
|
746
747
|
features.push(feature);
|
|
747
748
|
return feature;
|
|
748
749
|
};
|
|
749
|
-
|
|
750
|
-
* Get feature which match the type.
|
|
751
|
-
* @param type - The type of the feature
|
|
752
|
-
* @returns The feature which match type
|
|
753
|
-
*/ _proto.getFeature = function getFeature(type) {
|
|
750
|
+
_proto.getFeature = function getFeature(type) {
|
|
754
751
|
var features = this.features;
|
|
755
752
|
for(var i = 0, n = features.length; i < n; i++){
|
|
756
753
|
var feature = features[i];
|
|
@@ -759,12 +756,7 @@ var XRTargetRayMode;
|
|
|
759
756
|
}
|
|
760
757
|
}
|
|
761
758
|
};
|
|
762
|
-
|
|
763
|
-
* Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
|
|
764
|
-
* @param sessionMode - The mode of the session
|
|
765
|
-
* @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.
|
|
766
|
-
* @returns A promise that resolves if the XR virtual world is entered, otherwise rejects
|
|
767
|
-
*/ _proto.enterXR = function enterXR(sessionMode, autoRun) {
|
|
759
|
+
_proto.enterXR = function enterXR(sessionMode, autoRun) {
|
|
768
760
|
if (autoRun === void 0) autoRun = true;
|
|
769
761
|
var _this = this;
|
|
770
762
|
var sessionManager = this.sessionManager;
|
|
@@ -777,6 +769,7 @@ var XRTargetRayMode;
|
|
|
777
769
|
return new Promise(function(resolve, reject) {
|
|
778
770
|
// 1. Check if this xr mode is supported
|
|
779
771
|
sessionManager.isSupportedMode(sessionMode).then(function() {
|
|
772
|
+
sessionManager._setState(XRSessionState.Initializing);
|
|
780
773
|
// 2. Initialize session
|
|
781
774
|
sessionManager._initialize(sessionMode, _this.features).then(function() {
|
|
782
775
|
autoRun && sessionManager.run();
|
|
@@ -785,10 +778,7 @@ var XRTargetRayMode;
|
|
|
785
778
|
}, reject);
|
|
786
779
|
});
|
|
787
780
|
};
|
|
788
|
-
|
|
789
|
-
* Exit XR immersive mode, when you call this method, it will destroy the XR virtual world.
|
|
790
|
-
* @returns A promise that resolves if the XR virtual world is destroyed, otherwise rejects
|
|
791
|
-
*/ _proto.exitXR = function exitXR() {
|
|
781
|
+
_proto.exitXR = function exitXR() {
|
|
792
782
|
var _this = this;
|
|
793
783
|
return new Promise(function(resolve, reject) {
|
|
794
784
|
_this.sessionManager._exit().then(function() {
|
|
@@ -796,18 +786,13 @@ var XRTargetRayMode;
|
|
|
796
786
|
}, reject);
|
|
797
787
|
});
|
|
798
788
|
};
|
|
799
|
-
|
|
800
|
-
* @internal
|
|
801
|
-
*/ _proto._initialize = function _initialize(engine, xrDevice) {
|
|
802
|
-
this.features.length = 0;
|
|
789
|
+
_proto._initialize = function _initialize(engine, xrDevice) {
|
|
803
790
|
this._platformDevice = xrDevice;
|
|
804
791
|
this.sessionManager = new XRSessionManager(this, engine);
|
|
805
792
|
this.inputManager = new XRInputManager(this, engine);
|
|
806
793
|
this.cameraManager = new XRCameraManager(this);
|
|
807
794
|
};
|
|
808
|
-
|
|
809
|
-
* @internal
|
|
810
|
-
*/ _proto._update = function _update() {
|
|
795
|
+
_proto._update = function _update() {
|
|
811
796
|
var sessionManager = this.sessionManager;
|
|
812
797
|
if (sessionManager.state !== XRSessionState.Running) return;
|
|
813
798
|
sessionManager._onUpdate();
|
|
@@ -819,9 +804,7 @@ var XRTargetRayMode;
|
|
|
819
804
|
feature.enabled && feature._onUpdate();
|
|
820
805
|
}
|
|
821
806
|
};
|
|
822
|
-
|
|
823
|
-
* @internal
|
|
824
|
-
*/ _proto._destroy = function _destroy() {
|
|
807
|
+
_proto._destroy = function _destroy() {
|
|
825
808
|
var _this = this;
|
|
826
809
|
if (this.sessionManager._platformSession) {
|
|
827
810
|
this.exitXR().then(function() {
|
|
@@ -835,19 +818,13 @@ var XRTargetRayMode;
|
|
|
835
818
|
this.cameraManager._onDestroy();
|
|
836
819
|
}
|
|
837
820
|
};
|
|
838
|
-
|
|
839
|
-
* @internal
|
|
840
|
-
*/ _proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
|
|
821
|
+
_proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
|
|
841
822
|
return this.sessionManager._getRequestAnimationFrame();
|
|
842
823
|
};
|
|
843
|
-
|
|
844
|
-
* @internal
|
|
845
|
-
*/ _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
|
|
824
|
+
_proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
|
|
846
825
|
return this.sessionManager._getCancelAnimationFrame();
|
|
847
826
|
};
|
|
848
|
-
|
|
849
|
-
* @internal
|
|
850
|
-
*/ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
|
|
827
|
+
_proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
|
|
851
828
|
return this.cameraManager._getCameraClearFlagsMask(type);
|
|
852
829
|
};
|
|
853
830
|
/**
|
|
@@ -893,10 +870,7 @@ var XRTargetRayMode;
|
|
|
893
870
|
_create_class(XRManagerExtended, [
|
|
894
871
|
{
|
|
895
872
|
key: "origin",
|
|
896
|
-
get:
|
|
897
|
-
* The current origin of XR space.
|
|
898
|
-
* @remarks The connection point between the virtual world and the real world ( XR Space )
|
|
899
|
-
*/ function get() {
|
|
873
|
+
get: function get() {
|
|
900
874
|
return this._origin;
|
|
901
875
|
},
|
|
902
876
|
set: function set(value) {
|
|
@@ -1020,7 +994,7 @@ var XRRequestTrackingState;
|
|
|
1020
994
|
_this._updated = [];
|
|
1021
995
|
_this._removed = [];
|
|
1022
996
|
_this._statusSnapshot = {};
|
|
1023
|
-
_this._listeners =
|
|
997
|
+
_this._listeners = new SafeLoopArray();
|
|
1024
998
|
return _this;
|
|
1025
999
|
}
|
|
1026
1000
|
var _proto = XRTrackableFeature.prototype;
|
|
@@ -1028,22 +1002,22 @@ var XRRequestTrackingState;
|
|
|
1028
1002
|
* Add a listening function for tracked object changes.
|
|
1029
1003
|
* @param listener - The listening function
|
|
1030
1004
|
*/ _proto.addChangedListener = function addChangedListener(listener) {
|
|
1031
|
-
this._listeners.push(
|
|
1005
|
+
this._listeners.push({
|
|
1006
|
+
fn: listener
|
|
1007
|
+
});
|
|
1032
1008
|
};
|
|
1033
1009
|
/**
|
|
1034
1010
|
* Remove a listening function of tracked object changes.
|
|
1035
1011
|
* @param listener - The listening function
|
|
1036
1012
|
*/ _proto.removeChangedListener = function removeChangedListener(listener) {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
listeners.splice(index, 1);
|
|
1041
|
-
}
|
|
1013
|
+
this._listeners.findAndRemove(function(value) {
|
|
1014
|
+
return value.fn === listener ? value.destroyed = true : false;
|
|
1015
|
+
});
|
|
1042
1016
|
};
|
|
1043
1017
|
_proto._onUpdate = function _onUpdate() {
|
|
1044
1018
|
var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
|
|
1045
1019
|
var platformFrame = platformSession.frame;
|
|
1046
|
-
var _this = this, platformFeature = _this._platformFeature,
|
|
1020
|
+
var _this = this, platformFeature = _this._platformFeature, requestTrackings = _this._requestTrackings, statusSnapshot = _this._statusSnapshot, allTracked = _this._tracked, added = _this._added, updated = _this._updated, removed = _this._removed;
|
|
1047
1021
|
if (!platformFrame || !requestTrackings.length) {
|
|
1048
1022
|
return;
|
|
1049
1023
|
}
|
|
@@ -1095,8 +1069,10 @@ var XRRequestTrackingState;
|
|
|
1095
1069
|
requestTrackings[i1].state === XRRequestTrackingState.Destroyed && requestTrackings.splice(i1, 1);
|
|
1096
1070
|
}
|
|
1097
1071
|
if (added.length > 0 || updated.length > 0 || removed.length > 0) {
|
|
1072
|
+
var listeners = this._listeners.getLoopArray();
|
|
1098
1073
|
for(var i2 = 0, n3 = listeners.length; i2 < n3; i2++){
|
|
1099
|
-
listeners[i2]
|
|
1074
|
+
var listener = listeners[i2];
|
|
1075
|
+
!listener.destroyed && listener.fn(added, updated, removed);
|
|
1100
1076
|
}
|
|
1101
1077
|
}
|
|
1102
1078
|
};
|
|
@@ -1106,6 +1082,9 @@ var XRRequestTrackingState;
|
|
|
1106
1082
|
_proto._onSessionExit = function _onSessionExit() {
|
|
1107
1083
|
// prettier-ignore
|
|
1108
1084
|
this._requestTrackings.length = this._tracked.length = this._added.length = this._updated.length = this._removed.length = 0;
|
|
1085
|
+
this._listeners.findAndRemove(function(value) {
|
|
1086
|
+
return value.destroyed = true;
|
|
1087
|
+
});
|
|
1109
1088
|
};
|
|
1110
1089
|
_proto._addRequestTracking = function _addRequestTracking(requestTracking) {
|
|
1111
1090
|
var _this = this, platformFeature = _this._platformFeature;
|
|
@@ -1184,34 +1163,6 @@ function __decorate(decorators, target, key, desc) {
|
|
|
1184
1163
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1185
1164
|
}
|
|
1186
1165
|
|
|
1187
|
-
function __generator(thisArg, body) {
|
|
1188
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
1189
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
1190
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
1191
|
-
function step(op) {
|
|
1192
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1193
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
1194
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1195
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
1196
|
-
switch (op[0]) {
|
|
1197
|
-
case 0: case 1: t = op; break;
|
|
1198
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
1199
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
1200
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
1201
|
-
default:
|
|
1202
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
1203
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
1204
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
1205
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
1206
|
-
if (t[2]) _.ops.pop();
|
|
1207
|
-
_.trys.pop(); continue;
|
|
1208
|
-
}
|
|
1209
|
-
op = body.call(thisArg, _);
|
|
1210
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
1211
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1166
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1216
1167
|
var e = new Error(message);
|
|
1217
1168
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -1652,201 +1603,5 @@ XRReferenceImageLoader = __decorate([
|
|
|
1652
1603
|
resourceLoader("XRReferenceImage", [])
|
|
1653
1604
|
], XRReferenceImageLoader);
|
|
1654
1605
|
|
|
1655
|
-
|
|
1656
|
-
try {
|
|
1657
|
-
var info = gen[key](arg);
|
|
1658
|
-
var value = info.value;
|
|
1659
|
-
} catch (error) {
|
|
1660
|
-
reject(error);
|
|
1661
|
-
return;
|
|
1662
|
-
}
|
|
1663
|
-
if (info.done) resolve(value);
|
|
1664
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
1665
|
-
}
|
|
1666
|
-
function _async_to_generator(fn) {
|
|
1667
|
-
return function() {
|
|
1668
|
-
var self = this, args = arguments;
|
|
1669
|
-
|
|
1670
|
-
return new Promise(function(resolve, reject) {
|
|
1671
|
-
var gen = fn.apply(self, args);
|
|
1672
|
-
|
|
1673
|
-
function _next(value) {
|
|
1674
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1675
|
-
}
|
|
1676
|
-
|
|
1677
|
-
function _throw(err) {
|
|
1678
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
_next(undefined);
|
|
1682
|
-
});
|
|
1683
|
-
};
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
var XRSceneExtendParser = /*#__PURE__*/ function() {
|
|
1687
|
-
function XRSceneExtendParser() {}
|
|
1688
|
-
XRSceneExtendParser.parse = function parse(engine, context, data) {
|
|
1689
|
-
return _async_to_generator(function() {
|
|
1690
|
-
var xrManager, xr, origin, camera, leftCamera, rightCamera, features, entityMap, cameraManager, i, n, feature, _;
|
|
1691
|
-
return __generator(this, function(_state) {
|
|
1692
|
-
switch(_state.label){
|
|
1693
|
-
case 0:
|
|
1694
|
-
xrManager = engine.xrManager;
|
|
1695
|
-
if (!xrManager) {
|
|
1696
|
-
Logger.error("XRManager is not found in the engine.");
|
|
1697
|
-
return [
|
|
1698
|
-
2
|
|
1699
|
-
];
|
|
1700
|
-
}
|
|
1701
|
-
xr = data.scene.xr;
|
|
1702
|
-
origin = xr.origin, camera = xr.camera, leftCamera = xr.leftCamera, rightCamera = xr.rightCamera, features = xr.features;
|
|
1703
|
-
entityMap = context.entityMap;
|
|
1704
|
-
origin && (xrManager.origin = entityMap.get(origin));
|
|
1705
|
-
cameraManager = xrManager.cameraManager;
|
|
1706
|
-
setCamera(cameraManager, XRTrackedInputDevice.Camera, entityMap.get(camera));
|
|
1707
|
-
setCamera(cameraManager, XRTrackedInputDevice.LeftCamera, entityMap.get(leftCamera));
|
|
1708
|
-
setCamera(cameraManager, XRTrackedInputDevice.RightCamera, entityMap.get(rightCamera));
|
|
1709
|
-
i = 0, n = features.length;
|
|
1710
|
-
_state.label = 1;
|
|
1711
|
-
case 1:
|
|
1712
|
-
if (!(i < n)) return [
|
|
1713
|
-
3,
|
|
1714
|
-
9
|
|
1715
|
-
];
|
|
1716
|
-
feature = features[i];
|
|
1717
|
-
if (!feature.enable) return [
|
|
1718
|
-
3,
|
|
1719
|
-
8
|
|
1720
|
-
];
|
|
1721
|
-
_ = feature.type;
|
|
1722
|
-
switch(_){
|
|
1723
|
-
case XRFeatureType.ImageTracking:
|
|
1724
|
-
return [
|
|
1725
|
-
3,
|
|
1726
|
-
2
|
|
1727
|
-
];
|
|
1728
|
-
case XRFeatureType.PlaneTracking:
|
|
1729
|
-
return [
|
|
1730
|
-
3,
|
|
1731
|
-
4
|
|
1732
|
-
];
|
|
1733
|
-
case XRFeatureType.AnchorTracking:
|
|
1734
|
-
return [
|
|
1735
|
-
3,
|
|
1736
|
-
5
|
|
1737
|
-
];
|
|
1738
|
-
case XRFeatureType.HitTest:
|
|
1739
|
-
return [
|
|
1740
|
-
3,
|
|
1741
|
-
6
|
|
1742
|
-
];
|
|
1743
|
-
}
|
|
1744
|
-
return [
|
|
1745
|
-
3,
|
|
1746
|
-
7
|
|
1747
|
-
];
|
|
1748
|
-
case 2:
|
|
1749
|
-
return [
|
|
1750
|
-
4,
|
|
1751
|
-
addImageTracking(engine, xrManager, feature)
|
|
1752
|
-
];
|
|
1753
|
-
case 3:
|
|
1754
|
-
_state.sent();
|
|
1755
|
-
return [
|
|
1756
|
-
3,
|
|
1757
|
-
8
|
|
1758
|
-
];
|
|
1759
|
-
case 4:
|
|
1760
|
-
addPlaneTracking(xrManager, feature);
|
|
1761
|
-
return [
|
|
1762
|
-
3,
|
|
1763
|
-
8
|
|
1764
|
-
];
|
|
1765
|
-
case 5:
|
|
1766
|
-
addAnchorTracking(xrManager, feature);
|
|
1767
|
-
return [
|
|
1768
|
-
3,
|
|
1769
|
-
8
|
|
1770
|
-
];
|
|
1771
|
-
case 6:
|
|
1772
|
-
addHitTest(xrManager);
|
|
1773
|
-
return [
|
|
1774
|
-
3,
|
|
1775
|
-
8
|
|
1776
|
-
];
|
|
1777
|
-
case 7:
|
|
1778
|
-
return [
|
|
1779
|
-
3,
|
|
1780
|
-
8
|
|
1781
|
-
];
|
|
1782
|
-
case 8:
|
|
1783
|
-
i++;
|
|
1784
|
-
return [
|
|
1785
|
-
3,
|
|
1786
|
-
1
|
|
1787
|
-
];
|
|
1788
|
-
case 9:
|
|
1789
|
-
return [
|
|
1790
|
-
2
|
|
1791
|
-
];
|
|
1792
|
-
}
|
|
1793
|
-
});
|
|
1794
|
-
})();
|
|
1795
|
-
};
|
|
1796
|
-
return XRSceneExtendParser;
|
|
1797
|
-
}();
|
|
1798
|
-
XRSceneExtendParser = __decorate([
|
|
1799
|
-
registerSceneExtendParser("XR")
|
|
1800
|
-
], XRSceneExtendParser);
|
|
1801
|
-
function addImageTracking(engine, xrManager, schema) {
|
|
1802
|
-
if (!xrManager.isSupportedFeature(XRImageTracking)) {
|
|
1803
|
-
Logger.error("Image Tracking is not supported.");
|
|
1804
|
-
return;
|
|
1805
|
-
}
|
|
1806
|
-
var promises = [];
|
|
1807
|
-
var images = schema.images;
|
|
1808
|
-
var resourceManager = engine.resourceManager;
|
|
1809
|
-
for(var i = 0, n = images.length; i < n; i++){
|
|
1810
|
-
// @ts-ignore
|
|
1811
|
-
promises.push(resourceManager.getResourceByRef(images[i]));
|
|
1812
|
-
}
|
|
1813
|
-
return Promise.all(promises).then(function(xrReferenceImages) {
|
|
1814
|
-
xrManager.addFeature(XRImageTracking, xrReferenceImages);
|
|
1815
|
-
});
|
|
1816
|
-
}
|
|
1817
|
-
function addPlaneTracking(xrManager, schema) {
|
|
1818
|
-
if (!xrManager.isSupportedFeature(XRPlaneTracking)) {
|
|
1819
|
-
Logger.error("Plane Tracking is not supported.");
|
|
1820
|
-
return;
|
|
1821
|
-
}
|
|
1822
|
-
xrManager.addFeature(XRPlaneTracking, schema.detectionMode);
|
|
1823
|
-
}
|
|
1824
|
-
function addAnchorTracking(xrManager, schema) {
|
|
1825
|
-
if (!xrManager.isSupportedFeature(XRAnchorTracking)) {
|
|
1826
|
-
Logger.error("Anchor Tracking is not supported.");
|
|
1827
|
-
return;
|
|
1828
|
-
}
|
|
1829
|
-
var anchorTracking = xrManager.addFeature(XRAnchorTracking);
|
|
1830
|
-
var anchors = schema.anchors;
|
|
1831
|
-
for(var i = 0, n = anchors.length; i < n; i++){
|
|
1832
|
-
var anchor = anchors[i];
|
|
1833
|
-
var position = new Vector3().copyFrom(anchor.position);
|
|
1834
|
-
var rotation = new Quaternion().copyFrom(anchor.rotation);
|
|
1835
|
-
anchorTracking.addAnchor(position, rotation);
|
|
1836
|
-
}
|
|
1837
|
-
}
|
|
1838
|
-
function addHitTest(xrManager, schema) {
|
|
1839
|
-
if (!xrManager.isSupportedFeature(XRHitTest)) {
|
|
1840
|
-
Logger.error("Hit Test is not supported.");
|
|
1841
|
-
return;
|
|
1842
|
-
}
|
|
1843
|
-
xrManager.addFeature(XRHitTest);
|
|
1844
|
-
}
|
|
1845
|
-
function setCamera(cameraManager, device, entity) {
|
|
1846
|
-
var _entity;
|
|
1847
|
-
var camera = (_entity = entity) == null ? void 0 : _entity.getComponent(Camera);
|
|
1848
|
-
camera && cameraManager.attachCamera(device, camera);
|
|
1849
|
-
}
|
|
1850
|
-
|
|
1851
|
-
export { TrackableType, XRAnchor, XRAnchorTracking, XRCamera, XRCameraManager, XRController, XRFeature, XRFeatureType, XRHitResult, XRHitTest, XRImageTracking, XRInputButton, XRInputEventType, XRInputManager, XRPlaneMode, XRPlaneTracking, XRPose, XRReferenceImage, XRReferenceImageDecoder, XRReferenceImageLoader, XRRequestTrackingState, XRSceneExtendParser, XRSessionManager, XRSessionMode, XRSessionState, XRTargetRayMode, XRTrackableFeature, XRTracked, XRTrackedImage, XRTrackedInputDevice, XRTrackedPlane, XRTrackingState };
|
|
1606
|
+
export { TrackableType, XRAnchor, XRAnchorTracking, XRCamera, XRCameraManager, XRController, XRFeature, XRFeatureType, XRHitResult, XRHitTest, XRImageTracking, XRInputButton, XRInputEventType, XRInputManager, XRPlaneMode, XRPlaneTracking, XRPose, XRReferenceImage, XRReferenceImageDecoder, XRReferenceImageLoader, XRRequestTrackingState, XRSessionManager, XRSessionMode, XRSessionState, XRTargetRayMode, XRTrackableFeature, XRTracked, XRTrackedImage, XRTrackedInputDevice, XRTrackedPlane, XRTrackingState };
|
|
1852
1607
|
//# sourceMappingURL=module.js.map
|