@shopware-ag/dive
Version:
Shopware Spatial Framework
1,423 lines • 1.01 MB
JavaScript
/**
* @license
* Copyright 2010-2023 Three.js Authors
* SPDX-License-Identifier: MIT
*/
const Gu = "163", Ps = { ROTATE: 0, DOLLY: 1, PAN: 2 }, Ls = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, OE = 0, Ep = 1, NE = 2, Ng = 1, Fg = 2, sr = 3, Fi = 0, Gn = 1, yi = 2, Nr = 0, ro = 1, bp = 2, Tp = 3, Ap = 4, FE = 5, os = 100, BE = 101, zE = 102, kE = 103, HE = 104, GE = 200, VE = 201, WE = 202, XE = 203, vu = 204, xu = 205, YE = 206, jE = 207, qE = 208, KE = 209, ZE = 210, $E = 211, JE = 212, QE = 213, eb = 214, tb = 0, nb = 1, ib = 2, Jc = 3, rb = 4, sb = 5, ob = 6, ab = 7, Bg = 0, cb = 1, lb = 2, lr = 0, hb = 1, ub = 2, fb = 3, db = 4, pb = 5, mb = 6, gb = 7, wp = "attached", _b = "detached", zg = 300, co = 301, lo = 302, yu = 303, Su = 304, ll = 306, ho = 1e3, Dr = 1001, Qc = 1002, Nn = 1003, kg = 1004, ra = 1005, Hn = 1006, jc = 1007, or = 1008, Fr = 1009, vb = 1010, xb = 1011, Hg = 1012, Gg = 1013, uo = 1014, Oi = 1015, el = 1016, Vg = 1017, Wg = 1018, xa = 1020, yb = 35902, Sb = 1021, Mb = 1022, Ei = 1023, Eb = 1024, bb = 1025, so = 1026, ma = 1027, Xg = 1028, Yg = 1029, Tb = 1030, jg = 1031, qg = 1033, Ah = 33776, wh = 33777, Rh = 33778, Ch = 33779, Rp = 35840, Cp = 35841, Pp = 35842, Lp = 35843, Kg = 36196, Ip = 37492, Dp = 37496, Up = 37808, Op = 37809, Np = 37810, Fp = 37811, Bp = 37812, zp = 37813, kp = 37814, Hp = 37815, Gp = 37816, Vp = 37817, Wp = 37818, Xp = 37819, Yp = 37820, jp = 37821, Ph = 36492, qp = 36494, Kp = 36495, Ab = 36283, Zp = 36284, $p = 36285, Jp = 36286, ga = 2300, fo = 2301, Lh = 2302, Qp = 2400, em = 2401, tm = 2402, wb = 2500, Rb = 0, Zg = 1, Mu = 2, Cb = 3200, Pb = 3201, $g = 0, Lb = 1, Ir = "", mn = "srgb", gn = "srgb-linear", Vu = "display-p3", hl = "display-p3-linear", tl = "linear", Gt = "srgb", nl = "rec709", il = "p3", Is = 7680, nm = 519, Ib = 512, Db = 513, Ub = 514, Jg = 515, Ob = 516, Nb = 517, Fb = 518, Bb = 519, Eu = 35044, im = "300 es", ar = 2e3, rl = 2001;
class fs {
addEventListener(e, t) {
this._listeners === void 0 && (this._listeners = {});
const n = this._listeners;
n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);
}
hasEventListener(e, t) {
if (this._listeners === void 0) return !1;
const n = this._listeners;
return n[e] !== void 0 && n[e].indexOf(t) !== -1;
}
removeEventListener(e, t) {
if (this._listeners === void 0) return;
const i = this._listeners[e];
if (i !== void 0) {
const o = i.indexOf(t);
o !== -1 && i.splice(o, 1);
}
}
dispatchEvent(e) {
if (this._listeners === void 0) return;
const n = this._listeners[e.type];
if (n !== void 0) {
e.target = this;
const i = n.slice(0);
for (let o = 0, c = i.length; o < c; o++)
i[o].call(this, e);
e.target = null;
}
}
}
const bn = ["00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "0a", "0b", "0c", "0d", "0e", "0f", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "1a", "1b", "1c", "1d", "1e", "1f", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "2a", "2b", "2c", "2d", "2e", "2f", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "3a", "3b", "3c", "3d", "3e", "3f", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "4a", "4b", "4c", "4d", "4e", "4f", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "5a", "5b", "5c", "5d", "5e", "5f", "60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "6a", "6b", "6c", "6d", "6e", "6f", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "7a", "7b", "7c", "7d", "7e", "7f", "80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "8a", "8b", "8c", "8d", "8e", "8f", "90", "91", "92", "93", "94", "95", "96", "97", "98", "99", "9a", "9b", "9c", "9d", "9e", "9f", "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8", "a9", "aa", "ab", "ac", "ad", "ae", "af", "b0", "b1", "b2", "b3", "b4", "b5", "b6", "b7", "b8", "b9", "ba", "bb", "bc", "bd", "be", "bf", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "ca", "cb", "cc", "cd", "ce", "cf", "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", "d8", "d9", "da", "db", "dc", "dd", "de", "df", "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9", "ea", "eb", "ec", "ed", "ee", "ef", "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "fa", "fb", "fc", "fd", "fe", "ff"];
let rm = 1234567;
const ua = Math.PI / 180, po = 180 / Math.PI;
function bi() {
const s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0;
return (bn[s & 255] + bn[s >> 8 & 255] + bn[s >> 16 & 255] + bn[s >> 24 & 255] + "-" + bn[e & 255] + bn[e >> 8 & 255] + "-" + bn[e >> 16 & 15 | 64] + bn[e >> 24 & 255] + "-" + bn[t & 63 | 128] + bn[t >> 8 & 255] + "-" + bn[t >> 16 & 255] + bn[t >> 24 & 255] + bn[n & 255] + bn[n >> 8 & 255] + bn[n >> 16 & 255] + bn[n >> 24 & 255]).toLowerCase();
}
function xn(s, e, t) {
return Math.max(e, Math.min(t, s));
}
function Wu(s, e) {
return (s % e + e) % e;
}
function zb(s, e, t, n, i) {
return n + (s - e) * (i - n) / (t - e);
}
function kb(s, e, t) {
return s !== e ? (t - s) / (e - s) : 0;
}
function fa(s, e, t) {
return (1 - t) * s + t * e;
}
function Hb(s, e, t, n) {
return fa(s, e, 1 - Math.exp(-t * n));
}
function Gb(s, e = 1) {
return e - Math.abs(Wu(s, e * 2) - e);
}
function Vb(s, e, t) {
return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * (3 - 2 * s));
}
function Wb(s, e, t) {
return s <= e ? 0 : s >= t ? 1 : (s = (s - e) / (t - e), s * s * s * (s * (s * 6 - 15) + 10));
}
function Xb(s, e) {
return s + Math.floor(Math.random() * (e - s + 1));
}
function Yb(s, e) {
return s + Math.random() * (e - s);
}
function jb(s) {
return s * (0.5 - Math.random());
}
function qb(s) {
s !== void 0 && (rm = s);
let e = rm += 1831565813;
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
}
function Kb(s) {
return s * ua;
}
function Zb(s) {
return s * po;
}
function $b(s) {
return (s & s - 1) === 0 && s !== 0;
}
function Jb(s) {
return Math.pow(2, Math.ceil(Math.log(s) / Math.LN2));
}
function Qb(s) {
return Math.pow(2, Math.floor(Math.log(s) / Math.LN2));
}
function eT(s, e, t, n, i) {
const o = Math.cos, c = Math.sin, l = o(t / 2), u = c(t / 2), f = o((e + n) / 2), d = c((e + n) / 2), p = o((e - n) / 2), m = c((e - n) / 2), v = o((n - e) / 2), S = c((n - e) / 2);
switch (i) {
case "XYX":
s.set(l * d, u * p, u * m, l * f);
break;
case "YZY":
s.set(u * m, l * d, u * p, l * f);
break;
case "ZXZ":
s.set(u * p, u * m, l * d, l * f);
break;
case "XZX":
s.set(l * d, u * S, u * v, l * f);
break;
case "YXY":
s.set(u * v, l * d, u * S, l * f);
break;
case "ZYZ":
s.set(u * S, u * v, l * d, l * f);
break;
default:
console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i);
}
}
function Si(s, e) {
switch (e.constructor) {
case Float32Array:
return s;
case Uint32Array:
return s / 4294967295;
case Uint16Array:
return s / 65535;
case Uint8Array:
return s / 255;
case Int32Array:
return Math.max(s / 2147483647, -1);
case Int16Array:
return Math.max(s / 32767, -1);
case Int8Array:
return Math.max(s / 127, -1);
default:
throw new Error("Invalid component type.");
}
}
function Lt(s, e) {
switch (e.constructor) {
case Float32Array:
return s;
case Uint32Array:
return Math.round(s * 4294967295);
case Uint16Array:
return Math.round(s * 65535);
case Uint8Array:
return Math.round(s * 255);
case Int32Array:
return Math.round(s * 2147483647);
case Int16Array:
return Math.round(s * 32767);
case Int8Array:
return Math.round(s * 127);
default:
throw new Error("Invalid component type.");
}
}
const Bi = {
DEG2RAD: ua,
RAD2DEG: po,
generateUUID: bi,
clamp: xn,
euclideanModulo: Wu,
mapLinear: zb,
inverseLerp: kb,
lerp: fa,
damp: Hb,
pingpong: Gb,
smoothstep: Vb,
smootherstep: Wb,
randInt: Xb,
randFloat: Yb,
randFloatSpread: jb,
seededRandom: qb,
degToRad: Kb,
radToDeg: Zb,
isPowerOfTwo: $b,
ceilPowerOfTwo: Jb,
floorPowerOfTwo: Qb,
setQuaternionFromProperEuler: eT,
normalize: Lt,
denormalize: Si
};
class Ie {
constructor(e = 0, t = 0) {
Ie.prototype.isVector2 = !0, this.x = e, this.y = t;
}
get width() {
return this.x;
}
set width(e) {
this.x = e;
}
get height() {
return this.y;
}
set height(e) {
this.y = e;
}
set(e, t) {
return this.x = e, this.y = t, this;
}
setScalar(e) {
return this.x = e, this.y = e, this;
}
setX(e) {
return this.x = e, this;
}
setY(e) {
return this.y = e, this;
}
setComponent(e, t) {
switch (e) {
case 0:
this.x = t;
break;
case 1:
this.y = t;
break;
default:
throw new Error("index is out of range: " + e);
}
return this;
}
getComponent(e) {
switch (e) {
case 0:
return this.x;
case 1:
return this.y;
default:
throw new Error("index is out of range: " + e);
}
}
clone() {
return new this.constructor(this.x, this.y);
}
copy(e) {
return this.x = e.x, this.y = e.y, this;
}
add(e) {
return this.x += e.x, this.y += e.y, this;
}
addScalar(e) {
return this.x += e, this.y += e, this;
}
addVectors(e, t) {
return this.x = e.x + t.x, this.y = e.y + t.y, this;
}
addScaledVector(e, t) {
return this.x += e.x * t, this.y += e.y * t, this;
}
sub(e) {
return this.x -= e.x, this.y -= e.y, this;
}
subScalar(e) {
return this.x -= e, this.y -= e, this;
}
subVectors(e, t) {
return this.x = e.x - t.x, this.y = e.y - t.y, this;
}
multiply(e) {
return this.x *= e.x, this.y *= e.y, this;
}
multiplyScalar(e) {
return this.x *= e, this.y *= e, this;
}
divide(e) {
return this.x /= e.x, this.y /= e.y, this;
}
divideScalar(e) {
return this.multiplyScalar(1 / e);
}
applyMatrix3(e) {
const t = this.x, n = this.y, i = e.elements;
return this.x = i[0] * t + i[3] * n + i[6], this.y = i[1] * t + i[4] * n + i[7], this;
}
min(e) {
return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this;
}
max(e) {
return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this;
}
clamp(e, t) {
return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this;
}
clampScalar(e, t) {
return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this;
}
clampLength(e, t) {
const n = this.length();
return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
}
floor() {
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
}
ceil() {
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
}
round() {
return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
}
roundToZero() {
return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
}
negate() {
return this.x = -this.x, this.y = -this.y, this;
}
dot(e) {
return this.x * e.x + this.y * e.y;
}
cross(e) {
return this.x * e.y - this.y * e.x;
}
lengthSq() {
return this.x * this.x + this.y * this.y;
}
length() {
return Math.sqrt(this.x * this.x + this.y * this.y);
}
manhattanLength() {
return Math.abs(this.x) + Math.abs(this.y);
}
normalize() {
return this.divideScalar(this.length() || 1);
}
angle() {
return Math.atan2(-this.y, -this.x) + Math.PI;
}
angleTo(e) {
const t = Math.sqrt(this.lengthSq() * e.lengthSq());
if (t === 0) return Math.PI / 2;
const n = this.dot(e) / t;
return Math.acos(xn(n, -1, 1));
}
distanceTo(e) {
return Math.sqrt(this.distanceToSquared(e));
}
distanceToSquared(e) {
const t = this.x - e.x, n = this.y - e.y;
return t * t + n * n;
}
manhattanDistanceTo(e) {
return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);
}
setLength(e) {
return this.normalize().multiplyScalar(e);
}
lerp(e, t) {
return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;
}
lerpVectors(e, t, n) {
return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this;
}
equals(e) {
return e.x === this.x && e.y === this.y;
}
fromArray(e, t = 0) {
return this.x = e[t], this.y = e[t + 1], this;
}
toArray(e = [], t = 0) {
return e[t] = this.x, e[t + 1] = this.y, e;
}
fromBufferAttribute(e, t) {
return this.x = e.getX(t), this.y = e.getY(t), this;
}
rotateAround(e, t) {
const n = Math.cos(t), i = Math.sin(t), o = this.x - e.x, c = this.y - e.y;
return this.x = o * n - c * i + e.x, this.y = o * i + c * n + e.y, this;
}
random() {
return this.x = Math.random(), this.y = Math.random(), this;
}
*[Symbol.iterator]() {
yield this.x, yield this.y;
}
}
class lt {
constructor(e, t, n, i, o, c, l, u, f) {
lt.prototype.isMatrix3 = !0, this.elements = [
1,
0,
0,
0,
1,
0,
0,
0,
1
], e !== void 0 && this.set(e, t, n, i, o, c, l, u, f);
}
set(e, t, n, i, o, c, l, u, f) {
const d = this.elements;
return d[0] = e, d[1] = i, d[2] = l, d[3] = t, d[4] = o, d[5] = u, d[6] = n, d[7] = c, d[8] = f, this;
}
identity() {
return this.set(
1,
0,
0,
0,
1,
0,
0,
0,
1
), this;
}
copy(e) {
const t = this.elements, n = e.elements;
return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this;
}
extractBasis(e, t, n) {
return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this;
}
setFromMatrix4(e) {
const t = e.elements;
return this.set(
t[0],
t[4],
t[8],
t[1],
t[5],
t[9],
t[2],
t[6],
t[10]
), this;
}
multiply(e) {
return this.multiplyMatrices(this, e);
}
premultiply(e) {
return this.multiplyMatrices(e, this);
}
multiplyMatrices(e, t) {
const n = e.elements, i = t.elements, o = this.elements, c = n[0], l = n[3], u = n[6], f = n[1], d = n[4], p = n[7], m = n[2], v = n[5], S = n[8], b = i[0], x = i[3], _ = i[6], R = i[1], E = i[4], L = i[7], B = i[2], N = i[5], D = i[8];
return o[0] = c * b + l * R + u * B, o[3] = c * x + l * E + u * N, o[6] = c * _ + l * L + u * D, o[1] = f * b + d * R + p * B, o[4] = f * x + d * E + p * N, o[7] = f * _ + d * L + p * D, o[2] = m * b + v * R + S * B, o[5] = m * x + v * E + S * N, o[8] = m * _ + v * L + S * D, this;
}
multiplyScalar(e) {
const t = this.elements;
return t[0] *= e, t[3] *= e, t[6] *= e, t[1] *= e, t[4] *= e, t[7] *= e, t[2] *= e, t[5] *= e, t[8] *= e, this;
}
determinant() {
const e = this.elements, t = e[0], n = e[1], i = e[2], o = e[3], c = e[4], l = e[5], u = e[6], f = e[7], d = e[8];
return t * c * d - t * l * f - n * o * d + n * l * u + i * o * f - i * c * u;
}
invert() {
const e = this.elements, t = e[0], n = e[1], i = e[2], o = e[3], c = e[4], l = e[5], u = e[6], f = e[7], d = e[8], p = d * c - l * f, m = l * u - d * o, v = f * o - c * u, S = t * p + n * m + i * v;
if (S === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
const b = 1 / S;
return e[0] = p * b, e[1] = (i * f - d * n) * b, e[2] = (l * n - i * c) * b, e[3] = m * b, e[4] = (d * t - i * u) * b, e[5] = (i * o - l * t) * b, e[6] = v * b, e[7] = (n * u - f * t) * b, e[8] = (c * t - n * o) * b, this;
}
transpose() {
let e;
const t = this.elements;
return e = t[1], t[1] = t[3], t[3] = e, e = t[2], t[2] = t[6], t[6] = e, e = t[5], t[5] = t[7], t[7] = e, this;
}
getNormalMatrix(e) {
return this.setFromMatrix4(e).invert().transpose();
}
transposeIntoArray(e) {
const t = this.elements;
return e[0] = t[0], e[1] = t[3], e[2] = t[6], e[3] = t[1], e[4] = t[4], e[5] = t[7], e[6] = t[2], e[7] = t[5], e[8] = t[8], this;
}
setUvTransform(e, t, n, i, o, c, l) {
const u = Math.cos(o), f = Math.sin(o);
return this.set(
n * u,
n * f,
-n * (u * c + f * l) + c + e,
-i * f,
i * u,
-i * (-f * c + u * l) + l + t,
0,
0,
1
), this;
}
//
scale(e, t) {
return this.premultiply(Ih.makeScale(e, t)), this;
}
rotate(e) {
return this.premultiply(Ih.makeRotation(-e)), this;
}
translate(e, t) {
return this.premultiply(Ih.makeTranslation(e, t)), this;
}
// for 2D Transforms
makeTranslation(e, t) {
return e.isVector2 ? this.set(
1,
0,
e.x,
0,
1,
e.y,
0,
0,
1
) : this.set(
1,
0,
e,
0,
1,
t,
0,
0,
1
), this;
}
makeRotation(e) {
const t = Math.cos(e), n = Math.sin(e);
return this.set(
t,
-n,
0,
n,
t,
0,
0,
0,
1
), this;
}
makeScale(e, t) {
return this.set(
e,
0,
0,
0,
t,
0,
0,
0,
1
), this;
}
//
equals(e) {
const t = this.elements, n = e.elements;
for (let i = 0; i < 9; i++)
if (t[i] !== n[i]) return !1;
return !0;
}
fromArray(e, t = 0) {
for (let n = 0; n < 9; n++)
this.elements[n] = e[n + t];
return this;
}
toArray(e = [], t = 0) {
const n = this.elements;
return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e;
}
clone() {
return new this.constructor().fromArray(this.elements);
}
}
const Ih = /* @__PURE__ */ new lt();
function Qg(s) {
for (let e = s.length - 1; e >= 0; --e)
if (s[e] >= 65535) return !0;
return !1;
}
function _a(s) {
return document.createElementNS("http://www.w3.org/1999/xhtml", s);
}
function tT() {
const s = _a("canvas");
return s.style.display = "block", s;
}
const sm = {};
function e_(s) {
s in sm || (sm[s] = !0, console.warn(s));
}
const om = /* @__PURE__ */ new lt().set(
0.8224621,
0.177538,
0,
0.0331941,
0.9668058,
0,
0.0170827,
0.0723974,
0.9105199
), am = /* @__PURE__ */ new lt().set(
1.2249401,
-0.2249404,
0,
-0.0420569,
1.0420571,
0,
-0.0196376,
-0.0786361,
1.0982735
), uc = {
[gn]: {
transfer: tl,
primaries: nl,
toReference: (s) => s,
fromReference: (s) => s
},
[mn]: {
transfer: Gt,
primaries: nl,
toReference: (s) => s.convertSRGBToLinear(),
fromReference: (s) => s.convertLinearToSRGB()
},
[hl]: {
transfer: tl,
primaries: il,
toReference: (s) => s.applyMatrix3(am),
fromReference: (s) => s.applyMatrix3(om)
},
[Vu]: {
transfer: Gt,
primaries: il,
toReference: (s) => s.convertSRGBToLinear().applyMatrix3(am),
fromReference: (s) => s.applyMatrix3(om).convertLinearToSRGB()
}
}, nT = /* @__PURE__ */ new Set([gn, hl]), Ct = {
enabled: !0,
_workingColorSpace: gn,
get workingColorSpace() {
return this._workingColorSpace;
},
set workingColorSpace(s) {
if (!nT.has(s))
throw new Error(`Unsupported working color space, "${s}".`);
this._workingColorSpace = s;
},
convert: function(s, e, t) {
if (this.enabled === !1 || e === t || !e || !t)
return s;
const n = uc[e].toReference, i = uc[t].fromReference;
return i(n(s));
},
fromWorkingColorSpace: function(s, e) {
return this.convert(s, this._workingColorSpace, e);
},
toWorkingColorSpace: function(s, e) {
return this.convert(s, e, this._workingColorSpace);
},
getPrimaries: function(s) {
return uc[s].primaries;
},
getTransfer: function(s) {
return s === Ir ? tl : uc[s].transfer;
}
};
function oo(s) {
return s < 0.04045 ? s * 0.0773993808 : Math.pow(s * 0.9478672986 + 0.0521327014, 2.4);
}
function Dh(s) {
return s < 31308e-7 ? s * 12.92 : 1.055 * Math.pow(s, 0.41666) - 0.055;
}
let Ds;
class iT {
static getDataURL(e) {
if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u")
return e.src;
let t;
if (e instanceof HTMLCanvasElement)
t = e;
else {
Ds === void 0 && (Ds = _a("canvas")), Ds.width = e.width, Ds.height = e.height;
const n = Ds.getContext("2d");
e instanceof ImageData ? n.putImageData(e, 0, 0) : n.drawImage(e, 0, 0, e.width, e.height), t = Ds;
}
return t.width > 2048 || t.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", e), t.toDataURL("image/jpeg", 0.6)) : t.toDataURL("image/png");
}
static sRGBToLinear(e) {
if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
const t = _a("canvas");
t.width = e.width, t.height = e.height;
const n = t.getContext("2d");
n.drawImage(e, 0, 0, e.width, e.height);
const i = n.getImageData(0, 0, e.width, e.height), o = i.data;
for (let c = 0; c < o.length; c++)
o[c] = oo(o[c] / 255) * 255;
return n.putImageData(i, 0, 0), t;
} else if (e.data) {
const t = e.data.slice(0);
for (let n = 0; n < t.length; n++)
t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[n] = Math.floor(oo(t[n] / 255) * 255) : t[n] = oo(t[n]);
return {
data: t,
width: e.width,
height: e.height
};
} else
return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;
}
}
let rT = 0;
class t_ {
constructor(e = null) {
this.isSource = !0, Object.defineProperty(this, "id", { value: rT++ }), this.uuid = bi(), this.data = e, this.dataReady = !0, this.version = 0;
}
set needsUpdate(e) {
e === !0 && this.version++;
}
toJSON(e) {
const t = e === void 0 || typeof e == "string";
if (!t && e.images[this.uuid] !== void 0)
return e.images[this.uuid];
const n = {
uuid: this.uuid,
url: ""
}, i = this.data;
if (i !== null) {
let o;
if (Array.isArray(i)) {
o = [];
for (let c = 0, l = i.length; c < l; c++)
i[c].isDataTexture ? o.push(Uh(i[c].image)) : o.push(Uh(i[c]));
} else
o = Uh(i);
n.url = o;
}
return t || (e.images[this.uuid] = n), n;
}
}
function Uh(s) {
return typeof HTMLImageElement < "u" && s instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && s instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && s instanceof ImageBitmap ? iT.getDataURL(s) : s.data ? {
data: Array.from(s.data),
width: s.width,
height: s.height,
type: s.data.constructor.name
} : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let sT = 0;
class an extends fs {
constructor(e = an.DEFAULT_IMAGE, t = an.DEFAULT_MAPPING, n = Dr, i = Dr, o = Hn, c = or, l = Ei, u = Fr, f = an.DEFAULT_ANISOTROPY, d = Ir) {
super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: sT++ }), this.uuid = bi(), this.name = "", this.source = new t_(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = n, this.wrapT = i, this.magFilter = o, this.minFilter = c, this.anisotropy = f, this.format = l, this.internalFormat = null, this.type = u, this.offset = new Ie(0, 0), this.repeat = new Ie(1, 1), this.center = new Ie(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new lt(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = d, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.pmremVersion = 0;
}
get image() {
return this.source.data;
}
set image(e = null) {
this.source.data = e;
}
updateMatrix() {
this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
}
clone() {
return new this.constructor().copy(this);
}
copy(e) {
return this.name = e.name, this.source = e.source, this.mipmaps = e.mipmaps.slice(0), this.mapping = e.mapping, this.channel = e.channel, this.wrapS = e.wrapS, this.wrapT = e.wrapT, this.magFilter = e.magFilter, this.minFilter = e.minFilter, this.anisotropy = e.anisotropy, this.format = e.format, this.internalFormat = e.internalFormat, this.type = e.type, this.offset.copy(e.offset), this.repeat.copy(e.repeat), this.center.copy(e.center), this.rotation = e.rotation, this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrix.copy(e.matrix), this.generateMipmaps = e.generateMipmaps, this.premultiplyAlpha = e.premultiplyAlpha, this.flipY = e.flipY, this.unpackAlignment = e.unpackAlignment, this.colorSpace = e.colorSpace, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;
}
toJSON(e) {
const t = e === void 0 || typeof e == "string";
if (!t && e.textures[this.uuid] !== void 0)
return e.textures[this.uuid];
const n = {
metadata: {
version: 4.6,
type: "Texture",
generator: "Texture.toJSON"
},
uuid: this.uuid,
name: this.name,
image: this.source.toJSON(e).uuid,
mapping: this.mapping,
channel: this.channel,
repeat: [this.repeat.x, this.repeat.y],
offset: [this.offset.x, this.offset.y],
center: [this.center.x, this.center.y],
rotation: this.rotation,
wrap: [this.wrapS, this.wrapT],
format: this.format,
internalFormat: this.internalFormat,
type: this.type,
colorSpace: this.colorSpace,
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
flipY: this.flipY,
generateMipmaps: this.generateMipmaps,
premultiplyAlpha: this.premultiplyAlpha,
unpackAlignment: this.unpackAlignment
};
return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
transformUv(e) {
if (this.mapping !== zg) return e;
if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)
switch (this.wrapS) {
case ho:
e.x = e.x - Math.floor(e.x);
break;
case Dr:
e.x = e.x < 0 ? 0 : 1;
break;
case Qc:
Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x = e.x - Math.floor(e.x);
break;
}
if (e.y < 0 || e.y > 1)
switch (this.wrapT) {
case ho:
e.y = e.y - Math.floor(e.y);
break;
case Dr:
e.y = e.y < 0 ? 0 : 1;
break;
case Qc:
Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y = e.y - Math.floor(e.y);
break;
}
return this.flipY && (e.y = 1 - e.y), e;
}
set needsUpdate(e) {
e === !0 && (this.version++, this.source.needsUpdate = !0);
}
set needsPMREMUpdate(e) {
e === !0 && this.pmremVersion++;
}
}
an.DEFAULT_IMAGE = null;
an.DEFAULT_MAPPING = zg;
an.DEFAULT_ANISOTROPY = 1;
class Dt {
constructor(e = 0, t = 0, n = 0, i = 1) {
Dt.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = n, this.w = i;
}
get width() {
return this.z;
}
set width(e) {
this.z = e;
}
get height() {
return this.w;
}
set height(e) {
this.w = e;
}
set(e, t, n, i) {
return this.x = e, this.y = t, this.z = n, this.w = i, this;
}
setScalar(e) {
return this.x = e, this.y = e, this.z = e, this.w = e, this;
}
setX(e) {
return this.x = e, this;
}
setY(e) {
return this.y = e, this;
}
setZ(e) {
return this.z = e, this;
}
setW(e) {
return this.w = e, this;
}
setComponent(e, t) {
switch (e) {
case 0:
this.x = t;
break;
case 1:
this.y = t;
break;
case 2:
this.z = t;
break;
case 3:
this.w = t;
break;
default:
throw new Error("index is out of range: " + e);
}
return this;
}
getComponent(e) {
switch (e) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
case 3:
return this.w;
default:
throw new Error("index is out of range: " + e);
}
}
clone() {
return new this.constructor(this.x, this.y, this.z, this.w);
}
copy(e) {
return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w !== void 0 ? e.w : 1, this;
}
add(e) {
return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;
}
addScalar(e) {
return this.x += e, this.y += e, this.z += e, this.w += e, this;
}
addVectors(e, t) {
return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this.w = e.w + t.w, this;
}
addScaledVector(e, t) {
return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this;
}
sub(e) {
return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;
}
subScalar(e) {
return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;
}
subVectors(e, t) {
return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this.w = e.w - t.w, this;
}
multiply(e) {
return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;
}
multiplyScalar(e) {
return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;
}
applyMatrix4(e) {
const t = this.x, n = this.y, i = this.z, o = this.w, c = e.elements;
return this.x = c[0] * t + c[4] * n + c[8] * i + c[12] * o, this.y = c[1] * t + c[5] * n + c[9] * i + c[13] * o, this.z = c[2] * t + c[6] * n + c[10] * i + c[14] * o, this.w = c[3] * t + c[7] * n + c[11] * i + c[15] * o, this;
}
divideScalar(e) {
return this.multiplyScalar(1 / e);
}
setAxisAngleFromQuaternion(e) {
this.w = 2 * Math.acos(e.w);
const t = Math.sqrt(1 - e.w * e.w);
return t < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = e.x / t, this.y = e.y / t, this.z = e.z / t), this;
}
setAxisAngleFromRotationMatrix(e) {
let t, n, i, o;
const u = e.elements, f = u[0], d = u[4], p = u[8], m = u[1], v = u[5], S = u[9], b = u[2], x = u[6], _ = u[10];
if (Math.abs(d - m) < 0.01 && Math.abs(p - b) < 0.01 && Math.abs(S - x) < 0.01) {
if (Math.abs(d + m) < 0.1 && Math.abs(p + b) < 0.1 && Math.abs(S + x) < 0.1 && Math.abs(f + v + _ - 3) < 0.1)
return this.set(1, 0, 0, 0), this;
t = Math.PI;
const E = (f + 1) / 2, L = (v + 1) / 2, B = (_ + 1) / 2, N = (d + m) / 4, D = (p + b) / 4, k = (S + x) / 4;
return E > L && E > B ? E < 0.01 ? (n = 0, i = 0.707106781, o = 0.707106781) : (n = Math.sqrt(E), i = N / n, o = D / n) : L > B ? L < 0.01 ? (n = 0.707106781, i = 0, o = 0.707106781) : (i = Math.sqrt(L), n = N / i, o = k / i) : B < 0.01 ? (n = 0.707106781, i = 0.707106781, o = 0) : (o = Math.sqrt(B), n = D / o, i = k / o), this.set(n, i, o, t), this;
}
let R = Math.sqrt((x - S) * (x - S) + (p - b) * (p - b) + (m - d) * (m - d));
return Math.abs(R) < 1e-3 && (R = 1), this.x = (x - S) / R, this.y = (p - b) / R, this.z = (m - d) / R, this.w = Math.acos((f + v + _ - 1) / 2), this;
}
min(e) {
return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this.z = Math.min(this.z, e.z), this.w = Math.min(this.w, e.w), this;
}
max(e) {
return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this.z = Math.max(this.z, e.z), this.w = Math.max(this.w, e.w), this;
}
clamp(e, t) {
return this.x = Math.max(e.x, Math.min(t.x, this.x)), this.y = Math.max(e.y, Math.min(t.y, this.y)), this.z = Math.max(e.z, Math.min(t.z, this.z)), this.w = Math.max(e.w, Math.min(t.w, this.w)), this;
}
clampScalar(e, t) {
return this.x = Math.max(e, Math.min(t, this.x)), this.y = Math.max(e, Math.min(t, this.y)), this.z = Math.max(e, Math.min(t, this.z)), this.w = Math.max(e, Math.min(t, this.w)), this;
}
clampLength(e, t) {
const n = this.length();
return this.divideScalar(n || 1).multiplyScalar(Math.max(e, Math.min(t, n)));
}
floor() {
return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this.w = Math.floor(this.w), this;
}
ceil() {
return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this.w = Math.ceil(this.w), this;
}
round() {
return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this.w = Math.round(this.w), this;
}
roundToZero() {
return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this.w = Math.trunc(this.w), this;
}
negate() {
return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;
}
dot(e) {
return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;
}
lengthSq() {
return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
}
length() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
}
manhattanLength() {
return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
}
normalize() {
return this.divideScalar(this.length() || 1);
}
setLength(e) {
return this.normalize().multiplyScalar(e);
}
lerp(e, t) {
return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this.w += (e.w - this.w) * t, this;
}
lerpVectors(e, t, n) {
return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this;
}
equals(e) {
return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;
}
fromArray(e, t = 0) {
return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this;
}
toArray(e = [], t = 0) {
return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e;
}
fromBufferAttribute(e, t) {
return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this;
}
random() {
return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this;
}
*[Symbol.iterator]() {
yield this.x, yield this.y, yield this.z, yield this.w;
}
}
class oT extends fs {
constructor(e = 1, t = 1, n = {}) {
super(), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = 1, this.scissor = new Dt(0, 0, e, t), this.scissorTest = !1, this.viewport = new Dt(0, 0, e, t);
const i = { width: e, height: t, depth: 1 };
n = Object.assign({
generateMipmaps: !1,
internalFormat: null,
minFilter: Hn,
depthBuffer: !0,
stencilBuffer: !1,
depthTexture: null,
samples: 0,
count: 1
}, n);
const o = new an(i, n.mapping, n.wrapS, n.wrapT, n.magFilter, n.minFilter, n.format, n.type, n.anisotropy, n.colorSpace);
o.flipY = !1, o.generateMipmaps = n.generateMipmaps, o.internalFormat = n.internalFormat, this.textures = [];
const c = n.count;
for (let l = 0; l < c; l++)
this.textures[l] = o.clone(), this.textures[l].isRenderTargetTexture = !0;
this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.depthTexture = n.depthTexture, this.samples = n.samples;
}
get texture() {
return this.textures[0];
}
set texture(e) {
this.textures[0] = e;
}
setSize(e, t, n = 1) {
if (this.width !== e || this.height !== t || this.depth !== n) {
this.width = e, this.height = t, this.depth = n;
for (let i = 0, o = this.textures.length; i < o; i++)
this.textures[i].image.width = e, this.textures[i].image.height = t, this.textures[i].image.depth = n;
this.dispose();
}
this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);
}
clone() {
return new this.constructor().copy(this);
}
copy(e) {
this.width = e.width, this.height = e.height, this.depth = e.depth, this.scissor.copy(e.scissor), this.scissorTest = e.scissorTest, this.viewport.copy(e.viewport), this.textures.length = 0;
for (let n = 0, i = e.textures.length; n < i; n++)
this.textures[n] = e.textures[n].clone(), this.textures[n].isRenderTargetTexture = !0;
const t = Object.assign({}, e.texture.image);
return this.texture.source = new t_(t), this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
}
class hs extends oT {
constructor(e = 1, t = 1, n = {}) {
super(e, t, n), this.isWebGLRenderTarget = !0;
}
}
class n_ extends an {
constructor(e = null, t = 1, n = 1, i = 1) {
super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: n, depth: i }, this.magFilter = Nn, this.minFilter = Nn, this.wrapR = Dr, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
}
}
class aT extends an {
constructor(e = null, t = 1, n = 1, i = 1) {
super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: n, depth: i }, this.magFilter = Nn, this.minFilter = Nn, this.wrapR = Dr, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
}
}
class rn {
constructor(e = 0, t = 0, n = 0, i = 1) {
this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = i;
}
static slerpFlat(e, t, n, i, o, c, l) {
let u = n[i + 0], f = n[i + 1], d = n[i + 2], p = n[i + 3];
const m = o[c + 0], v = o[c + 1], S = o[c + 2], b = o[c + 3];
if (l === 0) {
e[t + 0] = u, e[t + 1] = f, e[t + 2] = d, e[t + 3] = p;
return;
}
if (l === 1) {
e[t + 0] = m, e[t + 1] = v, e[t + 2] = S, e[t + 3] = b;
return;
}
if (p !== b || u !== m || f !== v || d !== S) {
let x = 1 - l;
const _ = u * m + f * v + d * S + p * b, R = _ >= 0 ? 1 : -1, E = 1 - _ * _;
if (E > Number.EPSILON) {
const B = Math.sqrt(E), N = Math.atan2(B, _ * R);
x = Math.sin(x * N) / B, l = Math.sin(l * N) / B;
}
const L = l * R;
if (u = u * x + m * L, f = f * x + v * L, d = d * x + S * L, p = p * x + b * L, x === 1 - l) {
const B = 1 / Math.sqrt(u * u + f * f + d * d + p * p);
u *= B, f *= B, d *= B, p *= B;
}
}
e[t] = u, e[t + 1] = f, e[t + 2] = d, e[t + 3] = p;
}
static multiplyQuaternionsFlat(e, t, n, i, o, c) {
const l = n[i], u = n[i + 1], f = n[i + 2], d = n[i + 3], p = o[c], m = o[c + 1], v = o[c + 2], S = o[c + 3];
return e[t] = l * S + d * p + u * v - f * m, e[t + 1] = u * S + d * m + f * p - l * v, e[t + 2] = f * S + d * v + l * m - u * p, e[t + 3] = d * S - l * p - u * m - f * v, e;
}
get x() {
return this._x;
}
set x(e) {
this._x = e, this._onChangeCallback();
}
get y() {
return this._y;
}
set y(e) {
this._y = e, this._onChangeCallback();
}
get z() {
return this._z;
}
set z(e) {
this._z = e, this._onChangeCallback();
}
get w() {
return this._w;
}
set w(e) {
this._w = e, this._onChangeCallback();
}
set(e, t, n, i) {
return this._x = e, this._y = t, this._z = n, this._w = i, this._onChangeCallback(), this;
}
clone() {
return new this.constructor(this._x, this._y, this._z, this._w);
}
copy(e) {
return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;
}
setFromEuler(e, t = !0) {
const n = e._x, i = e._y, o = e._z, c = e._order, l = Math.cos, u = Math.sin, f = l(n / 2), d = l(i / 2), p = l(o / 2), m = u(n / 2), v = u(i / 2), S = u(o / 2);
switch (c) {
case "XYZ":
this._x = m * d * p + f * v * S, this._y = f * v * p - m * d * S, this._z = f * d * S + m * v * p, this._w = f * d * p - m * v * S;
break;
case "YXZ":
this._x = m * d * p + f * v * S, this._y = f * v * p - m * d * S, this._z = f * d * S - m * v * p, this._w = f * d * p + m * v * S;
break;
case "ZXY":
this._x = m * d * p - f * v * S, this._y = f * v * p + m * d * S, this._z = f * d * S + m * v * p, this._w = f * d * p - m * v * S;
break;
case "ZYX":
this._x = m * d * p - f * v * S, this._y = f * v * p + m * d * S, this._z = f * d * S - m * v * p, this._w = f * d * p + m * v * S;
break;
case "YZX":
this._x = m * d * p + f * v * S, this._y = f * v * p + m * d * S, this._z = f * d * S - m * v * p, this._w = f * d * p - m * v * S;
break;
case "XZY":
this._x = m * d * p - f * v * S, this._y = f * v * p - m * d * S, this._z = f * d * S + m * v * p, this._w = f * d * p + m * v * S;
break;
default:
console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + c);
}
return t === !0 && this._onChangeCallback(), this;
}
setFromAxisAngle(e, t) {
const n = t / 2, i = Math.sin(n);
return this._x = e.x * i, this._y = e.y * i, this._z = e.z * i, this._w = Math.cos(n), this._onChangeCallback(), this;
}
setFromRotationMatrix(e) {
const t = e.elements, n = t[0], i = t[4], o = t[8], c = t[1], l = t[5], u = t[9], f = t[2], d = t[6], p = t[10], m = n + l + p;
if (m > 0) {
const v = 0.5 / Math.sqrt(m + 1);
this._w = 0.25 / v, this._x = (d - u) * v, this._y = (o - f) * v, this._z = (c - i) * v;
} else if (n > l && n > p) {
const v = 2 * Math.sqrt(1 + n - l - p);
this._w = (d - u) / v, this._x = 0.25 * v, this._y = (i + c) / v, this._z = (o + f) / v;
} else if (l > p) {
const v = 2 * Math.sqrt(1 + l - n - p);
this._w = (o - f) / v, this._x = (i + c) / v, this._y = 0.25 * v, this._z = (u + d) / v;
} else {
const v = 2 * Math.sqrt(1 + p - n - l);
this._w = (c - i) / v, this._x = (o + f) / v, this._y = (u + d) / v, this._z = 0.25 * v;
}
return this._onChangeCallback(), this;
}
setFromUnitVectors(e, t) {
let n = e.dot(t) + 1;
return n < Number.EPSILON ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize();
}
angleTo(e) {
return 2 * Math.acos(Math.abs(xn(this.dot(e), -1, 1)));
}
rotateTowards(e, t) {
const n = this.angleTo(e);
if (n === 0) return this;
const i = Math.min(1, t / n);
return this.slerp(e, i), this;
}
identity() {
return this.set(0, 0, 0, 1);
}
invert() {
return this.conjugate();
}
conjugate() {
return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
}
dot(e) {
return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
}
lengthSq() {
return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
}
length() {
return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
}
normalize() {
let e = this.length();
return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x = this._x * e, this._y = this._y * e, this._z = this._z * e, this._w = this._w * e), this._onChangeCallback(), this;
}
multiply(e) {
return this.multiplyQuaternions(this, e);
}
premultiply(e) {
return this.multiplyQuaternions(e, this);
}
multiplyQuaternions(e, t) {
const n = e._x, i = e._y, o = e._z, c = e._w, l = t._x, u = t._y, f = t._z, d = t._w;
return this._x = n * d + c * l + i * f - o * u, this._y = i * d + c * u + o * l - n * f, this._z = o * d + c * f + n * u - i * l, this._w = c * d - n * l - i * u - o * f, this._onChangeCallback(), this;
}
slerp(e, t) {
if (t === 0) return this;
if (t === 1) return this.copy(e);
const n = this._x, i = this._y, o = this._z, c = this._w;
let l = c * e._w + n * e._x + i * e._y + o * e._z;
if (l < 0 ? (this._w = -e._w, this._x = -e._x, this._y = -e._y, this._z = -e._z, l = -l) : this.copy(e), l >= 1)
return this._w = c, this._x = n, this._y = i, this._z = o, this;
const u = 1 - l * l;
if (u <= Number.EPSILON) {
const v = 1 - t;
return this._w = v * c + t * this._w, this._x = v * n + t * this._x, this._y = v * i + t * this._y, this._z = v * o + t * this._z, this.normalize(), this;
}
const f = Math.sqrt(u), d = Math.atan2(f, l), p = Math.sin((1 - t) * d) / f, m = Math.sin(t * d) / f;
return this._w = c * p + this._w * m, this._x = n * p + this._x * m, this._y = i * p + this._y * m, this._z = o * p + this._z * m, this._onChangeCallback(), this;
}
slerpQuaternions(e, t, n) {
return this.copy(e).slerp(t, n);
}
random() {
const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), i = Math.sqrt(1 - n), o = Math.sqrt(n);
return this.set(
i * Math.sin(e),
i * Math.cos(e),
o * Math.sin(t),
o * Math.cos(t)
);
}
equals(e) {
return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
}
fromArray(e, t = 0) {
return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this;
}
toArray(e = [], t = 0) {
return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e;
}
fromBufferAttribute(e, t) {
return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this;
}
toJSON() {
return this.toArray();
}
_onChange(e) {
return this._onChangeCallback = e, this;
}
_onChangeCallback() {
}
*[Symbol.iterator]() {
yield this._x, yield this._y, yield this._z, yield this._w;
}
}
class U {
constructor(e = 0, t = 0, n = 0) {
U.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = n;
}
set(e, t, n) {
return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this;
}
setScalar(e) {
return this.x = e, this.y = e, this.z = e, this;
}
setX(e) {
return this.x = e, this;
}
setY(e) {
return this.y = e, this;
}
setZ(e) {
return this.z = e, this;
}
setComponent(e, t) {
switch (e) {
case 0:
this.x = t;
break;
case 1:
this.y = t;
break;
case 2:
this.z = t;
break;
default:
throw new Error("index is out of range: " + e);
}
return this;
}
getComponent(e) {
switch (e) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
default:
throw new Error("index is out of range: " + e);
}
}
clone() {
return new this.constructor(this.x, this.y, this.z);
}
copy(e) {
return this.x = e.x, this.y = e.y, this.z = e.z, this;
}
add(e) {
return this.x += e.x, this.y += e.y, this.z += e.z, this;
}
addScalar(e) {
return this.x += e, this.y += e, this.z += e, this;
}
addVectors(e, t) {
return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;
}
addScaledVector(e, t) {
return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;
}
sub(e) {
return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;
}
subScalar(e) {
return this.x -= e, this.y -= e, this.z -= e, this;
}
subVectors(e, t) {
return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;
}
multiply(e) {
return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;
}
multiplyScalar(e) {
return this.x *= e, this.y *= e, this.z *= e, this;
}
multiplyVectors(e, t) {
return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;
}
applyEuler(e) {
return this.applyQuaternion(cm.setFromEuler(e));
}
applyAxisAngle(e, t) {
return this.applyQuaternion(cm.setFromAxisAngle(e, t));
}
applyMatrix3(e) {
const t = this.x, n = this.y, i = this.z, o = e.elements;
return this.x = o[0] * t + o[3] * n + o[6] * i, this.y = o[1] * t + o[4] * n + o[7] * i, this.z = o[2] * t + o[5] * n + o[8] * i, this;
}
applyNormalMatrix(e) {
return this.applyMatrix3(e).normalize();
}
applyMatrix4(e) {
const t = this.x, n = this.y, i = this.z, o = e.elements, c = 1 / (o[3] * t + o[7] * n + o[11] * i + o[15]);
return this.x = (o[0] * t + o[4] * n + o[8] * i + o[12]) * c, this.y = (o[1] * t + o[5] * n + o[9] * i + o[13]) * c, this.z = (o[2] * t + o[6] * n + o[10] * i + o[14]) * c, this;
}
applyQuaternion(e) {
const t = this.x, n = this.y, i = this.z, o = e.x, c = e.y, l = e.z, u = e.w, f = 2 * (c * i - l * n), d = 2 * (l * t - o * i), p = 2 * (o * n - c * t);
return this.x = t + u * f + c * p - l * d, this.y = n + u * d + l * f - o * p, this.z = i + u * p + o * d - c * f, this;
}
project(e) {
return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
}
unproject(e) {
return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
}
transformDirection(e) {
const t = this.x, n = this.y, i = this.z, o = e.elements;
return this.x = o[0] * t + o[4] * n