@needle-tools/engine
Version:
Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in
1,420 lines (1,419 loc) • 6.83 MB
JavaScript
var G8 = Object.defineProperty;
var k8 = (g, A, e) => A in g ? G8(g, A, { enumerable: !0, configurable: !0, writable: !0, value: e }) : g[A] = e;
var c = (g, A, e) => (k8(g, typeof A != "symbol" ? A + "" : A, e), e), LR = (g, A, e) => {
if (!A.has(g))
throw TypeError("Cannot " + e);
};
var yt = (g, A, e) => (LR(g, A, "read from private field"), e ? e.call(g) : A.get(g)), os = (g, A, e) => {
if (A.has(g))
throw TypeError("Cannot add the same private member more than once");
A instanceof WeakSet ? A.add(g) : A.set(g, e);
}, Sn = (g, A, e, t) => (LR(g, A, "write to private field"), t ? t.call(g, e) : A.set(g, e), e);
var Rc = (g, A, e) => (LR(g, A, "access private method"), e);
/**
* @license
* Copyright 2010-2023 Three.js Authors
* SPDX-License-Identifier: MIT
*/
const uC = "162", rQ = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 }, CQ = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, h3 = 0, xb = 1, E3 = 2, M8 = 3, R8 = 0, pJ = 1, fJ = 2, wa = 3, Yi = 0, Ni = 1, Mt = 2, Fi = 0, _B = 1, Al = 2, Jb = 3, Lb = 4, DJ = 5, RB = 100, d3 = 101, u3 = 102, vb = 103, FS = 104, p3 = 200, f3 = 201, D3 = 202, y3 = 203, bS = 204, KS = 205, w3 = 206, m3 = 207, S3 = 208, G3 = 209, k3 = 210, M3 = 211, R3 = 212, U3 = 213, N3 = 214, yJ = 0, sk = 1, Zf = 2, el = 3, $E = 4, nk = 5, ak = 6, WD = 7, VD = 0, F3 = 1, b3 = 2, kI = 0, kd = 1, XD = 2, K3 = 3, zD = 4, x3 = 5, Md = 6, tl = 7, qb = "attached", J3 = "detached", rk = 300, pC = 301, ec = 302, MI = 303, Ad = 304, Rd = 306, NI = 1e3, mg = 1001, fC = 1002, _e = 1003, ed = 1004, U8 = 1004, Xr = 1005, N8 = 1005, Le = 1006, xQ = 1007, F8 = 1007, SI = 1008, b8 = 1008, wt = 1009, xS = 1010, wJ = 1011, jD = 1012, JQ = 1013, Vo = 1014, qt = 1015, Hi = 1016, mJ = 1017, SJ = 1018, cC = 1020, L3 = 1021, Qt = 1023, Ck = 1024, v3 = 1025, HB = 1026, tc = 1027, nn = 1028, Bk = 1029, IC = 1030, $D = 1031, td = 1033, af = 33776, Zm = 33777, Wm = 33778, rf = 33779, JS = 35840, Tb = 35841, LS = 35842, _b = 35843, ck = 36196, vS = 37492, qS = 37496, TS = 37808, Hb = 37809, Yb = 37810, Ob = 37811, Wf = 37812, Pb = 37813, Zb = 37814, Wb = 37815, Vb = 37816, Xb = 37817, zb = 37818, jb = 37819, $b = 37820, AK = 37821, Cf = 36492, eK = 36494, tK = 36495, q3 = 36283, iK = 36284, gK = 36285, oK = 36286, Vf = 2200, GJ = 2201, T3 = 2202, ic = 2300, ja = 2301, Vm = 2302, wQ = 2400, mQ = 2401, Xf = 2402, Qk = 2500, kJ = 2501, _3 = 0, MJ = 1, _S = 2, H3 = 3e3, IK = 3001, Ro = 3200, lk = 3201, rc = 0, Y3 = 1, Po = "", pe = "srgb", _t = "srgb-linear", Ay = "display-p3", Ud = "display-p3-linear", zf = "linear", si = "srgb", jf = "rec709", $f = "p3", O3 = 0, mB = 7680, P3 = 7681, Z3 = 7682, W3 = 7683, V3 = 34055, X3 = 34056, z3 = 5386, sK = 512, j3 = 513, $3 = 514, A4 = 515, e4 = 516, t4 = 517, i4 = 518, HS = 519, g4 = 512, o4 = 513, I4 = 514, RJ = 515, s4 = 516, n4 = 517, a4 = 518, r4 = 519, AD = 35044, Oo = 35048, K8 = 35040, x8 = 35045, J8 = 35049, L8 = 35041, v8 = 35046, q8 = 35050, T8 = 35042, _8 = "100", YS = "300 es", OS = 1035, La = 2e3, eD = 2001;
let no = class {
addEventListener(A, e) {
this._listeners === void 0 && (this._listeners = {});
const t = this._listeners;
t[A] === void 0 && (t[A] = []), t[A].indexOf(e) === -1 && t[A].push(e);
}
hasEventListener(A, e) {
if (this._listeners === void 0)
return !1;
const t = this._listeners;
return t[A] !== void 0 && t[A].indexOf(e) !== -1;
}
removeEventListener(A, e) {
if (this._listeners === void 0)
return;
const i = this._listeners[A];
if (i !== void 0) {
const o = i.indexOf(e);
o !== -1 && i.splice(o, 1);
}
}
dispatchEvent(A) {
if (this._listeners === void 0)
return;
const t = this._listeners[A.type];
if (t !== void 0) {
A.target = this;
const i = t.slice(0);
for (let o = 0, I = i.length; o < I; o++)
i[o].call(this, A);
A.target = null;
}
}
};
const Ko = ["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 FT = 1234567;
const LQ = Math.PI / 180, id = 180 / Math.PI;
function Gs() {
const g = Math.random() * 4294967295 | 0, A = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0;
return (Ko[g & 255] + Ko[g >> 8 & 255] + Ko[g >> 16 & 255] + Ko[g >> 24 & 255] + "-" + Ko[A & 255] + Ko[A >> 8 & 255] + "-" + Ko[A >> 16 & 15 | 64] + Ko[A >> 24 & 255] + "-" + Ko[e & 63 | 128] + Ko[e >> 8 & 255] + "-" + Ko[e >> 16 & 255] + Ko[e >> 24 & 255] + Ko[t & 255] + Ko[t >> 8 & 255] + Ko[t >> 16 & 255] + Ko[t >> 24 & 255]).toLowerCase();
}
function tg(g, A, e) {
return Math.max(A, Math.min(e, g));
}
function UJ(g, A) {
return (g % A + A) % A;
}
function H8(g, A, e, t, i) {
return t + (g - A) * (i - t) / (e - A);
}
function Y8(g, A, e) {
return g !== A ? (e - g) / (A - g) : 0;
}
function Bf(g, A, e) {
return (1 - e) * g + e * A;
}
function O8(g, A, e, t) {
return Bf(g, A, 1 - Math.exp(-e * t));
}
function P8(g, A = 1) {
return A - Math.abs(UJ(g, A * 2) - A);
}
function Z8(g, A, e) {
return g <= A ? 0 : g >= e ? 1 : (g = (g - A) / (e - A), g * g * (3 - 2 * g));
}
function W8(g, A, e) {
return g <= A ? 0 : g >= e ? 1 : (g = (g - A) / (e - A), g * g * g * (g * (g * 6 - 15) + 10));
}
function V8(g, A) {
return g + Math.floor(Math.random() * (A - g + 1));
}
function X8(g, A) {
return g + Math.random() * (A - g);
}
function z8(g) {
return g * (0.5 - Math.random());
}
function j8(g) {
g !== void 0 && (FT = g);
let A = FT += 1831565813;
return A = Math.imul(A ^ A >>> 15, A | 1), A ^= A + Math.imul(A ^ A >>> 7, A | 61), ((A ^ A >>> 14) >>> 0) / 4294967296;
}
function $8(g) {
return g * LQ;
}
function A9(g) {
return g * id;
}
function nK(g) {
return (g & g - 1) === 0 && g !== 0;
}
function e9(g) {
return Math.pow(2, Math.ceil(Math.log(g) / Math.LN2));
}
function PS(g) {
return Math.pow(2, Math.floor(Math.log(g) / Math.LN2));
}
function t9(g, A, e, t, i) {
const o = Math.cos, I = Math.sin, s = o(e / 2), n = I(e / 2), a = o((A + t) / 2), r = I((A + t) / 2), C = o((A - t) / 2), B = I((A - t) / 2), Q = o((t - A) / 2), l = I((t - A) / 2);
switch (i) {
case "XYX":
g.set(s * r, n * C, n * B, s * a);
break;
case "YZY":
g.set(n * B, s * r, n * C, s * a);
break;
case "ZXZ":
g.set(n * C, n * B, s * r, s * a);
break;
case "XZX":
g.set(s * r, n * l, n * Q, s * a);
break;
case "YXY":
g.set(n * Q, s * r, n * l, s * a);
break;
case "ZYZ":
g.set(n * l, n * Q, s * r, s * a);
break;
default:
console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i);
}
}
function wI(g, A) {
switch (A.constructor) {
case Float32Array:
return g;
case Uint32Array:
return g / 4294967295;
case Uint16Array:
return g / 65535;
case Uint8Array:
return g / 255;
case Int32Array:
return Math.max(g / 2147483647, -1);
case Int16Array:
return Math.max(g / 32767, -1);
case Int8Array:
return Math.max(g / 127, -1);
default:
throw new Error("Invalid component type.");
}
}
function it(g, A) {
switch (A.constructor) {
case Float32Array:
return g;
case Uint32Array:
return Math.round(g * 4294967295);
case Uint16Array:
return Math.round(g * 65535);
case Uint8Array:
return Math.round(g * 255);
case Int32Array:
return Math.round(g * 2147483647);
case Int16Array:
return Math.round(g * 32767);
case Int8Array:
return Math.round(g * 127);
default:
throw new Error("Invalid component type.");
}
}
const ct = {
DEG2RAD: LQ,
RAD2DEG: id,
generateUUID: Gs,
clamp: tg,
euclideanModulo: UJ,
mapLinear: H8,
inverseLerp: Y8,
lerp: Bf,
damp: O8,
pingpong: P8,
smoothstep: Z8,
smootherstep: W8,
randInt: V8,
randFloat: X8,
randFloatSpread: z8,
seededRandom: j8,
degToRad: $8,
radToDeg: A9,
isPowerOfTwo: nK,
ceilPowerOfTwo: e9,
floorPowerOfTwo: PS,
setQuaternionFromProperEuler: t9,
normalize: it,
denormalize: wI
};
let eA = class C4 {
constructor(A = 0, e = 0) {
C4.prototype.isVector2 = !0, this.x = A, this.y = e;
}
get width() {
return this.x;
}
set width(A) {
this.x = A;
}
get height() {
return this.y;
}
set height(A) {
this.y = A;
}
set(A, e) {
return this.x = A, this.y = e, this;
}
setScalar(A) {
return this.x = A, this.y = A, this;
}
setX(A) {
return this.x = A, this;
}
setY(A) {
return this.y = A, this;
}
setComponent(A, e) {
switch (A) {
case 0:
this.x = e;
break;
case 1:
this.y = e;
break;
default:
throw new Error("index is out of range: " + A);
}
return this;
}
getComponent(A) {
switch (A) {
case 0:
return this.x;
case 1:
return this.y;
default:
throw new Error("index is out of range: " + A);
}
}
clone() {
return new this.constructor(this.x, this.y);
}
copy(A) {
return this.x = A.x, this.y = A.y, this;
}
add(A) {
return this.x += A.x, this.y += A.y, this;
}
addScalar(A) {
return this.x += A, this.y += A, this;
}
addVectors(A, e) {
return this.x = A.x + e.x, this.y = A.y + e.y, this;
}
addScaledVector(A, e) {
return this.x += A.x * e, this.y += A.y * e, this;
}
sub(A) {
return this.x -= A.x, this.y -= A.y, this;
}
subScalar(A) {
return this.x -= A, this.y -= A, this;
}
subVectors(A, e) {
return this.x = A.x - e.x, this.y = A.y - e.y, this;
}
multiply(A) {
return this.x *= A.x, this.y *= A.y, this;
}
multiplyScalar(A) {
return this.x *= A, this.y *= A, this;
}
divide(A) {
return this.x /= A.x, this.y /= A.y, this;
}
divideScalar(A) {
return this.multiplyScalar(1 / A);
}
applyMatrix3(A) {
const e = this.x, t = this.y, i = A.elements;
return this.x = i[0] * e + i[3] * t + i[6], this.y = i[1] * e + i[4] * t + i[7], this;
}
min(A) {
return this.x = Math.min(this.x, A.x), this.y = Math.min(this.y, A.y), this;
}
max(A) {
return this.x = Math.max(this.x, A.x), this.y = Math.max(this.y, A.y), this;
}
clamp(A, e) {
return this.x = Math.max(A.x, Math.min(e.x, this.x)), this.y = Math.max(A.y, Math.min(e.y, this.y)), this;
}
clampScalar(A, e) {
return this.x = Math.max(A, Math.min(e, this.x)), this.y = Math.max(A, Math.min(e, this.y)), this;
}
clampLength(A, e) {
const t = this.length();
return this.divideScalar(t || 1).multiplyScalar(Math.max(A, Math.min(e, t)));
}
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(A) {
return this.x * A.x + this.y * A.y;
}
cross(A) {
return this.x * A.y - this.y * A.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(A) {
const e = Math.sqrt(this.lengthSq() * A.lengthSq());
if (e === 0)
return Math.PI / 2;
const t = this.dot(A) / e;
return Math.acos(tg(t, -1, 1));
}
distanceTo(A) {
return Math.sqrt(this.distanceToSquared(A));
}
distanceToSquared(A) {
const e = this.x - A.x, t = this.y - A.y;
return e * e + t * t;
}
manhattanDistanceTo(A) {
return Math.abs(this.x - A.x) + Math.abs(this.y - A.y);
}
setLength(A) {
return this.normalize().multiplyScalar(A);
}
lerp(A, e) {
return this.x += (A.x - this.x) * e, this.y += (A.y - this.y) * e, this;
}
lerpVectors(A, e, t) {
return this.x = A.x + (e.x - A.x) * t, this.y = A.y + (e.y - A.y) * t, this;
}
equals(A) {
return A.x === this.x && A.y === this.y;
}
fromArray(A, e = 0) {
return this.x = A[e], this.y = A[e + 1], this;
}
toArray(A = [], e = 0) {
return A[e] = this.x, A[e + 1] = this.y, A;
}
fromBufferAttribute(A, e) {
return this.x = A.getX(e), this.y = A.getY(e), this;
}
rotateAround(A, e) {
const t = Math.cos(e), i = Math.sin(e), o = this.x - A.x, I = this.y - A.y;
return this.x = o * t - I * i + A.x, this.y = o * i + I * t + A.y, this;
}
random() {
return this.x = Math.random(), this.y = Math.random(), this;
}
*[Symbol.iterator]() {
yield this.x, yield this.y;
}
}, Te = class B4 {
constructor(A, e, t, i, o, I, s, n, a) {
B4.prototype.isMatrix3 = !0, this.elements = [
1,
0,
0,
0,
1,
0,
0,
0,
1
], A !== void 0 && this.set(A, e, t, i, o, I, s, n, a);
}
set(A, e, t, i, o, I, s, n, a) {
const r = this.elements;
return r[0] = A, r[1] = i, r[2] = s, r[3] = e, r[4] = o, r[5] = n, r[6] = t, r[7] = I, r[8] = a, this;
}
identity() {
return this.set(
1,
0,
0,
0,
1,
0,
0,
0,
1
), this;
}
copy(A) {
const e = this.elements, t = A.elements;
return e[0] = t[0], e[1] = t[1], e[2] = t[2], e[3] = t[3], e[4] = t[4], e[5] = t[5], e[6] = t[6], e[7] = t[7], e[8] = t[8], this;
}
extractBasis(A, e, t) {
return A.setFromMatrix3Column(this, 0), e.setFromMatrix3Column(this, 1), t.setFromMatrix3Column(this, 2), this;
}
setFromMatrix4(A) {
const e = A.elements;
return this.set(
e[0],
e[4],
e[8],
e[1],
e[5],
e[9],
e[2],
e[6],
e[10]
), this;
}
multiply(A) {
return this.multiplyMatrices(this, A);
}
premultiply(A) {
return this.multiplyMatrices(A, this);
}
multiplyMatrices(A, e) {
const t = A.elements, i = e.elements, o = this.elements, I = t[0], s = t[3], n = t[6], a = t[1], r = t[4], C = t[7], B = t[2], Q = t[5], l = t[8], h = i[0], E = i[3], d = i[6], p = i[1], u = i[4], f = i[7], D = i[2], y = i[5], m = i[8];
return o[0] = I * h + s * p + n * D, o[3] = I * E + s * u + n * y, o[6] = I * d + s * f + n * m, o[1] = a * h + r * p + C * D, o[4] = a * E + r * u + C * y, o[7] = a * d + r * f + C * m, o[2] = B * h + Q * p + l * D, o[5] = B * E + Q * u + l * y, o[8] = B * d + Q * f + l * m, this;
}
multiplyScalar(A) {
const e = this.elements;
return e[0] *= A, e[3] *= A, e[6] *= A, e[1] *= A, e[4] *= A, e[7] *= A, e[2] *= A, e[5] *= A, e[8] *= A, this;
}
determinant() {
const A = this.elements, e = A[0], t = A[1], i = A[2], o = A[3], I = A[4], s = A[5], n = A[6], a = A[7], r = A[8];
return e * I * r - e * s * a - t * o * r + t * s * n + i * o * a - i * I * n;
}
invert() {
const A = this.elements, e = A[0], t = A[1], i = A[2], o = A[3], I = A[4], s = A[5], n = A[6], a = A[7], r = A[8], C = r * I - s * a, B = s * n - r * o, Q = a * o - I * n, l = e * C + t * B + i * Q;
if (l === 0)
return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
const h = 1 / l;
return A[0] = C * h, A[1] = (i * a - r * t) * h, A[2] = (s * t - i * I) * h, A[3] = B * h, A[4] = (r * e - i * n) * h, A[5] = (i * o - s * e) * h, A[6] = Q * h, A[7] = (t * n - a * e) * h, A[8] = (I * e - t * o) * h, this;
}
transpose() {
let A;
const e = this.elements;
return A = e[1], e[1] = e[3], e[3] = A, A = e[2], e[2] = e[6], e[6] = A, A = e[5], e[5] = e[7], e[7] = A, this;
}
getNormalMatrix(A) {
return this.setFromMatrix4(A).invert().transpose();
}
transposeIntoArray(A) {
const e = this.elements;
return A[0] = e[0], A[1] = e[3], A[2] = e[6], A[3] = e[1], A[4] = e[4], A[5] = e[7], A[6] = e[2], A[7] = e[5], A[8] = e[8], this;
}
setUvTransform(A, e, t, i, o, I, s) {
const n = Math.cos(o), a = Math.sin(o);
return this.set(
t * n,
t * a,
-t * (n * I + a * s) + I + A,
-i * a,
i * n,
-i * (-a * I + n * s) + s + e,
0,
0,
1
), this;
}
//
scale(A, e) {
return this.premultiply(vR.makeScale(A, e)), this;
}
rotate(A) {
return this.premultiply(vR.makeRotation(-A)), this;
}
translate(A, e) {
return this.premultiply(vR.makeTranslation(A, e)), this;
}
// for 2D Transforms
makeTranslation(A, e) {
return A.isVector2 ? this.set(
1,
0,
A.x,
0,
1,
A.y,
0,
0,
1
) : this.set(
1,
0,
A,
0,
1,
e,
0,
0,
1
), this;
}
makeRotation(A) {
const e = Math.cos(A), t = Math.sin(A);
return this.set(
e,
-t,
0,
t,
e,
0,
0,
0,
1
), this;
}
makeScale(A, e) {
return this.set(
A,
0,
0,
0,
e,
0,
0,
0,
1
), this;
}
//
equals(A) {
const e = this.elements, t = A.elements;
for (let i = 0; i < 9; i++)
if (e[i] !== t[i])
return !1;
return !0;
}
fromArray(A, e = 0) {
for (let t = 0; t < 9; t++)
this.elements[t] = A[t + e];
return this;
}
toArray(A = [], e = 0) {
const t = this.elements;
return A[e] = t[0], A[e + 1] = t[1], A[e + 2] = t[2], A[e + 3] = t[3], A[e + 4] = t[4], A[e + 5] = t[5], A[e + 6] = t[6], A[e + 7] = t[7], A[e + 8] = t[8], A;
}
clone() {
return new this.constructor().fromArray(this.elements);
}
};
const vR = /* @__PURE__ */ new Te();
function c4(g) {
for (let A = g.length - 1; A >= 0; --A)
if (g[A] >= 65535)
return !0;
return !1;
}
const i9 = {
Int8Array,
Uint8Array,
Uint8ClampedArray,
Int16Array,
Uint16Array,
Int32Array,
Uint32Array,
Float32Array,
Float64Array
};
function hE(g, A) {
return new i9[g](A);
}
function tD(g) {
return document.createElementNS("http://www.w3.org/1999/xhtml", g);
}
function Q4() {
const g = tD("canvas");
return g.style.display = "block", g;
}
const bT = {};
function l4(g) {
g in bT || (bT[g] = !0, console.warn(g));
}
const KT = /* @__PURE__ */ new Te().set(
0.8224621,
0.177538,
0,
0.0331941,
0.9668058,
0,
0.0170827,
0.0723974,
0.9105199
), xT = /* @__PURE__ */ new Te().set(
1.2249401,
-0.2249404,
0,
-0.0420569,
1.0420571,
0,
-0.0196376,
-0.0786361,
1.0982735
), ew = {
[_t]: {
transfer: zf,
primaries: jf,
toReference: (g) => g,
fromReference: (g) => g
},
[pe]: {
transfer: si,
primaries: jf,
toReference: (g) => g.convertSRGBToLinear(),
fromReference: (g) => g.convertLinearToSRGB()
},
[Ud]: {
transfer: zf,
primaries: $f,
toReference: (g) => g.applyMatrix3(xT),
fromReference: (g) => g.applyMatrix3(KT)
},
[Ay]: {
transfer: si,
primaries: $f,
toReference: (g) => g.convertSRGBToLinear().applyMatrix3(xT),
fromReference: (g) => g.applyMatrix3(KT).convertLinearToSRGB()
}
}, g9 = /* @__PURE__ */ new Set([_t, Ud]), xt = {
enabled: !0,
_workingColorSpace: _t,
get workingColorSpace() {
return this._workingColorSpace;
},
set workingColorSpace(g) {
if (!g9.has(g))
throw new Error(`Unsupported working color space, "${g}".`);
this._workingColorSpace = g;
},
convert: function(g, A, e) {
if (this.enabled === !1 || A === e || !A || !e)
return g;
const t = ew[A].toReference, i = ew[e].fromReference;
return i(t(g));
},
fromWorkingColorSpace: function(g, A) {
return this.convert(g, this._workingColorSpace, A);
},
toWorkingColorSpace: function(g, A) {
return this.convert(g, A, this._workingColorSpace);
},
getPrimaries: function(g) {
return ew[g].primaries;
},
getTransfer: function(g) {
return g === Po ? zf : ew[g].transfer;
}
};
function FE(g) {
return g < 0.04045 ? g * 0.0773993808 : Math.pow(g * 0.9478672986 + 0.0521327014, 2.4);
}
function qR(g) {
return g < 31308e-7 ? g * 12.92 : 1.055 * Math.pow(g, 0.41666) - 0.055;
}
let Zl, NJ = class {
static getDataURL(A) {
if (/^data:/i.test(A.src) || typeof HTMLCanvasElement > "u")
return A.src;
let e;
if (A instanceof HTMLCanvasElement)
e = A;
else {
Zl === void 0 && (Zl = tD("canvas")), Zl.width = A.width, Zl.height = A.height;
const t = Zl.getContext("2d");
A instanceof ImageData ? t.putImageData(A, 0, 0) : t.drawImage(A, 0, 0, A.width, A.height), e = Zl;
}
return e.width > 2048 || e.height > 2048 ? (console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons", A), e.toDataURL("image/jpeg", 0.6)) : e.toDataURL("image/png");
}
static sRGBToLinear(A) {
if (typeof HTMLImageElement < "u" && A instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && A instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && A instanceof ImageBitmap) {
const e = tD("canvas");
e.width = A.width, e.height = A.height;
const t = e.getContext("2d");
t.drawImage(A, 0, 0, A.width, A.height);
const i = t.getImageData(0, 0, A.width, A.height), o = i.data;
for (let I = 0; I < o.length; I++)
o[I] = FE(o[I] / 255) * 255;
return t.putImageData(i, 0, 0), e;
} else if (A.data) {
const e = A.data.slice(0);
for (let t = 0; t < e.length; t++)
e instanceof Uint8Array || e instanceof Uint8ClampedArray ? e[t] = Math.floor(FE(e[t] / 255) * 255) : e[t] = FE(e[t]);
return {
data: e,
width: A.width,
height: A.height
};
} else
return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), A;
}
}, o9 = 0, sC = class {
constructor(A = null) {
this.isSource = !0, Object.defineProperty(this, "id", { value: o9++ }), this.uuid = Gs(), this.data = A, this.dataReady = !0, this.version = 0;
}
set needsUpdate(A) {
A === !0 && this.version++;
}
toJSON(A) {
const e = A === void 0 || typeof A == "string";
if (!e && A.images[this.uuid] !== void 0)
return A.images[this.uuid];
const t = {
uuid: this.uuid,
url: ""
}, i = this.data;
if (i !== null) {
let o;
if (Array.isArray(i)) {
o = [];
for (let I = 0, s = i.length; I < s; I++)
i[I].isDataTexture ? o.push(TR(i[I].image)) : o.push(TR(i[I]));
} else
o = TR(i);
t.url = o;
}
return e || (A.images[this.uuid] = t), t;
}
};
function TR(g) {
return typeof HTMLImageElement < "u" && g instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && g instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && g instanceof ImageBitmap ? NJ.getDataURL(g) : g.data ? {
data: Array.from(g.data),
width: g.width,
height: g.height,
type: g.data.constructor.name
} : (console.warn("THREE.Texture: Unable to serialize Texture."), {});
}
let I9 = 0, Ze = class Xm extends no {
constructor(A = Xm.DEFAULT_IMAGE, e = Xm.DEFAULT_MAPPING, t = mg, i = mg, o = Le, I = SI, s = Qt, n = wt, a = Xm.DEFAULT_ANISOTROPY, r = Po) {
super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: I9++ }), this.uuid = Gs(), this.name = "", this.source = new sC(A), this.mipmaps = [], this.mapping = e, this.channel = 0, this.wrapS = t, this.wrapT = i, this.magFilter = o, this.minFilter = I, this.anisotropy = a, this.format = s, this.internalFormat = null, this.type = n, this.offset = new eA(0, 0), this.repeat = new eA(1, 1), this.center = new eA(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new Te(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = r, this.userData = {}, this.version = 0, this.onUpdate = null, this.isRenderTargetTexture = !1, this.needsPMREMUpdate = !1;
}
get image() {
return this.source.data;
}
set image(A = null) {
this.source.data = A;
}
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(A) {
return this.name = A.name, this.source = A.source, this.mipmaps = A.mipmaps.slice(0), this.mapping = A.mapping, this.channel = A.channel, this.wrapS = A.wrapS, this.wrapT = A.wrapT, this.magFilter = A.magFilter, this.minFilter = A.minFilter, this.anisotropy = A.anisotropy, this.format = A.format, this.internalFormat = A.internalFormat, this.type = A.type, this.offset.copy(A.offset), this.repeat.copy(A.repeat), this.center.copy(A.center), this.rotation = A.rotation, this.matrixAutoUpdate = A.matrixAutoUpdate, this.matrix.copy(A.matrix), this.generateMipmaps = A.generateMipmaps, this.premultiplyAlpha = A.premultiplyAlpha, this.flipY = A.flipY, this.unpackAlignment = A.unpackAlignment, this.colorSpace = A.colorSpace, this.userData = JSON.parse(JSON.stringify(A.userData)), this.needsUpdate = !0, this;
}
toJSON(A) {
const e = A === void 0 || typeof A == "string";
if (!e && A.textures[this.uuid] !== void 0)
return A.textures[this.uuid];
const t = {
metadata: {
version: 4.6,
type: "Texture",
generator: "Texture.toJSON"
},
uuid: this.uuid,
name: this.name,
image: this.source.toJSON(A).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 && (t.userData = this.userData), e || (A.textures[this.uuid] = t), t;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
transformUv(A) {
if (this.mapping !== rk)
return A;
if (A.applyMatrix3(this.matrix), A.x < 0 || A.x > 1)
switch (this.wrapS) {
case NI:
A.x = A.x - Math.floor(A.x);
break;
case mg:
A.x = A.x < 0 ? 0 : 1;
break;
case fC:
Math.abs(Math.floor(A.x) % 2) === 1 ? A.x = Math.ceil(A.x) - A.x : A.x = A.x - Math.floor(A.x);
break;
}
if (A.y < 0 || A.y > 1)
switch (this.wrapT) {
case NI:
A.y = A.y - Math.floor(A.y);
break;
case mg:
A.y = A.y < 0 ? 0 : 1;
break;
case fC:
Math.abs(Math.floor(A.y) % 2) === 1 ? A.y = Math.ceil(A.y) - A.y : A.y = A.y - Math.floor(A.y);
break;
}
return this.flipY && (A.y = 1 - A.y), A;
}
set needsUpdate(A) {
A === !0 && (this.version++, this.source.needsUpdate = !0);
}
};
Ze.DEFAULT_IMAGE = null;
Ze.DEFAULT_MAPPING = rk;
Ze.DEFAULT_ANISOTROPY = 1;
let $A = class h4 {
constructor(A = 0, e = 0, t = 0, i = 1) {
h4.prototype.isVector4 = !0, this.x = A, this.y = e, this.z = t, this.w = i;
}
get width() {
return this.z;
}
set width(A) {
this.z = A;
}
get height() {
return this.w;
}
set height(A) {
this.w = A;
}
set(A, e, t, i) {
return this.x = A, this.y = e, this.z = t, this.w = i, this;
}
setScalar(A) {
return this.x = A, this.y = A, this.z = A, this.w = A, this;
}
setX(A) {
return this.x = A, this;
}
setY(A) {
return this.y = A, this;
}
setZ(A) {
return this.z = A, this;
}
setW(A) {
return this.w = A, this;
}
setComponent(A, e) {
switch (A) {
case 0:
this.x = e;
break;
case 1:
this.y = e;
break;
case 2:
this.z = e;
break;
case 3:
this.w = e;
break;
default:
throw new Error("index is out of range: " + A);
}
return this;
}
getComponent(A) {
switch (A) {
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: " + A);
}
}
clone() {
return new this.constructor(this.x, this.y, this.z, this.w);
}
copy(A) {
return this.x = A.x, this.y = A.y, this.z = A.z, this.w = A.w !== void 0 ? A.w : 1, this;
}
add(A) {
return this.x += A.x, this.y += A.y, this.z += A.z, this.w += A.w, this;
}
addScalar(A) {
return this.x += A, this.y += A, this.z += A, this.w += A, this;
}
addVectors(A, e) {
return this.x = A.x + e.x, this.y = A.y + e.y, this.z = A.z + e.z, this.w = A.w + e.w, this;
}
addScaledVector(A, e) {
return this.x += A.x * e, this.y += A.y * e, this.z += A.z * e, this.w += A.w * e, this;
}
sub(A) {
return this.x -= A.x, this.y -= A.y, this.z -= A.z, this.w -= A.w, this;
}
subScalar(A) {
return this.x -= A, this.y -= A, this.z -= A, this.w -= A, this;
}
subVectors(A, e) {
return this.x = A.x - e.x, this.y = A.y - e.y, this.z = A.z - e.z, this.w = A.w - e.w, this;
}
multiply(A) {
return this.x *= A.x, this.y *= A.y, this.z *= A.z, this.w *= A.w, this;
}
multiplyScalar(A) {
return this.x *= A, this.y *= A, this.z *= A, this.w *= A, this;
}
applyMatrix4(A) {
const e = this.x, t = this.y, i = this.z, o = this.w, I = A.elements;
return this.x = I[0] * e + I[4] * t + I[8] * i + I[12] * o, this.y = I[1] * e + I[5] * t + I[9] * i + I[13] * o, this.z = I[2] * e + I[6] * t + I[10] * i + I[14] * o, this.w = I[3] * e + I[7] * t + I[11] * i + I[15] * o, this;
}
divideScalar(A) {
return this.multiplyScalar(1 / A);
}
setAxisAngleFromQuaternion(A) {
this.w = 2 * Math.acos(A.w);
const e = Math.sqrt(1 - A.w * A.w);
return e < 1e-4 ? (this.x = 1, this.y = 0, this.z = 0) : (this.x = A.x / e, this.y = A.y / e, this.z = A.z / e), this;
}
setAxisAngleFromRotationMatrix(A) {
let e, t, i, o;
const n = A.elements, a = n[0], r = n[4], C = n[8], B = n[1], Q = n[5], l = n[9], h = n[2], E = n[6], d = n[10];
if (Math.abs(r - B) < 0.01 && Math.abs(C - h) < 0.01 && Math.abs(l - E) < 0.01) {
if (Math.abs(r + B) < 0.1 && Math.abs(C + h) < 0.1 && Math.abs(l + E) < 0.1 && Math.abs(a + Q + d - 3) < 0.1)
return this.set(1, 0, 0, 0), this;
e = Math.PI;
const u = (a + 1) / 2, f = (Q + 1) / 2, D = (d + 1) / 2, y = (r + B) / 4, m = (C + h) / 4, k = (l + E) / 4;
return u > f && u > D ? u < 0.01 ? (t = 0, i = 0.707106781, o = 0.707106781) : (t = Math.sqrt(u), i = y / t, o = m / t) : f > D ? f < 0.01 ? (t = 0.707106781, i = 0, o = 0.707106781) : (i = Math.sqrt(f), t = y / i, o = k / i) : D < 0.01 ? (t = 0.707106781, i = 0.707106781, o = 0) : (o = Math.sqrt(D), t = m / o, i = k / o), this.set(t, i, o, e), this;
}
let p = Math.sqrt((E - l) * (E - l) + (C - h) * (C - h) + (B - r) * (B - r));
return Math.abs(p) < 1e-3 && (p = 1), this.x = (E - l) / p, this.y = (C - h) / p, this.z = (B - r) / p, this.w = Math.acos((a + Q + d - 1) / 2), this;
}
min(A) {
return this.x = Math.min(this.x, A.x), this.y = Math.min(this.y, A.y), this.z = Math.min(this.z, A.z), this.w = Math.min(this.w, A.w), this;
}
max(A) {
return this.x = Math.max(this.x, A.x), this.y = Math.max(this.y, A.y), this.z = Math.max(this.z, A.z), this.w = Math.max(this.w, A.w), this;
}
clamp(A, e) {
return this.x = Math.max(A.x, Math.min(e.x, this.x)), this.y = Math.max(A.y, Math.min(e.y, this.y)), this.z = Math.max(A.z, Math.min(e.z, this.z)), this.w = Math.max(A.w, Math.min(e.w, this.w)), this;
}
clampScalar(A, e) {
return this.x = Math.max(A, Math.min(e, this.x)), this.y = Math.max(A, Math.min(e, this.y)), this.z = Math.max(A, Math.min(e, this.z)), this.w = Math.max(A, Math.min(e, this.w)), this;
}
clampLength(A, e) {
const t = this.length();
return this.divideScalar(t || 1).multiplyScalar(Math.max(A, Math.min(e, t)));
}
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(A) {
return this.x * A.x + this.y * A.y + this.z * A.z + this.w * A.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(A) {
return this.normalize().multiplyScalar(A);
}
lerp(A, e) {
return this.x += (A.x - this.x) * e, this.y += (A.y - this.y) * e, this.z += (A.z - this.z) * e, this.w += (A.w - this.w) * e, this;
}
lerpVectors(A, e, t) {
return this.x = A.x + (e.x - A.x) * t, this.y = A.y + (e.y - A.y) * t, this.z = A.z + (e.z - A.z) * t, this.w = A.w + (e.w - A.w) * t, this;
}
equals(A) {
return A.x === this.x && A.y === this.y && A.z === this.z && A.w === this.w;
}
fromArray(A, e = 0) {
return this.x = A[e], this.y = A[e + 1], this.z = A[e + 2], this.w = A[e + 3], this;
}
toArray(A = [], e = 0) {
return A[e] = this.x, A[e + 1] = this.y, A[e + 2] = this.z, A[e + 3] = this.w, A;
}
fromBufferAttribute(A, e) {
return this.x = A.getX(e), this.y = A.getY(e), this.z = A.getZ(e), this.w = A.getW(e), 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 E4 extends no {
constructor(A = 1, e = 1, t = {}) {
super(), this.isRenderTarget = !0, this.width = A, this.height = e, this.depth = 1, this.scissor = new $A(0, 0, A, e), this.scissorTest = !1, this.viewport = new $A(0, 0, A, e);
const i = { width: A, height: e, depth: 1 };
t = Object.assign({
generateMipmaps: !1,
internalFormat: null,
minFilter: Le,
depthBuffer: !0,
stencilBuffer: !1,
depthTexture: null,
samples: 0,
count: 1
}, t);
const o = new Ze(i, t.mapping, t.wrapS, t.wrapT, t.magFilter, t.minFilter, t.format, t.type, t.anisotropy, t.colorSpace);
o.flipY = !1, o.generateMipmaps = t.generateMipmaps, o.internalFormat = t.internalFormat, this.textures = [];
const I = t.count;
for (let s = 0; s < I; s++)
this.textures[s] = o.clone(), this.textures[s].isRenderTargetTexture = !0;
this.depthBuffer = t.depthBuffer, this.stencilBuffer = t.stencilBuffer, this.depthTexture = t.depthTexture, this.samples = t.samples;
}
get texture() {
return this.textures[0];
}
set texture(A) {
this.textures[0] = A;
}
setSize(A, e, t = 1) {
if (this.width !== A || this.height !== e || this.depth !== t) {
this.width = A, this.height = e, this.depth = t;
for (let i = 0, o = this.textures.length; i < o; i++)
this.textures[i].image.width = A, this.textures[i].image.height = e, this.textures[i].image.depth = t;
this.dispose();
}
this.viewport.set(0, 0, A, e), this.scissor.set(0, 0, A, e);
}
clone() {
return new this.constructor().copy(this);
}
copy(A) {
this.width = A.width, this.height = A.height, this.depth = A.depth, this.scissor.copy(A.scissor), this.scissorTest = A.scissorTest, this.viewport.copy(A.viewport), this.textures.length = 0;
for (let t = 0, i = A.textures.length; t < i; t++)
this.textures[t] = A.textures[t].clone(), this.textures[t].isRenderTargetTexture = !0;
const e = Object.assign({}, A.texture.image);
return this.texture.source = new sC(e), this.depthBuffer = A.depthBuffer, this.stencilBuffer = A.stencilBuffer, A.depthTexture !== null && (this.depthTexture = A.depthTexture.clone()), this.samples = A.samples, this;
}
dispose() {
this.dispatchEvent({ type: "dispose" });
}
}
class et extends E4 {
constructor(A = 1, e = 1, t = {}) {
super(A, e, t), this.isWebGLRenderTarget = !0;
}
}
class hk extends Ze {
constructor(A = null, e = 1, t = 1, i = 1) {
super(null), this.isDataArrayTexture = !0, this.image = { data: A, width: e, height: t, depth: i }, this.magFilter = _e, this.minFilter = _e, this.wrapR = mg, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
}
}
class s9 extends et {
constructor(A = 1, e = 1, t = 1, i = {}) {
super(A, e, i), this.isWebGLArrayRenderTarget = !0, this.depth = t, this.texture = new hk(null, A, e, t), this.texture.isRenderTargetTexture = !0;
}
}
let Ek = class extends Ze {
constructor(A = null, e = 1, t = 1, i = 1) {
super(null), this.isData3DTexture = !0, this.image = { data: A, width: e, height: t, depth: i }, this.magFilter = _e, this.minFilter = _e, this.wrapR = mg, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
}
};
class n9 extends et {
constructor(A = 1, e = 1, t = 1, i = {}) {
super(A, e, i), this.isWebGL3DRenderTarget = !0, this.depth = t, this.texture = new Ek(null, A, e, t), this.texture.isRenderTargetTexture = !0;
}
}
let GA = class {
constructor(A = 0, e = 0, t = 0, i = 1) {
this.isQuaternion = !0, this._x = A, this._y = e, this._z = t, this._w = i;
}
static slerpFlat(A, e, t, i, o, I, s) {
let n = t[i + 0], a = t[i + 1], r = t[i + 2], C = t[i + 3];
const B = o[I + 0], Q = o[I + 1], l = o[I + 2], h = o[I + 3];
if (s === 0) {
A[e + 0] = n, A[e + 1] = a, A[e + 2] = r, A[e + 3] = C;
return;
}
if (s === 1) {
A[e + 0] = B, A[e + 1] = Q, A[e + 2] = l, A[e + 3] = h;
return;
}
if (C !== h || n !== B || a !== Q || r !== l) {
let E = 1 - s;
const d = n * B + a * Q + r * l + C * h, p = d >= 0 ? 1 : -1, u = 1 - d * d;
if (u > Number.EPSILON) {
const D = Math.sqrt(u), y = Math.atan2(D, d * p);
E = Math.sin(E * y) / D, s = Math.sin(s * y) / D;
}
const f = s * p;
if (n = n * E + B * f, a = a * E + Q * f, r = r * E + l * f, C = C * E + h * f, E === 1 - s) {
const D = 1 / Math.sqrt(n * n + a * a + r * r + C * C);
n *= D, a *= D, r *= D, C *= D;
}
}
A[e] = n, A[e + 1] = a, A[e + 2] = r, A[e + 3] = C;
}
static multiplyQuaternionsFlat(A, e, t, i, o, I) {
const s = t[i], n = t[i + 1], a = t[i + 2], r = t[i + 3], C = o[I], B = o[I + 1], Q = o[I + 2], l = o[I + 3];
return A[e] = s * l + r * C + n * Q - a * B, A[e + 1] = n * l + r * B + a * C - s * Q, A[e + 2] = a * l + r * Q + s * B - n * C, A[e + 3] = r * l - s * C - n * B - a * Q, A;
}
get x() {
return this._x;
}
set x(A) {
this._x = A, this._onChangeCallback();
}
get y() {
return this._y;
}
set y(A) {
this._y = A, this._onChangeCallback();
}
get z() {
return this._z;
}
set z(A) {
this._z = A, this._onChangeCallback();
}
get w() {
return this._w;
}
set w(A) {
this._w = A, this._onChangeCallback();
}
set(A, e, t, i) {
return this._x = A, this._y = e, this._z = t, this._w = i, this._onChangeCallback(), this;
}
clone() {
return new this.constructor(this._x, this._y, this._z, this._w);
}
copy(A) {
return this._x = A.x, this._y = A.y, this._z = A.z, this._w = A.w, this._onChangeCallback(), this;
}
setFromEuler(A, e = !0) {
const t = A._x, i = A._y, o = A._z, I = A._order, s = Math.cos, n = Math.sin, a = s(t / 2), r = s(i / 2), C = s(o / 2), B = n(t / 2), Q = n(i / 2), l = n(o / 2);
switch (I) {
case "XYZ":
this._x = B * r * C + a * Q * l, this._y = a * Q * C - B * r * l, this._z = a * r * l + B * Q * C, this._w = a * r * C - B * Q * l;
break;
case "YXZ":
this._x = B * r * C + a * Q * l, this._y = a * Q * C - B * r * l, this._z = a * r * l - B * Q * C, this._w = a * r * C + B * Q * l;
break;
case "ZXY":
this._x = B * r * C - a * Q * l, this._y = a * Q * C + B * r * l, this._z = a * r * l + B * Q * C, this._w = a * r * C - B * Q * l;
break;
case "ZYX":
this._x = B * r * C - a * Q * l, this._y = a * Q * C + B * r * l, this._z = a * r * l - B * Q * C, this._w = a * r * C + B * Q * l;
break;
case "YZX":
this._x = B * r * C + a * Q * l, this._y = a * Q * C + B * r * l, this._z = a * r * l - B * Q * C, this._w = a * r * C - B * Q * l;
break;
case "XZY":
this._x = B * r * C - a * Q * l, this._y = a * Q * C - B * r * l, this._z = a * r * l + B * Q * C, this._w = a * r * C + B * Q * l;
break;
default:
console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: " + I);
}
return e === !0 && this._onChangeCallback(), this;
}
setFromAxisAngle(A, e) {
const t = e / 2, i = Math.sin(t);
return this._x = A.x * i, this._y = A.y * i, this._z = A.z * i, this._w = Math.cos(t), this._onChangeCallback(), this;
}
setFromRotationMatrix(A) {
const e = A.elements, t = e[0], i = e[4], o = e[8], I = e[1], s = e[5], n = e[9], a = e[2], r = e[6], C = e[10], B = t + s + C;
if (B > 0) {
const Q = 0.5 / Math.sqrt(B + 1);
this._w = 0.25 / Q, this._x = (r - n) * Q, this._y = (o - a) * Q, this._z = (I - i) * Q;
} else if (t > s && t > C) {
const Q = 2 * Math.sqrt(1 + t - s - C);
this._w = (r - n) / Q, this._x = 0.25 * Q, this._y = (i + I) / Q, this._z = (o + a) / Q;
} else if (s > C) {
const Q = 2 * Math.sqrt(1 + s - t - C);
this._w = (o - a) / Q, this._x = (i + I) / Q, this._y = 0.25 * Q, this._z = (n + r) / Q;
} else {
const Q = 2 * Math.sqrt(1 + C - t - s);
this._w = (I - i) / Q, this._x = (o + a) / Q, this._y = (n + r) / Q, this._z = 0.25 * Q;
}
return this._onChangeCallback(), this;
}
setFromUnitVectors(A, e) {
let t = A.dot(e) + 1;
return t < Number.EPSILON ? (t = 0, Math.abs(A.x) > Math.abs(A.z) ? (this._x = -A.y, this._y = A.x, this._z = 0, this._w = t) : (this._x = 0, this._y = -A.z, this._z = A.y, this._w = t)) : (this._x = A.y * e.z - A.z * e.y, this._y = A.z * e.x - A.x * e.z, this._z = A.x * e.y - A.y * e.x, this._w = t), this.normalize();
}
angleTo(A) {
return 2 * Math.acos(Math.abs(tg(this.dot(A), -1, 1)));
}
rotateTowards(A, e) {
const t = this.angleTo(A);
if (t === 0)
return this;
const i = Math.min(1, e / t);
return this.slerp(A, 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(A) {
return this._x * A._x + this._y * A._y + this._z * A._z + this._w * A._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 A = this.length();
return A === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (A = 1 / A, this._x = this._x * A, this._y = this._y * A, this._z = this._z * A, this._w = this._w * A), this._onChangeCallback(), this;
}
multiply(A) {
return this.multiplyQuaternions(this, A);
}
premultiply(A) {
return this.multiplyQuaternions(A, this);
}
multiplyQuaternions(A, e) {
const t = A._x, i = A._y, o = A._z, I = A._w, s = e._x, n = e._y, a = e._z, r = e._w;
return this._x = t * r + I * s + i * a - o * n, this._y = i * r + I * n + o * s - t * a, this._z = o * r + I * a + t * n - i * s, this._w = I * r - t * s - i * n - o * a, this._onChangeCallback(), this;
}
slerp(A, e) {
if (e === 0)
return this;
if (e === 1)
return this.copy(A);
const t = this._x, i = this._y, o = this._z, I = this._w;
let s = I * A._w + t * A._x + i * A._y + o * A._z;
if (s < 0 ? (this._w = -A._w, this._x = -A._x, this._y = -A._y, this._z = -A._z, s = -s) : this.copy(A), s >= 1)
return this._w = I, this._x = t, this._y = i, this._z = o, this;
const n = 1 - s * s;
if (n <= Number.EPSILON) {
const Q = 1 - e;
return this._w = Q * I + e * this._w, this._x = Q * t + e * this._x, this._y = Q * i + e * this._y, this._z = Q * o + e * this._z, this.normalize(), this;
}
const a = Math.sqrt(n), r = Math.atan2(a, s), C = Math.sin((1 - e) * r) / a, B = Math.sin(e * r) / a;
return this._w = I * C + this._w * B, this._x = t * C + this._x * B, this._y = i * C + this._y * B, this._z = o * C + this._z * B, this._onChangeCallback(), this;
}
slerpQuaternions(A, e, t) {
return this.copy(A).slerp(e, t);
}
random() {
const A = 2 * Math.PI * Math.random(), e = 2 * Math.PI * Math.random(), t = Math.random(), i = Math.sqrt(1 - t), o = Math.sqrt(t);
return this.set(
i * Math.sin(A),
i * Math.cos(A),
o * Math.sin(e),
o * Math.cos(e)
);
}
equals(A) {
return A._x === this._x && A._y === this._y && A._z === this._z && A._w === this._w;
}
fromArray(A, e = 0) {
return this._x = A[e], this._y = A[e + 1], this._z = A[e + 2], this._w = A[e + 3], this._onChangeCallback(), this;
}
toArray(A = [], e = 0) {
return A[e] = this._x, A[e + 1] = this._y, A[e + 2] = this._z, A[e + 3] = this._w, A;
}
fromBufferAttribute(A, e) {
return this._x = A.getX(e), this._y = A.getY(e), this._z = A.getZ(e), this._w = A.getW(e), this._onChangeCallback(), this;
}
toJSON() {
return this.toArray();
}
_onChange(A) {
return this._onChangeCallback = A, this;
}
_onChangeCallback() {
}
*[Symbol.iterator]() {
yield this._x, yield this._y, yield this._z, yield this._w;
}
}, S = class d4 {
constructor(A = 0, e = 0, t = 0) {
d4.prototype.isVector3 = !0, this.x = A, this.y = e, this.z = t;
}
set(A, e, t) {
return t === void 0 && (t = this.z), this.x = A, this.y = e, this.z = t, this;
}
setScalar(A) {
return this.x = A, this.y = A, this.z = A, this;
}
setX(A) {
return this.x = A, this;
}
setY(A) {
return this.y = A, this;
}
setZ(A) {
return this.z = A, this;
}
setComponent(A, e) {
switch (A) {
case 0:
this.x = e;
break;
case 1:
this.y = e;
break;
case 2:
this.z = e;
break;
default:
throw new Error("index is out of range: " + A);
}
return this;
}
getComponent(A) {
switch (A) {
case 0:
return this.x;
case 1:
return this.y;
case 2:
return this.z;
default:
throw new Error("index is out of range: " + A);
}
}
clone() {
return new this.constructor(this.x, this.y, this.z);
}
copy(A) {
return this.x = A.x, this.y = A.y, this.z = A.z, this;
}
add(A) {
return this.x += A.x, this.y += A.y, this.z += A.z, this;
}
addScalar(A) {
return this.x += A, this.y += A, this.z += A, this;
}
addVectors(A, e) {
return this.x = A.x + e.x, this.y = A.y + e.y, this.z = A.z + e.z, this;
}
addScaledVector(A, e) {
return this.x += A.x * e, this.y += A.y * e, this.z += A.z * e, this;
}
sub(A) {
return this.x -= A.x, this.y -= A.y, this.z -= A.z, this;
}
subScalar(A) {
return this.x -= A, this.y -= A, this.z -= A, this;
}