@deck.gl/mesh-layers
Version:
deck.gl layers that loads 3D meshes or scene graphs
1,851 lines (1,829 loc) • 396 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if (typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if (typeof define === 'function' && define.amd) define([], factory);
else if (typeof exports === 'object') exports['deck'] = factory();
else root['deck'] = factory();})(globalThis, function () {
"use strict";
var __exports__ = (() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name12 in all)
__defProp(target, name12, { get: all[name12], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// external-global-plugin:@deck.gl/core
var require_core = __commonJS({
"external-global-plugin:@deck.gl/core"(exports, module) {
module.exports = globalThis.deck;
}
});
// external-global-plugin:@luma.gl/core
var require_core2 = __commonJS({
"external-global-plugin:@luma.gl/core"(exports, module) {
module.exports = globalThis.luma;
}
});
// external-global-plugin:@luma.gl/engine
var require_engine = __commonJS({
"external-global-plugin:@luma.gl/engine"(exports, module) {
module.exports = globalThis.luma;
}
});
// bundle.ts
var bundle_exports = {};
__export(bundle_exports, {
ScenegraphLayer: () => ScenegraphLayer,
SimpleMeshLayer: () => SimpleMeshLayer
});
// ../core/bundle/peer-dependency.ts
var peer_dependency_exports = {};
var import_core = __toESM(require_core(), 1);
__reExport(peer_dependency_exports, __toESM(require_core(), 1));
if (!import_core.Layer) {
throw new Error("@deck.gl/core is not found");
}
// bundle.ts
__reExport(bundle_exports, peer_dependency_exports);
// src/simple-mesh-layer/simple-mesh-layer.ts
var import_core4 = __toESM(require_core(), 1);
var import_core5 = __toESM(require_core2(), 1);
var import_engine = __toESM(require_engine(), 1);
// ../../node_modules/@math.gl/core/dist/lib/common.js
var RADIANS_TO_DEGREES = 1 / Math.PI * 180;
var DEGREES_TO_RADIANS = 1 / 180 * Math.PI;
var DEFAULT_CONFIG = {
EPSILON: 1e-12,
debug: false,
precision: 4,
printTypes: false,
printDegrees: false,
printRowMajor: true,
_cartographicRadians: false
};
globalThis.mathgl = globalThis.mathgl || { config: { ...DEFAULT_CONFIG } };
var config = globalThis.mathgl.config;
function formatValue(value, { precision = config.precision } = {}) {
value = round(value);
return `${parseFloat(value.toPrecision(precision))}`;
}
function isArray(value) {
return Array.isArray(value) || ArrayBuffer.isView(value) && !(value instanceof DataView);
}
function equals(a2, b, epsilon) {
const oldEpsilon = config.EPSILON;
if (epsilon) {
config.EPSILON = epsilon;
}
try {
if (a2 === b) {
return true;
}
if (isArray(a2) && isArray(b)) {
if (a2.length !== b.length) {
return false;
}
for (let i2 = 0; i2 < a2.length; ++i2) {
if (!equals(a2[i2], b[i2])) {
return false;
}
}
return true;
}
if (a2 && a2.equals) {
return a2.equals(b);
}
if (b && b.equals) {
return b.equals(a2);
}
if (typeof a2 === "number" && typeof b === "number") {
return Math.abs(a2 - b) <= config.EPSILON * Math.max(1, Math.abs(a2), Math.abs(b));
}
return false;
} finally {
config.EPSILON = oldEpsilon;
}
}
function round(value) {
return Math.round(value / config.EPSILON) * config.EPSILON;
}
// ../../node_modules/@math.gl/core/dist/classes/base/math-array.js
var MathArray = class extends Array {
// Common methods
/**
* Clone the current object
* @returns a new copy of this object
*/
clone() {
return new this.constructor().copy(this);
}
fromArray(array, offset = 0) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = array[i2 + offset];
}
return this.check();
}
toArray(targetArray = [], offset = 0) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
targetArray[offset + i2] = this[i2];
}
return targetArray;
}
toObject(targetObject) {
return targetObject;
}
from(arrayOrObject) {
return Array.isArray(arrayOrObject) ? this.copy(arrayOrObject) : (
// @ts-ignore
this.fromObject(arrayOrObject)
);
}
to(arrayOrObject) {
if (arrayOrObject === this) {
return this;
}
return isArray(arrayOrObject) ? this.toArray(arrayOrObject) : this.toObject(arrayOrObject);
}
toTarget(target) {
return target ? this.to(target) : this;
}
/** @deprecated */
toFloat32Array() {
return new Float32Array(this);
}
toString() {
return this.formatString(config);
}
/** Formats string according to options */
formatString(opts) {
let string = "";
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
string += (i2 > 0 ? ", " : "") + formatValue(this[i2], opts);
}
return `${opts.printTypes ? this.constructor.name : ""}[${string}]`;
}
equals(array) {
if (!array || this.length !== array.length) {
return false;
}
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
if (!equals(this[i2], array[i2])) {
return false;
}
}
return true;
}
exactEquals(array) {
if (!array || this.length !== array.length) {
return false;
}
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
if (this[i2] !== array[i2]) {
return false;
}
}
return true;
}
// Modifiers
/** Negates all values in this object */
negate() {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = -this[i2];
}
return this.check();
}
lerp(a2, b, t2) {
if (t2 === void 0) {
return this.lerp(this, a2, b);
}
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
const ai = a2[i2];
const endValue = typeof b === "number" ? b : b[i2];
this[i2] = ai + t2 * (endValue - ai);
}
return this.check();
}
/** Minimal */
min(vector) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = Math.min(vector[i2], this[i2]);
}
return this.check();
}
/** Maximal */
max(vector) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = Math.max(vector[i2], this[i2]);
}
return this.check();
}
clamp(minVector, maxVector) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = Math.min(Math.max(this[i2], minVector[i2]), maxVector[i2]);
}
return this.check();
}
add(...vectors) {
for (const vector of vectors) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] += vector[i2];
}
}
return this.check();
}
subtract(...vectors) {
for (const vector of vectors) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] -= vector[i2];
}
}
return this.check();
}
scale(scale5) {
if (typeof scale5 === "number") {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] *= scale5;
}
} else {
for (let i2 = 0; i2 < this.ELEMENTS && i2 < scale5.length; ++i2) {
this[i2] *= scale5[i2];
}
}
return this.check();
}
/**
* Multiplies all elements by `scale`
* Note: `Matrix4.multiplyByScalar` only scales its 3x3 "minor"
*/
multiplyByScalar(scalar) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] *= scalar;
}
return this.check();
}
// Debug checks
/** Throws an error if array length is incorrect or contains illegal values */
check() {
if (config.debug && !this.validate()) {
throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);
}
return this;
}
/** Returns false if the array length is incorrect or contains illegal values */
validate() {
let valid = this.length === this.ELEMENTS;
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
valid = valid && Number.isFinite(this[i2]);
}
return valid;
}
// three.js compatibility
/** @deprecated */
sub(a2) {
return this.subtract(a2);
}
/** @deprecated */
setScalar(a2) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = a2;
}
return this.check();
}
/** @deprecated */
addScalar(a2) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] += a2;
}
return this.check();
}
/** @deprecated */
subScalar(a2) {
return this.addScalar(-a2);
}
/** @deprecated */
multiplyScalar(scalar) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] *= scalar;
}
return this.check();
}
/** @deprecated */
divideScalar(a2) {
return this.multiplyByScalar(1 / a2);
}
/** @deprecated */
clampScalar(min, max) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] = Math.min(Math.max(this[i2], min), max);
}
return this.check();
}
/** @deprecated */
get elements() {
return this;
}
};
// ../../node_modules/@math.gl/core/dist/lib/validators.js
function validateVector(v, length4) {
if (v.length !== length4) {
return false;
}
for (let i2 = 0; i2 < v.length; ++i2) {
if (!Number.isFinite(v[i2])) {
return false;
}
}
return true;
}
function checkNumber(value) {
if (!Number.isFinite(value)) {
throw new Error(`Invalid number ${JSON.stringify(value)}`);
}
return value;
}
function checkVector(v, length4, callerName = "") {
if (config.debug && !validateVector(v, length4)) {
throw new Error(`math.gl: ${callerName} some fields set to invalid numbers'`);
}
return v;
}
// ../../node_modules/@math.gl/core/dist/lib/assert.js
function assert(condition, message) {
if (!condition) {
throw new Error(`math.gl assertion ${message}`);
}
}
// ../../node_modules/@math.gl/core/dist/classes/base/vector.js
var Vector = class extends MathArray {
// ACCESSORS
get x() {
return this[0];
}
set x(value) {
this[0] = checkNumber(value);
}
get y() {
return this[1];
}
set y(value) {
this[1] = checkNumber(value);
}
/**
* Returns the length of the vector from the origin to the point described by this vector
*
* @note `length` is a reserved word for Arrays, so `v.length()` will return number of elements
* Instead we provide `len` and `magnitude`
*/
len() {
return Math.sqrt(this.lengthSquared());
}
/**
* Returns the length of the vector from the origin to the point described by this vector
*/
magnitude() {
return this.len();
}
/**
* Returns the squared length of the vector from the origin to the point described by this vector
*/
lengthSquared() {
let length4 = 0;
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
length4 += this[i2] * this[i2];
}
return length4;
}
/**
* Returns the squared length of the vector from the origin to the point described by this vector
*/
magnitudeSquared() {
return this.lengthSquared();
}
distance(mathArray) {
return Math.sqrt(this.distanceSquared(mathArray));
}
distanceSquared(mathArray) {
let length4 = 0;
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
const dist = this[i2] - mathArray[i2];
length4 += dist * dist;
}
return checkNumber(length4);
}
dot(mathArray) {
let product = 0;
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
product += this[i2] * mathArray[i2];
}
return checkNumber(product);
}
// MODIFIERS
normalize() {
const length4 = this.magnitude();
if (length4 !== 0) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] /= length4;
}
}
return this.check();
}
multiply(...vectors) {
for (const vector of vectors) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] *= vector[i2];
}
}
return this.check();
}
divide(...vectors) {
for (const vector of vectors) {
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
this[i2] /= vector[i2];
}
}
return this.check();
}
// THREE.js compatibility
lengthSq() {
return this.lengthSquared();
}
distanceTo(vector) {
return this.distance(vector);
}
distanceToSquared(vector) {
return this.distanceSquared(vector);
}
getComponent(i2) {
assert(i2 >= 0 && i2 < this.ELEMENTS, "index is out of range");
return checkNumber(this[i2]);
}
setComponent(i2, value) {
assert(i2 >= 0 && i2 < this.ELEMENTS, "index is out of range");
this[i2] = value;
return this.check();
}
addVectors(a2, b) {
return this.copy(a2).add(b);
}
subVectors(a2, b) {
return this.copy(a2).subtract(b);
}
multiplyVectors(a2, b) {
return this.copy(a2).multiply(b);
}
addScaledVector(a2, b) {
return this.add(new this.constructor(a2).multiplyScalar(b));
}
};
// ../../node_modules/@math.gl/core/dist/gl-matrix/common.js
var EPSILON = 1e-6;
var ARRAY_TYPE = typeof Float32Array !== "undefined" ? Float32Array : Array;
var degree = Math.PI / 180;
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec2.js
function create() {
const out = new ARRAY_TYPE(2);
if (ARRAY_TYPE != Float32Array) {
out[0] = 0;
out[1] = 0;
}
return out;
}
function transformMat4(out, a2, m) {
const x = a2[0];
const y = a2[1];
out[0] = m[0] * x + m[4] * y + m[12];
out[1] = m[1] * x + m[5] * y + m[13];
return out;
}
var forEach = function() {
const vec = create();
return function(a2, stride, offset, count, fn, arg) {
let i2;
let l2;
if (!stride) {
stride = 2;
}
if (!offset) {
offset = 0;
}
if (count) {
l2 = Math.min(count * stride + offset, a2.length);
} else {
l2 = a2.length;
}
for (i2 = offset; i2 < l2; i2 += stride) {
vec[0] = a2[i2];
vec[1] = a2[i2 + 1];
fn(vec, vec, arg);
a2[i2] = vec[0];
a2[i2 + 1] = vec[1];
}
return a2;
};
}();
// ../../node_modules/@math.gl/core/dist/lib/gl-matrix-extras.js
function vec2_transformMat4AsVector(out, a2, m) {
const x = a2[0];
const y = a2[1];
const w = m[3] * x + m[7] * y || 1;
out[0] = (m[0] * x + m[4] * y) / w;
out[1] = (m[1] * x + m[5] * y) / w;
return out;
}
function vec3_transformMat4AsVector(out, a2, m) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
const w = m[3] * x + m[7] * y + m[11] * z || 1;
out[0] = (m[0] * x + m[4] * y + m[8] * z) / w;
out[1] = (m[1] * x + m[5] * y + m[9] * z) / w;
out[2] = (m[2] * x + m[6] * y + m[10] * z) / w;
return out;
}
function vec4_transformMat2(out, a2, m) {
const x = a2[0];
const y = a2[1];
out[0] = m[0] * x + m[2] * y;
out[1] = m[1] * x + m[3] * y;
out[2] = a2[2];
out[3] = a2[3];
return out;
}
function vec4_transformMat3(out, a2, m) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
out[0] = m[0] * x + m[3] * y + m[6] * z;
out[1] = m[1] * x + m[4] * y + m[7] * z;
out[2] = m[2] * x + m[5] * y + m[8] * z;
out[3] = a2[3];
return out;
}
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec3.js
function create2() {
const out = new ARRAY_TYPE(3);
if (ARRAY_TYPE != Float32Array) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
}
return out;
}
function length(a2) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
return Math.sqrt(x * x + y * y + z * z);
}
function fromValues(x, y, z) {
const out = new ARRAY_TYPE(3);
out[0] = x;
out[1] = y;
out[2] = z;
return out;
}
function normalize(out, a2) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
let len2 = x * x + y * y + z * z;
if (len2 > 0) {
len2 = 1 / Math.sqrt(len2);
}
out[0] = a2[0] * len2;
out[1] = a2[1] * len2;
out[2] = a2[2] * len2;
return out;
}
function dot(a2, b) {
return a2[0] * b[0] + a2[1] * b[1] + a2[2] * b[2];
}
function cross(out, a2, b) {
const ax = a2[0];
const ay = a2[1];
const az = a2[2];
const bx = b[0];
const by = b[1];
const bz = b[2];
out[0] = ay * bz - az * by;
out[1] = az * bx - ax * bz;
out[2] = ax * by - ay * bx;
return out;
}
function transformMat42(out, a2, m) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
let w = m[3] * x + m[7] * y + m[11] * z + m[15];
w = w || 1;
out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
return out;
}
function transformQuat(out, a2, q) {
const qx = q[0];
const qy = q[1];
const qz = q[2];
const qw = q[3];
const x = a2[0];
const y = a2[1];
const z = a2[2];
let uvx = qy * z - qz * y;
let uvy = qz * x - qx * z;
let uvz = qx * y - qy * x;
let uuvx = qy * uvz - qz * uvy;
let uuvy = qz * uvx - qx * uvz;
let uuvz = qx * uvy - qy * uvx;
const w2 = qw * 2;
uvx *= w2;
uvy *= w2;
uvz *= w2;
uuvx *= 2;
uuvy *= 2;
uuvz *= 2;
out[0] = x + uvx + uuvx;
out[1] = y + uvy + uuvy;
out[2] = z + uvz + uuvz;
return out;
}
var len = length;
var forEach2 = function() {
const vec = create2();
return function(a2, stride, offset, count, fn, arg) {
let i2;
let l2;
if (!stride) {
stride = 3;
}
if (!offset) {
offset = 0;
}
if (count) {
l2 = Math.min(count * stride + offset, a2.length);
} else {
l2 = a2.length;
}
for (i2 = offset; i2 < l2; i2 += stride) {
vec[0] = a2[i2];
vec[1] = a2[i2 + 1];
vec[2] = a2[i2 + 2];
fn(vec, vec, arg);
a2[i2] = vec[0];
a2[i2 + 1] = vec[1];
a2[i2 + 2] = vec[2];
}
return a2;
};
}();
// ../../node_modules/@math.gl/core/dist/classes/vector4.js
var ZERO;
var Vector4 = class extends Vector {
static get ZERO() {
if (!ZERO) {
ZERO = new Vector4(0, 0, 0, 0);
Object.freeze(ZERO);
}
return ZERO;
}
constructor(x = 0, y = 0, z = 0, w = 0) {
super(-0, -0, -0, -0);
if (isArray(x) && arguments.length === 1) {
this.copy(x);
} else {
if (config.debug) {
checkNumber(x);
checkNumber(y);
checkNumber(z);
checkNumber(w);
}
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = w;
}
}
set(x, y, z, w) {
this[0] = x;
this[1] = y;
this[2] = z;
this[3] = w;
return this.check();
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
return this.check();
}
fromObject(object) {
if (config.debug) {
checkNumber(object.x);
checkNumber(object.y);
checkNumber(object.z);
checkNumber(object.w);
}
this[0] = object.x;
this[1] = object.y;
this[2] = object.z;
this[3] = object.w;
return this;
}
toObject(object) {
object.x = this[0];
object.y = this[1];
object.z = this[2];
object.w = this[3];
return object;
}
// Getters/setters
/* eslint-disable no-multi-spaces, brace-style, no-return-assign */
get ELEMENTS() {
return 4;
}
get z() {
return this[2];
}
set z(value) {
this[2] = checkNumber(value);
}
get w() {
return this[3];
}
set w(value) {
this[3] = checkNumber(value);
}
transform(matrix4) {
transformMat42(this, this, matrix4);
return this.check();
}
transformByMatrix3(matrix3) {
vec4_transformMat3(this, this, matrix3);
return this.check();
}
transformByMatrix2(matrix2) {
vec4_transformMat2(this, this, matrix2);
return this.check();
}
transformByQuaternion(quaternion) {
transformQuat(this, this, quaternion);
return this.check();
}
// three.js compatibility
applyMatrix4(m) {
m.transform(this, this);
return this;
}
};
// ../../node_modules/@math.gl/core/dist/classes/base/matrix.js
var Matrix = class extends MathArray {
// fromObject(object) {
// const array = object.elements;
// return this.fromRowMajor(array);
// }
// toObject(object) {
// const array = object.elements;
// this.toRowMajor(array);
// return object;
// }
// TODO better override formatString?
toString() {
let string = "[";
if (config.printRowMajor) {
string += "row-major:";
for (let row = 0; row < this.RANK; ++row) {
for (let col = 0; col < this.RANK; ++col) {
string += ` ${this[col * this.RANK + row]}`;
}
}
} else {
string += "column-major:";
for (let i2 = 0; i2 < this.ELEMENTS; ++i2) {
string += ` ${this[i2]}`;
}
}
string += "]";
return string;
}
getElementIndex(row, col) {
return col * this.RANK + row;
}
// By default assumes row major indices
getElement(row, col) {
return this[col * this.RANK + row];
}
// By default assumes row major indices
setElement(row, col, value) {
this[col * this.RANK + row] = checkNumber(value);
return this;
}
getColumn(columnIndex, result = new Array(this.RANK).fill(-0)) {
const firstIndex = columnIndex * this.RANK;
for (let i2 = 0; i2 < this.RANK; ++i2) {
result[i2] = this[firstIndex + i2];
}
return result;
}
setColumn(columnIndex, columnVector) {
const firstIndex = columnIndex * this.RANK;
for (let i2 = 0; i2 < this.RANK; ++i2) {
this[firstIndex + i2] = columnVector[i2];
}
return this;
}
};
// ../../node_modules/@math.gl/core/dist/gl-matrix/mat3.js
function create3() {
const out = new ARRAY_TYPE(9);
if (ARRAY_TYPE != Float32Array) {
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[5] = 0;
out[6] = 0;
out[7] = 0;
}
out[0] = 1;
out[4] = 1;
out[8] = 1;
return out;
}
// ../../node_modules/@math.gl/core/dist/gl-matrix/mat4.js
function identity(out) {
out[0] = 1;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = 1;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = 1;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
function transpose(out, a2) {
if (out === a2) {
const a01 = a2[1];
const a02 = a2[2];
const a03 = a2[3];
const a12 = a2[6];
const a13 = a2[7];
const a23 = a2[11];
out[1] = a2[4];
out[2] = a2[8];
out[3] = a2[12];
out[4] = a01;
out[6] = a2[9];
out[7] = a2[13];
out[8] = a02;
out[9] = a12;
out[11] = a2[14];
out[12] = a03;
out[13] = a13;
out[14] = a23;
} else {
out[0] = a2[0];
out[1] = a2[4];
out[2] = a2[8];
out[3] = a2[12];
out[4] = a2[1];
out[5] = a2[5];
out[6] = a2[9];
out[7] = a2[13];
out[8] = a2[2];
out[9] = a2[6];
out[10] = a2[10];
out[11] = a2[14];
out[12] = a2[3];
out[13] = a2[7];
out[14] = a2[11];
out[15] = a2[15];
}
return out;
}
function invert(out, a2) {
const a00 = a2[0];
const a01 = a2[1];
const a02 = a2[2];
const a03 = a2[3];
const a10 = a2[4];
const a11 = a2[5];
const a12 = a2[6];
const a13 = a2[7];
const a20 = a2[8];
const a21 = a2[9];
const a22 = a2[10];
const a23 = a2[11];
const a30 = a2[12];
const a31 = a2[13];
const a32 = a2[14];
const a33 = a2[15];
const b00 = a00 * a11 - a01 * a10;
const b01 = a00 * a12 - a02 * a10;
const b02 = a00 * a13 - a03 * a10;
const b03 = a01 * a12 - a02 * a11;
const b04 = a01 * a13 - a03 * a11;
const b05 = a02 * a13 - a03 * a12;
const b06 = a20 * a31 - a21 * a30;
const b07 = a20 * a32 - a22 * a30;
const b08 = a20 * a33 - a23 * a30;
const b09 = a21 * a32 - a22 * a31;
const b10 = a21 * a33 - a23 * a31;
const b11 = a22 * a33 - a23 * a32;
let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
if (!det) {
return null;
}
det = 1 / det;
out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
return out;
}
function determinant(a2) {
const a00 = a2[0];
const a01 = a2[1];
const a02 = a2[2];
const a03 = a2[3];
const a10 = a2[4];
const a11 = a2[5];
const a12 = a2[6];
const a13 = a2[7];
const a20 = a2[8];
const a21 = a2[9];
const a22 = a2[10];
const a23 = a2[11];
const a30 = a2[12];
const a31 = a2[13];
const a32 = a2[14];
const a33 = a2[15];
const b0 = a00 * a11 - a01 * a10;
const b1 = a00 * a12 - a02 * a10;
const b2 = a01 * a12 - a02 * a11;
const b3 = a20 * a31 - a21 * a30;
const b4 = a20 * a32 - a22 * a30;
const b5 = a21 * a32 - a22 * a31;
const b6 = a00 * b5 - a01 * b4 + a02 * b3;
const b7 = a10 * b5 - a11 * b4 + a12 * b3;
const b8 = a20 * b2 - a21 * b1 + a22 * b0;
const b9 = a30 * b2 - a31 * b1 + a32 * b0;
return a13 * b6 - a03 * b7 + a33 * b8 - a23 * b9;
}
function multiply(out, a2, b) {
const a00 = a2[0];
const a01 = a2[1];
const a02 = a2[2];
const a03 = a2[3];
const a10 = a2[4];
const a11 = a2[5];
const a12 = a2[6];
const a13 = a2[7];
const a20 = a2[8];
const a21 = a2[9];
const a22 = a2[10];
const a23 = a2[11];
const a30 = a2[12];
const a31 = a2[13];
const a32 = a2[14];
const a33 = a2[15];
let b0 = b[0];
let b1 = b[1];
let b2 = b[2];
let b3 = b[3];
out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
b0 = b[4];
b1 = b[5];
b2 = b[6];
b3 = b[7];
out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
b0 = b[8];
b1 = b[9];
b2 = b[10];
b3 = b[11];
out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
b0 = b[12];
b1 = b[13];
b2 = b[14];
b3 = b[15];
out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
return out;
}
function translate(out, a2, v) {
const x = v[0];
const y = v[1];
const z = v[2];
let a00;
let a01;
let a02;
let a03;
let a10;
let a11;
let a12;
let a13;
let a20;
let a21;
let a22;
let a23;
if (a2 === out) {
out[12] = a2[0] * x + a2[4] * y + a2[8] * z + a2[12];
out[13] = a2[1] * x + a2[5] * y + a2[9] * z + a2[13];
out[14] = a2[2] * x + a2[6] * y + a2[10] * z + a2[14];
out[15] = a2[3] * x + a2[7] * y + a2[11] * z + a2[15];
} else {
a00 = a2[0];
a01 = a2[1];
a02 = a2[2];
a03 = a2[3];
a10 = a2[4];
a11 = a2[5];
a12 = a2[6];
a13 = a2[7];
a20 = a2[8];
a21 = a2[9];
a22 = a2[10];
a23 = a2[11];
out[0] = a00;
out[1] = a01;
out[2] = a02;
out[3] = a03;
out[4] = a10;
out[5] = a11;
out[6] = a12;
out[7] = a13;
out[8] = a20;
out[9] = a21;
out[10] = a22;
out[11] = a23;
out[12] = a00 * x + a10 * y + a20 * z + a2[12];
out[13] = a01 * x + a11 * y + a21 * z + a2[13];
out[14] = a02 * x + a12 * y + a22 * z + a2[14];
out[15] = a03 * x + a13 * y + a23 * z + a2[15];
}
return out;
}
function scale(out, a2, v) {
const x = v[0];
const y = v[1];
const z = v[2];
out[0] = a2[0] * x;
out[1] = a2[1] * x;
out[2] = a2[2] * x;
out[3] = a2[3] * x;
out[4] = a2[4] * y;
out[5] = a2[5] * y;
out[6] = a2[6] * y;
out[7] = a2[7] * y;
out[8] = a2[8] * z;
out[9] = a2[9] * z;
out[10] = a2[10] * z;
out[11] = a2[11] * z;
out[12] = a2[12];
out[13] = a2[13];
out[14] = a2[14];
out[15] = a2[15];
return out;
}
function rotate(out, a2, rad, axis) {
let x = axis[0];
let y = axis[1];
let z = axis[2];
let len2 = Math.sqrt(x * x + y * y + z * z);
let c;
let s2;
let t2;
let a00;
let a01;
let a02;
let a03;
let a10;
let a11;
let a12;
let a13;
let a20;
let a21;
let a22;
let a23;
let b00;
let b01;
let b02;
let b10;
let b11;
let b12;
let b20;
let b21;
let b22;
if (len2 < EPSILON) {
return null;
}
len2 = 1 / len2;
x *= len2;
y *= len2;
z *= len2;
s2 = Math.sin(rad);
c = Math.cos(rad);
t2 = 1 - c;
a00 = a2[0];
a01 = a2[1];
a02 = a2[2];
a03 = a2[3];
a10 = a2[4];
a11 = a2[5];
a12 = a2[6];
a13 = a2[7];
a20 = a2[8];
a21 = a2[9];
a22 = a2[10];
a23 = a2[11];
b00 = x * x * t2 + c;
b01 = y * x * t2 + z * s2;
b02 = z * x * t2 - y * s2;
b10 = x * y * t2 - z * s2;
b11 = y * y * t2 + c;
b12 = z * y * t2 + x * s2;
b20 = x * z * t2 + y * s2;
b21 = y * z * t2 - x * s2;
b22 = z * z * t2 + c;
out[0] = a00 * b00 + a10 * b01 + a20 * b02;
out[1] = a01 * b00 + a11 * b01 + a21 * b02;
out[2] = a02 * b00 + a12 * b01 + a22 * b02;
out[3] = a03 * b00 + a13 * b01 + a23 * b02;
out[4] = a00 * b10 + a10 * b11 + a20 * b12;
out[5] = a01 * b10 + a11 * b11 + a21 * b12;
out[6] = a02 * b10 + a12 * b11 + a22 * b12;
out[7] = a03 * b10 + a13 * b11 + a23 * b12;
out[8] = a00 * b20 + a10 * b21 + a20 * b22;
out[9] = a01 * b20 + a11 * b21 + a21 * b22;
out[10] = a02 * b20 + a12 * b21 + a22 * b22;
out[11] = a03 * b20 + a13 * b21 + a23 * b22;
if (a2 !== out) {
out[12] = a2[12];
out[13] = a2[13];
out[14] = a2[14];
out[15] = a2[15];
}
return out;
}
function rotateX(out, a2, rad) {
const s2 = Math.sin(rad);
const c = Math.cos(rad);
const a10 = a2[4];
const a11 = a2[5];
const a12 = a2[6];
const a13 = a2[7];
const a20 = a2[8];
const a21 = a2[9];
const a22 = a2[10];
const a23 = a2[11];
if (a2 !== out) {
out[0] = a2[0];
out[1] = a2[1];
out[2] = a2[2];
out[3] = a2[3];
out[12] = a2[12];
out[13] = a2[13];
out[14] = a2[14];
out[15] = a2[15];
}
out[4] = a10 * c + a20 * s2;
out[5] = a11 * c + a21 * s2;
out[6] = a12 * c + a22 * s2;
out[7] = a13 * c + a23 * s2;
out[8] = a20 * c - a10 * s2;
out[9] = a21 * c - a11 * s2;
out[10] = a22 * c - a12 * s2;
out[11] = a23 * c - a13 * s2;
return out;
}
function rotateY(out, a2, rad) {
const s2 = Math.sin(rad);
const c = Math.cos(rad);
const a00 = a2[0];
const a01 = a2[1];
const a02 = a2[2];
const a03 = a2[3];
const a20 = a2[8];
const a21 = a2[9];
const a22 = a2[10];
const a23 = a2[11];
if (a2 !== out) {
out[4] = a2[4];
out[5] = a2[5];
out[6] = a2[6];
out[7] = a2[7];
out[12] = a2[12];
out[13] = a2[13];
out[14] = a2[14];
out[15] = a2[15];
}
out[0] = a00 * c - a20 * s2;
out[1] = a01 * c - a21 * s2;
out[2] = a02 * c - a22 * s2;
out[3] = a03 * c - a23 * s2;
out[8] = a00 * s2 + a20 * c;
out[9] = a01 * s2 + a21 * c;
out[10] = a02 * s2 + a22 * c;
out[11] = a03 * s2 + a23 * c;
return out;
}
function rotateZ(out, a2, rad) {
const s2 = Math.sin(rad);
const c = Math.cos(rad);
const a00 = a2[0];
const a01 = a2[1];
const a02 = a2[2];
const a03 = a2[3];
const a10 = a2[4];
const a11 = a2[5];
const a12 = a2[6];
const a13 = a2[7];
if (a2 !== out) {
out[8] = a2[8];
out[9] = a2[9];
out[10] = a2[10];
out[11] = a2[11];
out[12] = a2[12];
out[13] = a2[13];
out[14] = a2[14];
out[15] = a2[15];
}
out[0] = a00 * c + a10 * s2;
out[1] = a01 * c + a11 * s2;
out[2] = a02 * c + a12 * s2;
out[3] = a03 * c + a13 * s2;
out[4] = a10 * c - a00 * s2;
out[5] = a11 * c - a01 * s2;
out[6] = a12 * c - a02 * s2;
out[7] = a13 * c - a03 * s2;
return out;
}
function fromQuat(out, q) {
const x = q[0];
const y = q[1];
const z = q[2];
const w = q[3];
const x2 = x + x;
const y2 = y + y;
const z2 = z + z;
const xx = x * x2;
const yx = y * x2;
const yy = y * y2;
const zx = z * x2;
const zy = z * y2;
const zz = z * z2;
const wx = w * x2;
const wy = w * y2;
const wz = w * z2;
out[0] = 1 - yy - zz;
out[1] = yx + wz;
out[2] = zx - wy;
out[3] = 0;
out[4] = yx - wz;
out[5] = 1 - xx - zz;
out[6] = zy + wx;
out[7] = 0;
out[8] = zx + wy;
out[9] = zy - wx;
out[10] = 1 - xx - yy;
out[11] = 0;
out[12] = 0;
out[13] = 0;
out[14] = 0;
out[15] = 1;
return out;
}
function frustum(out, left, right, bottom, top, near, far) {
const rl = 1 / (right - left);
const tb = 1 / (top - bottom);
const nf = 1 / (near - far);
out[0] = near * 2 * rl;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = near * 2 * tb;
out[6] = 0;
out[7] = 0;
out[8] = (right + left) * rl;
out[9] = (top + bottom) * tb;
out[10] = (far + near) * nf;
out[11] = -1;
out[12] = 0;
out[13] = 0;
out[14] = far * near * 2 * nf;
out[15] = 0;
return out;
}
function perspectiveNO(out, fovy, aspect, near, far) {
const f2 = 1 / Math.tan(fovy / 2);
out[0] = f2 / aspect;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = f2;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[11] = -1;
out[12] = 0;
out[13] = 0;
out[15] = 0;
if (far != null && far !== Infinity) {
const nf = 1 / (near - far);
out[10] = (far + near) * nf;
out[14] = 2 * far * near * nf;
} else {
out[10] = -1;
out[14] = -2 * near;
}
return out;
}
var perspective = perspectiveNO;
function orthoNO(out, left, right, bottom, top, near, far) {
const lr = 1 / (left - right);
const bt = 1 / (bottom - top);
const nf = 1 / (near - far);
out[0] = -2 * lr;
out[1] = 0;
out[2] = 0;
out[3] = 0;
out[4] = 0;
out[5] = -2 * bt;
out[6] = 0;
out[7] = 0;
out[8] = 0;
out[9] = 0;
out[10] = 2 * nf;
out[11] = 0;
out[12] = (left + right) * lr;
out[13] = (top + bottom) * bt;
out[14] = (far + near) * nf;
out[15] = 1;
return out;
}
var ortho = orthoNO;
function lookAt(out, eye, center, up) {
let len2;
let x0;
let x1;
let x2;
let y0;
let y1;
let y2;
let z0;
let z1;
let z2;
const eyex = eye[0];
const eyey = eye[1];
const eyez = eye[2];
const upx = up[0];
const upy = up[1];
const upz = up[2];
const centerx = center[0];
const centery = center[1];
const centerz = center[2];
if (Math.abs(eyex - centerx) < EPSILON && Math.abs(eyey - centery) < EPSILON && Math.abs(eyez - centerz) < EPSILON) {
return identity(out);
}
z0 = eyex - centerx;
z1 = eyey - centery;
z2 = eyez - centerz;
len2 = 1 / Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
z0 *= len2;
z1 *= len2;
z2 *= len2;
x0 = upy * z2 - upz * z1;
x1 = upz * z0 - upx * z2;
x2 = upx * z1 - upy * z0;
len2 = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
if (!len2) {
x0 = 0;
x1 = 0;
x2 = 0;
} else {
len2 = 1 / len2;
x0 *= len2;
x1 *= len2;
x2 *= len2;
}
y0 = z1 * x2 - z2 * x1;
y1 = z2 * x0 - z0 * x2;
y2 = z0 * x1 - z1 * x0;
len2 = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
if (!len2) {
y0 = 0;
y1 = 0;
y2 = 0;
} else {
len2 = 1 / len2;
y0 *= len2;
y1 *= len2;
y2 *= len2;
}
out[0] = x0;
out[1] = y0;
out[2] = z0;
out[3] = 0;
out[4] = x1;
out[5] = y1;
out[6] = z1;
out[7] = 0;
out[8] = x2;
out[9] = y2;
out[10] = z2;
out[11] = 0;
out[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
out[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
out[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
out[15] = 1;
return out;
}
// ../../node_modules/@math.gl/core/dist/gl-matrix/vec4.js
function create4() {
const out = new ARRAY_TYPE(4);
if (ARRAY_TYPE != Float32Array) {
out[0] = 0;
out[1] = 0;
out[2] = 0;
out[3] = 0;
}
return out;
}
function add(out, a2, b) {
out[0] = a2[0] + b[0];
out[1] = a2[1] + b[1];
out[2] = a2[2] + b[2];
out[3] = a2[3] + b[3];
return out;
}
function scale2(out, a2, b) {
out[0] = a2[0] * b;
out[1] = a2[1] * b;
out[2] = a2[2] * b;
out[3] = a2[3] * b;
return out;
}
function length2(a2) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
const w = a2[3];
return Math.sqrt(x * x + y * y + z * z + w * w);
}
function squaredLength(a2) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
const w = a2[3];
return x * x + y * y + z * z + w * w;
}
function normalize2(out, a2) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
const w = a2[3];
let len2 = x * x + y * y + z * z + w * w;
if (len2 > 0) {
len2 = 1 / Math.sqrt(len2);
}
out[0] = x * len2;
out[1] = y * len2;
out[2] = z * len2;
out[3] = w * len2;
return out;
}
function dot2(a2, b) {
return a2[0] * b[0] + a2[1] * b[1] + a2[2] * b[2] + a2[3] * b[3];
}
function lerp(out, a2, b, t2) {
const ax = a2[0];
const ay = a2[1];
const az = a2[2];
const aw = a2[3];
out[0] = ax + t2 * (b[0] - ax);
out[1] = ay + t2 * (b[1] - ay);
out[2] = az + t2 * (b[2] - az);
out[3] = aw + t2 * (b[3] - aw);
return out;
}
function transformMat43(out, a2, m) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
const w = a2[3];
out[0] = m[0] * x + m[4] * y + m[8] * z + m[12] * w;
out[1] = m[1] * x + m[5] * y + m[9] * z + m[13] * w;
out[2] = m[2] * x + m[6] * y + m[10] * z + m[14] * w;
out[3] = m[3] * x + m[7] * y + m[11] * z + m[15] * w;
return out;
}
function transformQuat2(out, a2, q) {
const x = a2[0];
const y = a2[1];
const z = a2[2];
const qx = q[0];
const qy = q[1];
const qz = q[2];
const qw = q[3];
const ix = qw * x + qy * z - qz * y;
const iy = qw * y + qz * x - qx * z;
const iz = qw * z + qx * y - qy * x;
const iw = -qx * x - qy * y - qz * z;
out[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
out[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
out[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
out[3] = a2[3];
return out;
}
var forEach3 = function() {
const vec = create4();
return function(a2, stride, offset, count, fn, arg) {
let i2;
let l2;
if (!stride) {
stride = 4;
}
if (!offset) {
offset = 0;
}
if (count) {
l2 = Math.min(count * stride + offset, a2.length);
} else {
l2 = a2.length;
}
for (i2 = offset; i2 < l2; i2 += stride) {
vec[0] = a2[i2];
vec[1] = a2[i2 + 1];
vec[2] = a2[i2 + 2];
vec[3] = a2[i2 + 3];
fn(vec, vec, arg);
a2[i2] = vec[0];
a2[i2 + 1] = vec[1];
a2[i2 + 2] = vec[2];
a2[i2 + 3] = vec[3];
}
return a2;
};
}();
// ../../node_modules/@math.gl/core/dist/classes/matrix4.js
var INDICES;
(function(INDICES3) {
INDICES3[INDICES3["COL0ROW0"] = 0] = "COL0ROW0";
INDICES3[INDICES3["COL0ROW1"] = 1] = "COL0ROW1";
INDICES3[INDICES3["COL0ROW2"] = 2] = "COL0ROW2";
INDICES3[INDICES3["COL0ROW3"] = 3] = "COL0ROW3";
INDICES3[INDICES3["COL1ROW0"] = 4] = "COL1ROW0";
INDICES3[INDICES3["COL1ROW1"] = 5] = "COL1ROW1";
INDICES3[INDICES3["COL1ROW2"] = 6] = "COL1ROW2";
INDICES3[INDICES3["COL1ROW3"] = 7] = "COL1ROW3";
INDICES3[INDICES3["COL2ROW0"] = 8] = "COL2ROW0";
INDICES3[INDICES3["COL2ROW1"] = 9] = "COL2ROW1";
INDICES3[INDICES3["COL2ROW2"] = 10] = "COL2ROW2";
INDICES3[INDICES3["COL2ROW3"] = 11] = "COL2ROW3";
INDICES3[INDICES3["COL3ROW0"] = 12] = "COL3ROW0";
INDICES3[INDICES3["COL3ROW1"] = 13] = "COL3ROW1";
INDICES3[INDICES3["COL3ROW2"] = 14] = "COL3ROW2";
INDICES3[INDICES3["COL3ROW3"] = 15] = "COL3ROW3";
})(INDICES || (INDICES = {}));
var DEFAULT_FOVY = 45 * Math.PI / 180;
var DEFAULT_ASPECT = 1;
var DEFAULT_NEAR = 0.1;
var DEFAULT_FAR = 500;
var IDENTITY_MATRIX = Object.freeze([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
var Matrix4 = class extends Matrix {
static get IDENTITY() {
return getIdentityMatrix();
}
static get ZERO() {
return getZeroMatrix();
}
get ELEMENTS() {
return 16;
}
get RANK() {
return 4;
}
get INDICES() {
return INDICES;
}
constructor(array) {
super(-0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0, -0);
if (arguments.length === 1 && Array.isArray(array)) {
this.copy(array);
} else {
this.identity();
}
}
copy(array) {
this[0] = array[0];
this[1] = array[1];
this[2] = array[2];
this[3] = array[3];
this[4] = array[4];
this[5] = array[5];
this[6] = array[6];
this[7] = array[7];
this[8] = array[8];
this[9] = array[9];
this[10] = array[10];
this[11] = array[11];
this[12] = array[12];
this[13] = array[13];
this[14] = array[14];
this[15] = array[15];
return this.check();
}
// eslint-disable-next-line max-params
set(m00, m10, m20, m30, m01, m11, m21, m31, m02, m12, m22, m32, m03, m13, m23, m33) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m30;
this[4] = m01;
this[5] = m11;
this[6] = m21;
this[7] = m31;
this[8] = m02;
this[9] = m12;
this[10] = m22;
this[11] = m32;
this[12] = m03;
this[13] = m13;
this[14] = m23;
this[15] = m33;
return this.check();
}
// accepts row major order, stores as column major
// eslint-disable-next-line max-params
setRowMajor(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
this[0] = m00;
this[1] = m10;
this[2] = m20;
this[3] = m30;
this[4] = m01;
this[5] = m11;
this[6] = m21;
this[7] = m31;
this[8] = m02;
this[9] = m12;
this[10] = m22;
this[11] = m32;
this[12] = m03;
this[13] = m13;
this[14] = m23;
this[15] = m33;
return this.check();
}
toRowMajor(result) {
result[0] = this[0];
result[1] = this[4];
result[2] = this[8];
result[3] = this[12];
result[4] = this[1];
result[5] = this[5];
result[6] = this[9];
result[7] = this[13];
result[8] = this[2];
result[9] = this[6];
result[10] = this[10];
result[11] = this[14];
result[12] = this[3];
result[13] = this[7];
result[14] = this[11];
result[15] = this[15];
return result;
}
// Constructors
/** Set to identity matrix */
identity() {
return this.copy(IDENTITY_MATRIX);
}
/**
*
* @param object
* @returns self
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
fromObject(object) {
return this.check();
}
/**
* Calculates a 4x4 matrix from the given quaternion
* @param quaternion Quaternion to create matrix from
* @returns self
*/
fromQuaternion(quaternion) {
fromQuat(this, quaternion);
return this.check();
}
/**
* Generates a frustum matrix with the given bounds
* @param view.left - Left bound of the frustum
* @param view.right - Right bound of the frustum
* @param view.bottom - Bottom bound of the frustum
* @param view.top - Top bound of the frustum
* @param view.near - Near bound of the frustum
* @param view.far - Far bound of the frustum. Can be set to Infinity.
* @returns self
*/
frustum(view) {
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
if (far === Infinity) {
computeInfinitePerspectiveOffCenter(this, left, right, bottom, top, near);
} else {
frustum(this, left, right, bottom, top, near, far);
}
return this.check();
}
/**
* Generates a look-at matrix with the given eye position, focal point,
* and up axis
* @param view.eye - (vector) Position of the viewer
* @param view.center - (vector) Point the viewer is looking at
* @param view.up - (vector) Up axis
* @returns self
*/
lookAt(view) {
const { eye, center = [0, 0, 0], up = [0, 1, 0] } = view;
lookAt(this, eye, center, up);
return this.check();
}
/**
* Generates a orthogonal projection matrix with the given bounds
* from "traditional" view space parameters
* @param view.left - Left bound of the frustum
* @param view.right number Right bound of the frustum
* @param view.bottom - Bottom bound of the frustum
* @param view.top number Top bound of the frustum
* @param view.near - Near bound of the frustum
* @param view.far number Far bound of the frustum
* @returns self
*/
ortho(view) {
const { left, right, bottom, top, near = DEFAULT_NEAR, far = DEFAULT_FAR } = view;
ortho(this, left, right, bottom, top, near, far);
return this.check();
}
/**
* Generates an orthogonal projection matrix with the same parameters
* as a perspective matrix (plus focalDistance)
* @param view.fovy Vertical field