@math.gl/core 3.6.0-alpha.1 → 3.6.0-alpha.2
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/classes/base/math-array.d.ts +61 -31
- package/dist/classes/base/math-array.d.ts.map +1 -1
- package/dist/classes/base/math-array.js +67 -65
- package/dist/classes/base/matrix.d.ts +12 -10
- package/dist/classes/base/matrix.d.ts.map +1 -1
- package/dist/classes/base/matrix.js +2 -10
- package/dist/classes/base/vector.d.ts +37 -25
- package/dist/classes/base/vector.d.ts.map +1 -1
- package/dist/classes/base/vector.js +17 -24
- package/dist/classes/euler.d.ts +59 -55
- package/dist/classes/euler.d.ts.map +1 -1
- package/dist/classes/euler.js +57 -77
- package/dist/classes/matrix3.d.ts +58 -41
- package/dist/classes/matrix3.d.ts.map +1 -1
- package/dist/classes/matrix3.js +68 -59
- package/dist/classes/matrix4.d.ts +214 -90
- package/dist/classes/matrix4.d.ts.map +1 -1
- package/dist/classes/matrix4.js +252 -171
- package/dist/classes/pose.d.ts +29 -26
- package/dist/classes/pose.d.ts.map +1 -1
- package/dist/classes/pose.js +6 -23
- package/dist/classes/quaternion.d.ts +61 -40
- package/dist/classes/quaternion.d.ts.map +1 -1
- package/dist/classes/quaternion.js +49 -53
- package/dist/classes/spherical-coordinates.d.ts +45 -25
- package/dist/classes/spherical-coordinates.d.ts.map +1 -1
- package/dist/classes/spherical-coordinates.js +30 -24
- package/dist/classes/vector2.d.ts +51 -15
- package/dist/classes/vector2.d.ts.map +1 -1
- package/dist/classes/vector2.js +29 -23
- package/dist/classes/vector3.d.ts +47 -32
- package/dist/classes/vector3.d.ts.map +1 -1
- package/dist/classes/vector3.js +16 -30
- package/dist/classes/vector4.d.ts +37 -19
- package/dist/classes/vector4.d.ts.map +1 -1
- package/dist/classes/vector4.js +12 -24
- package/dist/es5/classes/base/math-array.js +248 -179
- package/dist/es5/classes/base/math-array.js.map +1 -1
- package/dist/es5/classes/base/matrix.js +74 -54
- package/dist/es5/classes/base/matrix.js.map +1 -1
- package/dist/es5/classes/base/vector.js +167 -121
- package/dist/es5/classes/base/vector.js.map +1 -1
- package/dist/es5/classes/euler.js +575 -480
- package/dist/es5/classes/euler.js.map +1 -1
- package/dist/es5/classes/matrix3.js +234 -158
- package/dist/es5/classes/matrix3.js.map +1 -1
- package/dist/es5/classes/matrix4.js +510 -417
- package/dist/es5/classes/matrix4.js.map +1 -1
- package/dist/es5/classes/pose.js +126 -101
- package/dist/es5/classes/pose.js.map +1 -1
- package/dist/es5/classes/quaternion.js +285 -213
- package/dist/es5/classes/quaternion.js.map +1 -1
- package/dist/es5/classes/spherical-coordinates.js +170 -125
- package/dist/es5/classes/spherical-coordinates.js.map +1 -1
- package/dist/es5/classes/vector2.js +118 -76
- package/dist/es5/classes/vector2.js.map +1 -1
- package/dist/es5/classes/vector3.js +171 -119
- package/dist/es5/classes/vector3.js.map +1 -1
- package/dist/es5/classes/vector4.js +141 -94
- package/dist/es5/classes/vector4.js.map +1 -1
- package/dist/es5/index.js +34 -34
- package/dist/es5/lib/common.js +56 -30
- package/dist/es5/lib/common.js.map +1 -1
- package/dist/es5/lib/gl-matrix-extras.js +14 -14
- package/dist/es5/lib/gl-matrix-extras.js.map +1 -1
- package/dist/es5/lib/gl-matrix.d.js +2 -0
- package/dist/es5/lib/gl-matrix.d.js.map +1 -0
- package/dist/es5/lib/validators.js +5 -3
- package/dist/es5/lib/validators.js.map +1 -1
- package/dist/esm/classes/base/math-array.js +45 -47
- package/dist/esm/classes/base/math-array.js.map +1 -1
- package/dist/esm/classes/base/matrix.js +0 -11
- package/dist/esm/classes/base/matrix.js.map +1 -1
- package/dist/esm/classes/base/vector.js +0 -10
- package/dist/esm/classes/base/vector.js.map +1 -1
- package/dist/esm/classes/euler.js +61 -48
- package/dist/esm/classes/euler.js.map +1 -1
- package/dist/esm/classes/matrix3.js +55 -33
- package/dist/esm/classes/matrix3.js.map +1 -1
- package/dist/esm/classes/matrix4.js +156 -136
- package/dist/esm/classes/matrix4.js.map +1 -1
- package/dist/esm/classes/pose.js +8 -4
- package/dist/esm/classes/pose.js.map +1 -1
- package/dist/esm/classes/quaternion.js +37 -27
- package/dist/esm/classes/quaternion.js.map +1 -1
- package/dist/esm/classes/spherical-coordinates.js +15 -5
- package/dist/esm/classes/spherical-coordinates.js.map +1 -1
- package/dist/esm/classes/vector2.js.map +1 -1
- package/dist/esm/classes/vector3.js +7 -2
- package/dist/esm/classes/vector3.js.map +1 -1
- package/dist/esm/classes/vector4.js +7 -2
- package/dist/esm/classes/vector4.js.map +1 -1
- package/dist/esm/lib/common.js +8 -8
- package/dist/esm/lib/common.js.map +1 -1
- package/dist/esm/lib/gl-matrix-extras.js.map +1 -1
- package/dist/esm/lib/gl-matrix.d.js +2 -0
- package/dist/esm/lib/gl-matrix.d.js.map +1 -0
- package/dist/esm/lib/validators.js.map +1 -1
- package/dist/lib/common.d.ts +14 -11
- package/dist/lib/common.d.ts.map +1 -1
- package/dist/lib/common.js +10 -23
- package/dist/lib/gl-matrix-extras.d.ts +6 -5
- package/dist/lib/gl-matrix-extras.d.ts.map +1 -1
- package/dist/lib/gl-matrix-extras.js +0 -1
- package/dist/lib/validators.d.ts +5 -4
- package/dist/lib/validators.d.ts.map +1 -1
- package/dist/lib/validators.js +0 -19
- package/package.json +4 -4
- package/src/classes/base/math-array.ts +265 -0
- package/src/classes/base/{matrix.js → matrix.ts} +15 -19
- package/src/classes/base/{vector.js → vector.ts} +47 -54
- package/src/classes/{euler.js → euler.ts} +121 -221
- package/src/classes/matrix3.ts +253 -0
- package/src/classes/matrix4.ts +668 -0
- package/src/classes/{pose.js → pose.ts} +52 -49
- package/src/classes/{quaternion.js → quaternion.ts} +107 -95
- package/src/classes/{spherical-coordinates.js → spherical-coordinates.ts} +84 -54
- package/src/classes/vector2.ts +127 -0
- package/src/classes/{vector3.js → vector3.ts} +43 -55
- package/src/classes/{vector4.js → vector4.ts} +44 -48
- package/src/lib/common.ts +58 -37
- package/src/lib/gl-matrix-extras.ts +26 -5
- package/src/lib/gl-matrix.d.ts +266 -0
- package/src/lib/validators.ts +10 -6
- package/dist/es5/classes/base/math-array.d.js +0 -46
- package/dist/es5/classes/base/math-array.d.js.map +0 -1
- package/dist/es5/classes/base/matrix.d.js +0 -15
- package/dist/es5/classes/base/matrix.d.js.map +0 -1
- package/dist/es5/classes/base/vector.d.js +0 -24
- package/dist/es5/classes/base/vector.d.js.map +0 -1
- package/dist/es5/classes/euler.d.js +0 -45
- package/dist/es5/classes/euler.d.js.map +0 -1
- package/dist/es5/classes/matrix3.d.js +0 -25
- package/dist/es5/classes/matrix3.d.js.map +0 -1
- package/dist/es5/classes/matrix4.d.js +0 -25
- package/dist/es5/classes/matrix4.d.js.map +0 -1
- package/dist/es5/classes/pose.d.js +0 -25
- package/dist/es5/classes/pose.d.js.map +0 -1
- package/dist/es5/classes/quaternion.d.js +0 -27
- package/dist/es5/classes/quaternion.d.js.map +0 -1
- package/dist/es5/classes/spherical-coordinates.d.js +0 -27
- package/dist/es5/classes/spherical-coordinates.d.js.map +0 -1
- package/dist/es5/classes/vector2.d.js +0 -18
- package/dist/es5/classes/vector2.d.js.map +0 -1
- package/dist/es5/classes/vector3.d.js +0 -24
- package/dist/es5/classes/vector3.d.js.map +0 -1
- package/dist/es5/classes/vector4.d.js +0 -25
- package/dist/es5/classes/vector4.d.js.map +0 -1
- package/dist/esm/classes/base/math-array.d.js +0 -36
- package/dist/esm/classes/base/math-array.d.js.map +0 -1
- package/dist/esm/classes/base/matrix.d.js +0 -3
- package/dist/esm/classes/base/matrix.d.js.map +0 -1
- package/dist/esm/classes/base/vector.d.js +0 -13
- package/dist/esm/classes/base/vector.d.js.map +0 -1
- package/dist/esm/classes/euler.d.js +0 -55
- package/dist/esm/classes/euler.d.js.map +0 -1
- package/dist/esm/classes/matrix3.d.js +0 -15
- package/dist/esm/classes/matrix3.d.js.map +0 -1
- package/dist/esm/classes/matrix4.d.js +0 -15
- package/dist/esm/classes/matrix4.d.js.map +0 -1
- package/dist/esm/classes/pose.d.js +0 -18
- package/dist/esm/classes/pose.d.js.map +0 -1
- package/dist/esm/classes/quaternion.d.js +0 -19
- package/dist/esm/classes/quaternion.d.js.map +0 -1
- package/dist/esm/classes/spherical-coordinates.d.js +0 -22
- package/dist/esm/classes/spherical-coordinates.d.js.map +0 -1
- package/dist/esm/classes/vector2.d.js +0 -6
- package/dist/esm/classes/vector2.d.js.map +0 -1
- package/dist/esm/classes/vector3.d.js +0 -13
- package/dist/esm/classes/vector3.d.js.map +0 -1
- package/dist/esm/classes/vector4.d.js +0 -15
- package/dist/esm/classes/vector4.d.js.map +0 -1
- package/src/classes/base/math-array.d.ts +0 -55
- package/src/classes/base/math-array.js +0 -250
- package/src/classes/base/matrix.d.ts +0 -15
- package/src/classes/base/vector.d.ts +0 -45
- package/src/classes/euler.d.ts +0 -92
- package/src/classes/matrix3.d.ts +0 -91
- package/src/classes/matrix3.js +0 -225
- package/src/classes/matrix4.d.ts +0 -161
- package/src/classes/matrix4.js +0 -530
- package/src/classes/pose.d.ts +0 -92
- package/src/classes/quaternion.d.ts +0 -107
- package/src/classes/spherical-coordinates.d.ts +0 -87
- package/src/classes/vector2.d.ts +0 -65
- package/src/classes/vector2.js +0 -122
- package/src/classes/vector3.d.ts +0 -65
- package/src/classes/vector4.d.ts +0 -34
|
@@ -2,34 +2,54 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.default = void 0;
|
|
9
11
|
|
|
10
|
-
var
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
13
|
|
|
12
|
-
var
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
var _vector = _interopRequireDefault(require("./vector3"));
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
var _common = require("../lib/common");
|
|
23
|
+
|
|
24
|
+
var vec3 = _interopRequireWildcard(require("gl-matrix/vec3"));
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
var EPSILON = 0.000001;
|
|
31
|
+
var EARTH_RADIUS_METERS = 6371000;
|
|
32
|
+
|
|
33
|
+
var SphericalCoordinates = function () {
|
|
34
|
+
function SphericalCoordinates() {
|
|
35
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
36
|
+
_ref$phi = _ref.phi,
|
|
37
|
+
phi = _ref$phi === void 0 ? 0 : _ref$phi,
|
|
38
|
+
_ref$theta = _ref.theta,
|
|
39
|
+
theta = _ref$theta === void 0 ? 0 : _ref$theta,
|
|
40
|
+
_ref$radius = _ref.radius,
|
|
41
|
+
radius = _ref$radius === void 0 ? 1 : _ref$radius,
|
|
42
|
+
bearing = _ref.bearing,
|
|
43
|
+
pitch = _ref.pitch,
|
|
44
|
+
altitude = _ref.altitude,
|
|
45
|
+
_ref$radiusScale = _ref.radiusScale,
|
|
46
|
+
radiusScale = _ref$radiusScale === void 0 ? EARTH_RADIUS_METERS : _ref$radiusScale;
|
|
47
|
+
|
|
48
|
+
(0, _classCallCheck2.default)(this, SphericalCoordinates);
|
|
49
|
+
(0, _defineProperty2.default)(this, "phi", void 0);
|
|
50
|
+
(0, _defineProperty2.default)(this, "theta", void 0);
|
|
51
|
+
(0, _defineProperty2.default)(this, "radius", void 0);
|
|
52
|
+
(0, _defineProperty2.default)(this, "radiusScale", void 0);
|
|
33
53
|
this.phi = phi;
|
|
34
54
|
this.theta = theta;
|
|
35
55
|
this.radius = radius || altitude || 1;
|
|
@@ -46,118 +66,143 @@ class SphericalCoordinates {
|
|
|
46
66
|
this.check();
|
|
47
67
|
}
|
|
48
68
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
formatString({
|
|
54
|
-
printTypes = false
|
|
55
|
-
}) {
|
|
56
|
-
const f = _common.formatValue;
|
|
57
|
-
return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
equals(other) {
|
|
61
|
-
return (0, _common.equals)(this.radius, other.radius) && (0, _common.equals)(this.theta, other.theta) && (0, _common.equals)(this.phi, other.phi);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exactEquals(other) {
|
|
65
|
-
return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
get bearing() {
|
|
69
|
-
return 180 - (0, _common.degrees)(this.phi);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
set bearing(v) {
|
|
73
|
-
this.phi = Math.PI - (0, _common.radians)(v);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
get pitch() {
|
|
77
|
-
return (0, _common.degrees)(this.theta);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set pitch(v) {
|
|
81
|
-
this.theta = (0, _common.radians)(v);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get longitude() {
|
|
85
|
-
return (0, _common.degrees)(this.phi);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
get latitude() {
|
|
89
|
-
return (0, _common.degrees)(this.theta);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
get lng() {
|
|
93
|
-
return (0, _common.degrees)(this.phi);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
get lat() {
|
|
97
|
-
return (0, _common.degrees)(this.theta);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
get z() {
|
|
101
|
-
return (this.radius - 1) * this.radiusScale;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
set(radius, phi, theta) {
|
|
105
|
-
this.radius = radius;
|
|
106
|
-
this.phi = phi;
|
|
107
|
-
this.theta = theta;
|
|
108
|
-
return this.check();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
clone() {
|
|
112
|
-
return new SphericalCoordinates().copy(this);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
copy(other) {
|
|
116
|
-
this.radius = other.radius;
|
|
117
|
-
this.phi = other.phi;
|
|
118
|
-
this.theta = other.theta;
|
|
119
|
-
return this.check();
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
fromLngLatZ([lng, lat, z]) {
|
|
123
|
-
this.radius = 1 + z / this.radiusScale;
|
|
124
|
-
this.phi = (0, _common.radians)(lat);
|
|
125
|
-
this.theta = (0, _common.radians)(lng);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
fromVector3(v) {
|
|
129
|
-
this.radius = vec3.length(v);
|
|
130
|
-
|
|
131
|
-
if (this.radius > 0) {
|
|
132
|
-
this.theta = Math.atan2(v[0], v[1]);
|
|
133
|
-
this.phi = Math.acos((0, _common.clamp)(v[2] / this.radius, -1, 1));
|
|
69
|
+
(0, _createClass2.default)(SphericalCoordinates, [{
|
|
70
|
+
key: "toString",
|
|
71
|
+
value: function toString() {
|
|
72
|
+
return this.formatString(_common.config);
|
|
134
73
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
makeSafe() {
|
|
148
|
-
this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
|
|
149
|
-
return this;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
check() {
|
|
153
|
-
if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
|
|
154
|
-
throw new Error('SphericalCoordinates: some fields set to invalid numbers');
|
|
74
|
+
}, {
|
|
75
|
+
key: "formatString",
|
|
76
|
+
value: function formatString(_ref2) {
|
|
77
|
+
var _ref2$printTypes = _ref2.printTypes,
|
|
78
|
+
printTypes = _ref2$printTypes === void 0 ? false : _ref2$printTypes;
|
|
79
|
+
var f = _common.formatValue;
|
|
80
|
+
return "".concat(printTypes ? 'Spherical' : '', "[rho:").concat(f(this.radius), ",theta:").concat(f(this.theta), ",phi:").concat(f(this.phi), "]");
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "equals",
|
|
84
|
+
value: function equals(other) {
|
|
85
|
+
return (0, _common.equals)(this.radius, other.radius) && (0, _common.equals)(this.theta, other.theta) && (0, _common.equals)(this.phi, other.phi);
|
|
155
86
|
}
|
|
87
|
+
}, {
|
|
88
|
+
key: "exactEquals",
|
|
89
|
+
value: function exactEquals(other) {
|
|
90
|
+
return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "bearing",
|
|
94
|
+
get: function get() {
|
|
95
|
+
return 180 - (0, _common.degrees)(this.phi);
|
|
96
|
+
},
|
|
97
|
+
set: function set(v) {
|
|
98
|
+
this.phi = Math.PI - (0, _common.radians)(v);
|
|
99
|
+
}
|
|
100
|
+
}, {
|
|
101
|
+
key: "pitch",
|
|
102
|
+
get: function get() {
|
|
103
|
+
return (0, _common.degrees)(this.theta);
|
|
104
|
+
},
|
|
105
|
+
set: function set(v) {
|
|
106
|
+
this.theta = (0, _common.radians)(v);
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "longitude",
|
|
110
|
+
get: function get() {
|
|
111
|
+
return (0, _common.degrees)(this.phi);
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "latitude",
|
|
115
|
+
get: function get() {
|
|
116
|
+
return (0, _common.degrees)(this.theta);
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
key: "lng",
|
|
120
|
+
get: function get() {
|
|
121
|
+
return (0, _common.degrees)(this.phi);
|
|
122
|
+
}
|
|
123
|
+
}, {
|
|
124
|
+
key: "lat",
|
|
125
|
+
get: function get() {
|
|
126
|
+
return (0, _common.degrees)(this.theta);
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "z",
|
|
130
|
+
get: function get() {
|
|
131
|
+
return (this.radius - 1) * this.radiusScale;
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "set",
|
|
135
|
+
value: function set(radius, phi, theta) {
|
|
136
|
+
this.radius = radius;
|
|
137
|
+
this.phi = phi;
|
|
138
|
+
this.theta = theta;
|
|
139
|
+
return this.check();
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "clone",
|
|
143
|
+
value: function clone() {
|
|
144
|
+
return new SphericalCoordinates().copy(this);
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "copy",
|
|
148
|
+
value: function copy(other) {
|
|
149
|
+
this.radius = other.radius;
|
|
150
|
+
this.phi = other.phi;
|
|
151
|
+
this.theta = other.theta;
|
|
152
|
+
return this.check();
|
|
153
|
+
}
|
|
154
|
+
}, {
|
|
155
|
+
key: "fromLngLatZ",
|
|
156
|
+
value: function fromLngLatZ(_ref3) {
|
|
157
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 3),
|
|
158
|
+
lng = _ref4[0],
|
|
159
|
+
lat = _ref4[1],
|
|
160
|
+
z = _ref4[2];
|
|
161
|
+
|
|
162
|
+
this.radius = 1 + z / this.radiusScale;
|
|
163
|
+
this.phi = (0, _common.radians)(lat);
|
|
164
|
+
this.theta = (0, _common.radians)(lng);
|
|
165
|
+
return this.check();
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "fromVector3",
|
|
169
|
+
value: function fromVector3(v) {
|
|
170
|
+
this.radius = vec3.length(v);
|
|
156
171
|
|
|
157
|
-
|
|
158
|
-
|
|
172
|
+
if (this.radius > 0) {
|
|
173
|
+
this.theta = Math.atan2(v[0], v[1]);
|
|
174
|
+
this.phi = Math.acos((0, _common.clamp)(v[2] / this.radius, -1, 1));
|
|
175
|
+
}
|
|
159
176
|
|
|
160
|
-
|
|
177
|
+
return this.check();
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
key: "toVector3",
|
|
181
|
+
value: function toVector3() {
|
|
182
|
+
return new _vector.default(0, 0, this.radius).rotateX({
|
|
183
|
+
radians: this.theta
|
|
184
|
+
}).rotateZ({
|
|
185
|
+
radians: this.phi
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "makeSafe",
|
|
190
|
+
value: function makeSafe() {
|
|
191
|
+
this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
key: "check",
|
|
196
|
+
value: function check() {
|
|
197
|
+
if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {
|
|
198
|
+
throw new Error('SphericalCoordinates: some fields set to invalid numbers');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
}]);
|
|
204
|
+
return SphericalCoordinates;
|
|
205
|
+
}();
|
|
161
206
|
|
|
162
207
|
exports.default = SphericalCoordinates;
|
|
163
208
|
//# sourceMappingURL=spherical-coordinates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/spherical-coordinates.
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/spherical-coordinates.ts"],"names":["EPSILON","EARTH_RADIUS_METERS","SphericalCoordinates","phi","theta","radius","bearing","pitch","altitude","radiusScale","undefined","check","formatString","config","printTypes","f","formatValue","other","v","Math","PI","copy","lng","lat","z","vec3","length","atan2","acos","Vector3","rotateX","radians","rotateZ","max","min","Number","isFinite","Error"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAEA;;;;;;AAkBA,IAAMA,OAAO,GAAG,QAAhB;AACA,IAAMC,mBAAmB,GAAG,OAA5B;;IAOqBC,oB;AA4BnB,kCAQqC;AAAA,mFAAJ,EAAI;AAAA,wBAPnCC,GAOmC;AAAA,QAPnCA,GAOmC,yBAP7B,CAO6B;AAAA,0BANnCC,KAMmC;AAAA,QANnCA,KAMmC,2BAN3B,CAM2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D,IAA8B,CAACgC,MAAM,CAACC,QAAP,CAAgB,KAAKhC,KAArB,CAA/B,IAA8D,EAAE,KAAKC,MAAL,GAAc,CAAhB,CAAlE,EAAsF;AACpF,cAAM,IAAIgC,KAAJ,CAAU,0DAAV,CAAN;AACD;;AACD,aAAO,IAAP;AACD","sourcesContent":["// Copyright (c) 2017 Uber Technologies, Inc.\n// MIT License\n// Adaptation of THREE.js Spherical class, under MIT license\nimport Vector3 from './vector3';\nimport {formatValue, equals, config} from '../lib/common';\nimport {degrees, radians, clamp} from '../lib/common';\nimport * as vec3 from 'gl-matrix/vec3';\nimport {NumericArray} from '@math.gl/types';\n\ntype SphericalCoordinatesOptions = {\n phi?: number;\n theta?: number;\n radius?: number;\n bearing?: number;\n pitch?: number;\n altitude?: number;\n radiusScale?: number;\n};\n\ntype FormatOptions = {\n printTypes?: boolean;\n};\n\n// TODO - import epsilon\nconst EPSILON = 0.000001;\nconst EARTH_RADIUS_METERS = 6371000;\n\n/**\n * The poles (phi) are at the positive and negative y axis.\n * The equator starts at positive z.\n * @link https://en.wikipedia.org/wiki/Spherical_coordinate_system\n */\nexport default class SphericalCoordinates {\n phi: number;\n theta: number;\n radius: number;\n radiusScale: number;\n // bearing: number;\n // pitch: number;\n // altitude: number;\n\n // lnglatZ coordinates\n // longitude: number;\n // latitude: number;\n // lng: number;\n // lat: number;\n // z: number;\n\n /**\n * Creates a new SphericalCoordinates object\n * @param options\n * @param [options.phi] =0 - rotation around X (latitude)\n * @param [options.theta] =0 - rotation around Y (longitude)\n * @param [options.radius] =1 - Distance from center\n * @param [options.bearing]\n * @param [options.pitch]\n * @param [options.altitude]\n * @param [options.radiusScale] =1\n */\n // eslint-disable-next-line complexity\n constructor({\n phi = 0,\n theta = 0,\n radius = 1,\n bearing,\n pitch,\n altitude,\n radiusScale = EARTH_RADIUS_METERS\n }: SphericalCoordinatesOptions = {}) {\n this.phi = phi;\n this.theta = theta;\n // TODO - silently accepts illegal 0\n this.radius = radius || altitude || 1; // radial distance from center\n this.radiusScale = radiusScale || 1; // Used by lngLatZ\n if (bearing !== undefined) {\n this.bearing = bearing; // up / down towards top and bottom pole\n }\n if (pitch !== undefined) {\n this.pitch = pitch; // around the equator of the sphere\n }\n this.check();\n }\n\n toString(): string {\n return this.formatString(config);\n }\n\n formatString({printTypes = false}: FormatOptions): string {\n const f = formatValue;\n return `${printTypes ? 'Spherical' : ''}\\\n[rho:${f(this.radius)},theta:${f(this.theta)},phi:${f(this.phi)}]`;\n }\n\n equals(other: SphericalCoordinates): boolean {\n return (\n equals(this.radius, other.radius) &&\n equals(this.theta, other.theta) &&\n equals(this.phi, other.phi)\n );\n }\n\n exactEquals(other: SphericalCoordinates): boolean {\n return this.radius === other.radius && this.theta === other.theta && this.phi === other.phi;\n }\n\n /* eslint-disable brace-style */\n // Cartographic (bearing 0 north, pitch 0 look from above)\n get bearing(): number {\n return 180 - degrees(this.phi);\n }\n\n set bearing(v: number) {\n this.phi = Math.PI - radians(v);\n }\n\n get pitch(): number {\n return degrees(this.theta);\n }\n\n set pitch(v: number) {\n this.theta = radians(v);\n }\n\n // get pitch() { return 90 - degrees(this.phi); }\n // set pitch(v) { this.phi = radians(v) + Math.PI / 2; }\n // get altitude() { return this.radius - 1; } // relative altitude\n // lnglatZ coordinates\n get longitude(): number {\n return degrees(this.phi);\n }\n\n get latitude(): number {\n return degrees(this.theta);\n }\n\n get lng(): number {\n return degrees(this.phi);\n }\n\n get lat(): number {\n return degrees(this.theta);\n }\n\n get z(): number {\n return (this.radius - 1) * this.radiusScale;\n }\n\n /* eslint-enable brace-style */\n set(radius: number, phi: number, theta: number): this {\n this.radius = radius;\n this.phi = phi;\n this.theta = theta;\n return this.check();\n }\n\n clone(): SphericalCoordinates {\n return new SphericalCoordinates().copy(this);\n }\n\n copy(other: SphericalCoordinates): this {\n this.radius = other.radius;\n this.phi = other.phi;\n this.theta = other.theta;\n return this.check();\n }\n\n fromLngLatZ([lng, lat, z]: [number, number, number]): this {\n this.radius = 1 + z / this.radiusScale;\n this.phi = radians(lat);\n this.theta = radians(lng);\n return this.check();\n }\n\n fromVector3(v: Readonly<NumericArray>): this {\n this.radius = vec3.length(v);\n if (this.radius > 0) {\n this.theta = Math.atan2(v[0], v[1]); // equator angle around y-up axis\n this.phi = Math.acos(clamp(v[2] / this.radius, -1, 1)); // polar angle\n }\n return this.check();\n }\n\n toVector3(): Vector3 {\n return new Vector3(0, 0, this.radius)\n .rotateX({radians: this.theta})\n .rotateZ({radians: this.phi});\n }\n\n // restrict phi to be betwee EPS and PI-EPS\n makeSafe(): this {\n this.phi = Math.max(EPSILON, Math.min(Math.PI - EPSILON, this.phi));\n return this;\n }\n\n check(): this {\n // this.makeSafe();\n if (!Number.isFinite(this.phi) || !Number.isFinite(this.theta) || !(this.radius > 0)) {\n throw new Error('SphericalCoordinates: some fields set to invalid numbers');\n }\n return this;\n }\n}\n"],"file":"spherical-coordinates.js"}
|
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
8
10
|
exports.default = void 0;
|
|
9
11
|
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
10
22
|
var _vector = _interopRequireDefault(require("./base/vector"));
|
|
11
23
|
|
|
12
24
|
var _common = require("../lib/common");
|
|
@@ -17,98 +29,128 @@ var vec2 = _interopRequireWildcard(require("gl-matrix/vec2"));
|
|
|
17
29
|
|
|
18
30
|
var _glMatrixExtras = require("../lib/gl-matrix-extras");
|
|
19
31
|
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
35
|
|
|
22
|
-
function
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
23
37
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
|
+
|
|
40
|
+
var Vector2 = function (_Vector) {
|
|
41
|
+
(0, _inherits2.default)(Vector2, _Vector);
|
|
42
|
+
|
|
43
|
+
var _super = _createSuper(Vector2);
|
|
44
|
+
|
|
45
|
+
function Vector2() {
|
|
46
|
+
var _this;
|
|
47
|
+
|
|
48
|
+
var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
49
|
+
var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
50
|
+
(0, _classCallCheck2.default)(this, Vector2);
|
|
51
|
+
_this = _super.call(this, 2);
|
|
27
52
|
|
|
28
53
|
if ((0, _common.isArray)(x) && arguments.length === 1) {
|
|
29
|
-
|
|
54
|
+
_this.copy(x);
|
|
30
55
|
} else {
|
|
31
56
|
if (_common.config.debug) {
|
|
32
57
|
(0, _validators.checkNumber)(x);
|
|
33
58
|
(0, _validators.checkNumber)(y);
|
|
34
59
|
}
|
|
35
60
|
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
_this[0] = x;
|
|
62
|
+
_this[1] = y;
|
|
38
63
|
}
|
|
39
|
-
}
|
|
40
64
|
|
|
41
|
-
|
|
42
|
-
this[0] = x;
|
|
43
|
-
this[1] = y;
|
|
44
|
-
return this.check();
|
|
65
|
+
return _this;
|
|
45
66
|
}
|
|
46
67
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
fromObject(object) {
|
|
54
|
-
if (_common.config.debug) {
|
|
55
|
-
(0, _validators.checkNumber)(object.x);
|
|
56
|
-
(0, _validators.checkNumber)(object.y);
|
|
68
|
+
(0, _createClass2.default)(Vector2, [{
|
|
69
|
+
key: "set",
|
|
70
|
+
value: function set(x, y) {
|
|
71
|
+
this[0] = x;
|
|
72
|
+
this[1] = y;
|
|
73
|
+
return this.check();
|
|
57
74
|
}
|
|
75
|
+
}, {
|
|
76
|
+
key: "copy",
|
|
77
|
+
value: function copy(array) {
|
|
78
|
+
this[0] = array[0];
|
|
79
|
+
this[1] = array[1];
|
|
80
|
+
return this.check();
|
|
81
|
+
}
|
|
82
|
+
}, {
|
|
83
|
+
key: "fromObject",
|
|
84
|
+
value: function fromObject(object) {
|
|
85
|
+
if (_common.config.debug) {
|
|
86
|
+
(0, _validators.checkNumber)(object.x);
|
|
87
|
+
(0, _validators.checkNumber)(object.y);
|
|
88
|
+
}
|
|
58
89
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
object
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
90
|
+
this[0] = object.x;
|
|
91
|
+
this[1] = object.y;
|
|
92
|
+
return this.check();
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "toObject",
|
|
96
|
+
value: function toObject(object) {
|
|
97
|
+
object.x = this[0];
|
|
98
|
+
object.y = this[1];
|
|
99
|
+
return object;
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
key: "ELEMENTS",
|
|
103
|
+
get: function get() {
|
|
104
|
+
return 2;
|
|
105
|
+
}
|
|
106
|
+
}, {
|
|
107
|
+
key: "horizontalAngle",
|
|
108
|
+
value: function horizontalAngle() {
|
|
109
|
+
return Math.atan2(this.y, this.x);
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "verticalAngle",
|
|
113
|
+
value: function verticalAngle() {
|
|
114
|
+
return Math.atan2(this.x, this.y);
|
|
115
|
+
}
|
|
116
|
+
}, {
|
|
117
|
+
key: "transform",
|
|
118
|
+
value: function transform(matrix4) {
|
|
119
|
+
return this.transformAsPoint(matrix4);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "transformAsPoint",
|
|
123
|
+
value: function transformAsPoint(matrix4) {
|
|
124
|
+
vec2.transformMat4(this, this, matrix4);
|
|
125
|
+
return this.check();
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "transformAsVector",
|
|
129
|
+
value: function transformAsVector(matrix4) {
|
|
130
|
+
(0, _glMatrixExtras.vec2_transformMat4AsVector)(this, this, matrix4);
|
|
131
|
+
return this.check();
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "transformByMatrix3",
|
|
135
|
+
value: function transformByMatrix3(matrix3) {
|
|
136
|
+
vec2.transformMat3(this, this, matrix3);
|
|
137
|
+
return this.check();
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "transformByMatrix2x3",
|
|
141
|
+
value: function transformByMatrix2x3(matrix2x3) {
|
|
142
|
+
vec2.transformMat2d(this, this, matrix2x3);
|
|
143
|
+
return this.check();
|
|
144
|
+
}
|
|
145
|
+
}, {
|
|
146
|
+
key: "transformByMatrix2",
|
|
147
|
+
value: function transformByMatrix2(matrix2) {
|
|
148
|
+
vec2.transformMat2(this, this, matrix2);
|
|
149
|
+
return this.check();
|
|
150
|
+
}
|
|
151
|
+
}]);
|
|
152
|
+
return Vector2;
|
|
153
|
+
}(_vector.default);
|
|
112
154
|
|
|
113
155
|
exports.default = Vector2;
|
|
114
156
|
//# sourceMappingURL=vector2.js.map
|