@galacean/engine-xr-webxr 2.0.0-alpha.49 → 2.0.0-alpha.50
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 +29 -18
- 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 +24 -13
- package/dist/main.js.map +1 -1
- package/dist/module.js +24 -13
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/Util.d.ts +1 -1
- package/types/WebXRDevice.d.ts +1 -1
- package/types/WebXRFrame.d.ts +1 -1
- package/types/WebXRSession.d.ts +4 -4
package/dist/browser.js
CHANGED
|
@@ -278,7 +278,7 @@
|
|
|
278
278
|
{
|
|
279
279
|
key: "fixedFoveation",
|
|
280
280
|
get: /**
|
|
281
|
-
*
|
|
281
|
+
* Fixed foveation, or `undefined` if unsupported by the active session.
|
|
282
282
|
*/ function get() {
|
|
283
283
|
var _this__xrManager_sessionManager = this._xrManager.sessionManager, platformSession = _this__xrManager_sessionManager._platformSession;
|
|
284
284
|
if (platformSession) {
|
|
@@ -441,7 +441,7 @@
|
|
|
441
441
|
controller.down = controller.up = 0;
|
|
442
442
|
}
|
|
443
443
|
// Handle events and update tracked devices
|
|
444
|
-
var
|
|
444
|
+
var platformSession = this._xrManager.sessionManager._platformSession;
|
|
445
445
|
var platformEvents = platformSession.events;
|
|
446
446
|
for(var i1 = 0, n1 = platformEvents.length; i1 < n1; i1++){
|
|
447
447
|
this._handleEvent(platformEvents[i1]);
|
|
@@ -741,7 +741,7 @@
|
|
|
741
741
|
{
|
|
742
742
|
key: "supportedFrameRate",
|
|
743
743
|
get: /**
|
|
744
|
-
*
|
|
744
|
+
* Supported frame rates, or `undefined` if unsupported. Only available in-session.
|
|
745
745
|
*/ function get() {
|
|
746
746
|
return this._platformSession.supportedFrameRates;
|
|
747
747
|
}
|
|
@@ -749,7 +749,7 @@
|
|
|
749
749
|
{
|
|
750
750
|
key: "frameRate",
|
|
751
751
|
get: /**
|
|
752
|
-
*
|
|
752
|
+
* Current frame rate, or `undefined` if unsupported. Only available in-session.
|
|
753
753
|
*/ function get() {
|
|
754
754
|
return this._platformSession.frameRate;
|
|
755
755
|
}
|
|
@@ -1036,7 +1036,7 @@
|
|
|
1036
1036
|
}
|
|
1037
1037
|
var _proto = XRTrackableFeature.prototype;
|
|
1038
1038
|
_proto._onUpdate = function _onUpdate() {
|
|
1039
|
-
var
|
|
1039
|
+
var platformSession = this._xrManager.sessionManager._platformSession;
|
|
1040
1040
|
var platformFrame = platformSession.frame;
|
|
1041
1041
|
var _this = this, platformFeature = _this._platformFeature, requestTrackings = _this._requestTrackings, statusSnapshot = _this._statusSnapshot, allTracked = _this._tracked, added = _this._added, updated = _this._updated, removed = _this._removed;
|
|
1042
1042
|
if (!platformFrame || !requestTrackings.length) {
|
|
@@ -2638,6 +2638,7 @@
|
|
|
2638
2638
|
* Calculate the inverse of the specified matrix.
|
|
2639
2639
|
* @param a - The matrix whose inverse is to be calculated
|
|
2640
2640
|
* @param out - The inverse of the specified matrix
|
|
2641
|
+
* @returns Null if the matrix is singular; otherwise undefined
|
|
2641
2642
|
*/ Matrix3x3.invert = function invert(a, out) {
|
|
2642
2643
|
var ae = a.elements;
|
|
2643
2644
|
var oe = out.elements;
|
|
@@ -4107,6 +4108,7 @@
|
|
|
4107
4108
|
* Calculate the inverse of the specified matrix.
|
|
4108
4109
|
* @param a - The matrix whose inverse is to be calculated
|
|
4109
4110
|
* @param out - The inverse of the specified matrix
|
|
4111
|
+
* @returns Null if the matrix is singular; otherwise undefined
|
|
4110
4112
|
*/ Matrix.invert = function invert(a, out) {
|
|
4111
4113
|
var ae = a.elements;
|
|
4112
4114
|
var oe = out.elements;
|
|
@@ -4413,7 +4415,7 @@
|
|
|
4413
4415
|
this._updateCamera(inputs);
|
|
4414
4416
|
};
|
|
4415
4417
|
_proto._updateController = function _updateController(inputs) {
|
|
4416
|
-
var
|
|
4418
|
+
var frame = this._platformFrame;
|
|
4417
4419
|
var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
|
|
4418
4420
|
var inputSources = session.inputSources;
|
|
4419
4421
|
for(var i = 0, n = inputSources.length; i < n; i++){
|
|
@@ -4425,31 +4427,33 @@
|
|
|
4425
4427
|
case "tracked-pointer":
|
|
4426
4428
|
var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
|
|
4427
4429
|
if (gripSpace) {
|
|
4428
|
-
var
|
|
4429
|
-
if (
|
|
4430
|
+
var pose = frame.getPose(gripSpace, referenceSpace);
|
|
4431
|
+
if (pose) {
|
|
4432
|
+
var transform = pose.transform;
|
|
4430
4433
|
var gripPose = input.gripPose;
|
|
4431
4434
|
gripPose.matrix.copyFromArray(transform.matrix);
|
|
4432
4435
|
gripPose.position.copyFrom(transform.position);
|
|
4433
4436
|
gripPose.rotation.copyFrom(transform.orientation);
|
|
4434
4437
|
}
|
|
4435
|
-
input.trackingState = emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
|
|
4438
|
+
input.trackingState = !pose || pose.emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
|
|
4436
4439
|
}
|
|
4437
4440
|
if (targetRaySpace) {
|
|
4438
|
-
var
|
|
4439
|
-
if (
|
|
4441
|
+
var pose1 = frame.getPose(targetRaySpace, referenceSpace);
|
|
4442
|
+
if (pose1) {
|
|
4443
|
+
var transform1 = pose1.transform;
|
|
4440
4444
|
var targetRayPose = input.targetRayPose;
|
|
4441
4445
|
targetRayPose.matrix.copyFromArray(transform1.matrix);
|
|
4442
4446
|
targetRayPose.position.copyFrom(transform1.position);
|
|
4443
4447
|
targetRayPose.rotation.copyFrom(transform1.orientation);
|
|
4444
|
-
input.trackingState = emulatedPosition1 ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
|
|
4445
4448
|
}
|
|
4449
|
+
input.trackingState = !pose1 || pose1.emulatedPosition ? XRTrackingState.TrackingLost : XRTrackingState.Tracking;
|
|
4446
4450
|
}
|
|
4447
4451
|
break;
|
|
4448
4452
|
}
|
|
4449
4453
|
}
|
|
4450
4454
|
};
|
|
4451
4455
|
_proto._updateCamera = function _updateCamera(inputs) {
|
|
4452
|
-
var
|
|
4456
|
+
var frame = this._platformFrame;
|
|
4453
4457
|
var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
|
|
4454
4458
|
var viewerPose = frame.getViewerPose(referenceSpace);
|
|
4455
4459
|
if (viewerPose) {
|
|
@@ -4724,6 +4728,8 @@
|
|
|
4724
4728
|
case XRFeatureType.ImageTracking:
|
|
4725
4729
|
// @ts-ignore
|
|
4726
4730
|
return typeof XRImageTrackingResult !== "undefined";
|
|
4731
|
+
default:
|
|
4732
|
+
return false;
|
|
4727
4733
|
}
|
|
4728
4734
|
};
|
|
4729
4735
|
_proto.createPlatformFeature = function createPlatformFeature(type) {
|
|
@@ -4753,11 +4759,12 @@
|
|
|
4753
4759
|
var attributes = gl.getContextAttributes();
|
|
4754
4760
|
if (!attributes) {
|
|
4755
4761
|
reject(Error("GetContextAttributes Error!"));
|
|
4762
|
+
return;
|
|
4756
4763
|
}
|
|
4757
4764
|
gl.makeXRCompatible().then(function() {
|
|
4758
4765
|
var scaleFactor = XRWebGLLayer.getNativeFramebufferScaleFactor(session);
|
|
4759
4766
|
var layer;
|
|
4760
|
-
if (session.renderState.layers === undefined ||
|
|
4767
|
+
if (session.renderState.layers === undefined || !rhi.isWebGL2) {
|
|
4761
4768
|
var layerInit = {
|
|
4762
4769
|
antialias: session.renderState.layers === undefined ? attributes.antialias : true,
|
|
4763
4770
|
alpha: true,
|
|
@@ -4915,6 +4922,7 @@
|
|
|
4915
4922
|
_proto._updateTrackedAnchor = function _updateTrackedAnchor(frame, space, requestTracking) {
|
|
4916
4923
|
var xrAnchor = requestTracking.xrAnchor;
|
|
4917
4924
|
var xrPose = frame.getPose(xrAnchor.anchorSpace, space);
|
|
4925
|
+
if (!xrPose) return true;
|
|
4918
4926
|
var transform = xrPose.transform;
|
|
4919
4927
|
var pose = requestTracking.tracked[0].pose;
|
|
4920
4928
|
pose.matrix.copyFromArray(transform.matrix);
|
|
@@ -4974,8 +4982,7 @@
|
|
|
4974
4982
|
tracked.referenceImage = requestTrackingImage.image;
|
|
4975
4983
|
}
|
|
4976
4984
|
if (trackingResult.trackingState === "tracked") {
|
|
4977
|
-
this._updateTrackedImage(platformFrame, platformReferenceSpace, tracked, trackingResult);
|
|
4978
|
-
tracked.state = XRTrackingState.Tracking;
|
|
4985
|
+
tracked.state = this._updateTrackedImage(platformFrame, platformReferenceSpace, tracked, trackingResult) ? XRTrackingState.Tracking : XRTrackingState.TrackingLost;
|
|
4979
4986
|
} else {
|
|
4980
4987
|
tracked.state = XRTrackingState.TrackingLost;
|
|
4981
4988
|
}
|
|
@@ -5046,11 +5053,14 @@
|
|
|
5046
5053
|
};
|
|
5047
5054
|
_proto._updateTrackedImage = function _updateTrackedImage(frame, space, trackedImage, trackingResult) {
|
|
5048
5055
|
var pose = trackedImage.pose;
|
|
5049
|
-
var
|
|
5056
|
+
var xrPose = frame.getPose(trackingResult.imageSpace, space);
|
|
5057
|
+
if (!xrPose) return false;
|
|
5058
|
+
var transform = xrPose.transform;
|
|
5050
5059
|
pose.matrix.copyFromArray(transform.matrix);
|
|
5051
5060
|
pose.rotation.copyFrom(transform.orientation);
|
|
5052
5061
|
pose.position.copyFrom(transform.position);
|
|
5053
5062
|
trackedImage.measuredPhysicalWidth = trackingResult.measuredWidthInMeters;
|
|
5063
|
+
return true;
|
|
5054
5064
|
};
|
|
5055
5065
|
return WebXRImageTracking;
|
|
5056
5066
|
}(WebXRTrackableFeature);
|
|
@@ -5110,7 +5120,8 @@
|
|
|
5110
5120
|
options.optionalFeatures.push("plane-detection");
|
|
5111
5121
|
};
|
|
5112
5122
|
_proto._updatePlane = function _updatePlane(frame, space, trackedPlane) {
|
|
5113
|
-
var pose = trackedPlane.pose, polygon = trackedPlane.polygon
|
|
5123
|
+
var pose = trackedPlane.pose, polygon = trackedPlane.polygon;
|
|
5124
|
+
var xrPlane = trackedPlane.xrPlane;
|
|
5114
5125
|
var planePose = frame.getPose(xrPlane.planeSpace, space);
|
|
5115
5126
|
if (!planePose) return;
|
|
5116
5127
|
var transform = planePose.transform, emulatedPosition = planePose.emulatedPosition;
|