@math.gl/core 3.5.3 → 3.6.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/classes/base/math-array.d.ts +36 -0
- package/dist/classes/base/math-array.d.ts.map +1 -0
- package/dist/classes/base/math-array.js +214 -0
- package/dist/classes/base/matrix.d.ts +12 -0
- package/dist/classes/base/matrix.d.ts.map +1 -0
- package/dist/classes/base/matrix.js +69 -0
- package/dist/classes/base/vector.d.ts +32 -0
- package/dist/classes/base/vector.d.ts.map +1 -0
- package/dist/classes/base/vector.js +133 -0
- package/dist/classes/euler.d.ts +73 -0
- package/dist/classes/euler.d.ts.map +1 -0
- package/dist/classes/euler.js +505 -0
- package/dist/classes/matrix3.d.ts +43 -0
- package/dist/classes/matrix3.d.ts.map +1 -0
- package/dist/classes/matrix3.js +192 -0
- package/dist/classes/matrix4.d.ts +102 -0
- package/dist/classes/matrix4.d.ts.map +1 -0
- package/dist/classes/matrix4.js +457 -0
- package/dist/classes/pose.d.ts +37 -0
- package/dist/classes/pose.d.ts.map +1 -0
- package/dist/classes/pose.js +126 -0
- package/dist/classes/quaternion.d.ts +42 -0
- package/dist/classes/quaternion.d.ts.map +1 -0
- package/dist/classes/quaternion.js +266 -0
- package/dist/classes/spherical-coordinates.d.ts +40 -0
- package/dist/classes/spherical-coordinates.d.ts.map +1 -0
- package/dist/classes/spherical-coordinates.js +142 -0
- package/dist/classes/vector2.d.ts +19 -0
- package/dist/classes/vector2.d.ts.map +1 -0
- package/dist/classes/vector2.js +105 -0
- package/dist/classes/vector3.d.ts +41 -0
- package/dist/classes/vector3.d.ts.map +1 -0
- package/dist/classes/vector3.js +147 -0
- package/dist/classes/vector4.d.ts +23 -0
- package/dist/classes/vector4.d.ts.map +1 -0
- package/dist/classes/vector4.js +126 -0
- package/dist/es5/classes/base/math-array.d.js +46 -0
- package/dist/es5/classes/base/math-array.d.js.map +1 -0
- package/dist/es5/classes/base/math-array.js +178 -251
- package/dist/es5/classes/base/math-array.js.map +1 -1
- package/dist/es5/classes/base/matrix.d.js +15 -0
- package/dist/es5/classes/base/matrix.d.js.map +1 -0
- package/dist/es5/classes/base/matrix.js +54 -88
- package/dist/es5/classes/base/matrix.js.map +1 -1
- package/dist/es5/classes/base/vector.d.js +24 -0
- package/dist/es5/classes/base/vector.d.js.map +1 -0
- package/dist/es5/classes/base/vector.js +121 -179
- package/dist/es5/classes/base/vector.js.map +1 -1
- package/dist/es5/classes/euler.d.js +45 -0
- package/dist/es5/classes/euler.d.js.map +1 -0
- package/dist/es5/classes/euler.js +468 -549
- package/dist/es5/classes/euler.js.map +1 -1
- package/dist/es5/classes/matrix3.d.js +25 -0
- package/dist/es5/classes/matrix3.d.js.map +1 -0
- package/dist/es5/classes/matrix3.js +157 -206
- package/dist/es5/classes/matrix3.js.map +1 -1
- package/dist/es5/classes/matrix4.d.js +25 -0
- package/dist/es5/classes/matrix4.d.js.map +1 -0
- package/dist/es5/classes/matrix4.js +410 -500
- package/dist/es5/classes/matrix4.js.map +1 -1
- package/dist/es5/classes/pose.d.js +25 -0
- package/dist/es5/classes/pose.d.js.map +1 -0
- package/dist/es5/classes/pose.js +101 -125
- package/dist/es5/classes/pose.js.map +1 -1
- package/dist/es5/classes/quaternion.d.js +27 -0
- package/dist/es5/classes/quaternion.d.js.map +1 -0
- package/dist/es5/classes/quaternion.js +213 -277
- package/dist/es5/classes/quaternion.js.map +1 -1
- package/dist/es5/classes/spherical-coordinates.d.js +27 -0
- package/dist/es5/classes/spherical-coordinates.d.js.map +1 -0
- package/dist/es5/classes/spherical-coordinates.js +125 -166
- package/dist/es5/classes/spherical-coordinates.js.map +1 -1
- package/dist/es5/classes/vector2.d.js +18 -0
- package/dist/es5/classes/vector2.d.js.map +1 -0
- package/dist/es5/classes/vector2.js +76 -118
- package/dist/es5/classes/vector2.js.map +1 -1
- package/dist/es5/classes/vector3.d.js +24 -0
- package/dist/es5/classes/vector3.d.js.map +1 -0
- package/dist/es5/classes/vector3.js +120 -167
- package/dist/es5/classes/vector3.js.map +1 -1
- package/dist/es5/classes/vector4.d.js +25 -0
- package/dist/es5/classes/vector4.d.js.map +1 -0
- package/dist/es5/classes/vector4.js +95 -137
- package/dist/es5/classes/vector4.js.map +1 -1
- package/dist/es5/docs/README.md +0 -0
- package/dist/es5/index.js +105 -123
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/assert.js.map +1 -1
- package/dist/es5/lib/common.js +55 -84
- 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/math-utils.js.map +1 -1
- package/dist/es5/lib/validators.js +3 -5
- package/dist/es5/lib/validators.js.map +1 -1
- package/dist/esm/classes/base/math-array.d.js +36 -0
- package/dist/esm/classes/base/math-array.d.js.map +1 -0
- package/dist/esm/classes/base/matrix.d.js +3 -0
- package/dist/esm/classes/base/matrix.d.js.map +1 -0
- package/dist/esm/classes/base/vector.d.js +13 -0
- package/dist/esm/classes/base/vector.d.js.map +1 -0
- package/dist/esm/classes/euler.d.js +55 -0
- package/dist/esm/classes/euler.d.js.map +1 -0
- package/dist/esm/classes/euler.js +1 -1
- package/dist/esm/classes/euler.js.map +1 -1
- package/dist/esm/classes/matrix3.d.js +15 -0
- package/dist/esm/classes/matrix3.d.js.map +1 -0
- package/dist/esm/classes/matrix4.d.js +15 -0
- package/dist/esm/classes/matrix4.d.js.map +1 -0
- package/dist/esm/classes/pose.d.js +18 -0
- package/dist/esm/classes/pose.d.js.map +1 -0
- package/dist/esm/classes/quaternion.d.js +19 -0
- package/dist/esm/classes/quaternion.d.js.map +1 -0
- package/dist/esm/classes/spherical-coordinates.d.js +22 -0
- package/dist/esm/classes/spherical-coordinates.d.js.map +1 -0
- package/dist/esm/classes/vector2.d.js +6 -0
- package/dist/esm/classes/vector2.d.js.map +1 -0
- package/dist/esm/classes/vector3.d.js +13 -0
- package/dist/esm/classes/vector3.d.js.map +1 -0
- package/dist/esm/classes/vector4.d.js +15 -0
- package/dist/esm/classes/vector4.d.js.map +1 -0
- package/dist/esm/docs/README.md +0 -0
- package/dist/esm/index.js +2 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/assert.js.map +1 -1
- package/dist/esm/lib/common.js +34 -37
- package/dist/esm/lib/common.js.map +1 -1
- package/dist/esm/lib/gl-matrix-extras.js.map +1 -1
- package/dist/esm/lib/math-utils.js.map +1 -1
- package/dist/esm/lib/validators.js.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/lib/assert.d.ts +2 -0
- package/dist/lib/assert.d.ts.map +1 -0
- package/dist/lib/assert.js +5 -0
- package/dist/lib/common.d.ts +90 -0
- package/dist/lib/common.d.ts.map +1 -0
- package/dist/lib/common.js +223 -0
- package/dist/lib/gl-matrix-extras.d.ts +6 -0
- package/dist/lib/gl-matrix-extras.d.ts.map +1 -0
- package/dist/lib/gl-matrix-extras.js +50 -0
- package/dist/lib/math-utils.d.ts +28 -0
- package/dist/lib/math-utils.d.ts.map +1 -0
- package/dist/lib/math-utils.js +28 -0
- package/dist/lib/validators.d.ts +5 -0
- package/dist/lib/validators.d.ts.map +1 -0
- package/dist/lib/validators.js +52 -0
- package/package.json +5 -4
- package/src/classes/base/math-array.d.ts +0 -1
- package/src/classes/euler.js +1 -1
- package/src/docs/README.md +0 -0
- package/{dist/esm/index.d.ts → src/index.ts} +32 -34
- package/src/lib/{assert.js → assert.ts} +1 -1
- package/src/lib/common.ts +283 -0
- package/src/lib/{gl-matrix-extras.js → gl-matrix-extras.ts} +0 -0
- package/src/lib/{math-utils.js → math-utils.ts} +0 -0
- package/src/lib/{validators.js → validators.ts} +0 -0
- package/dist/es5/addons/polygon.d.ts +0 -17
- package/dist/es5/classes/base/math-array.d.ts +0 -56
- package/dist/es5/classes/base/matrix.d.ts +0 -15
- package/dist/es5/classes/base/vector.d.ts +0 -45
- package/dist/es5/classes/euler.d.ts +0 -92
- package/dist/es5/classes/matrix3.d.ts +0 -91
- package/dist/es5/classes/matrix4.d.ts +0 -161
- package/dist/es5/classes/pose.d.ts +0 -92
- package/dist/es5/classes/quaternion.d.ts +0 -107
- package/dist/es5/classes/spherical-coordinates.d.ts +0 -87
- package/dist/es5/classes/vector2.d.ts +0 -65
- package/dist/es5/classes/vector3.d.ts +0 -65
- package/dist/es5/classes/vector4.d.ts +0 -34
- package/dist/es5/index.d.ts +0 -54
- package/dist/es5/lib/common.d.ts +0 -80
- package/dist/esm/addons/polygon.d.ts +0 -17
- package/dist/esm/classes/base/math-array.d.ts +0 -56
- package/dist/esm/classes/base/matrix.d.ts +0 -15
- package/dist/esm/classes/base/vector.d.ts +0 -45
- package/dist/esm/classes/euler.d.ts +0 -92
- package/dist/esm/classes/matrix3.d.ts +0 -91
- package/dist/esm/classes/matrix4.d.ts +0 -161
- package/dist/esm/classes/pose.d.ts +0 -92
- package/dist/esm/classes/quaternion.d.ts +0 -107
- package/dist/esm/classes/spherical-coordinates.d.ts +0 -87
- package/dist/esm/classes/vector2.d.ts +0 -65
- package/dist/esm/classes/vector3.d.ts +0 -65
- package/dist/esm/classes/vector4.d.ts +0 -34
- package/dist/esm/lib/common.d.ts +0 -80
- package/src/addons/polygon.d.ts +0 -17
- package/src/index.d.ts +0 -54
- package/src/index.js +0 -86
- package/src/lib/common.d.ts +0 -80
- package/src/lib/common.js +0 -222
|
@@ -2,23 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
9
|
|
|
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
|
-
|
|
22
10
|
var _mathArray = _interopRequireDefault(require("./base/math-array"));
|
|
23
11
|
|
|
24
12
|
var _validators = require("../lib/validators");
|
|
@@ -29,287 +17,235 @@ var quat = _interopRequireWildcard(require("gl-matrix/quat"));
|
|
|
29
17
|
|
|
30
18
|
var vec4 = _interopRequireWildcard(require("gl-matrix/vec4"));
|
|
31
19
|
|
|
32
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function
|
|
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); }
|
|
33
21
|
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
22
|
+
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; }
|
|
35
23
|
|
|
36
|
-
|
|
24
|
+
const IDENTITY_QUATERNION = [0, 0, 0, 1];
|
|
37
25
|
|
|
38
|
-
|
|
26
|
+
class Quaternion extends _mathArray.default {
|
|
27
|
+
constructor(x = 0, y = 0, z = 0, w = 1) {
|
|
28
|
+
super(-0, -0, -0, -0);
|
|
39
29
|
|
|
40
|
-
|
|
30
|
+
if (Array.isArray(x) && arguments.length === 1) {
|
|
31
|
+
this.copy(x);
|
|
32
|
+
} else {
|
|
33
|
+
this.set(x, y, z, w);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
41
36
|
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
copy(array) {
|
|
38
|
+
this[0] = array[0];
|
|
39
|
+
this[1] = array[1];
|
|
40
|
+
this[2] = array[2];
|
|
41
|
+
this[3] = array[3];
|
|
42
|
+
return this.check();
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
set(x, y, z, w) {
|
|
46
|
+
this[0] = x;
|
|
47
|
+
this[1] = y;
|
|
48
|
+
this[2] = z;
|
|
49
|
+
this[3] = w;
|
|
50
|
+
return this.check();
|
|
51
|
+
}
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
fromMatrix3(m) {
|
|
54
|
+
quat.fromMat3(this, m);
|
|
55
|
+
return this.check();
|
|
56
|
+
}
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
(0, _classCallCheck2.default)(this, Quaternion);
|
|
55
|
-
_this = _super.call(this, -0, -0, -0, -0);
|
|
58
|
+
identity() {
|
|
59
|
+
quat.identity(this);
|
|
60
|
+
return this.check();
|
|
61
|
+
}
|
|
56
62
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
63
|
+
fromAxisRotation(axis, rad) {
|
|
64
|
+
quat.setAxisAngle(this, axis, rad);
|
|
65
|
+
return this.check();
|
|
66
|
+
}
|
|
62
67
|
|
|
63
|
-
|
|
68
|
+
setAxisAngle(axis, rad) {
|
|
69
|
+
return this.fromAxisRotation(axis, rad);
|
|
64
70
|
}
|
|
65
71
|
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
key: "x",
|
|
114
|
-
get: function get() {
|
|
115
|
-
return this[0];
|
|
116
|
-
},
|
|
117
|
-
set: function set(value) {
|
|
118
|
-
this[0] = (0, _validators.checkNumber)(value);
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "y",
|
|
122
|
-
get: function get() {
|
|
123
|
-
return this[1];
|
|
124
|
-
},
|
|
125
|
-
set: function set(value) {
|
|
126
|
-
this[1] = (0, _validators.checkNumber)(value);
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
129
|
-
key: "z",
|
|
130
|
-
get: function get() {
|
|
131
|
-
return this[2];
|
|
132
|
-
},
|
|
133
|
-
set: function set(value) {
|
|
134
|
-
this[2] = (0, _validators.checkNumber)(value);
|
|
135
|
-
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "w",
|
|
138
|
-
get: function get() {
|
|
139
|
-
return this[3];
|
|
140
|
-
},
|
|
141
|
-
set: function set(value) {
|
|
142
|
-
this[3] = (0, _validators.checkNumber)(value);
|
|
143
|
-
}
|
|
144
|
-
}, {
|
|
145
|
-
key: "len",
|
|
146
|
-
value: function len() {
|
|
147
|
-
return quat.length(this);
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "lengthSquared",
|
|
151
|
-
value: function lengthSquared() {
|
|
152
|
-
return quat.squaredLength(this);
|
|
153
|
-
}
|
|
154
|
-
}, {
|
|
155
|
-
key: "dot",
|
|
156
|
-
value: function dot(a, b) {
|
|
157
|
-
if (b !== undefined) {
|
|
158
|
-
throw new Error('Quaternion.dot only takes one argument');
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return quat.dot(this, a);
|
|
162
|
-
}
|
|
163
|
-
}, {
|
|
164
|
-
key: "rotationTo",
|
|
165
|
-
value: function rotationTo(vectorA, vectorB) {
|
|
166
|
-
quat.rotationTo(this, vectorA, vectorB);
|
|
167
|
-
return this.check();
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "add",
|
|
171
|
-
value: function add(a, b) {
|
|
172
|
-
if (b !== undefined) {
|
|
173
|
-
throw new Error('Quaternion.add only takes one argument');
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
quat.add(this, this, a);
|
|
177
|
-
return this.check();
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
key: "calculateW",
|
|
181
|
-
value: function calculateW() {
|
|
182
|
-
quat.calculateW(this, this);
|
|
183
|
-
return this.check();
|
|
184
|
-
}
|
|
185
|
-
}, {
|
|
186
|
-
key: "conjugate",
|
|
187
|
-
value: function conjugate() {
|
|
188
|
-
quat.conjugate(this, this);
|
|
189
|
-
return this.check();
|
|
190
|
-
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "invert",
|
|
193
|
-
value: function invert() {
|
|
194
|
-
quat.invert(this, this);
|
|
195
|
-
return this.check();
|
|
196
|
-
}
|
|
197
|
-
}, {
|
|
198
|
-
key: "lerp",
|
|
199
|
-
value: function lerp(a, b, t) {
|
|
200
|
-
quat.lerp(this, a, b, t);
|
|
201
|
-
return this.check();
|
|
202
|
-
}
|
|
203
|
-
}, {
|
|
204
|
-
key: "multiplyRight",
|
|
205
|
-
value: function multiplyRight(a, b) {
|
|
206
|
-
(0, _assert.default)(!b);
|
|
207
|
-
quat.multiply(this, this, a);
|
|
208
|
-
return this.check();
|
|
209
|
-
}
|
|
210
|
-
}, {
|
|
211
|
-
key: "multiplyLeft",
|
|
212
|
-
value: function multiplyLeft(a, b) {
|
|
213
|
-
(0, _assert.default)(!b);
|
|
214
|
-
quat.multiply(this, a, this);
|
|
215
|
-
return this.check();
|
|
216
|
-
}
|
|
217
|
-
}, {
|
|
218
|
-
key: "normalize",
|
|
219
|
-
value: function normalize() {
|
|
220
|
-
var length = this.len();
|
|
221
|
-
var l = length > 0 ? 1 / length : 0;
|
|
222
|
-
this[0] = this[0] * l;
|
|
223
|
-
this[1] = this[1] * l;
|
|
224
|
-
this[2] = this[2] * l;
|
|
225
|
-
this[3] = this[3] * l;
|
|
226
|
-
|
|
227
|
-
if (length === 0) {
|
|
228
|
-
this[3] = 1;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
return this.check();
|
|
232
|
-
}
|
|
233
|
-
}, {
|
|
234
|
-
key: "rotateX",
|
|
235
|
-
value: function rotateX(rad) {
|
|
236
|
-
quat.rotateX(this, this, rad);
|
|
237
|
-
return this.check();
|
|
238
|
-
}
|
|
239
|
-
}, {
|
|
240
|
-
key: "rotateY",
|
|
241
|
-
value: function rotateY(rad) {
|
|
242
|
-
quat.rotateY(this, this, rad);
|
|
243
|
-
return this.check();
|
|
244
|
-
}
|
|
245
|
-
}, {
|
|
246
|
-
key: "rotateZ",
|
|
247
|
-
value: function rotateZ(rad) {
|
|
248
|
-
quat.rotateZ(this, this, rad);
|
|
249
|
-
return this.check();
|
|
250
|
-
}
|
|
251
|
-
}, {
|
|
252
|
-
key: "scale",
|
|
253
|
-
value: function scale(b) {
|
|
254
|
-
quat.scale(this, this, b);
|
|
255
|
-
return this.check();
|
|
256
|
-
}
|
|
257
|
-
}, {
|
|
258
|
-
key: "slerp",
|
|
259
|
-
value: function slerp(start, target, ratio) {
|
|
260
|
-
switch (arguments.length) {
|
|
261
|
-
case 1:
|
|
262
|
-
var _arguments$ = arguments[0];
|
|
263
|
-
var _arguments$$start = _arguments$.start;
|
|
264
|
-
start = _arguments$$start === void 0 ? IDENTITY_QUATERNION : _arguments$$start;
|
|
265
|
-
target = _arguments$.target;
|
|
266
|
-
ratio = _arguments$.ratio;
|
|
267
|
-
break;
|
|
268
|
-
|
|
269
|
-
case 2:
|
|
270
|
-
var _arguments = Array.prototype.slice.call(arguments);
|
|
271
|
-
|
|
272
|
-
target = _arguments[0];
|
|
273
|
-
ratio = _arguments[1];
|
|
274
|
-
start = this;
|
|
275
|
-
break;
|
|
276
|
-
|
|
277
|
-
default:
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
quat.slerp(this, start, target, ratio);
|
|
281
|
-
return this.check();
|
|
282
|
-
}
|
|
283
|
-
}, {
|
|
284
|
-
key: "transformVector4",
|
|
285
|
-
value: function transformVector4(vector) {
|
|
286
|
-
var result = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : vector;
|
|
287
|
-
vec4.transformQuat(result, vector, this);
|
|
288
|
-
return (0, _validators.checkVector)(result, 4);
|
|
289
|
-
}
|
|
290
|
-
}, {
|
|
291
|
-
key: "lengthSq",
|
|
292
|
-
value: function lengthSq() {
|
|
293
|
-
return this.lengthSquared();
|
|
72
|
+
get ELEMENTS() {
|
|
73
|
+
return 4;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get x() {
|
|
77
|
+
return this[0];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
set x(value) {
|
|
81
|
+
this[0] = (0, _validators.checkNumber)(value);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get y() {
|
|
85
|
+
return this[1];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set y(value) {
|
|
89
|
+
this[1] = (0, _validators.checkNumber)(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get z() {
|
|
93
|
+
return this[2];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
set z(value) {
|
|
97
|
+
this[2] = (0, _validators.checkNumber)(value);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
get w() {
|
|
101
|
+
return this[3];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
set w(value) {
|
|
105
|
+
this[3] = (0, _validators.checkNumber)(value);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
len() {
|
|
109
|
+
return quat.length(this);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
lengthSquared() {
|
|
113
|
+
return quat.squaredLength(this);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
dot(a, b) {
|
|
117
|
+
if (b !== undefined) {
|
|
118
|
+
throw new Error('Quaternion.dot only takes one argument');
|
|
294
119
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
120
|
+
|
|
121
|
+
return quat.dot(this, a);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
rotationTo(vectorA, vectorB) {
|
|
125
|
+
quat.rotationTo(this, vectorA, vectorB);
|
|
126
|
+
return this.check();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
add(a, b) {
|
|
130
|
+
if (b !== undefined) {
|
|
131
|
+
throw new Error('Quaternion.add only takes one argument');
|
|
299
132
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
133
|
+
|
|
134
|
+
quat.add(this, this, a);
|
|
135
|
+
return this.check();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
calculateW() {
|
|
139
|
+
quat.calculateW(this, this);
|
|
140
|
+
return this.check();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
conjugate() {
|
|
144
|
+
quat.conjugate(this, this);
|
|
145
|
+
return this.check();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
invert() {
|
|
149
|
+
quat.invert(this, this);
|
|
150
|
+
return this.check();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
lerp(a, b, t) {
|
|
154
|
+
quat.lerp(this, a, b, t);
|
|
155
|
+
return this.check();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
multiplyRight(a, b) {
|
|
159
|
+
(0, _assert.default)(!b);
|
|
160
|
+
quat.multiply(this, this, a);
|
|
161
|
+
return this.check();
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
multiplyLeft(a, b) {
|
|
165
|
+
(0, _assert.default)(!b);
|
|
166
|
+
quat.multiply(this, a, this);
|
|
167
|
+
return this.check();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
normalize() {
|
|
171
|
+
const length = this.len();
|
|
172
|
+
const l = length > 0 ? 1 / length : 0;
|
|
173
|
+
this[0] = this[0] * l;
|
|
174
|
+
this[1] = this[1] * l;
|
|
175
|
+
this[2] = this[2] * l;
|
|
176
|
+
this[3] = this[3] * l;
|
|
177
|
+
|
|
178
|
+
if (length === 0) {
|
|
179
|
+
this[3] = 1;
|
|
304
180
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
181
|
+
|
|
182
|
+
return this.check();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
rotateX(rad) {
|
|
186
|
+
quat.rotateX(this, this, rad);
|
|
187
|
+
return this.check();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
rotateY(rad) {
|
|
191
|
+
quat.rotateY(this, this, rad);
|
|
192
|
+
return this.check();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
rotateZ(rad) {
|
|
196
|
+
quat.rotateZ(this, this, rad);
|
|
197
|
+
return this.check();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
scale(b) {
|
|
201
|
+
quat.scale(this, this, b);
|
|
202
|
+
return this.check();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
slerp(start, target, ratio) {
|
|
206
|
+
switch (arguments.length) {
|
|
207
|
+
case 1:
|
|
208
|
+
({
|
|
209
|
+
start = IDENTITY_QUATERNION,
|
|
210
|
+
target,
|
|
211
|
+
ratio
|
|
212
|
+
} = arguments[0]);
|
|
213
|
+
break;
|
|
214
|
+
|
|
215
|
+
case 2:
|
|
216
|
+
[target, ratio] = arguments;
|
|
217
|
+
start = this;
|
|
218
|
+
break;
|
|
219
|
+
|
|
220
|
+
default:
|
|
309
221
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
222
|
+
|
|
223
|
+
quat.slerp(this, start, target, ratio);
|
|
224
|
+
return this.check();
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
transformVector4(vector, result = vector) {
|
|
228
|
+
vec4.transformQuat(result, vector, this);
|
|
229
|
+
return (0, _validators.checkVector)(result, 4);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
lengthSq() {
|
|
233
|
+
return this.lengthSquared();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
setFromAxisAngle(axis, rad) {
|
|
237
|
+
return this.setAxisAngle(axis, rad);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
premultiply(a, b) {
|
|
241
|
+
return this.multiplyLeft(a, b);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
multiply(a, b) {
|
|
245
|
+
return this.multiplyRight(a, b);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
}
|
|
313
249
|
|
|
314
250
|
exports.default = Quaternion;
|
|
315
251
|
//# sourceMappingURL=quaternion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/classes/quaternion.js"],"names":["IDENTITY_QUATERNION","Quaternion","x","y","z","w","Array","isArray","arguments","length","copy","set","array","check","m","quat","fromMat3","identity","axis","rad","setAxisAngle","fromAxisRotation","value","squaredLength","a","b","undefined","Error","dot","vectorA","vectorB","rotationTo","add","calculateW","conjugate","invert","t","lerp","multiply","len","l","rotateX","rotateY","rotateZ","scale","start","target","ratio","slerp","vector","result","vec4","transformQuat","lengthSquared","multiplyLeft","multiplyRight","MathArray"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAoBA;;AACA;;AACA;;AAGA;;AAEA;;;;;;;;;;AAEA,IAAMA,mBAAmB,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAA5B;;IAEqBC,U;;;;;AACnB,wBAAwC;AAAA;;AAAA,QAA5BC,CAA4B,uEAAxB,CAAwB;AAAA,QAArBC,CAAqB,uEAAjB,CAAiB;AAAA,QAAdC,CAAc,uEAAV,CAAU;AAAA,QAAPC,CAAO,uEAAH,CAAG;AAAA;AAEtC,8BAAM,CAAC,CAAP,EAAU,CAAC,CAAX,EAAc,CAAC,CAAf,EAAkB,CAAC,CAAnB;;AAEA,QAAIC,KAAK,CAACC,OAAN,CAAcL,CAAd,KAAoBM,SAAS,CAACC,MAAV,KAAqB,CAA7C,EAAgD;AAC9C,YAAKC,IAAL,CAAUR,CAAV;AACD,KAFD,MAEO;AACL,YAAKS,GAAL,CAAST,CAAT,EAAYC,CAAZ,EAAeC,CAAf,EAAkBC,CAAlB;AACD;;AARqC;AASvC;;;;WAED,cAAKO,KAAL,EAAY;AACV,WAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,WAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,WAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,WAAK,CAAL,IAAUA,KAAK,CAAC,CAAD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B,CAAlB,EAAqBC,CAArB,CAAP;AACD;;;WAED,kBAASD,CAAT,EAAYC,CAAZ,EAAe;AACb,aAAO,KAAK8B,aAAL,CAAmB/B,CAAnB,EAAsBC,CAAtB,CAAP;AACD;;;EAvRqC+B,kB","sourcesContent":["// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport MathArray from './base/math-array';\nimport {checkNumber, checkVector} from '../lib/validators';\nimport assert from '../lib/assert';\n\n// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.\nimport * as quat from 'gl-matrix/quat';\n// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.\nimport * as vec4 from 'gl-matrix/vec4';\n\nconst IDENTITY_QUATERNION = [0, 0, 0, 1];\n\nexport default class Quaternion extends MathArray {\n constructor(x = 0, y = 0, z = 0, w = 1) {\n // PERF NOTE: initialize elements as double precision numbers\n super(-0, -0, -0, -0);\n // eslint-disable-next-line prefer-rest-params\n if (Array.isArray(x) && arguments.length === 1) {\n this.copy(x);\n } else {\n this.set(x, y, z, w);\n }\n }\n\n copy(array) {\n this[0] = array[0];\n this[1] = array[1];\n this[2] = array[2];\n this[3] = array[3];\n return this.check();\n }\n\n set(x, y, z, w) {\n this[0] = x;\n this[1] = y;\n this[2] = z;\n this[3] = w;\n return this.check();\n }\n\n // Creates a quaternion from the given 3x3 rotation matrix.\n // NOTE: The resultant quaternion is not normalized, so you should\n // be sure to renormalize the quaternion yourself where necessary.\n fromMatrix3(m) {\n quat.fromMat3(this, m);\n return this.check();\n }\n\n // Set a quat to the identity quaternion\n identity() {\n quat.identity(this);\n return this.check();\n }\n\n fromAxisRotation(axis, rad) {\n quat.setAxisAngle(this, axis, rad);\n return this.check();\n }\n\n // Set the components of a quat to the given values\n // set(i, j, k, l) {\n // quat.set(this, i, j, k, l);\n // return this.check();\n // }\n\n // Sets a quat from the given angle and rotation axis, then returns it.\n setAxisAngle(axis, rad) {\n return this.fromAxisRotation(axis, rad);\n }\n\n // Getters/setters\n /* eslint-disable no-multi-spaces, brace-style, no-return-assign */\n get ELEMENTS() {\n return 4;\n }\n\n get x() {\n return this[0];\n }\n\n set x(value) {\n this[0] = checkNumber(value);\n }\n\n get y() {\n return this[1];\n }\n\n set y(value) {\n this[1] = checkNumber(value);\n }\n\n get z() {\n return this[2];\n }\n\n set z(value) {\n this[2] = checkNumber(value);\n }\n\n get w() {\n return this[3];\n }\n\n set w(value) {\n this[3] = checkNumber(value);\n }\n\n /* eslint-enable no-multi-spaces, brace-style, no-return-assign */\n\n // Calculates the length of a quat\n len() {\n return quat.length(this);\n }\n\n // Calculates the squared length of a quat\n lengthSquared() {\n return quat.squaredLength(this);\n }\n\n // Calculates the dot product of two quat's\n // @return {Number}\n dot(a, b) {\n if (b !== undefined) {\n throw new Error('Quaternion.dot only takes one argument');\n }\n return quat.dot(this, a);\n }\n\n // Gets the rotation axis and angle for a given quaternion.\n // If a quaternion is created with setAxisAngle, this method will\n // return the same values as providied in the original parameter\n // list OR functionally equivalent values.\n // Example: The quaternion formed by axis [0, 0, 1] and angle -90\n // is the same as the quaternion formed by [0, 0, 1] and 270.\n // This method favors the latter.\n // @return {{[x,y,z], Number}}\n // getAxisAngle() {\n // const axis = [];\n // const angle = quat.getAxisAngle(axis, this);\n // return {axis, angle};\n // }\n\n // MODIFIERS\n\n // Sets a quaternion to represent the shortest rotation from one vector\n // to another. Both vectors are assumed to be unit length.\n rotationTo(vectorA, vectorB) {\n quat.rotationTo(this, vectorA, vectorB);\n return this.check();\n }\n\n // Sets the specified quaternion with values corresponding to the given axes.\n // Each axis is a vec3 and is expected to be unit length and perpendicular\n // to all other specified axes.\n // setAxes() {\n // Number\n // }\n\n // Performs a spherical linear interpolation with two control points\n // sqlerp() {\n // Number;\n // }\n\n // Adds two quat's\n add(a, b) {\n if (b !== undefined) {\n throw new Error('Quaternion.add only takes one argument');\n }\n quat.add(this, this, a);\n return this.check();\n }\n\n // Calculates the W component of a quat from the X, Y, and Z components.\n // Any existing W component will be ignored.\n calculateW() {\n quat.calculateW(this, this);\n return this.check();\n }\n\n // Calculates the conjugate of a quat If the quaternion is normalized,\n // this function is faster than quat.inverse and produces the same result.\n conjugate() {\n quat.conjugate(this, this);\n return this.check();\n }\n\n // Calculates the inverse of a quat\n invert() {\n quat.invert(this, this);\n return this.check();\n }\n\n // Performs a linear interpolation between two quat's\n lerp(a, b, t) {\n quat.lerp(this, a, b, t);\n return this.check();\n }\n\n // Multiplies two quat's\n multiplyRight(a, b) {\n assert(!b); // Quaternion.multiply only takes one argument\n quat.multiply(this, this, a);\n return this.check();\n }\n\n multiplyLeft(a, b) {\n assert(!b); // Quaternion.multiply only takes one argument\n quat.multiply(this, a, this);\n return this.check();\n }\n\n // Normalize a quat\n normalize() {\n // Handle 0 case\n const length = this.len();\n const l = length > 0 ? 1 / length : 0;\n this[0] = this[0] * l;\n this[1] = this[1] * l;\n this[2] = this[2] * l;\n this[3] = this[3] * l;\n // Set to [0, 0, 0, 1] if length is 0\n if (length === 0) {\n this[3] = 1;\n }\n return this.check();\n }\n\n // Rotates a quaternion by the given angle about the X axis\n rotateX(rad) {\n quat.rotateX(this, this, rad);\n return this.check();\n }\n\n // Rotates a quaternion by the given angle about the Y axis\n rotateY(rad) {\n quat.rotateY(this, this, rad);\n return this.check();\n }\n\n // Rotates a quaternion by the given angle about the Z axis\n rotateZ(rad) {\n quat.rotateZ(this, this, rad);\n return this.check();\n }\n\n // Scales a quat by a scalar number\n scale(b) {\n quat.scale(this, this, b);\n return this.check();\n }\n\n // Performs a spherical linear interpolation between two quat\n slerp(start, target, ratio) {\n // eslint-disable-next-line prefer-rest-params\n switch (arguments.length) {\n case 1: // Deprecated signature ({start, target, ratio})\n // eslint-disable-next-line prefer-rest-params\n ({start = IDENTITY_QUATERNION, target, ratio} = arguments[0]);\n break;\n case 2: // THREE.js compatibility signature (target, ration)\n // eslint-disable-next-line prefer-rest-params\n [target, ratio] = arguments;\n start = this; // eslint-disable-line\n break;\n default: // Default signature: (start, target, ratio)\n }\n quat.slerp(this, start, target, ratio);\n return this.check();\n }\n\n transformVector4(vector, result = vector) {\n vec4.transformQuat(result, vector, this);\n return checkVector(result, 4);\n }\n\n // THREE.js Math API compatibility\n lengthSq() {\n return this.lengthSquared();\n }\n\n setFromAxisAngle(axis, rad) {\n return this.setAxisAngle(axis, rad);\n }\n\n premultiply(a, b) {\n return this.multiplyLeft(a, b);\n }\n\n multiply(a, b) {\n return this.multiplyRight(a, b);\n }\n}\n"],"file":"quaternion.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/quaternion.js"],"names":["IDENTITY_QUATERNION","Quaternion","MathArray","constructor","x","y","z","w","Array","isArray","arguments","length","copy","set","array","check","fromMatrix3","m","quat","fromMat3","identity","fromAxisRotation","axis","rad","setAxisAngle","ELEMENTS","value","len","lengthSquared","squaredLength","dot","a","b","undefined","Error","rotationTo","vectorA","vectorB","add","calculateW","conjugate","invert","lerp","t","multiplyRight","multiply","multiplyLeft","normalize","l","rotateX","rotateY","rotateZ","scale","slerp","start","target","ratio","transformVector4","vector","result","vec4","transformQuat","lengthSq","setFromAxisAngle","premultiply"],"mappings":";;;;;;;;;AAoBA;;AACA;;AACA;;AAGA;;AAEA;;;;;;AAEA,MAAMA,mBAAmB,GAAG,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAA5B;;AAEe,MAAMC,UAAN,SAAyBC,kBAAzB,CAAmC;AAChDC,EAAAA,WAAW,CAACC,CAAC,GAAG,CAAL,EAAQC,CAAC,GAAG,CAAZ,EAAeC,CAAC,GAAG,CAAnB,EAAsBC,CAAC,GAAG,CAA1B,EAA6B;AAEtC,UAAM,CAAC,CAAP,EAAU,CAAC,CAAX,EAAc,CAAC,CAAf,EAAkB,CAAC,CAAnB;;AAEA,QAAIC,KAAK,CAACC,OAAN,CAAcL,CAAd,KAAoBM,SAAS,CAACC,MAAV,KAAqB,CAA7C,EAAgD;AAC9C,WAAKC,IAAL,CAAUR,CAAV;AACD,KAFD,MAEO;AACL,WAAKS,GAAL,CAAST,CAAT,EAAYC,CAAZ,EAAeC,CAAf,EAAkBC,CAAlB;AACD;AACF;;AAEDK,EAAAA,IAAI,CAACE,KAAD,EAAQ;AACV,SAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,SAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,SAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,SAAK,CAAL,IAAUA,KAAK,CAAC,CAAD,CAAf;AACA,WAAO,KAAKC,KAAL,EAAP;AACD;;AAEDF,EAAAA,GAAG,CAACT,CAAD,EAAIC,CAAJ,EAAOC,CAAP,EAAUC,CAAV,EAAa;AACd,SAAK,CAAL,IAAUH,CAAV;AACA,SAAK,CAAL,IAAUC,CAAV;AACA,SAAK,CAAL,IAAUC,CAAV;AACA,SAAK,CAAL,IAAUC,CAAV;AACA,WAAO,KAAKQ,KAAL,EAAP;AACD;;AAKDC,EAAAA,WAA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,EAAIC,CAAJ,EAAO;AAChB,WAAO,KAAKc,YAAL,CAAkBf,CAAlB,EAAqBC,CAArB,CAAP;AACD;;AAEDa,EAAAA,QAAQ,CAACd,CAAD,EAAIC,CAAJ,EAAO;AACb,WAAO,KAAKY,aAAL,CAAmBb,CAAnB,EAAsBC,CAAtB,CAAP;AACD;;AAvR+C","sourcesContent":["// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\nimport MathArray from './base/math-array';\nimport {checkNumber, checkVector} from '../lib/validators';\nimport assert from '../lib/assert';\n\n// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.\nimport * as quat from 'gl-matrix/quat';\n// @ts-ignore: error TS2307: Cannot find module 'gl-matrix/...'.\nimport * as vec4 from 'gl-matrix/vec4';\n\nconst IDENTITY_QUATERNION = [0, 0, 0, 1];\n\nexport default class Quaternion extends MathArray {\n constructor(x = 0, y = 0, z = 0, w = 1) {\n // PERF NOTE: initialize elements as double precision numbers\n super(-0, -0, -0, -0);\n // eslint-disable-next-line prefer-rest-params\n if (Array.isArray(x) && arguments.length === 1) {\n this.copy(x);\n } else {\n this.set(x, y, z, w);\n }\n }\n\n copy(array) {\n this[0] = array[0];\n this[1] = array[1];\n this[2] = array[2];\n this[3] = array[3];\n return this.check();\n }\n\n set(x, y, z, w) {\n this[0] = x;\n this[1] = y;\n this[2] = z;\n this[3] = w;\n return this.check();\n }\n\n // Creates a quaternion from the given 3x3 rotation matrix.\n // NOTE: The resultant quaternion is not normalized, so you should\n // be sure to renormalize the quaternion yourself where necessary.\n fromMatrix3(m) {\n quat.fromMat3(this, m);\n return this.check();\n }\n\n // Set a quat to the identity quaternion\n identity() {\n quat.identity(this);\n return this.check();\n }\n\n fromAxisRotation(axis, rad) {\n quat.setAxisAngle(this, axis, rad);\n return this.check();\n }\n\n // Set the components of a quat to the given values\n // set(i, j, k, l) {\n // quat.set(this, i, j, k, l);\n // return this.check();\n // }\n\n // Sets a quat from the given angle and rotation axis, then returns it.\n setAxisAngle(axis, rad) {\n return this.fromAxisRotation(axis, rad);\n }\n\n // Getters/setters\n /* eslint-disable no-multi-spaces, brace-style, no-return-assign */\n get ELEMENTS() {\n return 4;\n }\n\n get x() {\n return this[0];\n }\n\n set x(value) {\n this[0] = checkNumber(value);\n }\n\n get y() {\n return this[1];\n }\n\n set y(value) {\n this[1] = checkNumber(value);\n }\n\n get z() {\n return this[2];\n }\n\n set z(value) {\n this[2] = checkNumber(value);\n }\n\n get w() {\n return this[3];\n }\n\n set w(value) {\n this[3] = checkNumber(value);\n }\n\n /* eslint-enable no-multi-spaces, brace-style, no-return-assign */\n\n // Calculates the length of a quat\n len() {\n return quat.length(this);\n }\n\n // Calculates the squared length of a quat\n lengthSquared() {\n return quat.squaredLength(this);\n }\n\n // Calculates the dot product of two quat's\n // @return {Number}\n dot(a, b) {\n if (b !== undefined) {\n throw new Error('Quaternion.dot only takes one argument');\n }\n return quat.dot(this, a);\n }\n\n // Gets the rotation axis and angle for a given quaternion.\n // If a quaternion is created with setAxisAngle, this method will\n // return the same values as providied in the original parameter\n // list OR functionally equivalent values.\n // Example: The quaternion formed by axis [0, 0, 1] and angle -90\n // is the same as the quaternion formed by [0, 0, 1] and 270.\n // This method favors the latter.\n // @return {{[x,y,z], Number}}\n // getAxisAngle() {\n // const axis = [];\n // const angle = quat.getAxisAngle(axis, this);\n // return {axis, angle};\n // }\n\n // MODIFIERS\n\n // Sets a quaternion to represent the shortest rotation from one vector\n // to another. Both vectors are assumed to be unit length.\n rotationTo(vectorA, vectorB) {\n quat.rotationTo(this, vectorA, vectorB);\n return this.check();\n }\n\n // Sets the specified quaternion with values corresponding to the given axes.\n // Each axis is a vec3 and is expected to be unit length and perpendicular\n // to all other specified axes.\n // setAxes() {\n // Number\n // }\n\n // Performs a spherical linear interpolation with two control points\n // sqlerp() {\n // Number;\n // }\n\n // Adds two quat's\n add(a, b) {\n if (b !== undefined) {\n throw new Error('Quaternion.add only takes one argument');\n }\n quat.add(this, this, a);\n return this.check();\n }\n\n // Calculates the W component of a quat from the X, Y, and Z components.\n // Any existing W component will be ignored.\n calculateW() {\n quat.calculateW(this, this);\n return this.check();\n }\n\n // Calculates the conjugate of a quat If the quaternion is normalized,\n // this function is faster than quat.inverse and produces the same result.\n conjugate() {\n quat.conjugate(this, this);\n return this.check();\n }\n\n // Calculates the inverse of a quat\n invert() {\n quat.invert(this, this);\n return this.check();\n }\n\n // Performs a linear interpolation between two quat's\n lerp(a, b, t) {\n quat.lerp(this, a, b, t);\n return this.check();\n }\n\n // Multiplies two quat's\n multiplyRight(a, b) {\n assert(!b); // Quaternion.multiply only takes one argument\n quat.multiply(this, this, a);\n return this.check();\n }\n\n multiplyLeft(a, b) {\n assert(!b); // Quaternion.multiply only takes one argument\n quat.multiply(this, a, this);\n return this.check();\n }\n\n // Normalize a quat\n normalize() {\n // Handle 0 case\n const length = this.len();\n const l = length > 0 ? 1 / length : 0;\n this[0] = this[0] * l;\n this[1] = this[1] * l;\n this[2] = this[2] * l;\n this[3] = this[3] * l;\n // Set to [0, 0, 0, 1] if length is 0\n if (length === 0) {\n this[3] = 1;\n }\n return this.check();\n }\n\n // Rotates a quaternion by the given angle about the X axis\n rotateX(rad) {\n quat.rotateX(this, this, rad);\n return this.check();\n }\n\n // Rotates a quaternion by the given angle about the Y axis\n rotateY(rad) {\n quat.rotateY(this, this, rad);\n return this.check();\n }\n\n // Rotates a quaternion by the given angle about the Z axis\n rotateZ(rad) {\n quat.rotateZ(this, this, rad);\n return this.check();\n }\n\n // Scales a quat by a scalar number\n scale(b) {\n quat.scale(this, this, b);\n return this.check();\n }\n\n // Performs a spherical linear interpolation between two quat\n slerp(start, target, ratio) {\n // eslint-disable-next-line prefer-rest-params\n switch (arguments.length) {\n case 1: // Deprecated signature ({start, target, ratio})\n // eslint-disable-next-line prefer-rest-params\n ({start = IDENTITY_QUATERNION, target, ratio} = arguments[0]);\n break;\n case 2: // THREE.js compatibility signature (target, ration)\n // eslint-disable-next-line prefer-rest-params\n [target, ratio] = arguments;\n start = this; // eslint-disable-line\n break;\n default: // Default signature: (start, target, ratio)\n }\n quat.slerp(this, start, target, ratio);\n return this.check();\n }\n\n transformVector4(vector, result = vector) {\n vec4.transformQuat(result, vector, this);\n return checkVector(result, 4);\n }\n\n // THREE.js Math API compatibility\n lengthSq() {\n return this.lengthSquared();\n }\n\n setFromAxisAngle(axis, rad) {\n return this.setAxisAngle(axis, rad);\n }\n\n premultiply(a, b) {\n return this.multiplyLeft(a, b);\n }\n\n multiply(a, b) {\n return this.multiplyRight(a, b);\n }\n}\n"],"file":"quaternion.js"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
class SphericalCoordinates {
|
|
13
|
+
constructor() {
|
|
14
|
+
(0, _defineProperty2.default)(this, "bearing", void 0);
|
|
15
|
+
(0, _defineProperty2.default)(this, "pitch", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "altitude", void 0);
|
|
17
|
+
(0, _defineProperty2.default)(this, "longitude", void 0);
|
|
18
|
+
(0, _defineProperty2.default)(this, "latitude", void 0);
|
|
19
|
+
(0, _defineProperty2.default)(this, "lng", void 0);
|
|
20
|
+
(0, _defineProperty2.default)(this, "lat", void 0);
|
|
21
|
+
(0, _defineProperty2.default)(this, "z", void 0);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.default = SphericalCoordinates;
|
|
27
|
+
//# sourceMappingURL=spherical-coordinates.d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/classes/spherical-coordinates.d.ts"],"names":["SphericalCoordinates"],"mappings":";;;;;;;;;;;AA0Ce,MAAMA,oBAAN,CAA2B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA","sourcesContent":["// Copyright (c) 2017 Uber Technologies, Inc.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n\n// Adaptation of THREE.js Spherical class, under MIT license\nimport Vector3 from './vector3';\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/**\n * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system\n * The poles (phi) are at the positive and negative y axis.\n * The equator starts at positive z.\n */\nexport default class SphericalCoordinates {\n // Todo [rho, theta, phi] ?\n\n // Cartographic (bearing 0 north, pitch 0 look from above)\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 * @param {Object} options\n * @param {Number} [options.phi] =0 - rotation around X (latitude)\n * @param {Number} [options.theta] =0 - rotation around Y (longitude)\n * @param {Number} [options.radius] =1 - Distance from center\n * @param {Number} [options.bearing]\n * @param {Number} [options.pitch]\n * @param {Number} [options.altitude]\n * @param {Number} [options.radiusScale] =1\n */\n constructor(options?: SphericalCoordinatesOptions);\n\n fromLngLatZ(lngLatZ: number[]): SphericalCoordinates;\n fromVector3(v: number[]): SphericalCoordinates;\n\n clone(): SphericalCoordinates;\n copy(other: SphericalCoordinates): SphericalCoordinates;\n set(radius: number, phi: number, theta: number): SphericalCoordinates;\n\n equals(other: SphericalCoordinates): boolean;\n exactEquals(other: SphericalCoordinates): boolean;\n\n toString(): string;\n formatString(options?: FormatOptions): string;\n toVector3(): Vector3;\n\n // restrict phi to be betwee EPS and PI-EPS\n makeSafe(): SphericalCoordinates;\n check(): SphericalCoordinates;\n}\n"],"file":"spherical-coordinates.d.js"}
|