@luma.gl/gltf 9.0.9 → 9.0.11
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/dist.dev.js +133 -339
- package/dist/dist.min.js +7 -7
- package/package.json +4 -4
- package/LICENSE +0 -34
package/dist/dist.dev.js
CHANGED
|
@@ -237,7 +237,10 @@ var __exports__ = (() => {
|
|
|
237
237
|
var window_ = globals.window || globals.self || globals.global || {};
|
|
238
238
|
var global_ = globals.global || globals.self || globals.window || {};
|
|
239
239
|
var document_ = globals.document || {};
|
|
240
|
-
var isBrowser =
|
|
240
|
+
var isBrowser = (
|
|
241
|
+
// @ts-ignore process does not exist on browser
|
|
242
|
+
Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
|
|
243
|
+
);
|
|
241
244
|
var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
|
|
242
245
|
var nodeVersion = matches && parseFloat(matches[1]) || 0;
|
|
243
246
|
|
|
@@ -258,11 +261,10 @@ var __exports__ = (() => {
|
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
// ../../node_modules/@loaders.gl/images/dist/lib/utils/version.js
|
|
261
|
-
var VERSION = true ? "4.
|
|
264
|
+
var VERSION = true ? "4.2.0-beta.2" : "latest";
|
|
262
265
|
|
|
263
266
|
// ../../node_modules/@loaders.gl/images/dist/lib/category-api/image-type.js
|
|
264
|
-
var
|
|
265
|
-
var parseImageNode = (_globalThis$loaders = globalThis.loaders) === null || _globalThis$loaders === void 0 ? void 0 : _globalThis$loaders.parseImageNode;
|
|
267
|
+
var parseImageNode = globalThis.loaders?.parseImageNode;
|
|
266
268
|
var IMAGE_SUPPORTED = typeof Image !== "undefined";
|
|
267
269
|
var IMAGE_BITMAP_SUPPORTED = typeof ImageBitmap !== "undefined";
|
|
268
270
|
var NODE_IMAGE_SUPPORTED = Boolean(parseImageNode);
|
|
@@ -413,8 +415,7 @@ var __exports__ = (() => {
|
|
|
413
415
|
const imagebitmapOptions = options && options.imagebitmap;
|
|
414
416
|
return await safeCreateImageBitmap(blob, imagebitmapOptions);
|
|
415
417
|
}
|
|
416
|
-
async function safeCreateImageBitmap(blob) {
|
|
417
|
-
let imagebitmapOptions = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
|
|
418
|
+
async function safeCreateImageBitmap(blob, imagebitmapOptions = null) {
|
|
418
419
|
if (isEmptyObject(imagebitmapOptions) || !imagebitmapOptionsSupported) {
|
|
419
420
|
imagebitmapOptions = null;
|
|
420
421
|
}
|
|
@@ -450,10 +451,7 @@ var __exports__ = (() => {
|
|
|
450
451
|
switch (brandMajor) {
|
|
451
452
|
case "avif":
|
|
452
453
|
case "avis":
|
|
453
|
-
return {
|
|
454
|
-
extension: "avif",
|
|
455
|
-
mimeType: "image/avif"
|
|
456
|
-
};
|
|
454
|
+
return { extension: "avif", mimeType: "image/avif" };
|
|
457
455
|
default:
|
|
458
456
|
return null;
|
|
459
457
|
}
|
|
@@ -464,8 +462,7 @@ var __exports__ = (() => {
|
|
|
464
462
|
function stringToBytes(string) {
|
|
465
463
|
return [...string].map((character) => character.charCodeAt(0));
|
|
466
464
|
}
|
|
467
|
-
function checkString(buffer, header) {
|
|
468
|
-
let offset = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0;
|
|
465
|
+
function checkString(buffer, header, offset = 0) {
|
|
469
466
|
const headerBytes = stringToBytes(header);
|
|
470
467
|
for (let i = 0; i < headerBytes.length; ++i) {
|
|
471
468
|
if (headerBytes[i] !== buffer[i + offset]) {
|
|
@@ -490,6 +487,7 @@ var __exports__ = (() => {
|
|
|
490
487
|
}
|
|
491
488
|
return {
|
|
492
489
|
mimeType: mediaType.mimeType,
|
|
490
|
+
// TODO - decode width and height
|
|
493
491
|
width: 0,
|
|
494
492
|
height: 0
|
|
495
493
|
};
|
|
@@ -536,10 +534,7 @@ var __exports__ = (() => {
|
|
|
536
534
|
if (!isJpeg) {
|
|
537
535
|
return null;
|
|
538
536
|
}
|
|
539
|
-
const {
|
|
540
|
-
tableMarkers,
|
|
541
|
-
sofMarkers
|
|
542
|
-
} = getJpegMarkers();
|
|
537
|
+
const { tableMarkers, sofMarkers } = getJpegMarkers();
|
|
543
538
|
let i = 2;
|
|
544
539
|
while (i + 9 < dataView.byteLength) {
|
|
545
540
|
const marker = dataView.getUint16(i, BIG_ENDIAN);
|
|
@@ -547,7 +542,9 @@ var __exports__ = (() => {
|
|
|
547
542
|
return {
|
|
548
543
|
mimeType: "image/jpeg",
|
|
549
544
|
height: dataView.getUint16(i + 5, BIG_ENDIAN),
|
|
545
|
+
// Number of lines
|
|
550
546
|
width: dataView.getUint16(i + 7, BIG_ENDIAN)
|
|
547
|
+
// Number of pixels per line
|
|
551
548
|
};
|
|
552
549
|
}
|
|
553
550
|
if (!tableMarkers.has(marker)) {
|
|
@@ -563,11 +560,23 @@ var __exports__ = (() => {
|
|
|
563
560
|
for (let i = 65504; i < 65520; ++i) {
|
|
564
561
|
tableMarkers.add(i);
|
|
565
562
|
}
|
|
566
|
-
const sofMarkers = /* @__PURE__ */ new Set([
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
563
|
+
const sofMarkers = /* @__PURE__ */ new Set([
|
|
564
|
+
65472,
|
|
565
|
+
65473,
|
|
566
|
+
65474,
|
|
567
|
+
65475,
|
|
568
|
+
65477,
|
|
569
|
+
65478,
|
|
570
|
+
65479,
|
|
571
|
+
65481,
|
|
572
|
+
65482,
|
|
573
|
+
65483,
|
|
574
|
+
65485,
|
|
575
|
+
65486,
|
|
576
|
+
65487,
|
|
577
|
+
65502
|
|
578
|
+
]);
|
|
579
|
+
return { tableMarkers, sofMarkers };
|
|
571
580
|
}
|
|
572
581
|
function toDataView(data) {
|
|
573
582
|
if (data instanceof DataView) {
|
|
@@ -584,11 +593,8 @@ var __exports__ = (() => {
|
|
|
584
593
|
|
|
585
594
|
// ../../node_modules/@loaders.gl/images/dist/lib/parsers/parse-to-node-image.js
|
|
586
595
|
async function parseToNodeImage(arrayBuffer, options) {
|
|
587
|
-
|
|
588
|
-
const
|
|
589
|
-
mimeType
|
|
590
|
-
} = getBinaryImageMetadata(arrayBuffer) || {};
|
|
591
|
-
const parseImageNode2 = (_globalThis$loaders2 = globalThis.loaders) === null || _globalThis$loaders2 === void 0 ? void 0 : _globalThis$loaders2.parseImageNode;
|
|
596
|
+
const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
|
|
597
|
+
const parseImageNode2 = globalThis.loaders?.parseImageNode;
|
|
592
598
|
assert(parseImageNode2);
|
|
593
599
|
return await parseImageNode2(arrayBuffer, mimeType);
|
|
594
600
|
}
|
|
@@ -598,9 +604,7 @@ var __exports__ = (() => {
|
|
|
598
604
|
options = options || {};
|
|
599
605
|
const imageOptions = options.image || {};
|
|
600
606
|
const imageType = imageOptions.type || "auto";
|
|
601
|
-
const {
|
|
602
|
-
url
|
|
603
|
-
} = context || {};
|
|
607
|
+
const { url } = context || {};
|
|
604
608
|
const loadType = getLoadableImageType(imageType);
|
|
605
609
|
let image;
|
|
606
610
|
switch (loadType) {
|
|
@@ -634,14 +638,27 @@ var __exports__ = (() => {
|
|
|
634
638
|
|
|
635
639
|
// ../../node_modules/@loaders.gl/images/dist/image-loader.js
|
|
636
640
|
var EXTENSIONS = ["png", "jpg", "jpeg", "gif", "webp", "bmp", "ico", "svg", "avif"];
|
|
637
|
-
var MIME_TYPES = [
|
|
641
|
+
var MIME_TYPES = [
|
|
642
|
+
"image/png",
|
|
643
|
+
"image/jpeg",
|
|
644
|
+
"image/gif",
|
|
645
|
+
"image/webp",
|
|
646
|
+
"image/avif",
|
|
647
|
+
"image/bmp",
|
|
648
|
+
"image/vnd.microsoft.icon",
|
|
649
|
+
"image/svg+xml"
|
|
650
|
+
];
|
|
638
651
|
var DEFAULT_IMAGE_LOADER_OPTIONS = {
|
|
639
652
|
image: {
|
|
640
653
|
type: "auto",
|
|
641
654
|
decode: true
|
|
655
|
+
// if format is HTML
|
|
642
656
|
}
|
|
657
|
+
// imagebitmap: {} - passes (platform dependent) parameters to ImageBitmap constructor
|
|
643
658
|
};
|
|
644
659
|
var ImageLoader = {
|
|
660
|
+
dataType: null,
|
|
661
|
+
batchType: null,
|
|
645
662
|
id: "image",
|
|
646
663
|
module: "images",
|
|
647
664
|
name: "Images",
|
|
@@ -649,16 +666,14 @@ var __exports__ = (() => {
|
|
|
649
666
|
mimeTypes: MIME_TYPES,
|
|
650
667
|
extensions: EXTENSIONS,
|
|
651
668
|
parse: parseImage,
|
|
669
|
+
// TODO: byteOffset, byteLength;
|
|
652
670
|
tests: [(arrayBuffer) => Boolean(getBinaryImageMetadata(new DataView(arrayBuffer)))],
|
|
653
671
|
options: DEFAULT_IMAGE_LOADER_OPTIONS
|
|
654
672
|
};
|
|
655
673
|
|
|
656
674
|
// ../../node_modules/@loaders.gl/textures/dist/lib/texture-api/generate-url.js
|
|
657
675
|
function generateUrl(getUrl, options, urlOptions) {
|
|
658
|
-
let url = typeof getUrl === "function" ? getUrl({
|
|
659
|
-
...options,
|
|
660
|
-
...urlOptions
|
|
661
|
-
}) : getUrl;
|
|
676
|
+
let url = typeof getUrl === "function" ? getUrl({ ...options, ...urlOptions }) : getUrl;
|
|
662
677
|
const baseUrl = options.baseUrl;
|
|
663
678
|
if (baseUrl) {
|
|
664
679
|
url = baseUrl[baseUrl.length - 1] === "/" ? `${baseUrl}${url}` : `${baseUrl}/${url}`;
|
|
@@ -668,8 +683,7 @@ var __exports__ = (() => {
|
|
|
668
683
|
|
|
669
684
|
// ../../node_modules/@loaders.gl/textures/dist/lib/texture-api/async-deep-map.js
|
|
670
685
|
var isObject = (value) => value && typeof value === "object";
|
|
671
|
-
async function asyncDeepMap(tree, func) {
|
|
672
|
-
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
686
|
+
async function asyncDeepMap(tree, func, options = {}) {
|
|
673
687
|
return await mapSubtree(tree, func, options);
|
|
674
688
|
}
|
|
675
689
|
async function mapSubtree(object, func, options) {
|
|
@@ -695,8 +709,7 @@ var __exports__ = (() => {
|
|
|
695
709
|
await Promise.all(promises);
|
|
696
710
|
return values;
|
|
697
711
|
}
|
|
698
|
-
async function mapArray(urlArray, func) {
|
|
699
|
-
let options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
712
|
+
async function mapArray(urlArray, func, options = {}) {
|
|
700
713
|
const promises = urlArray.map((url) => mapSubtree(url, func, options));
|
|
701
714
|
return await Promise.all(promises);
|
|
702
715
|
}
|
|
@@ -712,40 +725,26 @@ var __exports__ = (() => {
|
|
|
712
725
|
}
|
|
713
726
|
|
|
714
727
|
// ../../node_modules/@loaders.gl/textures/dist/lib/texture-api/load-image.js
|
|
715
|
-
async function loadImageTexture(getUrl) {
|
|
716
|
-
let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
728
|
+
async function loadImageTexture(getUrl, options = {}) {
|
|
717
729
|
const imageUrls = await getImageUrls(getUrl, options);
|
|
718
730
|
return await deepLoad(imageUrls, ImageLoader.parse, options);
|
|
719
731
|
}
|
|
720
|
-
async function getImageUrls(getUrl, options) {
|
|
721
|
-
let urlOptions = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
732
|
+
async function getImageUrls(getUrl, options, urlOptions = {}) {
|
|
722
733
|
const mipLevels = options && options.image && options.image.mipLevels || 0;
|
|
723
734
|
return mipLevels !== 0 ? await getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) : generateUrl(getUrl, options, urlOptions);
|
|
724
735
|
}
|
|
725
736
|
async function getMipmappedImageUrls(getUrl, mipLevels, options, urlOptions) {
|
|
726
737
|
const urls = [];
|
|
727
738
|
if (mipLevels === "auto") {
|
|
728
|
-
const url = generateUrl(getUrl, options, {
|
|
729
|
-
...urlOptions,
|
|
730
|
-
lod: 0
|
|
731
|
-
});
|
|
739
|
+
const url = generateUrl(getUrl, options, { ...urlOptions, lod: 0 });
|
|
732
740
|
const image = await shallowLoad(url, ImageLoader.parse, options);
|
|
733
|
-
const {
|
|
734
|
-
|
|
735
|
-
height
|
|
736
|
-
} = getImageSize(image);
|
|
737
|
-
mipLevels = getMipLevels({
|
|
738
|
-
width,
|
|
739
|
-
height
|
|
740
|
-
});
|
|
741
|
+
const { width, height } = getImageSize(image);
|
|
742
|
+
mipLevels = getMipLevels({ width, height });
|
|
741
743
|
urls.push(url);
|
|
742
744
|
}
|
|
743
745
|
assert(mipLevels > 0);
|
|
744
746
|
for (let mipLevel = urls.length; mipLevel < mipLevels; ++mipLevel) {
|
|
745
|
-
const url = generateUrl(getUrl, options, {
|
|
746
|
-
...urlOptions,
|
|
747
|
-
lod: mipLevel
|
|
748
|
-
});
|
|
747
|
+
const url = generateUrl(getUrl, options, { ...urlOptions, lod: mipLevel });
|
|
749
748
|
urls.push(url);
|
|
750
749
|
}
|
|
751
750
|
return urls;
|
|
@@ -834,11 +833,17 @@ var __exports__ = (() => {
|
|
|
834
833
|
printRowMajor: true,
|
|
835
834
|
_cartographicRadians: false
|
|
836
835
|
};
|
|
837
|
-
globalThis.mathgl = globalThis.mathgl || {
|
|
836
|
+
globalThis.mathgl = globalThis.mathgl || {
|
|
837
|
+
config: {
|
|
838
|
+
...DEFAULT_CONFIG
|
|
839
|
+
}
|
|
840
|
+
};
|
|
838
841
|
var config = globalThis.mathgl.config;
|
|
839
|
-
function formatValue(value, {
|
|
842
|
+
function formatValue(value, {
|
|
843
|
+
precision = config.precision
|
|
844
|
+
} = {}) {
|
|
840
845
|
value = round(value);
|
|
841
|
-
return
|
|
846
|
+
return "".concat(parseFloat(value.toPrecision(precision)));
|
|
842
847
|
}
|
|
843
848
|
function isArray(value) {
|
|
844
849
|
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
@@ -882,12 +887,28 @@ var __exports__ = (() => {
|
|
|
882
887
|
}
|
|
883
888
|
|
|
884
889
|
// ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
890
|
+
function _extendableBuiltin(cls) {
|
|
891
|
+
function ExtendableBuiltin() {
|
|
892
|
+
var instance = Reflect.construct(cls, Array.from(arguments));
|
|
893
|
+
Object.setPrototypeOf(instance, Object.getPrototypeOf(this));
|
|
894
|
+
return instance;
|
|
895
|
+
}
|
|
896
|
+
ExtendableBuiltin.prototype = Object.create(cls.prototype, {
|
|
897
|
+
constructor: {
|
|
898
|
+
value: cls,
|
|
899
|
+
enumerable: false,
|
|
900
|
+
writable: true,
|
|
901
|
+
configurable: true
|
|
902
|
+
}
|
|
903
|
+
});
|
|
904
|
+
if (Object.setPrototypeOf) {
|
|
905
|
+
Object.setPrototypeOf(ExtendableBuiltin, cls);
|
|
906
|
+
} else {
|
|
907
|
+
ExtendableBuiltin.__proto__ = cls;
|
|
908
|
+
}
|
|
909
|
+
return ExtendableBuiltin;
|
|
910
|
+
}
|
|
911
|
+
var MathArray = class extends _extendableBuiltin(Array) {
|
|
891
912
|
clone() {
|
|
892
913
|
return new this.constructor().copy(this);
|
|
893
914
|
}
|
|
@@ -907,10 +928,7 @@ var __exports__ = (() => {
|
|
|
907
928
|
return targetObject;
|
|
908
929
|
}
|
|
909
930
|
from(arrayOrObject) {
|
|
910
|
-
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
|
|
911
|
-
// @ts-ignore
|
|
912
|
-
this.fromObject(arrayOrObject)
|
|
913
|
-
);
|
|
931
|
+
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : this.fromObject(arrayOrObject);
|
|
914
932
|
}
|
|
915
933
|
to(arrayOrObject) {
|
|
916
934
|
if (arrayOrObject === this) {
|
|
@@ -921,20 +939,18 @@ var __exports__ = (() => {
|
|
|
921
939
|
toTarget(target) {
|
|
922
940
|
return target ? this.to(target) : this;
|
|
923
941
|
}
|
|
924
|
-
/** @deprecated */
|
|
925
942
|
toFloat32Array() {
|
|
926
943
|
return new Float32Array(this);
|
|
927
944
|
}
|
|
928
945
|
toString() {
|
|
929
946
|
return this.formatString(config);
|
|
930
947
|
}
|
|
931
|
-
/** Formats string according to options */
|
|
932
948
|
formatString(opts) {
|
|
933
949
|
let string = "";
|
|
934
950
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
935
951
|
string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
|
|
936
952
|
}
|
|
937
|
-
return
|
|
953
|
+
return "".concat(opts.printTypes ? this.constructor.name : "", "[").concat(string, "]");
|
|
938
954
|
}
|
|
939
955
|
equals(array) {
|
|
940
956
|
if (!array || this.length !== array.length) {
|
|
@@ -958,8 +974,6 @@ var __exports__ = (() => {
|
|
|
958
974
|
}
|
|
959
975
|
return true;
|
|
960
976
|
}
|
|
961
|
-
// Modifiers
|
|
962
|
-
/** Negates all values in this object */
|
|
963
977
|
negate() {
|
|
964
978
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
965
979
|
this[i] = -this[i];
|
|
@@ -977,14 +991,12 @@ var __exports__ = (() => {
|
|
|
977
991
|
}
|
|
978
992
|
return this.check();
|
|
979
993
|
}
|
|
980
|
-
/** Minimal */
|
|
981
994
|
min(vector) {
|
|
982
995
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
983
996
|
this[i] = Math.min(vector[i], this[i]);
|
|
984
997
|
}
|
|
985
998
|
return this.check();
|
|
986
999
|
}
|
|
987
|
-
/** Maximal */
|
|
988
1000
|
max(vector) {
|
|
989
1001
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
990
1002
|
this[i] = Math.max(vector[i], this[i]);
|
|
@@ -1025,25 +1037,18 @@ var __exports__ = (() => {
|
|
|
1025
1037
|
}
|
|
1026
1038
|
return this.check();
|
|
1027
1039
|
}
|
|
1028
|
-
/**
|
|
1029
|
-
* Multiplies all elements by `scale`
|
|
1030
|
-
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
|
|
1031
|
-
*/
|
|
1032
1040
|
multiplyByScalar(scalar) {
|
|
1033
1041
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1034
1042
|
this[i] *= scalar;
|
|
1035
1043
|
}
|
|
1036
1044
|
return this.check();
|
|
1037
1045
|
}
|
|
1038
|
-
// Debug checks
|
|
1039
|
-
/** Throws an error if array length is incorrect or contains illegal values */
|
|
1040
1046
|
check() {
|
|
1041
1047
|
if (config.debug && !this.validate()) {
|
|
1042
|
-
throw new Error(
|
|
1048
|
+
throw new Error("math.gl: ".concat(this.constructor.name, " some fields set to invalid numbers'"));
|
|
1043
1049
|
}
|
|
1044
1050
|
return this;
|
|
1045
1051
|
}
|
|
1046
|
-
/** Returns false if the array length is incorrect or contains illegal values */
|
|
1047
1052
|
validate() {
|
|
1048
1053
|
let valid = this.length === this.ELEMENTS;
|
|
1049
1054
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -1051,48 +1056,39 @@ var __exports__ = (() => {
|
|
|
1051
1056
|
}
|
|
1052
1057
|
return valid;
|
|
1053
1058
|
}
|
|
1054
|
-
// three.js compatibility
|
|
1055
|
-
/** @deprecated */
|
|
1056
1059
|
sub(a) {
|
|
1057
1060
|
return this.subtract(a);
|
|
1058
1061
|
}
|
|
1059
|
-
/** @deprecated */
|
|
1060
1062
|
setScalar(a) {
|
|
1061
1063
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1062
1064
|
this[i] = a;
|
|
1063
1065
|
}
|
|
1064
1066
|
return this.check();
|
|
1065
1067
|
}
|
|
1066
|
-
/** @deprecated */
|
|
1067
1068
|
addScalar(a) {
|
|
1068
1069
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1069
1070
|
this[i] += a;
|
|
1070
1071
|
}
|
|
1071
1072
|
return this.check();
|
|
1072
1073
|
}
|
|
1073
|
-
/** @deprecated */
|
|
1074
1074
|
subScalar(a) {
|
|
1075
1075
|
return this.addScalar(-a);
|
|
1076
1076
|
}
|
|
1077
|
-
/** @deprecated */
|
|
1078
1077
|
multiplyScalar(scalar) {
|
|
1079
1078
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1080
1079
|
this[i] *= scalar;
|
|
1081
1080
|
}
|
|
1082
1081
|
return this.check();
|
|
1083
1082
|
}
|
|
1084
|
-
/** @deprecated */
|
|
1085
1083
|
divideScalar(a) {
|
|
1086
1084
|
return this.multiplyByScalar(1 / a);
|
|
1087
1085
|
}
|
|
1088
|
-
/** @deprecated */
|
|
1089
1086
|
clampScalar(min, max) {
|
|
1090
1087
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1091
1088
|
this[i] = Math.min(Math.max(this[i], min), max);
|
|
1092
1089
|
}
|
|
1093
1090
|
return this.check();
|
|
1094
1091
|
}
|
|
1095
|
-
/** @deprecated */
|
|
1096
1092
|
get elements() {
|
|
1097
1093
|
return this;
|
|
1098
1094
|
}
|
|
@@ -1112,13 +1108,13 @@ var __exports__ = (() => {
|
|
|
1112
1108
|
}
|
|
1113
1109
|
function checkNumber(value) {
|
|
1114
1110
|
if (!Number.isFinite(value)) {
|
|
1115
|
-
throw new Error(
|
|
1111
|
+
throw new Error("Invalid number ".concat(JSON.stringify(value)));
|
|
1116
1112
|
}
|
|
1117
1113
|
return value;
|
|
1118
1114
|
}
|
|
1119
1115
|
function checkVector(v, length4, callerName = "") {
|
|
1120
1116
|
if (config.debug && !validateVector(v, length4)) {
|
|
1121
|
-
throw new Error(
|
|
1117
|
+
throw new Error("math.gl: ".concat(callerName, " some fields set to invalid numbers'"));
|
|
1122
1118
|
}
|
|
1123
1119
|
return v;
|
|
1124
1120
|
}
|
|
@@ -1126,13 +1122,12 @@ var __exports__ = (() => {
|
|
|
1126
1122
|
// ../../node_modules/@math.gl/core/dist/lib/assert.js
|
|
1127
1123
|
function assert2(condition, message) {
|
|
1128
1124
|
if (!condition) {
|
|
1129
|
-
throw new Error(
|
|
1125
|
+
throw new Error("math.gl assertion ".concat(message));
|
|
1130
1126
|
}
|
|
1131
1127
|
}
|
|
1132
1128
|
|
|
1133
1129
|
// ../../node_modules/@math.gl/core/dist/classes/base/vector.js
|
|
1134
1130
|
var Vector = class extends MathArray {
|
|
1135
|
-
// ACCESSORS
|
|
1136
1131
|
get x() {
|
|
1137
1132
|
return this[0];
|
|
1138
1133
|
}
|
|
@@ -1145,24 +1140,12 @@ var __exports__ = (() => {
|
|
|
1145
1140
|
set y(value) {
|
|
1146
1141
|
this[1] = checkNumber(value);
|
|
1147
1142
|
}
|
|
1148
|
-
/**
|
|
1149
|
-
* Returns the length of the vector from the origin to the point described by this vector
|
|
1150
|
-
*
|
|
1151
|
-
* @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
|
|
1152
|
-
* Instead we provide `len` and `magnitude`
|
|
1153
|
-
*/
|
|
1154
1143
|
len() {
|
|
1155
1144
|
return Math.sqrt(this.lengthSquared());
|
|
1156
1145
|
}
|
|
1157
|
-
/**
|
|
1158
|
-
* Returns the length of the vector from the origin to the point described by this vector
|
|
1159
|
-
*/
|
|
1160
1146
|
magnitude() {
|
|
1161
1147
|
return this.len();
|
|
1162
1148
|
}
|
|
1163
|
-
/**
|
|
1164
|
-
* Returns the squared length of the vector from the origin to the point described by this vector
|
|
1165
|
-
*/
|
|
1166
1149
|
lengthSquared() {
|
|
1167
1150
|
let length4 = 0;
|
|
1168
1151
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
@@ -1170,9 +1153,6 @@ var __exports__ = (() => {
|
|
|
1170
1153
|
}
|
|
1171
1154
|
return length4;
|
|
1172
1155
|
}
|
|
1173
|
-
/**
|
|
1174
|
-
* Returns the squared length of the vector from the origin to the point described by this vector
|
|
1175
|
-
*/
|
|
1176
1156
|
magnitudeSquared() {
|
|
1177
1157
|
return this.lengthSquared();
|
|
1178
1158
|
}
|
|
@@ -1194,7 +1174,6 @@ var __exports__ = (() => {
|
|
|
1194
1174
|
}
|
|
1195
1175
|
return checkNumber(product);
|
|
1196
1176
|
}
|
|
1197
|
-
// MODIFIERS
|
|
1198
1177
|
normalize() {
|
|
1199
1178
|
const length4 = this.magnitude();
|
|
1200
1179
|
if (length4 !== 0) {
|
|
@@ -1220,7 +1199,6 @@ var __exports__ = (() => {
|
|
|
1220
1199
|
}
|
|
1221
1200
|
return this.check();
|
|
1222
1201
|
}
|
|
1223
|
-
// THREE.js compatibility
|
|
1224
1202
|
lengthSq() {
|
|
1225
1203
|
return this.lengthSquared();
|
|
1226
1204
|
}
|
|
@@ -1519,8 +1497,6 @@ var __exports__ = (() => {
|
|
|
1519
1497
|
object.w = this[3];
|
|
1520
1498
|
return object;
|
|
1521
1499
|
}
|
|
1522
|
-
// Getters/setters
|
|
1523
|
-
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
|
|
1524
1500
|
get ELEMENTS() {
|
|
1525
1501
|
return 4;
|
|
1526
1502
|
}
|
|
@@ -1552,7 +1528,6 @@ var __exports__ = (() => {
|
|
|
1552
1528
|
transformQuat(this, this, quaternion2);
|
|
1553
1529
|
return this.check();
|
|
1554
1530
|
}
|
|
1555
|
-
// three.js compatibility
|
|
1556
1531
|
applyMatrix4(m) {
|
|
1557
1532
|
m.transform(this, this);
|
|
1558
1533
|
return this;
|
|
@@ -1561,29 +1536,19 @@ var __exports__ = (() => {
|
|
|
1561
1536
|
|
|
1562
1537
|
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
|
|
1563
1538
|
var Matrix = class extends MathArray {
|
|
1564
|
-
// fromObject(object) {
|
|
1565
|
-
// const array = object.elements;
|
|
1566
|
-
// return this.fromRowMajor(array);
|
|
1567
|
-
// }
|
|
1568
|
-
// toObject(object) {
|
|
1569
|
-
// const array = object.elements;
|
|
1570
|
-
// this.toRowMajor(array);
|
|
1571
|
-
// return object;
|
|
1572
|
-
// }
|
|
1573
|
-
// TODO better override formatString?
|
|
1574
1539
|
toString() {
|
|
1575
1540
|
let string = "[";
|
|
1576
1541
|
if (config.printRowMajor) {
|
|
1577
1542
|
string += "row-major:";
|
|
1578
1543
|
for (let row = 0; row < this.RANK; ++row) {
|
|
1579
1544
|
for (let col = 0; col < this.RANK; ++col) {
|
|
1580
|
-
string +=
|
|
1545
|
+
string += " ".concat(this[col * this.RANK + row]);
|
|
1581
1546
|
}
|
|
1582
1547
|
}
|
|
1583
1548
|
} else {
|
|
1584
1549
|
string += "column-major:";
|
|
1585
1550
|
for (let i = 0; i < this.ELEMENTS; ++i) {
|
|
1586
|
-
string +=
|
|
1551
|
+
string += " ".concat(this[i]);
|
|
1587
1552
|
}
|
|
1588
1553
|
}
|
|
1589
1554
|
string += "]";
|
|
@@ -1592,11 +1557,9 @@ var __exports__ = (() => {
|
|
|
1592
1557
|
getElementIndex(row, col) {
|
|
1593
1558
|
return col * this.RANK + row;
|
|
1594
1559
|
}
|
|
1595
|
-
// By default assumes row major indices
|
|
1596
1560
|
getElement(row, col) {
|
|
1597
1561
|
return this[col * this.RANK + row];
|
|
1598
1562
|
}
|
|
1599
|
-
// By default assumes row major indices
|
|
1600
1563
|
setElement(row, col, value) {
|
|
1601
1564
|
this[col * this.RANK + row] = checkNumber(value);
|
|
1602
1565
|
return this;
|
|
@@ -2454,7 +2417,6 @@ var __exports__ = (() => {
|
|
|
2454
2417
|
this[15] = array[15];
|
|
2455
2418
|
return this.check();
|
|
2456
2419
|
}
|
|
2457
|
-
// eslint-disable-next-line max-params
|
|
2458
2420
|
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
|
|
2459
2421
|
this[0] = m00;
|
|
2460
2422
|
this[1] = m10;
|
|
@@ -2474,8 +2436,6 @@ var __exports__ = (() => {
|
|
|
2474
2436
|
this[15] = m33;
|
|
2475
2437
|
return this.check();
|
|
2476
2438
|
}
|
|
2477
|
-
// accepts row major order, stores as column major
|
|
2478
|
-
// eslint-disable-next-line max-params
|
|
2479
2439
|
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
2480
2440
|
this[0] = m00;
|
|
2481
2441
|
this[1] = m10;
|
|
@@ -2514,41 +2474,25 @@ var __exports__ = (() => {
|
|
|
2514
2474
|
result[15] = this[15];
|
|
2515
2475
|
return result;
|
|
2516
2476
|
}
|
|
2517
|
-
// Constructors
|
|
2518
|
-
/** Set to identity matrix */
|
|
2519
2477
|
identity() {
|
|
2520
2478
|
return this.copy(IDENTITY_MATRIX);
|
|
2521
2479
|
}
|
|
2522
|
-
/**
|
|
2523
|
-
*
|
|
2524
|
-
* @param object
|
|
2525
|
-
* @returns self
|
|
2526
|
-
*/
|
|
2527
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2528
2480
|
fromObject(object) {
|
|
2529
2481
|
return this.check();
|
|
2530
2482
|
}
|
|
2531
|
-
/**
|
|
2532
|
-
* Calculates a 4x4 matrix from the given quaternion
|
|
2533
|
-
* @param quaternion Quaternion to create matrix from
|
|
2534
|
-
* @returns self
|
|
2535
|
-
*/
|
|
2536
2483
|
fromQuaternion(quaternion2) {
|
|
2537
2484
|
fromQuat(this, quaternion2);
|
|
2538
2485
|
return this.check();
|
|
2539
2486
|
}
|
|
2540
|
-
/**
|
|
2541
|
-
* Generates a frustum matrix with the given bounds
|
|
2542
|
-
* @param view.left - Left bound of the frustum
|
|
2543
|
-
* @param view.right - Right bound of the frustum
|
|
2544
|
-
* @param view.bottom - Bottom bound of the frustum
|
|
2545
|
-
* @param view.top - Top bound of the frustum
|
|
2546
|
-
* @param view.near - Near bound of the frustum
|
|
2547
|
-
* @param view.far - Far bound of the frustum. Can be set to Infinity.
|
|
2548
|
-
* @returns self
|
|
2549
|
-
*/
|
|
2550
2487
|
frustum(view) {
|
|
2551
|
-
const {
|
|
2488
|
+
const {
|
|
2489
|
+
left,
|
|
2490
|
+
right,
|
|
2491
|
+
bottom,
|
|
2492
|
+
top,
|
|
2493
|
+
near = DEFAULT_NEAR,
|
|
2494
|
+
far = DEFAULT_FAR
|
|
2495
|
+
} = view;
|
|
2552
2496
|
if (far === Infinity) {
|
|
2553
2497
|
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
|
|
2554
2498
|
} else {
|
|
@@ -2556,47 +2500,35 @@ var __exports__ = (() => {
|
|
|
2556
2500
|
}
|
|
2557
2501
|
return this.check();
|
|
2558
2502
|
}
|
|
2559
|
-
/**
|
|
2560
|
-
* Generates a look-at matrix with the given eye position, focal point,
|
|
2561
|
-
* and up axis
|
|
2562
|
-
* @param view.eye - (vector) Position of the viewer
|
|
2563
|
-
* @param view.center - (vector) Point the viewer is looking at
|
|
2564
|
-
* @param view.up - (vector) Up axis
|
|
2565
|
-
* @returns self
|
|
2566
|
-
*/
|
|
2567
2503
|
lookAt(view) {
|
|
2568
|
-
const {
|
|
2504
|
+
const {
|
|
2505
|
+
eye,
|
|
2506
|
+
center = [0, 0, 0],
|
|
2507
|
+
up = [0, 1, 0]
|
|
2508
|
+
} = view;
|
|
2569
2509
|
lookAt(this, eye, center, up);
|
|
2570
2510
|
return this.check();
|
|
2571
2511
|
}
|
|
2572
|
-
/**
|
|
2573
|
-
* Generates a orthogonal projection matrix with the given bounds
|
|
2574
|
-
* from "traditional" view space parameters
|
|
2575
|
-
* @param view.left - Left bound of the frustum
|
|
2576
|
-
* @param view.right number Right bound of the frustum
|
|
2577
|
-
* @param view.bottom - Bottom bound of the frustum
|
|
2578
|
-
* @param view.top number Top bound of the frustum
|
|
2579
|
-
* @param view.near - Near bound of the frustum
|
|
2580
|
-
* @param view.far number Far bound of the frustum
|
|
2581
|
-
* @returns self
|
|
2582
|
-
*/
|
|
2583
2512
|
ortho(view) {
|
|
2584
|
-
const {
|
|
2513
|
+
const {
|
|
2514
|
+
left,
|
|
2515
|
+
right,
|
|
2516
|
+
bottom,
|
|
2517
|
+
top,
|
|
2518
|
+
near = DEFAULT_NEAR,
|
|
2519
|
+
far = DEFAULT_FAR
|
|
2520
|
+
} = view;
|
|
2585
2521
|
ortho(this, left, right, bottom, top, near, far);
|
|
2586
2522
|
return this.check();
|
|
2587
2523
|
}
|
|
2588
|
-
/**
|
|
2589
|
-
* Generates an orthogonal projection matrix with the same parameters
|
|
2590
|
-
* as a perspective matrix (plus focalDistance)
|
|
2591
|
-
* @param view.fovy Vertical field of view in radians
|
|
2592
|
-
* @param view.aspect Aspect ratio. Typically viewport width / viewport height
|
|
2593
|
-
* @param view.focalDistance Distance in the view frustum used for extent calculations
|
|
2594
|
-
* @param view.near Near bound of the frustum
|
|
2595
|
-
* @param view.far Far bound of the frustum
|
|
2596
|
-
* @returns self
|
|
2597
|
-
*/
|
|
2598
2524
|
orthographic(view) {
|
|
2599
|
-
const {
|
|
2525
|
+
const {
|
|
2526
|
+
fovy = DEFAULT_FOVY,
|
|
2527
|
+
aspect = DEFAULT_ASPECT,
|
|
2528
|
+
focalDistance = 1,
|
|
2529
|
+
near = DEFAULT_NEAR,
|
|
2530
|
+
far = DEFAULT_FAR
|
|
2531
|
+
} = view;
|
|
2600
2532
|
checkRadians(fovy);
|
|
2601
2533
|
const halfY = fovy / 2;
|
|
2602
2534
|
const top = focalDistance * Math.tan(halfY);
|
|
@@ -2610,53 +2542,32 @@ var __exports__ = (() => {
|
|
|
2610
2542
|
far
|
|
2611
2543
|
});
|
|
2612
2544
|
}
|
|
2613
|
-
/**
|
|
2614
|
-
* Generates a perspective projection matrix with the given bounds
|
|
2615
|
-
* @param view.fovy Vertical field of view in radians
|
|
2616
|
-
* @param view.aspect Aspect ratio. typically viewport width/height
|
|
2617
|
-
* @param view.near Near bound of the frustum
|
|
2618
|
-
* @param view.far Far bound of the frustum
|
|
2619
|
-
* @returns self
|
|
2620
|
-
*/
|
|
2621
2545
|
perspective(view) {
|
|
2622
|
-
const {
|
|
2546
|
+
const {
|
|
2547
|
+
fovy = 45 * Math.PI / 180,
|
|
2548
|
+
aspect = 1,
|
|
2549
|
+
near = 0.1,
|
|
2550
|
+
far = 500
|
|
2551
|
+
} = view;
|
|
2623
2552
|
checkRadians(fovy);
|
|
2624
2553
|
perspective(this, fovy, aspect, near, far);
|
|
2625
2554
|
return this.check();
|
|
2626
2555
|
}
|
|
2627
|
-
// Accessors
|
|
2628
2556
|
determinant() {
|
|
2629
2557
|
return determinant(this);
|
|
2630
2558
|
}
|
|
2631
|
-
/**
|
|
2632
|
-
* Extracts the non-uniform scale assuming the matrix is an affine transformation.
|
|
2633
|
-
* The scales are the "lengths" of the column vectors in the upper-left 3x3 matrix.
|
|
2634
|
-
* @param result
|
|
2635
|
-
* @returns self
|
|
2636
|
-
*/
|
|
2637
2559
|
getScale(result = [-0, -0, -0]) {
|
|
2638
2560
|
result[0] = Math.sqrt(this[0] * this[0] + this[1] * this[1] + this[2] * this[2]);
|
|
2639
2561
|
result[1] = Math.sqrt(this[4] * this[4] + this[5] * this[5] + this[6] * this[6]);
|
|
2640
2562
|
result[2] = Math.sqrt(this[8] * this[8] + this[9] * this[9] + this[10] * this[10]);
|
|
2641
2563
|
return result;
|
|
2642
2564
|
}
|
|
2643
|
-
/**
|
|
2644
|
-
* Gets the translation portion, assuming the matrix is a affine transformation matrix.
|
|
2645
|
-
* @param result
|
|
2646
|
-
* @returns self
|
|
2647
|
-
*/
|
|
2648
2565
|
getTranslation(result = [-0, -0, -0]) {
|
|
2649
2566
|
result[0] = this[12];
|
|
2650
2567
|
result[1] = this[13];
|
|
2651
2568
|
result[2] = this[14];
|
|
2652
2569
|
return result;
|
|
2653
2570
|
}
|
|
2654
|
-
/**
|
|
2655
|
-
* Gets upper left 3x3 pure rotation matrix (non-scaling), assume affine transformation matrix
|
|
2656
|
-
* @param result
|
|
2657
|
-
* @param scaleResult
|
|
2658
|
-
* @returns self
|
|
2659
|
-
*/
|
|
2660
2571
|
getRotation(result, scaleResult) {
|
|
2661
2572
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
2662
2573
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -2682,12 +2593,6 @@ var __exports__ = (() => {
|
|
|
2682
2593
|
result[15] = 1;
|
|
2683
2594
|
return result;
|
|
2684
2595
|
}
|
|
2685
|
-
/**
|
|
2686
|
-
*
|
|
2687
|
-
* @param result
|
|
2688
|
-
* @param scaleResult
|
|
2689
|
-
* @returns self
|
|
2690
|
-
*/
|
|
2691
2596
|
getRotationMatrix3(result, scaleResult) {
|
|
2692
2597
|
result = result || [-0, -0, -0, -0, -0, -0, -0, -0, -0];
|
|
2693
2598
|
scaleResult = scaleResult || [-0, -0, -0];
|
|
@@ -2706,7 +2611,6 @@ var __exports__ = (() => {
|
|
|
2706
2611
|
result[8] = this[10] * inverseScale2;
|
|
2707
2612
|
return result;
|
|
2708
2613
|
}
|
|
2709
|
-
// Modifiers
|
|
2710
2614
|
transpose() {
|
|
2711
2615
|
transpose(this, this);
|
|
2712
2616
|
return this.check();
|
|
@@ -2715,7 +2619,6 @@ var __exports__ = (() => {
|
|
|
2715
2619
|
invert(this, this);
|
|
2716
2620
|
return this.check();
|
|
2717
2621
|
}
|
|
2718
|
-
// Operations
|
|
2719
2622
|
multiplyLeft(a) {
|
|
2720
2623
|
multiply(this, a, this);
|
|
2721
2624
|
return this.check();
|
|
@@ -2724,68 +2627,33 @@ var __exports__ = (() => {
|
|
|
2724
2627
|
multiply(this, this, a);
|
|
2725
2628
|
return this.check();
|
|
2726
2629
|
}
|
|
2727
|
-
// Rotates a matrix by the given angle around the X axis
|
|
2728
2630
|
rotateX(radians) {
|
|
2729
2631
|
rotateX(this, this, radians);
|
|
2730
2632
|
return this.check();
|
|
2731
2633
|
}
|
|
2732
|
-
// Rotates a matrix by the given angle around the Y axis.
|
|
2733
2634
|
rotateY(radians) {
|
|
2734
2635
|
rotateY(this, this, radians);
|
|
2735
2636
|
return this.check();
|
|
2736
2637
|
}
|
|
2737
|
-
/**
|
|
2738
|
-
* Rotates a matrix by the given angle around the Z axis.
|
|
2739
|
-
* @param radians
|
|
2740
|
-
* @returns self
|
|
2741
|
-
*/
|
|
2742
2638
|
rotateZ(radians) {
|
|
2743
2639
|
rotateZ(this, this, radians);
|
|
2744
2640
|
return this.check();
|
|
2745
2641
|
}
|
|
2746
|
-
/**
|
|
2747
|
-
*
|
|
2748
|
-
* @param param0
|
|
2749
|
-
* @returns self
|
|
2750
|
-
*/
|
|
2751
2642
|
rotateXYZ(angleXYZ) {
|
|
2752
2643
|
return this.rotateX(angleXYZ[0]).rotateY(angleXYZ[1]).rotateZ(angleXYZ[2]);
|
|
2753
2644
|
}
|
|
2754
|
-
/**
|
|
2755
|
-
*
|
|
2756
|
-
* @param radians
|
|
2757
|
-
* @param axis
|
|
2758
|
-
* @returns self
|
|
2759
|
-
*/
|
|
2760
2645
|
rotateAxis(radians, axis) {
|
|
2761
2646
|
rotate(this, this, radians, axis);
|
|
2762
2647
|
return this.check();
|
|
2763
2648
|
}
|
|
2764
|
-
/**
|
|
2765
|
-
*
|
|
2766
|
-
* @param factor
|
|
2767
|
-
* @returns self
|
|
2768
|
-
*/
|
|
2769
2649
|
scale(factor) {
|
|
2770
2650
|
scale(this, this, Array.isArray(factor) ? factor : [factor, factor, factor]);
|
|
2771
2651
|
return this.check();
|
|
2772
2652
|
}
|
|
2773
|
-
/**
|
|
2774
|
-
*
|
|
2775
|
-
* @param vec
|
|
2776
|
-
* @returns self
|
|
2777
|
-
*/
|
|
2778
2653
|
translate(vector) {
|
|
2779
2654
|
translate(this, this, vector);
|
|
2780
2655
|
return this.check();
|
|
2781
2656
|
}
|
|
2782
|
-
// Transforms
|
|
2783
|
-
/**
|
|
2784
|
-
* Transforms any 2, 3 or 4 element vector. 2 and 3 elements are treated as points
|
|
2785
|
-
* @param vector
|
|
2786
|
-
* @param result
|
|
2787
|
-
* @returns self
|
|
2788
|
-
*/
|
|
2789
2657
|
transform(vector, result) {
|
|
2790
2658
|
if (vector.length === 4) {
|
|
2791
2659
|
result = transformMat43(result || [-0, -0, -0, -0], vector, this);
|
|
@@ -2794,14 +2662,10 @@ var __exports__ = (() => {
|
|
|
2794
2662
|
}
|
|
2795
2663
|
return this.transformAsPoint(vector, result);
|
|
2796
2664
|
}
|
|
2797
|
-
/**
|
|
2798
|
-
* Transforms any 2 or 3 element array as point (w implicitly 1)
|
|
2799
|
-
* @param vector
|
|
2800
|
-
* @param result
|
|
2801
|
-
* @returns self
|
|
2802
|
-
*/
|
|
2803
2665
|
transformAsPoint(vector, result) {
|
|
2804
|
-
const {
|
|
2666
|
+
const {
|
|
2667
|
+
length: length4
|
|
2668
|
+
} = vector;
|
|
2805
2669
|
let out;
|
|
2806
2670
|
switch (length4) {
|
|
2807
2671
|
case 2:
|
|
@@ -2816,12 +2680,6 @@ var __exports__ = (() => {
|
|
|
2816
2680
|
checkVector(out, vector.length);
|
|
2817
2681
|
return out;
|
|
2818
2682
|
}
|
|
2819
|
-
/**
|
|
2820
|
-
* Transforms any 2 or 3 element array as vector (w implicitly 0)
|
|
2821
|
-
* @param vector
|
|
2822
|
-
* @param result
|
|
2823
|
-
* @returns self
|
|
2824
|
-
*/
|
|
2825
2683
|
transformAsVector(vector, result) {
|
|
2826
2684
|
let out;
|
|
2827
2685
|
switch (vector.length) {
|
|
@@ -2837,19 +2695,15 @@ var __exports__ = (() => {
|
|
|
2837
2695
|
checkVector(out, vector.length);
|
|
2838
2696
|
return out;
|
|
2839
2697
|
}
|
|
2840
|
-
/** @deprecated */
|
|
2841
2698
|
transformPoint(vector, result) {
|
|
2842
2699
|
return this.transformAsPoint(vector, result);
|
|
2843
2700
|
}
|
|
2844
|
-
/** @deprecated */
|
|
2845
2701
|
transformVector(vector, result) {
|
|
2846
2702
|
return this.transformAsPoint(vector, result);
|
|
2847
2703
|
}
|
|
2848
|
-
/** @deprecated */
|
|
2849
2704
|
transformDirection(vector, result) {
|
|
2850
2705
|
return this.transformAsVector(vector, result);
|
|
2851
2706
|
}
|
|
2852
|
-
// three.js math API compatibility
|
|
2853
2707
|
makeRotationX(radians) {
|
|
2854
2708
|
return this.identity().rotateX(radians);
|
|
2855
2709
|
}
|
|
@@ -3176,13 +3030,6 @@ var __exports__ = (() => {
|
|
|
3176
3030
|
this[3] = object.w;
|
|
3177
3031
|
return this.check();
|
|
3178
3032
|
}
|
|
3179
|
-
/**
|
|
3180
|
-
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
3181
|
-
* NOTE: The resultant quaternion is not normalized, so you should
|
|
3182
|
-
* be sure to renormalize the quaternion yourself where necessary.
|
|
3183
|
-
* @param m
|
|
3184
|
-
* @returns
|
|
3185
|
-
*/
|
|
3186
3033
|
fromMatrix3(m) {
|
|
3187
3034
|
fromMat3(this, m);
|
|
3188
3035
|
return this.check();
|
|
@@ -3191,21 +3038,13 @@ var __exports__ = (() => {
|
|
|
3191
3038
|
setAxisAngle(this, axis, rad);
|
|
3192
3039
|
return this.check();
|
|
3193
3040
|
}
|
|
3194
|
-
/** Set a quat to the identity quaternion */
|
|
3195
3041
|
identity() {
|
|
3196
3042
|
identity2(this);
|
|
3197
3043
|
return this.check();
|
|
3198
3044
|
}
|
|
3199
|
-
// Set the components of a quat to the given values
|
|
3200
|
-
// set(i, j, k, l) {
|
|
3201
|
-
// quat_set(this, i, j, k, l);
|
|
3202
|
-
// return this.check();
|
|
3203
|
-
// }
|
|
3204
|
-
// Sets a quat from the given angle and rotation axis, then returns it.
|
|
3205
3045
|
setAxisAngle(axis, rad) {
|
|
3206
3046
|
return this.fromAxisRotation(axis, rad);
|
|
3207
3047
|
}
|
|
3208
|
-
// Getters/setters
|
|
3209
3048
|
get ELEMENTS() {
|
|
3210
3049
|
return 4;
|
|
3211
3050
|
}
|
|
@@ -3233,72 +3072,35 @@ var __exports__ = (() => {
|
|
|
3233
3072
|
set w(value) {
|
|
3234
3073
|
this[3] = checkNumber(value);
|
|
3235
3074
|
}
|
|
3236
|
-
// Calculates the length of a quat
|
|
3237
3075
|
len() {
|
|
3238
3076
|
return length3(this);
|
|
3239
3077
|
}
|
|
3240
|
-
// Calculates the squared length of a quat
|
|
3241
3078
|
lengthSquared() {
|
|
3242
3079
|
return squaredLength2(this);
|
|
3243
3080
|
}
|
|
3244
|
-
// Calculates the dot product of two quat's
|
|
3245
|
-
// @return {Number}
|
|
3246
3081
|
dot(a) {
|
|
3247
3082
|
return dot3(this, a);
|
|
3248
3083
|
}
|
|
3249
|
-
// Gets the rotation axis and angle for a given quaternion.
|
|
3250
|
-
// If a quaternion is created with setAxisAngle, this method will
|
|
3251
|
-
// return the same values as providied in the original parameter
|
|
3252
|
-
// list OR functionally equivalent values.
|
|
3253
|
-
// Example: The quaternion formed by axis [0, 0, 1] and angle -90
|
|
3254
|
-
// is the same as the quaternion formed by [0, 0, 1] and 270.
|
|
3255
|
-
// This method favors the latter.
|
|
3256
|
-
// @return {{[x,y,z], Number}}
|
|
3257
|
-
// getAxisAngle() {
|
|
3258
|
-
// const axis = [];
|
|
3259
|
-
// // const angle = quat_getAxisAngle(axis, this);
|
|
3260
|
-
// return {axis, angle};
|
|
3261
|
-
// }
|
|
3262
|
-
// MODIFIERS
|
|
3263
|
-
// Sets a quaternion to represent the shortest rotation from one vector
|
|
3264
|
-
// to another. Both vectors are assumed to be unit length.
|
|
3265
3084
|
rotationTo(vectorA, vectorB) {
|
|
3266
3085
|
rotationTo(this, vectorA, vectorB);
|
|
3267
3086
|
return this.check();
|
|
3268
3087
|
}
|
|
3269
|
-
// Sets the specified quaternion with values corresponding to the given axes.
|
|
3270
|
-
// Each axis is a vec3 and is expected to be unit length and perpendicular
|
|
3271
|
-
// to all other specified axes.
|
|
3272
|
-
// setAxes() {
|
|
3273
|
-
// Number
|
|
3274
|
-
// }
|
|
3275
|
-
// Performs a spherical linear interpolation with two control points
|
|
3276
|
-
// sqlerp() {
|
|
3277
|
-
// Number;
|
|
3278
|
-
// }
|
|
3279
|
-
// Adds two quat's
|
|
3280
3088
|
add(a) {
|
|
3281
3089
|
add2(this, this, a);
|
|
3282
3090
|
return this.check();
|
|
3283
3091
|
}
|
|
3284
|
-
// Calculates the W component of a quat from the X, Y, and Z components.
|
|
3285
|
-
// Any existing W component will be ignored.
|
|
3286
3092
|
calculateW() {
|
|
3287
3093
|
calculateW(this, this);
|
|
3288
3094
|
return this.check();
|
|
3289
3095
|
}
|
|
3290
|
-
// Calculates the conjugate of a quat If the quaternion is normalized,
|
|
3291
|
-
// this function is faster than quat_invert and produces the same result.
|
|
3292
3096
|
conjugate() {
|
|
3293
3097
|
conjugate(this, this);
|
|
3294
3098
|
return this.check();
|
|
3295
3099
|
}
|
|
3296
|
-
// Calculates the inverse of a quat
|
|
3297
3100
|
invert() {
|
|
3298
3101
|
invert2(this, this);
|
|
3299
3102
|
return this.check();
|
|
3300
3103
|
}
|
|
3301
|
-
// Performs a linear interpolation between two quat's
|
|
3302
3104
|
lerp(a, b, t) {
|
|
3303
3105
|
if (t === void 0) {
|
|
3304
3106
|
return this.lerp(this, a, b);
|
|
@@ -3306,7 +3108,6 @@ var __exports__ = (() => {
|
|
|
3306
3108
|
lerp2(this, a, b, t);
|
|
3307
3109
|
return this.check();
|
|
3308
3110
|
}
|
|
3309
|
-
// Multiplies two quat's
|
|
3310
3111
|
multiplyRight(a) {
|
|
3311
3112
|
multiply2(this, this, a);
|
|
3312
3113
|
return this.check();
|
|
@@ -3315,7 +3116,6 @@ var __exports__ = (() => {
|
|
|
3315
3116
|
multiply2(this, a, this);
|
|
3316
3117
|
return this.check();
|
|
3317
3118
|
}
|
|
3318
|
-
// Normalize a quat
|
|
3319
3119
|
normalize() {
|
|
3320
3120
|
const length4 = this.len();
|
|
3321
3121
|
const l = length4 > 0 ? 1 / length4 : 0;
|
|
@@ -3328,27 +3128,22 @@ var __exports__ = (() => {
|
|
|
3328
3128
|
}
|
|
3329
3129
|
return this.check();
|
|
3330
3130
|
}
|
|
3331
|
-
// Rotates a quaternion by the given angle about the X axis
|
|
3332
3131
|
rotateX(rad) {
|
|
3333
3132
|
rotateX2(this, this, rad);
|
|
3334
3133
|
return this.check();
|
|
3335
3134
|
}
|
|
3336
|
-
// Rotates a quaternion by the given angle about the Y axis
|
|
3337
3135
|
rotateY(rad) {
|
|
3338
3136
|
rotateY2(this, this, rad);
|
|
3339
3137
|
return this.check();
|
|
3340
3138
|
}
|
|
3341
|
-
// Rotates a quaternion by the given angle about the Z axis
|
|
3342
3139
|
rotateZ(rad) {
|
|
3343
3140
|
rotateZ2(this, this, rad);
|
|
3344
3141
|
return this.check();
|
|
3345
3142
|
}
|
|
3346
|
-
// Scales a quat by a scalar number
|
|
3347
3143
|
scale(b) {
|
|
3348
3144
|
scale3(this, this, b);
|
|
3349
3145
|
return this.check();
|
|
3350
3146
|
}
|
|
3351
|
-
// Performs a spherical linear interpolation between two quat
|
|
3352
3147
|
slerp(arg0, arg1, arg2) {
|
|
3353
3148
|
let start;
|
|
3354
3149
|
let target;
|
|
@@ -3378,7 +3173,6 @@ var __exports__ = (() => {
|
|
|
3378
3173
|
transformQuat2(result, vector, this);
|
|
3379
3174
|
return checkVector(result, 4);
|
|
3380
3175
|
}
|
|
3381
|
-
// THREE.js Math API compatibility
|
|
3382
3176
|
lengthSq() {
|
|
3383
3177
|
return this.lengthSquared();
|
|
3384
3178
|
}
|