@ohif/app 3.14.0-beta.98 → 3.14.0-beta.99
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/{1645.bundle.a98b9ca6.js → 1645.bundle.1a466b16.js} +600 -600
- package/dist/{1788.bundle.3f1349d2.js → 1788.bundle.962951f9.js} +26 -26
- package/dist/{1793.bundle.27458a55.js → 1793.bundle.30f89e46.js} +5 -3
- package/dist/{1862.bundle.79bfe469.js → 1862.bundle.3ae388c3.js} +2 -2
- package/dist/204.bundle.bc44c201.js +101 -0
- package/dist/204.bundle.css +52 -0
- package/dist/{2748.bundle.eaa94e2e.js → 2103.bundle.1cf348e8.js} +1 -1771
- package/dist/{2478.bundle.fc6ab30b.js → 2478.bundle.68ff1b2d.js} +2 -2
- package/dist/{2717.bundle.d5f58443.js → 2717.bundle.4318f1ee.js} +45 -43
- package/dist/{5989.bundle.f484884a.js → 287.bundle.ee60c370.js} +4570 -832
- package/dist/{2894.bundle.d612efb2.js → 2894.bundle.30c0af5b.js} +20 -14
- package/dist/{2991.bundle.f94892fb.js → 2991.bundle.77642eee.js} +101 -97
- package/dist/{3004.bundle.51919fdc.js → 3004.bundle.5568149a.js} +39 -38
- package/dist/{3255.bundle.13e205ac.js → 3255.bundle.3272671f.js} +29 -27
- package/dist/{3366.bundle.62baeeec.js → 3366.bundle.d9e78e25.js} +57 -53
- package/dist/{3468.bundle.f5dc5e44.js → 3468.bundle.666f2441.js} +37 -27
- package/dist/{347.bundle.397bb252.js → 347.bundle.1323658e.js} +44 -44
- package/dist/{3622.bundle.f4cf2d16.js → 3622.bundle.edb42b96.js} +56 -54
- package/dist/{3723.bundle.eab70100.js → 3723.bundle.43ff1971.js} +1 -1
- package/dist/{3771.bundle.aba09bd7.js → 3771.bundle.a5754f97.js} +8 -8
- package/dist/{4449.bundle.aaa4ab92.js → 4487.bundle.fa0375a4.js} +853 -95
- package/dist/{4606.bundle.a3485206.js → 4606.bundle.6c297e2a.js} +9 -7
- package/dist/{4998.bundle.3aedb48d.js → 4998.bundle.25b8cbfe.js} +5 -3
- package/dist/{5076.bundle.95c07142.js → 5076.bundle.2a14756f.js} +66 -66
- package/dist/{5143.bundle.04f54c00.js → 5143.bundle.53156bb0.js} +358 -226
- package/dist/{5154.bundle.2f460017.js → 5154.bundle.ccd02dd7.js} +5 -3
- package/dist/{5320.bundle.9b05cebb.js → 5320.bundle.c17eb4a7.js} +678 -546
- package/dist/{6212.bundle.e505e123.js → 6212.bundle.c4856be7.js} +48 -46
- package/dist/{6253.bundle.f74ac5c2.js → 6253.bundle.596ce463.js} +1225 -1145
- package/dist/{1153.bundle.51d39e80.js → 6314.bundle.5aadfe48.js} +199 -420
- package/dist/{641.bundle.4627a8e1.js → 641.bundle.8e45751e.js} +89 -89
- package/dist/{6481.bundle.d2fca485.js → 6481.bundle.85093e70.js} +29 -23
- package/dist/{6507.bundle.d52f5e81.js → 6507.bundle.bbcdd01e.js} +76 -76
- package/dist/{6722.bundle.d09a8aad.js → 6722.bundle.3e9a4ef6.js} +4 -4
- package/dist/{6956.bundle.c82fd790.js → 6956.bundle.dc0e8660.js} +33 -33
- package/dist/{7526.bundle.0685dfeb.js → 7526.bundle.3460c3ca.js} +55 -53
- package/dist/{7604.bundle.9eb317c8.js → 7604.bundle.f1eeded4.js} +2 -2
- package/dist/{8312.bundle.2cb75b58.js → 8312.bundle.d67b6f4e.js} +652 -687
- package/dist/{6847.bundle.b2adb444.js → 8729.bundle.e17fe9b2.js} +87 -845
- package/dist/{8788.bundle.4bb4c65b.js → 8788.bundle.83ddf642.js} +21 -20
- package/dist/{8868.bundle.4c357767.js → 8868.bundle.8f3653b3.js} +31 -31
- package/dist/{8923.bundle.9aca06c4.js → 8923.bundle.8b682e96.js} +148 -148
- package/dist/{899.bundle.9a033d16.js → 899.bundle.4e1aee7f.js} +73 -203
- package/dist/{9187.bundle.8f72b4fe.js → 9187.bundle.407afa07.js} +112 -110
- package/dist/9385.bundle.fb0bbf4a.js +1888 -0
- package/dist/{9481.bundle.ccb81f53.js → 9481.bundle.d045ae3a.js} +8 -6
- package/dist/{9517.bundle.1ae74db3.js → 9517.bundle.3e2896ef.js} +31 -17
- package/dist/{9620.bundle.d1dc0be1.js → 9620.bundle.b4cc392c.js} +63 -61
- package/dist/{9841.bundle.0f40f02b.js → 9841.bundle.4f2c401a.js} +93 -91
- package/dist/{9886.bundle.cabb4a24.js → 9886.bundle.b00d5d78.js} +4 -4
- package/dist/{8037.bundle.30a187f7.js → 9889.bundle.bf312047.js} +7743 -1098
- package/dist/{9948.bundle.1172ebca.js → 9948.bundle.fecf81f8.js} +5 -5
- package/dist/{app.bundle.51f0a437.js → app.bundle.bb359653.js} +1926 -1223
- package/dist/{compute.bundle.0ed1fe87.js → compute.bundle.9267d449.js} +13 -12
- package/dist/{histogram-worker.bundle.58e60d7c.js → histogram-worker.bundle.29bcdbf6.js} +6 -5
- package/dist/index.html +1 -1
- package/dist/{interpolation.bundle.5a53d112.js → interpolation.bundle.ee9998a4.js} +8 -7
- package/dist/{lib-router.bundle.a5ac870a.js → lib-router.bundle.2a887bc7.js} +334 -201
- package/dist/{polySeg.bundle.b4089601.js → polySeg.bundle.a55f8eee.js} +12 -12
- package/dist/sw.js +11 -1
- package/package.json +14 -19
- package/dist/1566.bundle.d58db206.js +0 -3610
|
@@ -1,3610 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
(globalThis["rspackChunk_ohif_app"] ||= []).push([[1566], {
|
|
3
|
-
39095(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
|
-
__webpack_require__.r(__webpack_exports__);
|
|
5
|
-
/* import */ var _common_js__rspack_import_0 = __webpack_require__(23172);
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
|
|
9
|
-
* @module mat4
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Creates a new identity mat4
|
|
14
|
-
*
|
|
15
|
-
* @returns {mat4} a new 4x4 matrix
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function create() {
|
|
19
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(16);
|
|
20
|
-
|
|
21
|
-
if (_common_js__rspack_import_0/* .ARRAY_TYPE */.tb != Float32Array) {
|
|
22
|
-
out[1] = 0;
|
|
23
|
-
out[2] = 0;
|
|
24
|
-
out[3] = 0;
|
|
25
|
-
out[4] = 0;
|
|
26
|
-
out[6] = 0;
|
|
27
|
-
out[7] = 0;
|
|
28
|
-
out[8] = 0;
|
|
29
|
-
out[9] = 0;
|
|
30
|
-
out[11] = 0;
|
|
31
|
-
out[12] = 0;
|
|
32
|
-
out[13] = 0;
|
|
33
|
-
out[14] = 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
out[0] = 1;
|
|
37
|
-
out[5] = 1;
|
|
38
|
-
out[10] = 1;
|
|
39
|
-
out[15] = 1;
|
|
40
|
-
return out;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Creates a new mat4 initialized with values from an existing matrix
|
|
44
|
-
*
|
|
45
|
-
* @param {ReadonlyMat4} a matrix to clone
|
|
46
|
-
* @returns {mat4} a new 4x4 matrix
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
function clone(a) {
|
|
50
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(16);
|
|
51
|
-
out[0] = a[0];
|
|
52
|
-
out[1] = a[1];
|
|
53
|
-
out[2] = a[2];
|
|
54
|
-
out[3] = a[3];
|
|
55
|
-
out[4] = a[4];
|
|
56
|
-
out[5] = a[5];
|
|
57
|
-
out[6] = a[6];
|
|
58
|
-
out[7] = a[7];
|
|
59
|
-
out[8] = a[8];
|
|
60
|
-
out[9] = a[9];
|
|
61
|
-
out[10] = a[10];
|
|
62
|
-
out[11] = a[11];
|
|
63
|
-
out[12] = a[12];
|
|
64
|
-
out[13] = a[13];
|
|
65
|
-
out[14] = a[14];
|
|
66
|
-
out[15] = a[15];
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Copy the values from one mat4 to another
|
|
71
|
-
*
|
|
72
|
-
* @param {mat4} out the receiving matrix
|
|
73
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
74
|
-
* @returns {mat4} out
|
|
75
|
-
*/
|
|
76
|
-
|
|
77
|
-
function copy(out, a) {
|
|
78
|
-
out[0] = a[0];
|
|
79
|
-
out[1] = a[1];
|
|
80
|
-
out[2] = a[2];
|
|
81
|
-
out[3] = a[3];
|
|
82
|
-
out[4] = a[4];
|
|
83
|
-
out[5] = a[5];
|
|
84
|
-
out[6] = a[6];
|
|
85
|
-
out[7] = a[7];
|
|
86
|
-
out[8] = a[8];
|
|
87
|
-
out[9] = a[9];
|
|
88
|
-
out[10] = a[10];
|
|
89
|
-
out[11] = a[11];
|
|
90
|
-
out[12] = a[12];
|
|
91
|
-
out[13] = a[13];
|
|
92
|
-
out[14] = a[14];
|
|
93
|
-
out[15] = a[15];
|
|
94
|
-
return out;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Create a new mat4 with the given values
|
|
98
|
-
*
|
|
99
|
-
* @param {Number} m00 Component in column 0, row 0 position (index 0)
|
|
100
|
-
* @param {Number} m01 Component in column 0, row 1 position (index 1)
|
|
101
|
-
* @param {Number} m02 Component in column 0, row 2 position (index 2)
|
|
102
|
-
* @param {Number} m03 Component in column 0, row 3 position (index 3)
|
|
103
|
-
* @param {Number} m10 Component in column 1, row 0 position (index 4)
|
|
104
|
-
* @param {Number} m11 Component in column 1, row 1 position (index 5)
|
|
105
|
-
* @param {Number} m12 Component in column 1, row 2 position (index 6)
|
|
106
|
-
* @param {Number} m13 Component in column 1, row 3 position (index 7)
|
|
107
|
-
* @param {Number} m20 Component in column 2, row 0 position (index 8)
|
|
108
|
-
* @param {Number} m21 Component in column 2, row 1 position (index 9)
|
|
109
|
-
* @param {Number} m22 Component in column 2, row 2 position (index 10)
|
|
110
|
-
* @param {Number} m23 Component in column 2, row 3 position (index 11)
|
|
111
|
-
* @param {Number} m30 Component in column 3, row 0 position (index 12)
|
|
112
|
-
* @param {Number} m31 Component in column 3, row 1 position (index 13)
|
|
113
|
-
* @param {Number} m32 Component in column 3, row 2 position (index 14)
|
|
114
|
-
* @param {Number} m33 Component in column 3, row 3 position (index 15)
|
|
115
|
-
* @returns {mat4} A new mat4
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
|
-
function fromValues(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
119
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(16);
|
|
120
|
-
out[0] = m00;
|
|
121
|
-
out[1] = m01;
|
|
122
|
-
out[2] = m02;
|
|
123
|
-
out[3] = m03;
|
|
124
|
-
out[4] = m10;
|
|
125
|
-
out[5] = m11;
|
|
126
|
-
out[6] = m12;
|
|
127
|
-
out[7] = m13;
|
|
128
|
-
out[8] = m20;
|
|
129
|
-
out[9] = m21;
|
|
130
|
-
out[10] = m22;
|
|
131
|
-
out[11] = m23;
|
|
132
|
-
out[12] = m30;
|
|
133
|
-
out[13] = m31;
|
|
134
|
-
out[14] = m32;
|
|
135
|
-
out[15] = m33;
|
|
136
|
-
return out;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Set the components of a mat4 to the given values
|
|
140
|
-
*
|
|
141
|
-
* @param {mat4} out the receiving matrix
|
|
142
|
-
* @param {Number} m00 Component in column 0, row 0 position (index 0)
|
|
143
|
-
* @param {Number} m01 Component in column 0, row 1 position (index 1)
|
|
144
|
-
* @param {Number} m02 Component in column 0, row 2 position (index 2)
|
|
145
|
-
* @param {Number} m03 Component in column 0, row 3 position (index 3)
|
|
146
|
-
* @param {Number} m10 Component in column 1, row 0 position (index 4)
|
|
147
|
-
* @param {Number} m11 Component in column 1, row 1 position (index 5)
|
|
148
|
-
* @param {Number} m12 Component in column 1, row 2 position (index 6)
|
|
149
|
-
* @param {Number} m13 Component in column 1, row 3 position (index 7)
|
|
150
|
-
* @param {Number} m20 Component in column 2, row 0 position (index 8)
|
|
151
|
-
* @param {Number} m21 Component in column 2, row 1 position (index 9)
|
|
152
|
-
* @param {Number} m22 Component in column 2, row 2 position (index 10)
|
|
153
|
-
* @param {Number} m23 Component in column 2, row 3 position (index 11)
|
|
154
|
-
* @param {Number} m30 Component in column 3, row 0 position (index 12)
|
|
155
|
-
* @param {Number} m31 Component in column 3, row 1 position (index 13)
|
|
156
|
-
* @param {Number} m32 Component in column 3, row 2 position (index 14)
|
|
157
|
-
* @param {Number} m33 Component in column 3, row 3 position (index 15)
|
|
158
|
-
* @returns {mat4} out
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
function set(out, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
162
|
-
out[0] = m00;
|
|
163
|
-
out[1] = m01;
|
|
164
|
-
out[2] = m02;
|
|
165
|
-
out[3] = m03;
|
|
166
|
-
out[4] = m10;
|
|
167
|
-
out[5] = m11;
|
|
168
|
-
out[6] = m12;
|
|
169
|
-
out[7] = m13;
|
|
170
|
-
out[8] = m20;
|
|
171
|
-
out[9] = m21;
|
|
172
|
-
out[10] = m22;
|
|
173
|
-
out[11] = m23;
|
|
174
|
-
out[12] = m30;
|
|
175
|
-
out[13] = m31;
|
|
176
|
-
out[14] = m32;
|
|
177
|
-
out[15] = m33;
|
|
178
|
-
return out;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Set a mat4 to the identity matrix
|
|
182
|
-
*
|
|
183
|
-
* @param {mat4} out the receiving matrix
|
|
184
|
-
* @returns {mat4} out
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
function identity(out) {
|
|
188
|
-
out[0] = 1;
|
|
189
|
-
out[1] = 0;
|
|
190
|
-
out[2] = 0;
|
|
191
|
-
out[3] = 0;
|
|
192
|
-
out[4] = 0;
|
|
193
|
-
out[5] = 1;
|
|
194
|
-
out[6] = 0;
|
|
195
|
-
out[7] = 0;
|
|
196
|
-
out[8] = 0;
|
|
197
|
-
out[9] = 0;
|
|
198
|
-
out[10] = 1;
|
|
199
|
-
out[11] = 0;
|
|
200
|
-
out[12] = 0;
|
|
201
|
-
out[13] = 0;
|
|
202
|
-
out[14] = 0;
|
|
203
|
-
out[15] = 1;
|
|
204
|
-
return out;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Transpose the values of a mat4
|
|
208
|
-
*
|
|
209
|
-
* @param {mat4} out the receiving matrix
|
|
210
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
211
|
-
* @returns {mat4} out
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
function transpose(out, a) {
|
|
215
|
-
// If we are transposing ourselves we can skip a few steps but have to cache some values
|
|
216
|
-
if (out === a) {
|
|
217
|
-
var a01 = a[1],
|
|
218
|
-
a02 = a[2],
|
|
219
|
-
a03 = a[3];
|
|
220
|
-
var a12 = a[6],
|
|
221
|
-
a13 = a[7];
|
|
222
|
-
var a23 = a[11];
|
|
223
|
-
out[1] = a[4];
|
|
224
|
-
out[2] = a[8];
|
|
225
|
-
out[3] = a[12];
|
|
226
|
-
out[4] = a01;
|
|
227
|
-
out[6] = a[9];
|
|
228
|
-
out[7] = a[13];
|
|
229
|
-
out[8] = a02;
|
|
230
|
-
out[9] = a12;
|
|
231
|
-
out[11] = a[14];
|
|
232
|
-
out[12] = a03;
|
|
233
|
-
out[13] = a13;
|
|
234
|
-
out[14] = a23;
|
|
235
|
-
} else {
|
|
236
|
-
out[0] = a[0];
|
|
237
|
-
out[1] = a[4];
|
|
238
|
-
out[2] = a[8];
|
|
239
|
-
out[3] = a[12];
|
|
240
|
-
out[4] = a[1];
|
|
241
|
-
out[5] = a[5];
|
|
242
|
-
out[6] = a[9];
|
|
243
|
-
out[7] = a[13];
|
|
244
|
-
out[8] = a[2];
|
|
245
|
-
out[9] = a[6];
|
|
246
|
-
out[10] = a[10];
|
|
247
|
-
out[11] = a[14];
|
|
248
|
-
out[12] = a[3];
|
|
249
|
-
out[13] = a[7];
|
|
250
|
-
out[14] = a[11];
|
|
251
|
-
out[15] = a[15];
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return out;
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* Inverts a mat4
|
|
258
|
-
*
|
|
259
|
-
* @param {mat4} out the receiving matrix
|
|
260
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
261
|
-
* @returns {mat4} out
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
function invert(out, a) {
|
|
265
|
-
var a00 = a[0],
|
|
266
|
-
a01 = a[1],
|
|
267
|
-
a02 = a[2],
|
|
268
|
-
a03 = a[3];
|
|
269
|
-
var a10 = a[4],
|
|
270
|
-
a11 = a[5],
|
|
271
|
-
a12 = a[6],
|
|
272
|
-
a13 = a[7];
|
|
273
|
-
var a20 = a[8],
|
|
274
|
-
a21 = a[9],
|
|
275
|
-
a22 = a[10],
|
|
276
|
-
a23 = a[11];
|
|
277
|
-
var a30 = a[12],
|
|
278
|
-
a31 = a[13],
|
|
279
|
-
a32 = a[14],
|
|
280
|
-
a33 = a[15];
|
|
281
|
-
var b00 = a00 * a11 - a01 * a10;
|
|
282
|
-
var b01 = a00 * a12 - a02 * a10;
|
|
283
|
-
var b02 = a00 * a13 - a03 * a10;
|
|
284
|
-
var b03 = a01 * a12 - a02 * a11;
|
|
285
|
-
var b04 = a01 * a13 - a03 * a11;
|
|
286
|
-
var b05 = a02 * a13 - a03 * a12;
|
|
287
|
-
var b06 = a20 * a31 - a21 * a30;
|
|
288
|
-
var b07 = a20 * a32 - a22 * a30;
|
|
289
|
-
var b08 = a20 * a33 - a23 * a30;
|
|
290
|
-
var b09 = a21 * a32 - a22 * a31;
|
|
291
|
-
var b10 = a21 * a33 - a23 * a31;
|
|
292
|
-
var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
|
|
293
|
-
|
|
294
|
-
var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
295
|
-
|
|
296
|
-
if (!det) {
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
det = 1.0 / det;
|
|
301
|
-
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
|
|
302
|
-
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
|
|
303
|
-
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
|
|
304
|
-
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
|
|
305
|
-
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
|
|
306
|
-
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
|
|
307
|
-
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
|
|
308
|
-
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
|
|
309
|
-
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
|
|
310
|
-
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
|
|
311
|
-
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
|
|
312
|
-
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
|
|
313
|
-
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
|
|
314
|
-
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
|
|
315
|
-
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
|
|
316
|
-
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
|
|
317
|
-
return out;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Calculates the adjugate of a mat4
|
|
321
|
-
*
|
|
322
|
-
* @param {mat4} out the receiving matrix
|
|
323
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
324
|
-
* @returns {mat4} out
|
|
325
|
-
*/
|
|
326
|
-
|
|
327
|
-
function adjoint(out, a) {
|
|
328
|
-
var a00 = a[0],
|
|
329
|
-
a01 = a[1],
|
|
330
|
-
a02 = a[2],
|
|
331
|
-
a03 = a[3];
|
|
332
|
-
var a10 = a[4],
|
|
333
|
-
a11 = a[5],
|
|
334
|
-
a12 = a[6],
|
|
335
|
-
a13 = a[7];
|
|
336
|
-
var a20 = a[8],
|
|
337
|
-
a21 = a[9],
|
|
338
|
-
a22 = a[10],
|
|
339
|
-
a23 = a[11];
|
|
340
|
-
var a30 = a[12],
|
|
341
|
-
a31 = a[13],
|
|
342
|
-
a32 = a[14],
|
|
343
|
-
a33 = a[15];
|
|
344
|
-
out[0] = a11 * (a22 * a33 - a23 * a32) - a21 * (a12 * a33 - a13 * a32) + a31 * (a12 * a23 - a13 * a22);
|
|
345
|
-
out[1] = -(a01 * (a22 * a33 - a23 * a32) - a21 * (a02 * a33 - a03 * a32) + a31 * (a02 * a23 - a03 * a22));
|
|
346
|
-
out[2] = a01 * (a12 * a33 - a13 * a32) - a11 * (a02 * a33 - a03 * a32) + a31 * (a02 * a13 - a03 * a12);
|
|
347
|
-
out[3] = -(a01 * (a12 * a23 - a13 * a22) - a11 * (a02 * a23 - a03 * a22) + a21 * (a02 * a13 - a03 * a12));
|
|
348
|
-
out[4] = -(a10 * (a22 * a33 - a23 * a32) - a20 * (a12 * a33 - a13 * a32) + a30 * (a12 * a23 - a13 * a22));
|
|
349
|
-
out[5] = a00 * (a22 * a33 - a23 * a32) - a20 * (a02 * a33 - a03 * a32) + a30 * (a02 * a23 - a03 * a22);
|
|
350
|
-
out[6] = -(a00 * (a12 * a33 - a13 * a32) - a10 * (a02 * a33 - a03 * a32) + a30 * (a02 * a13 - a03 * a12));
|
|
351
|
-
out[7] = a00 * (a12 * a23 - a13 * a22) - a10 * (a02 * a23 - a03 * a22) + a20 * (a02 * a13 - a03 * a12);
|
|
352
|
-
out[8] = a10 * (a21 * a33 - a23 * a31) - a20 * (a11 * a33 - a13 * a31) + a30 * (a11 * a23 - a13 * a21);
|
|
353
|
-
out[9] = -(a00 * (a21 * a33 - a23 * a31) - a20 * (a01 * a33 - a03 * a31) + a30 * (a01 * a23 - a03 * a21));
|
|
354
|
-
out[10] = a00 * (a11 * a33 - a13 * a31) - a10 * (a01 * a33 - a03 * a31) + a30 * (a01 * a13 - a03 * a11);
|
|
355
|
-
out[11] = -(a00 * (a11 * a23 - a13 * a21) - a10 * (a01 * a23 - a03 * a21) + a20 * (a01 * a13 - a03 * a11));
|
|
356
|
-
out[12] = -(a10 * (a21 * a32 - a22 * a31) - a20 * (a11 * a32 - a12 * a31) + a30 * (a11 * a22 - a12 * a21));
|
|
357
|
-
out[13] = a00 * (a21 * a32 - a22 * a31) - a20 * (a01 * a32 - a02 * a31) + a30 * (a01 * a22 - a02 * a21);
|
|
358
|
-
out[14] = -(a00 * (a11 * a32 - a12 * a31) - a10 * (a01 * a32 - a02 * a31) + a30 * (a01 * a12 - a02 * a11));
|
|
359
|
-
out[15] = a00 * (a11 * a22 - a12 * a21) - a10 * (a01 * a22 - a02 * a21) + a20 * (a01 * a12 - a02 * a11);
|
|
360
|
-
return out;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Calculates the determinant of a mat4
|
|
364
|
-
*
|
|
365
|
-
* @param {ReadonlyMat4} a the source matrix
|
|
366
|
-
* @returns {Number} determinant of a
|
|
367
|
-
*/
|
|
368
|
-
|
|
369
|
-
function determinant(a) {
|
|
370
|
-
var a00 = a[0],
|
|
371
|
-
a01 = a[1],
|
|
372
|
-
a02 = a[2],
|
|
373
|
-
a03 = a[3];
|
|
374
|
-
var a10 = a[4],
|
|
375
|
-
a11 = a[5],
|
|
376
|
-
a12 = a[6],
|
|
377
|
-
a13 = a[7];
|
|
378
|
-
var a20 = a[8],
|
|
379
|
-
a21 = a[9],
|
|
380
|
-
a22 = a[10],
|
|
381
|
-
a23 = a[11];
|
|
382
|
-
var a30 = a[12],
|
|
383
|
-
a31 = a[13],
|
|
384
|
-
a32 = a[14],
|
|
385
|
-
a33 = a[15];
|
|
386
|
-
var b00 = a00 * a11 - a01 * a10;
|
|
387
|
-
var b01 = a00 * a12 - a02 * a10;
|
|
388
|
-
var b02 = a00 * a13 - a03 * a10;
|
|
389
|
-
var b03 = a01 * a12 - a02 * a11;
|
|
390
|
-
var b04 = a01 * a13 - a03 * a11;
|
|
391
|
-
var b05 = a02 * a13 - a03 * a12;
|
|
392
|
-
var b06 = a20 * a31 - a21 * a30;
|
|
393
|
-
var b07 = a20 * a32 - a22 * a30;
|
|
394
|
-
var b08 = a20 * a33 - a23 * a30;
|
|
395
|
-
var b09 = a21 * a32 - a22 * a31;
|
|
396
|
-
var b10 = a21 * a33 - a23 * a31;
|
|
397
|
-
var b11 = a22 * a33 - a23 * a32; // Calculate the determinant
|
|
398
|
-
|
|
399
|
-
return b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Multiplies two mat4s
|
|
403
|
-
*
|
|
404
|
-
* @param {mat4} out the receiving matrix
|
|
405
|
-
* @param {ReadonlyMat4} a the first operand
|
|
406
|
-
* @param {ReadonlyMat4} b the second operand
|
|
407
|
-
* @returns {mat4} out
|
|
408
|
-
*/
|
|
409
|
-
|
|
410
|
-
function multiply(out, a, b) {
|
|
411
|
-
var a00 = a[0],
|
|
412
|
-
a01 = a[1],
|
|
413
|
-
a02 = a[2],
|
|
414
|
-
a03 = a[3];
|
|
415
|
-
var a10 = a[4],
|
|
416
|
-
a11 = a[5],
|
|
417
|
-
a12 = a[6],
|
|
418
|
-
a13 = a[7];
|
|
419
|
-
var a20 = a[8],
|
|
420
|
-
a21 = a[9],
|
|
421
|
-
a22 = a[10],
|
|
422
|
-
a23 = a[11];
|
|
423
|
-
var a30 = a[12],
|
|
424
|
-
a31 = a[13],
|
|
425
|
-
a32 = a[14],
|
|
426
|
-
a33 = a[15]; // Cache only the current line of the second matrix
|
|
427
|
-
|
|
428
|
-
var b0 = b[0],
|
|
429
|
-
b1 = b[1],
|
|
430
|
-
b2 = b[2],
|
|
431
|
-
b3 = b[3];
|
|
432
|
-
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
433
|
-
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
434
|
-
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
435
|
-
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
436
|
-
b0 = b[4];
|
|
437
|
-
b1 = b[5];
|
|
438
|
-
b2 = b[6];
|
|
439
|
-
b3 = b[7];
|
|
440
|
-
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
441
|
-
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
442
|
-
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
443
|
-
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
444
|
-
b0 = b[8];
|
|
445
|
-
b1 = b[9];
|
|
446
|
-
b2 = b[10];
|
|
447
|
-
b3 = b[11];
|
|
448
|
-
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
449
|
-
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
450
|
-
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
451
|
-
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
452
|
-
b0 = b[12];
|
|
453
|
-
b1 = b[13];
|
|
454
|
-
b2 = b[14];
|
|
455
|
-
b3 = b[15];
|
|
456
|
-
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
|
|
457
|
-
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
|
|
458
|
-
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
|
|
459
|
-
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
|
|
460
|
-
return out;
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
* Translate a mat4 by the given vector
|
|
464
|
-
*
|
|
465
|
-
* @param {mat4} out the receiving matrix
|
|
466
|
-
* @param {ReadonlyMat4} a the matrix to translate
|
|
467
|
-
* @param {ReadonlyVec3} v vector to translate by
|
|
468
|
-
* @returns {mat4} out
|
|
469
|
-
*/
|
|
470
|
-
|
|
471
|
-
function translate(out, a, v) {
|
|
472
|
-
var x = v[0],
|
|
473
|
-
y = v[1],
|
|
474
|
-
z = v[2];
|
|
475
|
-
var a00, a01, a02, a03;
|
|
476
|
-
var a10, a11, a12, a13;
|
|
477
|
-
var a20, a21, a22, a23;
|
|
478
|
-
|
|
479
|
-
if (a === out) {
|
|
480
|
-
out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
|
|
481
|
-
out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
|
|
482
|
-
out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
|
|
483
|
-
out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
|
|
484
|
-
} else {
|
|
485
|
-
a00 = a[0];
|
|
486
|
-
a01 = a[1];
|
|
487
|
-
a02 = a[2];
|
|
488
|
-
a03 = a[3];
|
|
489
|
-
a10 = a[4];
|
|
490
|
-
a11 = a[5];
|
|
491
|
-
a12 = a[6];
|
|
492
|
-
a13 = a[7];
|
|
493
|
-
a20 = a[8];
|
|
494
|
-
a21 = a[9];
|
|
495
|
-
a22 = a[10];
|
|
496
|
-
a23 = a[11];
|
|
497
|
-
out[0] = a00;
|
|
498
|
-
out[1] = a01;
|
|
499
|
-
out[2] = a02;
|
|
500
|
-
out[3] = a03;
|
|
501
|
-
out[4] = a10;
|
|
502
|
-
out[5] = a11;
|
|
503
|
-
out[6] = a12;
|
|
504
|
-
out[7] = a13;
|
|
505
|
-
out[8] = a20;
|
|
506
|
-
out[9] = a21;
|
|
507
|
-
out[10] = a22;
|
|
508
|
-
out[11] = a23;
|
|
509
|
-
out[12] = a00 * x + a10 * y + a20 * z + a[12];
|
|
510
|
-
out[13] = a01 * x + a11 * y + a21 * z + a[13];
|
|
511
|
-
out[14] = a02 * x + a12 * y + a22 * z + a[14];
|
|
512
|
-
out[15] = a03 * x + a13 * y + a23 * z + a[15];
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
return out;
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* Scales the mat4 by the dimensions in the given vec3 not using vectorization
|
|
519
|
-
*
|
|
520
|
-
* @param {mat4} out the receiving matrix
|
|
521
|
-
* @param {ReadonlyMat4} a the matrix to scale
|
|
522
|
-
* @param {ReadonlyVec3} v the vec3 to scale the matrix by
|
|
523
|
-
* @returns {mat4} out
|
|
524
|
-
**/
|
|
525
|
-
|
|
526
|
-
function scale(out, a, v) {
|
|
527
|
-
var x = v[0],
|
|
528
|
-
y = v[1],
|
|
529
|
-
z = v[2];
|
|
530
|
-
out[0] = a[0] * x;
|
|
531
|
-
out[1] = a[1] * x;
|
|
532
|
-
out[2] = a[2] * x;
|
|
533
|
-
out[3] = a[3] * x;
|
|
534
|
-
out[4] = a[4] * y;
|
|
535
|
-
out[5] = a[5] * y;
|
|
536
|
-
out[6] = a[6] * y;
|
|
537
|
-
out[7] = a[7] * y;
|
|
538
|
-
out[8] = a[8] * z;
|
|
539
|
-
out[9] = a[9] * z;
|
|
540
|
-
out[10] = a[10] * z;
|
|
541
|
-
out[11] = a[11] * z;
|
|
542
|
-
out[12] = a[12];
|
|
543
|
-
out[13] = a[13];
|
|
544
|
-
out[14] = a[14];
|
|
545
|
-
out[15] = a[15];
|
|
546
|
-
return out;
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Rotates a mat4 by the given angle around the given axis
|
|
550
|
-
*
|
|
551
|
-
* @param {mat4} out the receiving matrix
|
|
552
|
-
* @param {ReadonlyMat4} a the matrix to rotate
|
|
553
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
554
|
-
* @param {ReadonlyVec3} axis the axis to rotate around
|
|
555
|
-
* @returns {mat4} out
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
function rotate(out, a, rad, axis) {
|
|
559
|
-
var x = axis[0],
|
|
560
|
-
y = axis[1],
|
|
561
|
-
z = axis[2];
|
|
562
|
-
var len = Math.hypot(x, y, z);
|
|
563
|
-
var s, c, t;
|
|
564
|
-
var a00, a01, a02, a03;
|
|
565
|
-
var a10, a11, a12, a13;
|
|
566
|
-
var a20, a21, a22, a23;
|
|
567
|
-
var b00, b01, b02;
|
|
568
|
-
var b10, b11, b12;
|
|
569
|
-
var b20, b21, b22;
|
|
570
|
-
|
|
571
|
-
if (len < _common_js__rspack_import_0/* .EPSILON */.p8) {
|
|
572
|
-
return null;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
len = 1 / len;
|
|
576
|
-
x *= len;
|
|
577
|
-
y *= len;
|
|
578
|
-
z *= len;
|
|
579
|
-
s = Math.sin(rad);
|
|
580
|
-
c = Math.cos(rad);
|
|
581
|
-
t = 1 - c;
|
|
582
|
-
a00 = a[0];
|
|
583
|
-
a01 = a[1];
|
|
584
|
-
a02 = a[2];
|
|
585
|
-
a03 = a[3];
|
|
586
|
-
a10 = a[4];
|
|
587
|
-
a11 = a[5];
|
|
588
|
-
a12 = a[6];
|
|
589
|
-
a13 = a[7];
|
|
590
|
-
a20 = a[8];
|
|
591
|
-
a21 = a[9];
|
|
592
|
-
a22 = a[10];
|
|
593
|
-
a23 = a[11]; // Construct the elements of the rotation matrix
|
|
594
|
-
|
|
595
|
-
b00 = x * x * t + c;
|
|
596
|
-
b01 = y * x * t + z * s;
|
|
597
|
-
b02 = z * x * t - y * s;
|
|
598
|
-
b10 = x * y * t - z * s;
|
|
599
|
-
b11 = y * y * t + c;
|
|
600
|
-
b12 = z * y * t + x * s;
|
|
601
|
-
b20 = x * z * t + y * s;
|
|
602
|
-
b21 = y * z * t - x * s;
|
|
603
|
-
b22 = z * z * t + c; // Perform rotation-specific matrix multiplication
|
|
604
|
-
|
|
605
|
-
out[0] = a00 * b00 + a10 * b01 + a20 * b02;
|
|
606
|
-
out[1] = a01 * b00 + a11 * b01 + a21 * b02;
|
|
607
|
-
out[2] = a02 * b00 + a12 * b01 + a22 * b02;
|
|
608
|
-
out[3] = a03 * b00 + a13 * b01 + a23 * b02;
|
|
609
|
-
out[4] = a00 * b10 + a10 * b11 + a20 * b12;
|
|
610
|
-
out[5] = a01 * b10 + a11 * b11 + a21 * b12;
|
|
611
|
-
out[6] = a02 * b10 + a12 * b11 + a22 * b12;
|
|
612
|
-
out[7] = a03 * b10 + a13 * b11 + a23 * b12;
|
|
613
|
-
out[8] = a00 * b20 + a10 * b21 + a20 * b22;
|
|
614
|
-
out[9] = a01 * b20 + a11 * b21 + a21 * b22;
|
|
615
|
-
out[10] = a02 * b20 + a12 * b21 + a22 * b22;
|
|
616
|
-
out[11] = a03 * b20 + a13 * b21 + a23 * b22;
|
|
617
|
-
|
|
618
|
-
if (a !== out) {
|
|
619
|
-
// If the source and destination differ, copy the unchanged last row
|
|
620
|
-
out[12] = a[12];
|
|
621
|
-
out[13] = a[13];
|
|
622
|
-
out[14] = a[14];
|
|
623
|
-
out[15] = a[15];
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
return out;
|
|
627
|
-
}
|
|
628
|
-
/**
|
|
629
|
-
* Rotates a matrix by the given angle around the X axis
|
|
630
|
-
*
|
|
631
|
-
* @param {mat4} out the receiving matrix
|
|
632
|
-
* @param {ReadonlyMat4} a the matrix to rotate
|
|
633
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
634
|
-
* @returns {mat4} out
|
|
635
|
-
*/
|
|
636
|
-
|
|
637
|
-
function rotateX(out, a, rad) {
|
|
638
|
-
var s = Math.sin(rad);
|
|
639
|
-
var c = Math.cos(rad);
|
|
640
|
-
var a10 = a[4];
|
|
641
|
-
var a11 = a[5];
|
|
642
|
-
var a12 = a[6];
|
|
643
|
-
var a13 = a[7];
|
|
644
|
-
var a20 = a[8];
|
|
645
|
-
var a21 = a[9];
|
|
646
|
-
var a22 = a[10];
|
|
647
|
-
var a23 = a[11];
|
|
648
|
-
|
|
649
|
-
if (a !== out) {
|
|
650
|
-
// If the source and destination differ, copy the unchanged rows
|
|
651
|
-
out[0] = a[0];
|
|
652
|
-
out[1] = a[1];
|
|
653
|
-
out[2] = a[2];
|
|
654
|
-
out[3] = a[3];
|
|
655
|
-
out[12] = a[12];
|
|
656
|
-
out[13] = a[13];
|
|
657
|
-
out[14] = a[14];
|
|
658
|
-
out[15] = a[15];
|
|
659
|
-
} // Perform axis-specific matrix multiplication
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
out[4] = a10 * c + a20 * s;
|
|
663
|
-
out[5] = a11 * c + a21 * s;
|
|
664
|
-
out[6] = a12 * c + a22 * s;
|
|
665
|
-
out[7] = a13 * c + a23 * s;
|
|
666
|
-
out[8] = a20 * c - a10 * s;
|
|
667
|
-
out[9] = a21 * c - a11 * s;
|
|
668
|
-
out[10] = a22 * c - a12 * s;
|
|
669
|
-
out[11] = a23 * c - a13 * s;
|
|
670
|
-
return out;
|
|
671
|
-
}
|
|
672
|
-
/**
|
|
673
|
-
* Rotates a matrix by the given angle around the Y axis
|
|
674
|
-
*
|
|
675
|
-
* @param {mat4} out the receiving matrix
|
|
676
|
-
* @param {ReadonlyMat4} a the matrix to rotate
|
|
677
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
678
|
-
* @returns {mat4} out
|
|
679
|
-
*/
|
|
680
|
-
|
|
681
|
-
function rotateY(out, a, rad) {
|
|
682
|
-
var s = Math.sin(rad);
|
|
683
|
-
var c = Math.cos(rad);
|
|
684
|
-
var a00 = a[0];
|
|
685
|
-
var a01 = a[1];
|
|
686
|
-
var a02 = a[2];
|
|
687
|
-
var a03 = a[3];
|
|
688
|
-
var a20 = a[8];
|
|
689
|
-
var a21 = a[9];
|
|
690
|
-
var a22 = a[10];
|
|
691
|
-
var a23 = a[11];
|
|
692
|
-
|
|
693
|
-
if (a !== out) {
|
|
694
|
-
// If the source and destination differ, copy the unchanged rows
|
|
695
|
-
out[4] = a[4];
|
|
696
|
-
out[5] = a[5];
|
|
697
|
-
out[6] = a[6];
|
|
698
|
-
out[7] = a[7];
|
|
699
|
-
out[12] = a[12];
|
|
700
|
-
out[13] = a[13];
|
|
701
|
-
out[14] = a[14];
|
|
702
|
-
out[15] = a[15];
|
|
703
|
-
} // Perform axis-specific matrix multiplication
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
out[0] = a00 * c - a20 * s;
|
|
707
|
-
out[1] = a01 * c - a21 * s;
|
|
708
|
-
out[2] = a02 * c - a22 * s;
|
|
709
|
-
out[3] = a03 * c - a23 * s;
|
|
710
|
-
out[8] = a00 * s + a20 * c;
|
|
711
|
-
out[9] = a01 * s + a21 * c;
|
|
712
|
-
out[10] = a02 * s + a22 * c;
|
|
713
|
-
out[11] = a03 * s + a23 * c;
|
|
714
|
-
return out;
|
|
715
|
-
}
|
|
716
|
-
/**
|
|
717
|
-
* Rotates a matrix by the given angle around the Z axis
|
|
718
|
-
*
|
|
719
|
-
* @param {mat4} out the receiving matrix
|
|
720
|
-
* @param {ReadonlyMat4} a the matrix to rotate
|
|
721
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
722
|
-
* @returns {mat4} out
|
|
723
|
-
*/
|
|
724
|
-
|
|
725
|
-
function rotateZ(out, a, rad) {
|
|
726
|
-
var s = Math.sin(rad);
|
|
727
|
-
var c = Math.cos(rad);
|
|
728
|
-
var a00 = a[0];
|
|
729
|
-
var a01 = a[1];
|
|
730
|
-
var a02 = a[2];
|
|
731
|
-
var a03 = a[3];
|
|
732
|
-
var a10 = a[4];
|
|
733
|
-
var a11 = a[5];
|
|
734
|
-
var a12 = a[6];
|
|
735
|
-
var a13 = a[7];
|
|
736
|
-
|
|
737
|
-
if (a !== out) {
|
|
738
|
-
// If the source and destination differ, copy the unchanged last row
|
|
739
|
-
out[8] = a[8];
|
|
740
|
-
out[9] = a[9];
|
|
741
|
-
out[10] = a[10];
|
|
742
|
-
out[11] = a[11];
|
|
743
|
-
out[12] = a[12];
|
|
744
|
-
out[13] = a[13];
|
|
745
|
-
out[14] = a[14];
|
|
746
|
-
out[15] = a[15];
|
|
747
|
-
} // Perform axis-specific matrix multiplication
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
out[0] = a00 * c + a10 * s;
|
|
751
|
-
out[1] = a01 * c + a11 * s;
|
|
752
|
-
out[2] = a02 * c + a12 * s;
|
|
753
|
-
out[3] = a03 * c + a13 * s;
|
|
754
|
-
out[4] = a10 * c - a00 * s;
|
|
755
|
-
out[5] = a11 * c - a01 * s;
|
|
756
|
-
out[6] = a12 * c - a02 * s;
|
|
757
|
-
out[7] = a13 * c - a03 * s;
|
|
758
|
-
return out;
|
|
759
|
-
}
|
|
760
|
-
/**
|
|
761
|
-
* Creates a matrix from a vector translation
|
|
762
|
-
* This is equivalent to (but much faster than):
|
|
763
|
-
*
|
|
764
|
-
* mat4.identity(dest);
|
|
765
|
-
* mat4.translate(dest, dest, vec);
|
|
766
|
-
*
|
|
767
|
-
* @param {mat4} out mat4 receiving operation result
|
|
768
|
-
* @param {ReadonlyVec3} v Translation vector
|
|
769
|
-
* @returns {mat4} out
|
|
770
|
-
*/
|
|
771
|
-
|
|
772
|
-
function fromTranslation(out, v) {
|
|
773
|
-
out[0] = 1;
|
|
774
|
-
out[1] = 0;
|
|
775
|
-
out[2] = 0;
|
|
776
|
-
out[3] = 0;
|
|
777
|
-
out[4] = 0;
|
|
778
|
-
out[5] = 1;
|
|
779
|
-
out[6] = 0;
|
|
780
|
-
out[7] = 0;
|
|
781
|
-
out[8] = 0;
|
|
782
|
-
out[9] = 0;
|
|
783
|
-
out[10] = 1;
|
|
784
|
-
out[11] = 0;
|
|
785
|
-
out[12] = v[0];
|
|
786
|
-
out[13] = v[1];
|
|
787
|
-
out[14] = v[2];
|
|
788
|
-
out[15] = 1;
|
|
789
|
-
return out;
|
|
790
|
-
}
|
|
791
|
-
/**
|
|
792
|
-
* Creates a matrix from a vector scaling
|
|
793
|
-
* This is equivalent to (but much faster than):
|
|
794
|
-
*
|
|
795
|
-
* mat4.identity(dest);
|
|
796
|
-
* mat4.scale(dest, dest, vec);
|
|
797
|
-
*
|
|
798
|
-
* @param {mat4} out mat4 receiving operation result
|
|
799
|
-
* @param {ReadonlyVec3} v Scaling vector
|
|
800
|
-
* @returns {mat4} out
|
|
801
|
-
*/
|
|
802
|
-
|
|
803
|
-
function fromScaling(out, v) {
|
|
804
|
-
out[0] = v[0];
|
|
805
|
-
out[1] = 0;
|
|
806
|
-
out[2] = 0;
|
|
807
|
-
out[3] = 0;
|
|
808
|
-
out[4] = 0;
|
|
809
|
-
out[5] = v[1];
|
|
810
|
-
out[6] = 0;
|
|
811
|
-
out[7] = 0;
|
|
812
|
-
out[8] = 0;
|
|
813
|
-
out[9] = 0;
|
|
814
|
-
out[10] = v[2];
|
|
815
|
-
out[11] = 0;
|
|
816
|
-
out[12] = 0;
|
|
817
|
-
out[13] = 0;
|
|
818
|
-
out[14] = 0;
|
|
819
|
-
out[15] = 1;
|
|
820
|
-
return out;
|
|
821
|
-
}
|
|
822
|
-
/**
|
|
823
|
-
* Creates a matrix from a given angle around a given axis
|
|
824
|
-
* This is equivalent to (but much faster than):
|
|
825
|
-
*
|
|
826
|
-
* mat4.identity(dest);
|
|
827
|
-
* mat4.rotate(dest, dest, rad, axis);
|
|
828
|
-
*
|
|
829
|
-
* @param {mat4} out mat4 receiving operation result
|
|
830
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
831
|
-
* @param {ReadonlyVec3} axis the axis to rotate around
|
|
832
|
-
* @returns {mat4} out
|
|
833
|
-
*/
|
|
834
|
-
|
|
835
|
-
function fromRotation(out, rad, axis) {
|
|
836
|
-
var x = axis[0],
|
|
837
|
-
y = axis[1],
|
|
838
|
-
z = axis[2];
|
|
839
|
-
var len = Math.hypot(x, y, z);
|
|
840
|
-
var s, c, t;
|
|
841
|
-
|
|
842
|
-
if (len < _common_js__rspack_import_0/* .EPSILON */.p8) {
|
|
843
|
-
return null;
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
len = 1 / len;
|
|
847
|
-
x *= len;
|
|
848
|
-
y *= len;
|
|
849
|
-
z *= len;
|
|
850
|
-
s = Math.sin(rad);
|
|
851
|
-
c = Math.cos(rad);
|
|
852
|
-
t = 1 - c; // Perform rotation-specific matrix multiplication
|
|
853
|
-
|
|
854
|
-
out[0] = x * x * t + c;
|
|
855
|
-
out[1] = y * x * t + z * s;
|
|
856
|
-
out[2] = z * x * t - y * s;
|
|
857
|
-
out[3] = 0;
|
|
858
|
-
out[4] = x * y * t - z * s;
|
|
859
|
-
out[5] = y * y * t + c;
|
|
860
|
-
out[6] = z * y * t + x * s;
|
|
861
|
-
out[7] = 0;
|
|
862
|
-
out[8] = x * z * t + y * s;
|
|
863
|
-
out[9] = y * z * t - x * s;
|
|
864
|
-
out[10] = z * z * t + c;
|
|
865
|
-
out[11] = 0;
|
|
866
|
-
out[12] = 0;
|
|
867
|
-
out[13] = 0;
|
|
868
|
-
out[14] = 0;
|
|
869
|
-
out[15] = 1;
|
|
870
|
-
return out;
|
|
871
|
-
}
|
|
872
|
-
/**
|
|
873
|
-
* Creates a matrix from the given angle around the X axis
|
|
874
|
-
* This is equivalent to (but much faster than):
|
|
875
|
-
*
|
|
876
|
-
* mat4.identity(dest);
|
|
877
|
-
* mat4.rotateX(dest, dest, rad);
|
|
878
|
-
*
|
|
879
|
-
* @param {mat4} out mat4 receiving operation result
|
|
880
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
881
|
-
* @returns {mat4} out
|
|
882
|
-
*/
|
|
883
|
-
|
|
884
|
-
function fromXRotation(out, rad) {
|
|
885
|
-
var s = Math.sin(rad);
|
|
886
|
-
var c = Math.cos(rad); // Perform axis-specific matrix multiplication
|
|
887
|
-
|
|
888
|
-
out[0] = 1;
|
|
889
|
-
out[1] = 0;
|
|
890
|
-
out[2] = 0;
|
|
891
|
-
out[3] = 0;
|
|
892
|
-
out[4] = 0;
|
|
893
|
-
out[5] = c;
|
|
894
|
-
out[6] = s;
|
|
895
|
-
out[7] = 0;
|
|
896
|
-
out[8] = 0;
|
|
897
|
-
out[9] = -s;
|
|
898
|
-
out[10] = c;
|
|
899
|
-
out[11] = 0;
|
|
900
|
-
out[12] = 0;
|
|
901
|
-
out[13] = 0;
|
|
902
|
-
out[14] = 0;
|
|
903
|
-
out[15] = 1;
|
|
904
|
-
return out;
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* Creates a matrix from the given angle around the Y axis
|
|
908
|
-
* This is equivalent to (but much faster than):
|
|
909
|
-
*
|
|
910
|
-
* mat4.identity(dest);
|
|
911
|
-
* mat4.rotateY(dest, dest, rad);
|
|
912
|
-
*
|
|
913
|
-
* @param {mat4} out mat4 receiving operation result
|
|
914
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
915
|
-
* @returns {mat4} out
|
|
916
|
-
*/
|
|
917
|
-
|
|
918
|
-
function fromYRotation(out, rad) {
|
|
919
|
-
var s = Math.sin(rad);
|
|
920
|
-
var c = Math.cos(rad); // Perform axis-specific matrix multiplication
|
|
921
|
-
|
|
922
|
-
out[0] = c;
|
|
923
|
-
out[1] = 0;
|
|
924
|
-
out[2] = -s;
|
|
925
|
-
out[3] = 0;
|
|
926
|
-
out[4] = 0;
|
|
927
|
-
out[5] = 1;
|
|
928
|
-
out[6] = 0;
|
|
929
|
-
out[7] = 0;
|
|
930
|
-
out[8] = s;
|
|
931
|
-
out[9] = 0;
|
|
932
|
-
out[10] = c;
|
|
933
|
-
out[11] = 0;
|
|
934
|
-
out[12] = 0;
|
|
935
|
-
out[13] = 0;
|
|
936
|
-
out[14] = 0;
|
|
937
|
-
out[15] = 1;
|
|
938
|
-
return out;
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* Creates a matrix from the given angle around the Z axis
|
|
942
|
-
* This is equivalent to (but much faster than):
|
|
943
|
-
*
|
|
944
|
-
* mat4.identity(dest);
|
|
945
|
-
* mat4.rotateZ(dest, dest, rad);
|
|
946
|
-
*
|
|
947
|
-
* @param {mat4} out mat4 receiving operation result
|
|
948
|
-
* @param {Number} rad the angle to rotate the matrix by
|
|
949
|
-
* @returns {mat4} out
|
|
950
|
-
*/
|
|
951
|
-
|
|
952
|
-
function fromZRotation(out, rad) {
|
|
953
|
-
var s = Math.sin(rad);
|
|
954
|
-
var c = Math.cos(rad); // Perform axis-specific matrix multiplication
|
|
955
|
-
|
|
956
|
-
out[0] = c;
|
|
957
|
-
out[1] = s;
|
|
958
|
-
out[2] = 0;
|
|
959
|
-
out[3] = 0;
|
|
960
|
-
out[4] = -s;
|
|
961
|
-
out[5] = c;
|
|
962
|
-
out[6] = 0;
|
|
963
|
-
out[7] = 0;
|
|
964
|
-
out[8] = 0;
|
|
965
|
-
out[9] = 0;
|
|
966
|
-
out[10] = 1;
|
|
967
|
-
out[11] = 0;
|
|
968
|
-
out[12] = 0;
|
|
969
|
-
out[13] = 0;
|
|
970
|
-
out[14] = 0;
|
|
971
|
-
out[15] = 1;
|
|
972
|
-
return out;
|
|
973
|
-
}
|
|
974
|
-
/**
|
|
975
|
-
* Creates a matrix from a quaternion rotation and vector translation
|
|
976
|
-
* This is equivalent to (but much faster than):
|
|
977
|
-
*
|
|
978
|
-
* mat4.identity(dest);
|
|
979
|
-
* mat4.translate(dest, vec);
|
|
980
|
-
* let quatMat = mat4.create();
|
|
981
|
-
* quat4.toMat4(quat, quatMat);
|
|
982
|
-
* mat4.multiply(dest, quatMat);
|
|
983
|
-
*
|
|
984
|
-
* @param {mat4} out mat4 receiving operation result
|
|
985
|
-
* @param {quat4} q Rotation quaternion
|
|
986
|
-
* @param {ReadonlyVec3} v Translation vector
|
|
987
|
-
* @returns {mat4} out
|
|
988
|
-
*/
|
|
989
|
-
|
|
990
|
-
function fromRotationTranslation(out, q, v) {
|
|
991
|
-
// Quaternion math
|
|
992
|
-
var x = q[0],
|
|
993
|
-
y = q[1],
|
|
994
|
-
z = q[2],
|
|
995
|
-
w = q[3];
|
|
996
|
-
var x2 = x + x;
|
|
997
|
-
var y2 = y + y;
|
|
998
|
-
var z2 = z + z;
|
|
999
|
-
var xx = x * x2;
|
|
1000
|
-
var xy = x * y2;
|
|
1001
|
-
var xz = x * z2;
|
|
1002
|
-
var yy = y * y2;
|
|
1003
|
-
var yz = y * z2;
|
|
1004
|
-
var zz = z * z2;
|
|
1005
|
-
var wx = w * x2;
|
|
1006
|
-
var wy = w * y2;
|
|
1007
|
-
var wz = w * z2;
|
|
1008
|
-
out[0] = 1 - (yy + zz);
|
|
1009
|
-
out[1] = xy + wz;
|
|
1010
|
-
out[2] = xz - wy;
|
|
1011
|
-
out[3] = 0;
|
|
1012
|
-
out[4] = xy - wz;
|
|
1013
|
-
out[5] = 1 - (xx + zz);
|
|
1014
|
-
out[6] = yz + wx;
|
|
1015
|
-
out[7] = 0;
|
|
1016
|
-
out[8] = xz + wy;
|
|
1017
|
-
out[9] = yz - wx;
|
|
1018
|
-
out[10] = 1 - (xx + yy);
|
|
1019
|
-
out[11] = 0;
|
|
1020
|
-
out[12] = v[0];
|
|
1021
|
-
out[13] = v[1];
|
|
1022
|
-
out[14] = v[2];
|
|
1023
|
-
out[15] = 1;
|
|
1024
|
-
return out;
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Creates a new mat4 from a dual quat.
|
|
1028
|
-
*
|
|
1029
|
-
* @param {mat4} out Matrix
|
|
1030
|
-
* @param {ReadonlyQuat2} a Dual Quaternion
|
|
1031
|
-
* @returns {mat4} mat4 receiving operation result
|
|
1032
|
-
*/
|
|
1033
|
-
|
|
1034
|
-
function fromQuat2(out, a) {
|
|
1035
|
-
var translation = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(3);
|
|
1036
|
-
var bx = -a[0],
|
|
1037
|
-
by = -a[1],
|
|
1038
|
-
bz = -a[2],
|
|
1039
|
-
bw = a[3],
|
|
1040
|
-
ax = a[4],
|
|
1041
|
-
ay = a[5],
|
|
1042
|
-
az = a[6],
|
|
1043
|
-
aw = a[7];
|
|
1044
|
-
var magnitude = bx * bx + by * by + bz * bz + bw * bw; //Only scale if it makes sense
|
|
1045
|
-
|
|
1046
|
-
if (magnitude > 0) {
|
|
1047
|
-
translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2 / magnitude;
|
|
1048
|
-
translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2 / magnitude;
|
|
1049
|
-
translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2 / magnitude;
|
|
1050
|
-
} else {
|
|
1051
|
-
translation[0] = (ax * bw + aw * bx + ay * bz - az * by) * 2;
|
|
1052
|
-
translation[1] = (ay * bw + aw * by + az * bx - ax * bz) * 2;
|
|
1053
|
-
translation[2] = (az * bw + aw * bz + ax * by - ay * bx) * 2;
|
|
1054
|
-
}
|
|
1055
|
-
|
|
1056
|
-
fromRotationTranslation(out, a, translation);
|
|
1057
|
-
return out;
|
|
1058
|
-
}
|
|
1059
|
-
/**
|
|
1060
|
-
* Returns the translation vector component of a transformation
|
|
1061
|
-
* matrix. If a matrix is built with fromRotationTranslation,
|
|
1062
|
-
* the returned vector will be the same as the translation vector
|
|
1063
|
-
* originally supplied.
|
|
1064
|
-
* @param {vec3} out Vector to receive translation component
|
|
1065
|
-
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1066
|
-
* @return {vec3} out
|
|
1067
|
-
*/
|
|
1068
|
-
|
|
1069
|
-
function getTranslation(out, mat) {
|
|
1070
|
-
out[0] = mat[12];
|
|
1071
|
-
out[1] = mat[13];
|
|
1072
|
-
out[2] = mat[14];
|
|
1073
|
-
return out;
|
|
1074
|
-
}
|
|
1075
|
-
/**
|
|
1076
|
-
* Returns the scaling factor component of a transformation
|
|
1077
|
-
* matrix. If a matrix is built with fromRotationTranslationScale
|
|
1078
|
-
* with a normalized Quaternion paramter, the returned vector will be
|
|
1079
|
-
* the same as the scaling vector
|
|
1080
|
-
* originally supplied.
|
|
1081
|
-
* @param {vec3} out Vector to receive scaling factor component
|
|
1082
|
-
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1083
|
-
* @return {vec3} out
|
|
1084
|
-
*/
|
|
1085
|
-
|
|
1086
|
-
function getScaling(out, mat) {
|
|
1087
|
-
var m11 = mat[0];
|
|
1088
|
-
var m12 = mat[1];
|
|
1089
|
-
var m13 = mat[2];
|
|
1090
|
-
var m21 = mat[4];
|
|
1091
|
-
var m22 = mat[5];
|
|
1092
|
-
var m23 = mat[6];
|
|
1093
|
-
var m31 = mat[8];
|
|
1094
|
-
var m32 = mat[9];
|
|
1095
|
-
var m33 = mat[10];
|
|
1096
|
-
out[0] = Math.hypot(m11, m12, m13);
|
|
1097
|
-
out[1] = Math.hypot(m21, m22, m23);
|
|
1098
|
-
out[2] = Math.hypot(m31, m32, m33);
|
|
1099
|
-
return out;
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Returns a quaternion representing the rotational component
|
|
1103
|
-
* of a transformation matrix. If a matrix is built with
|
|
1104
|
-
* fromRotationTranslation, the returned quaternion will be the
|
|
1105
|
-
* same as the quaternion originally supplied.
|
|
1106
|
-
* @param {quat} out Quaternion to receive the rotation component
|
|
1107
|
-
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1108
|
-
* @return {quat} out
|
|
1109
|
-
*/
|
|
1110
|
-
|
|
1111
|
-
function getRotation(out, mat) {
|
|
1112
|
-
var scaling = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(3);
|
|
1113
|
-
getScaling(scaling, mat);
|
|
1114
|
-
var is1 = 1 / scaling[0];
|
|
1115
|
-
var is2 = 1 / scaling[1];
|
|
1116
|
-
var is3 = 1 / scaling[2];
|
|
1117
|
-
var sm11 = mat[0] * is1;
|
|
1118
|
-
var sm12 = mat[1] * is2;
|
|
1119
|
-
var sm13 = mat[2] * is3;
|
|
1120
|
-
var sm21 = mat[4] * is1;
|
|
1121
|
-
var sm22 = mat[5] * is2;
|
|
1122
|
-
var sm23 = mat[6] * is3;
|
|
1123
|
-
var sm31 = mat[8] * is1;
|
|
1124
|
-
var sm32 = mat[9] * is2;
|
|
1125
|
-
var sm33 = mat[10] * is3;
|
|
1126
|
-
var trace = sm11 + sm22 + sm33;
|
|
1127
|
-
var S = 0;
|
|
1128
|
-
|
|
1129
|
-
if (trace > 0) {
|
|
1130
|
-
S = Math.sqrt(trace + 1.0) * 2;
|
|
1131
|
-
out[3] = 0.25 * S;
|
|
1132
|
-
out[0] = (sm23 - sm32) / S;
|
|
1133
|
-
out[1] = (sm31 - sm13) / S;
|
|
1134
|
-
out[2] = (sm12 - sm21) / S;
|
|
1135
|
-
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
1136
|
-
S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
|
|
1137
|
-
out[3] = (sm23 - sm32) / S;
|
|
1138
|
-
out[0] = 0.25 * S;
|
|
1139
|
-
out[1] = (sm12 + sm21) / S;
|
|
1140
|
-
out[2] = (sm31 + sm13) / S;
|
|
1141
|
-
} else if (sm22 > sm33) {
|
|
1142
|
-
S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
|
|
1143
|
-
out[3] = (sm31 - sm13) / S;
|
|
1144
|
-
out[0] = (sm12 + sm21) / S;
|
|
1145
|
-
out[1] = 0.25 * S;
|
|
1146
|
-
out[2] = (sm23 + sm32) / S;
|
|
1147
|
-
} else {
|
|
1148
|
-
S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
|
|
1149
|
-
out[3] = (sm12 - sm21) / S;
|
|
1150
|
-
out[0] = (sm31 + sm13) / S;
|
|
1151
|
-
out[1] = (sm23 + sm32) / S;
|
|
1152
|
-
out[2] = 0.25 * S;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
return out;
|
|
1156
|
-
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Creates a matrix from a quaternion rotation, vector translation and vector scale
|
|
1159
|
-
* This is equivalent to (but much faster than):
|
|
1160
|
-
*
|
|
1161
|
-
* mat4.identity(dest);
|
|
1162
|
-
* mat4.translate(dest, vec);
|
|
1163
|
-
* let quatMat = mat4.create();
|
|
1164
|
-
* quat4.toMat4(quat, quatMat);
|
|
1165
|
-
* mat4.multiply(dest, quatMat);
|
|
1166
|
-
* mat4.scale(dest, scale)
|
|
1167
|
-
*
|
|
1168
|
-
* @param {mat4} out mat4 receiving operation result
|
|
1169
|
-
* @param {quat4} q Rotation quaternion
|
|
1170
|
-
* @param {ReadonlyVec3} v Translation vector
|
|
1171
|
-
* @param {ReadonlyVec3} s Scaling vector
|
|
1172
|
-
* @returns {mat4} out
|
|
1173
|
-
*/
|
|
1174
|
-
|
|
1175
|
-
function fromRotationTranslationScale(out, q, v, s) {
|
|
1176
|
-
// Quaternion math
|
|
1177
|
-
var x = q[0],
|
|
1178
|
-
y = q[1],
|
|
1179
|
-
z = q[2],
|
|
1180
|
-
w = q[3];
|
|
1181
|
-
var x2 = x + x;
|
|
1182
|
-
var y2 = y + y;
|
|
1183
|
-
var z2 = z + z;
|
|
1184
|
-
var xx = x * x2;
|
|
1185
|
-
var xy = x * y2;
|
|
1186
|
-
var xz = x * z2;
|
|
1187
|
-
var yy = y * y2;
|
|
1188
|
-
var yz = y * z2;
|
|
1189
|
-
var zz = z * z2;
|
|
1190
|
-
var wx = w * x2;
|
|
1191
|
-
var wy = w * y2;
|
|
1192
|
-
var wz = w * z2;
|
|
1193
|
-
var sx = s[0];
|
|
1194
|
-
var sy = s[1];
|
|
1195
|
-
var sz = s[2];
|
|
1196
|
-
out[0] = (1 - (yy + zz)) * sx;
|
|
1197
|
-
out[1] = (xy + wz) * sx;
|
|
1198
|
-
out[2] = (xz - wy) * sx;
|
|
1199
|
-
out[3] = 0;
|
|
1200
|
-
out[4] = (xy - wz) * sy;
|
|
1201
|
-
out[5] = (1 - (xx + zz)) * sy;
|
|
1202
|
-
out[6] = (yz + wx) * sy;
|
|
1203
|
-
out[7] = 0;
|
|
1204
|
-
out[8] = (xz + wy) * sz;
|
|
1205
|
-
out[9] = (yz - wx) * sz;
|
|
1206
|
-
out[10] = (1 - (xx + yy)) * sz;
|
|
1207
|
-
out[11] = 0;
|
|
1208
|
-
out[12] = v[0];
|
|
1209
|
-
out[13] = v[1];
|
|
1210
|
-
out[14] = v[2];
|
|
1211
|
-
out[15] = 1;
|
|
1212
|
-
return out;
|
|
1213
|
-
}
|
|
1214
|
-
/**
|
|
1215
|
-
* Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin
|
|
1216
|
-
* This is equivalent to (but much faster than):
|
|
1217
|
-
*
|
|
1218
|
-
* mat4.identity(dest);
|
|
1219
|
-
* mat4.translate(dest, vec);
|
|
1220
|
-
* mat4.translate(dest, origin);
|
|
1221
|
-
* let quatMat = mat4.create();
|
|
1222
|
-
* quat4.toMat4(quat, quatMat);
|
|
1223
|
-
* mat4.multiply(dest, quatMat);
|
|
1224
|
-
* mat4.scale(dest, scale)
|
|
1225
|
-
* mat4.translate(dest, negativeOrigin);
|
|
1226
|
-
*
|
|
1227
|
-
* @param {mat4} out mat4 receiving operation result
|
|
1228
|
-
* @param {quat4} q Rotation quaternion
|
|
1229
|
-
* @param {ReadonlyVec3} v Translation vector
|
|
1230
|
-
* @param {ReadonlyVec3} s Scaling vector
|
|
1231
|
-
* @param {ReadonlyVec3} o The origin vector around which to scale and rotate
|
|
1232
|
-
* @returns {mat4} out
|
|
1233
|
-
*/
|
|
1234
|
-
|
|
1235
|
-
function fromRotationTranslationScaleOrigin(out, q, v, s, o) {
|
|
1236
|
-
// Quaternion math
|
|
1237
|
-
var x = q[0],
|
|
1238
|
-
y = q[1],
|
|
1239
|
-
z = q[2],
|
|
1240
|
-
w = q[3];
|
|
1241
|
-
var x2 = x + x;
|
|
1242
|
-
var y2 = y + y;
|
|
1243
|
-
var z2 = z + z;
|
|
1244
|
-
var xx = x * x2;
|
|
1245
|
-
var xy = x * y2;
|
|
1246
|
-
var xz = x * z2;
|
|
1247
|
-
var yy = y * y2;
|
|
1248
|
-
var yz = y * z2;
|
|
1249
|
-
var zz = z * z2;
|
|
1250
|
-
var wx = w * x2;
|
|
1251
|
-
var wy = w * y2;
|
|
1252
|
-
var wz = w * z2;
|
|
1253
|
-
var sx = s[0];
|
|
1254
|
-
var sy = s[1];
|
|
1255
|
-
var sz = s[2];
|
|
1256
|
-
var ox = o[0];
|
|
1257
|
-
var oy = o[1];
|
|
1258
|
-
var oz = o[2];
|
|
1259
|
-
var out0 = (1 - (yy + zz)) * sx;
|
|
1260
|
-
var out1 = (xy + wz) * sx;
|
|
1261
|
-
var out2 = (xz - wy) * sx;
|
|
1262
|
-
var out4 = (xy - wz) * sy;
|
|
1263
|
-
var out5 = (1 - (xx + zz)) * sy;
|
|
1264
|
-
var out6 = (yz + wx) * sy;
|
|
1265
|
-
var out8 = (xz + wy) * sz;
|
|
1266
|
-
var out9 = (yz - wx) * sz;
|
|
1267
|
-
var out10 = (1 - (xx + yy)) * sz;
|
|
1268
|
-
out[0] = out0;
|
|
1269
|
-
out[1] = out1;
|
|
1270
|
-
out[2] = out2;
|
|
1271
|
-
out[3] = 0;
|
|
1272
|
-
out[4] = out4;
|
|
1273
|
-
out[5] = out5;
|
|
1274
|
-
out[6] = out6;
|
|
1275
|
-
out[7] = 0;
|
|
1276
|
-
out[8] = out8;
|
|
1277
|
-
out[9] = out9;
|
|
1278
|
-
out[10] = out10;
|
|
1279
|
-
out[11] = 0;
|
|
1280
|
-
out[12] = v[0] + ox - (out0 * ox + out4 * oy + out8 * oz);
|
|
1281
|
-
out[13] = v[1] + oy - (out1 * ox + out5 * oy + out9 * oz);
|
|
1282
|
-
out[14] = v[2] + oz - (out2 * ox + out6 * oy + out10 * oz);
|
|
1283
|
-
out[15] = 1;
|
|
1284
|
-
return out;
|
|
1285
|
-
}
|
|
1286
|
-
/**
|
|
1287
|
-
* Calculates a 4x4 matrix from the given quaternion
|
|
1288
|
-
*
|
|
1289
|
-
* @param {mat4} out mat4 receiving operation result
|
|
1290
|
-
* @param {ReadonlyQuat} q Quaternion to create matrix from
|
|
1291
|
-
*
|
|
1292
|
-
* @returns {mat4} out
|
|
1293
|
-
*/
|
|
1294
|
-
|
|
1295
|
-
function fromQuat(out, q) {
|
|
1296
|
-
var x = q[0],
|
|
1297
|
-
y = q[1],
|
|
1298
|
-
z = q[2],
|
|
1299
|
-
w = q[3];
|
|
1300
|
-
var x2 = x + x;
|
|
1301
|
-
var y2 = y + y;
|
|
1302
|
-
var z2 = z + z;
|
|
1303
|
-
var xx = x * x2;
|
|
1304
|
-
var yx = y * x2;
|
|
1305
|
-
var yy = y * y2;
|
|
1306
|
-
var zx = z * x2;
|
|
1307
|
-
var zy = z * y2;
|
|
1308
|
-
var zz = z * z2;
|
|
1309
|
-
var wx = w * x2;
|
|
1310
|
-
var wy = w * y2;
|
|
1311
|
-
var wz = w * z2;
|
|
1312
|
-
out[0] = 1 - yy - zz;
|
|
1313
|
-
out[1] = yx + wz;
|
|
1314
|
-
out[2] = zx - wy;
|
|
1315
|
-
out[3] = 0;
|
|
1316
|
-
out[4] = yx - wz;
|
|
1317
|
-
out[5] = 1 - xx - zz;
|
|
1318
|
-
out[6] = zy + wx;
|
|
1319
|
-
out[7] = 0;
|
|
1320
|
-
out[8] = zx + wy;
|
|
1321
|
-
out[9] = zy - wx;
|
|
1322
|
-
out[10] = 1 - xx - yy;
|
|
1323
|
-
out[11] = 0;
|
|
1324
|
-
out[12] = 0;
|
|
1325
|
-
out[13] = 0;
|
|
1326
|
-
out[14] = 0;
|
|
1327
|
-
out[15] = 1;
|
|
1328
|
-
return out;
|
|
1329
|
-
}
|
|
1330
|
-
/**
|
|
1331
|
-
* Generates a frustum matrix with the given bounds
|
|
1332
|
-
*
|
|
1333
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1334
|
-
* @param {Number} left Left bound of the frustum
|
|
1335
|
-
* @param {Number} right Right bound of the frustum
|
|
1336
|
-
* @param {Number} bottom Bottom bound of the frustum
|
|
1337
|
-
* @param {Number} top Top bound of the frustum
|
|
1338
|
-
* @param {Number} near Near bound of the frustum
|
|
1339
|
-
* @param {Number} far Far bound of the frustum
|
|
1340
|
-
* @returns {mat4} out
|
|
1341
|
-
*/
|
|
1342
|
-
|
|
1343
|
-
function frustum(out, left, right, bottom, top, near, far) {
|
|
1344
|
-
var rl = 1 / (right - left);
|
|
1345
|
-
var tb = 1 / (top - bottom);
|
|
1346
|
-
var nf = 1 / (near - far);
|
|
1347
|
-
out[0] = near * 2 * rl;
|
|
1348
|
-
out[1] = 0;
|
|
1349
|
-
out[2] = 0;
|
|
1350
|
-
out[3] = 0;
|
|
1351
|
-
out[4] = 0;
|
|
1352
|
-
out[5] = near * 2 * tb;
|
|
1353
|
-
out[6] = 0;
|
|
1354
|
-
out[7] = 0;
|
|
1355
|
-
out[8] = (right + left) * rl;
|
|
1356
|
-
out[9] = (top + bottom) * tb;
|
|
1357
|
-
out[10] = (far + near) * nf;
|
|
1358
|
-
out[11] = -1;
|
|
1359
|
-
out[12] = 0;
|
|
1360
|
-
out[13] = 0;
|
|
1361
|
-
out[14] = far * near * 2 * nf;
|
|
1362
|
-
out[15] = 0;
|
|
1363
|
-
return out;
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Generates a perspective projection matrix with the given bounds.
|
|
1367
|
-
* The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],
|
|
1368
|
-
* which matches WebGL/OpenGL's clip volume.
|
|
1369
|
-
* Passing null/undefined/no value for far will generate infinite projection matrix.
|
|
1370
|
-
*
|
|
1371
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1372
|
-
* @param {number} fovy Vertical field of view in radians
|
|
1373
|
-
* @param {number} aspect Aspect ratio. typically viewport width/height
|
|
1374
|
-
* @param {number} near Near bound of the frustum
|
|
1375
|
-
* @param {number} far Far bound of the frustum, can be null or Infinity
|
|
1376
|
-
* @returns {mat4} out
|
|
1377
|
-
*/
|
|
1378
|
-
|
|
1379
|
-
function perspectiveNO(out, fovy, aspect, near, far) {
|
|
1380
|
-
var f = 1.0 / Math.tan(fovy / 2),
|
|
1381
|
-
nf;
|
|
1382
|
-
out[0] = f / aspect;
|
|
1383
|
-
out[1] = 0;
|
|
1384
|
-
out[2] = 0;
|
|
1385
|
-
out[3] = 0;
|
|
1386
|
-
out[4] = 0;
|
|
1387
|
-
out[5] = f;
|
|
1388
|
-
out[6] = 0;
|
|
1389
|
-
out[7] = 0;
|
|
1390
|
-
out[8] = 0;
|
|
1391
|
-
out[9] = 0;
|
|
1392
|
-
out[11] = -1;
|
|
1393
|
-
out[12] = 0;
|
|
1394
|
-
out[13] = 0;
|
|
1395
|
-
out[15] = 0;
|
|
1396
|
-
|
|
1397
|
-
if (far != null && far !== Infinity) {
|
|
1398
|
-
nf = 1 / (near - far);
|
|
1399
|
-
out[10] = (far + near) * nf;
|
|
1400
|
-
out[14] = 2 * far * near * nf;
|
|
1401
|
-
} else {
|
|
1402
|
-
out[10] = -1;
|
|
1403
|
-
out[14] = -2 * near;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
return out;
|
|
1407
|
-
}
|
|
1408
|
-
/**
|
|
1409
|
-
* Alias for {@link mat4.perspectiveNO}
|
|
1410
|
-
* @function
|
|
1411
|
-
*/
|
|
1412
|
-
|
|
1413
|
-
var perspective = perspectiveNO;
|
|
1414
|
-
/**
|
|
1415
|
-
* Generates a perspective projection matrix suitable for WebGPU with the given bounds.
|
|
1416
|
-
* The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],
|
|
1417
|
-
* which matches WebGPU/Vulkan/DirectX/Metal's clip volume.
|
|
1418
|
-
* Passing null/undefined/no value for far will generate infinite projection matrix.
|
|
1419
|
-
*
|
|
1420
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1421
|
-
* @param {number} fovy Vertical field of view in radians
|
|
1422
|
-
* @param {number} aspect Aspect ratio. typically viewport width/height
|
|
1423
|
-
* @param {number} near Near bound of the frustum
|
|
1424
|
-
* @param {number} far Far bound of the frustum, can be null or Infinity
|
|
1425
|
-
* @returns {mat4} out
|
|
1426
|
-
*/
|
|
1427
|
-
|
|
1428
|
-
function perspectiveZO(out, fovy, aspect, near, far) {
|
|
1429
|
-
var f = 1.0 / Math.tan(fovy / 2),
|
|
1430
|
-
nf;
|
|
1431
|
-
out[0] = f / aspect;
|
|
1432
|
-
out[1] = 0;
|
|
1433
|
-
out[2] = 0;
|
|
1434
|
-
out[3] = 0;
|
|
1435
|
-
out[4] = 0;
|
|
1436
|
-
out[5] = f;
|
|
1437
|
-
out[6] = 0;
|
|
1438
|
-
out[7] = 0;
|
|
1439
|
-
out[8] = 0;
|
|
1440
|
-
out[9] = 0;
|
|
1441
|
-
out[11] = -1;
|
|
1442
|
-
out[12] = 0;
|
|
1443
|
-
out[13] = 0;
|
|
1444
|
-
out[15] = 0;
|
|
1445
|
-
|
|
1446
|
-
if (far != null && far !== Infinity) {
|
|
1447
|
-
nf = 1 / (near - far);
|
|
1448
|
-
out[10] = far * nf;
|
|
1449
|
-
out[14] = far * near * nf;
|
|
1450
|
-
} else {
|
|
1451
|
-
out[10] = -1;
|
|
1452
|
-
out[14] = -near;
|
|
1453
|
-
}
|
|
1454
|
-
|
|
1455
|
-
return out;
|
|
1456
|
-
}
|
|
1457
|
-
/**
|
|
1458
|
-
* Generates a perspective projection matrix with the given field of view.
|
|
1459
|
-
* This is primarily useful for generating projection matrices to be used
|
|
1460
|
-
* with the still experiemental WebVR API.
|
|
1461
|
-
*
|
|
1462
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1463
|
-
* @param {Object} fov Object containing the following values: upDegrees, downDegrees, leftDegrees, rightDegrees
|
|
1464
|
-
* @param {number} near Near bound of the frustum
|
|
1465
|
-
* @param {number} far Far bound of the frustum
|
|
1466
|
-
* @returns {mat4} out
|
|
1467
|
-
*/
|
|
1468
|
-
|
|
1469
|
-
function perspectiveFromFieldOfView(out, fov, near, far) {
|
|
1470
|
-
var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
|
|
1471
|
-
var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
|
|
1472
|
-
var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
|
|
1473
|
-
var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
|
|
1474
|
-
var xScale = 2.0 / (leftTan + rightTan);
|
|
1475
|
-
var yScale = 2.0 / (upTan + downTan);
|
|
1476
|
-
out[0] = xScale;
|
|
1477
|
-
out[1] = 0.0;
|
|
1478
|
-
out[2] = 0.0;
|
|
1479
|
-
out[3] = 0.0;
|
|
1480
|
-
out[4] = 0.0;
|
|
1481
|
-
out[5] = yScale;
|
|
1482
|
-
out[6] = 0.0;
|
|
1483
|
-
out[7] = 0.0;
|
|
1484
|
-
out[8] = -((leftTan - rightTan) * xScale * 0.5);
|
|
1485
|
-
out[9] = (upTan - downTan) * yScale * 0.5;
|
|
1486
|
-
out[10] = far / (near - far);
|
|
1487
|
-
out[11] = -1.0;
|
|
1488
|
-
out[12] = 0.0;
|
|
1489
|
-
out[13] = 0.0;
|
|
1490
|
-
out[14] = far * near / (near - far);
|
|
1491
|
-
out[15] = 0.0;
|
|
1492
|
-
return out;
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* Generates a orthogonal projection matrix with the given bounds.
|
|
1496
|
-
* The near/far clip planes correspond to a normalized device coordinate Z range of [-1, 1],
|
|
1497
|
-
* which matches WebGL/OpenGL's clip volume.
|
|
1498
|
-
*
|
|
1499
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1500
|
-
* @param {number} left Left bound of the frustum
|
|
1501
|
-
* @param {number} right Right bound of the frustum
|
|
1502
|
-
* @param {number} bottom Bottom bound of the frustum
|
|
1503
|
-
* @param {number} top Top bound of the frustum
|
|
1504
|
-
* @param {number} near Near bound of the frustum
|
|
1505
|
-
* @param {number} far Far bound of the frustum
|
|
1506
|
-
* @returns {mat4} out
|
|
1507
|
-
*/
|
|
1508
|
-
|
|
1509
|
-
function orthoNO(out, left, right, bottom, top, near, far) {
|
|
1510
|
-
var lr = 1 / (left - right);
|
|
1511
|
-
var bt = 1 / (bottom - top);
|
|
1512
|
-
var nf = 1 / (near - far);
|
|
1513
|
-
out[0] = -2 * lr;
|
|
1514
|
-
out[1] = 0;
|
|
1515
|
-
out[2] = 0;
|
|
1516
|
-
out[3] = 0;
|
|
1517
|
-
out[4] = 0;
|
|
1518
|
-
out[5] = -2 * bt;
|
|
1519
|
-
out[6] = 0;
|
|
1520
|
-
out[7] = 0;
|
|
1521
|
-
out[8] = 0;
|
|
1522
|
-
out[9] = 0;
|
|
1523
|
-
out[10] = 2 * nf;
|
|
1524
|
-
out[11] = 0;
|
|
1525
|
-
out[12] = (left + right) * lr;
|
|
1526
|
-
out[13] = (top + bottom) * bt;
|
|
1527
|
-
out[14] = (far + near) * nf;
|
|
1528
|
-
out[15] = 1;
|
|
1529
|
-
return out;
|
|
1530
|
-
}
|
|
1531
|
-
/**
|
|
1532
|
-
* Alias for {@link mat4.orthoNO}
|
|
1533
|
-
* @function
|
|
1534
|
-
*/
|
|
1535
|
-
|
|
1536
|
-
var ortho = orthoNO;
|
|
1537
|
-
/**
|
|
1538
|
-
* Generates a orthogonal projection matrix with the given bounds.
|
|
1539
|
-
* The near/far clip planes correspond to a normalized device coordinate Z range of [0, 1],
|
|
1540
|
-
* which matches WebGPU/Vulkan/DirectX/Metal's clip volume.
|
|
1541
|
-
*
|
|
1542
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1543
|
-
* @param {number} left Left bound of the frustum
|
|
1544
|
-
* @param {number} right Right bound of the frustum
|
|
1545
|
-
* @param {number} bottom Bottom bound of the frustum
|
|
1546
|
-
* @param {number} top Top bound of the frustum
|
|
1547
|
-
* @param {number} near Near bound of the frustum
|
|
1548
|
-
* @param {number} far Far bound of the frustum
|
|
1549
|
-
* @returns {mat4} out
|
|
1550
|
-
*/
|
|
1551
|
-
|
|
1552
|
-
function orthoZO(out, left, right, bottom, top, near, far) {
|
|
1553
|
-
var lr = 1 / (left - right);
|
|
1554
|
-
var bt = 1 / (bottom - top);
|
|
1555
|
-
var nf = 1 / (near - far);
|
|
1556
|
-
out[0] = -2 * lr;
|
|
1557
|
-
out[1] = 0;
|
|
1558
|
-
out[2] = 0;
|
|
1559
|
-
out[3] = 0;
|
|
1560
|
-
out[4] = 0;
|
|
1561
|
-
out[5] = -2 * bt;
|
|
1562
|
-
out[6] = 0;
|
|
1563
|
-
out[7] = 0;
|
|
1564
|
-
out[8] = 0;
|
|
1565
|
-
out[9] = 0;
|
|
1566
|
-
out[10] = nf;
|
|
1567
|
-
out[11] = 0;
|
|
1568
|
-
out[12] = (left + right) * lr;
|
|
1569
|
-
out[13] = (top + bottom) * bt;
|
|
1570
|
-
out[14] = near * nf;
|
|
1571
|
-
out[15] = 1;
|
|
1572
|
-
return out;
|
|
1573
|
-
}
|
|
1574
|
-
/**
|
|
1575
|
-
* Generates a look-at matrix with the given eye position, focal point, and up axis.
|
|
1576
|
-
* If you want a matrix that actually makes an object look at another object, you should use targetTo instead.
|
|
1577
|
-
*
|
|
1578
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1579
|
-
* @param {ReadonlyVec3} eye Position of the viewer
|
|
1580
|
-
* @param {ReadonlyVec3} center Point the viewer is looking at
|
|
1581
|
-
* @param {ReadonlyVec3} up vec3 pointing up
|
|
1582
|
-
* @returns {mat4} out
|
|
1583
|
-
*/
|
|
1584
|
-
|
|
1585
|
-
function lookAt(out, eye, center, up) {
|
|
1586
|
-
var x0, x1, x2, y0, y1, y2, z0, z1, z2, len;
|
|
1587
|
-
var eyex = eye[0];
|
|
1588
|
-
var eyey = eye[1];
|
|
1589
|
-
var eyez = eye[2];
|
|
1590
|
-
var upx = up[0];
|
|
1591
|
-
var upy = up[1];
|
|
1592
|
-
var upz = up[2];
|
|
1593
|
-
var centerx = center[0];
|
|
1594
|
-
var centery = center[1];
|
|
1595
|
-
var centerz = center[2];
|
|
1596
|
-
|
|
1597
|
-
if (Math.abs(eyex - centerx) < _common_js__rspack_import_0/* .EPSILON */.p8 && Math.abs(eyey - centery) < _common_js__rspack_import_0/* .EPSILON */.p8 && Math.abs(eyez - centerz) < _common_js__rspack_import_0/* .EPSILON */.p8) {
|
|
1598
|
-
return identity(out);
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
z0 = eyex - centerx;
|
|
1602
|
-
z1 = eyey - centery;
|
|
1603
|
-
z2 = eyez - centerz;
|
|
1604
|
-
len = 1 / Math.hypot(z0, z1, z2);
|
|
1605
|
-
z0 *= len;
|
|
1606
|
-
z1 *= len;
|
|
1607
|
-
z2 *= len;
|
|
1608
|
-
x0 = upy * z2 - upz * z1;
|
|
1609
|
-
x1 = upz * z0 - upx * z2;
|
|
1610
|
-
x2 = upx * z1 - upy * z0;
|
|
1611
|
-
len = Math.hypot(x0, x1, x2);
|
|
1612
|
-
|
|
1613
|
-
if (!len) {
|
|
1614
|
-
x0 = 0;
|
|
1615
|
-
x1 = 0;
|
|
1616
|
-
x2 = 0;
|
|
1617
|
-
} else {
|
|
1618
|
-
len = 1 / len;
|
|
1619
|
-
x0 *= len;
|
|
1620
|
-
x1 *= len;
|
|
1621
|
-
x2 *= len;
|
|
1622
|
-
}
|
|
1623
|
-
|
|
1624
|
-
y0 = z1 * x2 - z2 * x1;
|
|
1625
|
-
y1 = z2 * x0 - z0 * x2;
|
|
1626
|
-
y2 = z0 * x1 - z1 * x0;
|
|
1627
|
-
len = Math.hypot(y0, y1, y2);
|
|
1628
|
-
|
|
1629
|
-
if (!len) {
|
|
1630
|
-
y0 = 0;
|
|
1631
|
-
y1 = 0;
|
|
1632
|
-
y2 = 0;
|
|
1633
|
-
} else {
|
|
1634
|
-
len = 1 / len;
|
|
1635
|
-
y0 *= len;
|
|
1636
|
-
y1 *= len;
|
|
1637
|
-
y2 *= len;
|
|
1638
|
-
}
|
|
1639
|
-
|
|
1640
|
-
out[0] = x0;
|
|
1641
|
-
out[1] = y0;
|
|
1642
|
-
out[2] = z0;
|
|
1643
|
-
out[3] = 0;
|
|
1644
|
-
out[4] = x1;
|
|
1645
|
-
out[5] = y1;
|
|
1646
|
-
out[6] = z1;
|
|
1647
|
-
out[7] = 0;
|
|
1648
|
-
out[8] = x2;
|
|
1649
|
-
out[9] = y2;
|
|
1650
|
-
out[10] = z2;
|
|
1651
|
-
out[11] = 0;
|
|
1652
|
-
out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
|
|
1653
|
-
out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
|
|
1654
|
-
out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
|
|
1655
|
-
out[15] = 1;
|
|
1656
|
-
return out;
|
|
1657
|
-
}
|
|
1658
|
-
/**
|
|
1659
|
-
* Generates a matrix that makes something look at something else.
|
|
1660
|
-
*
|
|
1661
|
-
* @param {mat4} out mat4 frustum matrix will be written into
|
|
1662
|
-
* @param {ReadonlyVec3} eye Position of the viewer
|
|
1663
|
-
* @param {ReadonlyVec3} center Point the viewer is looking at
|
|
1664
|
-
* @param {ReadonlyVec3} up vec3 pointing up
|
|
1665
|
-
* @returns {mat4} out
|
|
1666
|
-
*/
|
|
1667
|
-
|
|
1668
|
-
function targetTo(out, eye, target, up) {
|
|
1669
|
-
var eyex = eye[0],
|
|
1670
|
-
eyey = eye[1],
|
|
1671
|
-
eyez = eye[2],
|
|
1672
|
-
upx = up[0],
|
|
1673
|
-
upy = up[1],
|
|
1674
|
-
upz = up[2];
|
|
1675
|
-
var z0 = eyex - target[0],
|
|
1676
|
-
z1 = eyey - target[1],
|
|
1677
|
-
z2 = eyez - target[2];
|
|
1678
|
-
var len = z0 * z0 + z1 * z1 + z2 * z2;
|
|
1679
|
-
|
|
1680
|
-
if (len > 0) {
|
|
1681
|
-
len = 1 / Math.sqrt(len);
|
|
1682
|
-
z0 *= len;
|
|
1683
|
-
z1 *= len;
|
|
1684
|
-
z2 *= len;
|
|
1685
|
-
}
|
|
1686
|
-
|
|
1687
|
-
var x0 = upy * z2 - upz * z1,
|
|
1688
|
-
x1 = upz * z0 - upx * z2,
|
|
1689
|
-
x2 = upx * z1 - upy * z0;
|
|
1690
|
-
len = x0 * x0 + x1 * x1 + x2 * x2;
|
|
1691
|
-
|
|
1692
|
-
if (len > 0) {
|
|
1693
|
-
len = 1 / Math.sqrt(len);
|
|
1694
|
-
x0 *= len;
|
|
1695
|
-
x1 *= len;
|
|
1696
|
-
x2 *= len;
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
out[0] = x0;
|
|
1700
|
-
out[1] = x1;
|
|
1701
|
-
out[2] = x2;
|
|
1702
|
-
out[3] = 0;
|
|
1703
|
-
out[4] = z1 * x2 - z2 * x1;
|
|
1704
|
-
out[5] = z2 * x0 - z0 * x2;
|
|
1705
|
-
out[6] = z0 * x1 - z1 * x0;
|
|
1706
|
-
out[7] = 0;
|
|
1707
|
-
out[8] = z0;
|
|
1708
|
-
out[9] = z1;
|
|
1709
|
-
out[10] = z2;
|
|
1710
|
-
out[11] = 0;
|
|
1711
|
-
out[12] = eyex;
|
|
1712
|
-
out[13] = eyey;
|
|
1713
|
-
out[14] = eyez;
|
|
1714
|
-
out[15] = 1;
|
|
1715
|
-
return out;
|
|
1716
|
-
}
|
|
1717
|
-
/**
|
|
1718
|
-
* Returns a string representation of a mat4
|
|
1719
|
-
*
|
|
1720
|
-
* @param {ReadonlyMat4} a matrix to represent as a string
|
|
1721
|
-
* @returns {String} string representation of the matrix
|
|
1722
|
-
*/
|
|
1723
|
-
|
|
1724
|
-
function str(a) {
|
|
1725
|
-
return "mat4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ", " + a[9] + ", " + a[10] + ", " + a[11] + ", " + a[12] + ", " + a[13] + ", " + a[14] + ", " + a[15] + ")";
|
|
1726
|
-
}
|
|
1727
|
-
/**
|
|
1728
|
-
* Returns Frobenius norm of a mat4
|
|
1729
|
-
*
|
|
1730
|
-
* @param {ReadonlyMat4} a the matrix to calculate Frobenius norm of
|
|
1731
|
-
* @returns {Number} Frobenius norm
|
|
1732
|
-
*/
|
|
1733
|
-
|
|
1734
|
-
function frob(a) {
|
|
1735
|
-
return Math.hypot(a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]);
|
|
1736
|
-
}
|
|
1737
|
-
/**
|
|
1738
|
-
* Adds two mat4's
|
|
1739
|
-
*
|
|
1740
|
-
* @param {mat4} out the receiving matrix
|
|
1741
|
-
* @param {ReadonlyMat4} a the first operand
|
|
1742
|
-
* @param {ReadonlyMat4} b the second operand
|
|
1743
|
-
* @returns {mat4} out
|
|
1744
|
-
*/
|
|
1745
|
-
|
|
1746
|
-
function add(out, a, b) {
|
|
1747
|
-
out[0] = a[0] + b[0];
|
|
1748
|
-
out[1] = a[1] + b[1];
|
|
1749
|
-
out[2] = a[2] + b[2];
|
|
1750
|
-
out[3] = a[3] + b[3];
|
|
1751
|
-
out[4] = a[4] + b[4];
|
|
1752
|
-
out[5] = a[5] + b[5];
|
|
1753
|
-
out[6] = a[6] + b[6];
|
|
1754
|
-
out[7] = a[7] + b[7];
|
|
1755
|
-
out[8] = a[8] + b[8];
|
|
1756
|
-
out[9] = a[9] + b[9];
|
|
1757
|
-
out[10] = a[10] + b[10];
|
|
1758
|
-
out[11] = a[11] + b[11];
|
|
1759
|
-
out[12] = a[12] + b[12];
|
|
1760
|
-
out[13] = a[13] + b[13];
|
|
1761
|
-
out[14] = a[14] + b[14];
|
|
1762
|
-
out[15] = a[15] + b[15];
|
|
1763
|
-
return out;
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Subtracts matrix b from matrix a
|
|
1767
|
-
*
|
|
1768
|
-
* @param {mat4} out the receiving matrix
|
|
1769
|
-
* @param {ReadonlyMat4} a the first operand
|
|
1770
|
-
* @param {ReadonlyMat4} b the second operand
|
|
1771
|
-
* @returns {mat4} out
|
|
1772
|
-
*/
|
|
1773
|
-
|
|
1774
|
-
function subtract(out, a, b) {
|
|
1775
|
-
out[0] = a[0] - b[0];
|
|
1776
|
-
out[1] = a[1] - b[1];
|
|
1777
|
-
out[2] = a[2] - b[2];
|
|
1778
|
-
out[3] = a[3] - b[3];
|
|
1779
|
-
out[4] = a[4] - b[4];
|
|
1780
|
-
out[5] = a[5] - b[5];
|
|
1781
|
-
out[6] = a[6] - b[6];
|
|
1782
|
-
out[7] = a[7] - b[7];
|
|
1783
|
-
out[8] = a[8] - b[8];
|
|
1784
|
-
out[9] = a[9] - b[9];
|
|
1785
|
-
out[10] = a[10] - b[10];
|
|
1786
|
-
out[11] = a[11] - b[11];
|
|
1787
|
-
out[12] = a[12] - b[12];
|
|
1788
|
-
out[13] = a[13] - b[13];
|
|
1789
|
-
out[14] = a[14] - b[14];
|
|
1790
|
-
out[15] = a[15] - b[15];
|
|
1791
|
-
return out;
|
|
1792
|
-
}
|
|
1793
|
-
/**
|
|
1794
|
-
* Multiply each element of the matrix by a scalar.
|
|
1795
|
-
*
|
|
1796
|
-
* @param {mat4} out the receiving matrix
|
|
1797
|
-
* @param {ReadonlyMat4} a the matrix to scale
|
|
1798
|
-
* @param {Number} b amount to scale the matrix's elements by
|
|
1799
|
-
* @returns {mat4} out
|
|
1800
|
-
*/
|
|
1801
|
-
|
|
1802
|
-
function multiplyScalar(out, a, b) {
|
|
1803
|
-
out[0] = a[0] * b;
|
|
1804
|
-
out[1] = a[1] * b;
|
|
1805
|
-
out[2] = a[2] * b;
|
|
1806
|
-
out[3] = a[3] * b;
|
|
1807
|
-
out[4] = a[4] * b;
|
|
1808
|
-
out[5] = a[5] * b;
|
|
1809
|
-
out[6] = a[6] * b;
|
|
1810
|
-
out[7] = a[7] * b;
|
|
1811
|
-
out[8] = a[8] * b;
|
|
1812
|
-
out[9] = a[9] * b;
|
|
1813
|
-
out[10] = a[10] * b;
|
|
1814
|
-
out[11] = a[11] * b;
|
|
1815
|
-
out[12] = a[12] * b;
|
|
1816
|
-
out[13] = a[13] * b;
|
|
1817
|
-
out[14] = a[14] * b;
|
|
1818
|
-
out[15] = a[15] * b;
|
|
1819
|
-
return out;
|
|
1820
|
-
}
|
|
1821
|
-
/**
|
|
1822
|
-
* Adds two mat4's after multiplying each element of the second operand by a scalar value.
|
|
1823
|
-
*
|
|
1824
|
-
* @param {mat4} out the receiving vector
|
|
1825
|
-
* @param {ReadonlyMat4} a the first operand
|
|
1826
|
-
* @param {ReadonlyMat4} b the second operand
|
|
1827
|
-
* @param {Number} scale the amount to scale b's elements by before adding
|
|
1828
|
-
* @returns {mat4} out
|
|
1829
|
-
*/
|
|
1830
|
-
|
|
1831
|
-
function multiplyScalarAndAdd(out, a, b, scale) {
|
|
1832
|
-
out[0] = a[0] + b[0] * scale;
|
|
1833
|
-
out[1] = a[1] + b[1] * scale;
|
|
1834
|
-
out[2] = a[2] + b[2] * scale;
|
|
1835
|
-
out[3] = a[3] + b[3] * scale;
|
|
1836
|
-
out[4] = a[4] + b[4] * scale;
|
|
1837
|
-
out[5] = a[5] + b[5] * scale;
|
|
1838
|
-
out[6] = a[6] + b[6] * scale;
|
|
1839
|
-
out[7] = a[7] + b[7] * scale;
|
|
1840
|
-
out[8] = a[8] + b[8] * scale;
|
|
1841
|
-
out[9] = a[9] + b[9] * scale;
|
|
1842
|
-
out[10] = a[10] + b[10] * scale;
|
|
1843
|
-
out[11] = a[11] + b[11] * scale;
|
|
1844
|
-
out[12] = a[12] + b[12] * scale;
|
|
1845
|
-
out[13] = a[13] + b[13] * scale;
|
|
1846
|
-
out[14] = a[14] + b[14] * scale;
|
|
1847
|
-
out[15] = a[15] + b[15] * scale;
|
|
1848
|
-
return out;
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
|
|
1852
|
-
*
|
|
1853
|
-
* @param {ReadonlyMat4} a The first matrix.
|
|
1854
|
-
* @param {ReadonlyMat4} b The second matrix.
|
|
1855
|
-
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
1856
|
-
*/
|
|
1857
|
-
|
|
1858
|
-
function exactEquals(a, b) {
|
|
1859
|
-
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8] && a[9] === b[9] && a[10] === b[10] && a[11] === b[11] && a[12] === b[12] && a[13] === b[13] && a[14] === b[14] && a[15] === b[15];
|
|
1860
|
-
}
|
|
1861
|
-
/**
|
|
1862
|
-
* Returns whether or not the matrices have approximately the same elements in the same position.
|
|
1863
|
-
*
|
|
1864
|
-
* @param {ReadonlyMat4} a The first matrix.
|
|
1865
|
-
* @param {ReadonlyMat4} b The second matrix.
|
|
1866
|
-
* @returns {Boolean} True if the matrices are equal, false otherwise.
|
|
1867
|
-
*/
|
|
1868
|
-
|
|
1869
|
-
function equals(a, b) {
|
|
1870
|
-
var a0 = a[0],
|
|
1871
|
-
a1 = a[1],
|
|
1872
|
-
a2 = a[2],
|
|
1873
|
-
a3 = a[3];
|
|
1874
|
-
var a4 = a[4],
|
|
1875
|
-
a5 = a[5],
|
|
1876
|
-
a6 = a[6],
|
|
1877
|
-
a7 = a[7];
|
|
1878
|
-
var a8 = a[8],
|
|
1879
|
-
a9 = a[9],
|
|
1880
|
-
a10 = a[10],
|
|
1881
|
-
a11 = a[11];
|
|
1882
|
-
var a12 = a[12],
|
|
1883
|
-
a13 = a[13],
|
|
1884
|
-
a14 = a[14],
|
|
1885
|
-
a15 = a[15];
|
|
1886
|
-
var b0 = b[0],
|
|
1887
|
-
b1 = b[1],
|
|
1888
|
-
b2 = b[2],
|
|
1889
|
-
b3 = b[3];
|
|
1890
|
-
var b4 = b[4],
|
|
1891
|
-
b5 = b[5],
|
|
1892
|
-
b6 = b[6],
|
|
1893
|
-
b7 = b[7];
|
|
1894
|
-
var b8 = b[8],
|
|
1895
|
-
b9 = b[9],
|
|
1896
|
-
b10 = b[10],
|
|
1897
|
-
b11 = b[11];
|
|
1898
|
-
var b12 = b[12],
|
|
1899
|
-
b13 = b[13],
|
|
1900
|
-
b14 = b[14],
|
|
1901
|
-
b15 = b[15];
|
|
1902
|
-
return Math.abs(a0 - b0) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a8), Math.abs(b8)) && Math.abs(a9 - b9) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a9), Math.abs(b9)) && Math.abs(a10 - b10) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a10), Math.abs(b10)) && Math.abs(a11 - b11) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a11), Math.abs(b11)) && Math.abs(a12 - b12) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a12), Math.abs(b12)) && Math.abs(a13 - b13) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a13), Math.abs(b13)) && Math.abs(a14 - b14) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a14), Math.abs(b14)) && Math.abs(a15 - b15) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a15), Math.abs(b15));
|
|
1903
|
-
}
|
|
1904
|
-
/**
|
|
1905
|
-
* Alias for {@link mat4.multiply}
|
|
1906
|
-
* @function
|
|
1907
|
-
*/
|
|
1908
|
-
|
|
1909
|
-
var mul = multiply;
|
|
1910
|
-
/**
|
|
1911
|
-
* Alias for {@link mat4.subtract}
|
|
1912
|
-
* @function
|
|
1913
|
-
*/
|
|
1914
|
-
|
|
1915
|
-
var sub = subtract;
|
|
1916
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
1917
|
-
add: () => (add),
|
|
1918
|
-
adjoint: () => (adjoint),
|
|
1919
|
-
clone: () => (clone),
|
|
1920
|
-
copy: () => (copy),
|
|
1921
|
-
create: () => (create),
|
|
1922
|
-
determinant: () => (determinant),
|
|
1923
|
-
equals: () => (equals),
|
|
1924
|
-
exactEquals: () => (exactEquals),
|
|
1925
|
-
frob: () => (frob),
|
|
1926
|
-
fromQuat: () => (fromQuat),
|
|
1927
|
-
fromQuat2: () => (fromQuat2),
|
|
1928
|
-
fromRotation: () => (fromRotation),
|
|
1929
|
-
fromRotationTranslation: () => (fromRotationTranslation),
|
|
1930
|
-
fromRotationTranslationScale: () => (fromRotationTranslationScale),
|
|
1931
|
-
fromRotationTranslationScaleOrigin: () => (fromRotationTranslationScaleOrigin),
|
|
1932
|
-
fromScaling: () => (fromScaling),
|
|
1933
|
-
fromTranslation: () => (fromTranslation),
|
|
1934
|
-
fromValues: () => (fromValues),
|
|
1935
|
-
fromXRotation: () => (fromXRotation),
|
|
1936
|
-
fromYRotation: () => (fromYRotation),
|
|
1937
|
-
fromZRotation: () => (fromZRotation),
|
|
1938
|
-
frustum: () => (frustum),
|
|
1939
|
-
getRotation: () => (getRotation),
|
|
1940
|
-
getScaling: () => (getScaling),
|
|
1941
|
-
getTranslation: () => (getTranslation),
|
|
1942
|
-
identity: () => (identity),
|
|
1943
|
-
invert: () => (invert),
|
|
1944
|
-
lookAt: () => (lookAt),
|
|
1945
|
-
mul: () => (mul),
|
|
1946
|
-
multiply: () => (multiply),
|
|
1947
|
-
multiplyScalar: () => (multiplyScalar),
|
|
1948
|
-
multiplyScalarAndAdd: () => (multiplyScalarAndAdd),
|
|
1949
|
-
ortho: () => (ortho),
|
|
1950
|
-
orthoNO: () => (orthoNO),
|
|
1951
|
-
orthoZO: () => (orthoZO),
|
|
1952
|
-
perspective: () => (perspective),
|
|
1953
|
-
perspectiveFromFieldOfView: () => (perspectiveFromFieldOfView),
|
|
1954
|
-
perspectiveNO: () => (perspectiveNO),
|
|
1955
|
-
perspectiveZO: () => (perspectiveZO),
|
|
1956
|
-
rotate: () => (rotate),
|
|
1957
|
-
rotateX: () => (rotateX),
|
|
1958
|
-
rotateY: () => (rotateY),
|
|
1959
|
-
rotateZ: () => (rotateZ),
|
|
1960
|
-
scale: () => (scale),
|
|
1961
|
-
set: () => (set),
|
|
1962
|
-
str: () => (str),
|
|
1963
|
-
sub: () => (sub),
|
|
1964
|
-
subtract: () => (subtract),
|
|
1965
|
-
targetTo: () => (targetTo),
|
|
1966
|
-
translate: () => (translate),
|
|
1967
|
-
transpose: () => (transpose)
|
|
1968
|
-
});
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
},
|
|
1972
|
-
6462(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
1973
|
-
/* import */ var _common_js__rspack_import_0 = __webpack_require__(23172);
|
|
1974
|
-
/* import */ var _mat3_js__rspack_import_1 = __webpack_require__(45878);
|
|
1975
|
-
/* import */ var _vec3_js__rspack_import_2 = __webpack_require__(64062);
|
|
1976
|
-
/* import */ var _vec4_js__rspack_import_3 = __webpack_require__(70911);
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
/**
|
|
1982
|
-
* Quaternion
|
|
1983
|
-
* @module quat
|
|
1984
|
-
*/
|
|
1985
|
-
|
|
1986
|
-
/**
|
|
1987
|
-
* Creates a new identity quat
|
|
1988
|
-
*
|
|
1989
|
-
* @returns {quat} a new quaternion
|
|
1990
|
-
*/
|
|
1991
|
-
|
|
1992
|
-
function create() {
|
|
1993
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(4);
|
|
1994
|
-
|
|
1995
|
-
if (_common_js__rspack_import_0/* .ARRAY_TYPE */.tb != Float32Array) {
|
|
1996
|
-
out[0] = 0;
|
|
1997
|
-
out[1] = 0;
|
|
1998
|
-
out[2] = 0;
|
|
1999
|
-
}
|
|
2000
|
-
|
|
2001
|
-
out[3] = 1;
|
|
2002
|
-
return out;
|
|
2003
|
-
}
|
|
2004
|
-
/**
|
|
2005
|
-
* Set a quat to the identity quaternion
|
|
2006
|
-
*
|
|
2007
|
-
* @param {quat} out the receiving quaternion
|
|
2008
|
-
* @returns {quat} out
|
|
2009
|
-
*/
|
|
2010
|
-
|
|
2011
|
-
function identity(out) {
|
|
2012
|
-
out[0] = 0;
|
|
2013
|
-
out[1] = 0;
|
|
2014
|
-
out[2] = 0;
|
|
2015
|
-
out[3] = 1;
|
|
2016
|
-
return out;
|
|
2017
|
-
}
|
|
2018
|
-
/**
|
|
2019
|
-
* Sets a quat from the given angle and rotation axis,
|
|
2020
|
-
* then returns it.
|
|
2021
|
-
*
|
|
2022
|
-
* @param {quat} out the receiving quaternion
|
|
2023
|
-
* @param {ReadonlyVec3} axis the axis around which to rotate
|
|
2024
|
-
* @param {Number} rad the angle in radians
|
|
2025
|
-
* @returns {quat} out
|
|
2026
|
-
**/
|
|
2027
|
-
|
|
2028
|
-
function setAxisAngle(out, axis, rad) {
|
|
2029
|
-
rad = rad * 0.5;
|
|
2030
|
-
var s = Math.sin(rad);
|
|
2031
|
-
out[0] = s * axis[0];
|
|
2032
|
-
out[1] = s * axis[1];
|
|
2033
|
-
out[2] = s * axis[2];
|
|
2034
|
-
out[3] = Math.cos(rad);
|
|
2035
|
-
return out;
|
|
2036
|
-
}
|
|
2037
|
-
/**
|
|
2038
|
-
* Gets the rotation axis and angle for a given
|
|
2039
|
-
* quaternion. If a quaternion is created with
|
|
2040
|
-
* setAxisAngle, this method will return the same
|
|
2041
|
-
* values as providied in the original parameter list
|
|
2042
|
-
* OR functionally equivalent values.
|
|
2043
|
-
* Example: The quaternion formed by axis [0, 0, 1] and
|
|
2044
|
-
* angle -90 is the same as the quaternion formed by
|
|
2045
|
-
* [0, 0, 1] and 270. This method favors the latter.
|
|
2046
|
-
* @param {vec3} out_axis Vector receiving the axis of rotation
|
|
2047
|
-
* @param {ReadonlyQuat} q Quaternion to be decomposed
|
|
2048
|
-
* @return {Number} Angle, in radians, of the rotation
|
|
2049
|
-
*/
|
|
2050
|
-
|
|
2051
|
-
function getAxisAngle(out_axis, q) {
|
|
2052
|
-
var rad = Math.acos(q[3]) * 2.0;
|
|
2053
|
-
var s = Math.sin(rad / 2.0);
|
|
2054
|
-
|
|
2055
|
-
if (s > _common_js__rspack_import_0/* .EPSILON */.p8) {
|
|
2056
|
-
out_axis[0] = q[0] / s;
|
|
2057
|
-
out_axis[1] = q[1] / s;
|
|
2058
|
-
out_axis[2] = q[2] / s;
|
|
2059
|
-
} else {
|
|
2060
|
-
// If s is zero, return any axis (no rotation - axis does not matter)
|
|
2061
|
-
out_axis[0] = 1;
|
|
2062
|
-
out_axis[1] = 0;
|
|
2063
|
-
out_axis[2] = 0;
|
|
2064
|
-
}
|
|
2065
|
-
|
|
2066
|
-
return rad;
|
|
2067
|
-
}
|
|
2068
|
-
/**
|
|
2069
|
-
* Gets the angular distance between two unit quaternions
|
|
2070
|
-
*
|
|
2071
|
-
* @param {ReadonlyQuat} a Origin unit quaternion
|
|
2072
|
-
* @param {ReadonlyQuat} b Destination unit quaternion
|
|
2073
|
-
* @return {Number} Angle, in radians, between the two quaternions
|
|
2074
|
-
*/
|
|
2075
|
-
|
|
2076
|
-
function getAngle(a, b) {
|
|
2077
|
-
var dotproduct = dot(a, b);
|
|
2078
|
-
return Math.acos(2 * dotproduct * dotproduct - 1);
|
|
2079
|
-
}
|
|
2080
|
-
/**
|
|
2081
|
-
* Multiplies two quat's
|
|
2082
|
-
*
|
|
2083
|
-
* @param {quat} out the receiving quaternion
|
|
2084
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2085
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2086
|
-
* @returns {quat} out
|
|
2087
|
-
*/
|
|
2088
|
-
|
|
2089
|
-
function multiply(out, a, b) {
|
|
2090
|
-
var ax = a[0],
|
|
2091
|
-
ay = a[1],
|
|
2092
|
-
az = a[2],
|
|
2093
|
-
aw = a[3];
|
|
2094
|
-
var bx = b[0],
|
|
2095
|
-
by = b[1],
|
|
2096
|
-
bz = b[2],
|
|
2097
|
-
bw = b[3];
|
|
2098
|
-
out[0] = ax * bw + aw * bx + ay * bz - az * by;
|
|
2099
|
-
out[1] = ay * bw + aw * by + az * bx - ax * bz;
|
|
2100
|
-
out[2] = az * bw + aw * bz + ax * by - ay * bx;
|
|
2101
|
-
out[3] = aw * bw - ax * bx - ay * by - az * bz;
|
|
2102
|
-
return out;
|
|
2103
|
-
}
|
|
2104
|
-
/**
|
|
2105
|
-
* Rotates a quaternion by the given angle about the X axis
|
|
2106
|
-
*
|
|
2107
|
-
* @param {quat} out quat receiving operation result
|
|
2108
|
-
* @param {ReadonlyQuat} a quat to rotate
|
|
2109
|
-
* @param {number} rad angle (in radians) to rotate
|
|
2110
|
-
* @returns {quat} out
|
|
2111
|
-
*/
|
|
2112
|
-
|
|
2113
|
-
function rotateX(out, a, rad) {
|
|
2114
|
-
rad *= 0.5;
|
|
2115
|
-
var ax = a[0],
|
|
2116
|
-
ay = a[1],
|
|
2117
|
-
az = a[2],
|
|
2118
|
-
aw = a[3];
|
|
2119
|
-
var bx = Math.sin(rad),
|
|
2120
|
-
bw = Math.cos(rad);
|
|
2121
|
-
out[0] = ax * bw + aw * bx;
|
|
2122
|
-
out[1] = ay * bw + az * bx;
|
|
2123
|
-
out[2] = az * bw - ay * bx;
|
|
2124
|
-
out[3] = aw * bw - ax * bx;
|
|
2125
|
-
return out;
|
|
2126
|
-
}
|
|
2127
|
-
/**
|
|
2128
|
-
* Rotates a quaternion by the given angle about the Y axis
|
|
2129
|
-
*
|
|
2130
|
-
* @param {quat} out quat receiving operation result
|
|
2131
|
-
* @param {ReadonlyQuat} a quat to rotate
|
|
2132
|
-
* @param {number} rad angle (in radians) to rotate
|
|
2133
|
-
* @returns {quat} out
|
|
2134
|
-
*/
|
|
2135
|
-
|
|
2136
|
-
function rotateY(out, a, rad) {
|
|
2137
|
-
rad *= 0.5;
|
|
2138
|
-
var ax = a[0],
|
|
2139
|
-
ay = a[1],
|
|
2140
|
-
az = a[2],
|
|
2141
|
-
aw = a[3];
|
|
2142
|
-
var by = Math.sin(rad),
|
|
2143
|
-
bw = Math.cos(rad);
|
|
2144
|
-
out[0] = ax * bw - az * by;
|
|
2145
|
-
out[1] = ay * bw + aw * by;
|
|
2146
|
-
out[2] = az * bw + ax * by;
|
|
2147
|
-
out[3] = aw * bw - ay * by;
|
|
2148
|
-
return out;
|
|
2149
|
-
}
|
|
2150
|
-
/**
|
|
2151
|
-
* Rotates a quaternion by the given angle about the Z axis
|
|
2152
|
-
*
|
|
2153
|
-
* @param {quat} out quat receiving operation result
|
|
2154
|
-
* @param {ReadonlyQuat} a quat to rotate
|
|
2155
|
-
* @param {number} rad angle (in radians) to rotate
|
|
2156
|
-
* @returns {quat} out
|
|
2157
|
-
*/
|
|
2158
|
-
|
|
2159
|
-
function rotateZ(out, a, rad) {
|
|
2160
|
-
rad *= 0.5;
|
|
2161
|
-
var ax = a[0],
|
|
2162
|
-
ay = a[1],
|
|
2163
|
-
az = a[2],
|
|
2164
|
-
aw = a[3];
|
|
2165
|
-
var bz = Math.sin(rad),
|
|
2166
|
-
bw = Math.cos(rad);
|
|
2167
|
-
out[0] = ax * bw + ay * bz;
|
|
2168
|
-
out[1] = ay * bw - ax * bz;
|
|
2169
|
-
out[2] = az * bw + aw * bz;
|
|
2170
|
-
out[3] = aw * bw - az * bz;
|
|
2171
|
-
return out;
|
|
2172
|
-
}
|
|
2173
|
-
/**
|
|
2174
|
-
* Calculates the W component of a quat from the X, Y, and Z components.
|
|
2175
|
-
* Assumes that quaternion is 1 unit in length.
|
|
2176
|
-
* Any existing W component will be ignored.
|
|
2177
|
-
*
|
|
2178
|
-
* @param {quat} out the receiving quaternion
|
|
2179
|
-
* @param {ReadonlyQuat} a quat to calculate W component of
|
|
2180
|
-
* @returns {quat} out
|
|
2181
|
-
*/
|
|
2182
|
-
|
|
2183
|
-
function calculateW(out, a) {
|
|
2184
|
-
var x = a[0],
|
|
2185
|
-
y = a[1],
|
|
2186
|
-
z = a[2];
|
|
2187
|
-
out[0] = x;
|
|
2188
|
-
out[1] = y;
|
|
2189
|
-
out[2] = z;
|
|
2190
|
-
out[3] = Math.sqrt(Math.abs(1.0 - x * x - y * y - z * z));
|
|
2191
|
-
return out;
|
|
2192
|
-
}
|
|
2193
|
-
/**
|
|
2194
|
-
* Calculate the exponential of a unit quaternion.
|
|
2195
|
-
*
|
|
2196
|
-
* @param {quat} out the receiving quaternion
|
|
2197
|
-
* @param {ReadonlyQuat} a quat to calculate the exponential of
|
|
2198
|
-
* @returns {quat} out
|
|
2199
|
-
*/
|
|
2200
|
-
|
|
2201
|
-
function exp(out, a) {
|
|
2202
|
-
var x = a[0],
|
|
2203
|
-
y = a[1],
|
|
2204
|
-
z = a[2],
|
|
2205
|
-
w = a[3];
|
|
2206
|
-
var r = Math.sqrt(x * x + y * y + z * z);
|
|
2207
|
-
var et = Math.exp(w);
|
|
2208
|
-
var s = r > 0 ? et * Math.sin(r) / r : 0;
|
|
2209
|
-
out[0] = x * s;
|
|
2210
|
-
out[1] = y * s;
|
|
2211
|
-
out[2] = z * s;
|
|
2212
|
-
out[3] = et * Math.cos(r);
|
|
2213
|
-
return out;
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Calculate the natural logarithm of a unit quaternion.
|
|
2217
|
-
*
|
|
2218
|
-
* @param {quat} out the receiving quaternion
|
|
2219
|
-
* @param {ReadonlyQuat} a quat to calculate the exponential of
|
|
2220
|
-
* @returns {quat} out
|
|
2221
|
-
*/
|
|
2222
|
-
|
|
2223
|
-
function ln(out, a) {
|
|
2224
|
-
var x = a[0],
|
|
2225
|
-
y = a[1],
|
|
2226
|
-
z = a[2],
|
|
2227
|
-
w = a[3];
|
|
2228
|
-
var r = Math.sqrt(x * x + y * y + z * z);
|
|
2229
|
-
var t = r > 0 ? Math.atan2(r, w) / r : 0;
|
|
2230
|
-
out[0] = x * t;
|
|
2231
|
-
out[1] = y * t;
|
|
2232
|
-
out[2] = z * t;
|
|
2233
|
-
out[3] = 0.5 * Math.log(x * x + y * y + z * z + w * w);
|
|
2234
|
-
return out;
|
|
2235
|
-
}
|
|
2236
|
-
/**
|
|
2237
|
-
* Calculate the scalar power of a unit quaternion.
|
|
2238
|
-
*
|
|
2239
|
-
* @param {quat} out the receiving quaternion
|
|
2240
|
-
* @param {ReadonlyQuat} a quat to calculate the exponential of
|
|
2241
|
-
* @param {Number} b amount to scale the quaternion by
|
|
2242
|
-
* @returns {quat} out
|
|
2243
|
-
*/
|
|
2244
|
-
|
|
2245
|
-
function pow(out, a, b) {
|
|
2246
|
-
ln(out, a);
|
|
2247
|
-
scale(out, out, b);
|
|
2248
|
-
exp(out, out);
|
|
2249
|
-
return out;
|
|
2250
|
-
}
|
|
2251
|
-
/**
|
|
2252
|
-
* Performs a spherical linear interpolation between two quat
|
|
2253
|
-
*
|
|
2254
|
-
* @param {quat} out the receiving quaternion
|
|
2255
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2256
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2257
|
-
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2258
|
-
* @returns {quat} out
|
|
2259
|
-
*/
|
|
2260
|
-
|
|
2261
|
-
function slerp(out, a, b, t) {
|
|
2262
|
-
// benchmarks:
|
|
2263
|
-
// http://jsperf.com/quaternion-slerp-implementations
|
|
2264
|
-
var ax = a[0],
|
|
2265
|
-
ay = a[1],
|
|
2266
|
-
az = a[2],
|
|
2267
|
-
aw = a[3];
|
|
2268
|
-
var bx = b[0],
|
|
2269
|
-
by = b[1],
|
|
2270
|
-
bz = b[2],
|
|
2271
|
-
bw = b[3];
|
|
2272
|
-
var omega, cosom, sinom, scale0, scale1; // calc cosine
|
|
2273
|
-
|
|
2274
|
-
cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
|
|
2275
|
-
|
|
2276
|
-
if (cosom < 0.0) {
|
|
2277
|
-
cosom = -cosom;
|
|
2278
|
-
bx = -bx;
|
|
2279
|
-
by = -by;
|
|
2280
|
-
bz = -bz;
|
|
2281
|
-
bw = -bw;
|
|
2282
|
-
} // calculate coefficients
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
if (1.0 - cosom > _common_js__rspack_import_0/* .EPSILON */.p8) {
|
|
2286
|
-
// standard case (slerp)
|
|
2287
|
-
omega = Math.acos(cosom);
|
|
2288
|
-
sinom = Math.sin(omega);
|
|
2289
|
-
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
2290
|
-
scale1 = Math.sin(t * omega) / sinom;
|
|
2291
|
-
} else {
|
|
2292
|
-
// "from" and "to" quaternions are very close
|
|
2293
|
-
// ... so we can do a linear interpolation
|
|
2294
|
-
scale0 = 1.0 - t;
|
|
2295
|
-
scale1 = t;
|
|
2296
|
-
} // calculate final values
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
out[0] = scale0 * ax + scale1 * bx;
|
|
2300
|
-
out[1] = scale0 * ay + scale1 * by;
|
|
2301
|
-
out[2] = scale0 * az + scale1 * bz;
|
|
2302
|
-
out[3] = scale0 * aw + scale1 * bw;
|
|
2303
|
-
return out;
|
|
2304
|
-
}
|
|
2305
|
-
/**
|
|
2306
|
-
* Generates a random unit quaternion
|
|
2307
|
-
*
|
|
2308
|
-
* @param {quat} out the receiving quaternion
|
|
2309
|
-
* @returns {quat} out
|
|
2310
|
-
*/
|
|
2311
|
-
|
|
2312
|
-
function random(out) {
|
|
2313
|
-
// Implementation of http://planning.cs.uiuc.edu/node198.html
|
|
2314
|
-
// TODO: Calling random 3 times is probably not the fastest solution
|
|
2315
|
-
var u1 = glMatrix.RANDOM();
|
|
2316
|
-
var u2 = glMatrix.RANDOM();
|
|
2317
|
-
var u3 = glMatrix.RANDOM();
|
|
2318
|
-
var sqrt1MinusU1 = Math.sqrt(1 - u1);
|
|
2319
|
-
var sqrtU1 = Math.sqrt(u1);
|
|
2320
|
-
out[0] = sqrt1MinusU1 * Math.sin(2.0 * Math.PI * u2);
|
|
2321
|
-
out[1] = sqrt1MinusU1 * Math.cos(2.0 * Math.PI * u2);
|
|
2322
|
-
out[2] = sqrtU1 * Math.sin(2.0 * Math.PI * u3);
|
|
2323
|
-
out[3] = sqrtU1 * Math.cos(2.0 * Math.PI * u3);
|
|
2324
|
-
return out;
|
|
2325
|
-
}
|
|
2326
|
-
/**
|
|
2327
|
-
* Calculates the inverse of a quat
|
|
2328
|
-
*
|
|
2329
|
-
* @param {quat} out the receiving quaternion
|
|
2330
|
-
* @param {ReadonlyQuat} a quat to calculate inverse of
|
|
2331
|
-
* @returns {quat} out
|
|
2332
|
-
*/
|
|
2333
|
-
|
|
2334
|
-
function invert(out, a) {
|
|
2335
|
-
var a0 = a[0],
|
|
2336
|
-
a1 = a[1],
|
|
2337
|
-
a2 = a[2],
|
|
2338
|
-
a3 = a[3];
|
|
2339
|
-
var dot = a0 * a0 + a1 * a1 + a2 * a2 + a3 * a3;
|
|
2340
|
-
var invDot = dot ? 1.0 / dot : 0; // TODO: Would be faster to return [0,0,0,0] immediately if dot == 0
|
|
2341
|
-
|
|
2342
|
-
out[0] = -a0 * invDot;
|
|
2343
|
-
out[1] = -a1 * invDot;
|
|
2344
|
-
out[2] = -a2 * invDot;
|
|
2345
|
-
out[3] = a3 * invDot;
|
|
2346
|
-
return out;
|
|
2347
|
-
}
|
|
2348
|
-
/**
|
|
2349
|
-
* Calculates the conjugate of a quat
|
|
2350
|
-
* If the quaternion is normalized, this function is faster than quat.inverse and produces the same result.
|
|
2351
|
-
*
|
|
2352
|
-
* @param {quat} out the receiving quaternion
|
|
2353
|
-
* @param {ReadonlyQuat} a quat to calculate conjugate of
|
|
2354
|
-
* @returns {quat} out
|
|
2355
|
-
*/
|
|
2356
|
-
|
|
2357
|
-
function conjugate(out, a) {
|
|
2358
|
-
out[0] = -a[0];
|
|
2359
|
-
out[1] = -a[1];
|
|
2360
|
-
out[2] = -a[2];
|
|
2361
|
-
out[3] = a[3];
|
|
2362
|
-
return out;
|
|
2363
|
-
}
|
|
2364
|
-
/**
|
|
2365
|
-
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
2366
|
-
*
|
|
2367
|
-
* NOTE: The resultant quaternion is not normalized, so you should be sure
|
|
2368
|
-
* to renormalize the quaternion yourself where necessary.
|
|
2369
|
-
*
|
|
2370
|
-
* @param {quat} out the receiving quaternion
|
|
2371
|
-
* @param {ReadonlyMat3} m rotation matrix
|
|
2372
|
-
* @returns {quat} out
|
|
2373
|
-
* @function
|
|
2374
|
-
*/
|
|
2375
|
-
|
|
2376
|
-
function fromMat3(out, m) {
|
|
2377
|
-
// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
|
|
2378
|
-
// article "Quaternion Calculus and Fast Animation".
|
|
2379
|
-
var fTrace = m[0] + m[4] + m[8];
|
|
2380
|
-
var fRoot;
|
|
2381
|
-
|
|
2382
|
-
if (fTrace > 0.0) {
|
|
2383
|
-
// |w| > 1/2, may as well choose w > 1/2
|
|
2384
|
-
fRoot = Math.sqrt(fTrace + 1.0); // 2w
|
|
2385
|
-
|
|
2386
|
-
out[3] = 0.5 * fRoot;
|
|
2387
|
-
fRoot = 0.5 / fRoot; // 1/(4w)
|
|
2388
|
-
|
|
2389
|
-
out[0] = (m[5] - m[7]) * fRoot;
|
|
2390
|
-
out[1] = (m[6] - m[2]) * fRoot;
|
|
2391
|
-
out[2] = (m[1] - m[3]) * fRoot;
|
|
2392
|
-
} else {
|
|
2393
|
-
// |w| <= 1/2
|
|
2394
|
-
var i = 0;
|
|
2395
|
-
if (m[4] > m[0]) i = 1;
|
|
2396
|
-
if (m[8] > m[i * 3 + i]) i = 2;
|
|
2397
|
-
var j = (i + 1) % 3;
|
|
2398
|
-
var k = (i + 2) % 3;
|
|
2399
|
-
fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
|
|
2400
|
-
out[i] = 0.5 * fRoot;
|
|
2401
|
-
fRoot = 0.5 / fRoot;
|
|
2402
|
-
out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
|
|
2403
|
-
out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
|
|
2404
|
-
out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
|
-
return out;
|
|
2408
|
-
}
|
|
2409
|
-
/**
|
|
2410
|
-
* Creates a quaternion from the given euler angle x, y, z.
|
|
2411
|
-
*
|
|
2412
|
-
* @param {quat} out the receiving quaternion
|
|
2413
|
-
* @param {x} Angle to rotate around X axis in degrees.
|
|
2414
|
-
* @param {y} Angle to rotate around Y axis in degrees.
|
|
2415
|
-
* @param {z} Angle to rotate around Z axis in degrees.
|
|
2416
|
-
* @returns {quat} out
|
|
2417
|
-
* @function
|
|
2418
|
-
*/
|
|
2419
|
-
|
|
2420
|
-
function fromEuler(out, x, y, z) {
|
|
2421
|
-
var halfToRad = 0.5 * Math.PI / 180.0;
|
|
2422
|
-
x *= halfToRad;
|
|
2423
|
-
y *= halfToRad;
|
|
2424
|
-
z *= halfToRad;
|
|
2425
|
-
var sx = Math.sin(x);
|
|
2426
|
-
var cx = Math.cos(x);
|
|
2427
|
-
var sy = Math.sin(y);
|
|
2428
|
-
var cy = Math.cos(y);
|
|
2429
|
-
var sz = Math.sin(z);
|
|
2430
|
-
var cz = Math.cos(z);
|
|
2431
|
-
out[0] = sx * cy * cz - cx * sy * sz;
|
|
2432
|
-
out[1] = cx * sy * cz + sx * cy * sz;
|
|
2433
|
-
out[2] = cx * cy * sz - sx * sy * cz;
|
|
2434
|
-
out[3] = cx * cy * cz + sx * sy * sz;
|
|
2435
|
-
return out;
|
|
2436
|
-
}
|
|
2437
|
-
/**
|
|
2438
|
-
* Returns a string representation of a quatenion
|
|
2439
|
-
*
|
|
2440
|
-
* @param {ReadonlyQuat} a vector to represent as a string
|
|
2441
|
-
* @returns {String} string representation of the vector
|
|
2442
|
-
*/
|
|
2443
|
-
|
|
2444
|
-
function str(a) {
|
|
2445
|
-
return "quat(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")";
|
|
2446
|
-
}
|
|
2447
|
-
/**
|
|
2448
|
-
* Creates a new quat initialized with values from an existing quaternion
|
|
2449
|
-
*
|
|
2450
|
-
* @param {ReadonlyQuat} a quaternion to clone
|
|
2451
|
-
* @returns {quat} a new quaternion
|
|
2452
|
-
* @function
|
|
2453
|
-
*/
|
|
2454
|
-
|
|
2455
|
-
var clone = _vec4_js__rspack_import_3/* .clone */.o8;
|
|
2456
|
-
/**
|
|
2457
|
-
* Creates a new quat initialized with the given values
|
|
2458
|
-
*
|
|
2459
|
-
* @param {Number} x X component
|
|
2460
|
-
* @param {Number} y Y component
|
|
2461
|
-
* @param {Number} z Z component
|
|
2462
|
-
* @param {Number} w W component
|
|
2463
|
-
* @returns {quat} a new quaternion
|
|
2464
|
-
* @function
|
|
2465
|
-
*/
|
|
2466
|
-
|
|
2467
|
-
var fromValues = _vec4_js__rspack_import_3/* .fromValues */.fA;
|
|
2468
|
-
/**
|
|
2469
|
-
* Copy the values from one quat to another
|
|
2470
|
-
*
|
|
2471
|
-
* @param {quat} out the receiving quaternion
|
|
2472
|
-
* @param {ReadonlyQuat} a the source quaternion
|
|
2473
|
-
* @returns {quat} out
|
|
2474
|
-
* @function
|
|
2475
|
-
*/
|
|
2476
|
-
|
|
2477
|
-
var copy = _vec4_js__rspack_import_3/* .copy */.C;
|
|
2478
|
-
/**
|
|
2479
|
-
* Set the components of a quat to the given values
|
|
2480
|
-
*
|
|
2481
|
-
* @param {quat} out the receiving quaternion
|
|
2482
|
-
* @param {Number} x X component
|
|
2483
|
-
* @param {Number} y Y component
|
|
2484
|
-
* @param {Number} z Z component
|
|
2485
|
-
* @param {Number} w W component
|
|
2486
|
-
* @returns {quat} out
|
|
2487
|
-
* @function
|
|
2488
|
-
*/
|
|
2489
|
-
|
|
2490
|
-
var set = _vec4_js__rspack_import_3/* .set */.hZ;
|
|
2491
|
-
/**
|
|
2492
|
-
* Adds two quat's
|
|
2493
|
-
*
|
|
2494
|
-
* @param {quat} out the receiving quaternion
|
|
2495
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2496
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2497
|
-
* @returns {quat} out
|
|
2498
|
-
* @function
|
|
2499
|
-
*/
|
|
2500
|
-
|
|
2501
|
-
var add = _vec4_js__rspack_import_3/* .add */.WQ;
|
|
2502
|
-
/**
|
|
2503
|
-
* Alias for {@link quat.multiply}
|
|
2504
|
-
* @function
|
|
2505
|
-
*/
|
|
2506
|
-
|
|
2507
|
-
var mul = (/* unused pure expression or super */ null && (multiply));
|
|
2508
|
-
/**
|
|
2509
|
-
* Scales a quat by a scalar number
|
|
2510
|
-
*
|
|
2511
|
-
* @param {quat} out the receiving vector
|
|
2512
|
-
* @param {ReadonlyQuat} a the vector to scale
|
|
2513
|
-
* @param {Number} b amount to scale the vector by
|
|
2514
|
-
* @returns {quat} out
|
|
2515
|
-
* @function
|
|
2516
|
-
*/
|
|
2517
|
-
|
|
2518
|
-
var scale = _vec4_js__rspack_import_3/* .scale */.hs;
|
|
2519
|
-
/**
|
|
2520
|
-
* Calculates the dot product of two quat's
|
|
2521
|
-
*
|
|
2522
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2523
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2524
|
-
* @returns {Number} dot product of a and b
|
|
2525
|
-
* @function
|
|
2526
|
-
*/
|
|
2527
|
-
|
|
2528
|
-
var dot = _vec4_js__rspack_import_3/* .dot */.Om;
|
|
2529
|
-
/**
|
|
2530
|
-
* Performs a linear interpolation between two quat's
|
|
2531
|
-
*
|
|
2532
|
-
* @param {quat} out the receiving quaternion
|
|
2533
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2534
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2535
|
-
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2536
|
-
* @returns {quat} out
|
|
2537
|
-
* @function
|
|
2538
|
-
*/
|
|
2539
|
-
|
|
2540
|
-
var lerp = _vec4_js__rspack_import_3/* .lerp */.Cc;
|
|
2541
|
-
/**
|
|
2542
|
-
* Calculates the length of a quat
|
|
2543
|
-
*
|
|
2544
|
-
* @param {ReadonlyQuat} a vector to calculate length of
|
|
2545
|
-
* @returns {Number} length of a
|
|
2546
|
-
*/
|
|
2547
|
-
|
|
2548
|
-
var length = _vec4_js__rspack_import_3/* .length */.Bw;
|
|
2549
|
-
/**
|
|
2550
|
-
* Alias for {@link quat.length}
|
|
2551
|
-
* @function
|
|
2552
|
-
*/
|
|
2553
|
-
|
|
2554
|
-
var len = (/* unused pure expression or super */ null && (length));
|
|
2555
|
-
/**
|
|
2556
|
-
* Calculates the squared length of a quat
|
|
2557
|
-
*
|
|
2558
|
-
* @param {ReadonlyQuat} a vector to calculate squared length of
|
|
2559
|
-
* @returns {Number} squared length of a
|
|
2560
|
-
* @function
|
|
2561
|
-
*/
|
|
2562
|
-
|
|
2563
|
-
var squaredLength = _vec4_js__rspack_import_3/* .squaredLength */.m3;
|
|
2564
|
-
/**
|
|
2565
|
-
* Alias for {@link quat.squaredLength}
|
|
2566
|
-
* @function
|
|
2567
|
-
*/
|
|
2568
|
-
|
|
2569
|
-
var sqrLen = (/* unused pure expression or super */ null && (squaredLength));
|
|
2570
|
-
/**
|
|
2571
|
-
* Normalize a quat
|
|
2572
|
-
*
|
|
2573
|
-
* @param {quat} out the receiving quaternion
|
|
2574
|
-
* @param {ReadonlyQuat} a quaternion to normalize
|
|
2575
|
-
* @returns {quat} out
|
|
2576
|
-
* @function
|
|
2577
|
-
*/
|
|
2578
|
-
|
|
2579
|
-
var normalize = _vec4_js__rspack_import_3/* .normalize */.S8;
|
|
2580
|
-
/**
|
|
2581
|
-
* Returns whether or not the quaternions have exactly the same elements in the same position (when compared with ===)
|
|
2582
|
-
*
|
|
2583
|
-
* @param {ReadonlyQuat} a The first quaternion.
|
|
2584
|
-
* @param {ReadonlyQuat} b The second quaternion.
|
|
2585
|
-
* @returns {Boolean} True if the vectors are equal, false otherwise.
|
|
2586
|
-
*/
|
|
2587
|
-
|
|
2588
|
-
var exactEquals = _vec4_js__rspack_import_3/* .exactEquals */.t2;
|
|
2589
|
-
/**
|
|
2590
|
-
* Returns whether or not the quaternions have approximately the same elements in the same position.
|
|
2591
|
-
*
|
|
2592
|
-
* @param {ReadonlyQuat} a The first vector.
|
|
2593
|
-
* @param {ReadonlyQuat} b The second vector.
|
|
2594
|
-
* @returns {Boolean} True if the vectors are equal, false otherwise.
|
|
2595
|
-
*/
|
|
2596
|
-
|
|
2597
|
-
var equals = _vec4_js__rspack_import_3/* .equals */.aI;
|
|
2598
|
-
/**
|
|
2599
|
-
* Sets a quaternion to represent the shortest rotation from one
|
|
2600
|
-
* vector to another.
|
|
2601
|
-
*
|
|
2602
|
-
* Both vectors are assumed to be unit length.
|
|
2603
|
-
*
|
|
2604
|
-
* @param {quat} out the receiving quaternion.
|
|
2605
|
-
* @param {ReadonlyVec3} a the initial vector
|
|
2606
|
-
* @param {ReadonlyVec3} b the destination vector
|
|
2607
|
-
* @returns {quat} out
|
|
2608
|
-
*/
|
|
2609
|
-
|
|
2610
|
-
var rotationTo = function () {
|
|
2611
|
-
var tmpvec3 = _vec3_js__rspack_import_2/* .create */.vt();
|
|
2612
|
-
var xUnitVec3 = _vec3_js__rspack_import_2/* .fromValues */.fA(1, 0, 0);
|
|
2613
|
-
var yUnitVec3 = _vec3_js__rspack_import_2/* .fromValues */.fA(0, 1, 0);
|
|
2614
|
-
return function (out, a, b) {
|
|
2615
|
-
var dot = _vec3_js__rspack_import_2/* .dot */.Om(a, b);
|
|
2616
|
-
|
|
2617
|
-
if (dot < -0.999999) {
|
|
2618
|
-
_vec3_js__rspack_import_2/* .cross */.$A(tmpvec3, xUnitVec3, a);
|
|
2619
|
-
if (_vec3_js__rspack_import_2/* .len */.Il(tmpvec3) < 0.000001) _vec3_js__rspack_import_2/* .cross */.$A(tmpvec3, yUnitVec3, a);
|
|
2620
|
-
_vec3_js__rspack_import_2/* .normalize */.S8(tmpvec3, tmpvec3);
|
|
2621
|
-
setAxisAngle(out, tmpvec3, Math.PI);
|
|
2622
|
-
return out;
|
|
2623
|
-
} else if (dot > 0.999999) {
|
|
2624
|
-
out[0] = 0;
|
|
2625
|
-
out[1] = 0;
|
|
2626
|
-
out[2] = 0;
|
|
2627
|
-
out[3] = 1;
|
|
2628
|
-
return out;
|
|
2629
|
-
} else {
|
|
2630
|
-
_vec3_js__rspack_import_2/* .cross */.$A(tmpvec3, a, b);
|
|
2631
|
-
out[0] = tmpvec3[0];
|
|
2632
|
-
out[1] = tmpvec3[1];
|
|
2633
|
-
out[2] = tmpvec3[2];
|
|
2634
|
-
out[3] = 1 + dot;
|
|
2635
|
-
return normalize(out, out);
|
|
2636
|
-
}
|
|
2637
|
-
};
|
|
2638
|
-
}();
|
|
2639
|
-
/**
|
|
2640
|
-
* Performs a spherical linear interpolation with two control points
|
|
2641
|
-
*
|
|
2642
|
-
* @param {quat} out the receiving quaternion
|
|
2643
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2644
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2645
|
-
* @param {ReadonlyQuat} c the third operand
|
|
2646
|
-
* @param {ReadonlyQuat} d the fourth operand
|
|
2647
|
-
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2648
|
-
* @returns {quat} out
|
|
2649
|
-
*/
|
|
2650
|
-
|
|
2651
|
-
var sqlerp = function () {
|
|
2652
|
-
var temp1 = create();
|
|
2653
|
-
var temp2 = create();
|
|
2654
|
-
return function (out, a, b, c, d, t) {
|
|
2655
|
-
slerp(temp1, a, d, t);
|
|
2656
|
-
slerp(temp2, b, c, t);
|
|
2657
|
-
slerp(out, temp1, temp2, 2 * t * (1 - t));
|
|
2658
|
-
return out;
|
|
2659
|
-
};
|
|
2660
|
-
}();
|
|
2661
|
-
/**
|
|
2662
|
-
* Sets the specified quaternion with values corresponding to the given
|
|
2663
|
-
* axes. Each axis is a vec3 and is expected to be unit length and
|
|
2664
|
-
* perpendicular to all other specified axes.
|
|
2665
|
-
*
|
|
2666
|
-
* @param {ReadonlyVec3} view the vector representing the viewing direction
|
|
2667
|
-
* @param {ReadonlyVec3} right the vector representing the local "right" direction
|
|
2668
|
-
* @param {ReadonlyVec3} up the vector representing the local "up" direction
|
|
2669
|
-
* @returns {quat} out
|
|
2670
|
-
*/
|
|
2671
|
-
|
|
2672
|
-
var setAxes = function () {
|
|
2673
|
-
var matr = _mat3_js__rspack_import_1.create();
|
|
2674
|
-
return function (out, view, right, up) {
|
|
2675
|
-
matr[0] = right[0];
|
|
2676
|
-
matr[3] = right[1];
|
|
2677
|
-
matr[6] = right[2];
|
|
2678
|
-
matr[1] = up[0];
|
|
2679
|
-
matr[4] = up[1];
|
|
2680
|
-
matr[7] = up[2];
|
|
2681
|
-
matr[2] = -view[0];
|
|
2682
|
-
matr[5] = -view[1];
|
|
2683
|
-
matr[8] = -view[2];
|
|
2684
|
-
return normalize(out, fromMat3(out, matr));
|
|
2685
|
-
};
|
|
2686
|
-
}();
|
|
2687
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
2688
|
-
Bw: () => (length),
|
|
2689
|
-
C: () => (copy),
|
|
2690
|
-
Om: () => (dot),
|
|
2691
|
-
Xd: () => (getAxisAngle),
|
|
2692
|
-
Xr: () => (conjugate),
|
|
2693
|
-
Yc: () => (rotationTo),
|
|
2694
|
-
fA: () => (fromValues),
|
|
2695
|
-
hs: () => (scale),
|
|
2696
|
-
lw: () => (multiply),
|
|
2697
|
-
m3: () => (squaredLength),
|
|
2698
|
-
nu: () => (slerp),
|
|
2699
|
-
vt: () => (create),
|
|
2700
|
-
x8: () => (setAxisAngle)
|
|
2701
|
-
});
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
},
|
|
2705
|
-
70911(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
2706
|
-
/* import */ var _common_js__rspack_import_0 = __webpack_require__(23172);
|
|
2707
|
-
|
|
2708
|
-
/**
|
|
2709
|
-
* 4 Dimensional Vector
|
|
2710
|
-
* @module vec4
|
|
2711
|
-
*/
|
|
2712
|
-
|
|
2713
|
-
/**
|
|
2714
|
-
* Creates a new, empty vec4
|
|
2715
|
-
*
|
|
2716
|
-
* @returns {vec4} a new 4D vector
|
|
2717
|
-
*/
|
|
2718
|
-
|
|
2719
|
-
function create() {
|
|
2720
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(4);
|
|
2721
|
-
|
|
2722
|
-
if (_common_js__rspack_import_0/* .ARRAY_TYPE */.tb != Float32Array) {
|
|
2723
|
-
out[0] = 0;
|
|
2724
|
-
out[1] = 0;
|
|
2725
|
-
out[2] = 0;
|
|
2726
|
-
out[3] = 0;
|
|
2727
|
-
}
|
|
2728
|
-
|
|
2729
|
-
return out;
|
|
2730
|
-
}
|
|
2731
|
-
/**
|
|
2732
|
-
* Creates a new vec4 initialized with values from an existing vector
|
|
2733
|
-
*
|
|
2734
|
-
* @param {ReadonlyVec4} a vector to clone
|
|
2735
|
-
* @returns {vec4} a new 4D vector
|
|
2736
|
-
*/
|
|
2737
|
-
|
|
2738
|
-
function clone(a) {
|
|
2739
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(4);
|
|
2740
|
-
out[0] = a[0];
|
|
2741
|
-
out[1] = a[1];
|
|
2742
|
-
out[2] = a[2];
|
|
2743
|
-
out[3] = a[3];
|
|
2744
|
-
return out;
|
|
2745
|
-
}
|
|
2746
|
-
/**
|
|
2747
|
-
* Creates a new vec4 initialized with the given values
|
|
2748
|
-
*
|
|
2749
|
-
* @param {Number} x X component
|
|
2750
|
-
* @param {Number} y Y component
|
|
2751
|
-
* @param {Number} z Z component
|
|
2752
|
-
* @param {Number} w W component
|
|
2753
|
-
* @returns {vec4} a new 4D vector
|
|
2754
|
-
*/
|
|
2755
|
-
|
|
2756
|
-
function fromValues(x, y, z, w) {
|
|
2757
|
-
var out = new _common_js__rspack_import_0/* .ARRAY_TYPE */.tb(4);
|
|
2758
|
-
out[0] = x;
|
|
2759
|
-
out[1] = y;
|
|
2760
|
-
out[2] = z;
|
|
2761
|
-
out[3] = w;
|
|
2762
|
-
return out;
|
|
2763
|
-
}
|
|
2764
|
-
/**
|
|
2765
|
-
* Copy the values from one vec4 to another
|
|
2766
|
-
*
|
|
2767
|
-
* @param {vec4} out the receiving vector
|
|
2768
|
-
* @param {ReadonlyVec4} a the source vector
|
|
2769
|
-
* @returns {vec4} out
|
|
2770
|
-
*/
|
|
2771
|
-
|
|
2772
|
-
function copy(out, a) {
|
|
2773
|
-
out[0] = a[0];
|
|
2774
|
-
out[1] = a[1];
|
|
2775
|
-
out[2] = a[2];
|
|
2776
|
-
out[3] = a[3];
|
|
2777
|
-
return out;
|
|
2778
|
-
}
|
|
2779
|
-
/**
|
|
2780
|
-
* Set the components of a vec4 to the given values
|
|
2781
|
-
*
|
|
2782
|
-
* @param {vec4} out the receiving vector
|
|
2783
|
-
* @param {Number} x X component
|
|
2784
|
-
* @param {Number} y Y component
|
|
2785
|
-
* @param {Number} z Z component
|
|
2786
|
-
* @param {Number} w W component
|
|
2787
|
-
* @returns {vec4} out
|
|
2788
|
-
*/
|
|
2789
|
-
|
|
2790
|
-
function set(out, x, y, z, w) {
|
|
2791
|
-
out[0] = x;
|
|
2792
|
-
out[1] = y;
|
|
2793
|
-
out[2] = z;
|
|
2794
|
-
out[3] = w;
|
|
2795
|
-
return out;
|
|
2796
|
-
}
|
|
2797
|
-
/**
|
|
2798
|
-
* Adds two vec4's
|
|
2799
|
-
*
|
|
2800
|
-
* @param {vec4} out the receiving vector
|
|
2801
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2802
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2803
|
-
* @returns {vec4} out
|
|
2804
|
-
*/
|
|
2805
|
-
|
|
2806
|
-
function add(out, a, b) {
|
|
2807
|
-
out[0] = a[0] + b[0];
|
|
2808
|
-
out[1] = a[1] + b[1];
|
|
2809
|
-
out[2] = a[2] + b[2];
|
|
2810
|
-
out[3] = a[3] + b[3];
|
|
2811
|
-
return out;
|
|
2812
|
-
}
|
|
2813
|
-
/**
|
|
2814
|
-
* Subtracts vector b from vector a
|
|
2815
|
-
*
|
|
2816
|
-
* @param {vec4} out the receiving vector
|
|
2817
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2818
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2819
|
-
* @returns {vec4} out
|
|
2820
|
-
*/
|
|
2821
|
-
|
|
2822
|
-
function subtract(out, a, b) {
|
|
2823
|
-
out[0] = a[0] - b[0];
|
|
2824
|
-
out[1] = a[1] - b[1];
|
|
2825
|
-
out[2] = a[2] - b[2];
|
|
2826
|
-
out[3] = a[3] - b[3];
|
|
2827
|
-
return out;
|
|
2828
|
-
}
|
|
2829
|
-
/**
|
|
2830
|
-
* Multiplies two vec4's
|
|
2831
|
-
*
|
|
2832
|
-
* @param {vec4} out the receiving vector
|
|
2833
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2834
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2835
|
-
* @returns {vec4} out
|
|
2836
|
-
*/
|
|
2837
|
-
|
|
2838
|
-
function multiply(out, a, b) {
|
|
2839
|
-
out[0] = a[0] * b[0];
|
|
2840
|
-
out[1] = a[1] * b[1];
|
|
2841
|
-
out[2] = a[2] * b[2];
|
|
2842
|
-
out[3] = a[3] * b[3];
|
|
2843
|
-
return out;
|
|
2844
|
-
}
|
|
2845
|
-
/**
|
|
2846
|
-
* Divides two vec4's
|
|
2847
|
-
*
|
|
2848
|
-
* @param {vec4} out the receiving vector
|
|
2849
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2850
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2851
|
-
* @returns {vec4} out
|
|
2852
|
-
*/
|
|
2853
|
-
|
|
2854
|
-
function divide(out, a, b) {
|
|
2855
|
-
out[0] = a[0] / b[0];
|
|
2856
|
-
out[1] = a[1] / b[1];
|
|
2857
|
-
out[2] = a[2] / b[2];
|
|
2858
|
-
out[3] = a[3] / b[3];
|
|
2859
|
-
return out;
|
|
2860
|
-
}
|
|
2861
|
-
/**
|
|
2862
|
-
* Math.ceil the components of a vec4
|
|
2863
|
-
*
|
|
2864
|
-
* @param {vec4} out the receiving vector
|
|
2865
|
-
* @param {ReadonlyVec4} a vector to ceil
|
|
2866
|
-
* @returns {vec4} out
|
|
2867
|
-
*/
|
|
2868
|
-
|
|
2869
|
-
function ceil(out, a) {
|
|
2870
|
-
out[0] = Math.ceil(a[0]);
|
|
2871
|
-
out[1] = Math.ceil(a[1]);
|
|
2872
|
-
out[2] = Math.ceil(a[2]);
|
|
2873
|
-
out[3] = Math.ceil(a[3]);
|
|
2874
|
-
return out;
|
|
2875
|
-
}
|
|
2876
|
-
/**
|
|
2877
|
-
* Math.floor the components of a vec4
|
|
2878
|
-
*
|
|
2879
|
-
* @param {vec4} out the receiving vector
|
|
2880
|
-
* @param {ReadonlyVec4} a vector to floor
|
|
2881
|
-
* @returns {vec4} out
|
|
2882
|
-
*/
|
|
2883
|
-
|
|
2884
|
-
function floor(out, a) {
|
|
2885
|
-
out[0] = Math.floor(a[0]);
|
|
2886
|
-
out[1] = Math.floor(a[1]);
|
|
2887
|
-
out[2] = Math.floor(a[2]);
|
|
2888
|
-
out[3] = Math.floor(a[3]);
|
|
2889
|
-
return out;
|
|
2890
|
-
}
|
|
2891
|
-
/**
|
|
2892
|
-
* Returns the minimum of two vec4's
|
|
2893
|
-
*
|
|
2894
|
-
* @param {vec4} out the receiving vector
|
|
2895
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2896
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2897
|
-
* @returns {vec4} out
|
|
2898
|
-
*/
|
|
2899
|
-
|
|
2900
|
-
function min(out, a, b) {
|
|
2901
|
-
out[0] = Math.min(a[0], b[0]);
|
|
2902
|
-
out[1] = Math.min(a[1], b[1]);
|
|
2903
|
-
out[2] = Math.min(a[2], b[2]);
|
|
2904
|
-
out[3] = Math.min(a[3], b[3]);
|
|
2905
|
-
return out;
|
|
2906
|
-
}
|
|
2907
|
-
/**
|
|
2908
|
-
* Returns the maximum of two vec4's
|
|
2909
|
-
*
|
|
2910
|
-
* @param {vec4} out the receiving vector
|
|
2911
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2912
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2913
|
-
* @returns {vec4} out
|
|
2914
|
-
*/
|
|
2915
|
-
|
|
2916
|
-
function max(out, a, b) {
|
|
2917
|
-
out[0] = Math.max(a[0], b[0]);
|
|
2918
|
-
out[1] = Math.max(a[1], b[1]);
|
|
2919
|
-
out[2] = Math.max(a[2], b[2]);
|
|
2920
|
-
out[3] = Math.max(a[3], b[3]);
|
|
2921
|
-
return out;
|
|
2922
|
-
}
|
|
2923
|
-
/**
|
|
2924
|
-
* Math.round the components of a vec4
|
|
2925
|
-
*
|
|
2926
|
-
* @param {vec4} out the receiving vector
|
|
2927
|
-
* @param {ReadonlyVec4} a vector to round
|
|
2928
|
-
* @returns {vec4} out
|
|
2929
|
-
*/
|
|
2930
|
-
|
|
2931
|
-
function round(out, a) {
|
|
2932
|
-
out[0] = Math.round(a[0]);
|
|
2933
|
-
out[1] = Math.round(a[1]);
|
|
2934
|
-
out[2] = Math.round(a[2]);
|
|
2935
|
-
out[3] = Math.round(a[3]);
|
|
2936
|
-
return out;
|
|
2937
|
-
}
|
|
2938
|
-
/**
|
|
2939
|
-
* Scales a vec4 by a scalar number
|
|
2940
|
-
*
|
|
2941
|
-
* @param {vec4} out the receiving vector
|
|
2942
|
-
* @param {ReadonlyVec4} a the vector to scale
|
|
2943
|
-
* @param {Number} b amount to scale the vector by
|
|
2944
|
-
* @returns {vec4} out
|
|
2945
|
-
*/
|
|
2946
|
-
|
|
2947
|
-
function scale(out, a, b) {
|
|
2948
|
-
out[0] = a[0] * b;
|
|
2949
|
-
out[1] = a[1] * b;
|
|
2950
|
-
out[2] = a[2] * b;
|
|
2951
|
-
out[3] = a[3] * b;
|
|
2952
|
-
return out;
|
|
2953
|
-
}
|
|
2954
|
-
/**
|
|
2955
|
-
* Adds two vec4's after scaling the second operand by a scalar value
|
|
2956
|
-
*
|
|
2957
|
-
* @param {vec4} out the receiving vector
|
|
2958
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2959
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2960
|
-
* @param {Number} scale the amount to scale b by before adding
|
|
2961
|
-
* @returns {vec4} out
|
|
2962
|
-
*/
|
|
2963
|
-
|
|
2964
|
-
function scaleAndAdd(out, a, b, scale) {
|
|
2965
|
-
out[0] = a[0] + b[0] * scale;
|
|
2966
|
-
out[1] = a[1] + b[1] * scale;
|
|
2967
|
-
out[2] = a[2] + b[2] * scale;
|
|
2968
|
-
out[3] = a[3] + b[3] * scale;
|
|
2969
|
-
return out;
|
|
2970
|
-
}
|
|
2971
|
-
/**
|
|
2972
|
-
* Calculates the euclidian distance between two vec4's
|
|
2973
|
-
*
|
|
2974
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2975
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2976
|
-
* @returns {Number} distance between a and b
|
|
2977
|
-
*/
|
|
2978
|
-
|
|
2979
|
-
function distance(a, b) {
|
|
2980
|
-
var x = b[0] - a[0];
|
|
2981
|
-
var y = b[1] - a[1];
|
|
2982
|
-
var z = b[2] - a[2];
|
|
2983
|
-
var w = b[3] - a[3];
|
|
2984
|
-
return Math.hypot(x, y, z, w);
|
|
2985
|
-
}
|
|
2986
|
-
/**
|
|
2987
|
-
* Calculates the squared euclidian distance between two vec4's
|
|
2988
|
-
*
|
|
2989
|
-
* @param {ReadonlyVec4} a the first operand
|
|
2990
|
-
* @param {ReadonlyVec4} b the second operand
|
|
2991
|
-
* @returns {Number} squared distance between a and b
|
|
2992
|
-
*/
|
|
2993
|
-
|
|
2994
|
-
function squaredDistance(a, b) {
|
|
2995
|
-
var x = b[0] - a[0];
|
|
2996
|
-
var y = b[1] - a[1];
|
|
2997
|
-
var z = b[2] - a[2];
|
|
2998
|
-
var w = b[3] - a[3];
|
|
2999
|
-
return x * x + y * y + z * z + w * w;
|
|
3000
|
-
}
|
|
3001
|
-
/**
|
|
3002
|
-
* Calculates the length of a vec4
|
|
3003
|
-
*
|
|
3004
|
-
* @param {ReadonlyVec4} a vector to calculate length of
|
|
3005
|
-
* @returns {Number} length of a
|
|
3006
|
-
*/
|
|
3007
|
-
|
|
3008
|
-
function length(a) {
|
|
3009
|
-
var x = a[0];
|
|
3010
|
-
var y = a[1];
|
|
3011
|
-
var z = a[2];
|
|
3012
|
-
var w = a[3];
|
|
3013
|
-
return Math.hypot(x, y, z, w);
|
|
3014
|
-
}
|
|
3015
|
-
/**
|
|
3016
|
-
* Calculates the squared length of a vec4
|
|
3017
|
-
*
|
|
3018
|
-
* @param {ReadonlyVec4} a vector to calculate squared length of
|
|
3019
|
-
* @returns {Number} squared length of a
|
|
3020
|
-
*/
|
|
3021
|
-
|
|
3022
|
-
function squaredLength(a) {
|
|
3023
|
-
var x = a[0];
|
|
3024
|
-
var y = a[1];
|
|
3025
|
-
var z = a[2];
|
|
3026
|
-
var w = a[3];
|
|
3027
|
-
return x * x + y * y + z * z + w * w;
|
|
3028
|
-
}
|
|
3029
|
-
/**
|
|
3030
|
-
* Negates the components of a vec4
|
|
3031
|
-
*
|
|
3032
|
-
* @param {vec4} out the receiving vector
|
|
3033
|
-
* @param {ReadonlyVec4} a vector to negate
|
|
3034
|
-
* @returns {vec4} out
|
|
3035
|
-
*/
|
|
3036
|
-
|
|
3037
|
-
function negate(out, a) {
|
|
3038
|
-
out[0] = -a[0];
|
|
3039
|
-
out[1] = -a[1];
|
|
3040
|
-
out[2] = -a[2];
|
|
3041
|
-
out[3] = -a[3];
|
|
3042
|
-
return out;
|
|
3043
|
-
}
|
|
3044
|
-
/**
|
|
3045
|
-
* Returns the inverse of the components of a vec4
|
|
3046
|
-
*
|
|
3047
|
-
* @param {vec4} out the receiving vector
|
|
3048
|
-
* @param {ReadonlyVec4} a vector to invert
|
|
3049
|
-
* @returns {vec4} out
|
|
3050
|
-
*/
|
|
3051
|
-
|
|
3052
|
-
function inverse(out, a) {
|
|
3053
|
-
out[0] = 1.0 / a[0];
|
|
3054
|
-
out[1] = 1.0 / a[1];
|
|
3055
|
-
out[2] = 1.0 / a[2];
|
|
3056
|
-
out[3] = 1.0 / a[3];
|
|
3057
|
-
return out;
|
|
3058
|
-
}
|
|
3059
|
-
/**
|
|
3060
|
-
* Normalize a vec4
|
|
3061
|
-
*
|
|
3062
|
-
* @param {vec4} out the receiving vector
|
|
3063
|
-
* @param {ReadonlyVec4} a vector to normalize
|
|
3064
|
-
* @returns {vec4} out
|
|
3065
|
-
*/
|
|
3066
|
-
|
|
3067
|
-
function normalize(out, a) {
|
|
3068
|
-
var x = a[0];
|
|
3069
|
-
var y = a[1];
|
|
3070
|
-
var z = a[2];
|
|
3071
|
-
var w = a[3];
|
|
3072
|
-
var len = x * x + y * y + z * z + w * w;
|
|
3073
|
-
|
|
3074
|
-
if (len > 0) {
|
|
3075
|
-
len = 1 / Math.sqrt(len);
|
|
3076
|
-
}
|
|
3077
|
-
|
|
3078
|
-
out[0] = x * len;
|
|
3079
|
-
out[1] = y * len;
|
|
3080
|
-
out[2] = z * len;
|
|
3081
|
-
out[3] = w * len;
|
|
3082
|
-
return out;
|
|
3083
|
-
}
|
|
3084
|
-
/**
|
|
3085
|
-
* Calculates the dot product of two vec4's
|
|
3086
|
-
*
|
|
3087
|
-
* @param {ReadonlyVec4} a the first operand
|
|
3088
|
-
* @param {ReadonlyVec4} b the second operand
|
|
3089
|
-
* @returns {Number} dot product of a and b
|
|
3090
|
-
*/
|
|
3091
|
-
|
|
3092
|
-
function dot(a, b) {
|
|
3093
|
-
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
|
|
3094
|
-
}
|
|
3095
|
-
/**
|
|
3096
|
-
* Returns the cross-product of three vectors in a 4-dimensional space
|
|
3097
|
-
*
|
|
3098
|
-
* @param {ReadonlyVec4} result the receiving vector
|
|
3099
|
-
* @param {ReadonlyVec4} U the first vector
|
|
3100
|
-
* @param {ReadonlyVec4} V the second vector
|
|
3101
|
-
* @param {ReadonlyVec4} W the third vector
|
|
3102
|
-
* @returns {vec4} result
|
|
3103
|
-
*/
|
|
3104
|
-
|
|
3105
|
-
function cross(out, u, v, w) {
|
|
3106
|
-
var A = v[0] * w[1] - v[1] * w[0],
|
|
3107
|
-
B = v[0] * w[2] - v[2] * w[0],
|
|
3108
|
-
C = v[0] * w[3] - v[3] * w[0],
|
|
3109
|
-
D = v[1] * w[2] - v[2] * w[1],
|
|
3110
|
-
E = v[1] * w[3] - v[3] * w[1],
|
|
3111
|
-
F = v[2] * w[3] - v[3] * w[2];
|
|
3112
|
-
var G = u[0];
|
|
3113
|
-
var H = u[1];
|
|
3114
|
-
var I = u[2];
|
|
3115
|
-
var J = u[3];
|
|
3116
|
-
out[0] = H * F - I * E + J * D;
|
|
3117
|
-
out[1] = -(G * F) + I * C - J * B;
|
|
3118
|
-
out[2] = G * E - H * C + J * A;
|
|
3119
|
-
out[3] = -(G * D) + H * B - I * A;
|
|
3120
|
-
return out;
|
|
3121
|
-
}
|
|
3122
|
-
/**
|
|
3123
|
-
* Performs a linear interpolation between two vec4's
|
|
3124
|
-
*
|
|
3125
|
-
* @param {vec4} out the receiving vector
|
|
3126
|
-
* @param {ReadonlyVec4} a the first operand
|
|
3127
|
-
* @param {ReadonlyVec4} b the second operand
|
|
3128
|
-
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
3129
|
-
* @returns {vec4} out
|
|
3130
|
-
*/
|
|
3131
|
-
|
|
3132
|
-
function lerp(out, a, b, t) {
|
|
3133
|
-
var ax = a[0];
|
|
3134
|
-
var ay = a[1];
|
|
3135
|
-
var az = a[2];
|
|
3136
|
-
var aw = a[3];
|
|
3137
|
-
out[0] = ax + t * (b[0] - ax);
|
|
3138
|
-
out[1] = ay + t * (b[1] - ay);
|
|
3139
|
-
out[2] = az + t * (b[2] - az);
|
|
3140
|
-
out[3] = aw + t * (b[3] - aw);
|
|
3141
|
-
return out;
|
|
3142
|
-
}
|
|
3143
|
-
/**
|
|
3144
|
-
* Generates a random vector with the given scale
|
|
3145
|
-
*
|
|
3146
|
-
* @param {vec4} out the receiving vector
|
|
3147
|
-
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
|
|
3148
|
-
* @returns {vec4} out
|
|
3149
|
-
*/
|
|
3150
|
-
|
|
3151
|
-
function random(out, scale) {
|
|
3152
|
-
scale = scale || 1.0; // Marsaglia, George. Choosing a Point from the Surface of a
|
|
3153
|
-
// Sphere. Ann. Math. Statist. 43 (1972), no. 2, 645--646.
|
|
3154
|
-
// http://projecteuclid.org/euclid.aoms/1177692644;
|
|
3155
|
-
|
|
3156
|
-
var v1, v2, v3, v4;
|
|
3157
|
-
var s1, s2;
|
|
3158
|
-
|
|
3159
|
-
do {
|
|
3160
|
-
v1 = glMatrix.RANDOM() * 2 - 1;
|
|
3161
|
-
v2 = glMatrix.RANDOM() * 2 - 1;
|
|
3162
|
-
s1 = v1 * v1 + v2 * v2;
|
|
3163
|
-
} while (s1 >= 1);
|
|
3164
|
-
|
|
3165
|
-
do {
|
|
3166
|
-
v3 = glMatrix.RANDOM() * 2 - 1;
|
|
3167
|
-
v4 = glMatrix.RANDOM() * 2 - 1;
|
|
3168
|
-
s2 = v3 * v3 + v4 * v4;
|
|
3169
|
-
} while (s2 >= 1);
|
|
3170
|
-
|
|
3171
|
-
var d = Math.sqrt((1 - s1) / s2);
|
|
3172
|
-
out[0] = scale * v1;
|
|
3173
|
-
out[1] = scale * v2;
|
|
3174
|
-
out[2] = scale * v3 * d;
|
|
3175
|
-
out[3] = scale * v4 * d;
|
|
3176
|
-
return out;
|
|
3177
|
-
}
|
|
3178
|
-
/**
|
|
3179
|
-
* Transforms the vec4 with a mat4.
|
|
3180
|
-
*
|
|
3181
|
-
* @param {vec4} out the receiving vector
|
|
3182
|
-
* @param {ReadonlyVec4} a the vector to transform
|
|
3183
|
-
* @param {ReadonlyMat4} m matrix to transform with
|
|
3184
|
-
* @returns {vec4} out
|
|
3185
|
-
*/
|
|
3186
|
-
|
|
3187
|
-
function transformMat4(out, a, m) {
|
|
3188
|
-
var x = a[0],
|
|
3189
|
-
y = a[1],
|
|
3190
|
-
z = a[2],
|
|
3191
|
-
w = a[3];
|
|
3192
|
-
out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
|
|
3193
|
-
out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
|
|
3194
|
-
out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
|
|
3195
|
-
out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
|
|
3196
|
-
return out;
|
|
3197
|
-
}
|
|
3198
|
-
/**
|
|
3199
|
-
* Transforms the vec4 with a quat
|
|
3200
|
-
*
|
|
3201
|
-
* @param {vec4} out the receiving vector
|
|
3202
|
-
* @param {ReadonlyVec4} a the vector to transform
|
|
3203
|
-
* @param {ReadonlyQuat} q quaternion to transform with
|
|
3204
|
-
* @returns {vec4} out
|
|
3205
|
-
*/
|
|
3206
|
-
|
|
3207
|
-
function transformQuat(out, a, q) {
|
|
3208
|
-
var x = a[0],
|
|
3209
|
-
y = a[1],
|
|
3210
|
-
z = a[2];
|
|
3211
|
-
var qx = q[0],
|
|
3212
|
-
qy = q[1],
|
|
3213
|
-
qz = q[2],
|
|
3214
|
-
qw = q[3]; // calculate quat * vec
|
|
3215
|
-
|
|
3216
|
-
var ix = qw * x + qy * z - qz * y;
|
|
3217
|
-
var iy = qw * y + qz * x - qx * z;
|
|
3218
|
-
var iz = qw * z + qx * y - qy * x;
|
|
3219
|
-
var iw = -qx * x - qy * y - qz * z; // calculate result * inverse quat
|
|
3220
|
-
|
|
3221
|
-
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
|
|
3222
|
-
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
|
|
3223
|
-
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
|
|
3224
|
-
out[3] = a[3];
|
|
3225
|
-
return out;
|
|
3226
|
-
}
|
|
3227
|
-
/**
|
|
3228
|
-
* Set the components of a vec4 to zero
|
|
3229
|
-
*
|
|
3230
|
-
* @param {vec4} out the receiving vector
|
|
3231
|
-
* @returns {vec4} out
|
|
3232
|
-
*/
|
|
3233
|
-
|
|
3234
|
-
function zero(out) {
|
|
3235
|
-
out[0] = 0.0;
|
|
3236
|
-
out[1] = 0.0;
|
|
3237
|
-
out[2] = 0.0;
|
|
3238
|
-
out[3] = 0.0;
|
|
3239
|
-
return out;
|
|
3240
|
-
}
|
|
3241
|
-
/**
|
|
3242
|
-
* Returns a string representation of a vector
|
|
3243
|
-
*
|
|
3244
|
-
* @param {ReadonlyVec4} a vector to represent as a string
|
|
3245
|
-
* @returns {String} string representation of the vector
|
|
3246
|
-
*/
|
|
3247
|
-
|
|
3248
|
-
function str(a) {
|
|
3249
|
-
return "vec4(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ")";
|
|
3250
|
-
}
|
|
3251
|
-
/**
|
|
3252
|
-
* Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
|
|
3253
|
-
*
|
|
3254
|
-
* @param {ReadonlyVec4} a The first vector.
|
|
3255
|
-
* @param {ReadonlyVec4} b The second vector.
|
|
3256
|
-
* @returns {Boolean} True if the vectors are equal, false otherwise.
|
|
3257
|
-
*/
|
|
3258
|
-
|
|
3259
|
-
function exactEquals(a, b) {
|
|
3260
|
-
return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
|
|
3261
|
-
}
|
|
3262
|
-
/**
|
|
3263
|
-
* Returns whether or not the vectors have approximately the same elements in the same position.
|
|
3264
|
-
*
|
|
3265
|
-
* @param {ReadonlyVec4} a The first vector.
|
|
3266
|
-
* @param {ReadonlyVec4} b The second vector.
|
|
3267
|
-
* @returns {Boolean} True if the vectors are equal, false otherwise.
|
|
3268
|
-
*/
|
|
3269
|
-
|
|
3270
|
-
function equals(a, b) {
|
|
3271
|
-
var a0 = a[0],
|
|
3272
|
-
a1 = a[1],
|
|
3273
|
-
a2 = a[2],
|
|
3274
|
-
a3 = a[3];
|
|
3275
|
-
var b0 = b[0],
|
|
3276
|
-
b1 = b[1],
|
|
3277
|
-
b2 = b[2],
|
|
3278
|
-
b3 = b[3];
|
|
3279
|
-
return Math.abs(a0 - b0) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= _common_js__rspack_import_0/* .EPSILON */.p8 * Math.max(1.0, Math.abs(a3), Math.abs(b3));
|
|
3280
|
-
}
|
|
3281
|
-
/**
|
|
3282
|
-
* Alias for {@link vec4.subtract}
|
|
3283
|
-
* @function
|
|
3284
|
-
*/
|
|
3285
|
-
|
|
3286
|
-
var sub = (/* unused pure expression or super */ null && (subtract));
|
|
3287
|
-
/**
|
|
3288
|
-
* Alias for {@link vec4.multiply}
|
|
3289
|
-
* @function
|
|
3290
|
-
*/
|
|
3291
|
-
|
|
3292
|
-
var mul = (/* unused pure expression or super */ null && (multiply));
|
|
3293
|
-
/**
|
|
3294
|
-
* Alias for {@link vec4.divide}
|
|
3295
|
-
* @function
|
|
3296
|
-
*/
|
|
3297
|
-
|
|
3298
|
-
var div = (/* unused pure expression or super */ null && (divide));
|
|
3299
|
-
/**
|
|
3300
|
-
* Alias for {@link vec4.distance}
|
|
3301
|
-
* @function
|
|
3302
|
-
*/
|
|
3303
|
-
|
|
3304
|
-
var dist = (/* unused pure expression or super */ null && (distance));
|
|
3305
|
-
/**
|
|
3306
|
-
* Alias for {@link vec4.squaredDistance}
|
|
3307
|
-
* @function
|
|
3308
|
-
*/
|
|
3309
|
-
|
|
3310
|
-
var sqrDist = (/* unused pure expression or super */ null && (squaredDistance));
|
|
3311
|
-
/**
|
|
3312
|
-
* Alias for {@link vec4.length}
|
|
3313
|
-
* @function
|
|
3314
|
-
*/
|
|
3315
|
-
|
|
3316
|
-
var len = (/* unused pure expression or super */ null && (length));
|
|
3317
|
-
/**
|
|
3318
|
-
* Alias for {@link vec4.squaredLength}
|
|
3319
|
-
* @function
|
|
3320
|
-
*/
|
|
3321
|
-
|
|
3322
|
-
var sqrLen = (/* unused pure expression or super */ null && (squaredLength));
|
|
3323
|
-
/**
|
|
3324
|
-
* Perform some operation over an array of vec4s.
|
|
3325
|
-
*
|
|
3326
|
-
* @param {Array} a the array of vectors to iterate over
|
|
3327
|
-
* @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
|
|
3328
|
-
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
3329
|
-
* @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
|
|
3330
|
-
* @param {Function} fn Function to call for each vector in the array
|
|
3331
|
-
* @param {Object} [arg] additional argument to pass to fn
|
|
3332
|
-
* @returns {Array} a
|
|
3333
|
-
* @function
|
|
3334
|
-
*/
|
|
3335
|
-
|
|
3336
|
-
var forEach = function () {
|
|
3337
|
-
var vec = create();
|
|
3338
|
-
return function (a, stride, offset, count, fn, arg) {
|
|
3339
|
-
var i, l;
|
|
3340
|
-
|
|
3341
|
-
if (!stride) {
|
|
3342
|
-
stride = 4;
|
|
3343
|
-
}
|
|
3344
|
-
|
|
3345
|
-
if (!offset) {
|
|
3346
|
-
offset = 0;
|
|
3347
|
-
}
|
|
3348
|
-
|
|
3349
|
-
if (count) {
|
|
3350
|
-
l = Math.min(count * stride + offset, a.length);
|
|
3351
|
-
} else {
|
|
3352
|
-
l = a.length;
|
|
3353
|
-
}
|
|
3354
|
-
|
|
3355
|
-
for (i = offset; i < l; i += stride) {
|
|
3356
|
-
vec[0] = a[i];
|
|
3357
|
-
vec[1] = a[i + 1];
|
|
3358
|
-
vec[2] = a[i + 2];
|
|
3359
|
-
vec[3] = a[i + 3];
|
|
3360
|
-
fn(vec, vec, arg);
|
|
3361
|
-
a[i] = vec[0];
|
|
3362
|
-
a[i + 1] = vec[1];
|
|
3363
|
-
a[i + 2] = vec[2];
|
|
3364
|
-
a[i + 3] = vec[3];
|
|
3365
|
-
}
|
|
3366
|
-
|
|
3367
|
-
return a;
|
|
3368
|
-
};
|
|
3369
|
-
}();
|
|
3370
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3371
|
-
Bw: () => (length),
|
|
3372
|
-
C: () => (copy),
|
|
3373
|
-
Cc: () => (lerp),
|
|
3374
|
-
Om: () => (dot),
|
|
3375
|
-
Re: () => (subtract),
|
|
3376
|
-
S8: () => (normalize),
|
|
3377
|
-
WQ: () => (add),
|
|
3378
|
-
Z0: () => (transformMat4),
|
|
3379
|
-
aI: () => (equals),
|
|
3380
|
-
fA: () => (fromValues),
|
|
3381
|
-
hZ: () => (set),
|
|
3382
|
-
hs: () => (scale),
|
|
3383
|
-
m3: () => (squaredLength),
|
|
3384
|
-
o8: () => (clone),
|
|
3385
|
-
t2: () => (exactEquals),
|
|
3386
|
-
vt: () => (create)
|
|
3387
|
-
});
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
},
|
|
3391
|
-
9891(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3392
|
-
/* import */ var _vtkClasses_index_js__rspack_import_0 = __webpack_require__(44418);
|
|
3393
|
-
/* import */ var _init_js__rspack_import_1 = __webpack_require__(90934);
|
|
3394
|
-
/* import */ var _kitware_vtk_js_Rendering_Core_VolumeMapper_js__rspack_import_2 = __webpack_require__(21067);
|
|
3395
|
-
/* import */ var _kitware_vtk_js_Common_Core_DataArray_js__rspack_import_3 = __webpack_require__(84472);
|
|
3396
|
-
/* import */ var _kitware_vtk_js_Common_DataModel_BoundingBox_js__rspack_import_4 = __webpack_require__(28710);
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
const MAXIMUM_SAMPLES_PER_RAY = 4000;
|
|
3403
|
-
function sampleDistanceOf(imageData, texture, multiplier = (0,_init_js__rspack_import_1/* .getConfiguration */.D0)().rendering?.volumeRendering
|
|
3404
|
-
?.sampleDistanceMultiplier || 1) {
|
|
3405
|
-
const grid = texture?.getGrid?.();
|
|
3406
|
-
const spacing = grid?.spacing ?? imageData.getSpacing();
|
|
3407
|
-
const distance = (multiplier * (spacing[0] + spacing[1] + spacing[2])) / 6;
|
|
3408
|
-
if (!(0,_init_js__rspack_import_1/* .getLossyDownsampling */.GR)().final) {
|
|
3409
|
-
return distance;
|
|
3410
|
-
}
|
|
3411
|
-
const diagonal = _kitware_vtk_js_Common_DataModel_BoundingBox_js__rspack_import_4/* ["default"].getDiagonalLength */.Ay.getDiagonalLength(imageData.getBounds());
|
|
3412
|
-
return Math.max(distance, diagonal / (MAXIMUM_SAMPLES_PER_RAY - 1));
|
|
3413
|
-
}
|
|
3414
|
-
const idleSampleDistanceMultipliers = new WeakMap();
|
|
3415
|
-
function setIdleSampleDistanceMultiplier(mapper, multiplier) {
|
|
3416
|
-
idleSampleDistanceMultipliers.set(mapper, Number.isFinite(multiplier) ? Math.max(multiplier, 0.001) : 1);
|
|
3417
|
-
}
|
|
3418
|
-
function idleSampleDistanceMultiplierOf(mapper) {
|
|
3419
|
-
return (idleSampleDistanceMultipliers.get(mapper) ??
|
|
3420
|
-
((0,_init_js__rspack_import_1/* .getConfiguration */.D0)().rendering?.volumeRendering?.sampleDistanceMultiplier ||
|
|
3421
|
-
1));
|
|
3422
|
-
}
|
|
3423
|
-
function sampleDistanceRatiosOf(mapper, texture = mapper?.getScalarTexture?.()) {
|
|
3424
|
-
const current = mapper?.getSampleDistance?.();
|
|
3425
|
-
const imageData = mapper?.getInputData?.();
|
|
3426
|
-
if (!imageData || !(current > 0)) {
|
|
3427
|
-
return { current: 1, idle: 1 };
|
|
3428
|
-
}
|
|
3429
|
-
const baseline = sampleDistanceOf(imageData, texture, 1);
|
|
3430
|
-
if (!(baseline > 0)) {
|
|
3431
|
-
return { current: 1, idle: 1 };
|
|
3432
|
-
}
|
|
3433
|
-
const idle = sampleDistanceOf(imageData, texture, idleSampleDistanceMultiplierOf(mapper));
|
|
3434
|
-
return { current: current / baseline, idle: idle / baseline };
|
|
3435
|
-
}
|
|
3436
|
-
function createVolumeMapper(imageData, vtkOpenGLTexture) {
|
|
3437
|
-
const volumeMapper = _vtkClasses_index_js__rspack_import_0/* .vtkSharedVolumeMapper.newInstance */.wu.newInstance();
|
|
3438
|
-
volumeMapper.setInputData(imageData);
|
|
3439
|
-
volumeMapper.setMaximumSamplesPerRay(MAXIMUM_SAMPLES_PER_RAY);
|
|
3440
|
-
volumeMapper.setSampleDistance(sampleDistanceOf(imageData, vtkOpenGLTexture));
|
|
3441
|
-
if (vtkOpenGLTexture) {
|
|
3442
|
-
volumeMapper.setScalarTexture(vtkOpenGLTexture);
|
|
3443
|
-
}
|
|
3444
|
-
return volumeMapper;
|
|
3445
|
-
}
|
|
3446
|
-
function convertMapperToNotSharedMapper(sharedMapper) {
|
|
3447
|
-
const volumeMapper = _kitware_vtk_js_Rendering_Core_VolumeMapper_js__rspack_import_2/* ["default"].newInstance */.Ay.newInstance();
|
|
3448
|
-
volumeMapper.setBlendMode(sharedMapper.getBlendMode());
|
|
3449
|
-
const imageData = sharedMapper.getInputData();
|
|
3450
|
-
const { voxelManager } = imageData.get('voxelManager');
|
|
3451
|
-
const values = voxelManager.getCompleteScalarDataArray();
|
|
3452
|
-
const scalarArray = _kitware_vtk_js_Common_Core_DataArray_js__rspack_import_3/* ["default"].newInstance */.Ay.newInstance({
|
|
3453
|
-
name: `Pixels`,
|
|
3454
|
-
values,
|
|
3455
|
-
});
|
|
3456
|
-
imageData.getPointData().setScalars(scalarArray);
|
|
3457
|
-
volumeMapper.setInputData(imageData);
|
|
3458
|
-
volumeMapper.setMaximumSamplesPerRay(sharedMapper.getMaximumSamplesPerRay());
|
|
3459
|
-
volumeMapper.setSampleDistance(sharedMapper.getSampleDistance());
|
|
3460
|
-
return volumeMapper;
|
|
3461
|
-
}
|
|
3462
|
-
|
|
3463
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3464
|
-
$U: () => (setIdleSampleDistanceMultiplier),
|
|
3465
|
-
Ax: () => (idleSampleDistanceMultiplierOf),
|
|
3466
|
-
Ay: () => (createVolumeMapper),
|
|
3467
|
-
h6: () => (sampleDistanceOf),
|
|
3468
|
-
hA: () => (convertMapperToNotSharedMapper),
|
|
3469
|
-
nr: () => (sampleDistanceRatiosOf)
|
|
3470
|
-
});
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
},
|
|
3474
|
-
4621(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3475
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3476
|
-
/* import */ var _TargetEventListeners_js__rspack_import_0 = __webpack_require__(23953);
|
|
3477
|
-
/* import */ var _MultiTargetEventListenerManager_js__rspack_import_1 = __webpack_require__(51706);
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3482
|
-
MultiTargetEventListenerManager: () => (/* reexport safe */ _MultiTargetEventListenerManager_js__rspack_import_1.I),
|
|
3483
|
-
TargetEventListeners: () => (/* reexport safe */ _TargetEventListeners_js__rspack_import_0.f)
|
|
3484
|
-
});
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
},
|
|
3488
|
-
46989(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3489
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3490
|
-
/* import */ var _getVoxelThicknessAlongNormal_js__rspack_import_0 = __webpack_require__(61761);
|
|
3491
|
-
/* import */ var _slabMembership_js__rspack_import_1 = __webpack_require__(83965);
|
|
3492
|
-
/* import */ var _indexSpaceSlab_js__rspack_import_2 = __webpack_require__(67251);
|
|
3493
|
-
/* import */ var _isPlaneDepthViewable_js__rspack_import_3 = __webpack_require__(45827);
|
|
3494
|
-
/* import */ var _iterateVoxelsInShape_js__rspack_import_4 = __webpack_require__(72960);
|
|
3495
|
-
/* import */ var _sampleVoxelsInShape_js__rspack_import_5 = __webpack_require__(98412);
|
|
3496
|
-
/* import */ var _shapes_index_js__rspack_import_6 = __webpack_require__(24779);
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3506
|
-
SLAB_RELATIVE_EPSILON: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.ni),
|
|
3507
|
-
UNBOUNDED: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.fk),
|
|
3508
|
-
asUnitNormal: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.Ko),
|
|
3509
|
-
buildIndexSpaceSlab: () => (/* reexport safe */ _indexSpaceSlab_js__rspack_import_2.r9),
|
|
3510
|
-
collectVoxelsInShape: () => (/* reexport safe */ _iterateVoxelsInShape_js__rspack_import_4.i),
|
|
3511
|
-
createCircleShape: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.Q6),
|
|
3512
|
-
createColumnLineResolver: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.nw),
|
|
3513
|
-
createEllipseShape: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.CZ),
|
|
3514
|
-
createPlaneBasis: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.NC),
|
|
3515
|
-
createPolylineShape: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.oY),
|
|
3516
|
-
createRectangleShape: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.Tc),
|
|
3517
|
-
createUnionShape: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.ZG),
|
|
3518
|
-
depthAtIndex: () => (/* reexport safe */ _indexSpaceSlab_js__rspack_import_2.xe),
|
|
3519
|
-
getAxisSteps: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.NU),
|
|
3520
|
-
getDepthRun: () => (/* reexport safe */ _indexSpaceSlab_js__rspack_import_2.XT),
|
|
3521
|
-
getDisplayHalfWidth: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.k),
|
|
3522
|
-
getFillHalfWidth: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.xG),
|
|
3523
|
-
getIndexSpaceNormal: () => (/* reexport safe */ _indexSpaceSlab_js__rspack_import_2.M0),
|
|
3524
|
-
getMembershipHalfWidth: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.q$),
|
|
3525
|
-
getSlabAxisBound: () => (/* reexport safe */ _indexSpaceSlab_js__rspack_import_2.i3),
|
|
3526
|
-
getSlabEpsilon: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.Xm),
|
|
3527
|
-
getSlabHalfWidth: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.ks),
|
|
3528
|
-
getVoxelThicknessAlongNormal: () => (/* reexport safe */ _getVoxelThicknessAlongNormal_js__rspack_import_0.A),
|
|
3529
|
-
intersectRanges: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.im),
|
|
3530
|
-
isPlaneDepthViewable: () => (/* reexport safe */ _isPlaneDepthViewable_js__rspack_import_3.L),
|
|
3531
|
-
isSlabDepthLowInclusive: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.K5),
|
|
3532
|
-
isVoxelCenterInSlab: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.$X),
|
|
3533
|
-
isWithinSlab: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.OP),
|
|
3534
|
-
iterateVoxelsInShape: () => (/* reexport safe */ _iterateVoxelsInShape_js__rspack_import_4.m),
|
|
3535
|
-
pickOuterAxis: () => (/* reexport safe */ _indexSpaceSlab_js__rspack_import_2.o2),
|
|
3536
|
-
projectPointOntoPlane: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.G9),
|
|
3537
|
-
resolveReferencePlaneThickness: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.gr),
|
|
3538
|
-
sampleVoxelsInShape: () => (/* reexport safe */ _sampleVoxelsInShape_js__rspack_import_5._),
|
|
3539
|
-
signedDistanceToPlane: () => (/* reexport safe */ _slabMembership_js__rspack_import_1.ny),
|
|
3540
|
-
solveAbsLinearLeq: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.n3),
|
|
3541
|
-
solveQuadraticLeqZero: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.mB),
|
|
3542
|
-
toIntegerRun: () => (/* reexport safe */ _shapes_index_js__rspack_import_6.nS)
|
|
3543
|
-
});
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
},
|
|
3547
|
-
90004(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3548
|
-
//#region Sources/Common/DataModel/DataSetAttributes/Constants.js
|
|
3549
|
-
var AttributeTypes = {
|
|
3550
|
-
SCALARS: 0,
|
|
3551
|
-
VECTORS: 1,
|
|
3552
|
-
NORMALS: 2,
|
|
3553
|
-
TCOORDS: 3,
|
|
3554
|
-
TENSORS: 4,
|
|
3555
|
-
GLOBALIDS: 5,
|
|
3556
|
-
PEDIGREEIDS: 6,
|
|
3557
|
-
EDGEFLAG: 7,
|
|
3558
|
-
NUM_ATTRIBUTES: 8
|
|
3559
|
-
};
|
|
3560
|
-
var AttributeLimitTypes = {
|
|
3561
|
-
MAX: 0,
|
|
3562
|
-
EXACT: 1,
|
|
3563
|
-
NOLIMIT: 2
|
|
3564
|
-
};
|
|
3565
|
-
var CellGhostTypes = {
|
|
3566
|
-
DUPLICATECELL: 1,
|
|
3567
|
-
HIGHCONNECTIVITYCELL: 2,
|
|
3568
|
-
LOWCONNECTIVITYCELL: 4,
|
|
3569
|
-
REFINEDCELL: 8,
|
|
3570
|
-
EXTERIORCELL: 16,
|
|
3571
|
-
HIDDENCELL: 32
|
|
3572
|
-
};
|
|
3573
|
-
var PointGhostTypes = {
|
|
3574
|
-
DUPLICATEPOINT: 1,
|
|
3575
|
-
HIDDENPOINT: 2
|
|
3576
|
-
};
|
|
3577
|
-
var AttributeCopyOperations = {
|
|
3578
|
-
COPYTUPLE: 0,
|
|
3579
|
-
INTERPOLATE: 1,
|
|
3580
|
-
PASSDATA: 2,
|
|
3581
|
-
ALLCOPY: 3
|
|
3582
|
-
};
|
|
3583
|
-
var ghostArrayName = "vtkGhostType";
|
|
3584
|
-
var DesiredOutputPrecision = {
|
|
3585
|
-
DEFAULT: 0,
|
|
3586
|
-
SINGLE: 1,
|
|
3587
|
-
DOUBLE: 2
|
|
3588
|
-
};
|
|
3589
|
-
var Constants_default = {
|
|
3590
|
-
AttributeCopyOperations,
|
|
3591
|
-
AttributeLimitTypes,
|
|
3592
|
-
AttributeTypes,
|
|
3593
|
-
CellGhostTypes,
|
|
3594
|
-
DesiredOutputPrecision,
|
|
3595
|
-
PointGhostTypes,
|
|
3596
|
-
ghostArrayName
|
|
3597
|
-
};
|
|
3598
|
-
//#endregion
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
//# sourceMappingURL=Constants.js.map
|
|
3602
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
3603
|
-
Ay: () => (Constants_default),
|
|
3604
|
-
kP: () => (DesiredOutputPrecision)
|
|
3605
|
-
});
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
},
|
|
3609
|
-
|
|
3610
|
-
}]);
|