@galacean/engine-xr 1.3.0-alpha.2 → 1.3.0-beta.5
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 +201 -147
- 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 +201 -147
- package/dist/main.js.map +1 -1
- package/dist/miniprogram.js +201 -147
- package/dist/module.js +201 -149
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/XRManagerExtended.d.ts +7 -64
- package/types/feature/trackable/XRTrackableFeature.d.ts +1 -2
- package/types/index.d.ts +4 -0
- package/types/loader/XRReferenceImageDecoder.d.ts +5 -0
- package/types/loader/XRReferenceImageLoader.d.ts +5 -0
- package/types/session/XRSessionManager.d.ts +11 -0
- package/types/session/XRSessionState.d.ts +5 -3
package/dist/browser.js
CHANGED
|
@@ -99,9 +99,10 @@
|
|
|
99
99
|
*/ exports.XRSessionState = void 0;
|
|
100
100
|
(function(XRSessionState) {
|
|
101
101
|
XRSessionState[XRSessionState[/** Not initialized. */ "None"] = 0] = "None";
|
|
102
|
-
XRSessionState[XRSessionState[/**
|
|
103
|
-
XRSessionState[XRSessionState[/**
|
|
104
|
-
XRSessionState[XRSessionState[/**
|
|
102
|
+
XRSessionState[XRSessionState[/** Initializing session. */ "Initializing"] = 1] = "Initializing";
|
|
103
|
+
XRSessionState[XRSessionState[/** Initialized but not started. */ "Initialized"] = 2] = "Initialized";
|
|
104
|
+
XRSessionState[XRSessionState[/** Running. */ "Running"] = 3] = "Running";
|
|
105
|
+
XRSessionState[XRSessionState[/** Paused. */ "Paused"] = 4] = "Paused";
|
|
105
106
|
})(exports.XRSessionState || (exports.XRSessionState = {}));
|
|
106
107
|
|
|
107
108
|
/**
|
|
@@ -526,6 +527,7 @@
|
|
|
526
527
|
this._engine = _engine;
|
|
527
528
|
this._mode = exports.XRSessionMode.None;
|
|
528
529
|
this._state = exports.XRSessionState.None;
|
|
530
|
+
this._listeners = new engine.SafeLoopArray();
|
|
529
531
|
// @ts-ignore
|
|
530
532
|
this._rhi = _engine._hardwareRenderer;
|
|
531
533
|
this._raf = requestAnimationFrame.bind(window);
|
|
@@ -548,7 +550,7 @@
|
|
|
548
550
|
throw new Error("Without session to run.");
|
|
549
551
|
}
|
|
550
552
|
platformSession.start();
|
|
551
|
-
this.
|
|
553
|
+
this._setState(exports.XRSessionState.Running);
|
|
552
554
|
this._xrManager._onSessionStart();
|
|
553
555
|
if (!engine.isPaused) {
|
|
554
556
|
engine.pause();
|
|
@@ -568,7 +570,7 @@
|
|
|
568
570
|
rhi._mainFrameBuffer = null;
|
|
569
571
|
rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
|
|
570
572
|
platformSession.stop();
|
|
571
|
-
this.
|
|
573
|
+
this._setState(exports.XRSessionState.Paused);
|
|
572
574
|
this._xrManager._onSessionStop();
|
|
573
575
|
if (!engine.isPaused) {
|
|
574
576
|
engine.pause();
|
|
@@ -576,6 +578,32 @@
|
|
|
576
578
|
}
|
|
577
579
|
};
|
|
578
580
|
/**
|
|
581
|
+
* Add a listening function for session state changes.
|
|
582
|
+
* @param listener - The listening function
|
|
583
|
+
*/ _proto.addStateChangedListener = function addStateChangedListener(listener) {
|
|
584
|
+
this._listeners.push({
|
|
585
|
+
fn: listener
|
|
586
|
+
});
|
|
587
|
+
};
|
|
588
|
+
/**
|
|
589
|
+
* Remove a listening function of session state changes.
|
|
590
|
+
* @param listener - The listening function
|
|
591
|
+
*/ _proto.removeStateChangedListener = function removeStateChangedListener(listener) {
|
|
592
|
+
this._listeners.findAndRemove(function(value) {
|
|
593
|
+
return value.fn === listener ? value.destroyed = true : false;
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
/**
|
|
597
|
+
* @internal
|
|
598
|
+
*/ _proto._setState = function _setState(value) {
|
|
599
|
+
this._state = value;
|
|
600
|
+
var listeners = this._listeners.getLoopArray();
|
|
601
|
+
for(var i = 0, n = listeners.length; i < n; i++){
|
|
602
|
+
var listener = listeners[i];
|
|
603
|
+
!listener.destroyed && listener.fn(value);
|
|
604
|
+
}
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
579
607
|
* @internal
|
|
580
608
|
*/ _proto._initialize = function _initialize(mode, features) {
|
|
581
609
|
var _this = this;
|
|
@@ -590,7 +618,7 @@
|
|
|
590
618
|
xrManager._platformDevice.requestSession(_this._rhi, mode, platformFeatures).then(function(platformSession) {
|
|
591
619
|
_this._mode = mode;
|
|
592
620
|
_this._platformSession = platformSession;
|
|
593
|
-
_this.
|
|
621
|
+
_this._setState(exports.XRSessionState.Initialized);
|
|
594
622
|
platformSession.setSessionExitCallBack(_this._onSessionExit);
|
|
595
623
|
platformSession.addEventListener();
|
|
596
624
|
xrManager._onSessionInit();
|
|
@@ -639,7 +667,7 @@
|
|
|
639
667
|
rhi._mainFrameWidth = rhi._mainFrameHeight = 0;
|
|
640
668
|
platformSession.removeEventListener();
|
|
641
669
|
this._platformSession = null;
|
|
642
|
-
this.
|
|
670
|
+
this._setState(exports.XRSessionState.None);
|
|
643
671
|
this._xrManager._onSessionExit();
|
|
644
672
|
if (!engine.isPaused) {
|
|
645
673
|
engine.pause();
|
|
@@ -648,7 +676,12 @@
|
|
|
648
676
|
};
|
|
649
677
|
/**
|
|
650
678
|
* @internal
|
|
651
|
-
*/ _proto._onDestroy = function _onDestroy() {
|
|
679
|
+
*/ _proto._onDestroy = function _onDestroy() {
|
|
680
|
+
this._listeners.findAndRemove(function(value) {
|
|
681
|
+
return value.destroyed = true;
|
|
682
|
+
});
|
|
683
|
+
this._raf = this._caf = null;
|
|
684
|
+
};
|
|
652
685
|
_create_class(XRSessionManager, [
|
|
653
686
|
{
|
|
654
687
|
key: "mode",
|
|
@@ -687,47 +720,36 @@
|
|
|
687
720
|
}();
|
|
688
721
|
|
|
689
722
|
/**
|
|
690
|
-
*
|
|
723
|
+
* @internal
|
|
691
724
|
*/ var XRManagerExtended = /*#__PURE__*/ function(XRManager1) {
|
|
692
725
|
_inherits(XRManagerExtended, XRManager1);
|
|
693
726
|
function XRManagerExtended() {
|
|
694
727
|
return XRManager1.apply(this, arguments);
|
|
695
728
|
}
|
|
696
729
|
var _proto = XRManagerExtended.prototype;
|
|
697
|
-
|
|
698
|
-
* Check if the specified feature is supported.
|
|
699
|
-
* @param type - The type of the feature
|
|
700
|
-
* @returns If the feature is supported
|
|
701
|
-
*/ _proto.isSupportedFeature = function isSupportedFeature(feature) {
|
|
730
|
+
_proto.isSupportedFeature = function isSupportedFeature(feature) {
|
|
702
731
|
return this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(feature));
|
|
703
732
|
};
|
|
704
|
-
|
|
705
|
-
* Add feature based on the xr feature type.
|
|
706
|
-
* @param type - The type of the feature
|
|
707
|
-
* @param args - The constructor params of the feature
|
|
708
|
-
* @returns The feature which has been added
|
|
709
|
-
*/ _proto.addFeature = function addFeature(type) {
|
|
733
|
+
_proto.addFeature = function addFeature(type) {
|
|
710
734
|
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
711
735
|
args[_key - 1] = arguments[_key];
|
|
712
736
|
}
|
|
713
737
|
if (this.sessionManager._platformSession) {
|
|
714
738
|
throw new Error("Cannot add feature when the session is initialized.");
|
|
715
739
|
}
|
|
716
|
-
|
|
740
|
+
if (!this._platformDevice.isSupportedFeature(XRManagerExtended._featureMap.get(type))) {
|
|
741
|
+
throw new Error("The feature is not supported");
|
|
742
|
+
}
|
|
743
|
+
var features = this.features;
|
|
717
744
|
for(var i = 0, n = features.length; i < n; i++){
|
|
718
|
-
|
|
719
|
-
if (_instanceof(feature, type)) throw new Error("The feature has been added");
|
|
745
|
+
if (_instanceof(features[i], type)) throw new Error("The feature has been added");
|
|
720
746
|
}
|
|
721
|
-
var
|
|
722
|
-
|
|
723
|
-
return
|
|
747
|
+
var feature = _construct(type, [].concat(this, args));
|
|
748
|
+
features.push(feature);
|
|
749
|
+
return feature;
|
|
724
750
|
};
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
* @param type - The type of the feature
|
|
728
|
-
* @returns The feature which match type
|
|
729
|
-
*/ _proto.getFeature = function getFeature(type) {
|
|
730
|
-
var _this = this, features = _this._features;
|
|
751
|
+
_proto.getFeature = function getFeature(type) {
|
|
752
|
+
var features = this.features;
|
|
731
753
|
for(var i = 0, n = features.length; i < n; i++){
|
|
732
754
|
var feature = features[i];
|
|
733
755
|
if (_instanceof(feature, type)) {
|
|
@@ -735,25 +757,7 @@
|
|
|
735
757
|
}
|
|
736
758
|
}
|
|
737
759
|
};
|
|
738
|
-
_proto.
|
|
739
|
-
if (out) {
|
|
740
|
-
out.length = 0;
|
|
741
|
-
} else {
|
|
742
|
-
out = [];
|
|
743
|
-
}
|
|
744
|
-
var _this = this, features = _this._features;
|
|
745
|
-
for(var i = 0, n = features.length; i < n; i--){
|
|
746
|
-
var feature = features[i];
|
|
747
|
-
_instanceof(feature, type) && out.push(feature);
|
|
748
|
-
}
|
|
749
|
-
return out;
|
|
750
|
-
};
|
|
751
|
-
/**
|
|
752
|
-
* Enter XR immersive mode, when you call this method, it will initialize and display the XR virtual world.
|
|
753
|
-
* @param sessionMode - The mode of the session
|
|
754
|
-
* @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.
|
|
755
|
-
* @returns A promise that resolves if the XR virtual world is entered, otherwise rejects
|
|
756
|
-
*/ _proto.enterXR = function enterXR(sessionMode, autoRun) {
|
|
760
|
+
_proto.enterXR = function enterXR(sessionMode, autoRun) {
|
|
757
761
|
if (autoRun === void 0) autoRun = true;
|
|
758
762
|
var _this = this;
|
|
759
763
|
var sessionManager = this.sessionManager;
|
|
@@ -766,18 +770,16 @@
|
|
|
766
770
|
return new Promise(function(resolve, reject) {
|
|
767
771
|
// 1. Check if this xr mode is supported
|
|
768
772
|
sessionManager.isSupportedMode(sessionMode).then(function() {
|
|
773
|
+
sessionManager._setState(exports.XRSessionState.Initializing);
|
|
769
774
|
// 2. Initialize session
|
|
770
|
-
sessionManager._initialize(sessionMode, _this.
|
|
775
|
+
sessionManager._initialize(sessionMode, _this.features).then(function() {
|
|
771
776
|
autoRun && sessionManager.run();
|
|
772
777
|
resolve();
|
|
773
778
|
}, reject);
|
|
774
779
|
}, reject);
|
|
775
780
|
});
|
|
776
781
|
};
|
|
777
|
-
|
|
778
|
-
* Exit XR immersive mode, when you call this method, it will destroy the XR virtual world.
|
|
779
|
-
* @returns A promise that resolves if the XR virtual world is destroyed, otherwise rejects
|
|
780
|
-
*/ _proto.exitXR = function exitXR() {
|
|
782
|
+
_proto.exitXR = function exitXR() {
|
|
781
783
|
var _this = this;
|
|
782
784
|
return new Promise(function(resolve, reject) {
|
|
783
785
|
_this.sessionManager._exit().then(function() {
|
|
@@ -785,32 +787,26 @@
|
|
|
785
787
|
}, reject);
|
|
786
788
|
});
|
|
787
789
|
};
|
|
788
|
-
|
|
789
|
-
* @internal
|
|
790
|
-
*/ _proto._initialize = function _initialize(engine, xrDevice) {
|
|
790
|
+
_proto._initialize = function _initialize(engine, xrDevice) {
|
|
791
791
|
this._features = [];
|
|
792
792
|
this._platformDevice = xrDevice;
|
|
793
793
|
this.sessionManager = new XRSessionManager(this, engine);
|
|
794
794
|
this.inputManager = new XRInputManager(this, engine);
|
|
795
795
|
this.cameraManager = new XRCameraManager(this);
|
|
796
796
|
};
|
|
797
|
-
|
|
798
|
-
* @internal
|
|
799
|
-
*/ _proto._update = function _update() {
|
|
797
|
+
_proto._update = function _update() {
|
|
800
798
|
var sessionManager = this.sessionManager;
|
|
801
799
|
if (sessionManager.state !== exports.XRSessionState.Running) return;
|
|
802
800
|
sessionManager._onUpdate();
|
|
803
801
|
this.inputManager._onUpdate();
|
|
804
802
|
this.cameraManager._onUpdate();
|
|
805
|
-
var
|
|
803
|
+
var features = this.features;
|
|
806
804
|
for(var i = 0, n = features.length; i < n; i++){
|
|
807
805
|
var feature = features[i];
|
|
808
806
|
feature.enabled && feature._onUpdate();
|
|
809
807
|
}
|
|
810
808
|
};
|
|
811
|
-
|
|
812
|
-
* @internal
|
|
813
|
-
*/ _proto._destroy = function _destroy() {
|
|
809
|
+
_proto._destroy = function _destroy() {
|
|
814
810
|
var _this = this;
|
|
815
811
|
if (this.sessionManager._platformSession) {
|
|
816
812
|
this.exitXR().then(function() {
|
|
@@ -824,25 +820,19 @@
|
|
|
824
820
|
this.cameraManager._onDestroy();
|
|
825
821
|
}
|
|
826
822
|
};
|
|
827
|
-
|
|
828
|
-
* @internal
|
|
829
|
-
*/ _proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
|
|
823
|
+
_proto._getRequestAnimationFrame = function _getRequestAnimationFrame() {
|
|
830
824
|
return this.sessionManager._getRequestAnimationFrame();
|
|
831
825
|
};
|
|
832
|
-
|
|
833
|
-
* @internal
|
|
834
|
-
*/ _proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
|
|
826
|
+
_proto._getCancelAnimationFrame = function _getCancelAnimationFrame() {
|
|
835
827
|
return this.sessionManager._getCancelAnimationFrame();
|
|
836
828
|
};
|
|
837
|
-
|
|
838
|
-
* @internal
|
|
839
|
-
*/ _proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
|
|
829
|
+
_proto._getCameraClearFlagsMask = function _getCameraClearFlagsMask(type) {
|
|
840
830
|
return this.cameraManager._getCameraClearFlagsMask(type);
|
|
841
831
|
};
|
|
842
832
|
/**
|
|
843
833
|
* @internal
|
|
844
834
|
*/ _proto._onSessionStop = function _onSessionStop() {
|
|
845
|
-
var
|
|
835
|
+
var features = this.features;
|
|
846
836
|
for(var i = 0, n = features.length; i < n; i++){
|
|
847
837
|
var feature = features[i];
|
|
848
838
|
feature.enabled && feature._onSessionStop();
|
|
@@ -851,7 +841,7 @@
|
|
|
851
841
|
/**
|
|
852
842
|
* @internal
|
|
853
843
|
*/ _proto._onSessionInit = function _onSessionInit() {
|
|
854
|
-
var
|
|
844
|
+
var features = this.features;
|
|
855
845
|
for(var i = 0, n = features.length; i < n; i++){
|
|
856
846
|
var feature = features[i];
|
|
857
847
|
feature.enabled && feature._onSessionInit();
|
|
@@ -861,7 +851,7 @@
|
|
|
861
851
|
* @internal
|
|
862
852
|
*/ _proto._onSessionStart = function _onSessionStart() {
|
|
863
853
|
this.cameraManager._onSessionStart();
|
|
864
|
-
var
|
|
854
|
+
var features = this.features;
|
|
865
855
|
for(var i = 0, n = features.length; i < n; i++){
|
|
866
856
|
var feature = features[i];
|
|
867
857
|
feature.enabled && feature._onSessionStart();
|
|
@@ -871,7 +861,7 @@
|
|
|
871
861
|
* @internal
|
|
872
862
|
*/ _proto._onSessionExit = function _onSessionExit() {
|
|
873
863
|
this.cameraManager._onSessionExit();
|
|
874
|
-
var
|
|
864
|
+
var features = this.features;
|
|
875
865
|
for(var i = 0, n = features.length; i < n; i++){
|
|
876
866
|
var feature = features[i];
|
|
877
867
|
feature.enabled && feature._onSessionExit();
|
|
@@ -880,12 +870,15 @@
|
|
|
880
870
|
features.length = 0;
|
|
881
871
|
};
|
|
882
872
|
_create_class(XRManagerExtended, [
|
|
873
|
+
{
|
|
874
|
+
key: "features",
|
|
875
|
+
get: function get() {
|
|
876
|
+
return this._features;
|
|
877
|
+
}
|
|
878
|
+
},
|
|
883
879
|
{
|
|
884
880
|
key: "origin",
|
|
885
|
-
get:
|
|
886
|
-
* The current origin of XR space.
|
|
887
|
-
* @remarks The connection point between the virtual world and the real world ( XR Space )
|
|
888
|
-
*/ function get() {
|
|
881
|
+
get: function get() {
|
|
889
882
|
return this._origin;
|
|
890
883
|
},
|
|
891
884
|
set: function set(value) {
|
|
@@ -978,50 +971,6 @@
|
|
|
978
971
|
return XRFeature;
|
|
979
972
|
}();
|
|
980
973
|
|
|
981
|
-
/**
|
|
982
|
-
* Enum for the types of hit test that can be performed.
|
|
983
|
-
* Note: currently only supports plane.
|
|
984
|
-
*/ exports.TrackableType = void 0;
|
|
985
|
-
(function(TrackableType) {
|
|
986
|
-
TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
|
|
987
|
-
TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
|
|
988
|
-
})(exports.TrackableType || (exports.TrackableType = {}));
|
|
989
|
-
|
|
990
|
-
/**
|
|
991
|
-
* XR hit result.
|
|
992
|
-
* It is the detection result returned by using XR HitTest feature.
|
|
993
|
-
*/ var XRHitResult = function XRHitResult() {
|
|
994
|
-
/** The position of the hit point. */ this.point = new engine.Vector3();
|
|
995
|
-
/** The normal of the hit point. */ this.normal = new engine.Vector3();
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
/******************************************************************************
|
|
999
|
-
Copyright (c) Microsoft Corporation.
|
|
1000
|
-
|
|
1001
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1002
|
-
purpose with or without fee is hereby granted.
|
|
1003
|
-
|
|
1004
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1005
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1006
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1007
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1008
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1009
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1010
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1011
|
-
***************************************************************************** */
|
|
1012
|
-
|
|
1013
|
-
function __decorate(decorators, target, key, desc) {
|
|
1014
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1015
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1016
|
-
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;
|
|
1017
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1021
|
-
var e = new Error(message);
|
|
1022
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1023
|
-
};
|
|
1024
|
-
|
|
1025
974
|
exports.XRFeatureType = void 0;
|
|
1026
975
|
(function(XRFeatureType) {
|
|
1027
976
|
XRFeatureType[XRFeatureType["AnchorTracking"] = 0] = "AnchorTracking";
|
|
@@ -1053,7 +1002,7 @@
|
|
|
1053
1002
|
_this._updated = [];
|
|
1054
1003
|
_this._removed = [];
|
|
1055
1004
|
_this._statusSnapshot = {};
|
|
1056
|
-
_this._listeners =
|
|
1005
|
+
_this._listeners = new engine.SafeLoopArray();
|
|
1057
1006
|
return _this;
|
|
1058
1007
|
}
|
|
1059
1008
|
var _proto = XRTrackableFeature.prototype;
|
|
@@ -1061,22 +1010,22 @@
|
|
|
1061
1010
|
* Add a listening function for tracked object changes.
|
|
1062
1011
|
* @param listener - The listening function
|
|
1063
1012
|
*/ _proto.addChangedListener = function addChangedListener(listener) {
|
|
1064
|
-
this._listeners.push(
|
|
1013
|
+
this._listeners.push({
|
|
1014
|
+
fn: listener
|
|
1015
|
+
});
|
|
1065
1016
|
};
|
|
1066
1017
|
/**
|
|
1067
1018
|
* Remove a listening function of tracked object changes.
|
|
1068
1019
|
* @param listener - The listening function
|
|
1069
1020
|
*/ _proto.removeChangedListener = function removeChangedListener(listener) {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
listeners.splice(index, 1);
|
|
1074
|
-
}
|
|
1021
|
+
this._listeners.findAndRemove(function(value) {
|
|
1022
|
+
return value.fn === listener ? value.destroyed = true : false;
|
|
1023
|
+
});
|
|
1075
1024
|
};
|
|
1076
1025
|
_proto._onUpdate = function _onUpdate() {
|
|
1077
1026
|
var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
|
|
1078
1027
|
var platformFrame = platformSession.frame;
|
|
1079
|
-
var _this = this, platformFeature = _this._platformFeature,
|
|
1028
|
+
var _this = this, platformFeature = _this._platformFeature, requestTrackings = _this._requestTrackings, statusSnapshot = _this._statusSnapshot, allTracked = _this._tracked, added = _this._added, updated = _this._updated, removed = _this._removed;
|
|
1080
1029
|
if (!platformFrame || !requestTrackings.length) {
|
|
1081
1030
|
return;
|
|
1082
1031
|
}
|
|
@@ -1128,8 +1077,10 @@
|
|
|
1128
1077
|
requestTrackings[i1].state === exports.XRRequestTrackingState.Destroyed && requestTrackings.splice(i1, 1);
|
|
1129
1078
|
}
|
|
1130
1079
|
if (added.length > 0 || updated.length > 0 || removed.length > 0) {
|
|
1080
|
+
var listeners = this._listeners.getLoopArray();
|
|
1131
1081
|
for(var i2 = 0, n3 = listeners.length; i2 < n3; i2++){
|
|
1132
|
-
listeners[i2]
|
|
1082
|
+
var listener = listeners[i2];
|
|
1083
|
+
!listener.destroyed && listener.fn(added, updated, removed);
|
|
1133
1084
|
}
|
|
1134
1085
|
}
|
|
1135
1086
|
};
|
|
@@ -1139,10 +1090,9 @@
|
|
|
1139
1090
|
_proto._onSessionExit = function _onSessionExit() {
|
|
1140
1091
|
// prettier-ignore
|
|
1141
1092
|
this._requestTrackings.length = this._tracked.length = this._added.length = this._updated.length = this._removed.length = 0;
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
this._requestTrackings.length = this._tracked.length = this._added.length = this._updated.length = this._removed.length = 0;
|
|
1093
|
+
this._listeners.findAndRemove(function(value) {
|
|
1094
|
+
return value.destroyed = true;
|
|
1095
|
+
});
|
|
1146
1096
|
};
|
|
1147
1097
|
_proto._addRequestTracking = function _addRequestTracking(requestTracking) {
|
|
1148
1098
|
var _this = this, platformFeature = _this._platformFeature;
|
|
@@ -1175,6 +1125,57 @@
|
|
|
1175
1125
|
XRTrackableFeature._uuid = 0;
|
|
1176
1126
|
})();
|
|
1177
1127
|
|
|
1128
|
+
/**
|
|
1129
|
+
* The base class of XR tracked object.
|
|
1130
|
+
*/ var XRTracked = function XRTracked() {
|
|
1131
|
+
/** The pose of the trackable in XR space. */ this.pose = new XRPose();
|
|
1132
|
+
/** The tracking state of the trackable. */ this.state = exports.XRTrackingState.NotTracking;
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Enum for the types of hit test that can be performed.
|
|
1137
|
+
* Note: currently only supports plane.
|
|
1138
|
+
*/ exports.TrackableType = void 0;
|
|
1139
|
+
(function(TrackableType) {
|
|
1140
|
+
TrackableType[TrackableType[/** Tracked plane. */ "Plane"] = 0x1] = "Plane";
|
|
1141
|
+
TrackableType[TrackableType[/** All tracked objects. */ "All"] = 0x1] = "All";
|
|
1142
|
+
})(exports.TrackableType || (exports.TrackableType = {}));
|
|
1143
|
+
|
|
1144
|
+
/**
|
|
1145
|
+
* XR hit result.
|
|
1146
|
+
* It is the detection result returned by using XR HitTest feature.
|
|
1147
|
+
*/ var XRHitResult = function XRHitResult() {
|
|
1148
|
+
/** The position of the hit point. */ this.point = new engine.Vector3();
|
|
1149
|
+
/** The normal of the hit point. */ this.normal = new engine.Vector3();
|
|
1150
|
+
};
|
|
1151
|
+
|
|
1152
|
+
/******************************************************************************
|
|
1153
|
+
Copyright (c) Microsoft Corporation.
|
|
1154
|
+
|
|
1155
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
1156
|
+
purpose with or without fee is hereby granted.
|
|
1157
|
+
|
|
1158
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1159
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1160
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1161
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1162
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1163
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1164
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
1165
|
+
***************************************************************************** */
|
|
1166
|
+
|
|
1167
|
+
function __decorate(decorators, target, key, desc) {
|
|
1168
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1169
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1170
|
+
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;
|
|
1171
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1175
|
+
var e = new Error(message);
|
|
1176
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1178
1179
|
/**
|
|
1179
1180
|
* Enumerates modes of plane in XR.
|
|
1180
1181
|
*/ exports.XRPlaneMode = void 0;
|
|
@@ -1205,13 +1206,6 @@
|
|
|
1205
1206
|
return XRRequestPlane;
|
|
1206
1207
|
}(XRRequestTracking);
|
|
1207
1208
|
|
|
1208
|
-
/**
|
|
1209
|
-
* The base class of XR tracked object.
|
|
1210
|
-
*/ var XRTracked = function XRTracked() {
|
|
1211
|
-
/** The pose of the trackable in XR space. */ this.pose = new XRPose();
|
|
1212
|
-
/** The tracking state of the trackable. */ this.state = exports.XRTrackingState.NotTracking;
|
|
1213
|
-
};
|
|
1214
|
-
|
|
1215
1209
|
/**
|
|
1216
1210
|
* The tracked plane in XR space.
|
|
1217
1211
|
*/ var XRTrackedPlane = /*#__PURE__*/ function(XRTracked1) {
|
|
@@ -1559,6 +1553,64 @@
|
|
|
1559
1553
|
this.physicalWidth = physicalWidth;
|
|
1560
1554
|
};
|
|
1561
1555
|
|
|
1556
|
+
exports.XRReferenceImageDecoder = /*#__PURE__*/ function() {
|
|
1557
|
+
function XRReferenceImageDecoder() {}
|
|
1558
|
+
XRReferenceImageDecoder.decode = function decode(engine, bufferReader) {
|
|
1559
|
+
return new Promise(function(resolve, reject) {
|
|
1560
|
+
var physicalWidth = bufferReader.nextFloat32();
|
|
1561
|
+
bufferReader.nextUint8();
|
|
1562
|
+
var img = new Image();
|
|
1563
|
+
img.onload = function() {
|
|
1564
|
+
resolve(new XRReferenceImage("", img, physicalWidth));
|
|
1565
|
+
};
|
|
1566
|
+
img.src = URL.createObjectURL(new window.Blob([
|
|
1567
|
+
bufferReader.nextImagesData(1)[0]
|
|
1568
|
+
]));
|
|
1569
|
+
});
|
|
1570
|
+
};
|
|
1571
|
+
return XRReferenceImageDecoder;
|
|
1572
|
+
}();
|
|
1573
|
+
exports.XRReferenceImageDecoder = __decorate([
|
|
1574
|
+
engine.decoder("XRReferenceImage")
|
|
1575
|
+
], exports.XRReferenceImageDecoder);
|
|
1576
|
+
|
|
1577
|
+
function _extends() {
|
|
1578
|
+
_extends = Object.assign || function assign(target) {
|
|
1579
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1580
|
+
var source = arguments[i];
|
|
1581
|
+
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
return target;
|
|
1585
|
+
};
|
|
1586
|
+
|
|
1587
|
+
return _extends.apply(this, arguments);
|
|
1588
|
+
}
|
|
1589
|
+
|
|
1590
|
+
exports.XRReferenceImageLoader = /*#__PURE__*/ function(Loader1) {
|
|
1591
|
+
_inherits(XRReferenceImageLoader, Loader1);
|
|
1592
|
+
function XRReferenceImageLoader() {
|
|
1593
|
+
return Loader1.apply(this, arguments);
|
|
1594
|
+
}
|
|
1595
|
+
var _proto = XRReferenceImageLoader.prototype;
|
|
1596
|
+
_proto.load = function load(item, resourceManager) {
|
|
1597
|
+
var _this = this;
|
|
1598
|
+
return new engine.AssetPromise(function(resolve, reject) {
|
|
1599
|
+
_this.request(item.url, _extends({}, item, {
|
|
1600
|
+
type: "arraybuffer"
|
|
1601
|
+
})).then(function(data) {
|
|
1602
|
+
engine.decode(data, resourceManager.engine).then(function(referenceImage) {
|
|
1603
|
+
resolve(referenceImage);
|
|
1604
|
+
});
|
|
1605
|
+
}).catch(reject);
|
|
1606
|
+
});
|
|
1607
|
+
};
|
|
1608
|
+
return XRReferenceImageLoader;
|
|
1609
|
+
}(engine.Loader);
|
|
1610
|
+
exports.XRReferenceImageLoader = __decorate([
|
|
1611
|
+
engine.resourceLoader("XRReferenceImage", [])
|
|
1612
|
+
], exports.XRReferenceImageLoader);
|
|
1613
|
+
|
|
1562
1614
|
exports.XRAnchor = XRAnchor;
|
|
1563
1615
|
exports.XRCamera = XRCamera;
|
|
1564
1616
|
exports.XRCameraManager = XRCameraManager;
|
|
@@ -1569,6 +1621,8 @@
|
|
|
1569
1621
|
exports.XRPose = XRPose;
|
|
1570
1622
|
exports.XRReferenceImage = XRReferenceImage;
|
|
1571
1623
|
exports.XRSessionManager = XRSessionManager;
|
|
1624
|
+
exports.XRTrackableFeature = XRTrackableFeature;
|
|
1625
|
+
exports.XRTracked = XRTracked;
|
|
1572
1626
|
exports.XRTrackedImage = XRTrackedImage;
|
|
1573
1627
|
exports.XRTrackedPlane = XRTrackedPlane;
|
|
1574
1628
|
|