@galacean/engine-xr 0.0.0-experimental-stateMachine.0 → 0.0.0-experimental-1.2-xr.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.
@@ -555,6 +555,7 @@ exports.XRTargetRayMode = void 0;
555
555
  engine.pause();
556
556
  engine.resume();
557
557
  }
558
+ engine.dispatch("XRSessionStart");
558
559
  };
559
560
  /**
560
561
  * Stop the session.
@@ -575,6 +576,7 @@ exports.XRTargetRayMode = void 0;
575
576
  engine.pause();
576
577
  engine.resume();
577
578
  }
579
+ engine.dispatch("XRSessionStop");
578
580
  };
579
581
  /**
580
582
  * @internal
@@ -596,6 +598,7 @@ exports.XRTargetRayMode = void 0;
596
598
  platformSession.addEventListener();
597
599
  xrManager._onSessionInit();
598
600
  resolve();
601
+ _this._engine.dispatch("XRSessionInit");
599
602
  }, reject);
600
603
  });
601
604
  };
@@ -628,11 +631,14 @@ exports.XRTargetRayMode = void 0;
628
631
  /**
629
632
  * @internal
630
633
  */ _proto._exit = function _exit() {
631
- var _this = this, platformSession = _this._platformSession;
634
+ var _this = this;
635
+ var _this1 = this, platformSession = _this1._platformSession;
632
636
  if (!platformSession) {
633
637
  return Promise.reject("Without session to stop.");
634
638
  }
635
- return platformSession.end();
639
+ return platformSession.end().then(function() {
640
+ _this._engine.dispatch("XRSessionExit");
641
+ });
636
642
  };
637
643
  _proto._onSessionExit = function _onSessionExit() {
638
644
  var _this = this, rhi = _this._rhi, platformSession = _this._platformSession, engine = _this._engine;
@@ -714,14 +720,16 @@ exports.XRTargetRayMode = void 0;
714
720
  if (this.sessionManager._platformSession) {
715
721
  throw new Error("Cannot add feature when the session is initialized.");
716
722
  }
717
- var _this = this, features = _this._features;
723
+ var _this = this, features = _this._features; _this._platformDevice;
724
+ if (!this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(type))) {
725
+ throw new Error("The feature is not supported");
726
+ }
718
727
  for(var i = 0, n = features.length; i < n; i++){
719
- var feature = features[i];
720
- if (_instanceof(feature, type)) throw new Error("The feature has been added");
728
+ if (_instanceof(features[i], type)) throw new Error("The feature has been added");
721
729
  }
722
- var feature1 = _construct(type, [].concat(this, args));
723
- this._features.push(feature1);
724
- return feature1;
730
+ var feature = _construct(type, [].concat(this, args));
731
+ this._features.push(feature);
732
+ return feature;
725
733
  };
726
734
  /**
727
735
  * Get feature which match the type.
@@ -736,16 +744,16 @@ exports.XRTargetRayMode = void 0;
736
744
  }
737
745
  }
738
746
  };
739
- _proto.getFeatures = function getFeatures(type, out) {
747
+ _proto.getFeatures = function getFeatures(out) {
748
+ var _this = this, features = _this._features;
749
+ var length = features.length;
740
750
  if (out) {
741
- out.length = 0;
751
+ out.length = length;
742
752
  } else {
743
- out = [];
753
+ out = new Array(length);
744
754
  }
745
- var _this = this, features = _this._features;
746
- for(var i = 0, n = features.length; i < n; i--){
747
- var feature = features[i];
748
- _instanceof(feature, type) && out.push(feature);
755
+ for(var i = 0; i < length; i--){
756
+ out[i] = features[i];
749
757
  }
750
758
  return out;
751
759
  };
@@ -980,47 +988,10 @@ ApplyMixins(miniprogram.XRManager, [
980
988
  }();
981
989
 
982
990
  /**
983
- * Enum for the types of hit test that can be performed.
984
- * Note: currently only supports plane.
985
- */ exports.TrackableType = void 0;
986
- (function(TrackableType) {
987
- TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
988
- TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
989
- })(exports.TrackableType || (exports.TrackableType = {}));
990
-
991
- /**
992
- * XR hit result.
993
- * It is the detection result returned by using XR HitTest feature.
994
- */ var XRHitResult = function XRHitResult() {
995
- /** The position of the hit point. */ this.point = new miniprogram.Vector3();
996
- /** The normal of the hit point. */ this.normal = new miniprogram.Vector3();
997
- };
998
-
999
- /******************************************************************************
1000
- Copyright (c) Microsoft Corporation.
1001
-
1002
- Permission to use, copy, modify, and/or distribute this software for any
1003
- purpose with or without fee is hereby granted.
1004
-
1005
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1006
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1007
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1008
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1009
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1010
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1011
- PERFORMANCE OF THIS SOFTWARE.
1012
- ***************************************************************************** */
1013
-
1014
- function __decorate(decorators, target, key, desc) {
1015
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1016
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1017
- 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;
1018
- return c > 3 && r && Object.defineProperty(target, key, r), r;
1019
- }
1020
-
1021
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1022
- var e = new Error(message);
1023
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
991
+ * The base class of XR tracked object.
992
+ */ var XRTracked = function XRTracked() {
993
+ /** The pose of the trackable in XR space. */ this.pose = new XRPose();
994
+ /** The tracking state of the trackable. */ this.state = exports.XRTrackingState.NotTracking;
1024
995
  };
1025
996
 
1026
997
  exports.XRFeatureType = void 0;
@@ -1176,6 +1147,50 @@ exports.XRRequestTrackingState = void 0;
1176
1147
  XRTrackableFeature._uuid = 0;
1177
1148
  })();
1178
1149
 
1150
+ /**
1151
+ * Enum for the types of hit test that can be performed.
1152
+ * Note: currently only supports plane.
1153
+ */ exports.TrackableType = void 0;
1154
+ (function(TrackableType) {
1155
+ TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
1156
+ TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
1157
+ })(exports.TrackableType || (exports.TrackableType = {}));
1158
+
1159
+ /**
1160
+ * XR hit result.
1161
+ * It is the detection result returned by using XR HitTest feature.
1162
+ */ var XRHitResult = function XRHitResult() {
1163
+ /** The position of the hit point. */ this.point = new miniprogram.Vector3();
1164
+ /** The normal of the hit point. */ this.normal = new miniprogram.Vector3();
1165
+ };
1166
+
1167
+ /******************************************************************************
1168
+ Copyright (c) Microsoft Corporation.
1169
+
1170
+ Permission to use, copy, modify, and/or distribute this software for any
1171
+ purpose with or without fee is hereby granted.
1172
+
1173
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1174
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1175
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1176
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1177
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1178
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1179
+ PERFORMANCE OF THIS SOFTWARE.
1180
+ ***************************************************************************** */
1181
+
1182
+ function __decorate(decorators, target, key, desc) {
1183
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1184
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1185
+ 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;
1186
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1187
+ }
1188
+
1189
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1190
+ var e = new Error(message);
1191
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1192
+ };
1193
+
1179
1194
  /**
1180
1195
  * Enumerates modes of plane in XR.
1181
1196
  */ exports.XRPlaneMode = void 0;
@@ -1206,13 +1221,6 @@ exports.XRRequestTrackingState = void 0;
1206
1221
  return XRRequestPlane;
1207
1222
  }(XRRequestTracking);
1208
1223
 
1209
- /**
1210
- * The base class of XR tracked object.
1211
- */ var XRTracked = function XRTracked() {
1212
- /** The pose of the trackable in XR space. */ this.pose = new XRPose();
1213
- /** The tracking state of the trackable. */ this.state = exports.XRTrackingState.NotTracking;
1214
- };
1215
-
1216
1224
  /**
1217
1225
  * The tracked plane in XR space.
1218
1226
  */ var XRTrackedPlane = /*#__PURE__*/ function(XRTracked1) {
@@ -1570,5 +1578,7 @@ exports.XRInputManager = XRInputManager;
1570
1578
  exports.XRPose = XRPose;
1571
1579
  exports.XRReferenceImage = XRReferenceImage;
1572
1580
  exports.XRSessionManager = XRSessionManager;
1581
+ exports.XRTrackableFeature = XRTrackableFeature;
1582
+ exports.XRTracked = XRTracked;
1573
1583
  exports.XRTrackedImage = XRTrackedImage;
1574
1584
  exports.XRTrackedPlane = XRTrackedPlane;
package/dist/module.js CHANGED
@@ -550,6 +550,7 @@ var XRTargetRayMode;
550
550
  engine.pause();
551
551
  engine.resume();
552
552
  }
553
+ engine.dispatch("XRSessionStart");
553
554
  };
554
555
  /**
555
556
  * Stop the session.
@@ -570,6 +571,7 @@ var XRTargetRayMode;
570
571
  engine.pause();
571
572
  engine.resume();
572
573
  }
574
+ engine.dispatch("XRSessionStop");
573
575
  };
574
576
  /**
575
577
  * @internal
@@ -591,6 +593,7 @@ var XRTargetRayMode;
591
593
  platformSession.addEventListener();
592
594
  xrManager._onSessionInit();
593
595
  resolve();
596
+ _this._engine.dispatch("XRSessionInit");
594
597
  }, reject);
595
598
  });
596
599
  };
@@ -623,11 +626,14 @@ var XRTargetRayMode;
623
626
  /**
624
627
  * @internal
625
628
  */ _proto._exit = function _exit() {
626
- var _this = this, platformSession = _this._platformSession;
629
+ var _this = this;
630
+ var _this1 = this, platformSession = _this1._platformSession;
627
631
  if (!platformSession) {
628
632
  return Promise.reject("Without session to stop.");
629
633
  }
630
- return platformSession.end();
634
+ return platformSession.end().then(function() {
635
+ _this._engine.dispatch("XRSessionExit");
636
+ });
631
637
  };
632
638
  _proto._onSessionExit = function _onSessionExit() {
633
639
  var _this = this, rhi = _this._rhi, platformSession = _this._platformSession, engine = _this._engine;
@@ -709,14 +715,16 @@ var XRTargetRayMode;
709
715
  if (this.sessionManager._platformSession) {
710
716
  throw new Error("Cannot add feature when the session is initialized.");
711
717
  }
712
- var _this = this, features = _this._features;
718
+ var _this = this, features = _this._features; _this._platformDevice;
719
+ if (!this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(type))) {
720
+ throw new Error("The feature is not supported");
721
+ }
713
722
  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");
723
+ if (_instanceof(features[i], type)) throw new Error("The feature has been added");
716
724
  }
717
- var feature1 = _construct(type, [].concat(this, args));
718
- this._features.push(feature1);
719
- return feature1;
725
+ var feature = _construct(type, [].concat(this, args));
726
+ this._features.push(feature);
727
+ return feature;
720
728
  };
721
729
  /**
722
730
  * Get feature which match the type.
@@ -731,16 +739,16 @@ var XRTargetRayMode;
731
739
  }
732
740
  }
733
741
  };
734
- _proto.getFeatures = function getFeatures(type, out) {
742
+ _proto.getFeatures = function getFeatures(out) {
743
+ var _this = this, features = _this._features;
744
+ var length = features.length;
735
745
  if (out) {
736
- out.length = 0;
746
+ out.length = length;
737
747
  } else {
738
- out = [];
748
+ out = new Array(length);
739
749
  }
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);
750
+ for(var i = 0; i < length; i--){
751
+ out[i] = features[i];
744
752
  }
745
753
  return out;
746
754
  };
@@ -975,47 +983,10 @@ ApplyMixins(XRManager, [
975
983
  }();
976
984
 
977
985
  /**
978
- * Enum for the types of hit test that can be performed.
979
- * Note: currently only supports plane.
980
- */ var TrackableType;
981
- (function(TrackableType) {
982
- TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
983
- TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
984
- })(TrackableType || (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 Vector3();
991
- /** The normal of the hit point. */ this.normal = new 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;
986
+ * The base class of XR tracked object.
987
+ */ var XRTracked = function XRTracked() {
988
+ /** The pose of the trackable in XR space. */ this.pose = new XRPose();
989
+ /** The tracking state of the trackable. */ this.state = XRTrackingState.NotTracking;
1019
990
  };
1020
991
 
1021
992
  var XRFeatureType;
@@ -1171,6 +1142,50 @@ var XRRequestTrackingState;
1171
1142
  XRTrackableFeature._uuid = 0;
1172
1143
  })();
1173
1144
 
1145
+ /**
1146
+ * Enum for the types of hit test that can be performed.
1147
+ * Note: currently only supports plane.
1148
+ */ var TrackableType;
1149
+ (function(TrackableType) {
1150
+ TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
1151
+ TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
1152
+ })(TrackableType || (TrackableType = {}));
1153
+
1154
+ /**
1155
+ * XR hit result.
1156
+ * It is the detection result returned by using XR HitTest feature.
1157
+ */ var XRHitResult = function XRHitResult() {
1158
+ /** The position of the hit point. */ this.point = new Vector3();
1159
+ /** The normal of the hit point. */ this.normal = new Vector3();
1160
+ };
1161
+
1162
+ /******************************************************************************
1163
+ Copyright (c) Microsoft Corporation.
1164
+
1165
+ Permission to use, copy, modify, and/or distribute this software for any
1166
+ purpose with or without fee is hereby granted.
1167
+
1168
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
1169
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
1170
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
1171
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
1172
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
1173
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1174
+ PERFORMANCE OF THIS SOFTWARE.
1175
+ ***************************************************************************** */
1176
+
1177
+ function __decorate(decorators, target, key, desc) {
1178
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1179
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1180
+ 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;
1181
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1182
+ }
1183
+
1184
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
1185
+ var e = new Error(message);
1186
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1187
+ };
1188
+
1174
1189
  /**
1175
1190
  * Enumerates modes of plane in XR.
1176
1191
  */ var XRPlaneMode;
@@ -1201,13 +1216,6 @@ var XRRequestTrackingState;
1201
1216
  return XRRequestPlane;
1202
1217
  }(XRRequestTracking);
1203
1218
 
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 = XRTrackingState.NotTracking;
1209
- };
1210
-
1211
1219
  /**
1212
1220
  * The tracked plane in XR space.
1213
1221
  */ var XRTrackedPlane = /*#__PURE__*/ function(XRTracked1) {
@@ -1555,5 +1563,5 @@ XRImageTracking = __decorate([
1555
1563
  this.physicalWidth = physicalWidth;
1556
1564
  };
1557
1565
 
1558
- export { TrackableType, XRAnchor, XRAnchorTracking, XRCamera, XRCameraManager, XRController, XRFeature, XRFeatureType, XRHitResult, XRHitTest, XRImageTracking, XRInputButton, XRInputEventType, XRInputManager, XRPlaneMode, XRPlaneTracking, XRPose, XRReferenceImage, XRRequestTrackingState, XRSessionManager, XRSessionMode, XRSessionState, XRTargetRayMode, XRTrackedImage, XRTrackedInputDevice, XRTrackedPlane, XRTrackingState };
1566
+ export { TrackableType, XRAnchor, XRAnchorTracking, XRCamera, XRCameraManager, XRController, XRFeature, XRFeatureType, XRHitResult, XRHitTest, XRImageTracking, XRInputButton, XRInputEventType, XRInputManager, XRPlaneMode, XRPlaneTracking, XRPose, XRReferenceImage, XRRequestTrackingState, XRSessionManager, XRSessionMode, XRSessionState, XRTargetRayMode, XRTrackableFeature, XRTracked, XRTrackedImage, XRTrackedInputDevice, XRTrackedPlane, XRTrackingState };
1559
1567
  //# sourceMappingURL=module.js.map