@vertexvis/geometry 1.1.1-testing.2 → 1.1.1-testing.4
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/README.md +8 -8
- package/README.template.md +8 -8
- package/dist/bundle.cjs +56 -58
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.js +56 -58
- package/dist/bundle.js.map +1 -1
- package/dist/cdn/bundle.js +56 -58
- package/dist/cdn/bundle.js.map +1 -1
- package/dist/cdn/bundle.min.js.map +1 -1
- package/package.json +4 -4
package/dist/cdn/bundle.js
CHANGED
|
@@ -248,37 +248,46 @@ var angle = /*#__PURE__*/Object.freeze({
|
|
|
248
248
|
/**
|
|
249
249
|
* Creates a 4x4 matrix from a set of row-major components.
|
|
250
250
|
*/
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
/* eslint-disable prettier/prettier */
|
|
251
|
+
// prettier-ignore
|
|
252
|
+
function fromValues(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) {
|
|
253
|
+
// prettier-ignore
|
|
255
254
|
return [
|
|
256
255
|
m11, m12, m13, m14,
|
|
257
256
|
m21, m22, m23, m24,
|
|
258
257
|
m31, m32, m33, m34,
|
|
259
258
|
m41, m42, m43, m44,
|
|
260
259
|
];
|
|
261
|
-
/* eslint-enable prettier/prettier */
|
|
262
260
|
}
|
|
263
261
|
/**
|
|
264
262
|
* Creates a `Matrix4` from an object representation.
|
|
265
263
|
*/
|
|
266
264
|
function fromObject(obj) {
|
|
267
|
-
|
|
265
|
+
// prettier-ignore
|
|
268
266
|
return fromValues(obj.m11, obj.m12, obj.m13, obj.m14, obj.m21, obj.m22, obj.m23, obj.m24, obj.m31, obj.m32, obj.m33, obj.m34, obj.m41, obj.m42, obj.m43, obj.m44);
|
|
269
|
-
/* eslint-enable prettier/prettier */
|
|
270
267
|
}
|
|
271
268
|
/**
|
|
272
269
|
* Returns a new [identity matrix](https://en.wikipedia.org/wiki/Identity_matrix).
|
|
273
270
|
*/
|
|
274
271
|
function makeIdentity() {
|
|
275
|
-
|
|
272
|
+
// prettier-ignore
|
|
273
|
+
return [
|
|
274
|
+
1, 0, 0, 0,
|
|
275
|
+
0, 1, 0, 0,
|
|
276
|
+
0, 0, 1, 0,
|
|
277
|
+
0, 0, 0, 1,
|
|
278
|
+
];
|
|
276
279
|
}
|
|
277
280
|
/**
|
|
278
281
|
* Returns a matrix with all values as 0.
|
|
279
282
|
*/
|
|
280
283
|
function makeZero() {
|
|
281
|
-
|
|
284
|
+
// prettier-ignore
|
|
285
|
+
return [
|
|
286
|
+
0, 0, 0, 0,
|
|
287
|
+
0, 0, 0, 0,
|
|
288
|
+
0, 0, 0, 0,
|
|
289
|
+
0, 0, 0, 0,
|
|
290
|
+
];
|
|
282
291
|
}
|
|
283
292
|
/**
|
|
284
293
|
* Creates a translation matrix.
|
|
@@ -295,14 +304,13 @@ function makeZero() {
|
|
|
295
304
|
*/
|
|
296
305
|
function makeTranslation(translation) {
|
|
297
306
|
const { x, y, z } = translation;
|
|
298
|
-
|
|
307
|
+
// prettier-ignore
|
|
299
308
|
return [
|
|
300
309
|
1, 0, 0, 0,
|
|
301
310
|
0, 1, 0, 0,
|
|
302
311
|
0, 0, 1, 0,
|
|
303
312
|
x, y, z, 1,
|
|
304
313
|
];
|
|
305
|
-
/* eslint-enable prettier/prettier */
|
|
306
314
|
}
|
|
307
315
|
/**
|
|
308
316
|
* Creates a rotation matrix.
|
|
@@ -324,14 +332,13 @@ function makeRotation(rotation) {
|
|
|
324
332
|
const xx = x * x2, xy = x * y2, xz = x * z2;
|
|
325
333
|
const yy = y * y2, yz = y * z2, zz = z * z2;
|
|
326
334
|
const wx = w * x2, wy = w * y2, wz = w * z2;
|
|
327
|
-
|
|
335
|
+
// prettier-ignore
|
|
328
336
|
return [
|
|
329
337
|
1 - (yy + zz), xy - wz, xz + wy, 0,
|
|
330
338
|
xy + wz, 1 - (xx + zz), yz - wx, 0,
|
|
331
339
|
xz - wy, yz + wx, 1 - (xx + yy), 0,
|
|
332
340
|
0, 0, 0, 1
|
|
333
341
|
];
|
|
334
|
-
/* eslint-enable prettier/prettier */
|
|
335
342
|
}
|
|
336
343
|
/**
|
|
337
344
|
* Creates a scale matrix.
|
|
@@ -348,14 +355,13 @@ function makeRotation(rotation) {
|
|
|
348
355
|
*/
|
|
349
356
|
function makeScale(scale) {
|
|
350
357
|
const { x, y, z } = scale;
|
|
351
|
-
|
|
358
|
+
// prettier-ignore
|
|
352
359
|
return [
|
|
353
360
|
x, 0, 0, 0,
|
|
354
361
|
0, y, 0, 0,
|
|
355
362
|
0, 0, z, 0,
|
|
356
363
|
0, 0, 0, 1,
|
|
357
364
|
];
|
|
358
|
-
/* eslint-enable prettier/prettier */
|
|
359
365
|
}
|
|
360
366
|
/**
|
|
361
367
|
* Creates a matrix that has translation, rotation, and scale applied to it.
|
|
@@ -388,14 +394,13 @@ function makeTRS(translation, rotation, scale) {
|
|
|
388
394
|
* @returns A matrix with its basis components populated.
|
|
389
395
|
*/
|
|
390
396
|
function makeBasis(x, y, z) {
|
|
391
|
-
|
|
397
|
+
// prettier-ignore
|
|
392
398
|
return [
|
|
393
399
|
x.x, x.y, x.z, 0,
|
|
394
400
|
y.x, y.y, y.z, 0,
|
|
395
401
|
z.x, z.y, z.z, 0,
|
|
396
402
|
0, 0, 0, 1
|
|
397
403
|
];
|
|
398
|
-
/* eslint-enable prettier/prettier */
|
|
399
404
|
}
|
|
400
405
|
/**
|
|
401
406
|
* Creates a matrix used for [perspective
|
|
@@ -422,14 +427,13 @@ function makeFrustum(left, right, top, bottom, near, far) {
|
|
|
422
427
|
const b = (top + bottom) / (top - bottom);
|
|
423
428
|
const c = -(far + near) / (far - near);
|
|
424
429
|
const d = (-2 * far * near) / (far - near);
|
|
425
|
-
|
|
430
|
+
// prettier-ignore
|
|
426
431
|
return [
|
|
427
432
|
x, 0, 0, 0,
|
|
428
433
|
0, y, 0, 0,
|
|
429
434
|
a, b, c, -1,
|
|
430
435
|
0, 0, d, 0
|
|
431
436
|
];
|
|
432
|
-
/* eslint-enable prettier/prettier */
|
|
433
437
|
}
|
|
434
438
|
/**
|
|
435
439
|
* Creates a perspective projection matrix.
|
|
@@ -482,14 +486,13 @@ function makeOrthographic(left, right, bottom, top, near, far) {
|
|
|
482
486
|
const x = (right + left) * w;
|
|
483
487
|
const y = (top + bottom) * h;
|
|
484
488
|
const z = (far + near) * d;
|
|
485
|
-
|
|
489
|
+
// prettier-ignore
|
|
486
490
|
return [
|
|
487
491
|
2 * w, 0, 0, -x,
|
|
488
492
|
0, 2 * h, 0, -y,
|
|
489
493
|
0, 0, -2 * d, -z,
|
|
490
494
|
0, 0, 0, 1
|
|
491
495
|
];
|
|
492
|
-
/* eslint-enable prettier/prettier */
|
|
493
496
|
}
|
|
494
497
|
/**
|
|
495
498
|
* Matrix becomes a combination of an inverse translation and rotation.
|
|
@@ -517,14 +520,13 @@ function makeLookAtView(position, lookAt, up) {
|
|
|
517
520
|
const dotX = -dot$1(x, position);
|
|
518
521
|
const dotY = -dot$1(y, position);
|
|
519
522
|
const dotZ = -dot$1(z, position);
|
|
520
|
-
|
|
523
|
+
// prettier-ignore
|
|
521
524
|
return [
|
|
522
525
|
x.x, y.x, z.x, 0,
|
|
523
526
|
x.y, y.y, z.y, 0,
|
|
524
527
|
x.z, y.z, z.z, 0,
|
|
525
528
|
dotX, dotY, dotZ, 1,
|
|
526
529
|
];
|
|
527
|
-
/* eslint-enable prettier/prettier */
|
|
528
530
|
}
|
|
529
531
|
/**
|
|
530
532
|
* Matrix becomes a combination of translation and rotation.
|
|
@@ -543,14 +545,13 @@ function makeLookAt(position, lookAt, up) {
|
|
|
543
545
|
const z = normalize(subtract(position, lookAt));
|
|
544
546
|
const x = normalize(cross(up, z));
|
|
545
547
|
const y = cross(z, x);
|
|
546
|
-
|
|
548
|
+
// prettier-ignore
|
|
547
549
|
return [
|
|
548
550
|
x.x, x.y, x.z, 0,
|
|
549
551
|
y.x, y.y, y.z, 0,
|
|
550
552
|
z.x, z.y, z.z, 0,
|
|
551
553
|
position.x, position.y, position.z, 1
|
|
552
554
|
];
|
|
553
|
-
/* eslint-enable prettier/prettier */
|
|
554
555
|
}
|
|
555
556
|
/**
|
|
556
557
|
* Returns the inverse of the given matrix. If the determinate of the matrix is
|
|
@@ -628,17 +629,18 @@ function lookAt(m, position, target, up) {
|
|
|
628
629
|
x = normalize(x);
|
|
629
630
|
const y = cross(z, x);
|
|
630
631
|
const res = [...m];
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
632
|
+
// prettier-ignore
|
|
633
|
+
{
|
|
634
|
+
res[0] = x.x;
|
|
635
|
+
res[1] = x.y;
|
|
636
|
+
res[2] = x.z;
|
|
637
|
+
res[4] = y.x;
|
|
638
|
+
res[5] = y.y;
|
|
639
|
+
res[6] = y.z;
|
|
640
|
+
res[8] = z.x;
|
|
641
|
+
res[9] = z.y;
|
|
642
|
+
res[10] = z.z;
|
|
643
|
+
}
|
|
642
644
|
return res;
|
|
643
645
|
}
|
|
644
646
|
/**
|
|
@@ -667,14 +669,13 @@ function multiply$2(a, b) {
|
|
|
667
669
|
* matrix.
|
|
668
670
|
*/
|
|
669
671
|
function transpose(matrix) {
|
|
670
|
-
|
|
672
|
+
// prettier-ignore
|
|
671
673
|
return [
|
|
672
674
|
matrix[0], matrix[4], matrix[8], matrix[12],
|
|
673
675
|
matrix[1], matrix[5], matrix[9], matrix[13],
|
|
674
676
|
matrix[2], matrix[6], matrix[10], matrix[14],
|
|
675
677
|
matrix[3], matrix[7], matrix[11], matrix[15],
|
|
676
678
|
];
|
|
677
|
-
/* eslint-enable prettier/prettier */
|
|
678
679
|
}
|
|
679
680
|
/**
|
|
680
681
|
* Multiplies the columns of a row-major matrix by the given vector.
|
|
@@ -682,20 +683,21 @@ function transpose(matrix) {
|
|
|
682
683
|
function scale$4(matrix, scale) {
|
|
683
684
|
const { x, y, z } = scale;
|
|
684
685
|
const m = [...matrix];
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
686
|
+
// prettier-ignore
|
|
687
|
+
{
|
|
688
|
+
m[0] *= x;
|
|
689
|
+
m[1] *= x;
|
|
690
|
+
m[2] *= x;
|
|
691
|
+
m[3] *= x;
|
|
692
|
+
m[4] *= y;
|
|
693
|
+
m[5] *= y;
|
|
694
|
+
m[6] *= y;
|
|
695
|
+
m[7] *= y;
|
|
696
|
+
m[8] *= z;
|
|
697
|
+
m[9] *= z;
|
|
698
|
+
m[10] *= z;
|
|
699
|
+
m[11] *= z;
|
|
700
|
+
}
|
|
699
701
|
return m;
|
|
700
702
|
}
|
|
701
703
|
/**
|
|
@@ -731,28 +733,26 @@ function toObject(m) {
|
|
|
731
733
|
* @param m A Matrix4 item written in column-major form.
|
|
732
734
|
*/
|
|
733
735
|
function toObjectColumnMajor(m) {
|
|
734
|
-
|
|
736
|
+
// prettier-ignore
|
|
735
737
|
return {
|
|
736
738
|
m11: m[0], m12: m[4], m13: m[8], m14: m[12],
|
|
737
739
|
m21: m[1], m22: m[5], m23: m[9], m24: m[13],
|
|
738
740
|
m31: m[2], m32: m[6], m33: m[10], m34: m[14],
|
|
739
741
|
m41: m[3], m42: m[7], m43: m[11], m44: m[15],
|
|
740
742
|
};
|
|
741
|
-
/* eslint-enable prettier/prettier */
|
|
742
743
|
}
|
|
743
744
|
/**
|
|
744
745
|
* Returns an object representation of a `Matrix4`.
|
|
745
746
|
* @param m A Matrix4 item written in row-major form.
|
|
746
747
|
*/
|
|
747
748
|
function toObjectRowMajor(m) {
|
|
748
|
-
|
|
749
|
+
// prettier-ignore
|
|
749
750
|
return {
|
|
750
751
|
m11: m[0], m12: m[1], m13: m[2], m14: m[3],
|
|
751
752
|
m21: m[4], m22: m[5], m23: m[6], m24: m[7],
|
|
752
753
|
m31: m[8], m32: m[9], m33: m[10], m34: m[11],
|
|
753
754
|
m41: m[12], m42: m[13], m43: m[14], m44: m[15],
|
|
754
755
|
};
|
|
755
|
-
/* eslint-enable prettier/prettier */
|
|
756
756
|
}
|
|
757
757
|
/**
|
|
758
758
|
* A type guard to check if `obj` is of type `Matrix4`.
|
|
@@ -1171,7 +1171,6 @@ function create$a(...args) {
|
|
|
1171
1171
|
};
|
|
1172
1172
|
}
|
|
1173
1173
|
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
1174
|
-
/* eslint-enable padding-line-between-statements */
|
|
1175
1174
|
/**
|
|
1176
1175
|
* Checks if each component of the given vector is populated with a numeric
|
|
1177
1176
|
* component. A component is invalid if it contains a non-finite or NaN value.
|
|
@@ -1628,7 +1627,6 @@ function union(box, ...rest) {
|
|
|
1628
1627
|
return create$9(min(a.min, b.min), max(a.max, b.max));
|
|
1629
1628
|
}, box);
|
|
1630
1629
|
}
|
|
1631
|
-
/* eslint-enable padding-line-between-statements */
|
|
1632
1630
|
/**
|
|
1633
1631
|
* Returns the distance between the min and max for the provided
|
|
1634
1632
|
* bounding box for each axis.
|