@galacean/engine-xr-webxr 1.3.24 → 1.4.0-alpha.1
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 +267 -1763
- 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 +147 -1621
- package/dist/main.js.map +1 -1
- package/dist/module.js +147 -1621
- package/dist/module.js.map +1 -1
- package/package.json +4 -4
- package/types/Util.d.ts +0 -1
- package/types/WebXRSession.d.ts +0 -1
- package/types/feature/WebXRAnchorTracking.d.ts +0 -1
- package/types/feature/WebXRPlaneTracking.d.ts +0 -1
- package/dist/miniprogram.js +0 -5977
package/dist/main.js
CHANGED
|
@@ -70,17 +70,18 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
function _is_native_reflect_construct() {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
// Since Reflect.construct can't be properly polyfilled, some
|
|
74
|
+
// implementations (e.g. core-js@2) don't set the correct internal slots.
|
|
75
|
+
// Those polyfills don't allow us to subclass built-ins, so we need to
|
|
76
|
+
// use our fallback implementation.
|
|
77
77
|
try {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
} catch (
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
// If the internal slots aren't set, this throws an error similar to
|
|
79
|
+
// TypeError: this is not a Boolean object.
|
|
80
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
81
|
+
} catch (_) {}
|
|
82
|
+
return (_is_native_reflect_construct = function() {
|
|
83
|
+
return !!result;
|
|
84
|
+
})();
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
function _construct(Parent, args, Class) {
|
|
@@ -149,33 +150,6 @@ function viewToCamera(type) {
|
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
/**
|
|
153
|
-
* Defines how the bounding volumes intersects or contain one another.
|
|
154
|
-
*/ var ContainmentType;
|
|
155
|
-
(function(ContainmentType) {
|
|
156
|
-
ContainmentType[ContainmentType[/** Indicates that there is no overlap between two bounding volumes. */ "Disjoint"] = 0] = "Disjoint";
|
|
157
|
-
ContainmentType[ContainmentType[/** Indicates that one bounding volume completely contains another volume. */ "Contains"] = 1] = "Contains";
|
|
158
|
-
ContainmentType[ContainmentType[/** Indicates that bounding volumes partially overlap one another. */ "Intersects"] = 2] = "Intersects";
|
|
159
|
-
})(ContainmentType || (ContainmentType = {}));
|
|
160
|
-
/**
|
|
161
|
-
* Defines the intersection between a plane and a bounding volume.
|
|
162
|
-
*/ var PlaneIntersectionType;
|
|
163
|
-
(function(PlaneIntersectionType) {
|
|
164
|
-
PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the back of the plane. */ "Back"] = 0] = "Back";
|
|
165
|
-
PlaneIntersectionType[PlaneIntersectionType[/** There is no intersection, the bounding volume is in the front of the plane. */ "Front"] = 1] = "Front";
|
|
166
|
-
PlaneIntersectionType[PlaneIntersectionType[/** The plane is intersected. */ "Intersecting"] = 2] = "Intersecting";
|
|
167
|
-
})(PlaneIntersectionType || (PlaneIntersectionType = {}));
|
|
168
|
-
/**
|
|
169
|
-
* Frustum face
|
|
170
|
-
*/ var FrustumFace;
|
|
171
|
-
(function(FrustumFace) {
|
|
172
|
-
FrustumFace[FrustumFace[/** Near face */ "Near"] = 0] = "Near";
|
|
173
|
-
FrustumFace[FrustumFace[/** Far face */ "Far"] = 1] = "Far";
|
|
174
|
-
FrustumFace[FrustumFace[/** Left face */ "Left"] = 2] = "Left";
|
|
175
|
-
FrustumFace[FrustumFace[/** Right face */ "Right"] = 3] = "Right";
|
|
176
|
-
FrustumFace[FrustumFace[/** Bottom face */ "Bottom"] = 4] = "Bottom";
|
|
177
|
-
FrustumFace[FrustumFace[/** Top face */ "Top"] = 5] = "Top";
|
|
178
|
-
})(FrustumFace || (FrustumFace = {}));
|
|
179
153
|
function _defineProperties(target, props) {
|
|
180
154
|
for(var i = 0; i < props.length; i++){
|
|
181
155
|
var descriptor = props[i];
|
|
@@ -193,7 +167,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
193
167
|
/**
|
|
194
168
|
* Common utility methods for math operations.
|
|
195
169
|
*/ var MathUtil = /*#__PURE__*/ function() {
|
|
196
|
-
|
|
170
|
+
function MathUtil() {}
|
|
197
171
|
/**
|
|
198
172
|
* Clamps the specified value.
|
|
199
173
|
* @param v - The specified value
|
|
@@ -244,19 +218,13 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
244
218
|
};
|
|
245
219
|
return MathUtil;
|
|
246
220
|
}();
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
(function() {
|
|
251
|
-
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
252
|
-
})();
|
|
253
|
-
(function() {
|
|
254
|
-
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
255
|
-
})();
|
|
221
|
+
/** The value for which all absolute numbers smaller than are considered equal to zero. */ MathUtil.zeroTolerance = 1e-6;
|
|
222
|
+
/** The conversion factor that radian to degree. */ MathUtil.radToDegreeFactor = 180 / Math.PI;
|
|
223
|
+
/** The conversion factor that degree to radian. */ MathUtil.degreeToRadFactor = Math.PI / 180;
|
|
256
224
|
/**
|
|
257
225
|
* Describes a 3D-vector.
|
|
258
226
|
*/ var Vector3 = /*#__PURE__*/ function() {
|
|
259
|
-
|
|
227
|
+
function Vector3(x, y, z) {
|
|
260
228
|
if (x === void 0) x = 0;
|
|
261
229
|
if (y === void 0) y = 0;
|
|
262
230
|
if (z === void 0) z = 0;
|
|
@@ -264,7 +232,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
264
232
|
this._x = x;
|
|
265
233
|
this._y = y;
|
|
266
234
|
this._z = z;
|
|
267
|
-
}
|
|
235
|
+
}
|
|
268
236
|
var _proto = Vector3.prototype;
|
|
269
237
|
/**
|
|
270
238
|
* Set the value of this vector.
|
|
@@ -760,655 +728,18 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
760
728
|
]);
|
|
761
729
|
return Vector3;
|
|
762
730
|
}();
|
|
763
|
-
(
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
(
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
* */ var BoundingSphere = /*#__PURE__*/ function() {
|
|
772
|
-
var BoundingSphere = function BoundingSphere(center, radius) {
|
|
773
|
-
if (center === void 0) center = null;
|
|
774
|
-
if (radius === void 0) radius = 0;
|
|
775
|
-
/** The center point of the sphere. */ this.center = new Vector3();
|
|
776
|
-
/** The radius of the sphere. */ this.radius = 0;
|
|
777
|
-
center && this.center.copyFrom(center);
|
|
778
|
-
this.radius = radius;
|
|
779
|
-
};
|
|
780
|
-
var _proto = BoundingSphere.prototype;
|
|
781
|
-
/**
|
|
782
|
-
* Creates a clone of this sphere.
|
|
783
|
-
* @returns A clone of this sphere
|
|
784
|
-
*/ _proto.clone = function clone() {
|
|
785
|
-
return new BoundingSphere(this.center, this.radius);
|
|
786
|
-
};
|
|
787
|
-
/**
|
|
788
|
-
* Copy this sphere from the specified sphere.
|
|
789
|
-
* @param source - The specified sphere
|
|
790
|
-
* @returns This sphere
|
|
791
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
792
|
-
this.center.copyFrom(source.center);
|
|
793
|
-
this.radius = source.radius;
|
|
794
|
-
return this;
|
|
795
|
-
};
|
|
796
|
-
/**
|
|
797
|
-
* Calculate a bounding sphere that fully contains the given points.
|
|
798
|
-
* @param points - The given points
|
|
799
|
-
* @param out - The calculated bounding sphere
|
|
800
|
-
*/ BoundingSphere.fromPoints = function fromPoints(points, out) {
|
|
801
|
-
if (!points || points.length === 0) {
|
|
802
|
-
throw new Error("points must be array and length must > 0");
|
|
803
|
-
}
|
|
804
|
-
var len = points.length;
|
|
805
|
-
var center = BoundingSphere._tempVec30;
|
|
806
|
-
center.x = center.y = center.z = 0;
|
|
807
|
-
// Calculate the center of the sphere.
|
|
808
|
-
for(var i = 0; i < len; ++i){
|
|
809
|
-
Vector3.add(points[i], center, center);
|
|
810
|
-
}
|
|
811
|
-
// The center of the sphere.
|
|
812
|
-
Vector3.scale(center, 1 / len, out.center);
|
|
813
|
-
// Calculate the radius of the sphere.
|
|
814
|
-
var radius = 0.0;
|
|
815
|
-
for(var i1 = 0; i1 < len; ++i1){
|
|
816
|
-
var distance = Vector3.distanceSquared(center, points[i1]);
|
|
817
|
-
distance > radius && (radius = distance);
|
|
818
|
-
}
|
|
819
|
-
// The radius of the sphere.
|
|
820
|
-
out.radius = Math.sqrt(radius);
|
|
821
|
-
};
|
|
822
|
-
/**
|
|
823
|
-
* Calculate a bounding sphere from a given box.
|
|
824
|
-
* @param box - The given box
|
|
825
|
-
* @param out - The calculated bounding sphere
|
|
826
|
-
*/ BoundingSphere.fromBox = function fromBox(box, out) {
|
|
827
|
-
var center = out.center;
|
|
828
|
-
var min = box.min, max = box.max;
|
|
829
|
-
center.x = (min.x + max.x) * 0.5;
|
|
830
|
-
center.y = (min.y + max.y) * 0.5;
|
|
831
|
-
center.z = (min.z + max.z) * 0.5;
|
|
832
|
-
out.radius = Vector3.distance(center, max);
|
|
833
|
-
};
|
|
834
|
-
return BoundingSphere;
|
|
835
|
-
}();
|
|
836
|
-
(function() {
|
|
837
|
-
BoundingSphere._tempVec30 = new Vector3();
|
|
838
|
-
})();
|
|
839
|
-
/**
|
|
840
|
-
* Axis Aligned Bound Box (AABB).
|
|
841
|
-
*/ var BoundingBox = /*#__PURE__*/ function() {
|
|
842
|
-
var BoundingBox = function BoundingBox(min, max) {
|
|
843
|
-
if (min === void 0) min = null;
|
|
844
|
-
if (max === void 0) max = null;
|
|
845
|
-
/** The minimum point of the box. */ this.min = new Vector3();
|
|
846
|
-
/** The maximum point of the box. */ this.max = new Vector3();
|
|
847
|
-
min && this.min.copyFrom(min);
|
|
848
|
-
max && this.max.copyFrom(max);
|
|
849
|
-
};
|
|
850
|
-
var _proto = BoundingBox.prototype;
|
|
851
|
-
/**
|
|
852
|
-
* Get the center point of this bounding box.
|
|
853
|
-
* @param out - The center point of this bounding box
|
|
854
|
-
* @returns The center point of this bounding box
|
|
855
|
-
*/ _proto.getCenter = function getCenter(out) {
|
|
856
|
-
var _this = this, min = _this.min, max = _this.max;
|
|
857
|
-
var centerX = max._x + min._x;
|
|
858
|
-
var centerY = max._y + min._y;
|
|
859
|
-
var centerZ = max._z + min._z;
|
|
860
|
-
out.set(isNaN(centerX) ? 0 : centerX * 0.5, isNaN(centerY) ? 0 : centerY * 0.5, isNaN(centerZ) ? 0 : centerZ * 0.5);
|
|
861
|
-
return out;
|
|
862
|
-
};
|
|
863
|
-
/**
|
|
864
|
-
* Get the extent of this bounding box.
|
|
865
|
-
* @param out - The extent of this bounding box
|
|
866
|
-
* @returns The extent of this bounding box
|
|
867
|
-
*/ _proto.getExtent = function getExtent(out) {
|
|
868
|
-
var _this = this, min = _this.min, max = _this.max;
|
|
869
|
-
var extentX = max._x - min._x;
|
|
870
|
-
var extentY = max._y - min._y;
|
|
871
|
-
var extentZ = max._z - min._z;
|
|
872
|
-
out.set(isNaN(extentX) ? 0 : extentX * 0.5, isNaN(extentY) ? 0 : extentY * 0.5, isNaN(extentZ) ? 0 : extentZ * 0.5);
|
|
873
|
-
return out;
|
|
874
|
-
};
|
|
875
|
-
/**
|
|
876
|
-
* Get the eight corners of this bounding box.
|
|
877
|
-
* @param out - An array of points representing the eight corners of this bounding box
|
|
878
|
-
* @returns An array of points representing the eight corners of this bounding box
|
|
879
|
-
*/ _proto.getCorners = function getCorners(out) {
|
|
880
|
-
if (out === void 0) out = [];
|
|
881
|
-
var _this = this, min = _this.min, max = _this.max;
|
|
882
|
-
var minX = min.x;
|
|
883
|
-
var minY = min.y;
|
|
884
|
-
var minZ = min.z;
|
|
885
|
-
var maxX = max.x;
|
|
886
|
-
var maxY = max.y;
|
|
887
|
-
var maxZ = max.z;
|
|
888
|
-
var len = out.length;
|
|
889
|
-
// The array length is less than 8 to make up
|
|
890
|
-
if (len < 8) {
|
|
891
|
-
for(var i = 0, l = 8 - len; i < l; ++i){
|
|
892
|
-
out[len + i] = new Vector3();
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
out[0].set(minX, maxY, maxZ);
|
|
896
|
-
out[1].set(maxX, maxY, maxZ);
|
|
897
|
-
out[2].set(maxX, minY, maxZ);
|
|
898
|
-
out[3].set(minX, minY, maxZ);
|
|
899
|
-
out[4].set(minX, maxY, minZ);
|
|
900
|
-
out[5].set(maxX, maxY, minZ);
|
|
901
|
-
out[6].set(maxX, minY, minZ);
|
|
902
|
-
out[7].set(minX, minY, minZ);
|
|
903
|
-
return out;
|
|
904
|
-
};
|
|
905
|
-
/**
|
|
906
|
-
* Transform a bounding box.
|
|
907
|
-
* @param matrix - The transform to apply to the bounding box
|
|
908
|
-
* @returns The transformed bounding box
|
|
909
|
-
*/ _proto.transform = function transform(matrix) {
|
|
910
|
-
BoundingBox.transform(this, matrix, this);
|
|
911
|
-
return this;
|
|
912
|
-
};
|
|
913
|
-
/**
|
|
914
|
-
* Creates a clone of this box.
|
|
915
|
-
* @returns A clone of this box
|
|
916
|
-
*/ _proto.clone = function clone() {
|
|
917
|
-
return new BoundingBox(this.min, this.max);
|
|
918
|
-
};
|
|
919
|
-
/**
|
|
920
|
-
* Copy this bounding box from the specified box.
|
|
921
|
-
* @param source - The specified box
|
|
922
|
-
* @returns This bounding box
|
|
923
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
924
|
-
this.min.copyFrom(source.min);
|
|
925
|
-
this.max.copyFrom(source.max);
|
|
926
|
-
return this;
|
|
927
|
-
};
|
|
928
|
-
/**
|
|
929
|
-
* Calculate a bounding box from the center point and the extent of the bounding box.
|
|
930
|
-
* @param center - The center point
|
|
931
|
-
* @param extent - The extent of the bounding box
|
|
932
|
-
* @param out - The calculated bounding box
|
|
933
|
-
*/ BoundingBox.fromCenterAndExtent = function fromCenterAndExtent(center, extent, out) {
|
|
934
|
-
Vector3.subtract(center, extent, out.min);
|
|
935
|
-
Vector3.add(center, extent, out.max);
|
|
936
|
-
};
|
|
937
|
-
/**
|
|
938
|
-
* Calculate a bounding box that fully contains the given points.
|
|
939
|
-
* @param points - The given points
|
|
940
|
-
* @param out - The calculated bounding box
|
|
941
|
-
*/ BoundingBox.fromPoints = function fromPoints(points, out) {
|
|
942
|
-
if (!points || points.length === 0) {
|
|
943
|
-
throw new Error("points must be array and length must > 0");
|
|
944
|
-
}
|
|
945
|
-
var min = out.min, max = out.max;
|
|
946
|
-
min.x = min.y = min.z = Number.MAX_VALUE;
|
|
947
|
-
max.x = max.y = max.z = -Number.MAX_VALUE;
|
|
948
|
-
for(var i = 0, l = points.length; i < l; ++i){
|
|
949
|
-
var point = points[i];
|
|
950
|
-
Vector3.min(min, point, min);
|
|
951
|
-
Vector3.max(max, point, max);
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
/**
|
|
955
|
-
* Calculate a bounding box from a given sphere.
|
|
956
|
-
* @param sphere - The given sphere
|
|
957
|
-
* @param out - The calculated bounding box
|
|
958
|
-
*/ BoundingBox.fromSphere = function fromSphere(sphere, out) {
|
|
959
|
-
var center = sphere.center, radius = sphere.radius;
|
|
960
|
-
var min = out.min, max = out.max;
|
|
961
|
-
min.x = center.x - radius;
|
|
962
|
-
min.y = center.y - radius;
|
|
963
|
-
min.z = center.z - radius;
|
|
964
|
-
max.x = center.x + radius;
|
|
965
|
-
max.y = center.y + radius;
|
|
966
|
-
max.z = center.z + radius;
|
|
967
|
-
};
|
|
968
|
-
/**
|
|
969
|
-
* Transform a bounding box.
|
|
970
|
-
* @param source - The original bounding box
|
|
971
|
-
* @param matrix - The transform to apply to the bounding box
|
|
972
|
-
* @param out - The transformed bounding box
|
|
973
|
-
*/ BoundingBox.transform = function transform(source, matrix, out) {
|
|
974
|
-
// https://zeux.io/2010/10/17/aabb-from-obb-with-component-wise-abs/
|
|
975
|
-
var center = BoundingBox._tempVec30;
|
|
976
|
-
var extent = BoundingBox._tempVec31;
|
|
977
|
-
source.getCenter(center);
|
|
978
|
-
source.getExtent(extent);
|
|
979
|
-
Vector3.transformCoordinate(center, matrix, center);
|
|
980
|
-
var x = extent.x, y = extent.y, z = extent.z;
|
|
981
|
-
var e = matrix.elements;
|
|
982
|
-
// prettier-ignore
|
|
983
|
-
var e0 = e[0], e1 = e[1], e2 = e[2], e4 = e[4], e5 = e[5], e6 = e[6], e8 = e[8], e9 = e[9], e10 = e[10];
|
|
984
|
-
extent.set((e0 === 0 ? 0 : Math.abs(x * e0)) + (e4 === 0 ? 0 : Math.abs(y * e4)) + (e8 === 0 ? 0 : Math.abs(z * e8)), (e1 === 0 ? 0 : Math.abs(x * e1)) + (e5 === 0 ? 0 : Math.abs(y * e5)) + (e9 === 0 ? 0 : Math.abs(z * e9)), (e2 === 0 ? 0 : Math.abs(x * e2)) + (e6 === 0 ? 0 : Math.abs(y * e6)) + (e10 === 0 ? 0 : Math.abs(z * e10)));
|
|
985
|
-
// set min、max
|
|
986
|
-
Vector3.subtract(center, extent, out.min);
|
|
987
|
-
Vector3.add(center, extent, out.max);
|
|
988
|
-
};
|
|
989
|
-
/**
|
|
990
|
-
* Calculate a bounding box that is as large as the total combined area of the two specified boxes.
|
|
991
|
-
* @param box1 - The first box to merge
|
|
992
|
-
* @param box2 - The second box to merge
|
|
993
|
-
* @param out - The merged bounding box
|
|
994
|
-
* @returns The merged bounding box
|
|
995
|
-
*/ BoundingBox.merge = function merge(box1, box2, out) {
|
|
996
|
-
Vector3.min(box1.min, box2.min, out.min);
|
|
997
|
-
Vector3.max(box1.max, box2.max, out.max);
|
|
998
|
-
return out;
|
|
999
|
-
};
|
|
1000
|
-
return BoundingBox;
|
|
1001
|
-
}();
|
|
1002
|
-
(function() {
|
|
1003
|
-
BoundingBox._tempVec30 = new Vector3();
|
|
1004
|
-
})();
|
|
1005
|
-
(function() {
|
|
1006
|
-
BoundingBox._tempVec31 = new Vector3();
|
|
1007
|
-
})();
|
|
1008
|
-
/**
|
|
1009
|
-
* Contains static methods to help in determining intersections, containment, etc.
|
|
1010
|
-
*/ var CollisionUtil = /*#__PURE__*/ function() {
|
|
1011
|
-
var CollisionUtil = function CollisionUtil() {};
|
|
1012
|
-
/**
|
|
1013
|
-
* Calculate the intersection point of three plane.
|
|
1014
|
-
* @param p1 - Plane 1
|
|
1015
|
-
* @param p2 - Plane 2
|
|
1016
|
-
* @param p3 - Plane 3
|
|
1017
|
-
* @param out - intersection point
|
|
1018
|
-
*/ CollisionUtil.intersectionPointThreePlanes = function intersectionPointThreePlanes(p1, p2, p3, out) {
|
|
1019
|
-
var p1Nor = p1.normal;
|
|
1020
|
-
var p2Nor = p2.normal;
|
|
1021
|
-
var p3Nor = p3.normal;
|
|
1022
|
-
Vector3.cross(p2Nor, p3Nor, CollisionUtil._tempVec30);
|
|
1023
|
-
Vector3.cross(p3Nor, p1Nor, CollisionUtil._tempVec31);
|
|
1024
|
-
Vector3.cross(p1Nor, p2Nor, CollisionUtil._tempVec32);
|
|
1025
|
-
var a = -Vector3.dot(p1Nor, CollisionUtil._tempVec30);
|
|
1026
|
-
var b = -Vector3.dot(p2Nor, CollisionUtil._tempVec31);
|
|
1027
|
-
var c = -Vector3.dot(p3Nor, CollisionUtil._tempVec32);
|
|
1028
|
-
Vector3.scale(CollisionUtil._tempVec30, p1.distance / a, CollisionUtil._tempVec30);
|
|
1029
|
-
Vector3.scale(CollisionUtil._tempVec31, p2.distance / b, CollisionUtil._tempVec31);
|
|
1030
|
-
Vector3.scale(CollisionUtil._tempVec32, p3.distance / c, CollisionUtil._tempVec32);
|
|
1031
|
-
Vector3.add(CollisionUtil._tempVec30, CollisionUtil._tempVec31, out);
|
|
1032
|
-
Vector3.add(out, CollisionUtil._tempVec32, out);
|
|
1033
|
-
};
|
|
1034
|
-
/**
|
|
1035
|
-
* Calculate the distance from a point to a plane.
|
|
1036
|
-
* @param plane - The plane
|
|
1037
|
-
* @param point - The point
|
|
1038
|
-
* @returns The distance from a point to a plane
|
|
1039
|
-
*/ CollisionUtil.distancePlaneAndPoint = function distancePlaneAndPoint(plane, point) {
|
|
1040
|
-
return Vector3.dot(plane.normal, point) + plane.distance;
|
|
1041
|
-
};
|
|
1042
|
-
/**
|
|
1043
|
-
* Get the intersection type between a plane and a point.
|
|
1044
|
-
* @param plane - The plane
|
|
1045
|
-
* @param point - The point
|
|
1046
|
-
* @returns The intersection type
|
|
1047
|
-
*/ CollisionUtil.intersectsPlaneAndPoint = function intersectsPlaneAndPoint(plane, point) {
|
|
1048
|
-
var distance = CollisionUtil.distancePlaneAndPoint(plane, point);
|
|
1049
|
-
if (distance > 0) {
|
|
1050
|
-
return PlaneIntersectionType.Front;
|
|
1051
|
-
}
|
|
1052
|
-
if (distance < 0) {
|
|
1053
|
-
return PlaneIntersectionType.Back;
|
|
1054
|
-
}
|
|
1055
|
-
return PlaneIntersectionType.Intersecting;
|
|
1056
|
-
};
|
|
1057
|
-
/**
|
|
1058
|
-
* Get the intersection type between a plane and a box (AABB).
|
|
1059
|
-
* @param plane - The plane
|
|
1060
|
-
* @param box - The box
|
|
1061
|
-
* @returns The intersection type
|
|
1062
|
-
*/ CollisionUtil.intersectsPlaneAndBox = function intersectsPlaneAndBox(plane, box) {
|
|
1063
|
-
var min = box.min, max = box.max;
|
|
1064
|
-
var normal = plane.normal;
|
|
1065
|
-
var front = CollisionUtil._tempVec30;
|
|
1066
|
-
var back = CollisionUtil._tempVec31;
|
|
1067
|
-
if (normal.x >= 0) {
|
|
1068
|
-
front.x = max.x;
|
|
1069
|
-
back.x = min.x;
|
|
1070
|
-
} else {
|
|
1071
|
-
front.x = min.x;
|
|
1072
|
-
back.x = max.x;
|
|
1073
|
-
}
|
|
1074
|
-
if (normal.y >= 0) {
|
|
1075
|
-
front.y = max.y;
|
|
1076
|
-
back.y = min.y;
|
|
1077
|
-
} else {
|
|
1078
|
-
front.y = min.y;
|
|
1079
|
-
back.y = max.y;
|
|
1080
|
-
}
|
|
1081
|
-
if (normal.z >= 0) {
|
|
1082
|
-
front.z = max.z;
|
|
1083
|
-
back.z = min.z;
|
|
1084
|
-
} else {
|
|
1085
|
-
front.z = min.z;
|
|
1086
|
-
back.z = max.z;
|
|
1087
|
-
}
|
|
1088
|
-
if (CollisionUtil.distancePlaneAndPoint(plane, front) < 0) {
|
|
1089
|
-
return PlaneIntersectionType.Back;
|
|
1090
|
-
}
|
|
1091
|
-
if (CollisionUtil.distancePlaneAndPoint(plane, back) > 0) {
|
|
1092
|
-
return PlaneIntersectionType.Front;
|
|
1093
|
-
}
|
|
1094
|
-
return PlaneIntersectionType.Intersecting;
|
|
1095
|
-
};
|
|
1096
|
-
/**
|
|
1097
|
-
* Get the intersection type between a plane and a sphere.
|
|
1098
|
-
* @param plane - The plane
|
|
1099
|
-
* @param sphere - The sphere
|
|
1100
|
-
* @returns The intersection type
|
|
1101
|
-
*/ CollisionUtil.intersectsPlaneAndSphere = function intersectsPlaneAndSphere(plane, sphere) {
|
|
1102
|
-
var center = sphere.center, radius = sphere.radius;
|
|
1103
|
-
var distance = CollisionUtil.distancePlaneAndPoint(plane, center);
|
|
1104
|
-
if (distance > radius) {
|
|
1105
|
-
return PlaneIntersectionType.Front;
|
|
1106
|
-
}
|
|
1107
|
-
if (distance < -radius) {
|
|
1108
|
-
return PlaneIntersectionType.Back;
|
|
1109
|
-
}
|
|
1110
|
-
return PlaneIntersectionType.Intersecting;
|
|
1111
|
-
};
|
|
1112
|
-
/**
|
|
1113
|
-
* Get the intersection type between a ray and a plane.
|
|
1114
|
-
* @param ray - The ray
|
|
1115
|
-
* @param plane - The plane
|
|
1116
|
-
* @returns The distance from ray to plane if intersecting, -1 otherwise
|
|
1117
|
-
*/ CollisionUtil.intersectsRayAndPlane = function intersectsRayAndPlane(ray, plane) {
|
|
1118
|
-
var normal = plane.normal;
|
|
1119
|
-
var zeroTolerance = MathUtil.zeroTolerance;
|
|
1120
|
-
var dir = Vector3.dot(normal, ray.direction);
|
|
1121
|
-
// Parallel
|
|
1122
|
-
if (Math.abs(dir) < zeroTolerance) {
|
|
1123
|
-
return -1;
|
|
1124
|
-
}
|
|
1125
|
-
var position = Vector3.dot(normal, ray.origin);
|
|
1126
|
-
var distance = (-plane.distance - position) / dir;
|
|
1127
|
-
if (distance < 0) {
|
|
1128
|
-
if (distance < -zeroTolerance) {
|
|
1129
|
-
return -1;
|
|
1130
|
-
}
|
|
1131
|
-
distance = 0;
|
|
1132
|
-
}
|
|
1133
|
-
return distance;
|
|
1134
|
-
};
|
|
1135
|
-
/**
|
|
1136
|
-
* Get the intersection type between a ray and a box (AABB).
|
|
1137
|
-
* @param ray - The ray
|
|
1138
|
-
* @param box - The box
|
|
1139
|
-
* @returns The distance from ray to box if intersecting, -1 otherwise
|
|
1140
|
-
*/ CollisionUtil.intersectsRayAndBox = function intersectsRayAndBox(ray, box) {
|
|
1141
|
-
var zeroTolerance = MathUtil.zeroTolerance;
|
|
1142
|
-
var origin = ray.origin, direction = ray.direction;
|
|
1143
|
-
var min = box.min, max = box.max;
|
|
1144
|
-
var dirX = direction.x;
|
|
1145
|
-
var dirY = direction.y;
|
|
1146
|
-
var dirZ = direction.z;
|
|
1147
|
-
var oriX = origin.x;
|
|
1148
|
-
var oriY = origin.y;
|
|
1149
|
-
var oriZ = origin.z;
|
|
1150
|
-
var distance = 0;
|
|
1151
|
-
var tmax = Number.MAX_VALUE;
|
|
1152
|
-
if (Math.abs(dirX) < zeroTolerance) {
|
|
1153
|
-
if (oriX < min.x || oriX > max.x) {
|
|
1154
|
-
return -1;
|
|
1155
|
-
}
|
|
1156
|
-
} else {
|
|
1157
|
-
var inverse = 1.0 / dirX;
|
|
1158
|
-
var t1 = (min.x - oriX) * inverse;
|
|
1159
|
-
var t2 = (max.x - oriX) * inverse;
|
|
1160
|
-
if (t1 > t2) {
|
|
1161
|
-
var temp = t1;
|
|
1162
|
-
t1 = t2;
|
|
1163
|
-
t2 = temp;
|
|
1164
|
-
}
|
|
1165
|
-
distance = Math.max(t1, distance);
|
|
1166
|
-
tmax = Math.min(t2, tmax);
|
|
1167
|
-
if (distance > tmax) {
|
|
1168
|
-
return -1;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
if (Math.abs(dirY) < zeroTolerance) {
|
|
1172
|
-
if (oriY < min.y || oriY > max.y) {
|
|
1173
|
-
return -1;
|
|
1174
|
-
}
|
|
1175
|
-
} else {
|
|
1176
|
-
var inverse1 = 1.0 / dirY;
|
|
1177
|
-
var t11 = (min.y - oriY) * inverse1;
|
|
1178
|
-
var t21 = (max.y - oriY) * inverse1;
|
|
1179
|
-
if (t11 > t21) {
|
|
1180
|
-
var temp1 = t11;
|
|
1181
|
-
t11 = t21;
|
|
1182
|
-
t21 = temp1;
|
|
1183
|
-
}
|
|
1184
|
-
distance = Math.max(t11, distance);
|
|
1185
|
-
tmax = Math.min(t21, tmax);
|
|
1186
|
-
if (distance > tmax) {
|
|
1187
|
-
return -1;
|
|
1188
|
-
}
|
|
1189
|
-
}
|
|
1190
|
-
if (Math.abs(dirZ) < zeroTolerance) {
|
|
1191
|
-
if (oriZ < min.z || oriZ > max.z) {
|
|
1192
|
-
return -1;
|
|
1193
|
-
}
|
|
1194
|
-
} else {
|
|
1195
|
-
var inverse2 = 1.0 / dirZ;
|
|
1196
|
-
var t12 = (min.z - oriZ) * inverse2;
|
|
1197
|
-
var t22 = (max.z - oriZ) * inverse2;
|
|
1198
|
-
if (t12 > t22) {
|
|
1199
|
-
var temp2 = t12;
|
|
1200
|
-
t12 = t22;
|
|
1201
|
-
t22 = temp2;
|
|
1202
|
-
}
|
|
1203
|
-
distance = Math.max(t12, distance);
|
|
1204
|
-
tmax = Math.min(t22, tmax);
|
|
1205
|
-
if (distance > tmax) {
|
|
1206
|
-
return -1;
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
return distance;
|
|
1210
|
-
};
|
|
1211
|
-
/**
|
|
1212
|
-
* Get the intersection type between a ray and a sphere.
|
|
1213
|
-
* @param ray - The ray
|
|
1214
|
-
* @param sphere - The sphere
|
|
1215
|
-
* @returns The distance from ray to sphere if intersecting, -1 otherwise
|
|
1216
|
-
*/ CollisionUtil.intersectsRayAndSphere = function intersectsRayAndSphere(ray, sphere) {
|
|
1217
|
-
var origin = ray.origin, direction = ray.direction;
|
|
1218
|
-
var center = sphere.center, radius = sphere.radius;
|
|
1219
|
-
var m = CollisionUtil._tempVec30;
|
|
1220
|
-
Vector3.subtract(origin, center, m);
|
|
1221
|
-
var b = Vector3.dot(m, direction);
|
|
1222
|
-
var c = Vector3.dot(m, m) - radius * radius;
|
|
1223
|
-
if (b > 0 && c > 0) {
|
|
1224
|
-
return -1;
|
|
1225
|
-
}
|
|
1226
|
-
var discriminant = b * b - c;
|
|
1227
|
-
if (discriminant < 0) {
|
|
1228
|
-
return -1;
|
|
1229
|
-
}
|
|
1230
|
-
var distance = -b - Math.sqrt(discriminant);
|
|
1231
|
-
if (distance < 0) {
|
|
1232
|
-
distance = 0;
|
|
1233
|
-
}
|
|
1234
|
-
return distance;
|
|
1235
|
-
};
|
|
1236
|
-
/**
|
|
1237
|
-
* Check whether the boxes intersect.
|
|
1238
|
-
* @param boxA - The first box to check
|
|
1239
|
-
* @param boxB - The second box to check
|
|
1240
|
-
* @returns True if the boxes intersect, false otherwise
|
|
1241
|
-
*/ CollisionUtil.intersectsBoxAndBox = function intersectsBoxAndBox(boxA, boxB) {
|
|
1242
|
-
if (boxA.min.x > boxB.max.x || boxB.min.x > boxA.max.x) {
|
|
1243
|
-
return false;
|
|
1244
|
-
}
|
|
1245
|
-
if (boxA.min.y > boxB.max.y || boxB.min.y > boxA.max.y) {
|
|
1246
|
-
return false;
|
|
1247
|
-
}
|
|
1248
|
-
return !(boxA.min.z > boxB.max.z || boxB.min.z > boxA.max.z);
|
|
1249
|
-
};
|
|
1250
|
-
/**
|
|
1251
|
-
* Check whether the spheres intersect.
|
|
1252
|
-
* @param sphereA - The first sphere to check
|
|
1253
|
-
* @param sphereB - The second sphere to check
|
|
1254
|
-
* @returns True if the spheres intersect, false otherwise
|
|
1255
|
-
*/ CollisionUtil.intersectsSphereAndSphere = function intersectsSphereAndSphere(sphereA, sphereB) {
|
|
1256
|
-
var radiisum = sphereA.radius + sphereB.radius;
|
|
1257
|
-
return Vector3.distanceSquared(sphereA.center, sphereB.center) < radiisum * radiisum;
|
|
1258
|
-
};
|
|
1259
|
-
/**
|
|
1260
|
-
* Check whether the sphere and the box intersect.
|
|
1261
|
-
* @param sphere - The sphere to check
|
|
1262
|
-
* @param box - The box to check
|
|
1263
|
-
* @returns True if the sphere and the box intersect, false otherwise
|
|
1264
|
-
*/ CollisionUtil.intersectsSphereAndBox = function intersectsSphereAndBox(sphere, box) {
|
|
1265
|
-
var center = sphere.center;
|
|
1266
|
-
var max = box.max;
|
|
1267
|
-
var min = box.min;
|
|
1268
|
-
var closestPoint = CollisionUtil._tempVec30;
|
|
1269
|
-
closestPoint.set(Math.max(min.x, Math.min(center.x, max.x)), Math.max(min.y, Math.min(center.y, max.y)), Math.max(min.z, Math.min(center.z, max.z)));
|
|
1270
|
-
var distance = Vector3.distanceSquared(center, closestPoint);
|
|
1271
|
-
return distance <= sphere.radius * sphere.radius;
|
|
1272
|
-
};
|
|
1273
|
-
/**
|
|
1274
|
-
* Get whether or not a specified bounding box intersects with this frustum (Contains or Intersects).
|
|
1275
|
-
* @param frustum - The frustum
|
|
1276
|
-
* @param box - The box
|
|
1277
|
-
* @returns True if bounding box intersects with this frustum, false otherwise
|
|
1278
|
-
*/ CollisionUtil.intersectsFrustumAndBox = function intersectsFrustumAndBox(frustum, box) {
|
|
1279
|
-
var min = box.min, max = box.max;
|
|
1280
|
-
var p = CollisionUtil._tempVec30;
|
|
1281
|
-
for(var i = 0; i < 6; ++i){
|
|
1282
|
-
var plane = frustum.getPlane(i);
|
|
1283
|
-
var normal = plane.normal;
|
|
1284
|
-
p.set(normal.x >= 0 ? max.x : min.x, normal.y >= 0 ? max.y : min.y, normal.z >= 0 ? max.z : min.z);
|
|
1285
|
-
if (Vector3.dot(normal, p) < -plane.distance) {
|
|
1286
|
-
return false;
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
return true;
|
|
1290
|
-
};
|
|
1291
|
-
/**
|
|
1292
|
-
* Get the containment type between a frustum and a point.
|
|
1293
|
-
* @param frustum - The frustum
|
|
1294
|
-
* @param point - The point
|
|
1295
|
-
* @returns The containment type
|
|
1296
|
-
*/ CollisionUtil.frustumContainsPoint = function frustumContainsPoint(frustum, point) {
|
|
1297
|
-
var distance = CollisionUtil.distancePlaneAndPoint(frustum.near, point);
|
|
1298
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1299
|
-
return ContainmentType.Intersects;
|
|
1300
|
-
} else if (distance < 0) {
|
|
1301
|
-
return ContainmentType.Disjoint;
|
|
1302
|
-
}
|
|
1303
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.far, point);
|
|
1304
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1305
|
-
return ContainmentType.Intersects;
|
|
1306
|
-
} else if (distance < 0) {
|
|
1307
|
-
return ContainmentType.Disjoint;
|
|
1308
|
-
}
|
|
1309
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.left, point);
|
|
1310
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1311
|
-
return ContainmentType.Intersects;
|
|
1312
|
-
} else if (distance < 0) {
|
|
1313
|
-
return ContainmentType.Disjoint;
|
|
1314
|
-
}
|
|
1315
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.right, point);
|
|
1316
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1317
|
-
return ContainmentType.Intersects;
|
|
1318
|
-
} else if (distance < 0) {
|
|
1319
|
-
return ContainmentType.Disjoint;
|
|
1320
|
-
}
|
|
1321
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.top, point);
|
|
1322
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1323
|
-
return ContainmentType.Intersects;
|
|
1324
|
-
} else if (distance < 0) {
|
|
1325
|
-
return ContainmentType.Disjoint;
|
|
1326
|
-
}
|
|
1327
|
-
distance = CollisionUtil.distancePlaneAndPoint(frustum.bottom, point);
|
|
1328
|
-
if (Math.abs(distance) < MathUtil.zeroTolerance) {
|
|
1329
|
-
return ContainmentType.Intersects;
|
|
1330
|
-
} else if (distance < 0) {
|
|
1331
|
-
return ContainmentType.Disjoint;
|
|
1332
|
-
}
|
|
1333
|
-
return ContainmentType.Contains;
|
|
1334
|
-
};
|
|
1335
|
-
/**
|
|
1336
|
-
* Get the containment type between a frustum and a box (AABB).
|
|
1337
|
-
* @param frustum - The frustum
|
|
1338
|
-
* @param box - The box
|
|
1339
|
-
* @returns The containment type
|
|
1340
|
-
*/ CollisionUtil.frustumContainsBox = function frustumContainsBox(frustum, box) {
|
|
1341
|
-
var min = box.min, max = box.max;
|
|
1342
|
-
var p = CollisionUtil._tempVec30;
|
|
1343
|
-
var n = CollisionUtil._tempVec31;
|
|
1344
|
-
var result = ContainmentType.Contains;
|
|
1345
|
-
for(var i = 0; i < 6; ++i){
|
|
1346
|
-
var plane = frustum.getPlane(i);
|
|
1347
|
-
var normal = plane.normal;
|
|
1348
|
-
if (normal.x >= 0) {
|
|
1349
|
-
p.x = max.x;
|
|
1350
|
-
n.x = min.x;
|
|
1351
|
-
} else {
|
|
1352
|
-
p.x = min.x;
|
|
1353
|
-
n.x = max.x;
|
|
1354
|
-
}
|
|
1355
|
-
if (normal.y >= 0) {
|
|
1356
|
-
p.y = max.y;
|
|
1357
|
-
n.y = min.y;
|
|
1358
|
-
} else {
|
|
1359
|
-
p.y = min.y;
|
|
1360
|
-
n.y = max.y;
|
|
1361
|
-
}
|
|
1362
|
-
if (normal.z >= 0) {
|
|
1363
|
-
p.z = max.z;
|
|
1364
|
-
n.z = min.z;
|
|
1365
|
-
} else {
|
|
1366
|
-
p.z = min.z;
|
|
1367
|
-
n.z = max.z;
|
|
1368
|
-
}
|
|
1369
|
-
if (CollisionUtil.intersectsPlaneAndPoint(plane, p) === PlaneIntersectionType.Back) {
|
|
1370
|
-
return ContainmentType.Disjoint;
|
|
1371
|
-
}
|
|
1372
|
-
if (CollisionUtil.intersectsPlaneAndPoint(plane, n) === PlaneIntersectionType.Back) {
|
|
1373
|
-
result = ContainmentType.Intersects;
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
return result;
|
|
1377
|
-
};
|
|
1378
|
-
/**
|
|
1379
|
-
* Get the containment type between a frustum and a sphere.
|
|
1380
|
-
* @param frustum - The frustum
|
|
1381
|
-
* @param sphere - The sphere
|
|
1382
|
-
* @returns The containment type
|
|
1383
|
-
*/ CollisionUtil.frustumContainsSphere = function frustumContainsSphere(frustum, sphere) {
|
|
1384
|
-
var result = ContainmentType.Contains;
|
|
1385
|
-
for(var i = 0; i < 6; ++i){
|
|
1386
|
-
var plane = frustum.getPlane(i);
|
|
1387
|
-
var intersectionType = CollisionUtil.intersectsPlaneAndSphere(plane, sphere);
|
|
1388
|
-
if (intersectionType === PlaneIntersectionType.Back) {
|
|
1389
|
-
return ContainmentType.Disjoint;
|
|
1390
|
-
} else if (intersectionType === PlaneIntersectionType.Intersecting) {
|
|
1391
|
-
result = ContainmentType.Intersects;
|
|
1392
|
-
break;
|
|
1393
|
-
}
|
|
1394
|
-
}
|
|
1395
|
-
return result;
|
|
1396
|
-
};
|
|
1397
|
-
return CollisionUtil;
|
|
1398
|
-
}();
|
|
1399
|
-
(function() {
|
|
1400
|
-
CollisionUtil._tempVec30 = new Vector3();
|
|
1401
|
-
})();
|
|
1402
|
-
(function() {
|
|
1403
|
-
CollisionUtil._tempVec31 = new Vector3();
|
|
1404
|
-
})();
|
|
1405
|
-
(function() {
|
|
1406
|
-
CollisionUtil._tempVec32 = new Vector3();
|
|
1407
|
-
})();
|
|
731
|
+
/** @internal */ Vector3._zero = new Vector3(0.0, 0.0, 0.0);
|
|
732
|
+
/** @internal */ Vector3._one = new Vector3(1.0, 1.0, 1.0);
|
|
733
|
+
new Vector3();
|
|
734
|
+
new Vector3();
|
|
735
|
+
new Vector3();
|
|
736
|
+
new Vector3();
|
|
737
|
+
new Vector3();
|
|
738
|
+
new Vector3();
|
|
1408
739
|
/**
|
|
1409
740
|
* Represents a 3x3 mathematical matrix.
|
|
1410
741
|
*/ var Matrix3x3 = /*#__PURE__*/ function() {
|
|
1411
|
-
|
|
742
|
+
function Matrix3x3(m11, m12, m13, m21, m22, m23, m31, m32, m33) {
|
|
1412
743
|
if (m11 === void 0) m11 = 1;
|
|
1413
744
|
if (m12 === void 0) m12 = 0;
|
|
1414
745
|
if (m13 === void 0) m13 = 0;
|
|
@@ -1437,7 +768,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1437
768
|
e[6] = m31;
|
|
1438
769
|
e[7] = m32;
|
|
1439
770
|
e[8] = m33;
|
|
1440
|
-
}
|
|
771
|
+
}
|
|
1441
772
|
var _proto = Matrix3x3.prototype;
|
|
1442
773
|
/**
|
|
1443
774
|
* Set the value of this matrix, and return this matrix.
|
|
@@ -1950,7 +1281,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1950
1281
|
/**
|
|
1951
1282
|
* Represents a four dimensional mathematical quaternion.
|
|
1952
1283
|
*/ var Quaternion = /*#__PURE__*/ function() {
|
|
1953
|
-
|
|
1284
|
+
function Quaternion(x, y, z, w) {
|
|
1954
1285
|
if (x === void 0) x = 0;
|
|
1955
1286
|
if (y === void 0) y = 0;
|
|
1956
1287
|
if (z === void 0) z = 0;
|
|
@@ -1960,7 +1291,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
1960
1291
|
this._y = y;
|
|
1961
1292
|
this._z = z;
|
|
1962
1293
|
this._w = w;
|
|
1963
|
-
}
|
|
1294
|
+
}
|
|
1964
1295
|
var _proto = Quaternion.prototype;
|
|
1965
1296
|
/**
|
|
1966
1297
|
* Set the value of this quaternion, and return this quaternion.
|
|
@@ -2606,16 +1937,12 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2606
1937
|
]);
|
|
2607
1938
|
return Quaternion;
|
|
2608
1939
|
}();
|
|
2609
|
-
(
|
|
2610
|
-
|
|
2611
|
-
})();
|
|
2612
|
-
(function() {
|
|
2613
|
-
/** @internal */ Quaternion._tempQuat1 = new Quaternion();
|
|
2614
|
-
})();
|
|
1940
|
+
/** @internal */ Quaternion._tempVector3 = new Vector3();
|
|
1941
|
+
/** @internal */ Quaternion._tempQuat1 = new Quaternion();
|
|
2615
1942
|
/**
|
|
2616
1943
|
* Represents a 4x4 mathematical matrix.
|
|
2617
1944
|
*/ var Matrix = /*#__PURE__*/ function() {
|
|
2618
|
-
|
|
1945
|
+
function Matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
|
|
2619
1946
|
if (m11 === void 0) m11 = 1;
|
|
2620
1947
|
if (m12 === void 0) m12 = 0;
|
|
2621
1948
|
if (m13 === void 0) m13 = 0;
|
|
@@ -2659,7 +1986,7 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
2659
1986
|
e[13] = m42;
|
|
2660
1987
|
e[14] = m43;
|
|
2661
1988
|
e[15] = m44;
|
|
2662
|
-
}
|
|
1989
|
+
}
|
|
2663
1990
|
var _proto = Matrix.prototype;
|
|
2664
1991
|
/**
|
|
2665
1992
|
* Set the value of this matrix, and return this matrix.
|
|
@@ -3551,897 +2878,107 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
3551
2878
|
};
|
|
3552
2879
|
return Matrix;
|
|
3553
2880
|
}();
|
|
3554
|
-
(
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
(
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
(
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
/**
|
|
3570
|
-
* Describes a 2D-vector.
|
|
3571
|
-
*/ var Vector2 = /*#__PURE__*/ function() {
|
|
3572
|
-
var Vector2 = function Vector2(x, y) {
|
|
3573
|
-
if (x === void 0) x = 0;
|
|
3574
|
-
if (y === void 0) y = 0;
|
|
3575
|
-
/** @internal */ this._onValueChanged = null;
|
|
3576
|
-
this._x = x;
|
|
3577
|
-
this._y = y;
|
|
3578
|
-
};
|
|
3579
|
-
var _proto = Vector2.prototype;
|
|
3580
|
-
/**
|
|
3581
|
-
* Set the value of this vector.
|
|
3582
|
-
* @param x - The x component of the vector
|
|
3583
|
-
* @param y - The y component of the vector
|
|
3584
|
-
* @returns This vector
|
|
3585
|
-
*/ _proto.set = function set(x, y) {
|
|
3586
|
-
this._x = x;
|
|
3587
|
-
this._y = y;
|
|
3588
|
-
this._onValueChanged && this._onValueChanged();
|
|
3589
|
-
return this;
|
|
2881
|
+
Matrix._tempVec30 = new Vector3();
|
|
2882
|
+
Matrix._tempVec31 = new Vector3();
|
|
2883
|
+
Matrix._tempVec32 = new Vector3();
|
|
2884
|
+
Matrix._tempMat30 = new Matrix3x3();
|
|
2885
|
+
/** @internal Identity matrix. */ Matrix._identity = new Matrix(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0);
|
|
2886
|
+
|
|
2887
|
+
var WebXRFrame = /*#__PURE__*/ function() {
|
|
2888
|
+
function WebXRFrame(session) {
|
|
2889
|
+
this._session = session;
|
|
2890
|
+
}
|
|
2891
|
+
var _proto = WebXRFrame.prototype;
|
|
2892
|
+
_proto.updateInputs = function updateInputs(inputs) {
|
|
2893
|
+
if (!this._platformFrame) return;
|
|
2894
|
+
this._updateController(inputs);
|
|
2895
|
+
this._updateCamera(inputs);
|
|
3590
2896
|
};
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
2897
|
+
_proto._updateController = function _updateController(inputs) {
|
|
2898
|
+
var _this = this, frame = _this._platformFrame;
|
|
2899
|
+
var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
|
|
2900
|
+
var inputSources = session.inputSources;
|
|
2901
|
+
for(var i = 0, n = inputSources.length; i < n; i++){
|
|
2902
|
+
var inputSource = inputSources[i];
|
|
2903
|
+
var type = getInputSource(inputSource);
|
|
2904
|
+
var input = inputs[type];
|
|
2905
|
+
switch(inputSource.targetRayMode){
|
|
2906
|
+
case "screen":
|
|
2907
|
+
case "tracked-pointer":
|
|
2908
|
+
var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
|
|
2909
|
+
if (gripSpace) {
|
|
2910
|
+
var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
|
|
2911
|
+
if (transform) {
|
|
2912
|
+
var gripPose = input.gripPose;
|
|
2913
|
+
gripPose.matrix.copyFromArray(transform.matrix);
|
|
2914
|
+
gripPose.position.copyFrom(transform.position);
|
|
2915
|
+
gripPose.rotation.copyFrom(transform.orientation);
|
|
2916
|
+
}
|
|
2917
|
+
input.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2918
|
+
}
|
|
2919
|
+
if (targetRaySpace) {
|
|
2920
|
+
var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
|
|
2921
|
+
if (transform1) {
|
|
2922
|
+
var targetRayPose = input.targetRayPose;
|
|
2923
|
+
targetRayPose.matrix.copyFromArray(transform1.matrix);
|
|
2924
|
+
targetRayPose.position.copyFrom(transform1.position);
|
|
2925
|
+
targetRayPose.rotation.copyFrom(transform1.orientation);
|
|
2926
|
+
input.trackingState = emulatedPosition1 ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
break;
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
3600
2932
|
};
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
this._y = -this._y;
|
|
3651
|
-
this._onValueChanged && this._onValueChanged();
|
|
3652
|
-
return this;
|
|
3653
|
-
};
|
|
3654
|
-
/**
|
|
3655
|
-
* Converts this vector into a unit vector.
|
|
3656
|
-
* @returns This vector
|
|
3657
|
-
*/ _proto.normalize = function normalize() {
|
|
3658
|
-
Vector2.normalize(this, this);
|
|
3659
|
-
return this;
|
|
3660
|
-
};
|
|
3661
|
-
/**
|
|
3662
|
-
* Scale this vector by the given value.
|
|
3663
|
-
* @param s - The amount by which to scale the vector
|
|
3664
|
-
* @returns This vector
|
|
3665
|
-
*/ _proto.scale = function scale(s) {
|
|
3666
|
-
this._x *= s;
|
|
3667
|
-
this._y *= s;
|
|
3668
|
-
this._onValueChanged && this._onValueChanged();
|
|
3669
|
-
return this;
|
|
3670
|
-
};
|
|
3671
|
-
/**
|
|
3672
|
-
* Creates a clone of this vector.
|
|
3673
|
-
* @returns A clone of this vector
|
|
3674
|
-
*/ _proto.clone = function clone() {
|
|
3675
|
-
return new Vector2(this._x, this._y);
|
|
3676
|
-
};
|
|
3677
|
-
/**
|
|
3678
|
-
* Copy from vector2 like object.
|
|
3679
|
-
* @param source - Vector2 like object
|
|
3680
|
-
* @returns This vector
|
|
3681
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
3682
|
-
this._x = source.x;
|
|
3683
|
-
this._y = source.y;
|
|
3684
|
-
this._onValueChanged && this._onValueChanged();
|
|
3685
|
-
return this;
|
|
3686
|
-
};
|
|
3687
|
-
/**
|
|
3688
|
-
* Copy to vector2 like object.
|
|
3689
|
-
* @param target - Vector2 like object
|
|
3690
|
-
* @returns This Vector2 like object
|
|
3691
|
-
*/ _proto.copyTo = function copyTo(target) {
|
|
3692
|
-
target.x = this._x;
|
|
3693
|
-
target.y = this._y;
|
|
3694
|
-
return target;
|
|
3695
|
-
};
|
|
3696
|
-
/**
|
|
3697
|
-
* Copy the value of this vector from an array.
|
|
3698
|
-
* @param array - The array
|
|
3699
|
-
* @param offset - The start offset of the array
|
|
3700
|
-
* @returns This vector
|
|
3701
|
-
*/ _proto.copyFromArray = function copyFromArray(array, offset) {
|
|
3702
|
-
if (offset === void 0) offset = 0;
|
|
3703
|
-
this._x = array[offset];
|
|
3704
|
-
this._y = array[offset + 1];
|
|
3705
|
-
this._onValueChanged && this._onValueChanged();
|
|
3706
|
-
return this;
|
|
3707
|
-
};
|
|
3708
|
-
/**
|
|
3709
|
-
* Copy the value of this vector to an array.
|
|
3710
|
-
* @param out - The array
|
|
3711
|
-
* @param outOffset - The start offset of the array
|
|
3712
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
3713
|
-
if (outOffset === void 0) outOffset = 0;
|
|
3714
|
-
out[outOffset] = this._x;
|
|
3715
|
-
out[outOffset + 1] = this._y;
|
|
3716
|
-
};
|
|
3717
|
-
/**
|
|
3718
|
-
* Serialize this vector to a JSON representation.
|
|
3719
|
-
* @returns A JSON representation of this vector
|
|
3720
|
-
*/ _proto.toJSON = function toJSON() {
|
|
3721
|
-
return {
|
|
3722
|
-
x: this._x,
|
|
3723
|
-
y: this._y
|
|
3724
|
-
};
|
|
3725
|
-
};
|
|
3726
|
-
/**
|
|
3727
|
-
* Determines the sum of two vectors.
|
|
3728
|
-
* @param left - The first vector to add
|
|
3729
|
-
* @param right - The second vector to add
|
|
3730
|
-
* @param out - The sum of two vectors
|
|
3731
|
-
*/ Vector2.add = function add(left, right, out) {
|
|
3732
|
-
out._x = left._x + right._x;
|
|
3733
|
-
out._y = left._y + right._y;
|
|
3734
|
-
out._onValueChanged && out._onValueChanged();
|
|
3735
|
-
};
|
|
3736
|
-
/**
|
|
3737
|
-
* Determines the difference between two vectors.
|
|
3738
|
-
* @param left - The first vector to subtract
|
|
3739
|
-
* @param right - The second vector to subtract
|
|
3740
|
-
* @param out - The difference between two vectors
|
|
3741
|
-
*/ Vector2.subtract = function subtract(left, right, out) {
|
|
3742
|
-
out._x = left._x - right._x;
|
|
3743
|
-
out._y = left._y - right._y;
|
|
3744
|
-
out._onValueChanged && out._onValueChanged();
|
|
3745
|
-
};
|
|
3746
|
-
/**
|
|
3747
|
-
* Determines the product of two vectors.
|
|
3748
|
-
* @param left - The first vector to multiply
|
|
3749
|
-
* @param right - The second vector to multiply
|
|
3750
|
-
* @param out - The product of two vectors
|
|
3751
|
-
*/ Vector2.multiply = function multiply(left, right, out) {
|
|
3752
|
-
out._x = left._x * right._x;
|
|
3753
|
-
out._y = left._y * right._y;
|
|
3754
|
-
out._onValueChanged && out._onValueChanged();
|
|
3755
|
-
};
|
|
3756
|
-
/**
|
|
3757
|
-
* Determines the divisor of two vectors.
|
|
3758
|
-
* @param left - The first vector to divide
|
|
3759
|
-
* @param right - The second vector to divide
|
|
3760
|
-
* @param out - The divisor of two vectors
|
|
3761
|
-
*/ Vector2.divide = function divide(left, right, out) {
|
|
3762
|
-
out._x = left._x / right._x;
|
|
3763
|
-
out._y = left._y / right._y;
|
|
3764
|
-
out._onValueChanged && out._onValueChanged();
|
|
3765
|
-
};
|
|
3766
|
-
/**
|
|
3767
|
-
* Determines the dot product of two vectors.
|
|
3768
|
-
* @param left - The first vector to dot
|
|
3769
|
-
* @param right - The second vector to dot
|
|
3770
|
-
* @returns The dot product of two vectors
|
|
3771
|
-
*/ Vector2.dot = function dot(left, right) {
|
|
3772
|
-
return left._x * right._x + left._y * right._y;
|
|
3773
|
-
};
|
|
3774
|
-
/**
|
|
3775
|
-
* Determines the distance of two vectors.
|
|
3776
|
-
* @param left - The first vector
|
|
3777
|
-
* @param right - The second vector
|
|
3778
|
-
* @returns The distance of two vectors
|
|
3779
|
-
*/ Vector2.distance = function distance(left, right) {
|
|
3780
|
-
var x = right._x - left._x;
|
|
3781
|
-
var y = right._y - left._y;
|
|
3782
|
-
return Math.sqrt(x * x + y * y);
|
|
3783
|
-
};
|
|
3784
|
-
/**
|
|
3785
|
-
* Determines the squared distance of two vectors.
|
|
3786
|
-
* @param left - The first vector
|
|
3787
|
-
* @param right - The second vector
|
|
3788
|
-
* @returns The squared distance of two vectors
|
|
3789
|
-
*/ Vector2.distanceSquared = function distanceSquared(left, right) {
|
|
3790
|
-
var x = right._x - left._x;
|
|
3791
|
-
var y = right._y - left._y;
|
|
3792
|
-
return x * x + y * y;
|
|
3793
|
-
};
|
|
3794
|
-
/**
|
|
3795
|
-
* Determines whether the specified vectors are equals.
|
|
3796
|
-
* @param left - The first vector to compare
|
|
3797
|
-
* @param right - The second vector to compare
|
|
3798
|
-
* @returns True if the specified vectors are equals, false otherwise
|
|
3799
|
-
*/ Vector2.equals = function equals(left, right) {
|
|
3800
|
-
return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y);
|
|
3801
|
-
};
|
|
3802
|
-
/**
|
|
3803
|
-
* Performs a linear interpolation between two vectors.
|
|
3804
|
-
* @param left - The first vector
|
|
3805
|
-
* @param right - The second vector
|
|
3806
|
-
* @param t - The blend amount where 0 returns left and 1 right
|
|
3807
|
-
* @param out - The result of linear blending between two vectors
|
|
3808
|
-
*/ Vector2.lerp = function lerp(left, right, t, out) {
|
|
3809
|
-
var _x = left._x, _y = left._y;
|
|
3810
|
-
out._x = _x + (right._x - _x) * t;
|
|
3811
|
-
out._y = _y + (right._y - _y) * t;
|
|
3812
|
-
out._onValueChanged && out._onValueChanged();
|
|
3813
|
-
};
|
|
3814
|
-
/**
|
|
3815
|
-
* Calculate a vector containing the largest components of the specified vectors.
|
|
3816
|
-
* @param left - The first vector
|
|
3817
|
-
* @param right - The second vector
|
|
3818
|
-
* @param out - The vector containing the largest components of the specified vectors
|
|
3819
|
-
*/ Vector2.max = function max(left, right, out) {
|
|
3820
|
-
out._x = Math.max(left._x, right._x);
|
|
3821
|
-
out._y = Math.max(left._y, right._y);
|
|
3822
|
-
out._onValueChanged && out._onValueChanged();
|
|
3823
|
-
};
|
|
3824
|
-
/**
|
|
3825
|
-
* Calculate a vector containing the smallest components of the specified vectors.
|
|
3826
|
-
* @param left - The first vector
|
|
3827
|
-
* @param right - The second vector
|
|
3828
|
-
* @param out - The vector containing the smallest components of the specified vectors
|
|
3829
|
-
*/ Vector2.min = function min(left, right, out) {
|
|
3830
|
-
out._x = Math.min(left._x, right._x);
|
|
3831
|
-
out._y = Math.min(left._y, right._y);
|
|
3832
|
-
out._onValueChanged && out._onValueChanged();
|
|
3833
|
-
};
|
|
3834
|
-
/**
|
|
3835
|
-
* Reverses the direction of a given vector.
|
|
3836
|
-
* @param left - The vector to negate
|
|
3837
|
-
* @param out - The vector facing in the opposite direction
|
|
3838
|
-
*/ Vector2.negate = function negate(left, out) {
|
|
3839
|
-
out._x = -left._x;
|
|
3840
|
-
out._y = -left._y;
|
|
3841
|
-
out._onValueChanged && out._onValueChanged();
|
|
3842
|
-
};
|
|
3843
|
-
/**
|
|
3844
|
-
* Converts the vector into a unit vector.
|
|
3845
|
-
* @param left - The vector to normalize
|
|
3846
|
-
* @param out - The normalized vector
|
|
3847
|
-
*/ Vector2.normalize = function normalize(left, out) {
|
|
3848
|
-
var _x = left._x, _y = left._y;
|
|
3849
|
-
var len = Math.sqrt(_x * _x + _y * _y);
|
|
3850
|
-
if (len > MathUtil.zeroTolerance) {
|
|
3851
|
-
len = 1 / len;
|
|
3852
|
-
out._x = _x * len;
|
|
3853
|
-
out._y = _y * len;
|
|
3854
|
-
out._onValueChanged && out._onValueChanged();
|
|
3855
|
-
}
|
|
3856
|
-
};
|
|
3857
|
-
/**
|
|
3858
|
-
* Scale a vector by the given value.
|
|
3859
|
-
* @param left - The vector to scale
|
|
3860
|
-
* @param s - The amount by which to scale the vector
|
|
3861
|
-
* @param out - The scaled vector
|
|
3862
|
-
*/ Vector2.scale = function scale(left, s, out) {
|
|
3863
|
-
out._x = left._x * s;
|
|
3864
|
-
out._y = left._y * s;
|
|
3865
|
-
out._onValueChanged && out._onValueChanged();
|
|
3866
|
-
};
|
|
3867
|
-
_create_class(Vector2, [
|
|
3868
|
-
{
|
|
3869
|
-
key: "x",
|
|
3870
|
-
get: /**
|
|
3871
|
-
* The x component of the vector.
|
|
3872
|
-
*/ function get() {
|
|
3873
|
-
return this._x;
|
|
3874
|
-
},
|
|
3875
|
-
set: function set(value) {
|
|
3876
|
-
this._x = value;
|
|
3877
|
-
this._onValueChanged && this._onValueChanged();
|
|
3878
|
-
}
|
|
3879
|
-
},
|
|
3880
|
-
{
|
|
3881
|
-
key: "y",
|
|
3882
|
-
get: /**
|
|
3883
|
-
* The y component of the vector.
|
|
3884
|
-
*/ function get() {
|
|
3885
|
-
return this._y;
|
|
3886
|
-
},
|
|
3887
|
-
set: function set(value) {
|
|
3888
|
-
this._y = value;
|
|
3889
|
-
this._onValueChanged && this._onValueChanged();
|
|
3890
|
-
}
|
|
3891
|
-
}
|
|
3892
|
-
]);
|
|
3893
|
-
return Vector2;
|
|
3894
|
-
}();
|
|
3895
|
-
(function() {
|
|
3896
|
-
/** @internal */ Vector2._zero = new Vector2(0.0, 0.0);
|
|
3897
|
-
})();
|
|
3898
|
-
(function() {
|
|
3899
|
-
/** @internal */ Vector2._one = new Vector2(1.0, 1.0);
|
|
3900
|
-
})();
|
|
3901
|
-
/**
|
|
3902
|
-
* Describes a 4D-vector.
|
|
3903
|
-
*/ var Vector4 = /*#__PURE__*/ function() {
|
|
3904
|
-
var Vector4 = function Vector4(x, y, z, w) {
|
|
3905
|
-
if (x === void 0) x = 0;
|
|
3906
|
-
if (y === void 0) y = 0;
|
|
3907
|
-
if (z === void 0) z = 0;
|
|
3908
|
-
if (w === void 0) w = 0;
|
|
3909
|
-
/** @internal */ this._onValueChanged = null;
|
|
3910
|
-
this._x = x;
|
|
3911
|
-
this._y = y;
|
|
3912
|
-
this._z = z;
|
|
3913
|
-
this._w = w;
|
|
3914
|
-
};
|
|
3915
|
-
var _proto = Vector4.prototype;
|
|
3916
|
-
/**
|
|
3917
|
-
* Set the value of this vector.
|
|
3918
|
-
* @param x - The x component of the vector
|
|
3919
|
-
* @param y - The y component of the vector
|
|
3920
|
-
* @param z - The z component of the vector
|
|
3921
|
-
* @param w - The w component of the vector
|
|
3922
|
-
* @returns This vector
|
|
3923
|
-
*/ _proto.set = function set(x, y, z, w) {
|
|
3924
|
-
this._x = x;
|
|
3925
|
-
this._y = y;
|
|
3926
|
-
this._z = z;
|
|
3927
|
-
this._w = w;
|
|
3928
|
-
this._onValueChanged && this._onValueChanged();
|
|
3929
|
-
return this;
|
|
3930
|
-
};
|
|
3931
|
-
/**
|
|
3932
|
-
* Determines the sum of this vector and the specified vector.
|
|
3933
|
-
* @param right - The specified vector
|
|
3934
|
-
* @returns This vector
|
|
3935
|
-
*/ _proto.add = function add(right) {
|
|
3936
|
-
this._x += right._x;
|
|
3937
|
-
this._y += right._y;
|
|
3938
|
-
this._z += right._z;
|
|
3939
|
-
this._w += right._w;
|
|
3940
|
-
this._onValueChanged && this._onValueChanged();
|
|
3941
|
-
return this;
|
|
3942
|
-
};
|
|
3943
|
-
/**
|
|
3944
|
-
* Determines the difference of this vector and the specified vector.
|
|
3945
|
-
* @param right - the specified vector
|
|
3946
|
-
* @returns This vector
|
|
3947
|
-
*/ _proto.subtract = function subtract(right) {
|
|
3948
|
-
this._x -= right._x;
|
|
3949
|
-
this._y -= right._y;
|
|
3950
|
-
this._z -= right._z;
|
|
3951
|
-
this._w -= right._w;
|
|
3952
|
-
this._onValueChanged && this._onValueChanged();
|
|
3953
|
-
return this;
|
|
3954
|
-
};
|
|
3955
|
-
/**
|
|
3956
|
-
* Determines the product of this vector and the specified vector.
|
|
3957
|
-
* @param right - the specified vector
|
|
3958
|
-
* @returns This vector
|
|
3959
|
-
*/ _proto.multiply = function multiply(right) {
|
|
3960
|
-
this._x *= right._x;
|
|
3961
|
-
this._y *= right._y;
|
|
3962
|
-
this._z *= right._z;
|
|
3963
|
-
this._w *= right._w;
|
|
3964
|
-
this._onValueChanged && this._onValueChanged();
|
|
3965
|
-
return this;
|
|
3966
|
-
};
|
|
3967
|
-
/**
|
|
3968
|
-
* Determines the divisor of this vector and the specified vector.
|
|
3969
|
-
* @param right - the specified vector
|
|
3970
|
-
* @returns This vector
|
|
3971
|
-
*/ _proto.divide = function divide(right) {
|
|
3972
|
-
this._x /= right._x;
|
|
3973
|
-
this._y /= right._y;
|
|
3974
|
-
this._z /= right._z;
|
|
3975
|
-
this._w /= right._w;
|
|
3976
|
-
this._onValueChanged && this._onValueChanged();
|
|
3977
|
-
return this;
|
|
3978
|
-
};
|
|
3979
|
-
/**
|
|
3980
|
-
* Calculate the length of this vector.
|
|
3981
|
-
* @returns The length of this vector
|
|
3982
|
-
*/ _proto.length = function length() {
|
|
3983
|
-
var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
|
|
3984
|
-
return Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
|
|
3985
|
-
};
|
|
3986
|
-
/**
|
|
3987
|
-
* Calculate the squared length of this vector.
|
|
3988
|
-
* @returns The squared length of this vector
|
|
3989
|
-
*/ _proto.lengthSquared = function lengthSquared() {
|
|
3990
|
-
var _this = this, _x = _this._x, _y = _this._y, _z = _this._z, _w = _this._w;
|
|
3991
|
-
return _x * _x + _y * _y + _z * _z + _w * _w;
|
|
3992
|
-
};
|
|
3993
|
-
/**
|
|
3994
|
-
* Reverses the direction of this vector.
|
|
3995
|
-
* @returns This vector
|
|
3996
|
-
*/ _proto.negate = function negate() {
|
|
3997
|
-
this._x = -this._x;
|
|
3998
|
-
this._y = -this._y;
|
|
3999
|
-
this._z = -this._z;
|
|
4000
|
-
this._w = -this._w;
|
|
4001
|
-
this._onValueChanged && this._onValueChanged();
|
|
4002
|
-
return this;
|
|
4003
|
-
};
|
|
4004
|
-
/**
|
|
4005
|
-
* Converts this vector into a unit vector.
|
|
4006
|
-
* @returns This vector
|
|
4007
|
-
*/ _proto.normalize = function normalize() {
|
|
4008
|
-
Vector4.normalize(this, this);
|
|
4009
|
-
return this;
|
|
4010
|
-
};
|
|
4011
|
-
/**
|
|
4012
|
-
* Scale this vector by the given value.
|
|
4013
|
-
* @param s - The amount by which to scale the vector
|
|
4014
|
-
* @returns This vector
|
|
4015
|
-
*/ _proto.scale = function scale(s) {
|
|
4016
|
-
this._x *= s;
|
|
4017
|
-
this._y *= s;
|
|
4018
|
-
this._z *= s;
|
|
4019
|
-
this._w *= s;
|
|
4020
|
-
this._onValueChanged && this._onValueChanged();
|
|
4021
|
-
return this;
|
|
4022
|
-
};
|
|
4023
|
-
/**
|
|
4024
|
-
* Creates a clone of this vector.
|
|
4025
|
-
* @returns A clone of this vector
|
|
4026
|
-
*/ _proto.clone = function clone() {
|
|
4027
|
-
var ret = new Vector4(this._x, this._y, this._z, this._w);
|
|
4028
|
-
return ret;
|
|
4029
|
-
};
|
|
4030
|
-
/**
|
|
4031
|
-
* Copy from vector3 like object.
|
|
4032
|
-
* @param source - Vector3 like object.
|
|
4033
|
-
* @returns This vector
|
|
4034
|
-
*/ _proto.copyFrom = function copyFrom(source) {
|
|
4035
|
-
this._x = source.x;
|
|
4036
|
-
this._y = source.y;
|
|
4037
|
-
this._z = source.z;
|
|
4038
|
-
this._w = source.w;
|
|
4039
|
-
this._onValueChanged && this._onValueChanged();
|
|
4040
|
-
return this;
|
|
4041
|
-
};
|
|
4042
|
-
/**
|
|
4043
|
-
* Copy to vector4 like object.
|
|
4044
|
-
* @param target - Vector4 like object
|
|
4045
|
-
* @returns This Vector4 like object
|
|
4046
|
-
*/ _proto.copyTo = function copyTo(target) {
|
|
4047
|
-
target.x = this._x;
|
|
4048
|
-
target.y = this._y;
|
|
4049
|
-
target.z = this._z;
|
|
4050
|
-
target.w = this._w;
|
|
4051
|
-
return target;
|
|
4052
|
-
};
|
|
4053
|
-
/**
|
|
4054
|
-
* Copy the value of this vector by an array.
|
|
4055
|
-
* @param array - The array
|
|
4056
|
-
* @param offset - The start offset of the array
|
|
4057
|
-
* @returns This vector
|
|
4058
|
-
*/ _proto.copyFromArray = function copyFromArray(array, offset) {
|
|
4059
|
-
if (offset === void 0) offset = 0;
|
|
4060
|
-
this._x = array[offset];
|
|
4061
|
-
this._y = array[offset + 1];
|
|
4062
|
-
this._z = array[offset + 2];
|
|
4063
|
-
this._w = array[offset + 3];
|
|
4064
|
-
this._onValueChanged && this._onValueChanged();
|
|
4065
|
-
return this;
|
|
4066
|
-
};
|
|
4067
|
-
/**
|
|
4068
|
-
* Copy the value of this vector to an array.
|
|
4069
|
-
* @param out - The array
|
|
4070
|
-
* @param outOffset - The start offset of the array
|
|
4071
|
-
*/ _proto.copyToArray = function copyToArray(out, outOffset) {
|
|
4072
|
-
if (outOffset === void 0) outOffset = 0;
|
|
4073
|
-
out[outOffset] = this._x;
|
|
4074
|
-
out[outOffset + 1] = this._y;
|
|
4075
|
-
out[outOffset + 2] = this._z;
|
|
4076
|
-
out[outOffset + 3] = this._w;
|
|
4077
|
-
};
|
|
4078
|
-
/**
|
|
4079
|
-
* Serialize this vector to a JSON representation.
|
|
4080
|
-
* @returns A JSON representation of this vector
|
|
4081
|
-
*/ _proto.toJSON = function toJSON() {
|
|
4082
|
-
return {
|
|
4083
|
-
x: this._x,
|
|
4084
|
-
y: this._y,
|
|
4085
|
-
z: this._z,
|
|
4086
|
-
w: this._w
|
|
4087
|
-
};
|
|
4088
|
-
};
|
|
4089
|
-
/**
|
|
4090
|
-
* Determines the sum of two vectors.
|
|
4091
|
-
* @param left - The first vector to add
|
|
4092
|
-
* @param right - The second vector to add
|
|
4093
|
-
* @param out - The sum of two vectors
|
|
4094
|
-
*/ Vector4.add = function add(left, right, out) {
|
|
4095
|
-
out._x = left._x + right._x;
|
|
4096
|
-
out._y = left._y + right._y;
|
|
4097
|
-
out._z = left._z + right._z;
|
|
4098
|
-
out._w = left._w + right._w;
|
|
4099
|
-
out._onValueChanged && out._onValueChanged();
|
|
4100
|
-
};
|
|
4101
|
-
/**
|
|
4102
|
-
* Determines the difference between two vectors.
|
|
4103
|
-
* @param left - The first vector to subtract
|
|
4104
|
-
* @param right - The second vector to subtract
|
|
4105
|
-
* @param out - The difference between two vectors
|
|
4106
|
-
*/ Vector4.subtract = function subtract(left, right, out) {
|
|
4107
|
-
out._x = left._x - right._x;
|
|
4108
|
-
out._y = left._y - right._y;
|
|
4109
|
-
out._z = left._z - right._z;
|
|
4110
|
-
out._w = left._w - right._w;
|
|
4111
|
-
out._onValueChanged && out._onValueChanged();
|
|
4112
|
-
};
|
|
4113
|
-
/**
|
|
4114
|
-
* Determines the product of two vectors.
|
|
4115
|
-
* @param left - The first vector to multiply
|
|
4116
|
-
* @param right - The second vector to multiply
|
|
4117
|
-
* @param out - The product of two vectors
|
|
4118
|
-
*/ Vector4.multiply = function multiply(left, right, out) {
|
|
4119
|
-
out._x = left._x * right._x;
|
|
4120
|
-
out._y = left._y * right._y;
|
|
4121
|
-
out._z = left._z * right._z;
|
|
4122
|
-
out._w = left._w * right._w;
|
|
4123
|
-
out._onValueChanged && out._onValueChanged();
|
|
4124
|
-
};
|
|
4125
|
-
/**
|
|
4126
|
-
* Determines the divisor of two vectors.
|
|
4127
|
-
* @param left - The first vector to divide
|
|
4128
|
-
* @param right - The second vector to divide
|
|
4129
|
-
* @param out - The divisor of two vectors
|
|
4130
|
-
*/ Vector4.divide = function divide(left, right, out) {
|
|
4131
|
-
out._x = left._x / right._x;
|
|
4132
|
-
out._y = left._y / right._y;
|
|
4133
|
-
out._z = left._z / right._z;
|
|
4134
|
-
out._w = left._w / right._w;
|
|
4135
|
-
out._onValueChanged && out._onValueChanged();
|
|
4136
|
-
};
|
|
4137
|
-
/**
|
|
4138
|
-
* Determines the dot product of two vectors.
|
|
4139
|
-
* @param left - The first vector to dot
|
|
4140
|
-
* @param right - The second vector to dot
|
|
4141
|
-
* @returns The dot product of two vectors
|
|
4142
|
-
*/ Vector4.dot = function dot(left, right) {
|
|
4143
|
-
return left._x * right._x + left._y * right._y + left._z * right._z + left._w * right._w;
|
|
4144
|
-
};
|
|
4145
|
-
/**
|
|
4146
|
-
* Determines the distance of two vectors.
|
|
4147
|
-
* @param a - The first vector
|
|
4148
|
-
* @param b - The second vector
|
|
4149
|
-
* @returns The distance of two vectors
|
|
4150
|
-
*/ Vector4.distance = function distance(a, b) {
|
|
4151
|
-
var x = b._x - a._x;
|
|
4152
|
-
var y = b._y - a._y;
|
|
4153
|
-
var z = b._z - a._z;
|
|
4154
|
-
var w = b._w - a._w;
|
|
4155
|
-
return Math.sqrt(x * x + y * y + z * z + w * w);
|
|
4156
|
-
};
|
|
4157
|
-
/**
|
|
4158
|
-
* Determines the squared distance of two vectors.
|
|
4159
|
-
* @param a - The first vector
|
|
4160
|
-
* @param b - The second vector
|
|
4161
|
-
* @returns The squared distance of two vectors
|
|
4162
|
-
*/ Vector4.distanceSquared = function distanceSquared(a, b) {
|
|
4163
|
-
var x = b._x - a._x;
|
|
4164
|
-
var y = b._y - a._y;
|
|
4165
|
-
var z = b._z - a._z;
|
|
4166
|
-
var w = b._w - a._w;
|
|
4167
|
-
return x * x + y * y + z * z + w * w;
|
|
4168
|
-
};
|
|
4169
|
-
/**
|
|
4170
|
-
* Determines whether the specified vectors are equals.
|
|
4171
|
-
* @param left - The first vector to compare
|
|
4172
|
-
* @param right - The second vector to compare
|
|
4173
|
-
* @returns True if the specified vectors are equals, false otherwise
|
|
4174
|
-
*/ Vector4.equals = function equals(left, right) {
|
|
4175
|
-
return MathUtil.equals(left._x, right._x) && MathUtil.equals(left._y, right._y) && MathUtil.equals(left._z, right._z) && MathUtil.equals(left._w, right._w);
|
|
4176
|
-
};
|
|
4177
|
-
/**
|
|
4178
|
-
* Performs a linear interpolation between two vectors.
|
|
4179
|
-
* @param start - The first vector
|
|
4180
|
-
* @param end - The second vector
|
|
4181
|
-
* @param t - The blend amount where 0 returns start and 1 end
|
|
4182
|
-
* @param out - The result of linear blending between two vectors
|
|
4183
|
-
*/ Vector4.lerp = function lerp(start, end, t, out) {
|
|
4184
|
-
var _x = start._x, _y = start._y, _z = start._z, _w = start._w;
|
|
4185
|
-
out._x = _x + (end._x - _x) * t;
|
|
4186
|
-
out._y = _y + (end._y - _y) * t;
|
|
4187
|
-
out._z = _z + (end._z - _z) * t;
|
|
4188
|
-
out._w = _w + (end._w - _w) * t;
|
|
4189
|
-
out._onValueChanged && out._onValueChanged();
|
|
4190
|
-
};
|
|
4191
|
-
/**
|
|
4192
|
-
* Calculate a vector containing the largest components of the specified vectors.
|
|
4193
|
-
* @param left - The first vector
|
|
4194
|
-
* @param right - The second vector
|
|
4195
|
-
* @param out - The vector containing the largest components of the specified vectors
|
|
4196
|
-
*/ Vector4.max = function max(left, right, out) {
|
|
4197
|
-
out._x = Math.max(left._x, right._x);
|
|
4198
|
-
out._y = Math.max(left._y, right._y);
|
|
4199
|
-
out._z = Math.max(left._z, right._z);
|
|
4200
|
-
out._w = Math.max(left._w, right._w);
|
|
4201
|
-
out._onValueChanged && out._onValueChanged();
|
|
4202
|
-
};
|
|
4203
|
-
/**
|
|
4204
|
-
* Calculate a vector containing the smallest components of the specified vectors.
|
|
4205
|
-
* @param left - The first vector
|
|
4206
|
-
* @param right - The second vector
|
|
4207
|
-
* @param out - The vector containing the smallest components of the specified vectors
|
|
4208
|
-
*/ Vector4.min = function min(left, right, out) {
|
|
4209
|
-
out._x = Math.min(left._x, right._x);
|
|
4210
|
-
out._y = Math.min(left._y, right._y);
|
|
4211
|
-
out._z = Math.min(left._z, right._z);
|
|
4212
|
-
out._w = Math.min(left._w, right._w);
|
|
4213
|
-
out._onValueChanged && out._onValueChanged();
|
|
4214
|
-
};
|
|
4215
|
-
/**
|
|
4216
|
-
* Reverses the direction of a given vector.
|
|
4217
|
-
* @param a - The vector to negate
|
|
4218
|
-
* @param out - The vector facing in the opposite direction
|
|
4219
|
-
*/ Vector4.negate = function negate(a, out) {
|
|
4220
|
-
out._x = -a._x;
|
|
4221
|
-
out._y = -a._y;
|
|
4222
|
-
out._z = -a._z;
|
|
4223
|
-
out._w = -a._w;
|
|
4224
|
-
out._onValueChanged && out._onValueChanged();
|
|
4225
|
-
};
|
|
4226
|
-
/**
|
|
4227
|
-
* Converts the vector into a unit vector.
|
|
4228
|
-
* @param a - The vector to normalize
|
|
4229
|
-
* @param out - The normalized vector
|
|
4230
|
-
*/ Vector4.normalize = function normalize(a, out) {
|
|
4231
|
-
var _x = a._x, _y = a._y, _z = a._z, _w = a._w;
|
|
4232
|
-
var len = Math.sqrt(_x * _x + _y * _y + _z * _z + _w * _w);
|
|
4233
|
-
if (len > MathUtil.zeroTolerance) {
|
|
4234
|
-
len = 1 / len;
|
|
4235
|
-
out._x = _x * len;
|
|
4236
|
-
out._y = _y * len;
|
|
4237
|
-
out._z = _z * len;
|
|
4238
|
-
out._w = _w * len;
|
|
4239
|
-
out._onValueChanged && out._onValueChanged();
|
|
4240
|
-
}
|
|
4241
|
-
};
|
|
4242
|
-
/**
|
|
4243
|
-
* Scale a vector by the given value.
|
|
4244
|
-
* @param a - The vector to scale
|
|
4245
|
-
* @param s - The amount by which to scale the vector
|
|
4246
|
-
* @param out - The scaled vector
|
|
4247
|
-
*/ Vector4.scale = function scale(a, s, out) {
|
|
4248
|
-
out._x = a._x * s;
|
|
4249
|
-
out._y = a._y * s;
|
|
4250
|
-
out._z = a._z * s;
|
|
4251
|
-
out._w = a._w * s;
|
|
4252
|
-
out._onValueChanged && out._onValueChanged();
|
|
4253
|
-
};
|
|
4254
|
-
/**
|
|
4255
|
-
* Performs a transformation using the given 4x4 matrix.
|
|
4256
|
-
* @param v - The vector to transform
|
|
4257
|
-
* @param m - The transform matrix
|
|
4258
|
-
* @param out - The transformed vector3
|
|
4259
|
-
*/ Vector4.transform = function transform(v, m, out) {
|
|
4260
|
-
var _x = v._x, _y = v._y, _z = v._z, _w = v._w;
|
|
4261
|
-
var e = m.elements;
|
|
4262
|
-
out._x = _x * e[0] + _y * e[4] + _z * e[8] + _w * e[12];
|
|
4263
|
-
out._y = _x * e[1] + _y * e[5] + _z * e[9] + _w * e[13];
|
|
4264
|
-
out._z = _x * e[2] + _y * e[6] + _z * e[10] + _w * e[14];
|
|
4265
|
-
out._w = _x * e[3] + _y * e[7] + _z * e[11] + _w * e[15];
|
|
4266
|
-
out._onValueChanged && out._onValueChanged();
|
|
4267
|
-
};
|
|
4268
|
-
/**
|
|
4269
|
-
* Performs a transformation using the given quaternion.
|
|
4270
|
-
* @param v - The vector to transform
|
|
4271
|
-
* @param q - The transform quaternion
|
|
4272
|
-
* @param out - The transformed vector
|
|
4273
|
-
*/ Vector4.transformByQuat = function transformByQuat(v, q, out) {
|
|
4274
|
-
var x = v._x, y = v._y, z = v._z, w = v._w;
|
|
4275
|
-
var qx = q._x;
|
|
4276
|
-
var qy = q._y;
|
|
4277
|
-
var qz = q._z;
|
|
4278
|
-
var qw = q._w;
|
|
4279
|
-
// calculate quat * vec
|
|
4280
|
-
var ix = qw * x + qy * z - qz * y;
|
|
4281
|
-
var iy = qw * y + qz * x - qx * z;
|
|
4282
|
-
var iz = qw * z + qx * y - qy * x;
|
|
4283
|
-
var iw = -qx * x - qy * y - qz * z;
|
|
4284
|
-
// calculate result * inverse quat
|
|
4285
|
-
out._x = ix * qw - iw * qx - iy * qz + iz * qy;
|
|
4286
|
-
out._y = iy * qw - iw * qy - iz * qx + ix * qz;
|
|
4287
|
-
out._z = iz * qw - iw * qz - ix * qy + iy * qx;
|
|
4288
|
-
out._w = w;
|
|
4289
|
-
out._onValueChanged && out._onValueChanged();
|
|
4290
|
-
};
|
|
4291
|
-
_create_class(Vector4, [
|
|
4292
|
-
{
|
|
4293
|
-
key: "x",
|
|
4294
|
-
get: /**
|
|
4295
|
-
* The x component of the vector.
|
|
4296
|
-
*/ function get() {
|
|
4297
|
-
return this._x;
|
|
4298
|
-
},
|
|
4299
|
-
set: function set(value) {
|
|
4300
|
-
this._x = value;
|
|
4301
|
-
this._onValueChanged && this._onValueChanged();
|
|
4302
|
-
}
|
|
4303
|
-
},
|
|
4304
|
-
{
|
|
4305
|
-
key: "y",
|
|
4306
|
-
get: /**
|
|
4307
|
-
* The y component of the vector.
|
|
4308
|
-
*/ function get() {
|
|
4309
|
-
return this._y;
|
|
4310
|
-
},
|
|
4311
|
-
set: function set(value) {
|
|
4312
|
-
this._y = value;
|
|
4313
|
-
this._onValueChanged && this._onValueChanged();
|
|
4314
|
-
}
|
|
4315
|
-
},
|
|
4316
|
-
{
|
|
4317
|
-
key: "z",
|
|
4318
|
-
get: /**
|
|
4319
|
-
* The z component of the vector.
|
|
4320
|
-
*/ function get() {
|
|
4321
|
-
return this._z;
|
|
4322
|
-
},
|
|
4323
|
-
set: function set(value) {
|
|
4324
|
-
this._z = value;
|
|
4325
|
-
this._onValueChanged && this._onValueChanged();
|
|
4326
|
-
}
|
|
4327
|
-
},
|
|
4328
|
-
{
|
|
4329
|
-
key: "w",
|
|
4330
|
-
get: /**
|
|
4331
|
-
* The w component of the vector.
|
|
4332
|
-
*/ function get() {
|
|
4333
|
-
return this._w;
|
|
4334
|
-
},
|
|
4335
|
-
set: function set(value) {
|
|
4336
|
-
this._w = value;
|
|
4337
|
-
this._onValueChanged && this._onValueChanged();
|
|
4338
|
-
}
|
|
4339
|
-
}
|
|
4340
|
-
]);
|
|
4341
|
-
return Vector4;
|
|
4342
|
-
}();
|
|
4343
|
-
(function() {
|
|
4344
|
-
/** @internal */ Vector4._zero = new Vector4(0.0, 0.0, 0.0, 0.0);
|
|
4345
|
-
})();
|
|
4346
|
-
(function() {
|
|
4347
|
-
/** @internal */ Vector4._one = new Vector4(1.0, 1.0, 1.0, 1.0);
|
|
4348
|
-
})();
|
|
4349
|
-
|
|
4350
|
-
var WebXRFrame = /*#__PURE__*/ function() {
|
|
4351
|
-
function WebXRFrame(session) {
|
|
4352
|
-
this._session = session;
|
|
4353
|
-
}
|
|
4354
|
-
var _proto = WebXRFrame.prototype;
|
|
4355
|
-
_proto.updateInputs = function updateInputs(inputs) {
|
|
4356
|
-
if (!this._platformFrame) return;
|
|
4357
|
-
this._updateController(inputs);
|
|
4358
|
-
this._updateCamera(inputs);
|
|
4359
|
-
};
|
|
4360
|
-
_proto._updateController = function _updateController(inputs) {
|
|
4361
|
-
var _this = this, frame = _this._platformFrame;
|
|
4362
|
-
var _this__session = this._session, session = _this__session._platformSession, referenceSpace = _this__session._platformReferenceSpace;
|
|
4363
|
-
var inputSources = session.inputSources;
|
|
4364
|
-
for(var i = 0, n = inputSources.length; i < n; i++){
|
|
4365
|
-
var inputSource = inputSources[i];
|
|
4366
|
-
var type = getInputSource(inputSource);
|
|
4367
|
-
var input = inputs[type];
|
|
4368
|
-
switch(inputSource.targetRayMode){
|
|
4369
|
-
case "screen":
|
|
4370
|
-
case "tracked-pointer":
|
|
4371
|
-
var gripSpace = inputSource.gripSpace, targetRaySpace = inputSource.targetRaySpace;
|
|
4372
|
-
if (gripSpace) {
|
|
4373
|
-
var _frame_getPose = frame.getPose(gripSpace, referenceSpace), transform = _frame_getPose.transform, emulatedPosition = _frame_getPose.emulatedPosition;
|
|
4374
|
-
if (transform) {
|
|
4375
|
-
var gripPose = input.gripPose;
|
|
4376
|
-
gripPose.matrix.copyFromArray(transform.matrix);
|
|
4377
|
-
gripPose.position.copyFrom(transform.position);
|
|
4378
|
-
gripPose.rotation.copyFrom(transform.orientation);
|
|
4379
|
-
}
|
|
4380
|
-
input.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4381
|
-
}
|
|
4382
|
-
if (targetRaySpace) {
|
|
4383
|
-
var _frame_getPose1 = frame.getPose(targetRaySpace, referenceSpace), transform1 = _frame_getPose1.transform, emulatedPosition1 = _frame_getPose1.emulatedPosition;
|
|
4384
|
-
if (transform1) {
|
|
4385
|
-
var targetRayPose = input.targetRayPose;
|
|
4386
|
-
targetRayPose.matrix.copyFromArray(transform1.matrix);
|
|
4387
|
-
targetRayPose.position.copyFrom(transform1.position);
|
|
4388
|
-
targetRayPose.rotation.copyFrom(transform1.orientation);
|
|
4389
|
-
input.trackingState = emulatedPosition1 ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4390
|
-
}
|
|
4391
|
-
}
|
|
4392
|
-
break;
|
|
4393
|
-
}
|
|
4394
|
-
}
|
|
4395
|
-
};
|
|
4396
|
-
_proto._updateCamera = function _updateCamera(inputs) {
|
|
4397
|
-
var _this = this, frame = _this._platformFrame;
|
|
4398
|
-
var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
|
|
4399
|
-
var viewerPose = frame.getViewerPose(referenceSpace);
|
|
4400
|
-
if (viewerPose) {
|
|
4401
|
-
var hadUpdateCenterViewer = false;
|
|
4402
|
-
var views = viewerPose.views, emulatedPosition = viewerPose.emulatedPosition;
|
|
4403
|
-
for(var i = 0, n = views.length; i < n; i++){
|
|
4404
|
-
var view = views[i];
|
|
4405
|
-
var type = viewToCamera(view.eye);
|
|
4406
|
-
var transform = views[i].transform;
|
|
4407
|
-
if (type === engineXr.XRTrackedInputDevice.Camera) {
|
|
4408
|
-
hadUpdateCenterViewer || (hadUpdateCenterViewer = true);
|
|
4409
|
-
}
|
|
4410
|
-
var xrCamera = inputs[type];
|
|
4411
|
-
var pose = xrCamera.pose;
|
|
4412
|
-
pose.matrix.copyFromArray(transform.matrix);
|
|
4413
|
-
pose.position.copyFrom(transform.position);
|
|
4414
|
-
pose.rotation.copyFrom(transform.orientation);
|
|
4415
|
-
xrCamera.projectionMatrix.copyFromArray(view.projectionMatrix);
|
|
4416
|
-
xrCamera.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4417
|
-
var xrViewport = layer.getViewport(view);
|
|
4418
|
-
var width = xrViewport.width / framebufferWidth;
|
|
4419
|
-
var height = xrViewport.height / framebufferHeight;
|
|
4420
|
-
var x = xrViewport.x / framebufferWidth;
|
|
4421
|
-
var y = 1 - xrViewport.y / framebufferHeight - height;
|
|
4422
|
-
xrCamera.viewport.set(x, y, width, height);
|
|
4423
|
-
}
|
|
4424
|
-
if (!hadUpdateCenterViewer) {
|
|
4425
|
-
var leftCameraDevice = inputs[engineXr.XRTrackedInputDevice.LeftCamera];
|
|
4426
|
-
var rightCameraDevice = inputs[engineXr.XRTrackedInputDevice.RightCamera];
|
|
4427
|
-
var cameraDevice = inputs[engineXr.XRTrackedInputDevice.Camera];
|
|
4428
|
-
var leftCameraPose = leftCameraDevice.pose;
|
|
4429
|
-
var rightCameraPose = rightCameraDevice.pose;
|
|
4430
|
-
var cameraPose = cameraDevice.pose;
|
|
4431
|
-
cameraPose.rotation.copyFrom(leftCameraPose.rotation);
|
|
4432
|
-
var position = cameraPose.position, matrix = cameraPose.matrix;
|
|
4433
|
-
Vector3.add(leftCameraPose.position, rightCameraPose.position, position);
|
|
4434
|
-
position.scale(0.5);
|
|
4435
|
-
matrix.copyFrom(leftCameraPose.matrix);
|
|
4436
|
-
var elements = matrix.elements;
|
|
4437
|
-
elements[12] = position.x;
|
|
4438
|
-
elements[13] = position.y;
|
|
4439
|
-
elements[14] = position.z;
|
|
4440
|
-
cameraDevice.projectionMatrix.copyFrom(leftCameraDevice.projectionMatrix);
|
|
4441
|
-
cameraDevice.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
4442
|
-
cameraDevice.viewport = leftCameraDevice.viewport.width && leftCameraDevice.viewport.height ? leftCameraDevice.viewport : rightCameraDevice.viewport;
|
|
4443
|
-
}
|
|
4444
|
-
}
|
|
2933
|
+
_proto._updateCamera = function _updateCamera(inputs) {
|
|
2934
|
+
var _this = this, frame = _this._platformFrame;
|
|
2935
|
+
var _this__session = this._session, referenceSpace = _this__session._platformReferenceSpace, layer = _this__session._platformLayer, framebufferWidth = _this__session.framebufferWidth, framebufferHeight = _this__session.framebufferHeight;
|
|
2936
|
+
var viewerPose = frame.getViewerPose(referenceSpace);
|
|
2937
|
+
if (viewerPose) {
|
|
2938
|
+
var hadUpdateCenterViewer = false;
|
|
2939
|
+
var views = viewerPose.views, emulatedPosition = viewerPose.emulatedPosition;
|
|
2940
|
+
for(var i = 0, n = views.length; i < n; i++){
|
|
2941
|
+
var view = views[i];
|
|
2942
|
+
var type = viewToCamera(view.eye);
|
|
2943
|
+
var transform = views[i].transform;
|
|
2944
|
+
if (type === engineXr.XRTrackedInputDevice.Camera) {
|
|
2945
|
+
hadUpdateCenterViewer || (hadUpdateCenterViewer = true);
|
|
2946
|
+
}
|
|
2947
|
+
var xrCamera = inputs[type];
|
|
2948
|
+
var pose = xrCamera.pose;
|
|
2949
|
+
pose.matrix.copyFromArray(transform.matrix);
|
|
2950
|
+
pose.position.copyFrom(transform.position);
|
|
2951
|
+
pose.rotation.copyFrom(transform.orientation);
|
|
2952
|
+
xrCamera.projectionMatrix.copyFromArray(view.projectionMatrix);
|
|
2953
|
+
xrCamera.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2954
|
+
var xrViewport = layer.getViewport(view);
|
|
2955
|
+
var width = xrViewport.width / framebufferWidth;
|
|
2956
|
+
var height = xrViewport.height / framebufferHeight;
|
|
2957
|
+
var x = xrViewport.x / framebufferWidth;
|
|
2958
|
+
var y = 1 - xrViewport.y / framebufferHeight - height;
|
|
2959
|
+
xrCamera.viewport.set(x, y, width, height);
|
|
2960
|
+
}
|
|
2961
|
+
if (!hadUpdateCenterViewer) {
|
|
2962
|
+
var leftCameraDevice = inputs[engineXr.XRTrackedInputDevice.LeftCamera];
|
|
2963
|
+
var rightCameraDevice = inputs[engineXr.XRTrackedInputDevice.RightCamera];
|
|
2964
|
+
var cameraDevice = inputs[engineXr.XRTrackedInputDevice.Camera];
|
|
2965
|
+
var leftCameraPose = leftCameraDevice.pose;
|
|
2966
|
+
var rightCameraPose = rightCameraDevice.pose;
|
|
2967
|
+
var cameraPose = cameraDevice.pose;
|
|
2968
|
+
cameraPose.rotation.copyFrom(leftCameraPose.rotation);
|
|
2969
|
+
var position = cameraPose.position, matrix = cameraPose.matrix;
|
|
2970
|
+
Vector3.add(leftCameraPose.position, rightCameraPose.position, position);
|
|
2971
|
+
position.scale(0.5);
|
|
2972
|
+
matrix.copyFrom(leftCameraPose.matrix);
|
|
2973
|
+
var elements = matrix.elements;
|
|
2974
|
+
elements[12] = position.x;
|
|
2975
|
+
elements[13] = position.y;
|
|
2976
|
+
elements[14] = position.z;
|
|
2977
|
+
cameraDevice.projectionMatrix.copyFrom(leftCameraDevice.projectionMatrix);
|
|
2978
|
+
cameraDevice.trackingState = emulatedPosition ? engineXr.XRTrackingState.TrackingLost : engineXr.XRTrackingState.Tracking;
|
|
2979
|
+
cameraDevice.viewport = leftCameraDevice.viewport.width && leftCameraDevice.viewport.height ? leftCameraDevice.viewport : rightCameraDevice.viewport;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
4445
2982
|
};
|
|
4446
2983
|
return WebXRFrame;
|
|
4447
2984
|
}();
|
|
@@ -4731,9 +3268,7 @@ var WebXRDevice = /*#__PURE__*/ function() {
|
|
|
4731
3268
|
};
|
|
4732
3269
|
return WebXRDevice;
|
|
4733
3270
|
}();
|
|
4734
|
-
|
|
4735
|
-
/** @internal */ WebXRDevice._platformFeatureMap = [];
|
|
4736
|
-
})();
|
|
3271
|
+
/** @internal */ WebXRDevice._platformFeatureMap = [];
|
|
4737
3272
|
function registerXRPlatformFeature(type) {
|
|
4738
3273
|
return function(platformFeatureConstructor) {
|
|
4739
3274
|
WebXRDevice._platformFeatureMap[type] = platformFeatureConstructor;
|
|
@@ -4747,10 +3282,10 @@ function registerXRPlatformFeature(type) {
|
|
|
4747
3282
|
|
|
4748
3283
|
/**
|
|
4749
3284
|
* @internal
|
|
4750
|
-
*/ var WebXRTrackableFeature = /*#__PURE__*/ function(
|
|
4751
|
-
_inherits(WebXRTrackableFeature,
|
|
3285
|
+
*/ var WebXRTrackableFeature = /*#__PURE__*/ function(WebXRFeature) {
|
|
3286
|
+
_inherits(WebXRTrackableFeature, WebXRFeature);
|
|
4752
3287
|
function WebXRTrackableFeature() {
|
|
4753
|
-
return
|
|
3288
|
+
return WebXRFeature.apply(this, arguments) || this;
|
|
4754
3289
|
}
|
|
4755
3290
|
var _proto = WebXRTrackableFeature.prototype;
|
|
4756
3291
|
_proto.onAddRequestTracking = function onAddRequestTracking(requestTracking) {};
|
|
@@ -4768,10 +3303,10 @@ function registerXRPlatformFeature(type) {
|
|
|
4768
3303
|
return WebXRTrackableFeature;
|
|
4769
3304
|
}(WebXRFeature);
|
|
4770
3305
|
|
|
4771
|
-
var WebXRAnchorTracking = /*#__PURE__*/ function(
|
|
4772
|
-
_inherits(WebXRAnchorTracking,
|
|
3306
|
+
var WebXRAnchorTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
|
|
3307
|
+
_inherits(WebXRAnchorTracking, WebXRTrackableFeature);
|
|
4773
3308
|
function WebXRAnchorTracking() {
|
|
4774
|
-
return
|
|
3309
|
+
return WebXRTrackableFeature.apply(this, arguments) || this;
|
|
4775
3310
|
}
|
|
4776
3311
|
var _proto = WebXRAnchorTracking.prototype;
|
|
4777
3312
|
_proto.checkAvailable = function checkAvailable(session, frame, requestTrackings) {
|
|
@@ -4882,14 +3417,11 @@ WebXRAnchorTracking = __decorate([
|
|
|
4882
3417
|
registerXRPlatformFeature(engineXr.XRFeatureType.AnchorTracking)
|
|
4883
3418
|
], WebXRAnchorTracking);
|
|
4884
3419
|
|
|
4885
|
-
var WebXRImageTracking = /*#__PURE__*/ function(
|
|
4886
|
-
_inherits(WebXRImageTracking,
|
|
3420
|
+
var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
|
|
3421
|
+
_inherits(WebXRImageTracking, WebXRTrackableFeature);
|
|
4887
3422
|
function WebXRImageTracking(images) {
|
|
4888
3423
|
var _this;
|
|
4889
|
-
_this =
|
|
4890
|
-
_this._trackingScoreStatus = 0;
|
|
4891
|
-
_this._tempIdx = 0;
|
|
4892
|
-
_this._tempArr = [];
|
|
3424
|
+
_this = WebXRTrackableFeature.call(this) || this, _this._trackingScoreStatus = 0, _this._tempIdx = 0, _this._tempArr = [];
|
|
4893
3425
|
_this._images = images;
|
|
4894
3426
|
return _this;
|
|
4895
3427
|
}
|
|
@@ -5006,17 +3538,12 @@ var WebXRImageTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
|
|
|
5006
3538
|
WebXRImageTracking = __decorate([
|
|
5007
3539
|
registerXRPlatformFeature(engineXr.XRFeatureType.ImageTracking)
|
|
5008
3540
|
], WebXRImageTracking);
|
|
5009
|
-
var ImageTrackingScoreStatus;
|
|
5010
|
-
(function(ImageTrackingScoreStatus) {
|
|
5011
|
-
ImageTrackingScoreStatus[ImageTrackingScoreStatus["NotReceived"] = 0] = "NotReceived";
|
|
5012
|
-
ImageTrackingScoreStatus[ImageTrackingScoreStatus["Waiting"] = 1] = "Waiting";
|
|
5013
|
-
ImageTrackingScoreStatus[ImageTrackingScoreStatus["Received"] = 2] = "Received";
|
|
5014
|
-
})(ImageTrackingScoreStatus || (ImageTrackingScoreStatus = {}));
|
|
5015
3541
|
|
|
5016
|
-
var WebXRPlaneTracking = /*#__PURE__*/ function(
|
|
5017
|
-
_inherits(WebXRPlaneTracking,
|
|
3542
|
+
var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature) {
|
|
3543
|
+
_inherits(WebXRPlaneTracking, WebXRTrackableFeature);
|
|
5018
3544
|
function WebXRPlaneTracking(detectedMode) {
|
|
5019
|
-
var _this
|
|
3545
|
+
var _this;
|
|
3546
|
+
_this = WebXRTrackableFeature.call(this) || this;
|
|
5020
3547
|
if (detectedMode !== engineXr.XRPlaneMode.EveryThing) {
|
|
5021
3548
|
console.warn("WebXR only support XRPlaneMode.EveryThing");
|
|
5022
3549
|
}
|
|
@@ -5045,8 +3572,7 @@ var WebXRPlaneTracking = /*#__PURE__*/ function(WebXRTrackableFeature1) {
|
|
|
5045
3572
|
}
|
|
5046
3573
|
var _this1 = this, lastDetectedPlanes = _this1._lastDetectedPlanes;
|
|
5047
3574
|
detectedPlanes.forEach(function(xrPlane) {
|
|
5048
|
-
|
|
5049
|
-
if (!((_lastDetectedPlanes = lastDetectedPlanes) == null ? void 0 : _lastDetectedPlanes.has(xrPlane))) {
|
|
3575
|
+
if (!(lastDetectedPlanes == null ? void 0 : lastDetectedPlanes.has(xrPlane))) {
|
|
5050
3576
|
var plane = generateTracked();
|
|
5051
3577
|
plane.xrPlane = xrPlane;
|
|
5052
3578
|
plane.lastChangedTime = -1;
|