lecodes-cli 0.1.3 → 0.1.6

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.
@@ -1,765 +0,0 @@
1
- import * as glMatrix from "./common.js";
2
-
3
- /**
4
- * 3x3 Matrix
5
- * @module mat3
6
- */
7
-
8
- /**
9
- * Creates a new identity mat3
10
- *
11
- * @returns {mat3} a new 3x3 matrix
12
- */
13
- export function create() {
14
- var out = new Float32Array(9);
15
- out[0] = 1;
16
- out[4] = 1;
17
- out[8] = 1;
18
- return out;
19
- }
20
-
21
- /**
22
- * Copies the upper-left 3x3 values into the given mat3.
23
- *
24
- * @param {mat3} out the receiving 3x3 matrix
25
- * @param {ReadonlyMat4} a the source 4x4 matrix
26
- * @returns {mat3} out
27
- */
28
- export function fromMat4(out, a) {
29
- out[0] = a[0];
30
- out[1] = a[1];
31
- out[2] = a[2];
32
- out[3] = a[4];
33
- out[4] = a[5];
34
- out[5] = a[6];
35
- out[6] = a[8];
36
- out[7] = a[9];
37
- out[8] = a[10];
38
- return out;
39
- }
40
-
41
- /**
42
- * Creates a new mat3 initialized with values from an existing matrix
43
- *
44
- * @param {ReadonlyMat3} a matrix to clone
45
- * @returns {mat3} a new 3x3 matrix
46
- */
47
- export function clone(a) {
48
- var out = new Float32Array(9);
49
- out[0] = a[0];
50
- out[1] = a[1];
51
- out[2] = a[2];
52
- out[3] = a[3];
53
- out[4] = a[4];
54
- out[5] = a[5];
55
- out[6] = a[6];
56
- out[7] = a[7];
57
- out[8] = a[8];
58
- return out;
59
- }
60
-
61
- /**
62
- * Copy the values from one mat3 to another
63
- *
64
- * @param {mat3} out the receiving matrix
65
- * @param {ReadonlyMat3} a the source matrix
66
- * @returns {mat3} out
67
- */
68
- export function copy(out, a) {
69
- out[0] = a[0];
70
- out[1] = a[1];
71
- out[2] = a[2];
72
- out[3] = a[3];
73
- out[4] = a[4];
74
- out[5] = a[5];
75
- out[6] = a[6];
76
- out[7] = a[7];
77
- out[8] = a[8];
78
- return out;
79
- }
80
-
81
- /**
82
- * Create a new mat3 with the given values
83
- *
84
- * @param {Number} m00 Component in column 0, row 0 position (index 0)
85
- * @param {Number} m01 Component in column 0, row 1 position (index 1)
86
- * @param {Number} m02 Component in column 0, row 2 position (index 2)
87
- * @param {Number} m10 Component in column 1, row 0 position (index 3)
88
- * @param {Number} m11 Component in column 1, row 1 position (index 4)
89
- * @param {Number} m12 Component in column 1, row 2 position (index 5)
90
- * @param {Number} m20 Component in column 2, row 0 position (index 6)
91
- * @param {Number} m21 Component in column 2, row 1 position (index 7)
92
- * @param {Number} m22 Component in column 2, row 2 position (index 8)
93
- * @returns {mat3} A new mat3
94
- */
95
- export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
96
- var out = new Float32Array(9);
97
- out[0] = m00;
98
- out[1] = m01;
99
- out[2] = m02;
100
- out[3] = m10;
101
- out[4] = m11;
102
- out[5] = m12;
103
- out[6] = m20;
104
- out[7] = m21;
105
- out[8] = m22;
106
- return out;
107
- }
108
-
109
- /**
110
- * Set the components of a mat3 to the given values
111
- *
112
- * @param {mat3} out the receiving matrix
113
- * @param {Number} m00 Component in column 0, row 0 position (index 0)
114
- * @param {Number} m01 Component in column 0, row 1 position (index 1)
115
- * @param {Number} m02 Component in column 0, row 2 position (index 2)
116
- * @param {Number} m10 Component in column 1, row 0 position (index 3)
117
- * @param {Number} m11 Component in column 1, row 1 position (index 4)
118
- * @param {Number} m12 Component in column 1, row 2 position (index 5)
119
- * @param {Number} m20 Component in column 2, row 0 position (index 6)
120
- * @param {Number} m21 Component in column 2, row 1 position (index 7)
121
- * @param {Number} m22 Component in column 2, row 2 position (index 8)
122
- * @returns {mat3} out
123
- */
124
- export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
125
- out[0] = m00;
126
- out[1] = m01;
127
- out[2] = m02;
128
- out[3] = m10;
129
- out[4] = m11;
130
- out[5] = m12;
131
- out[6] = m20;
132
- out[7] = m21;
133
- out[8] = m22;
134
- return out;
135
- }
136
-
137
- /**
138
- * Set a mat3 to the identity matrix
139
- *
140
- * @param {mat3} out the receiving matrix
141
- * @returns {mat3} out
142
- */
143
- export function identity(out) {
144
- out[0] = 1;
145
- out[1] = 0;
146
- out[2] = 0;
147
- out[3] = 0;
148
- out[4] = 1;
149
- out[5] = 0;
150
- out[6] = 0;
151
- out[7] = 0;
152
- out[8] = 1;
153
- return out;
154
- }
155
-
156
- /**
157
- * Transpose the values of a mat3
158
- *
159
- * @param {mat3} out the receiving matrix
160
- * @param {ReadonlyMat3} a the source matrix
161
- * @returns {mat3} out
162
- */
163
- export function transpose(out, a) {
164
- // If we are transposing ourselves we can skip a few steps but have to cache some values
165
- if (out === a) {
166
- var a01 = a[1],
167
- a02 = a[2],
168
- a12 = a[5];
169
- out[1] = a[3];
170
- out[2] = a[6];
171
- out[3] = a01;
172
- out[5] = a[7];
173
- out[6] = a02;
174
- out[7] = a12;
175
- } else {
176
- out[0] = a[0];
177
- out[1] = a[3];
178
- out[2] = a[6];
179
- out[3] = a[1];
180
- out[4] = a[4];
181
- out[5] = a[7];
182
- out[6] = a[2];
183
- out[7] = a[5];
184
- out[8] = a[8];
185
- }
186
- return out;
187
- }
188
-
189
- /**
190
- * Inverts a mat3
191
- *
192
- * @param {mat3} out the receiving matrix
193
- * @param {ReadonlyMat3} a the source matrix
194
- * @returns {mat3 | null} out, or null if source matrix is not invertible
195
- */
196
- export function invert(out, a) {
197
- var a00 = a[0],
198
- a01 = a[1],
199
- a02 = a[2];
200
- var a10 = a[3],
201
- a11 = a[4],
202
- a12 = a[5];
203
- var a20 = a[6],
204
- a21 = a[7],
205
- a22 = a[8];
206
- var b01 = a22 * a11 - a12 * a21;
207
- var b11 = -a22 * a10 + a12 * a20;
208
- var b21 = a21 * a10 - a11 * a20;
209
-
210
- // Calculate the determinant
211
- var det = a00 * b01 + a01 * b11 + a02 * b21;
212
- if (!det) {
213
- return null;
214
- }
215
- det = 1.0 / det;
216
- out[0] = b01 * det;
217
- out[1] = (-a22 * a01 + a02 * a21) * det;
218
- out[2] = (a12 * a01 - a02 * a11) * det;
219
- out[3] = b11 * det;
220
- out[4] = (a22 * a00 - a02 * a20) * det;
221
- out[5] = (-a12 * a00 + a02 * a10) * det;
222
- out[6] = b21 * det;
223
- out[7] = (-a21 * a00 + a01 * a20) * det;
224
- out[8] = (a11 * a00 - a01 * a10) * det;
225
- return out;
226
- }
227
-
228
- /**
229
- * Calculates the adjugate of a mat3
230
- *
231
- * @param {mat3} out the receiving matrix
232
- * @param {ReadonlyMat3} a the source matrix
233
- * @returns {mat3} out
234
- */
235
- export function adjoint(out, a) {
236
- var a00 = a[0],
237
- a01 = a[1],
238
- a02 = a[2];
239
- var a10 = a[3],
240
- a11 = a[4],
241
- a12 = a[5];
242
- var a20 = a[6],
243
- a21 = a[7],
244
- a22 = a[8];
245
- out[0] = a11 * a22 - a12 * a21;
246
- out[1] = a02 * a21 - a01 * a22;
247
- out[2] = a01 * a12 - a02 * a11;
248
- out[3] = a12 * a20 - a10 * a22;
249
- out[4] = a00 * a22 - a02 * a20;
250
- out[5] = a02 * a10 - a00 * a12;
251
- out[6] = a10 * a21 - a11 * a20;
252
- out[7] = a01 * a20 - a00 * a21;
253
- out[8] = a00 * a11 - a01 * a10;
254
- return out;
255
- }
256
-
257
- /**
258
- * Calculates the determinant of a mat3
259
- *
260
- * @param {ReadonlyMat3} a the source matrix
261
- * @returns {Number} determinant of a
262
- */
263
- export function determinant(a) {
264
- var a00 = a[0],
265
- a01 = a[1],
266
- a02 = a[2];
267
- var a10 = a[3],
268
- a11 = a[4],
269
- a12 = a[5];
270
- var a20 = a[6],
271
- a21 = a[7],
272
- a22 = a[8];
273
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
274
- }
275
-
276
- /**
277
- * Multiplies two mat3's
278
- *
279
- * @param {mat3} out the receiving matrix
280
- * @param {ReadonlyMat3} a the first operand
281
- * @param {ReadonlyMat3} b the second operand
282
- * @returns {mat3} out
283
- */
284
- export function multiply(out, a, b) {
285
- var a00 = a[0],
286
- a01 = a[1],
287
- a02 = a[2];
288
- var a10 = a[3],
289
- a11 = a[4],
290
- a12 = a[5];
291
- var a20 = a[6],
292
- a21 = a[7],
293
- a22 = a[8];
294
- var b00 = b[0],
295
- b01 = b[1],
296
- b02 = b[2];
297
- var b10 = b[3],
298
- b11 = b[4],
299
- b12 = b[5];
300
- var b20 = b[6],
301
- b21 = b[7],
302
- b22 = b[8];
303
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
304
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
305
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
306
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
307
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
308
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
309
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
310
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
311
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
312
- return out;
313
- }
314
-
315
- /**
316
- * Translate a mat3 by the given vector
317
- *
318
- * @param {mat3} out the receiving matrix
319
- * @param {ReadonlyMat3} a the matrix to translate
320
- * @param {ReadonlyVec2} v vector to translate by
321
- * @returns {mat3} out
322
- */
323
- export function translate(out, a, v) {
324
- var a00 = a[0],
325
- a01 = a[1],
326
- a02 = a[2],
327
- a10 = a[3],
328
- a11 = a[4],
329
- a12 = a[5],
330
- a20 = a[6],
331
- a21 = a[7],
332
- a22 = a[8],
333
- x = v[0],
334
- y = v[1];
335
- out[0] = a00;
336
- out[1] = a01;
337
- out[2] = a02;
338
- out[3] = a10;
339
- out[4] = a11;
340
- out[5] = a12;
341
- out[6] = x * a00 + y * a10 + a20;
342
- out[7] = x * a01 + y * a11 + a21;
343
- out[8] = x * a02 + y * a12 + a22;
344
- return out;
345
- }
346
-
347
- /**
348
- * Rotates a mat3 by the given angle
349
- *
350
- * @param {mat3} out the receiving matrix
351
- * @param {ReadonlyMat3} a the matrix to rotate
352
- * @param {Number} rad the angle to rotate the matrix by
353
- * @returns {mat3} out
354
- */
355
- export function rotate(out, a, rad) {
356
- var a00 = a[0],
357
- a01 = a[1],
358
- a02 = a[2],
359
- a10 = a[3],
360
- a11 = a[4],
361
- a12 = a[5],
362
- a20 = a[6],
363
- a21 = a[7],
364
- a22 = a[8],
365
- s = Math.sin(rad),
366
- c = Math.cos(rad);
367
- out[0] = c * a00 + s * a10;
368
- out[1] = c * a01 + s * a11;
369
- out[2] = c * a02 + s * a12;
370
- out[3] = c * a10 - s * a00;
371
- out[4] = c * a11 - s * a01;
372
- out[5] = c * a12 - s * a02;
373
- out[6] = a20;
374
- out[7] = a21;
375
- out[8] = a22;
376
- return out;
377
- }
378
-
379
- /**
380
- * Scales the mat3 by the dimensions in the given vec2
381
- *
382
- * @param {mat3} out the receiving matrix
383
- * @param {ReadonlyMat3} a the matrix to scale
384
- * @param {ReadonlyVec2} v the vec2 to scale the matrix by
385
- * @returns {mat3} out
386
- **/
387
- export function scale(out, a, v) {
388
- var x = v[0],
389
- y = v[1];
390
- out[0] = x * a[0];
391
- out[1] = x * a[1];
392
- out[2] = x * a[2];
393
- out[3] = y * a[3];
394
- out[4] = y * a[4];
395
- out[5] = y * a[5];
396
- out[6] = a[6];
397
- out[7] = a[7];
398
- out[8] = a[8];
399
- return out;
400
- }
401
-
402
- /**
403
- * Creates a matrix from a vector translation
404
- * This is equivalent to (but much faster than):
405
- *
406
- * mat3.identity(dest);
407
- * mat3.translate(dest, dest, vec);
408
- *
409
- * @param {mat3} out mat3 receiving operation result
410
- * @param {ReadonlyVec2} v Translation vector
411
- * @returns {mat3} out
412
- */
413
- export function fromTranslation(out, v) {
414
- out[0] = 1;
415
- out[1] = 0;
416
- out[2] = 0;
417
- out[3] = 0;
418
- out[4] = 1;
419
- out[5] = 0;
420
- out[6] = v[0];
421
- out[7] = v[1];
422
- out[8] = 1;
423
- return out;
424
- }
425
-
426
- /**
427
- * Creates a matrix from a given angle
428
- * This is equivalent to (but much faster than):
429
- *
430
- * mat3.identity(dest);
431
- * mat3.rotate(dest, dest, rad);
432
- *
433
- * @param {mat3} out mat3 receiving operation result
434
- * @param {Number} rad the angle to rotate the matrix by
435
- * @returns {mat3} out
436
- */
437
- export function fromRotation(out, rad) {
438
- var s = Math.sin(rad),
439
- c = Math.cos(rad);
440
- out[0] = c;
441
- out[1] = s;
442
- out[2] = 0;
443
- out[3] = -s;
444
- out[4] = c;
445
- out[5] = 0;
446
- out[6] = 0;
447
- out[7] = 0;
448
- out[8] = 1;
449
- return out;
450
- }
451
-
452
- /**
453
- * Creates a matrix from a vector scaling
454
- * This is equivalent to (but much faster than):
455
- *
456
- * mat3.identity(dest);
457
- * mat3.scale(dest, dest, vec);
458
- *
459
- * @param {mat3} out mat3 receiving operation result
460
- * @param {ReadonlyVec2} v Scaling vector
461
- * @returns {mat3} out
462
- */
463
- export function fromScaling(out, v) {
464
- out[0] = v[0];
465
- out[1] = 0;
466
- out[2] = 0;
467
- out[3] = 0;
468
- out[4] = v[1];
469
- out[5] = 0;
470
- out[6] = 0;
471
- out[7] = 0;
472
- out[8] = 1;
473
- return out;
474
- }
475
-
476
- /**
477
- * Copies the values from a mat2d into a mat3
478
- *
479
- * @param {mat3} out the receiving matrix
480
- * @param {ReadonlyMat2d} a the matrix to copy
481
- * @returns {mat3} out
482
- **/
483
- export function fromMat2d(out, a) {
484
- out[0] = a[0];
485
- out[1] = a[1];
486
- out[2] = 0;
487
- out[3] = a[2];
488
- out[4] = a[3];
489
- out[5] = 0;
490
- out[6] = a[4];
491
- out[7] = a[5];
492
- out[8] = 1;
493
- return out;
494
- }
495
-
496
- /**
497
- * Calculates a 3x3 matrix from the given quaternion
498
- *
499
- * @param {mat3} out mat3 receiving operation result
500
- * @param {ReadonlyQuat} q Quaternion to create matrix from
501
- *
502
- * @returns {mat3} out
503
- */
504
- export function fromQuat(out, q) {
505
- var x = q[0],
506
- y = q[1],
507
- z = q[2],
508
- w = q[3];
509
- var x2 = x + x;
510
- var y2 = y + y;
511
- var z2 = z + z;
512
- var xx = x * x2;
513
- var yx = y * x2;
514
- var yy = y * y2;
515
- var zx = z * x2;
516
- var zy = z * y2;
517
- var zz = z * z2;
518
- var wx = w * x2;
519
- var wy = w * y2;
520
- var wz = w * z2;
521
- out[0] = 1 - yy - zz;
522
- out[3] = yx - wz;
523
- out[6] = zx + wy;
524
- out[1] = yx + wz;
525
- out[4] = 1 - xx - zz;
526
- out[7] = zy - wx;
527
- out[2] = zx - wy;
528
- out[5] = zy + wx;
529
- out[8] = 1 - xx - yy;
530
- return out;
531
- }
532
-
533
- /**
534
- * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
535
- *
536
- * @param {mat3} out mat3 receiving operation result
537
- * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from
538
- *
539
- * @returns {mat3} out
540
- */
541
- export function normalFromMat4(out, a) {
542
- var a00 = a[0],
543
- a01 = a[1],
544
- a02 = a[2],
545
- a03 = a[3];
546
- var a10 = a[4],
547
- a11 = a[5],
548
- a12 = a[6],
549
- a13 = a[7];
550
- var a20 = a[8],
551
- a21 = a[9],
552
- a22 = a[10],
553
- a23 = a[11];
554
- var a30 = a[12],
555
- a31 = a[13],
556
- a32 = a[14],
557
- a33 = a[15];
558
- var b00 = a00 * a11 - a01 * a10;
559
- var b01 = a00 * a12 - a02 * a10;
560
- var b02 = a00 * a13 - a03 * a10;
561
- var b03 = a01 * a12 - a02 * a11;
562
- var b04 = a01 * a13 - a03 * a11;
563
- var b05 = a02 * a13 - a03 * a12;
564
- var b06 = a20 * a31 - a21 * a30;
565
- var b07 = a20 * a32 - a22 * a30;
566
- var b08 = a20 * a33 - a23 * a30;
567
- var b09 = a21 * a32 - a22 * a31;
568
- var b10 = a21 * a33 - a23 * a31;
569
- var b11 = a22 * a33 - a23 * a32;
570
-
571
- // Calculate the determinant
572
- var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
573
- if (!det) {
574
- return null;
575
- }
576
- det = 1.0 / det;
577
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
578
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
579
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
580
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
581
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
582
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
583
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
584
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
585
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
586
- return out;
587
- }
588
-
589
- /**
590
- * Generates a 2D projection matrix with the given bounds
591
- *
592
- * @param {mat3} out mat3 frustum matrix will be written into
593
- * @param {number} width Width of your gl context
594
- * @param {number} height Height of gl context
595
- * @returns {mat3} out
596
- */
597
- export function projection(out, width, height) {
598
- out[0] = 2 / width;
599
- out[1] = 0;
600
- out[2] = 0;
601
- out[3] = 0;
602
- out[4] = -2 / height;
603
- out[5] = 0;
604
- out[6] = -1;
605
- out[7] = 1;
606
- out[8] = 1;
607
- return out;
608
- }
609
-
610
- /**
611
- * Returns a string representation of a mat3
612
- *
613
- * @param {ReadonlyMat3} a matrix to represent as a string
614
- * @returns {String} string representation of the matrix
615
- */
616
- export function str(a) {
617
- return "mat3(" + a[0] + ", " + a[1] + ", " + a[2] + ", " + a[3] + ", " + a[4] + ", " + a[5] + ", " + a[6] + ", " + a[7] + ", " + a[8] + ")";
618
- }
619
-
620
- /**
621
- * Returns Frobenius norm of a mat3
622
- *
623
- * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of
624
- * @returns {Number} Frobenius norm
625
- */
626
- export function frob(a) {
627
- return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8]);
628
- }
629
-
630
- /**
631
- * Adds two mat3's
632
- *
633
- * @param {mat3} out the receiving matrix
634
- * @param {ReadonlyMat3} a the first operand
635
- * @param {ReadonlyMat3} b the second operand
636
- * @returns {mat3} out
637
- */
638
- export function add(out, a, b) {
639
- out[0] = a[0] + b[0];
640
- out[1] = a[1] + b[1];
641
- out[2] = a[2] + b[2];
642
- out[3] = a[3] + b[3];
643
- out[4] = a[4] + b[4];
644
- out[5] = a[5] + b[5];
645
- out[6] = a[6] + b[6];
646
- out[7] = a[7] + b[7];
647
- out[8] = a[8] + b[8];
648
- return out;
649
- }
650
-
651
- /**
652
- * Subtracts matrix b from matrix a
653
- *
654
- * @param {mat3} out the receiving matrix
655
- * @param {ReadonlyMat3} a the first operand
656
- * @param {ReadonlyMat3} b the second operand
657
- * @returns {mat3} out
658
- */
659
- export function subtract(out, a, b) {
660
- out[0] = a[0] - b[0];
661
- out[1] = a[1] - b[1];
662
- out[2] = a[2] - b[2];
663
- out[3] = a[3] - b[3];
664
- out[4] = a[4] - b[4];
665
- out[5] = a[5] - b[5];
666
- out[6] = a[6] - b[6];
667
- out[7] = a[7] - b[7];
668
- out[8] = a[8] - b[8];
669
- return out;
670
- }
671
-
672
- /**
673
- * Multiply each element of the matrix by a scalar.
674
- *
675
- * @param {mat3} out the receiving matrix
676
- * @param {ReadonlyMat3} a the matrix to scale
677
- * @param {Number} b amount to scale the matrix's elements by
678
- * @returns {mat3} out
679
- */
680
- export function multiplyScalar(out, a, b) {
681
- out[0] = a[0] * b;
682
- out[1] = a[1] * b;
683
- out[2] = a[2] * b;
684
- out[3] = a[3] * b;
685
- out[4] = a[4] * b;
686
- out[5] = a[5] * b;
687
- out[6] = a[6] * b;
688
- out[7] = a[7] * b;
689
- out[8] = a[8] * b;
690
- return out;
691
- }
692
-
693
- /**
694
- * Adds two mat3's after multiplying each element of the second operand by a scalar value.
695
- *
696
- * @param {mat3} out the receiving vector
697
- * @param {ReadonlyMat3} a the first operand
698
- * @param {ReadonlyMat3} b the second operand
699
- * @param {Number} scale the amount to scale b's elements by before adding
700
- * @returns {mat3} out
701
- */
702
- export function multiplyScalarAndAdd(out, a, b, scale) {
703
- out[0] = a[0] + b[0] * scale;
704
- out[1] = a[1] + b[1] * scale;
705
- out[2] = a[2] + b[2] * scale;
706
- out[3] = a[3] + b[3] * scale;
707
- out[4] = a[4] + b[4] * scale;
708
- out[5] = a[5] + b[5] * scale;
709
- out[6] = a[6] + b[6] * scale;
710
- out[7] = a[7] + b[7] * scale;
711
- out[8] = a[8] + b[8] * scale;
712
- return out;
713
- }
714
-
715
- /**
716
- * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
717
- *
718
- * @param {ReadonlyMat3} a The first matrix.
719
- * @param {ReadonlyMat3} b The second matrix.
720
- * @returns {Boolean} True if the matrices are equal, false otherwise.
721
- */
722
- export function exactEquals(a, b) {
723
- 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];
724
- }
725
-
726
- /**
727
- * Returns whether or not the matrices have approximately the same elements in the same position.
728
- *
729
- * @param {ReadonlyMat3} a The first matrix.
730
- * @param {ReadonlyMat3} b The second matrix.
731
- * @returns {Boolean} True if the matrices are equal, false otherwise.
732
- */
733
- export function equals(a, b) {
734
- var a0 = a[0],
735
- a1 = a[1],
736
- a2 = a[2],
737
- a3 = a[3],
738
- a4 = a[4],
739
- a5 = a[5],
740
- a6 = a[6],
741
- a7 = a[7],
742
- a8 = a[8];
743
- var b0 = b[0],
744
- b1 = b[1],
745
- b2 = b[2],
746
- b3 = b[3],
747
- b4 = b[4],
748
- b5 = b[5],
749
- b6 = b[6],
750
- b7 = b[7],
751
- b8 = b[8];
752
- return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
753
- }
754
-
755
- /**
756
- * Alias for {@link mat3.multiply}
757
- * @function
758
- */
759
- export var mul = multiply;
760
-
761
- /**
762
- * Alias for {@link mat3.subtract}
763
- * @function
764
- */
765
- export var sub = subtract;