@loaders.gl/i3s 4.3.2 → 4.4.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -4305,1082 +4305,631 @@ var __exports__ = (() => {
4305
4305
  ...GL_TYPE
4306
4306
  };
4307
4307
 
4308
- // ../loader-utils/src/loader-types.ts
4309
- async function parseFromContext(data, loaders, options, context) {
4310
- return context._parse(data, loaders, options, context);
4308
+ // ../../node_modules/@math.gl/core/dist/lib/common.js
4309
+ var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
4310
+ var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
4311
+ var DEFAULT_CONFIG = {
4312
+ EPSILON: 1e-12,
4313
+ debug: false,
4314
+ precision: 4,
4315
+ printTypes: false,
4316
+ printDegrees: false,
4317
+ printRowMajor: true,
4318
+ _cartographicRadians: false
4319
+ };
4320
+ globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
4321
+ var config = globalThis.mathgl.config;
4322
+ function formatValue(value, { precision = config.precision } = {}) {
4323
+ value = round(value);
4324
+ return `${parseFloat(value.toPrecision(precision))}`;
4311
4325
  }
4312
-
4313
- // ../loader-utils/src/lib/env-utils/assert.ts
4314
- function assert(condition, message) {
4315
- if (!condition) {
4316
- throw new Error(message || "loader assertion failed.");
4317
- }
4326
+ function isArray(value) {
4327
+ return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
4318
4328
  }
4319
-
4320
- // ../loader-utils/src/lib/env-utils/globals.ts
4321
- var globals = {
4322
- self: typeof self !== "undefined" && self,
4323
- window: typeof window !== "undefined" && window,
4324
- global: typeof global !== "undefined" && global,
4325
- document: typeof document !== "undefined" && document
4326
- };
4327
- var self_ = globals.self || globals.window || globals.global || {};
4328
- var window_ = globals.window || globals.self || globals.global || {};
4329
- var global_ = globals.global || globals.self || globals.window || {};
4330
- var document_ = globals.document || {};
4331
- var isBrowser = (
4332
- // @ts-ignore process does not exist on browser
4333
- Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
4334
- );
4335
- var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
4336
- var nodeVersion = matches && parseFloat(matches[1]) || 0;
4337
-
4338
- // ../loader-utils/src/lib/module-utils/js-module-utils.ts
4339
- function registerJSModules(modules) {
4340
- globalThis.loaders ||= {};
4341
- globalThis.loaders.modules ||= {};
4342
- Object.assign(globalThis.loaders.modules, modules);
4329
+ function toRadians(degrees2) {
4330
+ return radians(degrees2);
4343
4331
  }
4344
- function getJSModuleOrNull(name) {
4345
- const module = globalThis.loaders?.modules?.[name];
4346
- return module || null;
4332
+ function toDegrees(radians2) {
4333
+ return degrees(radians2);
4347
4334
  }
4348
-
4349
- // ../worker-utils/src/lib/env-utils/version.ts
4350
- var NPM_TAG = "latest";
4351
- function getVersion() {
4352
- if (!globalThis._loadersgl_?.version) {
4353
- globalThis._loadersgl_ = globalThis._loadersgl_ || {};
4354
- if (typeof __VERSION__ === "undefined") {
4355
- console.warn(
4356
- "loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
4357
- );
4358
- globalThis._loadersgl_.version = NPM_TAG;
4359
- } else {
4360
- globalThis._loadersgl_.version = __VERSION__;
4335
+ function radians(degrees2, result) {
4336
+ return map(degrees2, (degrees3) => degrees3 * DEGREES_TO_RADIANS, result);
4337
+ }
4338
+ function degrees(radians2, result) {
4339
+ return map(radians2, (radians3) => radians3 * RADIANS_TO_DEGREES, result);
4340
+ }
4341
+ function equals(a, b, epsilon) {
4342
+ const oldEpsilon = config.EPSILON;
4343
+ if (epsilon) {
4344
+ config.EPSILON = epsilon;
4345
+ }
4346
+ try {
4347
+ if (a === b) {
4348
+ return true;
4349
+ }
4350
+ if (isArray(a) && isArray(b)) {
4351
+ if (a.length !== b.length) {
4352
+ return false;
4353
+ }
4354
+ for (let i = 0; i < a.length; ++i) {
4355
+ if (!equals(a[i], b[i])) {
4356
+ return false;
4357
+ }
4358
+ }
4359
+ return true;
4361
4360
  }
4361
+ if (a && a.equals) {
4362
+ return a.equals(b);
4363
+ }
4364
+ if (b && b.equals) {
4365
+ return b.equals(a);
4366
+ }
4367
+ if (typeof a === "number" && typeof b === "number") {
4368
+ return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
4369
+ }
4370
+ return false;
4371
+ } finally {
4372
+ config.EPSILON = oldEpsilon;
4362
4373
  }
4363
- return globalThis._loadersgl_.version;
4364
4374
  }
4365
- var VERSION = getVersion();
4366
-
4367
- // ../worker-utils/src/lib/env-utils/assert.ts
4368
- function assert2(condition, message) {
4369
- if (!condition) {
4370
- throw new Error(message || "loaders.gl assertion failed.");
4371
- }
4375
+ function round(value) {
4376
+ return Math.round(value / config.EPSILON) * config.EPSILON;
4372
4377
  }
4373
-
4374
- // ../worker-utils/src/lib/env-utils/globals.ts
4375
- var globals2 = {
4376
- self: typeof self !== "undefined" && self,
4377
- window: typeof window !== "undefined" && window,
4378
- global: typeof global !== "undefined" && global,
4379
- document: typeof document !== "undefined" && document
4380
- };
4381
- var self_2 = globals2.self || globals2.window || globals2.global || {};
4382
- var window_2 = globals2.window || globals2.self || globals2.global || {};
4383
- var global_2 = globals2.global || globals2.self || globals2.window || {};
4384
- var document_2 = globals2.document || {};
4385
- var isBrowser2 = (
4386
- // @ts-ignore process.browser
4387
- typeof process !== "object" || String(process) !== "[object process]" || process.browser
4388
- );
4389
- var isWorker = typeof importScripts === "function";
4390
- var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
4391
- var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
4392
- var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
4393
-
4394
- // ../worker-utils/src/lib/library-utils/library-utils.ts
4395
- var loadLibraryPromises = {};
4396
- async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
4397
- if (moduleName) {
4398
- libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
4399
- }
4400
- loadLibraryPromises[libraryUrl] = // eslint-disable-next-line @typescript-eslint/no-misused-promises
4401
- loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
4402
- return await loadLibraryPromises[libraryUrl];
4378
+ function duplicateArray(array) {
4379
+ return array.clone ? array.clone() : new Array(array.length);
4403
4380
  }
4404
- function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
4405
- if (!options.useLocalLibraries && library.startsWith("http")) {
4406
- return library;
4381
+ function map(value, func, result) {
4382
+ if (isArray(value)) {
4383
+ const array = value;
4384
+ result = result || duplicateArray(array);
4385
+ for (let i = 0; i < result.length && i < array.length; ++i) {
4386
+ const val = typeof value === "number" ? value : value[i];
4387
+ result[i] = func(val, i, result);
4388
+ }
4389
+ return result;
4407
4390
  }
4408
- libraryName = libraryName || library;
4409
- const modules = options.modules || {};
4410
- if (modules[libraryName]) {
4411
- return modules[libraryName];
4391
+ return func(value);
4392
+ }
4393
+
4394
+ // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
4395
+ var MathArray = class extends Array {
4396
+ // Common methods
4397
+ /**
4398
+ * Clone the current object
4399
+ * @returns a new copy of this object
4400
+ */
4401
+ clone() {
4402
+ return new this.constructor().copy(this);
4412
4403
  }
4413
- if (!isBrowser2) {
4414
- return `modules/${moduleName}/dist/libs/${libraryName}`;
4404
+ fromArray(array, offset = 0) {
4405
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4406
+ this[i] = array[i + offset];
4407
+ }
4408
+ return this.check();
4415
4409
  }
4416
- if (options.CDN) {
4417
- assert2(options.CDN.startsWith("http"));
4418
- return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
4410
+ toArray(targetArray = [], offset = 0) {
4411
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4412
+ targetArray[offset + i] = this[i];
4413
+ }
4414
+ return targetArray;
4419
4415
  }
4420
- if (isWorker) {
4421
- return `../src/libs/${libraryName}`;
4416
+ toObject(targetObject) {
4417
+ return targetObject;
4422
4418
  }
4423
- return `modules/${moduleName}/src/libs/${libraryName}`;
4424
- }
4425
- async function loadLibraryFromFile(libraryUrl) {
4426
- if (libraryUrl.endsWith("wasm")) {
4427
- return await loadAsArrayBuffer(libraryUrl);
4419
+ from(arrayOrObject) {
4420
+ return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
4421
+ // @ts-ignore
4422
+ this.fromObject(arrayOrObject)
4423
+ );
4428
4424
  }
4429
- if (!isBrowser2) {
4430
- try {
4431
- const { requireFromFile } = globalThis.loaders || {};
4432
- return await requireFromFile?.(libraryUrl);
4433
- } catch (error) {
4434
- console.error(error);
4435
- return null;
4425
+ to(arrayOrObject) {
4426
+ if (arrayOrObject === this) {
4427
+ return this;
4436
4428
  }
4429
+ return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
4437
4430
  }
4438
- if (isWorker) {
4439
- return importScripts(libraryUrl);
4431
+ toTarget(target) {
4432
+ return target ? this.to(target) : this;
4440
4433
  }
4441
- const scriptSource = await loadAsText(libraryUrl);
4442
- return loadLibraryFromString(scriptSource, libraryUrl);
4443
- }
4444
- function loadLibraryFromString(scriptSource, id) {
4445
- if (!isBrowser2) {
4446
- const { requireFromString } = globalThis.loaders || {};
4447
- return requireFromString?.(scriptSource, id);
4434
+ /** @deprecated */
4435
+ toFloat32Array() {
4436
+ return new Float32Array(this);
4448
4437
  }
4449
- if (isWorker) {
4450
- eval.call(globalThis, scriptSource);
4451
- return null;
4438
+ toString() {
4439
+ return this.formatString(config);
4452
4440
  }
4453
- const script = document.createElement("script");
4454
- script.id = id;
4455
- try {
4456
- script.appendChild(document.createTextNode(scriptSource));
4457
- } catch (e) {
4458
- script.text = scriptSource;
4441
+ /** Formats string according to options */
4442
+ formatString(opts) {
4443
+ let string = "";
4444
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4445
+ string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
4446
+ }
4447
+ return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
4459
4448
  }
4460
- document.body.appendChild(script);
4461
- return null;
4462
- }
4463
- async function loadAsArrayBuffer(url) {
4464
- const { readFileAsArrayBuffer } = globalThis.loaders || {};
4465
- if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
4466
- const response = await fetch(url);
4467
- return await response.arrayBuffer();
4449
+ equals(array) {
4450
+ if (!array || this.length !== array.length) {
4451
+ return false;
4452
+ }
4453
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4454
+ if (!equals(this[i], array[i])) {
4455
+ return false;
4456
+ }
4457
+ }
4458
+ return true;
4468
4459
  }
4469
- return await readFileAsArrayBuffer(url);
4470
- }
4471
- async function loadAsText(url) {
4472
- const { readFileAsText } = globalThis.loaders || {};
4473
- if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
4474
- const response = await fetch(url);
4475
- return await response.text();
4460
+ exactEquals(array) {
4461
+ if (!array || this.length !== array.length) {
4462
+ return false;
4463
+ }
4464
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4465
+ if (this[i] !== array[i]) {
4466
+ return false;
4467
+ }
4468
+ }
4469
+ return true;
4476
4470
  }
4477
- return await readFileAsText(url);
4478
- }
4479
-
4480
- // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
4481
- function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
4482
- byteLength = byteLength || arrayBuffer1.byteLength;
4483
- if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
4484
- return false;
4471
+ // Modifiers
4472
+ /** Negates all values in this object */
4473
+ negate() {
4474
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4475
+ this[i] = -this[i];
4476
+ }
4477
+ return this.check();
4485
4478
  }
4486
- const array1 = new Uint8Array(arrayBuffer1);
4487
- const array2 = new Uint8Array(arrayBuffer2);
4488
- for (let i = 0; i < array1.length; ++i) {
4489
- if (array1[i] !== array2[i]) {
4490
- return false;
4479
+ lerp(a, b, t) {
4480
+ if (t === void 0) {
4481
+ return this.lerp(this, a, b);
4482
+ }
4483
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4484
+ const ai = a[i];
4485
+ const endValue = typeof b === "number" ? b : b[i];
4486
+ this[i] = ai + t * (endValue - ai);
4491
4487
  }
4488
+ return this.check();
4492
4489
  }
4493
- return true;
4494
- }
4495
- function concatenateArrayBuffers(...sources) {
4496
- return concatenateArrayBuffersFromArray(sources);
4497
- }
4498
- function concatenateArrayBuffersFromArray(sources) {
4499
- const sourceArrays = sources.map(
4500
- (source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
4501
- );
4502
- const byteLength = sourceArrays.reduce((length4, typedArray) => length4 + typedArray.byteLength, 0);
4503
- const result = new Uint8Array(byteLength);
4504
- let offset = 0;
4505
- for (const sourceArray of sourceArrays) {
4506
- result.set(sourceArray, offset);
4507
- offset += sourceArray.byteLength;
4490
+ /** Minimal */
4491
+ min(vector) {
4492
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4493
+ this[i] = Math.min(vector[i], this[i]);
4494
+ }
4495
+ return this.check();
4508
4496
  }
4509
- return result.buffer;
4510
- }
4511
-
4512
- // ../loader-utils/src/lib/iterators/async-iteration.ts
4513
- async function concatenateArrayBuffersAsync(asyncIterator) {
4514
- const arrayBuffers = [];
4515
- for await (const chunk of asyncIterator) {
4516
- arrayBuffers.push(chunk);
4497
+ /** Maximal */
4498
+ max(vector) {
4499
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4500
+ this[i] = Math.max(vector[i], this[i]);
4501
+ }
4502
+ return this.check();
4517
4503
  }
4518
- return concatenateArrayBuffers(...arrayBuffers);
4519
- }
4520
-
4521
- // ../loader-utils/src/lib/node/buffer.browser.ts
4522
- function toArrayBuffer(buffer) {
4523
- return buffer;
4524
- }
4525
-
4526
- // ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
4527
- function isBuffer(value) {
4528
- return value && typeof value === "object" && value.isBuffer;
4529
- }
4530
- function toArrayBuffer2(data) {
4531
- if (isBuffer(data)) {
4532
- return toArrayBuffer(data);
4504
+ clamp(minVector, maxVector) {
4505
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4506
+ this[i] = Math.min(Math.max(this[i], minVector[i]), maxVector[i]);
4507
+ }
4508
+ return this.check();
4533
4509
  }
4534
- if (data instanceof ArrayBuffer) {
4535
- return data;
4510
+ add(...vectors) {
4511
+ for (const vector of vectors) {
4512
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4513
+ this[i] += vector[i];
4514
+ }
4515
+ }
4516
+ return this.check();
4536
4517
  }
4537
- if (ArrayBuffer.isView(data)) {
4538
- if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
4539
- return data.buffer;
4518
+ subtract(...vectors) {
4519
+ for (const vector of vectors) {
4520
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4521
+ this[i] -= vector[i];
4522
+ }
4540
4523
  }
4541
- return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
4524
+ return this.check();
4542
4525
  }
4543
- if (typeof data === "string") {
4544
- const text = data;
4545
- const uint8Array = new TextEncoder().encode(text);
4546
- return uint8Array.buffer;
4526
+ scale(scale6) {
4527
+ if (typeof scale6 === "number") {
4528
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4529
+ this[i] *= scale6;
4530
+ }
4531
+ } else {
4532
+ for (let i = 0; i < this.ELEMENTS && i < scale6.length; ++i) {
4533
+ this[i] *= scale6[i];
4534
+ }
4535
+ }
4536
+ return this.check();
4547
4537
  }
4548
- if (data && typeof data === "object" && data._toArrayBuffer) {
4549
- return data._toArrayBuffer();
4538
+ /**
4539
+ * Multiplies all elements by `scale`
4540
+ * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
4541
+ */
4542
+ multiplyByScalar(scalar) {
4543
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4544
+ this[i] *= scalar;
4545
+ }
4546
+ return this.check();
4550
4547
  }
4551
- throw new Error("toArrayBuffer");
4552
- }
4553
-
4554
- // ../loader-utils/src/lib/node/promisify.ts
4555
- function promisify1(fn) {
4556
- return (args) => new Promise(
4557
- (resolve, reject) => fn(args, (error, callbackArgs) => error ? reject(error) : resolve(callbackArgs))
4558
- );
4559
- }
4560
-
4561
- // ../loader-utils/src/lib/files/node-file-facade.ts
4562
- var NOT_IMPLEMENTED = new Error("Not implemented");
4563
- var NodeFileFacade = class {
4564
- handle;
4565
- size = 0;
4566
- bigsize = 0n;
4567
- url = "";
4568
- constructor(url, flags, mode) {
4569
- if (globalThis.loaders?.NodeFile) {
4570
- return new globalThis.loaders.NodeFile(url, flags, mode);
4548
+ // Debug checks
4549
+ /** Throws an error if array length is incorrect or contains illegal values */
4550
+ check() {
4551
+ if (config.debug && !this.validate()) {
4552
+ throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
4571
4553
  }
4572
- if (isBrowser) {
4573
- throw new Error("Can't instantiate NodeFile in browser.");
4554
+ return this;
4555
+ }
4556
+ /** Returns false if the array length is incorrect or contains illegal values */
4557
+ validate() {
4558
+ let valid = this.length === this.ELEMENTS;
4559
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4560
+ valid = valid && Number.isFinite(this[i]);
4574
4561
  }
4575
- throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
4562
+ return valid;
4576
4563
  }
4577
- /** Read data */
4578
- async read(start, end) {
4579
- throw NOT_IMPLEMENTED;
4564
+ // three.js compatibility
4565
+ /** @deprecated */
4566
+ sub(a) {
4567
+ return this.subtract(a);
4580
4568
  }
4581
- /** Write to file. The number of bytes written will be returned */
4582
- async write(arrayBuffer, offset, length4) {
4583
- throw NOT_IMPLEMENTED;
4569
+ /** @deprecated */
4570
+ setScalar(a) {
4571
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4572
+ this[i] = a;
4573
+ }
4574
+ return this.check();
4584
4575
  }
4585
- /** Get information about file */
4586
- async stat() {
4587
- throw NOT_IMPLEMENTED;
4576
+ /** @deprecated */
4577
+ addScalar(a) {
4578
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4579
+ this[i] += a;
4580
+ }
4581
+ return this.check();
4588
4582
  }
4589
- /** Truncates the file descriptor. Only available on NodeFile. */
4590
- async truncate(length4) {
4591
- throw NOT_IMPLEMENTED;
4583
+ /** @deprecated */
4584
+ subScalar(a) {
4585
+ return this.addScalar(-a);
4592
4586
  }
4593
- /** Append data to a file. Only available on NodeFile. */
4594
- async append(data) {
4595
- throw NOT_IMPLEMENTED;
4587
+ /** @deprecated */
4588
+ multiplyScalar(scalar) {
4589
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4590
+ this[i] *= scalar;
4591
+ }
4592
+ return this.check();
4596
4593
  }
4597
- /** Close the file */
4598
- async close() {
4594
+ /** @deprecated */
4595
+ divideScalar(a) {
4596
+ return this.multiplyByScalar(1 / a);
4597
+ }
4598
+ /** @deprecated */
4599
+ clampScalar(min2, max2) {
4600
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4601
+ this[i] = Math.min(Math.max(this[i], min2), max2);
4602
+ }
4603
+ return this.check();
4604
+ }
4605
+ /** @deprecated */
4606
+ get elements() {
4607
+ return this;
4599
4608
  }
4600
4609
  };
4601
4610
 
4602
- // ../loader-utils/src/lib/file-provider/file-provider-interface.ts
4603
- var isFileProvider = (fileProvider) => {
4604
- return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
4605
- };
4606
-
4607
- // ../loader-utils/src/lib/file-provider/file-handle-file.ts
4608
- var FileHandleFile = class {
4609
- /** The FileHandle from which data is provided */
4610
- file;
4611
- /** Create a new FileHandleFile */
4612
- constructor(path, append = false) {
4613
- this.file = new NodeFileFacade(path, append ? "a+" : "r");
4611
+ // ../../node_modules/@math.gl/core/dist/lib/validators.js
4612
+ function validateVector(v, length4) {
4613
+ if (v.length !== length4) {
4614
+ return false;
4615
+ }
4616
+ for (let i = 0; i < v.length; ++i) {
4617
+ if (!Number.isFinite(v[i])) {
4618
+ return false;
4619
+ }
4620
+ }
4621
+ return true;
4622
+ }
4623
+ function checkNumber(value) {
4624
+ if (!Number.isFinite(value)) {
4625
+ throw new Error(`Invalid number ${JSON.stringify(value)}`);
4626
+ }
4627
+ return value;
4628
+ }
4629
+ function checkVector(v, length4, callerName = "") {
4630
+ if (config.debug && !validateVector(v, length4)) {
4631
+ throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
4632
+ }
4633
+ return v;
4634
+ }
4635
+
4636
+ // ../../node_modules/@math.gl/core/dist/lib/assert.js
4637
+ function assert(condition, message) {
4638
+ if (!condition) {
4639
+ throw new Error(`math.gl assertion ${message}`);
4640
+ }
4641
+ }
4642
+
4643
+ // ../../node_modules/@math.gl/core/dist/classes/base/vector.js
4644
+ var Vector = class extends MathArray {
4645
+ // ACCESSORS
4646
+ get x() {
4647
+ return this[0];
4648
+ }
4649
+ set x(value) {
4650
+ this[0] = checkNumber(value);
4651
+ }
4652
+ get y() {
4653
+ return this[1];
4654
+ }
4655
+ set y(value) {
4656
+ this[1] = checkNumber(value);
4614
4657
  }
4615
4658
  /**
4616
- * Truncates the file descriptor.
4617
- * @param length desired file lenght
4659
+ * Returns the length of the vector from the origin to the point described by this vector
4660
+ *
4661
+ * @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
4662
+ * Instead we provide `len` and `magnitude`
4618
4663
  */
4619
- async truncate(length4) {
4620
- await this.file.truncate(length4);
4664
+ len() {
4665
+ return Math.sqrt(this.lengthSquared());
4621
4666
  }
4622
4667
  /**
4623
- * Append data to a file.
4624
- * @param buffer data to append
4668
+ * Returns the length of the vector from the origin to the point described by this vector
4625
4669
  */
4626
- async append(buffer) {
4627
- await this.file.append(buffer);
4628
- }
4629
- /** Close file */
4630
- async destroy() {
4631
- await this.file.close();
4670
+ magnitude() {
4671
+ return this.len();
4632
4672
  }
4633
4673
  /**
4634
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
4635
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4674
+ * Returns the squared length of the vector from the origin to the point described by this vector
4636
4675
  */
4637
- async getUint8(offset) {
4638
- const arrayBuffer = await this.file.read(offset, 1);
4639
- const val = new Uint8Array(arrayBuffer).at(0);
4640
- if (val === void 0) {
4641
- throw new Error("something went wrong");
4676
+ lengthSquared() {
4677
+ let length4 = 0;
4678
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4679
+ length4 += this[i] * this[i];
4642
4680
  }
4643
- return val;
4681
+ return length4;
4644
4682
  }
4645
4683
  /**
4646
- * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
4647
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4684
+ * Returns the squared length of the vector from the origin to the point described by this vector
4648
4685
  */
4649
- async getUint16(offset) {
4650
- const arrayBuffer = await this.file.read(offset, 2);
4651
- const val = new Uint16Array(arrayBuffer).at(0);
4652
- if (val === void 0) {
4653
- throw new Error("something went wrong");
4686
+ magnitudeSquared() {
4687
+ return this.lengthSquared();
4688
+ }
4689
+ distance(mathArray) {
4690
+ return Math.sqrt(this.distanceSquared(mathArray));
4691
+ }
4692
+ distanceSquared(mathArray) {
4693
+ let length4 = 0;
4694
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4695
+ const dist2 = this[i] - mathArray[i];
4696
+ length4 += dist2 * dist2;
4654
4697
  }
4655
- return val;
4698
+ return checkNumber(length4);
4656
4699
  }
4657
- /**
4658
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
4659
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4660
- */
4661
- async getUint32(offset) {
4662
- const arrayBuffer = await this.file.read(offset, 4);
4663
- const val = new Uint32Array(arrayBuffer).at(0);
4664
- if (val === void 0) {
4665
- throw new Error("something went wrong");
4700
+ dot(mathArray) {
4701
+ let product = 0;
4702
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4703
+ product += this[i] * mathArray[i];
4666
4704
  }
4667
- return val;
4705
+ return checkNumber(product);
4668
4706
  }
4669
- /**
4670
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
4671
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4672
- */
4673
- async getBigUint64(offset) {
4674
- const arrayBuffer = await this.file.read(offset, 8);
4675
- const val = new BigInt64Array(arrayBuffer).at(0);
4676
- if (val === void 0) {
4677
- throw new Error("something went wrong");
4707
+ // MODIFIERS
4708
+ normalize() {
4709
+ const length4 = this.magnitude();
4710
+ if (length4 !== 0) {
4711
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4712
+ this[i] /= length4;
4713
+ }
4678
4714
  }
4679
- return val;
4715
+ return this.check();
4680
4716
  }
4681
- /**
4682
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
4683
- * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
4684
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
4685
- */
4686
- async slice(startOffset, endOffset) {
4687
- const bigLength = endOffset - startOffset;
4688
- if (bigLength > Number.MAX_SAFE_INTEGER) {
4689
- throw new Error("too big slice");
4717
+ multiply(...vectors) {
4718
+ for (const vector of vectors) {
4719
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4720
+ this[i] *= vector[i];
4721
+ }
4690
4722
  }
4691
- const length4 = Number(bigLength);
4692
- return await this.file.read(startOffset, length4);
4723
+ return this.check();
4693
4724
  }
4694
- /**
4695
- * the length (in bytes) of the data.
4696
- */
4697
- get length() {
4698
- return this.file.bigsize;
4725
+ divide(...vectors) {
4726
+ for (const vector of vectors) {
4727
+ for (let i = 0; i < this.ELEMENTS; ++i) {
4728
+ this[i] /= vector[i];
4729
+ }
4730
+ }
4731
+ return this.check();
4699
4732
  }
4700
- };
4701
-
4702
- // ../loader-utils/src/lib/file-provider/data-view-file.ts
4703
- var toNumber = (bigint) => {
4704
- if (bigint > Number.MAX_SAFE_INTEGER) {
4705
- throw new Error("Offset is out of bounds");
4733
+ // THREE.js compatibility
4734
+ lengthSq() {
4735
+ return this.lengthSquared();
4706
4736
  }
4707
- return Number(bigint);
4708
- };
4709
- var DataViewFile = class {
4710
- /** The DataView from which data is provided */
4711
- file;
4712
- constructor(file) {
4713
- this.file = file;
4737
+ distanceTo(vector) {
4738
+ return this.distance(vector);
4714
4739
  }
4715
- async destroy() {
4740
+ distanceToSquared(vector) {
4741
+ return this.distanceSquared(vector);
4716
4742
  }
4717
- /**
4718
- * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
4719
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4720
- */
4721
- async getUint8(offset) {
4722
- return this.file.getUint8(toNumber(offset));
4743
+ getComponent(i) {
4744
+ assert(i >= 0 && i < this.ELEMENTS, "index is out of range");
4745
+ return checkNumber(this[i]);
4723
4746
  }
4724
- /**
4725
- * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
4726
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4727
- */
4728
- async getUint16(offset) {
4729
- return this.file.getUint16(toNumber(offset), true);
4747
+ setComponent(i, value) {
4748
+ assert(i >= 0 && i < this.ELEMENTS, "index is out of range");
4749
+ this[i] = value;
4750
+ return this.check();
4730
4751
  }
4731
- /**
4732
- * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
4733
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4734
- */
4735
- async getUint32(offset) {
4736
- return this.file.getUint32(toNumber(offset), true);
4752
+ addVectors(a, b) {
4753
+ return this.copy(a).add(b);
4737
4754
  }
4738
- /**
4739
- * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
4740
- * @param offset The offset, in bytes, from the start of the file where to read the data.
4741
- */
4742
- async getBigUint64(offset) {
4743
- return this.file.getBigUint64(toNumber(offset), true);
4755
+ subVectors(a, b) {
4756
+ return this.copy(a).subtract(b);
4744
4757
  }
4745
- /**
4746
- * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
4747
- * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
4748
- * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
4749
- */
4750
- async slice(startOffset, endOffset) {
4751
- return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
4758
+ multiplyVectors(a, b) {
4759
+ return this.copy(a).multiply(b);
4752
4760
  }
4753
- /** the length (in bytes) of the data. */
4754
- get length() {
4755
- return BigInt(this.file.byteLength);
4761
+ addScaledVector(a, b) {
4762
+ return this.add(new this.constructor(a).multiplyScalar(b));
4756
4763
  }
4757
4764
  };
4758
4765
 
4759
- // ../../node_modules/@math.gl/core/dist/lib/common.js
4760
- var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
4761
- var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
4762
- var DEFAULT_CONFIG = {
4763
- EPSILON: 1e-12,
4764
- debug: false,
4765
- precision: 4,
4766
- printTypes: false,
4767
- printDegrees: false,
4768
- printRowMajor: true,
4769
- _cartographicRadians: false
4770
- };
4771
- globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
4772
- var config = globalThis.mathgl.config;
4773
- function formatValue(value, { precision = config.precision } = {}) {
4774
- value = round(value);
4775
- return `${parseFloat(value.toPrecision(precision))}`;
4776
- }
4777
- function isArray(value) {
4778
- return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
4779
- }
4780
- function toRadians(degrees2) {
4781
- return radians(degrees2);
4766
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
4767
+ var EPSILON = 1e-6;
4768
+ var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
4769
+ var RANDOM = Math.random;
4770
+ function round2(a) {
4771
+ if (a >= 0)
4772
+ return Math.round(a);
4773
+ return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
4782
4774
  }
4783
- function toDegrees(radians2) {
4784
- return degrees(radians2);
4775
+ var degree = Math.PI / 180;
4776
+
4777
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
4778
+ function create() {
4779
+ const out = new ARRAY_TYPE(2);
4780
+ if (ARRAY_TYPE != Float32Array) {
4781
+ out[0] = 0;
4782
+ out[1] = 0;
4783
+ }
4784
+ return out;
4785
4785
  }
4786
- function radians(degrees2, result) {
4787
- return map(degrees2, (degrees3) => degrees3 * DEGREES_TO_RADIANS, result);
4786
+ function transformMat3(out, a, m) {
4787
+ const x = a[0];
4788
+ const y = a[1];
4789
+ out[0] = m[0] * x + m[3] * y + m[6];
4790
+ out[1] = m[1] * x + m[4] * y + m[7];
4791
+ return out;
4788
4792
  }
4789
- function degrees(radians2, result) {
4790
- return map(radians2, (radians3) => radians3 * RADIANS_TO_DEGREES, result);
4793
+ function transformMat4(out, a, m) {
4794
+ const x = a[0];
4795
+ const y = a[1];
4796
+ out[0] = m[0] * x + m[4] * y + m[12];
4797
+ out[1] = m[1] * x + m[5] * y + m[13];
4798
+ return out;
4791
4799
  }
4792
- function equals(a, b, epsilon) {
4793
- const oldEpsilon = config.EPSILON;
4794
- if (epsilon) {
4795
- config.EPSILON = epsilon;
4796
- }
4797
- try {
4798
- if (a === b) {
4799
- return true;
4800
- }
4801
- if (isArray(a) && isArray(b)) {
4802
- if (a.length !== b.length) {
4803
- return false;
4804
- }
4805
- for (let i = 0; i < a.length; ++i) {
4806
- if (!equals(a[i], b[i])) {
4807
- return false;
4808
- }
4809
- }
4810
- return true;
4800
+ var forEach = function() {
4801
+ const vec = create();
4802
+ return function(a, stride, offset, count, fn, arg) {
4803
+ let i;
4804
+ let l;
4805
+ if (!stride) {
4806
+ stride = 2;
4811
4807
  }
4812
- if (a && a.equals) {
4813
- return a.equals(b);
4808
+ if (!offset) {
4809
+ offset = 0;
4814
4810
  }
4815
- if (b && b.equals) {
4816
- return b.equals(a);
4811
+ if (count) {
4812
+ l = Math.min(count * stride + offset, a.length);
4813
+ } else {
4814
+ l = a.length;
4817
4815
  }
4818
- if (typeof a === "number" && typeof b === "number") {
4819
- return Math.abs(a - b) <= config.EPSILON * Math.max(1, Math.abs(a), Math.abs(b));
4816
+ for (i = offset; i < l; i += stride) {
4817
+ vec[0] = a[i];
4818
+ vec[1] = a[i + 1];
4819
+ fn(vec, vec, arg);
4820
+ a[i] = vec[0];
4821
+ a[i + 1] = vec[1];
4820
4822
  }
4821
- return false;
4822
- } finally {
4823
- config.EPSILON = oldEpsilon;
4824
- }
4823
+ return a;
4824
+ };
4825
+ }();
4826
+
4827
+ // ../../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js
4828
+ function vec2_transformMat4AsVector(out, a, m) {
4829
+ const x = a[0];
4830
+ const y = a[1];
4831
+ const w = m[3] * x + m[7] * y || 1;
4832
+ out[0] = (m[0] * x + m[4] * y) / w;
4833
+ out[1] = (m[1] * x + m[5] * y) / w;
4834
+ return out;
4825
4835
  }
4826
- function round(value) {
4827
- return Math.round(value / config.EPSILON) * config.EPSILON;
4836
+ function vec3_transformMat4AsVector(out, a, m) {
4837
+ const x = a[0];
4838
+ const y = a[1];
4839
+ const z = a[2];
4840
+ const w = m[3] * x + m[7] * y + m[11] * z || 1;
4841
+ out[0] = (m[0] * x + m[4] * y + m[8] * z) / w;
4842
+ out[1] = (m[1] * x + m[5] * y + m[9] * z) / w;
4843
+ out[2] = (m[2] * x + m[6] * y + m[10] * z) / w;
4844
+ return out;
4828
4845
  }
4829
- function duplicateArray(array) {
4830
- return array.clone ? array.clone() : new Array(array.length);
4846
+ function vec3_transformMat2(out, a, m) {
4847
+ const x = a[0];
4848
+ const y = a[1];
4849
+ out[0] = m[0] * x + m[2] * y;
4850
+ out[1] = m[1] * x + m[3] * y;
4851
+ out[2] = a[2];
4852
+ return out;
4831
4853
  }
4832
- function map(value, func, result) {
4833
- if (isArray(value)) {
4834
- const array = value;
4835
- result = result || duplicateArray(array);
4836
- for (let i = 0; i < result.length && i < array.length; ++i) {
4837
- const val = typeof value === "number" ? value : value[i];
4838
- result[i] = func(val, i, result);
4839
- }
4840
- return result;
4841
- }
4842
- return func(value);
4854
+ function vec4_transformMat2(out, a, m) {
4855
+ const x = a[0];
4856
+ const y = a[1];
4857
+ out[0] = m[0] * x + m[2] * y;
4858
+ out[1] = m[1] * x + m[3] * y;
4859
+ out[2] = a[2];
4860
+ out[3] = a[3];
4861
+ return out;
4862
+ }
4863
+ function vec4_transformMat3(out, a, m) {
4864
+ const x = a[0];
4865
+ const y = a[1];
4866
+ const z = a[2];
4867
+ out[0] = m[0] * x + m[3] * y + m[6] * z;
4868
+ out[1] = m[1] * x + m[4] * y + m[7] * z;
4869
+ out[2] = m[2] * x + m[5] * y + m[8] * z;
4870
+ out[3] = a[3];
4871
+ return out;
4843
4872
  }
4844
4873
 
4845
- // ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
4846
- var MathArray = class extends Array {
4847
- // Common methods
4848
- /**
4849
- * Clone the current object
4850
- * @returns a new copy of this object
4851
- */
4852
- clone() {
4853
- return new this.constructor().copy(this);
4854
- }
4855
- fromArray(array, offset = 0) {
4856
- for (let i = 0; i < this.ELEMENTS; ++i) {
4857
- this[i] = array[i + offset];
4858
- }
4859
- return this.check();
4860
- }
4861
- toArray(targetArray = [], offset = 0) {
4862
- for (let i = 0; i < this.ELEMENTS; ++i) {
4863
- targetArray[offset + i] = this[i];
4864
- }
4865
- return targetArray;
4866
- }
4867
- toObject(targetObject) {
4868
- return targetObject;
4869
- }
4870
- from(arrayOrObject) {
4871
- return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
4872
- // @ts-ignore
4873
- this.fromObject(arrayOrObject)
4874
- );
4875
- }
4876
- to(arrayOrObject) {
4877
- if (arrayOrObject === this) {
4878
- return this;
4879
- }
4880
- return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
4881
- }
4882
- toTarget(target) {
4883
- return target ? this.to(target) : this;
4884
- }
4885
- /** @deprecated */
4886
- toFloat32Array() {
4887
- return new Float32Array(this);
4888
- }
4889
- toString() {
4890
- return this.formatString(config);
4891
- }
4892
- /** Formats string according to options */
4893
- formatString(opts) {
4894
- let string = "";
4895
- for (let i = 0; i < this.ELEMENTS; ++i) {
4896
- string += (i > 0 ? ", " : "") + formatValue(this[i], opts);
4897
- }
4898
- return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
4899
- }
4900
- equals(array) {
4901
- if (!array || this.length !== array.length) {
4902
- return false;
4903
- }
4904
- for (let i = 0; i < this.ELEMENTS; ++i) {
4905
- if (!equals(this[i], array[i])) {
4906
- return false;
4907
- }
4908
- }
4909
- return true;
4910
- }
4911
- exactEquals(array) {
4912
- if (!array || this.length !== array.length) {
4913
- return false;
4914
- }
4915
- for (let i = 0; i < this.ELEMENTS; ++i) {
4916
- if (this[i] !== array[i]) {
4917
- return false;
4918
- }
4919
- }
4920
- return true;
4921
- }
4922
- // Modifiers
4923
- /** Negates all values in this object */
4924
- negate() {
4925
- for (let i = 0; i < this.ELEMENTS; ++i) {
4926
- this[i] = -this[i];
4927
- }
4928
- return this.check();
4929
- }
4930
- lerp(a, b, t) {
4931
- if (t === void 0) {
4932
- return this.lerp(this, a, b);
4933
- }
4934
- for (let i = 0; i < this.ELEMENTS; ++i) {
4935
- const ai = a[i];
4936
- const endValue = typeof b === "number" ? b : b[i];
4937
- this[i] = ai + t * (endValue - ai);
4938
- }
4939
- return this.check();
4940
- }
4941
- /** Minimal */
4942
- min(vector) {
4943
- for (let i = 0; i < this.ELEMENTS; ++i) {
4944
- this[i] = Math.min(vector[i], this[i]);
4945
- }
4946
- return this.check();
4947
- }
4948
- /** Maximal */
4949
- max(vector) {
4950
- for (let i = 0; i < this.ELEMENTS; ++i) {
4951
- this[i] = Math.max(vector[i], this[i]);
4952
- }
4953
- return this.check();
4954
- }
4955
- clamp(minVector, maxVector) {
4956
- for (let i = 0; i < this.ELEMENTS; ++i) {
4957
- this[i] = Math.min(Math.max(this[i], minVector[i]), maxVector[i]);
4958
- }
4959
- return this.check();
4960
- }
4961
- add(...vectors) {
4962
- for (const vector of vectors) {
4963
- for (let i = 0; i < this.ELEMENTS; ++i) {
4964
- this[i] += vector[i];
4965
- }
4966
- }
4967
- return this.check();
4968
- }
4969
- subtract(...vectors) {
4970
- for (const vector of vectors) {
4971
- for (let i = 0; i < this.ELEMENTS; ++i) {
4972
- this[i] -= vector[i];
4973
- }
4974
- }
4975
- return this.check();
4976
- }
4977
- scale(scale6) {
4978
- if (typeof scale6 === "number") {
4979
- for (let i = 0; i < this.ELEMENTS; ++i) {
4980
- this[i] *= scale6;
4981
- }
4982
- } else {
4983
- for (let i = 0; i < this.ELEMENTS && i < scale6.length; ++i) {
4984
- this[i] *= scale6[i];
4985
- }
4986
- }
4987
- return this.check();
4988
- }
4989
- /**
4990
- * Multiplies all elements by `scale`
4991
- * Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
4992
- */
4993
- multiplyByScalar(scalar) {
4994
- for (let i = 0; i < this.ELEMENTS; ++i) {
4995
- this[i] *= scalar;
4996
- }
4997
- return this.check();
4998
- }
4999
- // Debug checks
5000
- /** Throws an error if array length is incorrect or contains illegal values */
5001
- check() {
5002
- if (config.debug && !this.validate()) {
5003
- throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
5004
- }
5005
- return this;
5006
- }
5007
- /** Returns false if the array length is incorrect or contains illegal values */
5008
- validate() {
5009
- let valid = this.length === this.ELEMENTS;
5010
- for (let i = 0; i < this.ELEMENTS; ++i) {
5011
- valid = valid && Number.isFinite(this[i]);
5012
- }
5013
- return valid;
5014
- }
5015
- // three.js compatibility
5016
- /** @deprecated */
5017
- sub(a) {
5018
- return this.subtract(a);
5019
- }
5020
- /** @deprecated */
5021
- setScalar(a) {
5022
- for (let i = 0; i < this.ELEMENTS; ++i) {
5023
- this[i] = a;
5024
- }
5025
- return this.check();
5026
- }
5027
- /** @deprecated */
5028
- addScalar(a) {
5029
- for (let i = 0; i < this.ELEMENTS; ++i) {
5030
- this[i] += a;
5031
- }
5032
- return this.check();
5033
- }
5034
- /** @deprecated */
5035
- subScalar(a) {
5036
- return this.addScalar(-a);
5037
- }
5038
- /** @deprecated */
5039
- multiplyScalar(scalar) {
5040
- for (let i = 0; i < this.ELEMENTS; ++i) {
5041
- this[i] *= scalar;
5042
- }
5043
- return this.check();
5044
- }
5045
- /** @deprecated */
5046
- divideScalar(a) {
5047
- return this.multiplyByScalar(1 / a);
5048
- }
5049
- /** @deprecated */
5050
- clampScalar(min2, max2) {
5051
- for (let i = 0; i < this.ELEMENTS; ++i) {
5052
- this[i] = Math.min(Math.max(this[i], min2), max2);
5053
- }
5054
- return this.check();
5055
- }
5056
- /** @deprecated */
5057
- get elements() {
5058
- return this;
5059
- }
5060
- };
5061
-
5062
- // ../../node_modules/@math.gl/core/dist/lib/validators.js
5063
- function validateVector(v, length4) {
5064
- if (v.length !== length4) {
5065
- return false;
5066
- }
5067
- for (let i = 0; i < v.length; ++i) {
5068
- if (!Number.isFinite(v[i])) {
5069
- return false;
5070
- }
5071
- }
5072
- return true;
5073
- }
5074
- function checkNumber(value) {
5075
- if (!Number.isFinite(value)) {
5076
- throw new Error(`Invalid number ${JSON.stringify(value)}`);
5077
- }
5078
- return value;
5079
- }
5080
- function checkVector(v, length4, callerName = "") {
5081
- if (config.debug && !validateVector(v, length4)) {
5082
- throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
5083
- }
5084
- return v;
5085
- }
5086
-
5087
- // ../../node_modules/@math.gl/core/dist/lib/assert.js
5088
- function assert3(condition, message) {
5089
- if (!condition) {
5090
- throw new Error(`math.gl assertion ${message}`);
5091
- }
5092
- }
5093
-
5094
- // ../../node_modules/@math.gl/core/dist/classes/base/vector.js
5095
- var Vector = class extends MathArray {
5096
- // ACCESSORS
5097
- get x() {
5098
- return this[0];
5099
- }
5100
- set x(value) {
5101
- this[0] = checkNumber(value);
5102
- }
5103
- get y() {
5104
- return this[1];
5105
- }
5106
- set y(value) {
5107
- this[1] = checkNumber(value);
5108
- }
5109
- /**
5110
- * Returns the length of the vector from the origin to the point described by this vector
5111
- *
5112
- * @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
5113
- * Instead we provide `len` and `magnitude`
5114
- */
5115
- len() {
5116
- return Math.sqrt(this.lengthSquared());
5117
- }
5118
- /**
5119
- * Returns the length of the vector from the origin to the point described by this vector
5120
- */
5121
- magnitude() {
5122
- return this.len();
5123
- }
5124
- /**
5125
- * Returns the squared length of the vector from the origin to the point described by this vector
5126
- */
5127
- lengthSquared() {
5128
- let length4 = 0;
5129
- for (let i = 0; i < this.ELEMENTS; ++i) {
5130
- length4 += this[i] * this[i];
5131
- }
5132
- return length4;
5133
- }
5134
- /**
5135
- * Returns the squared length of the vector from the origin to the point described by this vector
5136
- */
5137
- magnitudeSquared() {
5138
- return this.lengthSquared();
5139
- }
5140
- distance(mathArray) {
5141
- return Math.sqrt(this.distanceSquared(mathArray));
5142
- }
5143
- distanceSquared(mathArray) {
5144
- let length4 = 0;
5145
- for (let i = 0; i < this.ELEMENTS; ++i) {
5146
- const dist2 = this[i] - mathArray[i];
5147
- length4 += dist2 * dist2;
5148
- }
5149
- return checkNumber(length4);
5150
- }
5151
- dot(mathArray) {
5152
- let product = 0;
5153
- for (let i = 0; i < this.ELEMENTS; ++i) {
5154
- product += this[i] * mathArray[i];
5155
- }
5156
- return checkNumber(product);
5157
- }
5158
- // MODIFIERS
5159
- normalize() {
5160
- const length4 = this.magnitude();
5161
- if (length4 !== 0) {
5162
- for (let i = 0; i < this.ELEMENTS; ++i) {
5163
- this[i] /= length4;
5164
- }
5165
- }
5166
- return this.check();
5167
- }
5168
- multiply(...vectors) {
5169
- for (const vector of vectors) {
5170
- for (let i = 0; i < this.ELEMENTS; ++i) {
5171
- this[i] *= vector[i];
5172
- }
5173
- }
5174
- return this.check();
5175
- }
5176
- divide(...vectors) {
5177
- for (const vector of vectors) {
5178
- for (let i = 0; i < this.ELEMENTS; ++i) {
5179
- this[i] /= vector[i];
5180
- }
5181
- }
5182
- return this.check();
5183
- }
5184
- // THREE.js compatibility
5185
- lengthSq() {
5186
- return this.lengthSquared();
5187
- }
5188
- distanceTo(vector) {
5189
- return this.distance(vector);
5190
- }
5191
- distanceToSquared(vector) {
5192
- return this.distanceSquared(vector);
5193
- }
5194
- getComponent(i) {
5195
- assert3(i >= 0 && i < this.ELEMENTS, "index is out of range");
5196
- return checkNumber(this[i]);
5197
- }
5198
- setComponent(i, value) {
5199
- assert3(i >= 0 && i < this.ELEMENTS, "index is out of range");
5200
- this[i] = value;
5201
- return this.check();
5202
- }
5203
- addVectors(a, b) {
5204
- return this.copy(a).add(b);
5205
- }
5206
- subVectors(a, b) {
5207
- return this.copy(a).subtract(b);
5208
- }
5209
- multiplyVectors(a, b) {
5210
- return this.copy(a).multiply(b);
5211
- }
5212
- addScaledVector(a, b) {
5213
- return this.add(new this.constructor(a).multiplyScalar(b));
5214
- }
5215
- };
5216
-
5217
- // ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
5218
- var EPSILON = 1e-6;
5219
- var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
5220
- var RANDOM = Math.random;
5221
- function round2(a) {
5222
- if (a >= 0)
5223
- return Math.round(a);
5224
- return a % 0.5 === 0 ? Math.floor(a) : Math.round(a);
5225
- }
5226
- var degree = Math.PI / 180;
5227
-
5228
- // ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
5229
- function create() {
5230
- const out = new ARRAY_TYPE(2);
5231
- if (ARRAY_TYPE != Float32Array) {
5232
- out[0] = 0;
5233
- out[1] = 0;
5234
- }
5235
- return out;
5236
- }
5237
- function transformMat3(out, a, m) {
5238
- const x = a[0];
5239
- const y = a[1];
5240
- out[0] = m[0] * x + m[3] * y + m[6];
5241
- out[1] = m[1] * x + m[4] * y + m[7];
5242
- return out;
5243
- }
5244
- function transformMat4(out, a, m) {
5245
- const x = a[0];
5246
- const y = a[1];
5247
- out[0] = m[0] * x + m[4] * y + m[12];
5248
- out[1] = m[1] * x + m[5] * y + m[13];
5249
- return out;
5250
- }
5251
- var forEach2 = function() {
5252
- const vec = create();
5253
- return function(a, stride, offset, count, fn, arg) {
5254
- let i;
5255
- let l;
5256
- if (!stride) {
5257
- stride = 2;
5258
- }
5259
- if (!offset) {
5260
- offset = 0;
5261
- }
5262
- if (count) {
5263
- l = Math.min(count * stride + offset, a.length);
5264
- } else {
5265
- l = a.length;
5266
- }
5267
- for (i = offset; i < l; i += stride) {
5268
- vec[0] = a[i];
5269
- vec[1] = a[i + 1];
5270
- fn(vec, vec, arg);
5271
- a[i] = vec[0];
5272
- a[i + 1] = vec[1];
5273
- }
5274
- return a;
5275
- };
5276
- }();
5277
-
5278
- // ../../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js
5279
- function vec2_transformMat4AsVector(out, a, m) {
5280
- const x = a[0];
5281
- const y = a[1];
5282
- const w = m[3] * x + m[7] * y || 1;
5283
- out[0] = (m[0] * x + m[4] * y) / w;
5284
- out[1] = (m[1] * x + m[5] * y) / w;
5285
- return out;
5286
- }
5287
- function vec3_transformMat4AsVector(out, a, m) {
5288
- const x = a[0];
5289
- const y = a[1];
5290
- const z = a[2];
5291
- const w = m[3] * x + m[7] * y + m[11] * z || 1;
5292
- out[0] = (m[0] * x + m[4] * y + m[8] * z) / w;
5293
- out[1] = (m[1] * x + m[5] * y + m[9] * z) / w;
5294
- out[2] = (m[2] * x + m[6] * y + m[10] * z) / w;
5295
- return out;
5296
- }
5297
- function vec3_transformMat2(out, a, m) {
5298
- const x = a[0];
5299
- const y = a[1];
5300
- out[0] = m[0] * x + m[2] * y;
5301
- out[1] = m[1] * x + m[3] * y;
5302
- out[2] = a[2];
5303
- return out;
5304
- }
5305
- function vec4_transformMat2(out, a, m) {
5306
- const x = a[0];
5307
- const y = a[1];
5308
- out[0] = m[0] * x + m[2] * y;
5309
- out[1] = m[1] * x + m[3] * y;
5310
- out[2] = a[2];
5311
- out[3] = a[3];
5312
- return out;
5313
- }
5314
- function vec4_transformMat3(out, a, m) {
5315
- const x = a[0];
5316
- const y = a[1];
5317
- const z = a[2];
5318
- out[0] = m[0] * x + m[3] * y + m[6] * z;
5319
- out[1] = m[1] * x + m[4] * y + m[7] * z;
5320
- out[2] = m[2] * x + m[5] * y + m[8] * z;
5321
- out[3] = a[3];
5322
- return out;
5323
- }
5324
-
5325
- // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
5326
- var vec3_exports = {};
5327
- __export(vec3_exports, {
5328
- add: () => add,
5329
- angle: () => angle,
5330
- bezier: () => bezier,
5331
- ceil: () => ceil,
5332
- clone: () => clone,
5333
- copy: () => copy,
5334
- create: () => create2,
5335
- cross: () => cross,
5336
- dist: () => dist,
5337
- distance: () => distance,
5338
- div: () => div,
5339
- divide: () => divide,
5340
- dot: () => dot,
5341
- equals: () => equals2,
5342
- exactEquals: () => exactEquals,
5343
- floor: () => floor,
5344
- forEach: () => forEach3,
5345
- fromValues: () => fromValues,
5346
- hermite: () => hermite,
5347
- inverse: () => inverse,
5348
- len: () => len,
5349
- length: () => length,
5350
- lerp: () => lerp,
5351
- max: () => max,
5352
- min: () => min,
5353
- mul: () => mul,
5354
- multiply: () => multiply,
5355
- negate: () => negate,
5356
- normalize: () => normalize,
5357
- random: () => random,
5358
- rotateX: () => rotateX,
5359
- rotateY: () => rotateY,
5360
- rotateZ: () => rotateZ,
5361
- round: () => round3,
5362
- scale: () => scale,
5363
- scaleAndAdd: () => scaleAndAdd,
5364
- set: () => set,
5365
- slerp: () => slerp,
5366
- sqrDist: () => sqrDist,
5367
- sqrLen: () => sqrLen,
5368
- squaredDistance: () => squaredDistance,
5369
- squaredLength: () => squaredLength,
5370
- str: () => str,
5371
- sub: () => sub,
5372
- subtract: () => subtract,
5373
- transformMat3: () => transformMat32,
5374
- transformMat4: () => transformMat42,
5375
- transformQuat: () => transformQuat,
5376
- zero: () => zero
5377
- });
5378
- function create2() {
5379
- const out = new ARRAY_TYPE(3);
5380
- if (ARRAY_TYPE != Float32Array) {
5381
- out[0] = 0;
5382
- out[1] = 0;
5383
- out[2] = 0;
4874
+ // ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
4875
+ var vec3_exports = {};
4876
+ __export(vec3_exports, {
4877
+ add: () => add,
4878
+ angle: () => angle,
4879
+ bezier: () => bezier,
4880
+ ceil: () => ceil,
4881
+ clone: () => clone,
4882
+ copy: () => copy,
4883
+ create: () => create2,
4884
+ cross: () => cross,
4885
+ dist: () => dist,
4886
+ distance: () => distance,
4887
+ div: () => div,
4888
+ divide: () => divide,
4889
+ dot: () => dot,
4890
+ equals: () => equals2,
4891
+ exactEquals: () => exactEquals,
4892
+ floor: () => floor,
4893
+ forEach: () => forEach2,
4894
+ fromValues: () => fromValues,
4895
+ hermite: () => hermite,
4896
+ inverse: () => inverse,
4897
+ len: () => len,
4898
+ length: () => length,
4899
+ lerp: () => lerp,
4900
+ max: () => max,
4901
+ min: () => min,
4902
+ mul: () => mul,
4903
+ multiply: () => multiply,
4904
+ negate: () => negate,
4905
+ normalize: () => normalize,
4906
+ random: () => random,
4907
+ rotateX: () => rotateX,
4908
+ rotateY: () => rotateY,
4909
+ rotateZ: () => rotateZ,
4910
+ round: () => round3,
4911
+ scale: () => scale,
4912
+ scaleAndAdd: () => scaleAndAdd,
4913
+ set: () => set,
4914
+ slerp: () => slerp,
4915
+ sqrDist: () => sqrDist,
4916
+ sqrLen: () => sqrLen,
4917
+ squaredDistance: () => squaredDistance,
4918
+ squaredLength: () => squaredLength,
4919
+ str: () => str,
4920
+ sub: () => sub,
4921
+ subtract: () => subtract,
4922
+ transformMat3: () => transformMat32,
4923
+ transformMat4: () => transformMat42,
4924
+ transformQuat: () => transformQuat,
4925
+ zero: () => zero
4926
+ });
4927
+ function create2() {
4928
+ const out = new ARRAY_TYPE(3);
4929
+ if (ARRAY_TYPE != Float32Array) {
4930
+ out[0] = 0;
4931
+ out[1] = 0;
4932
+ out[2] = 0;
5384
4933
  }
5385
4934
  return out;
5386
4935
  }
@@ -5720,7 +5269,7 @@ var __exports__ = (() => {
5720
5269
  var sqrDist = squaredDistance;
5721
5270
  var len = length;
5722
5271
  var sqrLen = squaredLength;
5723
- var forEach3 = function() {
5272
+ var forEach2 = function() {
5724
5273
  const vec = create2();
5725
5274
  return function(a, stride, offset, count, fn, arg) {
5726
5275
  let i;
@@ -7989,7 +7538,7 @@ var __exports__ = (() => {
7989
7538
  out[3] = a[3];
7990
7539
  return out;
7991
7540
  }
7992
- var forEach4 = function() {
7541
+ var forEach3 = function() {
7993
7542
  const vec = create5();
7994
7543
  return function(a, stride, offset, count, fn, arg) {
7995
7544
  let i;
@@ -8789,716 +8338,1169 @@ var __exports__ = (() => {
8789
8338
  this.set(x, y, z, w);
8790
8339
  }
8791
8340
  }
8792
- copy(array) {
8793
- this[0] = array[0];
8794
- this[1] = array[1];
8795
- this[2] = array[2];
8796
- this[3] = array[3];
8341
+ copy(array) {
8342
+ this[0] = array[0];
8343
+ this[1] = array[1];
8344
+ this[2] = array[2];
8345
+ this[3] = array[3];
8346
+ return this.check();
8347
+ }
8348
+ set(x, y, z, w) {
8349
+ this[0] = x;
8350
+ this[1] = y;
8351
+ this[2] = z;
8352
+ this[3] = w;
8353
+ return this.check();
8354
+ }
8355
+ fromObject(object) {
8356
+ this[0] = object.x;
8357
+ this[1] = object.y;
8358
+ this[2] = object.z;
8359
+ this[3] = object.w;
8360
+ return this.check();
8361
+ }
8362
+ /**
8363
+ * Creates a quaternion from the given 3x3 rotation matrix.
8364
+ * NOTE: The resultant quaternion is not normalized, so you should
8365
+ * be sure to renormalize the quaternion yourself where necessary.
8366
+ * @param m
8367
+ * @returns
8368
+ */
8369
+ fromMatrix3(m) {
8370
+ fromMat3(this, m);
8371
+ return this.check();
8372
+ }
8373
+ fromAxisRotation(axis, rad) {
8374
+ setAxisAngle(this, axis, rad);
8375
+ return this.check();
8376
+ }
8377
+ /** Set a quat to the identity quaternion */
8378
+ identity() {
8379
+ identity2(this);
8380
+ return this.check();
8381
+ }
8382
+ // Set the components of a quat to the given values
8383
+ // set(i, j, k, l) {
8384
+ // quat_set(this, i, j, k, l);
8385
+ // return this.check();
8386
+ // }
8387
+ // Sets a quat from the given angle and rotation axis, then returns it.
8388
+ setAxisAngle(axis, rad) {
8389
+ return this.fromAxisRotation(axis, rad);
8390
+ }
8391
+ // Getters/setters
8392
+ get ELEMENTS() {
8393
+ return 4;
8394
+ }
8395
+ get x() {
8396
+ return this[0];
8397
+ }
8398
+ set x(value) {
8399
+ this[0] = checkNumber(value);
8400
+ }
8401
+ get y() {
8402
+ return this[1];
8403
+ }
8404
+ set y(value) {
8405
+ this[1] = checkNumber(value);
8406
+ }
8407
+ get z() {
8408
+ return this[2];
8409
+ }
8410
+ set z(value) {
8411
+ this[2] = checkNumber(value);
8412
+ }
8413
+ get w() {
8414
+ return this[3];
8415
+ }
8416
+ set w(value) {
8417
+ this[3] = checkNumber(value);
8418
+ }
8419
+ // Calculates the length of a quat
8420
+ len() {
8421
+ return length3(this);
8422
+ }
8423
+ // Calculates the squared length of a quat
8424
+ lengthSquared() {
8425
+ return squaredLength3(this);
8426
+ }
8427
+ // Calculates the dot product of two quat's
8428
+ // @return {Number}
8429
+ dot(a) {
8430
+ return dot3(this, a);
8431
+ }
8432
+ // Gets the rotation axis and angle for a given quaternion.
8433
+ // If a quaternion is created with setAxisAngle, this method will
8434
+ // return the same values as providied in the original parameter
8435
+ // list OR functionally equivalent values.
8436
+ // Example: The quaternion formed by axis [0, 0, 1] and angle -90
8437
+ // is the same as the quaternion formed by [0, 0, 1] and 270.
8438
+ // This method favors the latter.
8439
+ // @return {{[x,y,z], Number}}
8440
+ // getAxisAngle() {
8441
+ // const axis = [];
8442
+ // // const angle = quat_getAxisAngle(axis, this);
8443
+ // return {axis, angle};
8444
+ // }
8445
+ // MODIFIERS
8446
+ // Sets a quaternion to represent the shortest rotation from one vector
8447
+ // to another. Both vectors are assumed to be unit length.
8448
+ rotationTo(vectorA, vectorB) {
8449
+ rotationTo(this, vectorA, vectorB);
8450
+ return this.check();
8451
+ }
8452
+ // Sets the specified quaternion with values corresponding to the given axes.
8453
+ // Each axis is a vec3 and is expected to be unit length and perpendicular
8454
+ // to all other specified axes.
8455
+ // setAxes() {
8456
+ // Number
8457
+ // }
8458
+ // Performs a spherical linear interpolation with two control points
8459
+ // sqlerp() {
8460
+ // Number;
8461
+ // }
8462
+ // Adds two quat's
8463
+ add(a) {
8464
+ add4(this, this, a);
8465
+ return this.check();
8466
+ }
8467
+ // Calculates the W component of a quat from the X, Y, and Z components.
8468
+ // Any existing W component will be ignored.
8469
+ calculateW() {
8470
+ calculateW(this, this);
8471
+ return this.check();
8472
+ }
8473
+ // Calculates the conjugate of a quat If the quaternion is normalized,
8474
+ // this function is faster than quat_invert and produces the same result.
8475
+ conjugate() {
8476
+ conjugate(this, this);
8477
+ return this.check();
8478
+ }
8479
+ // Calculates the inverse of a quat
8480
+ invert() {
8481
+ invert3(this, this);
8482
+ return this.check();
8483
+ }
8484
+ // Performs a linear interpolation between two quat's
8485
+ lerp(a, b, t) {
8486
+ if (t === void 0) {
8487
+ return this.lerp(this, a, b);
8488
+ }
8489
+ lerp3(this, a, b, t);
8490
+ return this.check();
8491
+ }
8492
+ // Multiplies two quat's
8493
+ multiplyRight(a) {
8494
+ multiply4(this, this, a);
8797
8495
  return this.check();
8798
8496
  }
8799
- set(x, y, z, w) {
8800
- this[0] = x;
8801
- this[1] = y;
8802
- this[2] = z;
8803
- this[3] = w;
8497
+ multiplyLeft(a) {
8498
+ multiply4(this, a, this);
8804
8499
  return this.check();
8805
8500
  }
8806
- fromObject(object) {
8807
- this[0] = object.x;
8808
- this[1] = object.y;
8809
- this[2] = object.z;
8810
- this[3] = object.w;
8501
+ // Normalize a quat
8502
+ normalize() {
8503
+ const length4 = this.len();
8504
+ const l = length4 > 0 ? 1 / length4 : 0;
8505
+ this[0] = this[0] * l;
8506
+ this[1] = this[1] * l;
8507
+ this[2] = this[2] * l;
8508
+ this[3] = this[3] * l;
8509
+ if (length4 === 0) {
8510
+ this[3] = 1;
8511
+ }
8512
+ return this.check();
8513
+ }
8514
+ // Rotates a quaternion by the given angle about the X axis
8515
+ rotateX(rad) {
8516
+ rotateX3(this, this, rad);
8517
+ return this.check();
8518
+ }
8519
+ // Rotates a quaternion by the given angle about the Y axis
8520
+ rotateY(rad) {
8521
+ rotateY3(this, this, rad);
8522
+ return this.check();
8523
+ }
8524
+ // Rotates a quaternion by the given angle about the Z axis
8525
+ rotateZ(rad) {
8526
+ rotateZ3(this, this, rad);
8527
+ return this.check();
8528
+ }
8529
+ // Scales a quat by a scalar number
8530
+ scale(b) {
8531
+ scale5(this, this, b);
8532
+ return this.check();
8533
+ }
8534
+ // Performs a spherical linear interpolation between two quat
8535
+ slerp(arg0, arg1, arg2) {
8536
+ let start;
8537
+ let target;
8538
+ let ratio;
8539
+ switch (arguments.length) {
8540
+ case 1:
8541
+ ({
8542
+ start = IDENTITY_QUATERNION,
8543
+ target,
8544
+ ratio
8545
+ } = arg0);
8546
+ break;
8547
+ case 2:
8548
+ start = this;
8549
+ target = arg0;
8550
+ ratio = arg1;
8551
+ break;
8552
+ default:
8553
+ start = arg0;
8554
+ target = arg1;
8555
+ ratio = arg2;
8556
+ }
8557
+ slerp2(this, start, target, ratio);
8811
8558
  return this.check();
8812
8559
  }
8813
- /**
8814
- * Creates a quaternion from the given 3x3 rotation matrix.
8815
- * NOTE: The resultant quaternion is not normalized, so you should
8816
- * be sure to renormalize the quaternion yourself where necessary.
8817
- * @param m
8818
- * @returns
8819
- */
8820
- fromMatrix3(m) {
8821
- fromMat3(this, m);
8822
- return this.check();
8560
+ transformVector4(vector, result = new Vector4()) {
8561
+ transformQuat2(result, vector, this);
8562
+ return checkVector(result, 4);
8563
+ }
8564
+ // THREE.js Math API compatibility
8565
+ lengthSq() {
8566
+ return this.lengthSquared();
8567
+ }
8568
+ setFromAxisAngle(axis, rad) {
8569
+ return this.setAxisAngle(axis, rad);
8570
+ }
8571
+ premultiply(a) {
8572
+ return this.multiplyLeft(a);
8573
+ }
8574
+ multiply(a) {
8575
+ return this.multiplyRight(a);
8576
+ }
8577
+ };
8578
+
8579
+ // ../../node_modules/@math.gl/core/dist/lib/math-utils.js
8580
+ var math_utils_exports = {};
8581
+ __export(math_utils_exports, {
8582
+ EPSILON1: () => EPSILON1,
8583
+ EPSILON10: () => EPSILON10,
8584
+ EPSILON11: () => EPSILON11,
8585
+ EPSILON12: () => EPSILON12,
8586
+ EPSILON13: () => EPSILON13,
8587
+ EPSILON14: () => EPSILON14,
8588
+ EPSILON15: () => EPSILON15,
8589
+ EPSILON16: () => EPSILON16,
8590
+ EPSILON17: () => EPSILON17,
8591
+ EPSILON18: () => EPSILON18,
8592
+ EPSILON19: () => EPSILON19,
8593
+ EPSILON2: () => EPSILON2,
8594
+ EPSILON20: () => EPSILON20,
8595
+ EPSILON3: () => EPSILON3,
8596
+ EPSILON4: () => EPSILON4,
8597
+ EPSILON5: () => EPSILON5,
8598
+ EPSILON6: () => EPSILON6,
8599
+ EPSILON7: () => EPSILON7,
8600
+ EPSILON8: () => EPSILON8,
8601
+ EPSILON9: () => EPSILON9,
8602
+ PI_OVER_FOUR: () => PI_OVER_FOUR,
8603
+ PI_OVER_SIX: () => PI_OVER_SIX,
8604
+ PI_OVER_TWO: () => PI_OVER_TWO,
8605
+ TWO_PI: () => TWO_PI
8606
+ });
8607
+ var EPSILON1 = 0.1;
8608
+ var EPSILON2 = 0.01;
8609
+ var EPSILON3 = 1e-3;
8610
+ var EPSILON4 = 1e-4;
8611
+ var EPSILON5 = 1e-5;
8612
+ var EPSILON6 = 1e-6;
8613
+ var EPSILON7 = 1e-7;
8614
+ var EPSILON8 = 1e-8;
8615
+ var EPSILON9 = 1e-9;
8616
+ var EPSILON10 = 1e-10;
8617
+ var EPSILON11 = 1e-11;
8618
+ var EPSILON12 = 1e-12;
8619
+ var EPSILON13 = 1e-13;
8620
+ var EPSILON14 = 1e-14;
8621
+ var EPSILON15 = 1e-15;
8622
+ var EPSILON16 = 1e-16;
8623
+ var EPSILON17 = 1e-17;
8624
+ var EPSILON18 = 1e-18;
8625
+ var EPSILON19 = 1e-19;
8626
+ var EPSILON20 = 1e-20;
8627
+ var PI_OVER_TWO = Math.PI / 2;
8628
+ var PI_OVER_FOUR = Math.PI / 4;
8629
+ var PI_OVER_SIX = Math.PI / 6;
8630
+ var TWO_PI = Math.PI * 2;
8631
+
8632
+ // src/lib/parsers/constants.ts
8633
+ function getConstructorForDataFormat(dataType) {
8634
+ switch (dataType) {
8635
+ case "UInt8":
8636
+ return Uint8Array;
8637
+ case "UInt16":
8638
+ return Uint16Array;
8639
+ case "UInt32":
8640
+ return Uint32Array;
8641
+ case "Float32":
8642
+ return Float32Array;
8643
+ case "UInt64":
8644
+ return Float64Array;
8645
+ default:
8646
+ throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
8647
+ }
8648
+ }
8649
+ var GL_TYPE_MAP = {
8650
+ UInt8: GL.UNSIGNED_BYTE,
8651
+ UInt16: GL.UNSIGNED_SHORT,
8652
+ Float32: GL.FLOAT,
8653
+ UInt32: GL.UNSIGNED_INT,
8654
+ UInt64: GL.DOUBLE
8655
+ };
8656
+ function sizeOf(dataType) {
8657
+ switch (dataType) {
8658
+ case "UInt8":
8659
+ return 1;
8660
+ case "UInt16":
8661
+ case "Int16":
8662
+ return 2;
8663
+ case "UInt32":
8664
+ case "Int32":
8665
+ case "Float32":
8666
+ return 4;
8667
+ case "UInt64":
8668
+ case "Int64":
8669
+ case "Float64":
8670
+ return 8;
8671
+ default:
8672
+ throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
8673
+ }
8674
+ }
8675
+ var STRING_ATTRIBUTE_TYPE = "String";
8676
+ var OBJECT_ID_ATTRIBUTE_TYPE = "Oid32";
8677
+ var FLOAT_64_TYPE = "Float64";
8678
+ var INT_16_ATTRIBUTE_TYPE = "Int16";
8679
+ var COORDINATE_SYSTEM = /* @__PURE__ */ ((COORDINATE_SYSTEM2) => {
8680
+ COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["DEFAULT"] = -1] = "DEFAULT";
8681
+ COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["LNGLAT"] = 1] = "LNGLAT";
8682
+ COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["METER_OFFSETS"] = 2] = "METER_OFFSETS";
8683
+ COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
8684
+ COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["CARTESIAN"] = 0] = "CARTESIAN";
8685
+ return COORDINATE_SYSTEM2;
8686
+ })(COORDINATE_SYSTEM || {});
8687
+
8688
+ // src/i3s-loader.ts
8689
+ var import_core18 = __toESM(require_core(), 1);
8690
+
8691
+ // src/lib/parsers/parse-i3s-tile-content.ts
8692
+ var import_core5 = __toESM(require_core(), 1);
8693
+
8694
+ // ../../node_modules/@math.gl/geospatial/dist/constants.js
8695
+ var WGS84_RADIUS_X = 6378137;
8696
+ var WGS84_RADIUS_Y = 6378137;
8697
+ var WGS84_RADIUS_Z = 6356752314245179e-9;
8698
+ var WGS84_CONSTANTS = {
8699
+ radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],
8700
+ radiiSquared: [
8701
+ WGS84_RADIUS_X * WGS84_RADIUS_X,
8702
+ WGS84_RADIUS_Y * WGS84_RADIUS_Y,
8703
+ WGS84_RADIUS_Z * WGS84_RADIUS_Z
8704
+ ],
8705
+ oneOverRadii: [1 / WGS84_RADIUS_X, 1 / WGS84_RADIUS_Y, 1 / WGS84_RADIUS_Z],
8706
+ oneOverRadiiSquared: [
8707
+ 1 / (WGS84_RADIUS_X * WGS84_RADIUS_X),
8708
+ 1 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y),
8709
+ 1 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)
8710
+ ],
8711
+ maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),
8712
+ centerToleranceSquared: 0.1
8713
+ // EPSILON1;
8714
+ };
8715
+
8716
+ // ../../node_modules/@math.gl/geospatial/dist/type-utils.js
8717
+ function identity3(x) {
8718
+ return x;
8719
+ }
8720
+ var scratchVector = new Vector3();
8721
+ function fromCartographic(cartographic, result = [], map2 = identity3) {
8722
+ if ("longitude" in cartographic) {
8723
+ result[0] = map2(cartographic.longitude);
8724
+ result[1] = map2(cartographic.latitude);
8725
+ result[2] = cartographic.height;
8726
+ } else if ("x" in cartographic) {
8727
+ result[0] = map2(cartographic.x);
8728
+ result[1] = map2(cartographic.y);
8729
+ result[2] = cartographic.z;
8730
+ } else {
8731
+ result[0] = map2(cartographic[0]);
8732
+ result[1] = map2(cartographic[1]);
8733
+ result[2] = cartographic[2];
8734
+ }
8735
+ return result;
8736
+ }
8737
+ function fromCartographicToRadians(cartographic, vector = []) {
8738
+ return fromCartographic(cartographic, vector, config._cartographicRadians ? identity3 : toRadians);
8739
+ }
8740
+ function toCartographic(vector, cartographic, map2 = identity3) {
8741
+ if ("longitude" in cartographic) {
8742
+ cartographic.longitude = map2(vector[0]);
8743
+ cartographic.latitude = map2(vector[1]);
8744
+ cartographic.height = vector[2];
8745
+ } else if ("x" in cartographic) {
8746
+ cartographic.x = map2(vector[0]);
8747
+ cartographic.y = map2(vector[1]);
8748
+ cartographic.z = vector[2];
8749
+ } else {
8750
+ cartographic[0] = map2(vector[0]);
8751
+ cartographic[1] = map2(vector[1]);
8752
+ cartographic[2] = vector[2];
8823
8753
  }
8824
- fromAxisRotation(axis, rad) {
8825
- setAxisAngle(this, axis, rad);
8826
- return this.check();
8754
+ return cartographic;
8755
+ }
8756
+ function toCartographicFromRadians(vector, cartographic) {
8757
+ return toCartographic(vector, cartographic, config._cartographicRadians ? identity3 : toDegrees);
8758
+ }
8759
+
8760
+ // ../../node_modules/@math.gl/geospatial/dist/ellipsoid/helpers/ellipsoid-transform.js
8761
+ var EPSILON142 = 1e-14;
8762
+ var scratchOrigin = new Vector3();
8763
+ var VECTOR_PRODUCT_LOCAL_FRAME = {
8764
+ up: {
8765
+ south: "east",
8766
+ north: "west",
8767
+ west: "south",
8768
+ east: "north"
8769
+ },
8770
+ down: {
8771
+ south: "west",
8772
+ north: "east",
8773
+ west: "north",
8774
+ east: "south"
8775
+ },
8776
+ south: {
8777
+ up: "west",
8778
+ down: "east",
8779
+ west: "down",
8780
+ east: "up"
8781
+ },
8782
+ north: {
8783
+ up: "east",
8784
+ down: "west",
8785
+ west: "up",
8786
+ east: "down"
8787
+ },
8788
+ west: {
8789
+ up: "north",
8790
+ down: "south",
8791
+ north: "down",
8792
+ south: "up"
8793
+ },
8794
+ east: {
8795
+ up: "south",
8796
+ down: "north",
8797
+ north: "up",
8798
+ south: "down"
8827
8799
  }
8828
- /** Set a quat to the identity quaternion */
8829
- identity() {
8830
- identity2(this);
8831
- return this.check();
8800
+ };
8801
+ var degeneratePositionLocalFrame = {
8802
+ north: [-1, 0, 0],
8803
+ east: [0, 1, 0],
8804
+ up: [0, 0, 1],
8805
+ south: [1, 0, 0],
8806
+ west: [0, -1, 0],
8807
+ down: [0, 0, -1]
8808
+ };
8809
+ var scratchAxisVectors = {
8810
+ east: new Vector3(),
8811
+ north: new Vector3(),
8812
+ up: new Vector3(),
8813
+ west: new Vector3(),
8814
+ south: new Vector3(),
8815
+ down: new Vector3()
8816
+ };
8817
+ var scratchVector1 = new Vector3();
8818
+ var scratchVector2 = new Vector3();
8819
+ var scratchVector3 = new Vector3();
8820
+ function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
8821
+ const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
8822
+ assert(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
8823
+ let firstAxisVector;
8824
+ let secondAxisVector;
8825
+ let thirdAxisVector;
8826
+ const origin = scratchOrigin.copy(cartesianOrigin);
8827
+ const atPole = equals(origin.x, 0, EPSILON142) && equals(origin.y, 0, EPSILON142);
8828
+ if (atPole) {
8829
+ const sign = Math.sign(origin.z);
8830
+ firstAxisVector = scratchVector1.fromArray(degeneratePositionLocalFrame[firstAxis]);
8831
+ if (firstAxis !== "east" && firstAxis !== "west") {
8832
+ firstAxisVector.scale(sign);
8833
+ }
8834
+ secondAxisVector = scratchVector2.fromArray(degeneratePositionLocalFrame[secondAxis]);
8835
+ if (secondAxis !== "east" && secondAxis !== "west") {
8836
+ secondAxisVector.scale(sign);
8837
+ }
8838
+ thirdAxisVector = scratchVector3.fromArray(degeneratePositionLocalFrame[thirdAxis]);
8839
+ if (thirdAxis !== "east" && thirdAxis !== "west") {
8840
+ thirdAxisVector.scale(sign);
8841
+ }
8842
+ } else {
8843
+ const { up, east, north } = scratchAxisVectors;
8844
+ east.set(-origin.y, origin.x, 0).normalize();
8845
+ ellipsoid.geodeticSurfaceNormal(origin, up);
8846
+ north.copy(up).cross(east);
8847
+ const { down, west, south } = scratchAxisVectors;
8848
+ down.copy(up).scale(-1);
8849
+ west.copy(east).scale(-1);
8850
+ south.copy(north).scale(-1);
8851
+ firstAxisVector = scratchAxisVectors[firstAxis];
8852
+ secondAxisVector = scratchAxisVectors[secondAxis];
8853
+ thirdAxisVector = scratchAxisVectors[thirdAxis];
8832
8854
  }
8833
- // Set the components of a quat to the given values
8834
- // set(i, j, k, l) {
8835
- // quat_set(this, i, j, k, l);
8836
- // return this.check();
8837
- // }
8838
- // Sets a quat from the given angle and rotation axis, then returns it.
8839
- setAxisAngle(axis, rad) {
8840
- return this.fromAxisRotation(axis, rad);
8855
+ result[0] = firstAxisVector.x;
8856
+ result[1] = firstAxisVector.y;
8857
+ result[2] = firstAxisVector.z;
8858
+ result[3] = 0;
8859
+ result[4] = secondAxisVector.x;
8860
+ result[5] = secondAxisVector.y;
8861
+ result[6] = secondAxisVector.z;
8862
+ result[7] = 0;
8863
+ result[8] = thirdAxisVector.x;
8864
+ result[9] = thirdAxisVector.y;
8865
+ result[10] = thirdAxisVector.z;
8866
+ result[11] = 0;
8867
+ result[12] = origin.x;
8868
+ result[13] = origin.y;
8869
+ result[14] = origin.z;
8870
+ result[15] = 1;
8871
+ return result;
8872
+ }
8873
+
8874
+ // ../../node_modules/@math.gl/geospatial/dist/ellipsoid/helpers/scale-to-geodetic-surface.js
8875
+ var scratchVector4 = new Vector3();
8876
+ var scaleToGeodeticSurfaceIntersection = new Vector3();
8877
+ var scaleToGeodeticSurfaceGradient = new Vector3();
8878
+ function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
8879
+ const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;
8880
+ scratchVector4.from(cartesian);
8881
+ const positionX = scratchVector4.x;
8882
+ const positionY = scratchVector4.y;
8883
+ const positionZ = scratchVector4.z;
8884
+ const oneOverRadiiX = oneOverRadii.x;
8885
+ const oneOverRadiiY = oneOverRadii.y;
8886
+ const oneOverRadiiZ = oneOverRadii.z;
8887
+ const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
8888
+ const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
8889
+ const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
8890
+ const squaredNorm = x2 + y2 + z2;
8891
+ const ratio = Math.sqrt(1 / squaredNorm);
8892
+ if (!Number.isFinite(ratio)) {
8893
+ return void 0;
8841
8894
  }
8842
- // Getters/setters
8843
- get ELEMENTS() {
8844
- return 4;
8895
+ const intersection = scaleToGeodeticSurfaceIntersection;
8896
+ intersection.copy(cartesian).scale(ratio);
8897
+ if (squaredNorm < centerToleranceSquared) {
8898
+ return intersection.to(result);
8845
8899
  }
8846
- get x() {
8847
- return this[0];
8900
+ const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
8901
+ const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
8902
+ const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
8903
+ const gradient = scaleToGeodeticSurfaceGradient;
8904
+ gradient.set(intersection.x * oneOverRadiiSquaredX * 2, intersection.y * oneOverRadiiSquaredY * 2, intersection.z * oneOverRadiiSquaredZ * 2);
8905
+ let lambda = (1 - ratio) * scratchVector4.len() / (0.5 * gradient.len());
8906
+ let correction = 0;
8907
+ let xMultiplier;
8908
+ let yMultiplier;
8909
+ let zMultiplier;
8910
+ let func;
8911
+ do {
8912
+ lambda -= correction;
8913
+ xMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredX);
8914
+ yMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredY);
8915
+ zMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredZ);
8916
+ const xMultiplier2 = xMultiplier * xMultiplier;
8917
+ const yMultiplier2 = yMultiplier * yMultiplier;
8918
+ const zMultiplier2 = zMultiplier * zMultiplier;
8919
+ const xMultiplier3 = xMultiplier2 * xMultiplier;
8920
+ const yMultiplier3 = yMultiplier2 * yMultiplier;
8921
+ const zMultiplier3 = zMultiplier2 * zMultiplier;
8922
+ func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1;
8923
+ const denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
8924
+ const derivative = -2 * denominator;
8925
+ correction = func / derivative;
8926
+ } while (Math.abs(func) > math_utils_exports.EPSILON12);
8927
+ return scratchVector4.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
8928
+ }
8929
+
8930
+ // ../../node_modules/@math.gl/geospatial/dist/ellipsoid/ellipsoid.js
8931
+ var scratchVector5 = new Vector3();
8932
+ var scratchNormal = new Vector3();
8933
+ var scratchK = new Vector3();
8934
+ var scratchPosition = new Vector3();
8935
+ var scratchHeight = new Vector3();
8936
+ var scratchCartesian = new Vector3();
8937
+ var Ellipsoid = class {
8938
+ constructor(x = 0, y = 0, z = 0) {
8939
+ this.centerToleranceSquared = math_utils_exports.EPSILON1;
8940
+ assert(x >= 0);
8941
+ assert(y >= 0);
8942
+ assert(z >= 0);
8943
+ this.radii = new Vector3(x, y, z);
8944
+ this.radiiSquared = new Vector3(x * x, y * y, z * z);
8945
+ this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);
8946
+ this.oneOverRadii = new Vector3(x === 0 ? 0 : 1 / x, y === 0 ? 0 : 1 / y, z === 0 ? 0 : 1 / z);
8947
+ this.oneOverRadiiSquared = new Vector3(x === 0 ? 0 : 1 / (x * x), y === 0 ? 0 : 1 / (y * y), z === 0 ? 0 : 1 / (z * z));
8948
+ this.minimumRadius = Math.min(x, y, z);
8949
+ this.maximumRadius = Math.max(x, y, z);
8950
+ if (this.radiiSquared.z !== 0) {
8951
+ this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
8952
+ }
8953
+ Object.freeze(this);
8848
8954
  }
8849
- set x(value) {
8850
- this[0] = checkNumber(value);
8955
+ /** Compares this Ellipsoid against the provided Ellipsoid componentwise */
8956
+ equals(right) {
8957
+ return this === right || Boolean(right && this.radii.equals(right.radii));
8851
8958
  }
8852
- get y() {
8853
- return this[1];
8959
+ /** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */
8960
+ toString() {
8961
+ return this.radii.toString();
8854
8962
  }
8855
- set y(value) {
8856
- this[1] = checkNumber(value);
8963
+ cartographicToCartesian(cartographic, result = [0, 0, 0]) {
8964
+ const normal = scratchNormal;
8965
+ const k = scratchK;
8966
+ const [, , height] = cartographic;
8967
+ this.geodeticSurfaceNormalCartographic(cartographic, normal);
8968
+ k.copy(this.radiiSquared).scale(normal);
8969
+ const gamma = Math.sqrt(normal.dot(k));
8970
+ k.scale(1 / gamma);
8971
+ normal.scale(height);
8972
+ k.add(normal);
8973
+ return k.to(result);
8857
8974
  }
8858
- get z() {
8859
- return this[2];
8975
+ cartesianToCartographic(cartesian, result = [0, 0, 0]) {
8976
+ scratchCartesian.from(cartesian);
8977
+ const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
8978
+ if (!point) {
8979
+ return void 0;
8980
+ }
8981
+ const normal = this.geodeticSurfaceNormal(point, scratchNormal);
8982
+ const h = scratchHeight;
8983
+ h.copy(scratchCartesian).subtract(point);
8984
+ const longitude = Math.atan2(normal.y, normal.x);
8985
+ const latitude = Math.asin(normal.z);
8986
+ const height = Math.sign(vec3_exports.dot(h, scratchCartesian)) * vec3_exports.length(h);
8987
+ return toCartographicFromRadians([longitude, latitude, height], result);
8860
8988
  }
8861
- set z(value) {
8862
- this[2] = checkNumber(value);
8989
+ eastNorthUpToFixedFrame(origin, result = new Matrix4()) {
8990
+ return localFrameToFixedFrame(this, "east", "north", "up", origin, result);
8863
8991
  }
8864
- get w() {
8865
- return this[3];
8992
+ // Computes a 4x4 transformation matrix from a reference frame centered at
8993
+ // the provided origin to the ellipsoid's fixed reference frame.
8994
+ localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {
8995
+ return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);
8866
8996
  }
8867
- set w(value) {
8868
- this[3] = checkNumber(value);
8997
+ geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {
8998
+ return scratchVector5.from(cartesian).normalize().to(result);
8869
8999
  }
8870
- // Calculates the length of a quat
8871
- len() {
8872
- return length3(this);
9000
+ geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {
9001
+ const cartographicVectorRadians = fromCartographicToRadians(cartographic);
9002
+ const longitude = cartographicVectorRadians[0];
9003
+ const latitude = cartographicVectorRadians[1];
9004
+ const cosLatitude = Math.cos(latitude);
9005
+ scratchVector5.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
9006
+ return scratchVector5.to(result);
8873
9007
  }
8874
- // Calculates the squared length of a quat
8875
- lengthSquared() {
8876
- return squaredLength3(this);
9008
+ geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
9009
+ return scratchVector5.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
8877
9010
  }
8878
- // Calculates the dot product of two quat's
8879
- // @return {Number}
8880
- dot(a) {
8881
- return dot3(this, a);
9011
+ /** Scales the provided Cartesian position along the geodetic surface normal
9012
+ * so that it is on the surface of this ellipsoid. If the position is
9013
+ * at the center of the ellipsoid, this function returns undefined. */
9014
+ scaleToGeodeticSurface(cartesian, result) {
9015
+ return scaleToGeodeticSurface(cartesian, this, result);
8882
9016
  }
8883
- // Gets the rotation axis and angle for a given quaternion.
8884
- // If a quaternion is created with setAxisAngle, this method will
8885
- // return the same values as providied in the original parameter
8886
- // list OR functionally equivalent values.
8887
- // Example: The quaternion formed by axis [0, 0, 1] and angle -90
8888
- // is the same as the quaternion formed by [0, 0, 1] and 270.
8889
- // This method favors the latter.
8890
- // @return {{[x,y,z], Number}}
8891
- // getAxisAngle() {
8892
- // const axis = [];
8893
- // // const angle = quat_getAxisAngle(axis, this);
8894
- // return {axis, angle};
8895
- // }
8896
- // MODIFIERS
8897
- // Sets a quaternion to represent the shortest rotation from one vector
8898
- // to another. Both vectors are assumed to be unit length.
8899
- rotationTo(vectorA, vectorB) {
8900
- rotationTo(this, vectorA, vectorB);
8901
- return this.check();
9017
+ /** Scales the provided Cartesian position along the geocentric surface normal
9018
+ * so that it is on the surface of this ellipsoid. */
9019
+ scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {
9020
+ scratchPosition.from(cartesian);
9021
+ const positionX = scratchPosition.x;
9022
+ const positionY = scratchPosition.y;
9023
+ const positionZ = scratchPosition.z;
9024
+ const oneOverRadiiSquared = this.oneOverRadiiSquared;
9025
+ const beta = 1 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
9026
+ return scratchPosition.multiplyScalar(beta).to(result);
8902
9027
  }
8903
- // Sets the specified quaternion with values corresponding to the given axes.
8904
- // Each axis is a vec3 and is expected to be unit length and perpendicular
8905
- // to all other specified axes.
8906
- // setAxes() {
8907
- // Number
8908
- // }
8909
- // Performs a spherical linear interpolation with two control points
8910
- // sqlerp() {
8911
- // Number;
8912
- // }
8913
- // Adds two quat's
8914
- add(a) {
8915
- add4(this, this, a);
8916
- return this.check();
9028
+ /** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
9029
+ * its components by the result of `Ellipsoid#oneOverRadii` */
9030
+ transformPositionToScaledSpace(position, result = [0, 0, 0]) {
9031
+ return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
8917
9032
  }
8918
- // Calculates the W component of a quat from the X, Y, and Z components.
8919
- // Any existing W component will be ignored.
8920
- calculateW() {
8921
- calculateW(this, this);
8922
- return this.check();
9033
+ /** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
9034
+ * its components by the result of `Ellipsoid#radii`. */
9035
+ transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
9036
+ return scratchPosition.from(position).scale(this.radii).to(result);
8923
9037
  }
8924
- // Calculates the conjugate of a quat If the quaternion is normalized,
8925
- // this function is faster than quat_invert and produces the same result.
8926
- conjugate() {
8927
- conjugate(this, this);
8928
- return this.check();
9038
+ /** Computes a point which is the intersection of the surface normal with the z-axis. */
9039
+ getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
9040
+ assert(equals(this.radii.x, this.radii.y, math_utils_exports.EPSILON15));
9041
+ assert(this.radii.z > 0);
9042
+ scratchPosition.from(position);
9043
+ const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);
9044
+ if (Math.abs(z) >= this.radii.z - buffer) {
9045
+ return void 0;
9046
+ }
9047
+ return scratchPosition.set(0, 0, z).to(result);
8929
9048
  }
8930
- // Calculates the inverse of a quat
8931
- invert() {
8932
- invert3(this, this);
8933
- return this.check();
9049
+ };
9050
+ Ellipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
9051
+
9052
+ // ../loader-utils/src/loader-types.ts
9053
+ async function parseFromContext(data, loaders, options, context) {
9054
+ return context._parse(data, loaders, options, context);
9055
+ }
9056
+
9057
+ // ../loader-utils/src/lib/env-utils/assert.ts
9058
+ function assert2(condition, message) {
9059
+ if (!condition) {
9060
+ throw new Error(message || "loader assertion failed.");
8934
9061
  }
8935
- // Performs a linear interpolation between two quat's
8936
- lerp(a, b, t) {
8937
- if (t === void 0) {
8938
- return this.lerp(this, a, b);
9062
+ }
9063
+
9064
+ // ../loader-utils/src/lib/env-utils/globals.ts
9065
+ var globals = {
9066
+ self: typeof self !== "undefined" && self,
9067
+ window: typeof window !== "undefined" && window,
9068
+ global: typeof global !== "undefined" && global,
9069
+ document: typeof document !== "undefined" && document
9070
+ };
9071
+ var self_ = globals.self || globals.window || globals.global || {};
9072
+ var window_ = globals.window || globals.self || globals.global || {};
9073
+ var global_ = globals.global || globals.self || globals.window || {};
9074
+ var document_ = globals.document || {};
9075
+ var isBrowser = (
9076
+ // @ts-ignore process does not exist on browser
9077
+ Boolean(typeof process !== "object" || String(process) !== "[object process]" || process.browser)
9078
+ );
9079
+ var matches = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
9080
+ var nodeVersion = matches && parseFloat(matches[1]) || 0;
9081
+
9082
+ // ../loader-utils/src/lib/module-utils/js-module-utils.ts
9083
+ function registerJSModules(modules) {
9084
+ globalThis.loaders ||= {};
9085
+ globalThis.loaders.modules ||= {};
9086
+ Object.assign(globalThis.loaders.modules, modules);
9087
+ }
9088
+ function getJSModuleOrNull(name) {
9089
+ const module = globalThis.loaders?.modules?.[name];
9090
+ return module || null;
9091
+ }
9092
+
9093
+ // ../worker-utils/src/lib/npm-tag.ts
9094
+ var NPM_TAG = "beta";
9095
+
9096
+ // ../worker-utils/src/lib/env-utils/version.ts
9097
+ function getVersion() {
9098
+ if (!globalThis._loadersgl_?.version) {
9099
+ globalThis._loadersgl_ = globalThis._loadersgl_ || {};
9100
+ if (typeof __VERSION__ === "undefined") {
9101
+ console.warn(
9102
+ "loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN."
9103
+ );
9104
+ globalThis._loadersgl_.version = NPM_TAG;
9105
+ } else {
9106
+ globalThis._loadersgl_.version = __VERSION__;
8939
9107
  }
8940
- lerp3(this, a, b, t);
8941
- return this.check();
8942
9108
  }
8943
- // Multiplies two quat's
8944
- multiplyRight(a) {
8945
- multiply4(this, this, a);
8946
- return this.check();
9109
+ return globalThis._loadersgl_.version;
9110
+ }
9111
+ var VERSION = getVersion();
9112
+
9113
+ // ../worker-utils/src/lib/env-utils/assert.ts
9114
+ function assert3(condition, message) {
9115
+ if (!condition) {
9116
+ throw new Error(message || "loaders.gl assertion failed.");
9117
+ }
9118
+ }
9119
+
9120
+ // ../worker-utils/src/lib/env-utils/globals.ts
9121
+ var globals2 = {
9122
+ self: typeof self !== "undefined" && self,
9123
+ window: typeof window !== "undefined" && window,
9124
+ global: typeof global !== "undefined" && global,
9125
+ document: typeof document !== "undefined" && document
9126
+ };
9127
+ var self_2 = globals2.self || globals2.window || globals2.global || {};
9128
+ var window_2 = globals2.window || globals2.self || globals2.global || {};
9129
+ var global_2 = globals2.global || globals2.self || globals2.window || {};
9130
+ var document_2 = globals2.document || {};
9131
+ var isBrowser2 = (
9132
+ // @ts-ignore process.browser
9133
+ typeof process !== "object" || String(process) !== "[object process]" || process.browser
9134
+ );
9135
+ var isWorker = typeof importScripts === "function";
9136
+ var isMobile = typeof window !== "undefined" && typeof window.orientation !== "undefined";
9137
+ var matches2 = typeof process !== "undefined" && process.version && /v([0-9]*)/.exec(process.version);
9138
+ var nodeVersion2 = matches2 && parseFloat(matches2[1]) || 0;
9139
+
9140
+ // ../worker-utils/src/lib/library-utils/library-utils.ts
9141
+ var loadLibraryPromises = {};
9142
+ async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
9143
+ if (moduleName) {
9144
+ libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
8947
9145
  }
8948
- multiplyLeft(a) {
8949
- multiply4(this, a, this);
8950
- return this.check();
9146
+ loadLibraryPromises[libraryUrl] = // eslint-disable-next-line @typescript-eslint/no-misused-promises
9147
+ loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
9148
+ return await loadLibraryPromises[libraryUrl];
9149
+ }
9150
+ function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
9151
+ if (!options.useLocalLibraries && library.startsWith("http")) {
9152
+ return library;
8951
9153
  }
8952
- // Normalize a quat
8953
- normalize() {
8954
- const length4 = this.len();
8955
- const l = length4 > 0 ? 1 / length4 : 0;
8956
- this[0] = this[0] * l;
8957
- this[1] = this[1] * l;
8958
- this[2] = this[2] * l;
8959
- this[3] = this[3] * l;
8960
- if (length4 === 0) {
8961
- this[3] = 1;
8962
- }
8963
- return this.check();
9154
+ libraryName = libraryName || library;
9155
+ const modules = options.modules || {};
9156
+ if (modules[libraryName]) {
9157
+ return modules[libraryName];
8964
9158
  }
8965
- // Rotates a quaternion by the given angle about the X axis
8966
- rotateX(rad) {
8967
- rotateX3(this, this, rad);
8968
- return this.check();
9159
+ if (!isBrowser2) {
9160
+ return `modules/${moduleName}/dist/libs/${libraryName}`;
8969
9161
  }
8970
- // Rotates a quaternion by the given angle about the Y axis
8971
- rotateY(rad) {
8972
- rotateY3(this, this, rad);
8973
- return this.check();
9162
+ if (options.CDN) {
9163
+ assert3(options.CDN.startsWith("http"));
9164
+ return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
8974
9165
  }
8975
- // Rotates a quaternion by the given angle about the Z axis
8976
- rotateZ(rad) {
8977
- rotateZ3(this, this, rad);
8978
- return this.check();
9166
+ if (isWorker) {
9167
+ return `../src/libs/${libraryName}`;
8979
9168
  }
8980
- // Scales a quat by a scalar number
8981
- scale(b) {
8982
- scale5(this, this, b);
8983
- return this.check();
9169
+ return `modules/${moduleName}/src/libs/${libraryName}`;
9170
+ }
9171
+ async function loadLibraryFromFile(libraryUrl) {
9172
+ if (libraryUrl.endsWith("wasm")) {
9173
+ return await loadAsArrayBuffer(libraryUrl);
8984
9174
  }
8985
- // Performs a spherical linear interpolation between two quat
8986
- slerp(arg0, arg1, arg2) {
8987
- let start;
8988
- let target;
8989
- let ratio;
8990
- switch (arguments.length) {
8991
- case 1:
8992
- ({
8993
- start = IDENTITY_QUATERNION,
8994
- target,
8995
- ratio
8996
- } = arg0);
8997
- break;
8998
- case 2:
8999
- start = this;
9000
- target = arg0;
9001
- ratio = arg1;
9002
- break;
9003
- default:
9004
- start = arg0;
9005
- target = arg1;
9006
- ratio = arg2;
9175
+ if (!isBrowser2) {
9176
+ try {
9177
+ const { requireFromFile } = globalThis.loaders || {};
9178
+ return await requireFromFile?.(libraryUrl);
9179
+ } catch (error) {
9180
+ console.error(error);
9181
+ return null;
9007
9182
  }
9008
- slerp2(this, start, target, ratio);
9009
- return this.check();
9010
9183
  }
9011
- transformVector4(vector, result = new Vector4()) {
9012
- transformQuat2(result, vector, this);
9013
- return checkVector(result, 4);
9184
+ if (isWorker) {
9185
+ return importScripts(libraryUrl);
9014
9186
  }
9015
- // THREE.js Math API compatibility
9016
- lengthSq() {
9017
- return this.lengthSquared();
9187
+ const scriptSource = await loadAsText(libraryUrl);
9188
+ return loadLibraryFromString(scriptSource, libraryUrl);
9189
+ }
9190
+ function loadLibraryFromString(scriptSource, id) {
9191
+ if (!isBrowser2) {
9192
+ const { requireFromString } = globalThis.loaders || {};
9193
+ return requireFromString?.(scriptSource, id);
9018
9194
  }
9019
- setFromAxisAngle(axis, rad) {
9020
- return this.setAxisAngle(axis, rad);
9195
+ if (isWorker) {
9196
+ eval.call(globalThis, scriptSource);
9197
+ return null;
9021
9198
  }
9022
- premultiply(a) {
9023
- return this.multiplyLeft(a);
9199
+ const script = document.createElement("script");
9200
+ script.id = id;
9201
+ try {
9202
+ script.appendChild(document.createTextNode(scriptSource));
9203
+ } catch (e) {
9204
+ script.text = scriptSource;
9024
9205
  }
9025
- multiply(a) {
9026
- return this.multiplyRight(a);
9206
+ document.body.appendChild(script);
9207
+ return null;
9208
+ }
9209
+ async function loadAsArrayBuffer(url) {
9210
+ const { readFileAsArrayBuffer } = globalThis.loaders || {};
9211
+ if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
9212
+ const response = await fetch(url);
9213
+ return await response.arrayBuffer();
9027
9214
  }
9028
- };
9029
-
9030
- // ../../node_modules/@math.gl/core/dist/lib/math-utils.js
9031
- var math_utils_exports = {};
9032
- __export(math_utils_exports, {
9033
- EPSILON1: () => EPSILON1,
9034
- EPSILON10: () => EPSILON10,
9035
- EPSILON11: () => EPSILON11,
9036
- EPSILON12: () => EPSILON12,
9037
- EPSILON13: () => EPSILON13,
9038
- EPSILON14: () => EPSILON14,
9039
- EPSILON15: () => EPSILON15,
9040
- EPSILON16: () => EPSILON16,
9041
- EPSILON17: () => EPSILON17,
9042
- EPSILON18: () => EPSILON18,
9043
- EPSILON19: () => EPSILON19,
9044
- EPSILON2: () => EPSILON2,
9045
- EPSILON20: () => EPSILON20,
9046
- EPSILON3: () => EPSILON3,
9047
- EPSILON4: () => EPSILON4,
9048
- EPSILON5: () => EPSILON5,
9049
- EPSILON6: () => EPSILON6,
9050
- EPSILON7: () => EPSILON7,
9051
- EPSILON8: () => EPSILON8,
9052
- EPSILON9: () => EPSILON9,
9053
- PI_OVER_FOUR: () => PI_OVER_FOUR,
9054
- PI_OVER_SIX: () => PI_OVER_SIX,
9055
- PI_OVER_TWO: () => PI_OVER_TWO,
9056
- TWO_PI: () => TWO_PI
9057
- });
9058
- var EPSILON1 = 0.1;
9059
- var EPSILON2 = 0.01;
9060
- var EPSILON3 = 1e-3;
9061
- var EPSILON4 = 1e-4;
9062
- var EPSILON5 = 1e-5;
9063
- var EPSILON6 = 1e-6;
9064
- var EPSILON7 = 1e-7;
9065
- var EPSILON8 = 1e-8;
9066
- var EPSILON9 = 1e-9;
9067
- var EPSILON10 = 1e-10;
9068
- var EPSILON11 = 1e-11;
9069
- var EPSILON12 = 1e-12;
9070
- var EPSILON13 = 1e-13;
9071
- var EPSILON14 = 1e-14;
9072
- var EPSILON15 = 1e-15;
9073
- var EPSILON16 = 1e-16;
9074
- var EPSILON17 = 1e-17;
9075
- var EPSILON18 = 1e-18;
9076
- var EPSILON19 = 1e-19;
9077
- var EPSILON20 = 1e-20;
9078
- var PI_OVER_TWO = Math.PI / 2;
9079
- var PI_OVER_FOUR = Math.PI / 4;
9080
- var PI_OVER_SIX = Math.PI / 6;
9081
- var TWO_PI = Math.PI * 2;
9082
-
9083
- // src/lib/parsers/constants.ts
9084
- function getConstructorForDataFormat(dataType) {
9085
- switch (dataType) {
9086
- case "UInt8":
9087
- return Uint8Array;
9088
- case "UInt16":
9089
- return Uint16Array;
9090
- case "UInt32":
9091
- return Uint32Array;
9092
- case "Float32":
9093
- return Float32Array;
9094
- case "UInt64":
9095
- return Float64Array;
9096
- default:
9097
- throw new Error(`parse i3s tile content: unknown type of data: ${dataType}`);
9215
+ return await readFileAsArrayBuffer(url);
9216
+ }
9217
+ async function loadAsText(url) {
9218
+ const { readFileAsText } = globalThis.loaders || {};
9219
+ if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
9220
+ const response = await fetch(url);
9221
+ return await response.text();
9098
9222
  }
9223
+ return await readFileAsText(url);
9099
9224
  }
9100
- var GL_TYPE_MAP = {
9101
- UInt8: GL.UNSIGNED_BYTE,
9102
- UInt16: GL.UNSIGNED_SHORT,
9103
- Float32: GL.FLOAT,
9104
- UInt32: GL.UNSIGNED_INT,
9105
- UInt64: GL.DOUBLE
9106
- };
9107
- function sizeOf(dataType) {
9108
- switch (dataType) {
9109
- case "UInt8":
9110
- return 1;
9111
- case "UInt16":
9112
- case "Int16":
9113
- return 2;
9114
- case "UInt32":
9115
- case "Int32":
9116
- case "Float32":
9117
- return 4;
9118
- case "UInt64":
9119
- case "Int64":
9120
- case "Float64":
9121
- return 8;
9122
- default:
9123
- throw new Error(`parse i3s tile content: unknown size of data: ${dataType}`);
9225
+
9226
+ // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
9227
+ function compareArrayBuffers(arrayBuffer1, arrayBuffer2, byteLength) {
9228
+ byteLength = byteLength || arrayBuffer1.byteLength;
9229
+ if (arrayBuffer1.byteLength < byteLength || arrayBuffer2.byteLength < byteLength) {
9230
+ return false;
9231
+ }
9232
+ const array1 = new Uint8Array(arrayBuffer1);
9233
+ const array2 = new Uint8Array(arrayBuffer2);
9234
+ for (let i = 0; i < array1.length; ++i) {
9235
+ if (array1[i] !== array2[i]) {
9236
+ return false;
9237
+ }
9238
+ }
9239
+ return true;
9240
+ }
9241
+ function concatenateArrayBuffers(...sources) {
9242
+ return concatenateArrayBuffersFromArray(sources);
9243
+ }
9244
+ function concatenateArrayBuffersFromArray(sources) {
9245
+ const sourceArrays = sources.map(
9246
+ (source2) => source2 instanceof ArrayBuffer ? new Uint8Array(source2) : source2
9247
+ );
9248
+ const byteLength = sourceArrays.reduce((length4, typedArray) => length4 + typedArray.byteLength, 0);
9249
+ const result = new Uint8Array(byteLength);
9250
+ let offset = 0;
9251
+ for (const sourceArray of sourceArrays) {
9252
+ result.set(sourceArray, offset);
9253
+ offset += sourceArray.byteLength;
9124
9254
  }
9255
+ return result.buffer;
9125
9256
  }
9126
- var STRING_ATTRIBUTE_TYPE = "String";
9127
- var OBJECT_ID_ATTRIBUTE_TYPE = "Oid32";
9128
- var FLOAT_64_TYPE = "Float64";
9129
- var INT_16_ATTRIBUTE_TYPE = "Int16";
9130
- var COORDINATE_SYSTEM = /* @__PURE__ */ ((COORDINATE_SYSTEM2) => {
9131
- COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["DEFAULT"] = -1] = "DEFAULT";
9132
- COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["LNGLAT"] = 1] = "LNGLAT";
9133
- COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["METER_OFFSETS"] = 2] = "METER_OFFSETS";
9134
- COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["LNGLAT_OFFSETS"] = 3] = "LNGLAT_OFFSETS";
9135
- COORDINATE_SYSTEM2[COORDINATE_SYSTEM2["CARTESIAN"] = 0] = "CARTESIAN";
9136
- return COORDINATE_SYSTEM2;
9137
- })(COORDINATE_SYSTEM || {});
9138
-
9139
- // src/i3s-loader.ts
9140
- var import_core18 = __toESM(require_core(), 1);
9141
9257
 
9142
- // src/lib/parsers/parse-i3s-tile-content.ts
9143
- var import_core5 = __toESM(require_core(), 1);
9258
+ // ../loader-utils/src/lib/iterators/async-iteration.ts
9259
+ async function concatenateArrayBuffersAsync(asyncIterator) {
9260
+ const arrayBuffers = [];
9261
+ for await (const chunk of asyncIterator) {
9262
+ arrayBuffers.push(chunk);
9263
+ }
9264
+ return concatenateArrayBuffers(...arrayBuffers);
9265
+ }
9144
9266
 
9145
- // ../../node_modules/@math.gl/geospatial/dist/constants.js
9146
- var WGS84_RADIUS_X = 6378137;
9147
- var WGS84_RADIUS_Y = 6378137;
9148
- var WGS84_RADIUS_Z = 6356752314245179e-9;
9149
- var WGS84_CONSTANTS = {
9150
- radii: [WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z],
9151
- radiiSquared: [
9152
- WGS84_RADIUS_X * WGS84_RADIUS_X,
9153
- WGS84_RADIUS_Y * WGS84_RADIUS_Y,
9154
- WGS84_RADIUS_Z * WGS84_RADIUS_Z
9155
- ],
9156
- oneOverRadii: [1 / WGS84_RADIUS_X, 1 / WGS84_RADIUS_Y, 1 / WGS84_RADIUS_Z],
9157
- oneOverRadiiSquared: [
9158
- 1 / (WGS84_RADIUS_X * WGS84_RADIUS_X),
9159
- 1 / (WGS84_RADIUS_Y * WGS84_RADIUS_Y),
9160
- 1 / (WGS84_RADIUS_Z * WGS84_RADIUS_Z)
9161
- ],
9162
- maximumRadius: Math.max(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z),
9163
- centerToleranceSquared: 0.1
9164
- // EPSILON1;
9165
- };
9267
+ // ../loader-utils/src/lib/node/buffer.browser.ts
9268
+ function toArrayBuffer(buffer) {
9269
+ return buffer;
9270
+ }
9166
9271
 
9167
- // ../../node_modules/@math.gl/geospatial/dist/type-utils.js
9168
- function identity3(x) {
9169
- return x;
9272
+ // ../loader-utils/src/lib/binary-utils/memory-conversion-utils.ts
9273
+ function isBuffer(value) {
9274
+ return value && typeof value === "object" && value.isBuffer;
9170
9275
  }
9171
- var scratchVector = new Vector3();
9172
- function fromCartographic(cartographic, result = [], map2 = identity3) {
9173
- if ("longitude" in cartographic) {
9174
- result[0] = map2(cartographic.longitude);
9175
- result[1] = map2(cartographic.latitude);
9176
- result[2] = cartographic.height;
9177
- } else if ("x" in cartographic) {
9178
- result[0] = map2(cartographic.x);
9179
- result[1] = map2(cartographic.y);
9180
- result[2] = cartographic.z;
9181
- } else {
9182
- result[0] = map2(cartographic[0]);
9183
- result[1] = map2(cartographic[1]);
9184
- result[2] = cartographic[2];
9276
+ function toArrayBuffer2(data) {
9277
+ if (isBuffer(data)) {
9278
+ return toArrayBuffer(data);
9185
9279
  }
9186
- return result;
9187
- }
9188
- function fromCartographicToRadians(cartographic, vector = []) {
9189
- return fromCartographic(cartographic, vector, config._cartographicRadians ? identity3 : toRadians);
9190
- }
9191
- function toCartographic(vector, cartographic, map2 = identity3) {
9192
- if ("longitude" in cartographic) {
9193
- cartographic.longitude = map2(vector[0]);
9194
- cartographic.latitude = map2(vector[1]);
9195
- cartographic.height = vector[2];
9196
- } else if ("x" in cartographic) {
9197
- cartographic.x = map2(vector[0]);
9198
- cartographic.y = map2(vector[1]);
9199
- cartographic.z = vector[2];
9200
- } else {
9201
- cartographic[0] = map2(vector[0]);
9202
- cartographic[1] = map2(vector[1]);
9203
- cartographic[2] = vector[2];
9280
+ if (data instanceof ArrayBuffer) {
9281
+ return data;
9204
9282
  }
9205
- return cartographic;
9283
+ if (ArrayBuffer.isView(data)) {
9284
+ if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
9285
+ return data.buffer;
9286
+ }
9287
+ return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
9288
+ }
9289
+ if (typeof data === "string") {
9290
+ const text = data;
9291
+ const uint8Array = new TextEncoder().encode(text);
9292
+ return uint8Array.buffer;
9293
+ }
9294
+ if (data && typeof data === "object" && data._toArrayBuffer) {
9295
+ return data._toArrayBuffer();
9296
+ }
9297
+ throw new Error("toArrayBuffer");
9206
9298
  }
9207
- function toCartographicFromRadians(vector, cartographic) {
9208
- return toCartographic(vector, cartographic, config._cartographicRadians ? identity3 : toDegrees);
9299
+
9300
+ // ../loader-utils/src/lib/node/promisify.ts
9301
+ function promisify1(fn) {
9302
+ return (args) => new Promise(
9303
+ (resolve, reject) => fn(args, (error, callbackArgs) => error ? reject(error) : resolve(callbackArgs))
9304
+ );
9209
9305
  }
9210
9306
 
9211
- // ../../node_modules/@math.gl/geospatial/dist/ellipsoid/helpers/ellipsoid-transform.js
9212
- var EPSILON142 = 1e-14;
9213
- var scratchOrigin = new Vector3();
9214
- var VECTOR_PRODUCT_LOCAL_FRAME = {
9215
- up: {
9216
- south: "east",
9217
- north: "west",
9218
- west: "south",
9219
- east: "north"
9220
- },
9221
- down: {
9222
- south: "west",
9223
- north: "east",
9224
- west: "north",
9225
- east: "south"
9226
- },
9227
- south: {
9228
- up: "west",
9229
- down: "east",
9230
- west: "down",
9231
- east: "up"
9232
- },
9233
- north: {
9234
- up: "east",
9235
- down: "west",
9236
- west: "up",
9237
- east: "down"
9238
- },
9239
- west: {
9240
- up: "north",
9241
- down: "south",
9242
- north: "down",
9243
- south: "up"
9244
- },
9245
- east: {
9246
- up: "south",
9247
- down: "north",
9248
- north: "up",
9249
- south: "down"
9250
- }
9251
- };
9252
- var degeneratePositionLocalFrame = {
9253
- north: [-1, 0, 0],
9254
- east: [0, 1, 0],
9255
- up: [0, 0, 1],
9256
- south: [1, 0, 0],
9257
- west: [0, -1, 0],
9258
- down: [0, 0, -1]
9259
- };
9260
- var scratchAxisVectors = {
9261
- east: new Vector3(),
9262
- north: new Vector3(),
9263
- up: new Vector3(),
9264
- west: new Vector3(),
9265
- south: new Vector3(),
9266
- down: new Vector3()
9267
- };
9268
- var scratchVector1 = new Vector3();
9269
- var scratchVector2 = new Vector3();
9270
- var scratchVector3 = new Vector3();
9271
- function localFrameToFixedFrame(ellipsoid, firstAxis, secondAxis, thirdAxis, cartesianOrigin, result) {
9272
- const thirdAxisInferred = VECTOR_PRODUCT_LOCAL_FRAME[firstAxis] && VECTOR_PRODUCT_LOCAL_FRAME[firstAxis][secondAxis];
9273
- assert3(thirdAxisInferred && (!thirdAxis || thirdAxis === thirdAxisInferred));
9274
- let firstAxisVector;
9275
- let secondAxisVector;
9276
- let thirdAxisVector;
9277
- const origin = scratchOrigin.copy(cartesianOrigin);
9278
- const atPole = equals(origin.x, 0, EPSILON142) && equals(origin.y, 0, EPSILON142);
9279
- if (atPole) {
9280
- const sign = Math.sign(origin.z);
9281
- firstAxisVector = scratchVector1.fromArray(degeneratePositionLocalFrame[firstAxis]);
9282
- if (firstAxis !== "east" && firstAxis !== "west") {
9283
- firstAxisVector.scale(sign);
9284
- }
9285
- secondAxisVector = scratchVector2.fromArray(degeneratePositionLocalFrame[secondAxis]);
9286
- if (secondAxis !== "east" && secondAxis !== "west") {
9287
- secondAxisVector.scale(sign);
9307
+ // ../loader-utils/src/lib/files/node-file-facade.ts
9308
+ var NOT_IMPLEMENTED = new Error("Not implemented");
9309
+ var NodeFileFacade = class {
9310
+ handle;
9311
+ size = 0;
9312
+ bigsize = 0n;
9313
+ url = "";
9314
+ constructor(url, flags, mode) {
9315
+ if (globalThis.loaders?.NodeFile) {
9316
+ return new globalThis.loaders.NodeFile(url, flags, mode);
9288
9317
  }
9289
- thirdAxisVector = scratchVector3.fromArray(degeneratePositionLocalFrame[thirdAxis]);
9290
- if (thirdAxis !== "east" && thirdAxis !== "west") {
9291
- thirdAxisVector.scale(sign);
9318
+ if (isBrowser) {
9319
+ throw new Error("Can't instantiate NodeFile in browser.");
9292
9320
  }
9293
- } else {
9294
- const { up, east, north } = scratchAxisVectors;
9295
- east.set(-origin.y, origin.x, 0).normalize();
9296
- ellipsoid.geodeticSurfaceNormal(origin, up);
9297
- north.copy(up).cross(east);
9298
- const { down, west, south } = scratchAxisVectors;
9299
- down.copy(up).scale(-1);
9300
- west.copy(east).scale(-1);
9301
- south.copy(north).scale(-1);
9302
- firstAxisVector = scratchAxisVectors[firstAxis];
9303
- secondAxisVector = scratchAxisVectors[secondAxis];
9304
- thirdAxisVector = scratchAxisVectors[thirdAxis];
9321
+ throw new Error("Can't instantiate NodeFile. Make sure to import @loaders.gl/polyfills first.");
9322
+ }
9323
+ /** Read data */
9324
+ async read(start, length4) {
9325
+ throw NOT_IMPLEMENTED;
9326
+ }
9327
+ /** Write to file. The number of bytes written will be returned */
9328
+ async write(arrayBuffer, offset, length4) {
9329
+ throw NOT_IMPLEMENTED;
9330
+ }
9331
+ /** Get information about file */
9332
+ async stat() {
9333
+ throw NOT_IMPLEMENTED;
9334
+ }
9335
+ /** Truncates the file descriptor. Only available on NodeFile. */
9336
+ async truncate(length4) {
9337
+ throw NOT_IMPLEMENTED;
9338
+ }
9339
+ /** Append data to a file. Only available on NodeFile. */
9340
+ async append(data) {
9341
+ throw NOT_IMPLEMENTED;
9342
+ }
9343
+ /** Close the file */
9344
+ async close() {
9305
9345
  }
9306
- result[0] = firstAxisVector.x;
9307
- result[1] = firstAxisVector.y;
9308
- result[2] = firstAxisVector.z;
9309
- result[3] = 0;
9310
- result[4] = secondAxisVector.x;
9311
- result[5] = secondAxisVector.y;
9312
- result[6] = secondAxisVector.z;
9313
- result[7] = 0;
9314
- result[8] = thirdAxisVector.x;
9315
- result[9] = thirdAxisVector.y;
9316
- result[10] = thirdAxisVector.z;
9317
- result[11] = 0;
9318
- result[12] = origin.x;
9319
- result[13] = origin.y;
9320
- result[14] = origin.z;
9321
- result[15] = 1;
9322
- return result;
9323
- }
9346
+ };
9324
9347
 
9325
- // ../../node_modules/@math.gl/geospatial/dist/ellipsoid/helpers/scale-to-geodetic-surface.js
9326
- var scratchVector4 = new Vector3();
9327
- var scaleToGeodeticSurfaceIntersection = new Vector3();
9328
- var scaleToGeodeticSurfaceGradient = new Vector3();
9329
- function scaleToGeodeticSurface(cartesian, ellipsoid, result = []) {
9330
- const { oneOverRadii, oneOverRadiiSquared, centerToleranceSquared } = ellipsoid;
9331
- scratchVector4.from(cartesian);
9332
- const positionX = scratchVector4.x;
9333
- const positionY = scratchVector4.y;
9334
- const positionZ = scratchVector4.z;
9335
- const oneOverRadiiX = oneOverRadii.x;
9336
- const oneOverRadiiY = oneOverRadii.y;
9337
- const oneOverRadiiZ = oneOverRadii.z;
9338
- const x2 = positionX * positionX * oneOverRadiiX * oneOverRadiiX;
9339
- const y2 = positionY * positionY * oneOverRadiiY * oneOverRadiiY;
9340
- const z2 = positionZ * positionZ * oneOverRadiiZ * oneOverRadiiZ;
9341
- const squaredNorm = x2 + y2 + z2;
9342
- const ratio = Math.sqrt(1 / squaredNorm);
9343
- if (!Number.isFinite(ratio)) {
9344
- return void 0;
9348
+ // ../loader-utils/src/lib/file-provider/file-provider-interface.ts
9349
+ var isFileProvider = (fileProvider) => {
9350
+ return fileProvider?.getUint8 && fileProvider?.slice && fileProvider?.length;
9351
+ };
9352
+
9353
+ // ../loader-utils/src/lib/file-provider/file-handle-file.ts
9354
+ var FileHandleFile = class {
9355
+ /** The FileHandle from which data is provided */
9356
+ file;
9357
+ /** Create a new FileHandleFile */
9358
+ constructor(path, append = false) {
9359
+ this.file = new NodeFileFacade(path, append ? "a+" : "r");
9345
9360
  }
9346
- const intersection = scaleToGeodeticSurfaceIntersection;
9347
- intersection.copy(cartesian).scale(ratio);
9348
- if (squaredNorm < centerToleranceSquared) {
9349
- return intersection.to(result);
9361
+ /**
9362
+ * Truncates the file descriptor.
9363
+ * @param length desired file lenght
9364
+ */
9365
+ async truncate(length4) {
9366
+ await this.file.truncate(length4);
9350
9367
  }
9351
- const oneOverRadiiSquaredX = oneOverRadiiSquared.x;
9352
- const oneOverRadiiSquaredY = oneOverRadiiSquared.y;
9353
- const oneOverRadiiSquaredZ = oneOverRadiiSquared.z;
9354
- const gradient = scaleToGeodeticSurfaceGradient;
9355
- gradient.set(intersection.x * oneOverRadiiSquaredX * 2, intersection.y * oneOverRadiiSquaredY * 2, intersection.z * oneOverRadiiSquaredZ * 2);
9356
- let lambda = (1 - ratio) * scratchVector4.len() / (0.5 * gradient.len());
9357
- let correction = 0;
9358
- let xMultiplier;
9359
- let yMultiplier;
9360
- let zMultiplier;
9361
- let func;
9362
- do {
9363
- lambda -= correction;
9364
- xMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredX);
9365
- yMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredY);
9366
- zMultiplier = 1 / (1 + lambda * oneOverRadiiSquaredZ);
9367
- const xMultiplier2 = xMultiplier * xMultiplier;
9368
- const yMultiplier2 = yMultiplier * yMultiplier;
9369
- const zMultiplier2 = zMultiplier * zMultiplier;
9370
- const xMultiplier3 = xMultiplier2 * xMultiplier;
9371
- const yMultiplier3 = yMultiplier2 * yMultiplier;
9372
- const zMultiplier3 = zMultiplier2 * zMultiplier;
9373
- func = x2 * xMultiplier2 + y2 * yMultiplier2 + z2 * zMultiplier2 - 1;
9374
- const denominator = x2 * xMultiplier3 * oneOverRadiiSquaredX + y2 * yMultiplier3 * oneOverRadiiSquaredY + z2 * zMultiplier3 * oneOverRadiiSquaredZ;
9375
- const derivative = -2 * denominator;
9376
- correction = func / derivative;
9377
- } while (Math.abs(func) > math_utils_exports.EPSILON12);
9378
- return scratchVector4.scale([xMultiplier, yMultiplier, zMultiplier]).to(result);
9379
- }
9380
-
9381
- // ../../node_modules/@math.gl/geospatial/dist/ellipsoid/ellipsoid.js
9382
- var scratchVector5 = new Vector3();
9383
- var scratchNormal = new Vector3();
9384
- var scratchK = new Vector3();
9385
- var scratchPosition = new Vector3();
9386
- var scratchHeight = new Vector3();
9387
- var scratchCartesian = new Vector3();
9388
- var Ellipsoid = class {
9389
- constructor(x = 0, y = 0, z = 0) {
9390
- this.centerToleranceSquared = math_utils_exports.EPSILON1;
9391
- assert3(x >= 0);
9392
- assert3(y >= 0);
9393
- assert3(z >= 0);
9394
- this.radii = new Vector3(x, y, z);
9395
- this.radiiSquared = new Vector3(x * x, y * y, z * z);
9396
- this.radiiToTheFourth = new Vector3(x * x * x * x, y * y * y * y, z * z * z * z);
9397
- this.oneOverRadii = new Vector3(x === 0 ? 0 : 1 / x, y === 0 ? 0 : 1 / y, z === 0 ? 0 : 1 / z);
9398
- this.oneOverRadiiSquared = new Vector3(x === 0 ? 0 : 1 / (x * x), y === 0 ? 0 : 1 / (y * y), z === 0 ? 0 : 1 / (z * z));
9399
- this.minimumRadius = Math.min(x, y, z);
9400
- this.maximumRadius = Math.max(x, y, z);
9401
- if (this.radiiSquared.z !== 0) {
9402
- this.squaredXOverSquaredZ = this.radiiSquared.x / this.radiiSquared.z;
9368
+ /**
9369
+ * Append data to a file.
9370
+ * @param buffer data to append
9371
+ */
9372
+ async append(buffer) {
9373
+ await this.file.append(buffer);
9374
+ }
9375
+ /** Close file */
9376
+ async destroy() {
9377
+ await this.file.close();
9378
+ }
9379
+ /**
9380
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
9381
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9382
+ */
9383
+ async getUint8(offset) {
9384
+ const arrayBuffer = await this.file.read(offset, 1);
9385
+ const val = new Uint8Array(arrayBuffer).at(0);
9386
+ if (val === void 0) {
9387
+ throw new Error("something went wrong");
9403
9388
  }
9404
- Object.freeze(this);
9389
+ return val;
9405
9390
  }
9406
- /** Compares this Ellipsoid against the provided Ellipsoid componentwise */
9407
- equals(right) {
9408
- return this === right || Boolean(right && this.radii.equals(right.radii));
9391
+ /**
9392
+ * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.
9393
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9394
+ */
9395
+ async getUint16(offset) {
9396
+ const arrayBuffer = await this.file.read(offset, 2);
9397
+ const val = new Uint16Array(arrayBuffer).at(0);
9398
+ if (val === void 0) {
9399
+ throw new Error("something went wrong");
9400
+ }
9401
+ return val;
9409
9402
  }
9410
- /** Creates a string representing this Ellipsoid in the format '(radii.x, radii.y, radii.z)'. */
9411
- toString() {
9412
- return this.radii.toString();
9403
+ /**
9404
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
9405
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9406
+ */
9407
+ async getUint32(offset) {
9408
+ const arrayBuffer = await this.file.read(offset, 4);
9409
+ const val = new Uint32Array(arrayBuffer).at(0);
9410
+ if (val === void 0) {
9411
+ throw new Error("something went wrong");
9412
+ }
9413
+ return val;
9413
9414
  }
9414
- cartographicToCartesian(cartographic, result = [0, 0, 0]) {
9415
- const normal = scratchNormal;
9416
- const k = scratchK;
9417
- const [, , height] = cartographic;
9418
- this.geodeticSurfaceNormalCartographic(cartographic, normal);
9419
- k.copy(this.radiiSquared).scale(normal);
9420
- const gamma = Math.sqrt(normal.dot(k));
9421
- k.scale(1 / gamma);
9422
- normal.scale(height);
9423
- k.add(normal);
9424
- return k.to(result);
9415
+ /**
9416
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
9417
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9418
+ */
9419
+ async getBigUint64(offset) {
9420
+ const arrayBuffer = await this.file.read(offset, 8);
9421
+ const val = new BigInt64Array(arrayBuffer).at(0);
9422
+ if (val === void 0) {
9423
+ throw new Error("something went wrong");
9424
+ }
9425
+ return val;
9425
9426
  }
9426
- cartesianToCartographic(cartesian, result = [0, 0, 0]) {
9427
- scratchCartesian.from(cartesian);
9428
- const point = this.scaleToGeodeticSurface(scratchCartesian, scratchPosition);
9429
- if (!point) {
9430
- return void 0;
9427
+ /**
9428
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
9429
+ * @param startOffset The offset, in byte, from the start of the file where to start reading the data.
9430
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
9431
+ */
9432
+ async slice(startOffset, endOffset) {
9433
+ const bigLength = endOffset - startOffset;
9434
+ if (bigLength > Number.MAX_SAFE_INTEGER) {
9435
+ throw new Error("too big slice");
9431
9436
  }
9432
- const normal = this.geodeticSurfaceNormal(point, scratchNormal);
9433
- const h = scratchHeight;
9434
- h.copy(scratchCartesian).subtract(point);
9435
- const longitude = Math.atan2(normal.y, normal.x);
9436
- const latitude = Math.asin(normal.z);
9437
- const height = Math.sign(vec3_exports.dot(h, scratchCartesian)) * vec3_exports.length(h);
9438
- return toCartographicFromRadians([longitude, latitude, height], result);
9437
+ const length4 = Number(bigLength);
9438
+ return await this.file.read(startOffset, length4);
9439
9439
  }
9440
- eastNorthUpToFixedFrame(origin, result = new Matrix4()) {
9441
- return localFrameToFixedFrame(this, "east", "north", "up", origin, result);
9440
+ /**
9441
+ * the length (in bytes) of the data.
9442
+ */
9443
+ get length() {
9444
+ return this.file.bigsize;
9442
9445
  }
9443
- // Computes a 4x4 transformation matrix from a reference frame centered at
9444
- // the provided origin to the ellipsoid's fixed reference frame.
9445
- localFrameToFixedFrame(firstAxis, secondAxis, thirdAxis, origin, result = new Matrix4()) {
9446
- return localFrameToFixedFrame(this, firstAxis, secondAxis, thirdAxis, origin, result);
9446
+ };
9447
+
9448
+ // ../loader-utils/src/lib/file-provider/data-view-file.ts
9449
+ var toNumber = (bigint) => {
9450
+ if (bigint > Number.MAX_SAFE_INTEGER) {
9451
+ throw new Error("Offset is out of bounds");
9447
9452
  }
9448
- geocentricSurfaceNormal(cartesian, result = [0, 0, 0]) {
9449
- return scratchVector5.from(cartesian).normalize().to(result);
9453
+ return Number(bigint);
9454
+ };
9455
+ var DataViewFile = class {
9456
+ /** The DataView from which data is provided */
9457
+ file;
9458
+ constructor(file) {
9459
+ this.file = file;
9450
9460
  }
9451
- geodeticSurfaceNormalCartographic(cartographic, result = [0, 0, 0]) {
9452
- const cartographicVectorRadians = fromCartographicToRadians(cartographic);
9453
- const longitude = cartographicVectorRadians[0];
9454
- const latitude = cartographicVectorRadians[1];
9455
- const cosLatitude = Math.cos(latitude);
9456
- scratchVector5.set(cosLatitude * Math.cos(longitude), cosLatitude * Math.sin(longitude), Math.sin(latitude)).normalize();
9457
- return scratchVector5.to(result);
9461
+ async destroy() {
9458
9462
  }
9459
- geodeticSurfaceNormal(cartesian, result = [0, 0, 0]) {
9460
- return scratchVector5.from(cartesian).scale(this.oneOverRadiiSquared).normalize().to(result);
9463
+ /**
9464
+ * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.
9465
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9466
+ */
9467
+ async getUint8(offset) {
9468
+ return this.file.getUint8(toNumber(offset));
9461
9469
  }
9462
- /** Scales the provided Cartesian position along the geodetic surface normal
9463
- * so that it is on the surface of this ellipsoid. If the position is
9464
- * at the center of the ellipsoid, this function returns undefined. */
9465
- scaleToGeodeticSurface(cartesian, result) {
9466
- return scaleToGeodeticSurface(cartesian, this, result);
9470
+ /**
9471
+ * Gets an unsigned 16-bit intege at the specified byte offset from the start of the file.
9472
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9473
+ */
9474
+ async getUint16(offset) {
9475
+ return this.file.getUint16(toNumber(offset), true);
9467
9476
  }
9468
- /** Scales the provided Cartesian position along the geocentric surface normal
9469
- * so that it is on the surface of this ellipsoid. */
9470
- scaleToGeocentricSurface(cartesian, result = [0, 0, 0]) {
9471
- scratchPosition.from(cartesian);
9472
- const positionX = scratchPosition.x;
9473
- const positionY = scratchPosition.y;
9474
- const positionZ = scratchPosition.z;
9475
- const oneOverRadiiSquared = this.oneOverRadiiSquared;
9476
- const beta = 1 / Math.sqrt(positionX * positionX * oneOverRadiiSquared.x + positionY * positionY * oneOverRadiiSquared.y + positionZ * positionZ * oneOverRadiiSquared.z);
9477
- return scratchPosition.multiplyScalar(beta).to(result);
9477
+ /**
9478
+ * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.
9479
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9480
+ */
9481
+ async getUint32(offset) {
9482
+ return this.file.getUint32(toNumber(offset), true);
9478
9483
  }
9479
- /** Transforms a Cartesian X, Y, Z position to the ellipsoid-scaled space by multiplying
9480
- * its components by the result of `Ellipsoid#oneOverRadii` */
9481
- transformPositionToScaledSpace(position, result = [0, 0, 0]) {
9482
- return scratchPosition.from(position).scale(this.oneOverRadii).to(result);
9484
+ /**
9485
+ * Gets an unsigned 64-bit integer at the specified byte offset from the start of the file.
9486
+ * @param offset The offset, in bytes, from the start of the file where to read the data.
9487
+ */
9488
+ async getBigUint64(offset) {
9489
+ return this.file.getBigUint64(toNumber(offset), true);
9483
9490
  }
9484
- /** Transforms a Cartesian X, Y, Z position from the ellipsoid-scaled space by multiplying
9485
- * its components by the result of `Ellipsoid#radii`. */
9486
- transformPositionFromScaledSpace(position, result = [0, 0, 0]) {
9487
- return scratchPosition.from(position).scale(this.radii).to(result);
9491
+ /**
9492
+ * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.
9493
+ * @param startOffset The offset, in bytes, from the start of the file where to start reading the data.
9494
+ * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.
9495
+ */
9496
+ async slice(startOffset, endOffset) {
9497
+ return this.file.buffer.slice(toNumber(startOffset), toNumber(endOffset));
9488
9498
  }
9489
- /** Computes a point which is the intersection of the surface normal with the z-axis. */
9490
- getSurfaceNormalIntersectionWithZAxis(position, buffer = 0, result = [0, 0, 0]) {
9491
- assert3(equals(this.radii.x, this.radii.y, math_utils_exports.EPSILON15));
9492
- assert3(this.radii.z > 0);
9493
- scratchPosition.from(position);
9494
- const z = scratchPosition.z * (1 - this.squaredXOverSquaredZ);
9495
- if (Math.abs(z) >= this.radii.z - buffer) {
9496
- return void 0;
9497
- }
9498
- return scratchPosition.set(0, 0, z).to(result);
9499
+ /** the length (in bytes) of the data. */
9500
+ get length() {
9501
+ return BigInt(this.file.byteLength);
9499
9502
  }
9500
9503
  };
9501
- Ellipsoid.WGS84 = new Ellipsoid(WGS84_RADIUS_X, WGS84_RADIUS_Y, WGS84_RADIUS_Z);
9502
9504
 
9503
9505
  // ../images/src/lib/utils/version.ts
9504
9506
  var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
@@ -9832,7 +9834,7 @@ var __exports__ = (() => {
9832
9834
  async function parseToNodeImage(arrayBuffer, options) {
9833
9835
  const { mimeType } = getBinaryImageMetadata(arrayBuffer) || {};
9834
9836
  const parseImageNode2 = globalThis.loaders?.parseImageNode;
9835
- assert(parseImageNode2);
9837
+ assert2(parseImageNode2);
9836
9838
  return await parseImageNode2(arrayBuffer, mimeType);
9837
9839
  }
9838
9840
 
@@ -9855,7 +9857,7 @@ var __exports__ = (() => {
9855
9857
  image = await parseToNodeImage(arrayBuffer, options);
9856
9858
  break;
9857
9859
  default:
9858
- assert(false);
9860
+ assert2(false);
9859
9861
  }
9860
9862
  if (imageType === "data") {
9861
9863
  image = getImageData(image);
@@ -9908,35 +9910,88 @@ var __exports__ = (() => {
9908
9910
  options: DEFAULT_IMAGE_LOADER_OPTIONS
9909
9911
  };
9910
9912
 
9913
+ // ../draco/src/lib/draco-module-loader.ts
9914
+ var DRACO_DECODER_VERSION = "1.5.6";
9915
+ var DRACO_ENCODER_VERSION = "1.4.1";
9916
+ var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
9917
+ var DRACO_EXTERNAL_LIBRARIES = {
9918
+ /** The primary Draco3D encoder, javascript wrapper part */
9919
+ DECODER: "draco_wasm_wrapper.js",
9920
+ /** The primary draco decoder, compiled web assembly part */
9921
+ DECODER_WASM: "draco_decoder.wasm",
9922
+ /** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
9923
+ FALLBACK_DECODER: "draco_decoder.js",
9924
+ /** Draco encoder */
9925
+ ENCODER: "draco_encoder.js"
9926
+ };
9927
+ var DRACO_EXTERNAL_LIBRARY_URLS = {
9928
+ [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,
9929
+ [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,
9930
+ [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,
9931
+ [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
9932
+ };
9933
+ var loadDecoderPromise;
9934
+ async function loadDracoDecoderModule(options) {
9935
+ const modules = options.modules || {};
9936
+ if (modules.draco3d) {
9937
+ loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
9938
+ return { draco };
9939
+ });
9940
+ } else {
9941
+ loadDecoderPromise ||= loadDracoDecoder(options);
9942
+ }
9943
+ return await loadDecoderPromise;
9944
+ }
9945
+ async function loadDracoDecoder(options) {
9946
+ let DracoDecoderModule;
9947
+ let wasmBinary;
9948
+ switch (options.draco && options.draco.decoderType) {
9949
+ case "js":
9950
+ DracoDecoderModule = await loadLibrary(
9951
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
9952
+ "draco",
9953
+ options,
9954
+ DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
9955
+ );
9956
+ break;
9957
+ case "wasm":
9958
+ default:
9959
+ [DracoDecoderModule, wasmBinary] = await Promise.all([
9960
+ await loadLibrary(
9961
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
9962
+ "draco",
9963
+ options,
9964
+ DRACO_EXTERNAL_LIBRARIES.DECODER
9965
+ ),
9966
+ await loadLibrary(
9967
+ DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
9968
+ "draco",
9969
+ options,
9970
+ DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
9971
+ )
9972
+ ]);
9973
+ }
9974
+ DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
9975
+ return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
9976
+ }
9977
+ function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
9978
+ const options = {};
9979
+ if (wasmBinary) {
9980
+ options.wasmBinary = wasmBinary;
9981
+ }
9982
+ return new Promise((resolve) => {
9983
+ DracoDecoderModule({
9984
+ ...options,
9985
+ onModuleLoaded: (draco) => resolve({ draco })
9986
+ // Module is Promise-like. Wrap in object to avoid loop.
9987
+ });
9988
+ });
9989
+ }
9990
+
9911
9991
  // ../draco/src/lib/utils/version.ts
9912
9992
  var VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
9913
9993
 
9914
- // ../draco/src/draco-loader.ts
9915
- var DracoLoader = {
9916
- dataType: null,
9917
- batchType: null,
9918
- name: "Draco",
9919
- id: "draco",
9920
- module: "draco",
9921
- // shapes: ['mesh'],
9922
- version: VERSION3,
9923
- worker: true,
9924
- extensions: ["drc"],
9925
- mimeTypes: ["application/octet-stream"],
9926
- binary: true,
9927
- tests: ["DRACO"],
9928
- options: {
9929
- draco: {
9930
- decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
9931
- // 'js' for IE11
9932
- libraryPath: "libs/",
9933
- extraAttributes: {},
9934
- attributeNameEntry: void 0
9935
- }
9936
- }
9937
- };
9938
-
9939
- // ../schema/src/lib/table/simple-table/data-type.ts
9994
+ // ../schema-utils/src/lib/schema/data-type.ts
9940
9995
  function getDataTypeFromTypedArray(array) {
9941
9996
  switch (array.constructor) {
9942
9997
  case Int8Array:
@@ -9961,7 +10016,7 @@ var __exports__ = (() => {
9961
10016
  }
9962
10017
  }
9963
10018
 
9964
- // ../schema/src/lib/mesh/mesh-utils.ts
10019
+ // ../schema-utils/src/lib/mesh/mesh-utils.ts
9965
10020
  function getMeshBoundingBox(attributes) {
9966
10021
  let minX = Infinity;
9967
10022
  let minY = Infinity;
@@ -9988,7 +10043,7 @@ var __exports__ = (() => {
9988
10043
  ];
9989
10044
  }
9990
10045
 
9991
- // ../schema/src/lib/mesh/deduce-mesh-schema.ts
10046
+ // ../schema-utils/src/lib/mesh/deduce-mesh-schema.ts
9992
10047
  function deduceMeshField(name, attribute, optionalMetadata) {
9993
10048
  const type = getDataTypeFromTypedArray(attribute.value);
9994
10049
  const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
@@ -10212,6 +10267,7 @@ var __exports__ = (() => {
10212
10267
  case "triangle-strip":
10213
10268
  return {
10214
10269
  topology: "triangle-strip",
10270
+ // TODO - mode is wrong?
10215
10271
  mode: 4,
10216
10272
  // GL.TRIANGLES
10217
10273
  attributes,
@@ -10224,6 +10280,7 @@ var __exports__ = (() => {
10224
10280
  default:
10225
10281
  return {
10226
10282
  topology: "triangle-list",
10283
+ // TODO - mode is wrong?
10227
10284
  mode: 5,
10228
10285
  // GL.TRIANGLE_STRIP
10229
10286
  attributes,
@@ -10508,87 +10565,32 @@ var __exports__ = (() => {
10508
10565
  return intArray;
10509
10566
  }
10510
10567
 
10511
- // ../draco/src/lib/draco-module-loader.ts
10512
- var DRACO_DECODER_VERSION = "1.5.6";
10513
- var DRACO_ENCODER_VERSION = "1.4.1";
10514
- var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
10515
- var DRACO_EXTERNAL_LIBRARIES = {
10516
- /** The primary Draco3D encoder, javascript wrapper part */
10517
- DECODER: "draco_wasm_wrapper.js",
10518
- /** The primary draco decoder, compiled web assembly part */
10519
- DECODER_WASM: "draco_decoder.wasm",
10520
- /** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
10521
- FALLBACK_DECODER: "draco_decoder.js",
10522
- /** Draco encoder */
10523
- ENCODER: "draco_encoder.js"
10524
- };
10525
- var DRACO_EXTERNAL_LIBRARY_URLS = {
10526
- [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,
10527
- [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,
10528
- [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,
10529
- [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
10530
- };
10531
- var loadDecoderPromise;
10532
- async function loadDracoDecoderModule(options) {
10533
- const modules = options.modules || {};
10534
- if (modules.draco3d) {
10535
- loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
10536
- return { draco };
10537
- });
10538
- } else {
10539
- loadDecoderPromise ||= loadDracoDecoder(options);
10540
- }
10541
- return await loadDecoderPromise;
10542
- }
10543
- async function loadDracoDecoder(options) {
10544
- let DracoDecoderModule;
10545
- let wasmBinary;
10546
- switch (options.draco && options.draco.decoderType) {
10547
- case "js":
10548
- DracoDecoderModule = await loadLibrary(
10549
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
10550
- "draco",
10551
- options,
10552
- DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
10553
- );
10554
- break;
10555
- case "wasm":
10556
- default:
10557
- [DracoDecoderModule, wasmBinary] = await Promise.all([
10558
- await loadLibrary(
10559
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
10560
- "draco",
10561
- options,
10562
- DRACO_EXTERNAL_LIBRARIES.DECODER
10563
- ),
10564
- await loadLibrary(
10565
- DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
10566
- "draco",
10567
- options,
10568
- DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
10569
- )
10570
- ]);
10571
- }
10572
- DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
10573
- return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
10574
- }
10575
- function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
10576
- const options = {};
10577
- if (wasmBinary) {
10578
- options.wasmBinary = wasmBinary;
10568
+ // ../draco/src/draco-loader.ts
10569
+ var DracoWorkerLoader = {
10570
+ dataType: null,
10571
+ batchType: null,
10572
+ name: "Draco",
10573
+ id: "draco",
10574
+ module: "draco",
10575
+ // shapes: ['mesh'],
10576
+ version: VERSION3,
10577
+ worker: true,
10578
+ extensions: ["drc"],
10579
+ mimeTypes: ["application/octet-stream"],
10580
+ binary: true,
10581
+ tests: ["DRACO"],
10582
+ options: {
10583
+ draco: {
10584
+ decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
10585
+ // 'js' for IE11
10586
+ libraryPath: "libs/",
10587
+ extraAttributes: {},
10588
+ attributeNameEntry: void 0
10589
+ }
10579
10590
  }
10580
- return new Promise((resolve) => {
10581
- DracoDecoderModule({
10582
- ...options,
10583
- onModuleLoaded: (draco) => resolve({ draco })
10584
- // Module is Promise-like. Wrap in object to avoid loop.
10585
- });
10586
- });
10587
- }
10588
-
10589
- // ../draco/src/index.ts
10590
- var DracoLoader2 = {
10591
- ...DracoLoader,
10591
+ };
10592
+ var DracoLoader = {
10593
+ ...DracoWorkerLoader,
10592
10594
  parse
10593
10595
  };
10594
10596
  async function parse(arrayBuffer, options) {
@@ -11507,14 +11509,14 @@ var __exports__ = (() => {
11507
11509
  function parseDDS(data) {
11508
11510
  const header = new Int32Array(data, 0, DDS_CONSTANTS.HEADER_LENGTH);
11509
11511
  const pixelFormatNumber = header[DDS_CONSTANTS.HEADER_PF_FOURCC_INDEX];
11510
- assert(
11512
+ assert2(
11511
11513
  Boolean(header[DDS_CONSTANTS.HEADER_PF_FLAGS_INDEX] & DDS_CONSTANTS.DDPF_FOURCC),
11512
11514
  "DDS: Unsupported format, must contain a FourCC code"
11513
11515
  );
11514
11516
  const fourCC = int32ToFourCC(pixelFormatNumber);
11515
11517
  const internalFormat = DDS_PIXEL_FORMATS[fourCC];
11516
11518
  const sizeFunction = DDS_SIZE_FUNCTIONS[fourCC];
11517
- assert(internalFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
11519
+ assert2(internalFormat && sizeFunction, `DDS: Unknown pixel format ${pixelFormatNumber}`);
11518
11520
  let mipMapLevels = 1;
11519
11521
  if (header[DDS_CONSTANTS.HEADER_FLAGS_INDEX] & DDS_CONSTANTS.DDSD_MIPMAPCOUNT) {
11520
11522
  mipMapLevels = Math.max(1, header[DDS_CONSTANTS.MIPMAPCOUNT_INDEX]);
@@ -11918,7 +11920,7 @@ var __exports__ = (() => {
11918
11920
  let featureCount = 0;
11919
11921
  let indices;
11920
11922
  if (tileOptions.isDracoGeometry) {
11921
- const decompressedGeometry = await (0, import_core5.parse)(arrayBuffer, DracoLoader2, {
11923
+ const decompressedGeometry = await (0, import_core5.parse)(arrayBuffer, DracoLoader, {
11922
11924
  draco: {
11923
11925
  attributeNameEntry: I3S_ATTRIBUTE_TYPE
11924
11926
  }
@@ -12620,7 +12622,7 @@ var __exports__ = (() => {
12620
12622
  }
12621
12623
  /** Creates a plane from a normal and a distance from the origin. */
12622
12624
  fromNormalDistance(normal, distance2) {
12623
- assert3(Number.isFinite(distance2));
12625
+ assert(Number.isFinite(distance2));
12624
12626
  this.normal.from(normal).normalize();
12625
12627
  this.distance = distance2;
12626
12628
  return this;
@@ -12636,7 +12638,7 @@ var __exports__ = (() => {
12636
12638
  /** Creates a plane from the general equation */
12637
12639
  fromCoefficients(a, b, c, d) {
12638
12640
  this.normal.set(a, b, c);
12639
- assert3(equals(this.normal.len(), 1));
12641
+ assert(equals(this.normal.len(), 1));
12640
12642
  this.distance = d;
12641
12643
  return this;
12642
12644
  }
@@ -12732,7 +12734,7 @@ var __exports__ = (() => {
12732
12734
  * and that plane check can be skipped.
12733
12735
  */
12734
12736
  computeVisibilityWithPlaneMask(boundingVolume, parentPlaneMask) {
12735
- assert3(Number.isFinite(parentPlaneMask), "parentPlaneMask is required.");
12737
+ assert(Number.isFinite(parentPlaneMask), "parentPlaneMask is required.");
12736
12738
  if (parentPlaneMask === CullingVolume.MASK_OUTSIDE || parentPlaneMask === CullingVolume.MASK_INSIDE) {
12737
12739
  return parentPlaneMask;
12738
12740
  }
@@ -14708,7 +14710,7 @@ var __exports__ = (() => {
14708
14710
  extensions: [".bin.gz"]
14709
14711
  },
14710
14712
  {
14711
- test: /statistics\/f_\d+\/\d+$/,
14713
+ test: /statistics\/(f_\d+\/\d+|summary)$/,
14712
14714
  extensions: [".json.gz"]
14713
14715
  },
14714
14716
  {