@galacean/engine-xr-webxr 0.0.0-experimental-1.3-xr.5 → 0.0.0-experimental-1.3-xr.9
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 +61 -369
- 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.map +1 -1
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
package/dist/browser.js
CHANGED
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
*/ var XRSessionState;
|
|
160
160
|
(function(XRSessionState) {
|
|
161
161
|
XRSessionState[XRSessionState[/** Not initialized. */ "None"] = 0] = "None";
|
|
162
|
-
XRSessionState[XRSessionState[/**
|
|
162
|
+
XRSessionState[XRSessionState[/** Initializing session. */ "Initializing"] = 1] = "Initializing";
|
|
163
163
|
XRSessionState[XRSessionState[/** Initialized but not started. */ "Initialized"] = 2] = "Initialized";
|
|
164
164
|
XRSessionState[XRSessionState[/** Running. */ "Running"] = 3] = "Running";
|
|
165
165
|
XRSessionState[XRSessionState[/** Paused. */ "Paused"] = 4] = "Paused";
|
|
@@ -575,7 +575,7 @@
|
|
|
575
575
|
this._engine = _engine;
|
|
576
576
|
this._mode = XRSessionMode.None;
|
|
577
577
|
this._state = XRSessionState.None;
|
|
578
|
-
this._listeners =
|
|
578
|
+
this._listeners = new engine.SafeLoopArray();
|
|
579
579
|
// @ts-ignore
|
|
580
580
|
this._rhi = _engine._hardwareRenderer;
|
|
581
581
|
this._raf = requestAnimationFrame.bind(window);
|
|
@@ -598,7 +598,7 @@
|
|
|
598
598
|
throw new Error("Without session to run.");
|
|
599
599
|
}
|
|
600
600
|
platformSession.start();
|
|
601
|
-
this.
|
|
601
|
+
this._setState(XRSessionState.Running);
|
|
602
602
|
this._xrManager._onSessionStart();
|
|
603
603
|
if (!engine.isPaused) {
|
|
604
604
|
engine.pause();
|
|
@@ -618,7 +618,7 @@
|
|
|
618
618
|
rhi._mainFrameBuffer = null;
|
|
619
619
|
rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
|
|
620
620
|
platformSession.stop();
|
|
621
|
-
this.
|
|
621
|
+
this._setState(XRSessionState.Paused);
|
|
622
622
|
this._xrManager._onSessionStop();
|
|
623
623
|
if (!engine.isPaused) {
|
|
624
624
|
engine.pause();
|
|
@@ -628,17 +628,27 @@
|
|
|
628
628
|
/**
|
|
629
629
|
* Add a listening function for session state changes.
|
|
630
630
|
* @param listener - The listening function
|
|
631
|
-
*/ _proto.
|
|
632
|
-
this._listeners.push(
|
|
631
|
+
*/ _proto.addStateChangedListener = function addStateChangedListener(listener) {
|
|
632
|
+
this._listeners.push({
|
|
633
|
+
fn: listener
|
|
634
|
+
});
|
|
633
635
|
};
|
|
634
636
|
/**
|
|
635
637
|
* Remove a listening function of session state changes.
|
|
636
638
|
* @param listener - The listening function
|
|
637
|
-
*/ _proto.
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
639
|
+
*/ _proto.removeStateChangedListener = function removeStateChangedListener(listener) {
|
|
640
|
+
this._listeners.findAndRemove(function(value) {
|
|
641
|
+
return value.fn === listener ? value.destroyed = true : false;
|
|
642
|
+
});
|
|
643
|
+
};
|
|
644
|
+
/**
|
|
645
|
+
* @internal
|
|
646
|
+
*/ _proto._setState = function _setState(value) {
|
|
647
|
+
this._state = value;
|
|
648
|
+
var listeners = this._listeners.getLoopArray();
|
|
649
|
+
for(var i = 0, n = listeners.length; i < n; i++){
|
|
650
|
+
var listener = listeners[i];
|
|
651
|
+
!listener.destroyed && listener.fn(value);
|
|
642
652
|
}
|
|
643
653
|
};
|
|
644
654
|
/**
|
|
@@ -656,7 +666,7 @@
|
|
|
656
666
|
xrManager._platformDevice.requestSession(_this._rhi, mode, platformFeatures).then(function(platformSession) {
|
|
657
667
|
_this._mode = mode;
|
|
658
668
|
_this._platformSession = platformSession;
|
|
659
|
-
_this.
|
|
669
|
+
_this._setState(XRSessionState.Initialized);
|
|
660
670
|
platformSession.setSessionExitCallBack(_this._onSessionExit);
|
|
661
671
|
platformSession.addEventListener();
|
|
662
672
|
xrManager._onSessionInit();
|
|
@@ -705,7 +715,7 @@
|
|
|
705
715
|
rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
|
|
706
716
|
platformSession.removeEventListener();
|
|
707
717
|
this._platformSession = null;
|
|
708
|
-
this.
|
|
718
|
+
this._setState(XRSessionState.None);
|
|
709
719
|
this._xrManager._onSessionExit();
|
|
710
720
|
if (!engine.isPaused) {
|
|
711
721
|
engine.pause();
|
|
@@ -714,7 +724,12 @@
|
|
|
714
724
|
};
|
|
715
725
|
/**
|
|
716
726
|
* @internal
|
|
717
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
727
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
728
|
+
this._listeners.findAndRemove(function(value) {
|
|
729
|
+
return value.destroyed = true;
|
|
730
|
+
});
|
|
731
|
+
this._raf = this._caf = null;
|
|
732
|
+
};
|
|
718
733
|
_create_class$1(XRSessionManager, [
|
|
719
734
|
{
|
|
720
735
|
key: "mode",
|
|
@@ -730,15 +745,6 @@
|
|
|
730
745
|
* Return the current session state.
|
|
731
746
|
*/ function get() {
|
|
732
747
|
return this._state;
|
|
733
|
-
},
|
|
734
|
-
set: /**
|
|
735
|
-
* @internal
|
|
736
|
-
*/ function set(value) {
|
|
737
|
-
this._state = value;
|
|
738
|
-
var listeners = this._listeners;
|
|
739
|
-
for(var i = 0, n = listeners.length; i < n; i++){
|
|
740
|
-
listeners[i](value);
|
|
741
|
-
}
|
|
742
748
|
}
|
|
743
749
|
},
|
|
744
750
|
{
|
|
@@ -761,26 +767,20 @@
|
|
|
761
767
|
return XRSessionManager;
|
|
762
768
|
}();
|
|
763
769
|
/**
|
|
764
|
-
*
|
|
770
|
+
* @internal
|
|
765
771
|
*/ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
|
|
766
772
|
var XRManagerExtended = function XRManagerExtended() {
|
|
767
|
-
|
|
773
|
+
var _this;
|
|
774
|
+
_this = XRManager1.apply(this, arguments) || this;
|
|
775
|
+
_this.features = [];
|
|
776
|
+
return _this;
|
|
768
777
|
};
|
|
769
778
|
_inherits(XRManagerExtended, XRManager1);
|
|
770
779
|
var _proto = XRManagerExtended.prototype;
|
|
771
|
-
|
|
772
|
-
* Check if the specified feature is supported.
|
|
773
|
-
* @param type - The type of the feature
|
|
774
|
-
* @returns If the feature is supported
|
|
775
|
-
*/ _proto.isSupportedFeature = function isSupportedFeature(feature) {
|
|
780
|
+
_proto.isSupportedFeature = function isSupportedFeature(feature) {
|
|
776
781
|
return this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(feature));
|
|
777
782
|
};
|
|
778
|
-
|
|
779
|
-
* Add feature based on the xr feature type.
|
|
780
|
-
* @param type - The type of the feature
|
|
781
|
-
* @param args - The constructor params of the feature
|
|
782
|
-
* @returns The feature which has been added
|
|
783
|
-
*/ _proto.addFeature = function addFeature(type) {
|
|
783
|
+
_proto.addFeature = function addFeature(type) {
|
|
784
784
|
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
785
785
|
args[_key - 1] = arguments[_key];
|
|
786
786
|
}
|
|
@@ -798,11 +798,7 @@
|
|
|
798
798
|
features.push(feature);
|
|
799
799
|
return feature;
|
|
800
800
|
};
|
|
801
|
-
|
|
802
|
-
* Get feature which match the type.
|
|
803
|
-
* @param type - The type of the feature
|
|
804
|
-
* @returns The feature which match type
|
|
805
|
-
*/ _proto.getFeature = function getFeature(type) {
|
|
801
|
+
_proto.getFeature = function getFeature(type) {
|
|
806
802
|
var features = this.features;
|
|
807
803
|
for(var i = 0, n = features.length; i < n; i++){
|
|
808
804
|
var feature = features[i];
|
|
@@ -811,12 +807,7 @@
|
|
|
811
807
|
}
|
|
812
808
|
}
|
|
813
809
|
};
|
|
814
|
-
|
|
815
|
-
* Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
|
|
816
|
-
* @param sessionMode - The mode of the session
|
|
817
|
-
* @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.
|
|
818
|
-
* @returns A promise that resolves if the XR virtual world is entered, otherwise rejects
|
|
819
|
-
*/ _proto.enterXR = function enterXR(sessionMode, autoRun) {
|
|
810
|
+
_proto.enterXR = function enterXR(sessionMode, autoRun) {
|
|
820
811
|
if (autoRun === void 0) autoRun = true;
|
|
821
812
|
var _this = this;
|
|
822
813
|
var sessionManager = this.sessionManager;
|
|
@@ -829,7 +820,7 @@
|
|
|
829
820
|
return new Promise(function(resolve, reject) {
|
|
830
821
|
// 1. Check if this xr mode is supported
|
|
831
822
|
sessionManager.isSupportedMode(sessionMode).then(function() {
|
|
832
|
-
sessionManager.
|
|
823
|
+
sessionManager._setState(XRSessionState.Initializing);
|
|
833
824
|
// 2. Initialize session
|
|
834
825
|
sessionManager._initialize(sessionMode, _this.features).then(function() {
|
|
835
826
|
autoRun && sessionManager.run();
|
|
@@ -838,10 +829,7 @@
|
|
|
838
829
|
}, reject);
|
|
839
830
|
});
|
|
840
831
|
};
|
|
841
|
-
|
|
842
|
-
* Exit XR immersive mode, when you call this method, it will destroy the XR virtual world.
|
|
843
|
-
* @returns A promise that resolves if the XR virtual world is destroyed, otherwise rejects
|
|
844
|
-
*/ _proto.exitXR = function exitXR() {
|
|
832
|
+
_proto.exitXR = function exitXR() {
|
|
845
833
|
var _this = this;
|
|
846
834
|
return new Promise(function(resolve, reject) {
|
|
847
835
|
_this.sessionManager._exit().then(function() {
|
|
@@ -849,18 +837,13 @@
|
|
|
849
837
|
}, reject);
|
|
850
838
|
});
|
|
851
839
|
};
|
|
852
|
-
|
|
853
|
-
* @internal
|
|
854
|
-
*/ _proto._initialize = function _initialize(engine, xrDevice) {
|
|
855
|
-
this.features.length = 0;
|
|
840
|
+
_proto._initialize = function _initialize(engine, xrDevice) {
|
|
856
841
|
this._platformDevice = xrDevice;
|
|
857
842
|
this.sessionManager = new XRSessionManager(this, engine);
|
|
858
843
|
this.inputManager = new XRInputManager(this, engine);
|
|
859
844
|
this.cameraManager = new XRCameraManager(this);
|
|
860
845
|
};
|
|
861
|
-
|
|
862
|
-
* @internal
|
|
863
|
-
*/ _proto._update = function _update() {
|
|
846
|
+
_proto._update = function _update() {
|
|
864
847
|
var sessionManager = this.sessionManager;
|
|
865
848
|
if (sessionManager.state !== XRSessionState.Running) return;
|
|
866
849
|
sessionManager._onUpdate();
|
|
@@ -872,9 +855,7 @@
|
|
|
872
855
|
feature.enabled && feature._onUpdate();
|
|
873
856
|
}
|
|
874
857
|
};
|
|
875
|
-
|
|
876
|
-
* @internal
|
|
877
|
-
*/ _proto._destroy = function _destroy() {
|
|
858
|
+
_proto._destroy = function _destroy() {
|
|
878
859
|
var _this = this;
|
|
879
860
|
if (this.sessionManager._platformSession) {
|
|
880
861
|
this.exitXR().then(function() {
|
|
@@ -888,19 +869,13 @@
|
|
|
888
869
|
this.cameraManager._onDestroy();
|
|
889
870
|
}
|
|
890
871
|
};
|
|
891
|
-
|
|
892
|
-
* @internal
|
|
893
|
-
*/ _proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
|
|
872
|
+
_proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
|
|
894
873
|
return this.sessionManager._getRequestAnimationFrame();
|
|
895
874
|
};
|
|
896
|
-
|
|
897
|
-
* @internal
|
|
898
|
-
*/ _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
|
|
875
|
+
_proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
|
|
899
876
|
return this.sessionManager._getCancelAnimationFrame();
|
|
900
877
|
};
|
|
901
|
-
|
|
902
|
-
* @internal
|
|
903
|
-
*/ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
|
|
878
|
+
_proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
|
|
904
879
|
return this.cameraManager._getCameraClearFlagsMask(type);
|
|
905
880
|
};
|
|
906
881
|
/**
|
|
@@ -946,10 +921,7 @@
|
|
|
946
921
|
_create_class$1(XRManagerExtended, [
|
|
947
922
|
{
|
|
948
923
|
key: "origin",
|
|
949
|
-
get:
|
|
950
|
-
* The current origin of XR space.
|
|
951
|
-
* @remarks The connection point between the virtual world and the real world ( XR Space )
|
|
952
|
-
*/ function get() {
|
|
924
|
+
get: function get() {
|
|
953
925
|
return this._origin;
|
|
954
926
|
},
|
|
955
927
|
set: function set(value) {
|
|
@@ -1068,7 +1040,7 @@
|
|
|
1068
1040
|
_this._updated = [];
|
|
1069
1041
|
_this._removed = [];
|
|
1070
1042
|
_this._statusSnapshot = {};
|
|
1071
|
-
_this._listeners =
|
|
1043
|
+
_this._listeners = new engine.SafeLoopArray();
|
|
1072
1044
|
return _this;
|
|
1073
1045
|
};
|
|
1074
1046
|
_inherits(XRTrackableFeature, XRFeature1);
|
|
@@ -1077,22 +1049,22 @@
|
|
|
1077
1049
|
* Add a listening function for tracked object changes.
|
|
1078
1050
|
* @param listener - The listening function
|
|
1079
1051
|
*/ _proto.addChangedListener = function addChangedListener(listener) {
|
|
1080
|
-
this._listeners.push(
|
|
1052
|
+
this._listeners.push({
|
|
1053
|
+
fn: listener
|
|
1054
|
+
});
|
|
1081
1055
|
};
|
|
1082
1056
|
/**
|
|
1083
1057
|
* Remove a listening function of tracked object changes.
|
|
1084
1058
|
* @param listener - The listening function
|
|
1085
1059
|
*/ _proto.removeChangedListener = function removeChangedListener(listener) {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
listeners.splice(index, 1);
|
|
1090
|
-
}
|
|
1060
|
+
this._listeners.findAndRemove(function(value) {
|
|
1061
|
+
return value.fn === listener ? value.destroyed = true : false;
|
|
1062
|
+
});
|
|
1091
1063
|
};
|
|
1092
1064
|
_proto._onUpdate = function _onUpdate() {
|
|
1093
1065
|
var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
|
|
1094
1066
|
var platformFrame = platformSession.frame;
|
|
1095
|
-
var _this = this, platformFeature = _this._platformFeature,
|
|
1067
|
+
var _this = this, platformFeature = _this._platformFeature, requestTrackings = _this._requestTrackings, statusSnapshot = _this._statusSnapshot, allTracked = _this._tracked, added = _this._added, updated = _this._updated, removed = _this._removed;
|
|
1096
1068
|
if (!platformFrame || !requestTrackings.length) {
|
|
1097
1069
|
return;
|
|
1098
1070
|
}
|
|
@@ -1144,8 +1116,10 @@
|
|
|
1144
1116
|
requestTrackings[i1].state === XRRequestTrackingState.Destroyed && requestTrackings.splice(i1, 1);
|
|
1145
1117
|
}
|
|
1146
1118
|
if (added.length > 0 || updated.length > 0 || removed.length > 0) {
|
|
1119
|
+
var listeners = this._listeners.getLoopArray();
|
|
1147
1120
|
for(var i2 = 0, n3 = listeners.length; i2 < n3; i2++){
|
|
1148
|
-
listeners[i2]
|
|
1121
|
+
var listener = listeners[i2];
|
|
1122
|
+
!listener.destroyed && listener.fn(added, updated, removed);
|
|
1149
1123
|
}
|
|
1150
1124
|
}
|
|
1151
1125
|
};
|
|
@@ -1155,6 +1129,9 @@
|
|
|
1155
1129
|
_proto._onSessionExit = function _onSessionExit() {
|
|
1156
1130
|
// prettier-ignore
|
|
1157
1131
|
this._requestTrackings.length = this._tracked.length = this._added.length = this._updated.length = this._removed.length = 0;
|
|
1132
|
+
this._listeners.findAndRemove(function(value) {
|
|
1133
|
+
return value.destroyed = true;
|
|
1134
|
+
});
|
|
1158
1135
|
};
|
|
1159
1136
|
_proto._addRequestTracking = function _addRequestTracking(requestTracking) {
|
|
1160
1137
|
var _this = this, platformFeature = _this._platformFeature;
|
|
@@ -1226,101 +1203,6 @@
|
|
|
1226
1203
|
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;
|
|
1227
1204
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1228
1205
|
}
|
|
1229
|
-
function __generator(thisArg, body) {
|
|
1230
|
-
var verb = function verb(n) {
|
|
1231
|
-
return function(v) {
|
|
1232
|
-
return step([
|
|
1233
|
-
n,
|
|
1234
|
-
v
|
|
1235
|
-
]);
|
|
1236
|
-
};
|
|
1237
|
-
};
|
|
1238
|
-
var step = function step(op) {
|
|
1239
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1240
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
1241
|
-
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;
|
|
1242
|
-
if (y = 0, t) op = [
|
|
1243
|
-
op[0] & 2,
|
|
1244
|
-
t.value
|
|
1245
|
-
];
|
|
1246
|
-
switch(op[0]){
|
|
1247
|
-
case 0:
|
|
1248
|
-
case 1:
|
|
1249
|
-
t = op;
|
|
1250
|
-
break;
|
|
1251
|
-
case 4:
|
|
1252
|
-
_.label++;
|
|
1253
|
-
return {
|
|
1254
|
-
value: op[1],
|
|
1255
|
-
done: false
|
|
1256
|
-
};
|
|
1257
|
-
case 5:
|
|
1258
|
-
_.label++;
|
|
1259
|
-
y = op[1];
|
|
1260
|
-
op = [
|
|
1261
|
-
0
|
|
1262
|
-
];
|
|
1263
|
-
continue;
|
|
1264
|
-
case 7:
|
|
1265
|
-
op = _.ops.pop();
|
|
1266
|
-
_.trys.pop();
|
|
1267
|
-
continue;
|
|
1268
|
-
default:
|
|
1269
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1270
|
-
_ = 0;
|
|
1271
|
-
continue;
|
|
1272
|
-
}
|
|
1273
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1274
|
-
_.label = op[1];
|
|
1275
|
-
break;
|
|
1276
|
-
}
|
|
1277
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1278
|
-
_.label = t[1];
|
|
1279
|
-
t = op;
|
|
1280
|
-
break;
|
|
1281
|
-
}
|
|
1282
|
-
if (t && _.label < t[2]) {
|
|
1283
|
-
_.label = t[2];
|
|
1284
|
-
_.ops.push(op);
|
|
1285
|
-
break;
|
|
1286
|
-
}
|
|
1287
|
-
if (t[2]) _.ops.pop();
|
|
1288
|
-
_.trys.pop();
|
|
1289
|
-
continue;
|
|
1290
|
-
}
|
|
1291
|
-
op = body.call(thisArg, _);
|
|
1292
|
-
} catch (e) {
|
|
1293
|
-
op = [
|
|
1294
|
-
6,
|
|
1295
|
-
e
|
|
1296
|
-
];
|
|
1297
|
-
y = 0;
|
|
1298
|
-
} finally{
|
|
1299
|
-
f = t = 0;
|
|
1300
|
-
}
|
|
1301
|
-
if (op[0] & 5) throw op[1];
|
|
1302
|
-
return {
|
|
1303
|
-
value: op[0] ? op[1] : void 0,
|
|
1304
|
-
done: true
|
|
1305
|
-
};
|
|
1306
|
-
};
|
|
1307
|
-
var _ = {
|
|
1308
|
-
label: 0,
|
|
1309
|
-
sent: function sent() {
|
|
1310
|
-
if (t[0] & 1) throw t[1];
|
|
1311
|
-
return t[1];
|
|
1312
|
-
},
|
|
1313
|
-
trys: [],
|
|
1314
|
-
ops: []
|
|
1315
|
-
}, f, y, t, g;
|
|
1316
|
-
return g = {
|
|
1317
|
-
next: verb(0),
|
|
1318
|
-
"throw": verb(1),
|
|
1319
|
-
"return": verb(2)
|
|
1320
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1321
|
-
return this;
|
|
1322
|
-
}), g;
|
|
1323
|
-
}
|
|
1324
1206
|
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
1325
1207
|
var e = new Error(message);
|
|
1326
1208
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -1742,196 +1624,6 @@
|
|
|
1742
1624
|
XRReferenceImageLoader = __decorate([
|
|
1743
1625
|
engine.resourceLoader("XRReferenceImage", [])
|
|
1744
1626
|
], XRReferenceImageLoader);
|
|
1745
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1746
|
-
try {
|
|
1747
|
-
var info = gen[key](arg);
|
|
1748
|
-
var value = info.value;
|
|
1749
|
-
} catch (error) {
|
|
1750
|
-
reject(error);
|
|
1751
|
-
return;
|
|
1752
|
-
}
|
|
1753
|
-
if (info.done) resolve(value);
|
|
1754
|
-
else Promise.resolve(value).then(_next, _throw);
|
|
1755
|
-
}
|
|
1756
|
-
function _async_to_generator(fn) {
|
|
1757
|
-
return function() {
|
|
1758
|
-
var self = this, args = arguments;
|
|
1759
|
-
return new Promise(function(resolve, reject) {
|
|
1760
|
-
var gen = fn.apply(self, args);
|
|
1761
|
-
function _next(value) {
|
|
1762
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
1763
|
-
}
|
|
1764
|
-
function _throw(err) {
|
|
1765
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1766
|
-
}
|
|
1767
|
-
_next(undefined);
|
|
1768
|
-
});
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
var XRSceneExtendParser = /*#__PURE__*/ function() {
|
|
1772
|
-
var XRSceneExtendParser = function XRSceneExtendParser() {};
|
|
1773
|
-
XRSceneExtendParser.parse = function parse(engine$1, context, data) {
|
|
1774
|
-
return _async_to_generator(function() {
|
|
1775
|
-
var xrManager, xr, origin, camera, leftCamera, rightCamera, features, entityMap, cameraManager, i, n, feature, _;
|
|
1776
|
-
return __generator(this, function(_state) {
|
|
1777
|
-
switch(_state.label){
|
|
1778
|
-
case 0:
|
|
1779
|
-
xrManager = engine$1.xrManager;
|
|
1780
|
-
if (!xrManager) {
|
|
1781
|
-
engine.Logger.error("XRManager is not found in the engine.");
|
|
1782
|
-
return [
|
|
1783
|
-
2
|
|
1784
|
-
];
|
|
1785
|
-
}
|
|
1786
|
-
xr = data.scene.xr;
|
|
1787
|
-
origin = xr.origin, camera = xr.camera, leftCamera = xr.leftCamera, rightCamera = xr.rightCamera, features = xr.features;
|
|
1788
|
-
entityMap = context.entityMap;
|
|
1789
|
-
origin && (xrManager.origin = entityMap.get(origin));
|
|
1790
|
-
cameraManager = xrManager.cameraManager;
|
|
1791
|
-
setCamera(cameraManager, XRTrackedInputDevice.Camera, entityMap.get(camera));
|
|
1792
|
-
setCamera(cameraManager, XRTrackedInputDevice.LeftCamera, entityMap.get(leftCamera));
|
|
1793
|
-
setCamera(cameraManager, XRTrackedInputDevice.RightCamera, entityMap.get(rightCamera));
|
|
1794
|
-
i = 0, n = features.length;
|
|
1795
|
-
_state.label = 1;
|
|
1796
|
-
case 1:
|
|
1797
|
-
if (!(i < n)) return [
|
|
1798
|
-
3,
|
|
1799
|
-
9
|
|
1800
|
-
];
|
|
1801
|
-
feature = features[i];
|
|
1802
|
-
if (!feature.enable) return [
|
|
1803
|
-
3,
|
|
1804
|
-
8
|
|
1805
|
-
];
|
|
1806
|
-
_ = feature.type;
|
|
1807
|
-
switch(_){
|
|
1808
|
-
case XRFeatureType.ImageTracking:
|
|
1809
|
-
return [
|
|
1810
|
-
3,
|
|
1811
|
-
2
|
|
1812
|
-
];
|
|
1813
|
-
case XRFeatureType.PlaneTracking:
|
|
1814
|
-
return [
|
|
1815
|
-
3,
|
|
1816
|
-
4
|
|
1817
|
-
];
|
|
1818
|
-
case XRFeatureType.AnchorTracking:
|
|
1819
|
-
return [
|
|
1820
|
-
3,
|
|
1821
|
-
5
|
|
1822
|
-
];
|
|
1823
|
-
case XRFeatureType.HitTest:
|
|
1824
|
-
return [
|
|
1825
|
-
3,
|
|
1826
|
-
6
|
|
1827
|
-
];
|
|
1828
|
-
}
|
|
1829
|
-
return [
|
|
1830
|
-
3,
|
|
1831
|
-
7
|
|
1832
|
-
];
|
|
1833
|
-
case 2:
|
|
1834
|
-
return [
|
|
1835
|
-
4,
|
|
1836
|
-
addImageTracking(engine$1, xrManager, feature)
|
|
1837
|
-
];
|
|
1838
|
-
case 3:
|
|
1839
|
-
_state.sent();
|
|
1840
|
-
return [
|
|
1841
|
-
3,
|
|
1842
|
-
8
|
|
1843
|
-
];
|
|
1844
|
-
case 4:
|
|
1845
|
-
addPlaneTracking(xrManager, feature);
|
|
1846
|
-
return [
|
|
1847
|
-
3,
|
|
1848
|
-
8
|
|
1849
|
-
];
|
|
1850
|
-
case 5:
|
|
1851
|
-
addAnchorTracking(xrManager, feature);
|
|
1852
|
-
return [
|
|
1853
|
-
3,
|
|
1854
|
-
8
|
|
1855
|
-
];
|
|
1856
|
-
case 6:
|
|
1857
|
-
addHitTest(xrManager);
|
|
1858
|
-
return [
|
|
1859
|
-
3,
|
|
1860
|
-
8
|
|
1861
|
-
];
|
|
1862
|
-
case 7:
|
|
1863
|
-
return [
|
|
1864
|
-
3,
|
|
1865
|
-
8
|
|
1866
|
-
];
|
|
1867
|
-
case 8:
|
|
1868
|
-
i++;
|
|
1869
|
-
return [
|
|
1870
|
-
3,
|
|
1871
|
-
1
|
|
1872
|
-
];
|
|
1873
|
-
case 9:
|
|
1874
|
-
return [
|
|
1875
|
-
2
|
|
1876
|
-
];
|
|
1877
|
-
}
|
|
1878
|
-
});
|
|
1879
|
-
})();
|
|
1880
|
-
};
|
|
1881
|
-
return XRSceneExtendParser;
|
|
1882
|
-
}();
|
|
1883
|
-
XRSceneExtendParser = __decorate([
|
|
1884
|
-
engine.registerSceneExtendParser("XR")
|
|
1885
|
-
], XRSceneExtendParser);
|
|
1886
|
-
function addImageTracking(engine$1, xrManager, schema) {
|
|
1887
|
-
if (!xrManager.isSupportedFeature(XRImageTracking)) {
|
|
1888
|
-
engine.Logger.error("Image Tracking is not supported.");
|
|
1889
|
-
return;
|
|
1890
|
-
}
|
|
1891
|
-
var promises = [];
|
|
1892
|
-
var images = schema.images;
|
|
1893
|
-
var resourceManager = engine$1.resourceManager;
|
|
1894
|
-
for(var i = 0, n = images.length; i < n; i++){
|
|
1895
|
-
// @ts-ignore
|
|
1896
|
-
promises.push(resourceManager.getResourceByRef(images[i]));
|
|
1897
|
-
}
|
|
1898
|
-
return Promise.all(promises).then(function(xrReferenceImages) {
|
|
1899
|
-
xrManager.addFeature(XRImageTracking, xrReferenceImages);
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
function addPlaneTracking(xrManager, schema) {
|
|
1903
|
-
if (!xrManager.isSupportedFeature(XRPlaneTracking)) {
|
|
1904
|
-
engine.Logger.error("Plane Tracking is not supported.");
|
|
1905
|
-
return;
|
|
1906
|
-
}
|
|
1907
|
-
xrManager.addFeature(XRPlaneTracking, schema.detectionMode);
|
|
1908
|
-
}
|
|
1909
|
-
function addAnchorTracking(xrManager, schema) {
|
|
1910
|
-
if (!xrManager.isSupportedFeature(XRAnchorTracking)) {
|
|
1911
|
-
engine.Logger.error("Anchor Tracking is not supported.");
|
|
1912
|
-
return;
|
|
1913
|
-
}
|
|
1914
|
-
var anchorTracking = xrManager.addFeature(XRAnchorTracking);
|
|
1915
|
-
var anchors = schema.anchors;
|
|
1916
|
-
for(var i = 0, n = anchors.length; i < n; i++){
|
|
1917
|
-
var anchor = anchors[i];
|
|
1918
|
-
var position = new engine.Vector3().copyFrom(anchor.position);
|
|
1919
|
-
var rotation = new engine.Quaternion().copyFrom(anchor.rotation);
|
|
1920
|
-
anchorTracking.addAnchor(position, rotation);
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
function addHitTest(xrManager, schema) {
|
|
1924
|
-
if (!xrManager.isSupportedFeature(XRHitTest)) {
|
|
1925
|
-
engine.Logger.error("Hit Test is not supported.");
|
|
1926
|
-
return;
|
|
1927
|
-
}
|
|
1928
|
-
xrManager.addFeature(XRHitTest);
|
|
1929
|
-
}
|
|
1930
|
-
function setCamera(cameraManager, device, entity) {
|
|
1931
|
-
var _entity;
|
|
1932
|
-
var camera = (_entity = entity) == null ? void 0 : _entity.getComponent(engine.Camera);
|
|
1933
|
-
camera && cameraManager.attachCamera(device, camera);
|
|
1934
|
-
}
|
|
1935
1627
|
|
|
1936
1628
|
function _is_native_reflect_construct() {
|
|
1937
1629
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|