Date: ${(/* @__PURE__ */ new Date()).toLocaleDateString()}
-
Status:Active
- `;
- const r = document.createElement("button");
- r.textContent = "Update Status", r.style.marginTop = "10px", r.onclick = () => {
- alert("Status updated!");
- }, t.appendChild(i), t.appendChild(s), t.appendChild(r), super({
- container: e,
- title: "dialog.testTitle",
- content: t,
- width: 320,
- height: "auto",
- position: "center",
- resizable: !0,
- draggable: !0,
- // 可以在这里添加特定的 onClose 逻辑
- onClose: () => {
- console.log("Info dialog closed");
- },
- onOpen: () => {
- console.log("Info dialog opened");
- }
- });
- }
- // 不需要再手动实现 setTheme, destroy, close, init
- // 它们都已从 BimDialog 继承
-}
-class ru extends Yt {
- /** 弹窗挂载的父容器 */
- container;
- /** 活跃的弹窗实例列表 */
- activeDialogs = [];
- /**
- * 构造函数
- * @param engine 引擎实例
- * @param container 弹窗挂载的目标容器
- */
- constructor(e, t) {
- super(e), this.container = t, this.on("ui:open-dialog", (i) => {
- console.log("[DialogManager] Received open-dialog event:", i), i.id === "info" && this.showInfoDialog();
- });
- }
- /**
- * 创建一个通用弹窗
- * @param options 弹窗配置选项(不需要传 container,自动使用管理器绑定的容器)
- * @returns BimDialog 实例
- */
- create(e) {
- const t = new Gc({
- container: this.container,
- ...e,
- onClose: () => {
- this.activeDialogs = this.activeDialogs.filter((i) => i !== t), e.onClose && e.onClose();
- }
- });
- return t.setTheme(Ze.getTheme()), this.activeDialogs.push(t), t;
- }
- /**
- * 显示二次封装的模型信息弹窗
- * 演示如何调用特定的业务弹窗组件
- */
- showInfoDialog() {
- new nu(this.container);
- }
- /**
- * 响应全局主题变更
- * @param theme 全局主题配置
- */
- updateTheme(e) {
- this.activeDialogs.forEach((t) => {
- t.setTheme && t.setTheme(e);
- });
- }
- destroy() {
- this.activeDialogs.forEach((e) => e.destroy()), this.activeDialogs = [];
- }
-}
-const Fs = { ROTATE: 0, DOLLY: 1, PAN: 2 }, Os = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 }, au = 0, ul = 1, ou = 2, Wc = 1, jc = 2, Hi = 3, Ai = 0, Vt = 1, Xt = 2, bt = 0, zs = 1, Sr = 2, dl = 3, pl = 4, Xc = 5, di = 100, lu = 101, cu = 102, hu = 103, uu = 104, xn = 200, du = 201, pu = 202, mu = 203, Aa = 204, Ra = 205, Pa = 206, fu = 207, La = 208, gu = 209, vu = 210, _u = 211, xu = 212, bu = 213, yu = 214, Da = 0, Ia = 1, Ua = 2, js = 3, Na = 4, Ba = 5, Oa = 6, ka = 7, Ro = 0, Mu = 1, Su = 2, is = 0, qc = 1, Yc = 2, Kc = 3, Po = 4, Zc = 5, $c = 6, Jc = 7, ml = "attached", Tu = "detached", Qc = 300, Xs = 301, qs = 302, Tr = 303, Fa = 304, Ir = 306, Ri = 1e3, ii = 1001, Er = 1002, Nt = 1003, eh = 1004, bn = 1005, Mt = 1006, vr = 1007, wi = 1008, _i = 1009, th = 1010, ih = 1011, Cn = 1012, Lo = 1013, gs = 1014, qt = 1015, vt = 1016, Do = 1017, Io = 1018, Ys = 1020, sh = 35902, nh = 35899, rh = 1021, ah = 1022, Jt = 1023, An = 1026, Ks = 1027, Uo = 1028, No = 1029, Bo = 1030, Oo = 1031, ko = 1033, _r = 33776, xr = 33777, br = 33778, yr = 33779, za = 35840, Ha = 35841, Va = 35842, Ga = 35843, Wa = 36196, ja = 37492, Xa = 37496, qa = 37808, Ya = 37809, Ka = 37810, Za = 37811, $a = 37812, Ja = 37813, Qa = 37814, eo = 37815, to = 37816, io = 37817, so = 37818, no = 37819, ro = 37820, ao = 37821, oo = 36492, lo = 36494, co = 36495, ho = 36283, uo = 36284, po = 36285, mo = 36286, Rn = 2300, Pn = 2301, Fr = 2302, fl = 2400, gl = 2401, vl = 2402, Eu = 2500, wu = 0, oh = 1, fo = 2, Cu = 3200, lh = 3201, Ur = 0, Au = 1, Qi = "", Rt = "srgb", kt = "srgb-linear", wr = "linear", it = "srgb", ys = 7680, zr = 34055, Hr = 34056, Ru = 517, go = 519, Pu = 512, Lu = 513, Du = 514, ch = 515, Iu = 516, Uu = 517, Nu = 518, Bu = 519, vo = 35044, _l = "300 es", Ci = 2e3, Cr = 2001;
-function hh(n) {
- for (let e = n.length - 1; e >= 0; --e)
- if (n[e] >= 65535) return !0;
- return !1;
-}
-function Ln(n) {
- return document.createElementNS("http://www.w3.org/1999/xhtml", n);
-}
-function Ou() {
- const n = Ln("canvas");
- return n.style.display = "block", n;
-}
-const xl = {};
-function Ar(...n) {
- const e = "THREE." + n.shift();
- console.log(e, ...n);
-}
-function Se(...n) {
- const e = "THREE." + n.shift();
- console.warn(e, ...n);
-}
-function Ve(...n) {
- const e = "THREE." + n.shift();
- console.error(e, ...n);
-}
-function Dn(...n) {
- const e = n.join(" ");
- e in xl || (xl[e] = !0, Se(...n));
-}
-function ku(n, e, t) {
- return new Promise(function(i, s) {
- function r() {
- switch (n.clientWaitSync(e, n.SYNC_FLUSH_COMMANDS_BIT, 0)) {
- case n.WAIT_FAILED:
- s();
- break;
- case n.TIMEOUT_EXPIRED:
- setTimeout(r, t);
- break;
- default:
- i();
- }
- }
- setTimeout(r, t);
- });
-}
-class xs {
- /**
- * Adds the given event listener to the given event type.
- *
- * @param {string} type - The type of event to listen to.
- * @param {Function} listener - The function that gets called when the event is fired.
- */
- addEventListener(e, t) {
- this._listeners === void 0 && (this._listeners = {});
- const i = this._listeners;
- i[e] === void 0 && (i[e] = []), i[e].indexOf(t) === -1 && i[e].push(t);
- }
- /**
- * Returns `true` if the given event listener has been added to the given event type.
- *
- * @param {string} type - The type of event.
- * @param {Function} listener - The listener to check.
- * @return {boolean} Whether the given event listener has been added to the given event type.
- */
- hasEventListener(e, t) {
- const i = this._listeners;
- return i === void 0 ? !1 : i[e] !== void 0 && i[e].indexOf(t) !== -1;
- }
- /**
- * Removes the given event listener from the given event type.
- *
- * @param {string} type - The type of event.
- * @param {Function} listener - The listener to remove.
- */
- removeEventListener(e, t) {
- const i = this._listeners;
- if (i === void 0) return;
- const s = i[e];
- if (s !== void 0) {
- const r = s.indexOf(t);
- r !== -1 && s.splice(r, 1);
- }
- }
- /**
- * Dispatches an event object.
- *
- * @param {Object} event - The event that gets fired.
- */
- dispatchEvent(e) {
- const t = this._listeners;
- if (t === void 0) return;
- const i = t[e.type];
- if (i !== void 0) {
- e.target = this;
- const s = i.slice(0);
- for (let r = 0, a = s.length; r < a; r++)
- s[r].call(this, e);
- e.target = null;
- }
- }
-}
-const Bt = ["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 bl = 1234567;
-const Sn = Math.PI / 180, Zs = 180 / Math.PI;
-function gi() {
- const n = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, i = Math.random() * 4294967295 | 0;
- return (Bt[n & 255] + Bt[n >> 8 & 255] + Bt[n >> 16 & 255] + Bt[n >> 24 & 255] + "-" + Bt[e & 255] + Bt[e >> 8 & 255] + "-" + Bt[e >> 16 & 15 | 64] + Bt[e >> 24 & 255] + "-" + Bt[t & 63 | 128] + Bt[t >> 8 & 255] + "-" + Bt[t >> 16 & 255] + Bt[t >> 24 & 255] + Bt[i & 255] + Bt[i >> 8 & 255] + Bt[i >> 16 & 255] + Bt[i >> 24 & 255]).toLowerCase();
-}
-function ze(n, e, t) {
- return Math.max(e, Math.min(t, n));
-}
-function Fo(n, e) {
- return (n % e + e) % e;
-}
-function Fu(n, e, t, i, s) {
- return i + (n - e) * (s - i) / (t - e);
-}
-function zu(n, e, t) {
- return n !== e ? (t - n) / (e - n) : 0;
-}
-function Tn(n, e, t) {
- return (1 - t) * n + t * e;
-}
-function Hu(n, e, t, i) {
- return Tn(n, e, 1 - Math.exp(-t * i));
-}
-function Vu(n, e = 1) {
- return e - Math.abs(Fo(n, e * 2) - e);
-}
-function Gu(n, e, t) {
- return n <= e ? 0 : n >= t ? 1 : (n = (n - e) / (t - e), n * n * (3 - 2 * n));
-}
-function Wu(n, e, t) {
- return n <= e ? 0 : n >= t ? 1 : (n = (n - e) / (t - e), n * n * n * (n * (n * 6 - 15) + 10));
-}
-function ju(n, e) {
- return n + Math.floor(Math.random() * (e - n + 1));
-}
-function Xu(n, e) {
- return n + Math.random() * (e - n);
-}
-function qu(n) {
- return n * (0.5 - Math.random());
-}
-function Yu(n) {
- n !== void 0 && (bl = n);
- let e = bl += 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 Ku(n) {
- return n * Sn;
-}
-function Zu(n) {
- return n * Zs;
-}
-function $u(n) {
- return (n & n - 1) === 0 && n !== 0;
-}
-function Ju(n) {
- return Math.pow(2, Math.ceil(Math.log(n) / Math.LN2));
-}
-function Qu(n) {
- return Math.pow(2, Math.floor(Math.log(n) / Math.LN2));
-}
-function ed(n, e, t, i, s) {
- const r = Math.cos, a = Math.sin, o = r(t / 2), l = a(t / 2), c = r((e + i) / 2), h = a((e + i) / 2), u = r((e - i) / 2), d = a((e - i) / 2), m = r((i - e) / 2), g = a((i - e) / 2);
- switch (s) {
- case "XYX":
- n.set(o * h, l * u, l * d, o * c);
- break;
- case "YZY":
- n.set(l * d, o * h, l * u, o * c);
- break;
- case "ZXZ":
- n.set(l * u, l * d, o * h, o * c);
- break;
- case "XZX":
- n.set(o * h, l * g, l * m, o * c);
- break;
- case "YXY":
- n.set(l * m, o * h, l * g, o * c);
- break;
- case "ZYZ":
- n.set(l * g, l * m, o * h, o * c);
- break;
- default:
- Se("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + s);
- }
-}
-function pi(n, e) {
- switch (e.constructor) {
- case Float32Array:
- return n;
- case Uint32Array:
- return n / 4294967295;
- case Uint16Array:
- return n / 65535;
- case Uint8Array:
- return n / 255;
- case Int32Array:
- return Math.max(n / 2147483647, -1);
- case Int16Array:
- return Math.max(n / 32767, -1);
- case Int8Array:
- return Math.max(n / 127, -1);
- default:
- throw new Error("Invalid component type.");
- }
-}
-function st(n, e) {
- switch (e.constructor) {
- case Float32Array:
- return n;
- case Uint32Array:
- return Math.round(n * 4294967295);
- case Uint16Array:
- return Math.round(n * 65535);
- case Uint8Array:
- return Math.round(n * 255);
- case Int32Array:
- return Math.round(n * 2147483647);
- case Int16Array:
- return Math.round(n * 32767);
- case Int8Array:
- return Math.round(n * 127);
- default:
- throw new Error("Invalid component type.");
- }
-}
-const zo = {
- DEG2RAD: Sn,
- RAD2DEG: Zs,
- /**
- * Generate a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier)
- * (universally unique identifier).
- *
- * @static
- * @method
- * @return {string} The UUID.
- */
- generateUUID: gi,
- /**
- * Clamps the given value between min and max.
- *
- * @static
- * @method
- * @param {number} value - The value to clamp.
- * @param {number} min - The min value.
- * @param {number} max - The max value.
- * @return {number} The clamped value.
- */
- clamp: ze,
- /**
- * Computes the Euclidean modulo of the given parameters that
- * is `( ( n % m ) + m ) % m`.
- *
- * @static
- * @method
- * @param {number} n - The first parameter.
- * @param {number} m - The second parameter.
- * @return {number} The Euclidean modulo.
- */
- euclideanModulo: Fo,
- /**
- * Performs a linear mapping from range `` to range ``
- * for the given value.
- *
- * @static
- * @method
- * @param {number} x - The value to be mapped.
- * @param {number} a1 - Minimum value for range A.
- * @param {number} a2 - Maximum value for range A.
- * @param {number} b1 - Minimum value for range B.
- * @param {number} b2 - Maximum value for range B.
- * @return {number} The mapped value.
- */
- mapLinear: Fu,
- /**
- * Returns the percentage in the closed interval `[0, 1]` of the given value
- * between the start and end point.
- *
- * @static
- * @method
- * @param {number} x - The start point
- * @param {number} y - The end point.
- * @param {number} value - A value between start and end.
- * @return {number} The interpolation factor.
- */
- inverseLerp: zu,
- /**
- * Returns a value linearly interpolated from two known points based on the given interval -
- * `t = 0` will return `x` and `t = 1` will return `y`.
- *
- * @static
- * @method
- * @param {number} x - The start point
- * @param {number} y - The end point.
- * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
- * @return {number} The interpolated value.
- */
- lerp: Tn,
- /**
- * Smoothly interpolate a number from `x` to `y` in a spring-like manner using a delta
- * time to maintain frame rate independent movement. For details, see
- * [Frame rate independent damping using lerp](http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/).
- *
- * @static
- * @method
- * @param {number} x - The current point.
- * @param {number} y - The target point.
- * @param {number} lambda - A higher lambda value will make the movement more sudden,
- * and a lower value will make the movement more gradual.
- * @param {number} dt - Delta time in seconds.
- * @return {number} The interpolated value.
- */
- damp: Hu,
- /**
- * Returns a value that alternates between `0` and the given `length` parameter.
- *
- * @static
- * @method
- * @param {number} x - The value to pingpong.
- * @param {number} [length=1] - The positive value the function will pingpong to.
- * @return {number} The alternated value.
- */
- pingpong: Vu,
- /**
- * Returns a value in the range `[0,1]` that represents the percentage that `x` has
- * moved between `min` and `max`, but smoothed or slowed down the closer `x` is to
- * the `min` and `max`.
- *
- * See [Smoothstep](http://en.wikipedia.org/wiki/Smoothstep) for more details.
- *
- * @static
- * @method
- * @param {number} x - The value to evaluate based on its position between min and max.
- * @param {number} min - The min value. Any x value below min will be `0`.
- * @param {number} max - The max value. Any x value above max will be `1`.
- * @return {number} The alternated value.
- */
- smoothstep: Gu,
- /**
- * A [variation on smoothstep](https://en.wikipedia.org/wiki/Smoothstep#Variations)
- * that has zero 1st and 2nd order derivatives at x=0 and x=1.
- *
- * @static
- * @method
- * @param {number} x - The value to evaluate based on its position between min and max.
- * @param {number} min - The min value. Any x value below min will be `0`.
- * @param {number} max - The max value. Any x value above max will be `1`.
- * @return {number} The alternated value.
- */
- smootherstep: Wu,
- /**
- * Returns a random integer from `` interval.
- *
- * @static
- * @method
- * @param {number} low - The lower value boundary.
- * @param {number} high - The upper value boundary
- * @return {number} A random integer.
- */
- randInt: ju,
- /**
- * Returns a random float from `` interval.
- *
- * @static
- * @method
- * @param {number} low - The lower value boundary.
- * @param {number} high - The upper value boundary
- * @return {number} A random float.
- */
- randFloat: Xu,
- /**
- * Returns a random integer from `<-range/2, range/2>` interval.
- *
- * @static
- * @method
- * @param {number} range - Defines the value range.
- * @return {number} A random float.
- */
- randFloatSpread: qu,
- /**
- * Returns a deterministic pseudo-random float in the interval `[0, 1]`.
- *
- * @static
- * @method
- * @param {number} [s] - The integer seed.
- * @return {number} A random float.
- */
- seededRandom: Yu,
- /**
- * Converts degrees to radians.
- *
- * @static
- * @method
- * @param {number} degrees - A value in degrees.
- * @return {number} The converted value in radians.
- */
- degToRad: Ku,
- /**
- * Converts radians to degrees.
- *
- * @static
- * @method
- * @param {number} radians - A value in radians.
- * @return {number} The converted value in degrees.
- */
- radToDeg: Zu,
- /**
- * Returns `true` if the given number is a power of two.
- *
- * @static
- * @method
- * @param {number} value - The value to check.
- * @return {boolean} Whether the given number is a power of two or not.
- */
- isPowerOfTwo: $u,
- /**
- * Returns the smallest power of two that is greater than or equal to the given number.
- *
- * @static
- * @method
- * @param {number} value - The value to find a POT for.
- * @return {number} The smallest power of two that is greater than or equal to the given number.
- */
- ceilPowerOfTwo: Ju,
- /**
- * Returns the largest power of two that is less than or equal to the given number.
- *
- * @static
- * @method
- * @param {number} value - The value to find a POT for.
- * @return {number} The largest power of two that is less than or equal to the given number.
- */
- floorPowerOfTwo: Qu,
- /**
- * Sets the given quaternion from the [Intrinsic Proper Euler Angles](https://en.wikipedia.org/wiki/Euler_angles)
- * defined by the given angles and order.
- *
- * Rotations are applied to the axes in the order specified by order:
- * rotation by angle `a` is applied first, then by angle `b`, then by angle `c`.
- *
- * @static
- * @method
- * @param {Quaternion} q - The quaternion to set.
- * @param {number} a - The rotation applied to the first axis, in radians.
- * @param {number} b - The rotation applied to the second axis, in radians.
- * @param {number} c - The rotation applied to the third axis, in radians.
- * @param {('XYX'|'XZX'|'YXY'|'YZY'|'ZXZ'|'ZYZ')} order - A string specifying the axes order.
- */
- setQuaternionFromProperEuler: ed,
- /**
- * Normalizes the given value according to the given typed array.
- *
- * @static
- * @method
- * @param {number} value - The float value in the range `[0,1]` to normalize.
- * @param {TypedArray} array - The typed array that defines the data type of the value.
- * @return {number} The normalize value.
- */
- normalize: st,
- /**
- * Denormalizes the given value according to the given typed array.
- *
- * @static
- * @method
- * @param {number} value - The value to denormalize.
- * @param {TypedArray} array - The typed array that defines the data type of the value.
- * @return {number} The denormalize (float) value in the range `[0,1]`.
- */
- denormalize: pi
-};
-class oe {
- /**
- * Constructs a new 2D vector.
- *
- * @param {number} [x=0] - The x value of this vector.
- * @param {number} [y=0] - The y value of this vector.
- */
- constructor(e = 0, t = 0) {
- oe.prototype.isVector2 = !0, this.x = e, this.y = t;
- }
- /**
- * Alias for {@link Vector2#x}.
- *
- * @type {number}
- */
- get width() {
- return this.x;
- }
- set width(e) {
- this.x = e;
- }
- /**
- * Alias for {@link Vector2#y}.
- *
- * @type {number}
- */
- get height() {
- return this.y;
- }
- set height(e) {
- this.y = e;
- }
- /**
- * Sets the vector components.
- *
- * @param {number} x - The value of the x component.
- * @param {number} y - The value of the y component.
- * @return {Vector2} A reference to this vector.
- */
- set(e, t) {
- return this.x = e, this.y = t, this;
- }
- /**
- * Sets the vector components to the same value.
- *
- * @param {number} scalar - The value to set for all vector components.
- * @return {Vector2} A reference to this vector.
- */
- setScalar(e) {
- return this.x = e, this.y = e, this;
- }
- /**
- * Sets the vector's x component to the given value
- *
- * @param {number} x - The value to set.
- * @return {Vector2} A reference to this vector.
- */
- setX(e) {
- return this.x = e, this;
- }
- /**
- * Sets the vector's y component to the given value
- *
- * @param {number} y - The value to set.
- * @return {Vector2} A reference to this vector.
- */
- setY(e) {
- return this.y = e, this;
- }
- /**
- * Allows to set a vector component with an index.
- *
- * @param {number} index - The component index. `0` equals to x, `1` equals to y.
- * @param {number} value - The value to set.
- * @return {Vector2} A reference to this vector.
- */
- 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;
- }
- /**
- * Returns the value of the vector component which matches the given index.
- *
- * @param {number} index - The component index. `0` equals to x, `1` equals to y.
- * @return {number} A vector component value.
- */
- getComponent(e) {
- switch (e) {
- case 0:
- return this.x;
- case 1:
- return this.y;
- default:
- throw new Error("index is out of range: " + e);
- }
- }
- /**
- * Returns a new vector with copied values from this instance.
- *
- * @return {Vector2} A clone of this instance.
- */
- clone() {
- return new this.constructor(this.x, this.y);
- }
- /**
- * Copies the values of the given vector to this instance.
- *
- * @param {Vector2} v - The vector to copy.
- * @return {Vector2} A reference to this vector.
- */
- copy(e) {
- return this.x = e.x, this.y = e.y, this;
- }
- /**
- * Adds the given vector to this instance.
- *
- * @param {Vector2} v - The vector to add.
- * @return {Vector2} A reference to this vector.
- */
- add(e) {
- return this.x += e.x, this.y += e.y, this;
- }
- /**
- * Adds the given scalar value to all components of this instance.
- *
- * @param {number} s - The scalar to add.
- * @return {Vector2} A reference to this vector.
- */
- addScalar(e) {
- return this.x += e, this.y += e, this;
- }
- /**
- * Adds the given vectors and stores the result in this instance.
- *
- * @param {Vector2} a - The first vector.
- * @param {Vector2} b - The second vector.
- * @return {Vector2} A reference to this vector.
- */
- addVectors(e, t) {
- return this.x = e.x + t.x, this.y = e.y + t.y, this;
- }
- /**
- * Adds the given vector scaled by the given factor to this instance.
- *
- * @param {Vector2} v - The vector.
- * @param {number} s - The factor that scales `v`.
- * @return {Vector2} A reference to this vector.
- */
- addScaledVector(e, t) {
- return this.x += e.x * t, this.y += e.y * t, this;
- }
- /**
- * Subtracts the given vector from this instance.
- *
- * @param {Vector2} v - The vector to subtract.
- * @return {Vector2} A reference to this vector.
- */
- sub(e) {
- return this.x -= e.x, this.y -= e.y, this;
- }
- /**
- * Subtracts the given scalar value from all components of this instance.
- *
- * @param {number} s - The scalar to subtract.
- * @return {Vector2} A reference to this vector.
- */
- subScalar(e) {
- return this.x -= e, this.y -= e, this;
- }
- /**
- * Subtracts the given vectors and stores the result in this instance.
- *
- * @param {Vector2} a - The first vector.
- * @param {Vector2} b - The second vector.
- * @return {Vector2} A reference to this vector.
- */
- subVectors(e, t) {
- return this.x = e.x - t.x, this.y = e.y - t.y, this;
- }
- /**
- * Multiplies the given vector with this instance.
- *
- * @param {Vector2} v - The vector to multiply.
- * @return {Vector2} A reference to this vector.
- */
- multiply(e) {
- return this.x *= e.x, this.y *= e.y, this;
- }
- /**
- * Multiplies the given scalar value with all components of this instance.
- *
- * @param {number} scalar - The scalar to multiply.
- * @return {Vector2} A reference to this vector.
- */
- multiplyScalar(e) {
- return this.x *= e, this.y *= e, this;
- }
- /**
- * Divides this instance by the given vector.
- *
- * @param {Vector2} v - The vector to divide.
- * @return {Vector2} A reference to this vector.
- */
- divide(e) {
- return this.x /= e.x, this.y /= e.y, this;
- }
- /**
- * Divides this vector by the given scalar.
- *
- * @param {number} scalar - The scalar to divide.
- * @return {Vector2} A reference to this vector.
- */
- divideScalar(e) {
- return this.multiplyScalar(1 / e);
- }
- /**
- * Multiplies this vector (with an implicit 1 as the 3rd component) by
- * the given 3x3 matrix.
- *
- * @param {Matrix3} m - The matrix to apply.
- * @return {Vector2} A reference to this vector.
- */
- applyMatrix3(e) {
- const t = this.x, i = this.y, s = e.elements;
- return this.x = s[0] * t + s[3] * i + s[6], this.y = s[1] * t + s[4] * i + s[7], this;
- }
- /**
- * If this vector's x or y value is greater than the given vector's x or y
- * value, replace that value with the corresponding min value.
- *
- * @param {Vector2} v - The vector.
- * @return {Vector2} A reference to this vector.
- */
- min(e) {
- return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this;
- }
- /**
- * If this vector's x or y value is less than the given vector's x or y
- * value, replace that value with the corresponding max value.
- *
- * @param {Vector2} v - The vector.
- * @return {Vector2} A reference to this vector.
- */
- max(e) {
- return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this;
- }
- /**
- * If this vector's x or y value is greater than the max vector's x or y
- * value, it is replaced by the corresponding value.
- * If this vector's x or y value is less than the min vector's x or y value,
- * it is replaced by the corresponding value.
- *
- * @param {Vector2} min - The minimum x and y values.
- * @param {Vector2} max - The maximum x and y values in the desired range.
- * @return {Vector2} A reference to this vector.
- */
- clamp(e, t) {
- return this.x = ze(this.x, e.x, t.x), this.y = ze(this.y, e.y, t.y), this;
- }
- /**
- * If this vector's x or y values are greater than the max value, they are
- * replaced by the max value.
- * If this vector's x or y values are less than the min value, they are
- * replaced by the min value.
- *
- * @param {number} minVal - The minimum value the components will be clamped to.
- * @param {number} maxVal - The maximum value the components will be clamped to.
- * @return {Vector2} A reference to this vector.
- */
- clampScalar(e, t) {
- return this.x = ze(this.x, e, t), this.y = ze(this.y, e, t), this;
- }
- /**
- * If this vector's length is greater than the max value, it is replaced by
- * the max value.
- * If this vector's length is less than the min value, it is replaced by the
- * min value.
- *
- * @param {number} min - The minimum value the vector length will be clamped to.
- * @param {number} max - The maximum value the vector length will be clamped to.
- * @return {Vector2} A reference to this vector.
- */
- clampLength(e, t) {
- const i = this.length();
- return this.divideScalar(i || 1).multiplyScalar(ze(i, e, t));
- }
- /**
- * The components of this vector are rounded down to the nearest integer value.
- *
- * @return {Vector2} A reference to this vector.
- */
- floor() {
- return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
- }
- /**
- * The components of this vector are rounded up to the nearest integer value.
- *
- * @return {Vector2} A reference to this vector.
- */
- ceil() {
- return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
- }
- /**
- * The components of this vector are rounded to the nearest integer value
- *
- * @return {Vector2} A reference to this vector.
- */
- round() {
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
- }
- /**
- * The components of this vector are rounded towards zero (up if negative,
- * down if positive) to an integer value.
- *
- * @return {Vector2} A reference to this vector.
- */
- roundToZero() {
- return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
- }
- /**
- * Inverts this vector - i.e. sets x = -x and y = -y.
- *
- * @return {Vector2} A reference to this vector.
- */
- negate() {
- return this.x = -this.x, this.y = -this.y, this;
- }
- /**
- * Calculates the dot product of the given vector with this instance.
- *
- * @param {Vector2} v - The vector to compute the dot product with.
- * @return {number} The result of the dot product.
- */
- dot(e) {
- return this.x * e.x + this.y * e.y;
- }
- /**
- * Calculates the cross product of the given vector with this instance.
- *
- * @param {Vector2} v - The vector to compute the cross product with.
- * @return {number} The result of the cross product.
- */
- cross(e) {
- return this.x * e.y - this.y * e.x;
- }
- /**
- * Computes the square of the Euclidean length (straight-line length) from
- * (0, 0) to (x, y). If you are comparing the lengths of vectors, you should
- * compare the length squared instead as it is slightly more efficient to calculate.
- *
- * @return {number} The square length of this vector.
- */
- lengthSq() {
- return this.x * this.x + this.y * this.y;
- }
- /**
- * Computes the Euclidean length (straight-line length) from (0, 0) to (x, y).
- *
- * @return {number} The length of this vector.
- */
- length() {
- return Math.sqrt(this.x * this.x + this.y * this.y);
- }
- /**
- * Computes the Manhattan length of this vector.
- *
- * @return {number} The length of this vector.
- */
- manhattanLength() {
- return Math.abs(this.x) + Math.abs(this.y);
- }
- /**
- * Converts this vector to a unit vector - that is, sets it equal to a vector
- * with the same direction as this one, but with a vector length of `1`.
- *
- * @return {Vector2} A reference to this vector.
- */
- normalize() {
- return this.divideScalar(this.length() || 1);
- }
- /**
- * Computes the angle in radians of this vector with respect to the positive x-axis.
- *
- * @return {number} The angle in radians.
- */
- angle() {
- return Math.atan2(-this.y, -this.x) + Math.PI;
- }
- /**
- * Returns the angle between the given vector and this instance in radians.
- *
- * @param {Vector2} v - The vector to compute the angle with.
- * @return {number} The angle in radians.
- */
- angleTo(e) {
- const t = Math.sqrt(this.lengthSq() * e.lengthSq());
- if (t === 0) return Math.PI / 2;
- const i = this.dot(e) / t;
- return Math.acos(ze(i, -1, 1));
- }
- /**
- * Computes the distance from the given vector to this instance.
- *
- * @param {Vector2} v - The vector to compute the distance to.
- * @return {number} The distance.
- */
- distanceTo(e) {
- return Math.sqrt(this.distanceToSquared(e));
- }
- /**
- * Computes the squared distance from the given vector to this instance.
- * If you are just comparing the distance with another distance, you should compare
- * the distance squared instead as it is slightly more efficient to calculate.
- *
- * @param {Vector2} v - The vector to compute the squared distance to.
- * @return {number} The squared distance.
- */
- distanceToSquared(e) {
- const t = this.x - e.x, i = this.y - e.y;
- return t * t + i * i;
- }
- /**
- * Computes the Manhattan distance from the given vector to this instance.
- *
- * @param {Vector2} v - The vector to compute the Manhattan distance to.
- * @return {number} The Manhattan distance.
- */
- manhattanDistanceTo(e) {
- return Math.abs(this.x - e.x) + Math.abs(this.y - e.y);
- }
- /**
- * Sets this vector to a vector with the same direction as this one, but
- * with the specified length.
- *
- * @param {number} length - The new length of this vector.
- * @return {Vector2} A reference to this vector.
- */
- setLength(e) {
- return this.normalize().multiplyScalar(e);
- }
- /**
- * Linearly interpolates between the given vector and this instance, where
- * alpha is the percent distance along the line - alpha = 0 will be this
- * vector, and alpha = 1 will be the given one.
- *
- * @param {Vector2} v - The vector to interpolate towards.
- * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
- * @return {Vector2} A reference to this vector.
- */
- lerp(e, t) {
- return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this;
- }
- /**
- * Linearly interpolates between the given vectors, where alpha is the percent
- * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
- * be the second one. The result is stored in this instance.
- *
- * @param {Vector2} v1 - The first vector.
- * @param {Vector2} v2 - The second vector.
- * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
- * @return {Vector2} A reference to this vector.
- */
- lerpVectors(e, t, i) {
- return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this;
- }
- /**
- * Returns `true` if this vector is equal with the given one.
- *
- * @param {Vector2} v - The vector to test for equality.
- * @return {boolean} Whether this vector is equal with the given one.
- */
- equals(e) {
- return e.x === this.x && e.y === this.y;
- }
- /**
- * Sets this vector's x value to be `array[ offset ]` and y
- * value to be `array[ offset + 1 ]`.
- *
- * @param {Array} array - An array holding the vector component values.
- * @param {number} [offset=0] - The offset into the array.
- * @return {Vector2} A reference to this vector.
- */
- fromArray(e, t = 0) {
- return this.x = e[t], this.y = e[t + 1], this;
- }
- /**
- * Writes the components of this vector to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the vector components.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The vector components.
- */
- toArray(e = [], t = 0) {
- return e[t] = this.x, e[t + 1] = this.y, e;
- }
- /**
- * Sets the components of this vector from the given buffer attribute.
- *
- * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
- * @param {number} index - The index into the attribute.
- * @return {Vector2} A reference to this vector.
- */
- fromBufferAttribute(e, t) {
- return this.x = e.getX(t), this.y = e.getY(t), this;
- }
- /**
- * Rotates this vector around the given center by the given angle.
- *
- * @param {Vector2} center - The point around which to rotate.
- * @param {number} angle - The angle to rotate, in radians.
- * @return {Vector2} A reference to this vector.
- */
- rotateAround(e, t) {
- const i = Math.cos(t), s = Math.sin(t), r = this.x - e.x, a = this.y - e.y;
- return this.x = r * i - a * s + e.x, this.y = r * s + a * i + e.y, this;
- }
- /**
- * Sets each component of this vector to a pseudo-random value between `0` and
- * `1`, excluding `1`.
- *
- * @return {Vector2} A reference to this vector.
- */
- random() {
- return this.x = Math.random(), this.y = Math.random(), this;
- }
- *[Symbol.iterator]() {
- yield this.x, yield this.y;
- }
-}
-class xi {
- /**
- * Constructs a new quaternion.
- *
- * @param {number} [x=0] - The x value of this quaternion.
- * @param {number} [y=0] - The y value of this quaternion.
- * @param {number} [z=0] - The z value of this quaternion.
- * @param {number} [w=1] - The w value of this quaternion.
- */
- constructor(e = 0, t = 0, i = 0, s = 1) {
- this.isQuaternion = !0, this._x = e, this._y = t, this._z = i, this._w = s;
- }
- /**
- * Interpolates between two quaternions via SLERP. This implementation assumes the
- * quaternion data are managed in flat arrays.
- *
- * @param {Array} dst - The destination array.
- * @param {number} dstOffset - An offset into the destination array.
- * @param {Array} src0 - The source array of the first quaternion.
- * @param {number} srcOffset0 - An offset into the first source array.
- * @param {Array} src1 - The source array of the second quaternion.
- * @param {number} srcOffset1 - An offset into the second source array.
- * @param {number} t - The interpolation factor in the range `[0,1]`.
- * @see {@link Quaternion#slerp}
- */
- static slerpFlat(e, t, i, s, r, a, o) {
- let l = i[s + 0], c = i[s + 1], h = i[s + 2], u = i[s + 3], d = r[a + 0], m = r[a + 1], g = r[a + 2], v = r[a + 3];
- if (o <= 0) {
- e[t + 0] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u;
- return;
- }
- if (o >= 1) {
- e[t + 0] = d, e[t + 1] = m, e[t + 2] = g, e[t + 3] = v;
- return;
- }
- if (u !== v || l !== d || c !== m || h !== g) {
- let f = l * d + c * m + h * g + u * v;
- f < 0 && (d = -d, m = -m, g = -g, v = -v, f = -f);
- let p = 1 - o;
- if (f < 0.9995) {
- const b = Math.acos(f), _ = Math.sin(b);
- p = Math.sin(p * b) / _, o = Math.sin(o * b) / _, l = l * p + d * o, c = c * p + m * o, h = h * p + g * o, u = u * p + v * o;
- } else {
- l = l * p + d * o, c = c * p + m * o, h = h * p + g * o, u = u * p + v * o;
- const b = 1 / Math.sqrt(l * l + c * c + h * h + u * u);
- l *= b, c *= b, h *= b, u *= b;
- }
- }
- e[t] = l, e[t + 1] = c, e[t + 2] = h, e[t + 3] = u;
- }
- /**
- * Multiplies two quaternions. This implementation assumes the quaternion data are managed
- * in flat arrays.
- *
- * @param {Array} dst - The destination array.
- * @param {number} dstOffset - An offset into the destination array.
- * @param {Array} src0 - The source array of the first quaternion.
- * @param {number} srcOffset0 - An offset into the first source array.
- * @param {Array} src1 - The source array of the second quaternion.
- * @param {number} srcOffset1 - An offset into the second source array.
- * @return {Array} The destination array.
- * @see {@link Quaternion#multiplyQuaternions}.
- */
- static multiplyQuaternionsFlat(e, t, i, s, r, a) {
- const o = i[s], l = i[s + 1], c = i[s + 2], h = i[s + 3], u = r[a], d = r[a + 1], m = r[a + 2], g = r[a + 3];
- return e[t] = o * g + h * u + l * m - c * d, e[t + 1] = l * g + h * d + c * u - o * m, e[t + 2] = c * g + h * m + o * d - l * u, e[t + 3] = h * g - o * u - l * d - c * m, e;
- }
- /**
- * The x value of this quaternion.
- *
- * @type {number}
- * @default 0
- */
- get x() {
- return this._x;
- }
- set x(e) {
- this._x = e, this._onChangeCallback();
- }
- /**
- * The y value of this quaternion.
- *
- * @type {number}
- * @default 0
- */
- get y() {
- return this._y;
- }
- set y(e) {
- this._y = e, this._onChangeCallback();
- }
- /**
- * The z value of this quaternion.
- *
- * @type {number}
- * @default 0
- */
- get z() {
- return this._z;
- }
- set z(e) {
- this._z = e, this._onChangeCallback();
- }
- /**
- * The w value of this quaternion.
- *
- * @type {number}
- * @default 1
- */
- get w() {
- return this._w;
- }
- set w(e) {
- this._w = e, this._onChangeCallback();
- }
- /**
- * Sets the quaternion components.
- *
- * @param {number} x - The x value of this quaternion.
- * @param {number} y - The y value of this quaternion.
- * @param {number} z - The z value of this quaternion.
- * @param {number} w - The w value of this quaternion.
- * @return {Quaternion} A reference to this quaternion.
- */
- set(e, t, i, s) {
- return this._x = e, this._y = t, this._z = i, this._w = s, this._onChangeCallback(), this;
- }
- /**
- * Returns a new quaternion with copied values from this instance.
- *
- * @return {Quaternion} A clone of this instance.
- */
- clone() {
- return new this.constructor(this._x, this._y, this._z, this._w);
- }
- /**
- * Copies the values of the given quaternion to this instance.
- *
- * @param {Quaternion} quaternion - The quaternion to copy.
- * @return {Quaternion} A reference to this quaternion.
- */
- copy(e) {
- return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this;
- }
- /**
- * Sets this quaternion from the rotation specified by the given
- * Euler angles.
- *
- * @param {Euler} euler - The Euler angles.
- * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
- * @return {Quaternion} A reference to this quaternion.
- */
- setFromEuler(e, t = !0) {
- const i = e._x, s = e._y, r = e._z, a = e._order, o = Math.cos, l = Math.sin, c = o(i / 2), h = o(s / 2), u = o(r / 2), d = l(i / 2), m = l(s / 2), g = l(r / 2);
- switch (a) {
- case "XYZ":
- this._x = d * h * u + c * m * g, this._y = c * m * u - d * h * g, this._z = c * h * g + d * m * u, this._w = c * h * u - d * m * g;
- break;
- case "YXZ":
- this._x = d * h * u + c * m * g, this._y = c * m * u - d * h * g, this._z = c * h * g - d * m * u, this._w = c * h * u + d * m * g;
- break;
- case "ZXY":
- this._x = d * h * u - c * m * g, this._y = c * m * u + d * h * g, this._z = c * h * g + d * m * u, this._w = c * h * u - d * m * g;
- break;
- case "ZYX":
- this._x = d * h * u - c * m * g, this._y = c * m * u + d * h * g, this._z = c * h * g - d * m * u, this._w = c * h * u + d * m * g;
- break;
- case "YZX":
- this._x = d * h * u + c * m * g, this._y = c * m * u + d * h * g, this._z = c * h * g - d * m * u, this._w = c * h * u - d * m * g;
- break;
- case "XZY":
- this._x = d * h * u - c * m * g, this._y = c * m * u - d * h * g, this._z = c * h * g + d * m * u, this._w = c * h * u + d * m * g;
- break;
- default:
- Se("Quaternion: .setFromEuler() encountered an unknown order: " + a);
- }
- return t === !0 && this._onChangeCallback(), this;
- }
- /**
- * Sets this quaternion from the given axis and angle.
- *
- * @param {Vector3} axis - The normalized axis.
- * @param {number} angle - The angle in radians.
- * @return {Quaternion} A reference to this quaternion.
- */
- setFromAxisAngle(e, t) {
- const i = t / 2, s = Math.sin(i);
- return this._x = e.x * s, this._y = e.y * s, this._z = e.z * s, this._w = Math.cos(i), this._onChangeCallback(), this;
- }
- /**
- * Sets this quaternion from the given rotation matrix.
- *
- * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
- * @return {Quaternion} A reference to this quaternion.
- */
- setFromRotationMatrix(e) {
- const t = e.elements, i = t[0], s = t[4], r = t[8], a = t[1], o = t[5], l = t[9], c = t[2], h = t[6], u = t[10], d = i + o + u;
- if (d > 0) {
- const m = 0.5 / Math.sqrt(d + 1);
- this._w = 0.25 / m, this._x = (h - l) * m, this._y = (r - c) * m, this._z = (a - s) * m;
- } else if (i > o && i > u) {
- const m = 2 * Math.sqrt(1 + i - o - u);
- this._w = (h - l) / m, this._x = 0.25 * m, this._y = (s + a) / m, this._z = (r + c) / m;
- } else if (o > u) {
- const m = 2 * Math.sqrt(1 + o - i - u);
- this._w = (r - c) / m, this._x = (s + a) / m, this._y = 0.25 * m, this._z = (l + h) / m;
- } else {
- const m = 2 * Math.sqrt(1 + u - i - o);
- this._w = (a - s) / m, this._x = (r + c) / m, this._y = (l + h) / m, this._z = 0.25 * m;
- }
- return this._onChangeCallback(), this;
- }
- /**
- * Sets this quaternion to the rotation required to rotate the direction vector
- * `vFrom` to the direction vector `vTo`.
- *
- * @param {Vector3} vFrom - The first (normalized) direction vector.
- * @param {Vector3} vTo - The second (normalized) direction vector.
- * @return {Quaternion} A reference to this quaternion.
- */
- setFromUnitVectors(e, t) {
- let i = e.dot(t) + 1;
- return i < 1e-8 ? (i = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = i) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = i)) : (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 = i), this.normalize();
- }
- /**
- * Returns the angle between this quaternion and the given one in radians.
- *
- * @param {Quaternion} q - The quaternion to compute the angle with.
- * @return {number} The angle in radians.
- */
- angleTo(e) {
- return 2 * Math.acos(Math.abs(ze(this.dot(e), -1, 1)));
- }
- /**
- * Rotates this quaternion by a given angular step to the given quaternion.
- * The method ensures that the final quaternion will not overshoot `q`.
- *
- * @param {Quaternion} q - The target quaternion.
- * @param {number} step - The angular step in radians.
- * @return {Quaternion} A reference to this quaternion.
- */
- rotateTowards(e, t) {
- const i = this.angleTo(e);
- if (i === 0) return this;
- const s = Math.min(1, t / i);
- return this.slerp(e, s), this;
- }
- /**
- * Sets this quaternion to the identity quaternion; that is, to the
- * quaternion that represents "no rotation".
- *
- * @return {Quaternion} A reference to this quaternion.
- */
- identity() {
- return this.set(0, 0, 0, 1);
- }
- /**
- * Inverts this quaternion via {@link Quaternion#conjugate}. The
- * quaternion is assumed to have unit length.
- *
- * @return {Quaternion} A reference to this quaternion.
- */
- invert() {
- return this.conjugate();
- }
- /**
- * Returns the rotational conjugate of this quaternion. The conjugate of a
- * quaternion represents the same rotation in the opposite direction about
- * the rotational axis.
- *
- * @return {Quaternion} A reference to this quaternion.
- */
- conjugate() {
- return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
- }
- /**
- * Calculates the dot product of this quaternion and the given one.
- *
- * @param {Quaternion} v - The quaternion to compute the dot product with.
- * @return {number} The result of the dot product.
- */
- dot(e) {
- return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w;
- }
- /**
- * Computes the squared Euclidean length (straight-line length) of this quaternion,
- * considered as a 4 dimensional vector. This can be useful if you are comparing the
- * lengths of two quaternions, as this is a slightly more efficient calculation than
- * {@link Quaternion#length}.
- *
- * @return {number} The squared Euclidean length.
- */
- lengthSq() {
- return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
- }
- /**
- * Computes the Euclidean length (straight-line length) of this quaternion,
- * considered as a 4 dimensional vector.
- *
- * @return {number} The Euclidean length.
- */
- length() {
- return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w);
- }
- /**
- * Normalizes this quaternion - that is, calculated the quaternion that performs
- * the same rotation as this one, but has a length equal to `1`.
- *
- * @return {Quaternion} A reference to this quaternion.
- */
- 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;
- }
- /**
- * Multiplies this quaternion by the given one.
- *
- * @param {Quaternion} q - The quaternion.
- * @return {Quaternion} A reference to this quaternion.
- */
- multiply(e) {
- return this.multiplyQuaternions(this, e);
- }
- /**
- * Pre-multiplies this quaternion by the given one.
- *
- * @param {Quaternion} q - The quaternion.
- * @return {Quaternion} A reference to this quaternion.
- */
- premultiply(e) {
- return this.multiplyQuaternions(e, this);
- }
- /**
- * Multiplies the given quaternions and stores the result in this instance.
- *
- * @param {Quaternion} a - The first quaternion.
- * @param {Quaternion} b - The second quaternion.
- * @return {Quaternion} A reference to this quaternion.
- */
- multiplyQuaternions(e, t) {
- const i = e._x, s = e._y, r = e._z, a = e._w, o = t._x, l = t._y, c = t._z, h = t._w;
- return this._x = i * h + a * o + s * c - r * l, this._y = s * h + a * l + r * o - i * c, this._z = r * h + a * c + i * l - s * o, this._w = a * h - i * o - s * l - r * c, this._onChangeCallback(), this;
- }
- /**
- * Performs a spherical linear interpolation between quaternions.
- *
- * @param {Quaternion} qb - The target quaternion.
- * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
- * @return {Quaternion} A reference to this quaternion.
- */
- slerp(e, t) {
- if (t <= 0) return this;
- if (t >= 1) return this.copy(e);
- let i = e._x, s = e._y, r = e._z, a = e._w, o = this.dot(e);
- o < 0 && (i = -i, s = -s, r = -r, a = -a, o = -o);
- let l = 1 - t;
- if (o < 0.9995) {
- const c = Math.acos(o), h = Math.sin(c);
- l = Math.sin(l * c) / h, t = Math.sin(t * c) / h, this._x = this._x * l + i * t, this._y = this._y * l + s * t, this._z = this._z * l + r * t, this._w = this._w * l + a * t, this._onChangeCallback();
- } else
- this._x = this._x * l + i * t, this._y = this._y * l + s * t, this._z = this._z * l + r * t, this._w = this._w * l + a * t, this.normalize();
- return this;
- }
- /**
- * Performs a spherical linear interpolation between the given quaternions
- * and stores the result in this quaternion.
- *
- * @param {Quaternion} qa - The source quaternion.
- * @param {Quaternion} qb - The target quaternion.
- * @param {number} t - The interpolation factor in the closed interval `[0, 1]`.
- * @return {Quaternion} A reference to this quaternion.
- */
- slerpQuaternions(e, t, i) {
- return this.copy(e).slerp(t, i);
- }
- /**
- * Sets this quaternion to a uniformly random, normalized quaternion.
- *
- * @return {Quaternion} A reference to this quaternion.
- */
- random() {
- const e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), i = Math.random(), s = Math.sqrt(1 - i), r = Math.sqrt(i);
- return this.set(
- s * Math.sin(e),
- s * Math.cos(e),
- r * Math.sin(t),
- r * Math.cos(t)
- );
- }
- /**
- * Returns `true` if this quaternion is equal with the given one.
- *
- * @param {Quaternion} quaternion - The quaternion to test for equality.
- * @return {boolean} Whether this quaternion is equal with the given one.
- */
- equals(e) {
- return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w;
- }
- /**
- * Sets this quaternion's components from the given array.
- *
- * @param {Array} array - An array holding the quaternion component values.
- * @param {number} [offset=0] - The offset into the array.
- * @return {Quaternion} A reference to this quaternion.
- */
- 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;
- }
- /**
- * Writes the components of this quaternion to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the quaternion components.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The quaternion components.
- */
- 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;
- }
- /**
- * Sets the components of this quaternion from the given buffer attribute.
- *
- * @param {BufferAttribute} attribute - The buffer attribute holding quaternion data.
- * @param {number} index - The index into the attribute.
- * @return {Quaternion} A reference to this quaternion.
- */
- 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;
- }
- /**
- * This methods defines the serialization result of this class. Returns the
- * numerical elements of this quaternion in an array of format `[x, y, z, w]`.
- *
- * @return {Array} The serialized quaternion.
- */
- 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 w {
- /**
- * Constructs a new 3D vector.
- *
- * @param {number} [x=0] - The x value of this vector.
- * @param {number} [y=0] - The y value of this vector.
- * @param {number} [z=0] - The z value of this vector.
- */
- constructor(e = 0, t = 0, i = 0) {
- w.prototype.isVector3 = !0, this.x = e, this.y = t, this.z = i;
- }
- /**
- * Sets the vector components.
- *
- * @param {number} x - The value of the x component.
- * @param {number} y - The value of the y component.
- * @param {number} z - The value of the z component.
- * @return {Vector3} A reference to this vector.
- */
- set(e, t, i) {
- return i === void 0 && (i = this.z), this.x = e, this.y = t, this.z = i, this;
- }
- /**
- * Sets the vector components to the same value.
- *
- * @param {number} scalar - The value to set for all vector components.
- * @return {Vector3} A reference to this vector.
- */
- setScalar(e) {
- return this.x = e, this.y = e, this.z = e, this;
- }
- /**
- * Sets the vector's x component to the given value
- *
- * @param {number} x - The value to set.
- * @return {Vector3} A reference to this vector.
- */
- setX(e) {
- return this.x = e, this;
- }
- /**
- * Sets the vector's y component to the given value
- *
- * @param {number} y - The value to set.
- * @return {Vector3} A reference to this vector.
- */
- setY(e) {
- return this.y = e, this;
- }
- /**
- * Sets the vector's z component to the given value
- *
- * @param {number} z - The value to set.
- * @return {Vector3} A reference to this vector.
- */
- setZ(e) {
- return this.z = e, this;
- }
- /**
- * Allows to set a vector component with an index.
- *
- * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
- * @param {number} value - The value to set.
- * @return {Vector3} A reference to this vector.
- */
- 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;
- }
- /**
- * Returns the value of the vector component which matches the given index.
- *
- * @param {number} index - The component index. `0` equals to x, `1` equals to y, `2` equals to z.
- * @return {number} A vector component value.
- */
- 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);
- }
- }
- /**
- * Returns a new vector with copied values from this instance.
- *
- * @return {Vector3} A clone of this instance.
- */
- clone() {
- return new this.constructor(this.x, this.y, this.z);
- }
- /**
- * Copies the values of the given vector to this instance.
- *
- * @param {Vector3} v - The vector to copy.
- * @return {Vector3} A reference to this vector.
- */
- copy(e) {
- return this.x = e.x, this.y = e.y, this.z = e.z, this;
- }
- /**
- * Adds the given vector to this instance.
- *
- * @param {Vector3} v - The vector to add.
- * @return {Vector3} A reference to this vector.
- */
- add(e) {
- return this.x += e.x, this.y += e.y, this.z += e.z, this;
- }
- /**
- * Adds the given scalar value to all components of this instance.
- *
- * @param {number} s - The scalar to add.
- * @return {Vector3} A reference to this vector.
- */
- addScalar(e) {
- return this.x += e, this.y += e, this.z += e, this;
- }
- /**
- * Adds the given vectors and stores the result in this instance.
- *
- * @param {Vector3} a - The first vector.
- * @param {Vector3} b - The second vector.
- * @return {Vector3} A reference to this vector.
- */
- addVectors(e, t) {
- return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this;
- }
- /**
- * Adds the given vector scaled by the given factor to this instance.
- *
- * @param {Vector3|Vector4} v - The vector.
- * @param {number} s - The factor that scales `v`.
- * @return {Vector3} A reference to this vector.
- */
- addScaledVector(e, t) {
- return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this;
- }
- /**
- * Subtracts the given vector from this instance.
- *
- * @param {Vector3} v - The vector to subtract.
- * @return {Vector3} A reference to this vector.
- */
- sub(e) {
- return this.x -= e.x, this.y -= e.y, this.z -= e.z, this;
- }
- /**
- * Subtracts the given scalar value from all components of this instance.
- *
- * @param {number} s - The scalar to subtract.
- * @return {Vector3} A reference to this vector.
- */
- subScalar(e) {
- return this.x -= e, this.y -= e, this.z -= e, this;
- }
- /**
- * Subtracts the given vectors and stores the result in this instance.
- *
- * @param {Vector3} a - The first vector.
- * @param {Vector3} b - The second vector.
- * @return {Vector3} A reference to this vector.
- */
- subVectors(e, t) {
- return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this;
- }
- /**
- * Multiplies the given vector with this instance.
- *
- * @param {Vector3} v - The vector to multiply.
- * @return {Vector3} A reference to this vector.
- */
- multiply(e) {
- return this.x *= e.x, this.y *= e.y, this.z *= e.z, this;
- }
- /**
- * Multiplies the given scalar value with all components of this instance.
- *
- * @param {number} scalar - The scalar to multiply.
- * @return {Vector3} A reference to this vector.
- */
- multiplyScalar(e) {
- return this.x *= e, this.y *= e, this.z *= e, this;
- }
- /**
- * Multiplies the given vectors and stores the result in this instance.
- *
- * @param {Vector3} a - The first vector.
- * @param {Vector3} b - The second vector.
- * @return {Vector3} A reference to this vector.
- */
- multiplyVectors(e, t) {
- return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this;
- }
- /**
- * Applies the given Euler rotation to this vector.
- *
- * @param {Euler} euler - The Euler angles.
- * @return {Vector3} A reference to this vector.
- */
- applyEuler(e) {
- return this.applyQuaternion(yl.setFromEuler(e));
- }
- /**
- * Applies a rotation specified by an axis and an angle to this vector.
- *
- * @param {Vector3} axis - A normalized vector representing the rotation axis.
- * @param {number} angle - The angle in radians.
- * @return {Vector3} A reference to this vector.
- */
- applyAxisAngle(e, t) {
- return this.applyQuaternion(yl.setFromAxisAngle(e, t));
- }
- /**
- * Multiplies this vector with the given 3x3 matrix.
- *
- * @param {Matrix3} m - The 3x3 matrix.
- * @return {Vector3} A reference to this vector.
- */
- applyMatrix3(e) {
- const t = this.x, i = this.y, s = this.z, r = e.elements;
- return this.x = r[0] * t + r[3] * i + r[6] * s, this.y = r[1] * t + r[4] * i + r[7] * s, this.z = r[2] * t + r[5] * i + r[8] * s, this;
- }
- /**
- * Multiplies this vector by the given normal matrix and normalizes
- * the result.
- *
- * @param {Matrix3} m - The normal matrix.
- * @return {Vector3} A reference to this vector.
- */
- applyNormalMatrix(e) {
- return this.applyMatrix3(e).normalize();
- }
- /**
- * Multiplies this vector (with an implicit 1 in the 4th dimension) by m, and
- * divides by perspective.
- *
- * @param {Matrix4} m - The matrix to apply.
- * @return {Vector3} A reference to this vector.
- */
- applyMatrix4(e) {
- const t = this.x, i = this.y, s = this.z, r = e.elements, a = 1 / (r[3] * t + r[7] * i + r[11] * s + r[15]);
- return this.x = (r[0] * t + r[4] * i + r[8] * s + r[12]) * a, this.y = (r[1] * t + r[5] * i + r[9] * s + r[13]) * a, this.z = (r[2] * t + r[6] * i + r[10] * s + r[14]) * a, this;
- }
- /**
- * Applies the given Quaternion to this vector.
- *
- * @param {Quaternion} q - The Quaternion.
- * @return {Vector3} A reference to this vector.
- */
- applyQuaternion(e) {
- const t = this.x, i = this.y, s = this.z, r = e.x, a = e.y, o = e.z, l = e.w, c = 2 * (a * s - o * i), h = 2 * (o * t - r * s), u = 2 * (r * i - a * t);
- return this.x = t + l * c + a * u - o * h, this.y = i + l * h + o * c - r * u, this.z = s + l * u + r * h - a * c, this;
- }
- /**
- * Projects this vector from world space into the camera's normalized
- * device coordinate (NDC) space.
- *
- * @param {Camera} camera - The camera.
- * @return {Vector3} A reference to this vector.
- */
- project(e) {
- return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix);
- }
- /**
- * Unprojects this vector from the camera's normalized device coordinate (NDC)
- * space into world space.
- *
- * @param {Camera} camera - The camera.
- * @return {Vector3} A reference to this vector.
- */
- unproject(e) {
- return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld);
- }
- /**
- * Transforms the direction of this vector by a matrix (the upper left 3 x 3
- * subset of the given 4x4 matrix and then normalizes the result.
- *
- * @param {Matrix4} m - The matrix.
- * @return {Vector3} A reference to this vector.
- */
- transformDirection(e) {
- const t = this.x, i = this.y, s = this.z, r = e.elements;
- return this.x = r[0] * t + r[4] * i + r[8] * s, this.y = r[1] * t + r[5] * i + r[9] * s, this.z = r[2] * t + r[6] * i + r[10] * s, this.normalize();
- }
- /**
- * Divides this instance by the given vector.
- *
- * @param {Vector3} v - The vector to divide.
- * @return {Vector3} A reference to this vector.
- */
- divide(e) {
- return this.x /= e.x, this.y /= e.y, this.z /= e.z, this;
- }
- /**
- * Divides this vector by the given scalar.
- *
- * @param {number} scalar - The scalar to divide.
- * @return {Vector3} A reference to this vector.
- */
- divideScalar(e) {
- return this.multiplyScalar(1 / e);
- }
- /**
- * If this vector's x, y or z value is greater than the given vector's x, y or z
- * value, replace that value with the corresponding min value.
- *
- * @param {Vector3} v - The vector.
- * @return {Vector3} A reference to this vector.
- */
- 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;
- }
- /**
- * If this vector's x, y or z value is less than the given vector's x, y or z
- * value, replace that value with the corresponding max value.
- *
- * @param {Vector3} v - The vector.
- * @return {Vector3} A reference to this vector.
- */
- 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;
- }
- /**
- * If this vector's x, y or z value is greater than the max vector's x, y or z
- * value, it is replaced by the corresponding value.
- * If this vector's x, y or z value is less than the min vector's x, y or z value,
- * it is replaced by the corresponding value.
- *
- * @param {Vector3} min - The minimum x, y and z values.
- * @param {Vector3} max - The maximum x, y and z values in the desired range.
- * @return {Vector3} A reference to this vector.
- */
- clamp(e, t) {
- return this.x = ze(this.x, e.x, t.x), this.y = ze(this.y, e.y, t.y), this.z = ze(this.z, e.z, t.z), this;
- }
- /**
- * If this vector's x, y or z values are greater than the max value, they are
- * replaced by the max value.
- * If this vector's x, y or z values are less than the min value, they are
- * replaced by the min value.
- *
- * @param {number} minVal - The minimum value the components will be clamped to.
- * @param {number} maxVal - The maximum value the components will be clamped to.
- * @return {Vector3} A reference to this vector.
- */
- clampScalar(e, t) {
- return this.x = ze(this.x, e, t), this.y = ze(this.y, e, t), this.z = ze(this.z, e, t), this;
- }
- /**
- * If this vector's length is greater than the max value, it is replaced by
- * the max value.
- * If this vector's length is less than the min value, it is replaced by the
- * min value.
- *
- * @param {number} min - The minimum value the vector length will be clamped to.
- * @param {number} max - The maximum value the vector length will be clamped to.
- * @return {Vector3} A reference to this vector.
- */
- clampLength(e, t) {
- const i = this.length();
- return this.divideScalar(i || 1).multiplyScalar(ze(i, e, t));
- }
- /**
- * The components of this vector are rounded down to the nearest integer value.
- *
- * @return {Vector3} A reference to this vector.
- */
- floor() {
- return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
- }
- /**
- * The components of this vector are rounded up to the nearest integer value.
- *
- * @return {Vector3} A reference to this vector.
- */
- ceil() {
- return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
- }
- /**
- * The components of this vector are rounded to the nearest integer value
- *
- * @return {Vector3} A reference to this vector.
- */
- round() {
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
- }
- /**
- * The components of this vector are rounded towards zero (up if negative,
- * down if positive) to an integer value.
- *
- * @return {Vector3} A reference to this vector.
- */
- roundToZero() {
- return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
- }
- /**
- * Inverts this vector - i.e. sets x = -x, y = -y and z = -z.
- *
- * @return {Vector3} A reference to this vector.
- */
- negate() {
- return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
- }
- /**
- * Calculates the dot product of the given vector with this instance.
- *
- * @param {Vector3} v - The vector to compute the dot product with.
- * @return {number} The result of the dot product.
- */
- dot(e) {
- return this.x * e.x + this.y * e.y + this.z * e.z;
- }
- // TODO lengthSquared?
- /**
- * Computes the square of the Euclidean length (straight-line length) from
- * (0, 0, 0) to (x, y, z). If you are comparing the lengths of vectors, you should
- * compare the length squared instead as it is slightly more efficient to calculate.
- *
- * @return {number} The square length of this vector.
- */
- lengthSq() {
- return this.x * this.x + this.y * this.y + this.z * this.z;
- }
- /**
- * Computes the Euclidean length (straight-line length) from (0, 0, 0) to (x, y, z).
- *
- * @return {number} The length of this vector.
- */
- length() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
- }
- /**
- * Computes the Manhattan length of this vector.
- *
- * @return {number} The length of this vector.
- */
- manhattanLength() {
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
- }
- /**
- * Converts this vector to a unit vector - that is, sets it equal to a vector
- * with the same direction as this one, but with a vector length of `1`.
- *
- * @return {Vector3} A reference to this vector.
- */
- normalize() {
- return this.divideScalar(this.length() || 1);
- }
- /**
- * Sets this vector to a vector with the same direction as this one, but
- * with the specified length.
- *
- * @param {number} length - The new length of this vector.
- * @return {Vector3} A reference to this vector.
- */
- setLength(e) {
- return this.normalize().multiplyScalar(e);
- }
- /**
- * Linearly interpolates between the given vector and this instance, where
- * alpha is the percent distance along the line - alpha = 0 will be this
- * vector, and alpha = 1 will be the given one.
- *
- * @param {Vector3} v - The vector to interpolate towards.
- * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
- * @return {Vector3} A reference to this vector.
- */
- 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;
- }
- /**
- * Linearly interpolates between the given vectors, where alpha is the percent
- * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
- * be the second one. The result is stored in this instance.
- *
- * @param {Vector3} v1 - The first vector.
- * @param {Vector3} v2 - The second vector.
- * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
- * @return {Vector3} A reference to this vector.
- */
- lerpVectors(e, t, i) {
- return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this.z = e.z + (t.z - e.z) * i, this;
- }
- /**
- * Calculates the cross product of the given vector with this instance.
- *
- * @param {Vector3} v - The vector to compute the cross product with.
- * @return {Vector3} The result of the cross product.
- */
- cross(e) {
- return this.crossVectors(this, e);
- }
- /**
- * Calculates the cross product of the given vectors and stores the result
- * in this instance.
- *
- * @param {Vector3} a - The first vector.
- * @param {Vector3} b - The second vector.
- * @return {Vector3} A reference to this vector.
- */
- crossVectors(e, t) {
- const i = e.x, s = e.y, r = e.z, a = t.x, o = t.y, l = t.z;
- return this.x = s * l - r * o, this.y = r * a - i * l, this.z = i * o - s * a, this;
- }
- /**
- * Projects this vector onto the given one.
- *
- * @param {Vector3} v - The vector to project to.
- * @return {Vector3} A reference to this vector.
- */
- projectOnVector(e) {
- const t = e.lengthSq();
- if (t === 0) return this.set(0, 0, 0);
- const i = e.dot(this) / t;
- return this.copy(e).multiplyScalar(i);
- }
- /**
- * Projects this vector onto a plane by subtracting this
- * vector projected onto the plane's normal from this vector.
- *
- * @param {Vector3} planeNormal - The plane normal.
- * @return {Vector3} A reference to this vector.
- */
- projectOnPlane(e) {
- return Vr.copy(this).projectOnVector(e), this.sub(Vr);
- }
- /**
- * Reflects this vector off a plane orthogonal to the given normal vector.
- *
- * @param {Vector3} normal - The (normalized) normal vector.
- * @return {Vector3} A reference to this vector.
- */
- reflect(e) {
- return this.sub(Vr.copy(e).multiplyScalar(2 * this.dot(e)));
- }
- /**
- * Returns the angle between the given vector and this instance in radians.
- *
- * @param {Vector3} v - The vector to compute the angle with.
- * @return {number} The angle in radians.
- */
- angleTo(e) {
- const t = Math.sqrt(this.lengthSq() * e.lengthSq());
- if (t === 0) return Math.PI / 2;
- const i = this.dot(e) / t;
- return Math.acos(ze(i, -1, 1));
- }
- /**
- * Computes the distance from the given vector to this instance.
- *
- * @param {Vector3} v - The vector to compute the distance to.
- * @return {number} The distance.
- */
- distanceTo(e) {
- return Math.sqrt(this.distanceToSquared(e));
- }
- /**
- * Computes the squared distance from the given vector to this instance.
- * If you are just comparing the distance with another distance, you should compare
- * the distance squared instead as it is slightly more efficient to calculate.
- *
- * @param {Vector3} v - The vector to compute the squared distance to.
- * @return {number} The squared distance.
- */
- distanceToSquared(e) {
- const t = this.x - e.x, i = this.y - e.y, s = this.z - e.z;
- return t * t + i * i + s * s;
- }
- /**
- * Computes the Manhattan distance from the given vector to this instance.
- *
- * @param {Vector3} v - The vector to compute the Manhattan distance to.
- * @return {number} The Manhattan distance.
- */
- manhattanDistanceTo(e) {
- return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z);
- }
- /**
- * Sets the vector components from the given spherical coordinates.
- *
- * @param {Spherical} s - The spherical coordinates.
- * @return {Vector3} A reference to this vector.
- */
- setFromSpherical(e) {
- return this.setFromSphericalCoords(e.radius, e.phi, e.theta);
- }
- /**
- * Sets the vector components from the given spherical coordinates.
- *
- * @param {number} radius - The radius.
- * @param {number} phi - The phi angle in radians.
- * @param {number} theta - The theta angle in radians.
- * @return {Vector3} A reference to this vector.
- */
- setFromSphericalCoords(e, t, i) {
- const s = Math.sin(t) * e;
- return this.x = s * Math.sin(i), this.y = Math.cos(t) * e, this.z = s * Math.cos(i), this;
- }
- /**
- * Sets the vector components from the given cylindrical coordinates.
- *
- * @param {Cylindrical} c - The cylindrical coordinates.
- * @return {Vector3} A reference to this vector.
- */
- setFromCylindrical(e) {
- return this.setFromCylindricalCoords(e.radius, e.theta, e.y);
- }
- /**
- * Sets the vector components from the given cylindrical coordinates.
- *
- * @param {number} radius - The radius.
- * @param {number} theta - The theta angle in radians.
- * @param {number} y - The y value.
- * @return {Vector3} A reference to this vector.
- */
- setFromCylindricalCoords(e, t, i) {
- return this.x = e * Math.sin(t), this.y = i, this.z = e * Math.cos(t), this;
- }
- /**
- * Sets the vector components to the position elements of the
- * given transformation matrix.
- *
- * @param {Matrix4} m - The 4x4 matrix.
- * @return {Vector3} A reference to this vector.
- */
- setFromMatrixPosition(e) {
- const t = e.elements;
- return this.x = t[12], this.y = t[13], this.z = t[14], this;
- }
- /**
- * Sets the vector components to the scale elements of the
- * given transformation matrix.
- *
- * @param {Matrix4} m - The 4x4 matrix.
- * @return {Vector3} A reference to this vector.
- */
- setFromMatrixScale(e) {
- const t = this.setFromMatrixColumn(e, 0).length(), i = this.setFromMatrixColumn(e, 1).length(), s = this.setFromMatrixColumn(e, 2).length();
- return this.x = t, this.y = i, this.z = s, this;
- }
- /**
- * Sets the vector components from the specified matrix column.
- *
- * @param {Matrix4} m - The 4x4 matrix.
- * @param {number} index - The column index.
- * @return {Vector3} A reference to this vector.
- */
- setFromMatrixColumn(e, t) {
- return this.fromArray(e.elements, t * 4);
- }
- /**
- * Sets the vector components from the specified matrix column.
- *
- * @param {Matrix3} m - The 3x3 matrix.
- * @param {number} index - The column index.
- * @return {Vector3} A reference to this vector.
- */
- setFromMatrix3Column(e, t) {
- return this.fromArray(e.elements, t * 3);
- }
- /**
- * Sets the vector components from the given Euler angles.
- *
- * @param {Euler} e - The Euler angles to set.
- * @return {Vector3} A reference to this vector.
- */
- setFromEuler(e) {
- return this.x = e._x, this.y = e._y, this.z = e._z, this;
- }
- /**
- * Sets the vector components from the RGB components of the
- * given color.
- *
- * @param {Color} c - The color to set.
- * @return {Vector3} A reference to this vector.
- */
- setFromColor(e) {
- return this.x = e.r, this.y = e.g, this.z = e.b, this;
- }
- /**
- * Returns `true` if this vector is equal with the given one.
- *
- * @param {Vector3} v - The vector to test for equality.
- * @return {boolean} Whether this vector is equal with the given one.
- */
- equals(e) {
- return e.x === this.x && e.y === this.y && e.z === this.z;
- }
- /**
- * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`
- * and z value to be `array[ offset + 2 ]`.
- *
- * @param {Array} array - An array holding the vector component values.
- * @param {number} [offset=0] - The offset into the array.
- * @return {Vector3} A reference to this vector.
- */
- fromArray(e, t = 0) {
- return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this;
- }
- /**
- * Writes the components of this vector to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the vector components.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The vector components.
- */
- toArray(e = [], t = 0) {
- return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e;
- }
- /**
- * Sets the components of this vector from the given buffer attribute.
- *
- * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
- * @param {number} index - The index into the attribute.
- * @return {Vector3} A reference to this vector.
- */
- fromBufferAttribute(e, t) {
- return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this;
- }
- /**
- * Sets each component of this vector to a pseudo-random value between `0` and
- * `1`, excluding `1`.
- *
- * @return {Vector3} A reference to this vector.
- */
- random() {
- return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
- }
- /**
- * Sets this vector to a uniformly random point on a unit sphere.
- *
- * @return {Vector3} A reference to this vector.
- */
- randomDirection() {
- const e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, i = Math.sqrt(1 - t * t);
- return this.x = i * Math.cos(e), this.y = t, this.z = i * Math.sin(e), this;
- }
- *[Symbol.iterator]() {
- yield this.x, yield this.y, yield this.z;
- }
-}
-const Vr = /* @__PURE__ */ new w(), yl = /* @__PURE__ */ new xi();
-class ke {
- /**
- * Constructs a new 3x3 matrix. The arguments are supposed to be
- * in row-major order. If no arguments are provided, the constructor
- * initializes the matrix as an identity matrix.
- *
- * @param {number} [n11] - 1-1 matrix element.
- * @param {number} [n12] - 1-2 matrix element.
- * @param {number} [n13] - 1-3 matrix element.
- * @param {number} [n21] - 2-1 matrix element.
- * @param {number} [n22] - 2-2 matrix element.
- * @param {number} [n23] - 2-3 matrix element.
- * @param {number} [n31] - 3-1 matrix element.
- * @param {number} [n32] - 3-2 matrix element.
- * @param {number} [n33] - 3-3 matrix element.
- */
- constructor(e, t, i, s, r, a, o, l, c) {
- ke.prototype.isMatrix3 = !0, this.elements = [
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1
- ], e !== void 0 && this.set(e, t, i, s, r, a, o, l, c);
- }
- /**
- * Sets the elements of the matrix.The arguments are supposed to be
- * in row-major order.
- *
- * @param {number} [n11] - 1-1 matrix element.
- * @param {number} [n12] - 1-2 matrix element.
- * @param {number} [n13] - 1-3 matrix element.
- * @param {number} [n21] - 2-1 matrix element.
- * @param {number} [n22] - 2-2 matrix element.
- * @param {number} [n23] - 2-3 matrix element.
- * @param {number} [n31] - 3-1 matrix element.
- * @param {number} [n32] - 3-2 matrix element.
- * @param {number} [n33] - 3-3 matrix element.
- * @return {Matrix3} A reference to this matrix.
- */
- set(e, t, i, s, r, a, o, l, c) {
- const h = this.elements;
- return h[0] = e, h[1] = s, h[2] = o, h[3] = t, h[4] = r, h[5] = l, h[6] = i, h[7] = a, h[8] = c, this;
- }
- /**
- * Sets this matrix to the 3x3 identity matrix.
- *
- * @return {Matrix3} A reference to this matrix.
- */
- identity() {
- return this.set(
- 1,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Copies the values of the given matrix to this instance.
- *
- * @param {Matrix3} m - The matrix to copy.
- * @return {Matrix3} A reference to this matrix.
- */
- copy(e) {
- const t = this.elements, i = e.elements;
- return t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t[4] = i[4], t[5] = i[5], t[6] = i[6], t[7] = i[7], t[8] = i[8], this;
- }
- /**
- * Extracts the basis of this matrix into the three axis vectors provided.
- *
- * @param {Vector3} xAxis - The basis's x axis.
- * @param {Vector3} yAxis - The basis's y axis.
- * @param {Vector3} zAxis - The basis's z axis.
- * @return {Matrix3} A reference to this matrix.
- */
- extractBasis(e, t, i) {
- return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), i.setFromMatrix3Column(this, 2), this;
- }
- /**
- * Set this matrix to the upper 3x3 matrix of the given 4x4 matrix.
- *
- * @param {Matrix4} m - The 4x4 matrix.
- * @return {Matrix3} A reference to this matrix.
- */
- 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;
- }
- /**
- * Post-multiplies this matrix by the given 3x3 matrix.
- *
- * @param {Matrix3} m - The matrix to multiply with.
- * @return {Matrix3} A reference to this matrix.
- */
- multiply(e) {
- return this.multiplyMatrices(this, e);
- }
- /**
- * Pre-multiplies this matrix by the given 3x3 matrix.
- *
- * @param {Matrix3} m - The matrix to multiply with.
- * @return {Matrix3} A reference to this matrix.
- */
- premultiply(e) {
- return this.multiplyMatrices(e, this);
- }
- /**
- * Multiples the given 3x3 matrices and stores the result
- * in this matrix.
- *
- * @param {Matrix3} a - The first matrix.
- * @param {Matrix3} b - The second matrix.
- * @return {Matrix3} A reference to this matrix.
- */
- multiplyMatrices(e, t) {
- const i = e.elements, s = t.elements, r = this.elements, a = i[0], o = i[3], l = i[6], c = i[1], h = i[4], u = i[7], d = i[2], m = i[5], g = i[8], v = s[0], f = s[3], p = s[6], b = s[1], _ = s[4], E = s[7], R = s[2], T = s[5], A = s[8];
- return r[0] = a * v + o * b + l * R, r[3] = a * f + o * _ + l * T, r[6] = a * p + o * E + l * A, r[1] = c * v + h * b + u * R, r[4] = c * f + h * _ + u * T, r[7] = c * p + h * E + u * A, r[2] = d * v + m * b + g * R, r[5] = d * f + m * _ + g * T, r[8] = d * p + m * E + g * A, this;
- }
- /**
- * Multiplies every component of the matrix by the given scalar.
- *
- * @param {number} s - The scalar.
- * @return {Matrix3} A reference to this matrix.
- */
- 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;
- }
- /**
- * Computes and returns the determinant of this matrix.
- *
- * @return {number} The determinant.
- */
- determinant() {
- const e = this.elements, t = e[0], i = e[1], s = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8];
- return t * a * h - t * o * c - i * r * h + i * o * l + s * r * c - s * a * l;
- }
- /**
- * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
- * You can not invert with a determinant of zero. If you attempt this, the method produces
- * a zero matrix instead.
- *
- * @return {Matrix3} A reference to this matrix.
- */
- invert() {
- const e = this.elements, t = e[0], i = e[1], s = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8], u = h * a - o * c, d = o * l - h * r, m = c * r - a * l, g = t * u + i * d + s * m;
- if (g === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
- const v = 1 / g;
- return e[0] = u * v, e[1] = (s * c - h * i) * v, e[2] = (o * i - s * a) * v, e[3] = d * v, e[4] = (h * t - s * l) * v, e[5] = (s * r - o * t) * v, e[6] = m * v, e[7] = (i * l - c * t) * v, e[8] = (a * t - i * r) * v, this;
- }
- /**
- * Transposes this matrix in place.
- *
- * @return {Matrix3} A reference to this matrix.
- */
- 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;
- }
- /**
- * Computes the normal matrix which is the inverse transpose of the upper
- * left 3x3 portion of the given 4x4 matrix.
- *
- * @param {Matrix4} matrix4 - The 4x4 matrix.
- * @return {Matrix3} A reference to this matrix.
- */
- getNormalMatrix(e) {
- return this.setFromMatrix4(e).invert().transpose();
- }
- /**
- * Transposes this matrix into the supplied array, and returns itself unchanged.
- *
- * @param {Array} r - An array to store the transposed matrix elements.
- * @return {Matrix3} A reference to this matrix.
- */
- 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;
- }
- /**
- * Sets the UV transform matrix from offset, repeat, rotation, and center.
- *
- * @param {number} tx - Offset x.
- * @param {number} ty - Offset y.
- * @param {number} sx - Repeat x.
- * @param {number} sy - Repeat y.
- * @param {number} rotation - Rotation, in radians. Positive values rotate counterclockwise.
- * @param {number} cx - Center x of rotation.
- * @param {number} cy - Center y of rotation
- * @return {Matrix3} A reference to this matrix.
- */
- setUvTransform(e, t, i, s, r, a, o) {
- const l = Math.cos(r), c = Math.sin(r);
- return this.set(
- i * l,
- i * c,
- -i * (l * a + c * o) + a + e,
- -s * c,
- s * l,
- -s * (-c * a + l * o) + o + t,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Scales this matrix with the given scalar values.
- *
- * @param {number} sx - The amount to scale in the X axis.
- * @param {number} sy - The amount to scale in the Y axis.
- * @return {Matrix3} A reference to this matrix.
- */
- scale(e, t) {
- return this.premultiply(Gr.makeScale(e, t)), this;
- }
- /**
- * Rotates this matrix by the given angle.
- *
- * @param {number} theta - The rotation in radians.
- * @return {Matrix3} A reference to this matrix.
- */
- rotate(e) {
- return this.premultiply(Gr.makeRotation(-e)), this;
- }
- /**
- * Translates this matrix by the given scalar values.
- *
- * @param {number} tx - The amount to translate in the X axis.
- * @param {number} ty - The amount to translate in the Y axis.
- * @return {Matrix3} A reference to this matrix.
- */
- translate(e, t) {
- return this.premultiply(Gr.makeTranslation(e, t)), this;
- }
- // for 2D Transforms
- /**
- * Sets this matrix as a 2D translation transform.
- *
- * @param {number|Vector2} x - The amount to translate in the X axis or alternatively a translation vector.
- * @param {number} y - The amount to translate in the Y axis.
- * @return {Matrix3} A reference to this matrix.
- */
- 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;
- }
- /**
- * Sets this matrix as a 2D rotational transformation.
- *
- * @param {number} theta - The rotation in radians.
- * @return {Matrix3} A reference to this matrix.
- */
- makeRotation(e) {
- const t = Math.cos(e), i = Math.sin(e);
- return this.set(
- t,
- -i,
- 0,
- i,
- t,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a 2D scale transform.
- *
- * @param {number} x - The amount to scale in the X axis.
- * @param {number} y - The amount to scale in the Y axis.
- * @return {Matrix3} A reference to this matrix.
- */
- makeScale(e, t) {
- return this.set(
- e,
- 0,
- 0,
- 0,
- t,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Returns `true` if this matrix is equal with the given one.
- *
- * @param {Matrix3} matrix - The matrix to test for equality.
- * @return {boolean} Whether this matrix is equal with the given one.
- */
- equals(e) {
- const t = this.elements, i = e.elements;
- for (let s = 0; s < 9; s++)
- if (t[s] !== i[s]) return !1;
- return !0;
- }
- /**
- * Sets the elements of the matrix from the given array.
- *
- * @param {Array} array - The matrix elements in column-major order.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Matrix3} A reference to this matrix.
- */
- fromArray(e, t = 0) {
- for (let i = 0; i < 9; i++)
- this.elements[i] = e[i + t];
- return this;
- }
- /**
- * Writes the elements of this matrix to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The matrix elements in column-major order.
- */
- toArray(e = [], t = 0) {
- const i = this.elements;
- return e[t] = i[0], e[t + 1] = i[1], e[t + 2] = i[2], e[t + 3] = i[3], e[t + 4] = i[4], e[t + 5] = i[5], e[t + 6] = i[6], e[t + 7] = i[7], e[t + 8] = i[8], e;
- }
- /**
- * Returns a matrix with copied values from this instance.
- *
- * @return {Matrix3} A clone of this instance.
- */
- clone() {
- return new this.constructor().fromArray(this.elements);
- }
-}
-const Gr = /* @__PURE__ */ new ke(), Ml = /* @__PURE__ */ new ke().set(
- 0.4123908,
- 0.3575843,
- 0.1804808,
- 0.212639,
- 0.7151687,
- 0.0721923,
- 0.0193308,
- 0.1191948,
- 0.9505322
-), Sl = /* @__PURE__ */ new ke().set(
- 3.2409699,
- -1.5373832,
- -0.4986108,
- -0.9692436,
- 1.8759675,
- 0.0415551,
- 0.0556301,
- -0.203977,
- 1.0569715
-);
-function td() {
- const n = {
- enabled: !0,
- workingColorSpace: kt,
- /**
- * Implementations of supported color spaces.
- *
- * Required:
- * - primaries: chromaticity coordinates [ rx ry gx gy bx by ]
- * - whitePoint: reference white [ x y ]
- * - transfer: transfer function (pre-defined)
- * - toXYZ: Matrix3 RGB to XYZ transform
- * - fromXYZ: Matrix3 XYZ to RGB transform
- * - luminanceCoefficients: RGB luminance coefficients
- *
- * Optional:
- * - outputColorSpaceConfig: { drawingBufferColorSpace: ColorSpace, toneMappingMode: 'extended' | 'standard' }
- * - workingColorSpaceConfig: { unpackColorSpace: ColorSpace }
- *
- * Reference:
- * - https://www.russellcottrell.com/photo/matrixCalculator.htm
- */
- spaces: {},
- convert: function(s, r, a) {
- return this.enabled === !1 || r === a || !r || !a || (this.spaces[r].transfer === it && (s.r = ji(s.r), s.g = ji(s.g), s.b = ji(s.b)), this.spaces[r].primaries !== this.spaces[a].primaries && (s.applyMatrix3(this.spaces[r].toXYZ), s.applyMatrix3(this.spaces[a].fromXYZ)), this.spaces[a].transfer === it && (s.r = Hs(s.r), s.g = Hs(s.g), s.b = Hs(s.b))), s;
- },
- workingToColorSpace: function(s, r) {
- return this.convert(s, this.workingColorSpace, r);
- },
- colorSpaceToWorking: function(s, r) {
- return this.convert(s, r, this.workingColorSpace);
- },
- getPrimaries: function(s) {
- return this.spaces[s].primaries;
- },
- getTransfer: function(s) {
- return s === Qi ? wr : this.spaces[s].transfer;
- },
- getToneMappingMode: function(s) {
- return this.spaces[s].outputColorSpaceConfig.toneMappingMode || "standard";
- },
- getLuminanceCoefficients: function(s, r = this.workingColorSpace) {
- return s.fromArray(this.spaces[r].luminanceCoefficients);
- },
- define: function(s) {
- Object.assign(this.spaces, s);
- },
- // Internal APIs
- _getMatrix: function(s, r, a) {
- return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ);
- },
- _getDrawingBufferColorSpace: function(s) {
- return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace;
- },
- _getUnpackColorSpace: function(s = this.workingColorSpace) {
- return this.spaces[s].workingColorSpaceConfig.unpackColorSpace;
- },
- // Deprecated
- fromWorkingColorSpace: function(s, r) {
- return Dn("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), n.workingToColorSpace(s, r);
- },
- toWorkingColorSpace: function(s, r) {
- return Dn("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), n.colorSpaceToWorking(s, r);
- }
- }, e = [0.64, 0.33, 0.3, 0.6, 0.15, 0.06], t = [0.2126, 0.7152, 0.0722], i = [0.3127, 0.329];
- return n.define({
- [kt]: {
- primaries: e,
- whitePoint: i,
- transfer: wr,
- toXYZ: Ml,
- fromXYZ: Sl,
- luminanceCoefficients: t,
- workingColorSpaceConfig: { unpackColorSpace: Rt },
- outputColorSpaceConfig: { drawingBufferColorSpace: Rt }
- },
- [Rt]: {
- primaries: e,
- whitePoint: i,
- transfer: it,
- toXYZ: Ml,
- fromXYZ: Sl,
- luminanceCoefficients: t,
- outputColorSpaceConfig: { drawingBufferColorSpace: Rt }
- }
- }), n;
-}
-const qe = /* @__PURE__ */ td();
-function ji(n) {
- return n < 0.04045 ? n * 0.0773993808 : Math.pow(n * 0.9478672986 + 0.0521327014, 2.4);
-}
-function Hs(n) {
- return n < 31308e-7 ? n * 12.92 : 1.055 * Math.pow(n, 0.41666) - 0.055;
-}
-let Ms;
-class id {
- /**
- * Returns a data URI containing a representation of the given image.
- *
- * @param {(HTMLImageElement|HTMLCanvasElement)} image - The image object.
- * @param {string} [type='image/png'] - Indicates the image format.
- * @return {string} The data URI.
- */
- static getDataURL(e, t = "image/png") {
- if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u")
- return e.src;
- let i;
- if (e instanceof HTMLCanvasElement)
- i = e;
- else {
- Ms === void 0 && (Ms = Ln("canvas")), Ms.width = e.width, Ms.height = e.height;
- const s = Ms.getContext("2d");
- e instanceof ImageData ? s.putImageData(e, 0, 0) : s.drawImage(e, 0, 0, e.width, e.height), i = Ms;
- }
- return i.toDataURL(t);
- }
- /**
- * Converts the given sRGB image data to linear color space.
- *
- * @param {(HTMLImageElement|HTMLCanvasElement|ImageBitmap|Object)} image - The image object.
- * @return {HTMLCanvasElement|Object} The converted image.
- */
- static sRGBToLinear(e) {
- if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) {
- const t = Ln("canvas");
- t.width = e.width, t.height = e.height;
- const i = t.getContext("2d");
- i.drawImage(e, 0, 0, e.width, e.height);
- const s = i.getImageData(0, 0, e.width, e.height), r = s.data;
- for (let a = 0; a < r.length; a++)
- r[a] = ji(r[a] / 255) * 255;
- return i.putImageData(s, 0, 0), t;
- } else if (e.data) {
- const t = e.data.slice(0);
- for (let i = 0; i < t.length; i++)
- t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[i] = Math.floor(ji(t[i] / 255) * 255) : t[i] = ji(t[i]);
- return {
- data: t,
- width: e.width,
- height: e.height
- };
- } else
- return Se("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e;
- }
-}
-let sd = 0;
-class Ho {
- /**
- * Constructs a new video texture.
- *
- * @param {any} [data=null] - The data definition of a texture.
- */
- constructor(e = null) {
- this.isSource = !0, Object.defineProperty(this, "id", { value: sd++ }), this.uuid = gi(), this.data = e, this.dataReady = !0, this.version = 0;
- }
- /**
- * Returns the dimensions of the source into the given target vector.
- *
- * @param {(Vector2|Vector3)} target - The target object the result is written into.
- * @return {(Vector2|Vector3)} The dimensions of the source.
- */
- getSize(e) {
- const t = this.data;
- return typeof HTMLVideoElement < "u" && t instanceof HTMLVideoElement ? e.set(t.videoWidth, t.videoHeight, 0) : t instanceof VideoFrame ? e.set(t.displayHeight, t.displayWidth, 0) : t !== null ? e.set(t.width, t.height, t.depth || 0) : e.set(0, 0, 0), e;
- }
- /**
- * When the property is set to `true`, the engine allocates the memory
- * for the texture (if necessary) and triggers the actual texture upload
- * to the GPU next time the source is used.
- *
- * @type {boolean}
- * @default false
- * @param {boolean} value
- */
- set needsUpdate(e) {
- e === !0 && this.version++;
- }
- /**
- * Serializes the source into JSON.
- *
- * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
- * @return {Object} A JSON object representing the serialized source.
- * @see {@link ObjectLoader#parse}
- */
- toJSON(e) {
- const t = e === void 0 || typeof e == "string";
- if (!t && e.images[this.uuid] !== void 0)
- return e.images[this.uuid];
- const i = {
- uuid: this.uuid,
- url: ""
- }, s = this.data;
- if (s !== null) {
- let r;
- if (Array.isArray(s)) {
- r = [];
- for (let a = 0, o = s.length; a < o; a++)
- s[a].isDataTexture ? r.push(Wr(s[a].image)) : r.push(Wr(s[a]));
- } else
- r = Wr(s);
- i.url = r;
- }
- return t || (e.images[this.uuid] = i), i;
- }
-}
-function Wr(n) {
- return typeof HTMLImageElement < "u" && n instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && n instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && n instanceof ImageBitmap ? id.getDataURL(n) : n.data ? {
- data: Array.from(n.data),
- width: n.width,
- height: n.height,
- type: n.data.constructor.name
- } : (Se("Texture: Unable to serialize Texture."), {});
-}
-let nd = 0;
-const jr = /* @__PURE__ */ new w();
-class Pt extends xs {
- /**
- * Constructs a new texture.
- *
- * @param {?Object} [image=Texture.DEFAULT_IMAGE] - The image holding the texture data.
- * @param {number} [mapping=Texture.DEFAULT_MAPPING] - The texture mapping.
- * @param {number} [wrapS=ClampToEdgeWrapping] - The wrapS value.
- * @param {number} [wrapT=ClampToEdgeWrapping] - The wrapT value.
- * @param {number} [magFilter=LinearFilter] - The mag filter value.
- * @param {number} [minFilter=LinearMipmapLinearFilter] - The min filter value.
- * @param {number} [format=RGBAFormat] - The texture format.
- * @param {number} [type=UnsignedByteType] - The texture type.
- * @param {number} [anisotropy=Texture.DEFAULT_ANISOTROPY] - The anisotropy value.
- * @param {string} [colorSpace=NoColorSpace] - The color space.
- */
- constructor(e = Pt.DEFAULT_IMAGE, t = Pt.DEFAULT_MAPPING, i = ii, s = ii, r = Mt, a = wi, o = Jt, l = _i, c = Pt.DEFAULT_ANISOTROPY, h = Qi) {
- super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: nd++ }), this.uuid = gi(), this.name = "", this.source = new Ho(e), this.mipmaps = [], this.mapping = t, this.channel = 0, this.wrapS = i, this.wrapT = s, this.magFilter = r, this.minFilter = a, this.anisotropy = c, this.format = o, this.internalFormat = null, this.type = l, this.offset = new oe(0, 0), this.repeat = new oe(1, 1), this.center = new oe(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new ke(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = h, this.userData = {}, this.updateRanges = [], this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.isArrayTexture = !!(e && e.depth && e.depth > 1), this.pmremVersion = 0;
- }
- /**
- * The width of the texture in pixels.
- */
- get width() {
- return this.source.getSize(jr).x;
- }
- /**
- * The height of the texture in pixels.
- */
- get height() {
- return this.source.getSize(jr).y;
- }
- /**
- * The depth of the texture in pixels.
- */
- get depth() {
- return this.source.getSize(jr).z;
- }
- /**
- * The image object holding the texture data.
- *
- * @type {?Object}
- */
- get image() {
- return this.source.data;
- }
- set image(e = null) {
- this.source.data = e;
- }
- /**
- * Updates the texture transformation matrix from the from the properties {@link Texture#offset},
- * {@link Texture#repeat}, {@link Texture#rotation}, and {@link Texture#center}.
- */
- updateMatrix() {
- this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y);
- }
- /**
- * Adds a range of data in the data texture to be updated on the GPU.
- *
- * @param {number} start - Position at which to start update.
- * @param {number} count - The number of components to update.
- */
- addUpdateRange(e, t) {
- this.updateRanges.push({ start: e, count: t });
- }
- /**
- * Clears the update ranges.
- */
- clearUpdateRanges() {
- this.updateRanges.length = 0;
- }
- /**
- * Returns a new texture with copied values from this instance.
- *
- * @return {Texture} A clone of this instance.
- */
- clone() {
- return new this.constructor().copy(this);
- }
- /**
- * Copies the values of the given texture to this instance.
- *
- * @param {Texture} source - The texture to copy.
- * @return {Texture} A reference to this instance.
- */
- 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.renderTarget = e.renderTarget, this.isRenderTargetTexture = e.isRenderTargetTexture, this.isArrayTexture = e.isArrayTexture, this.userData = JSON.parse(JSON.stringify(e.userData)), this.needsUpdate = !0, this;
- }
- /**
- * Sets this texture's properties based on `values`.
- * @param {Object} values - A container with texture parameters.
- */
- setValues(e) {
- for (const t in e) {
- const i = e[t];
- if (i === void 0) {
- Se(`Texture.setValues(): parameter '${t}' has value of undefined.`);
- continue;
- }
- const s = this[t];
- if (s === void 0) {
- Se(`Texture.setValues(): property '${t}' does not exist.`);
- continue;
- }
- s && i && s.isVector2 && i.isVector2 || s && i && s.isVector3 && i.isVector3 || s && i && s.isMatrix3 && i.isMatrix3 ? s.copy(i) : this[t] = i;
- }
- }
- /**
- * Serializes the texture into JSON.
- *
- * @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
- * @return {Object} A JSON object representing the serialized texture.
- * @see {@link ObjectLoader#parse}
- */
- toJSON(e) {
- const t = e === void 0 || typeof e == "string";
- if (!t && e.textures[this.uuid] !== void 0)
- return e.textures[this.uuid];
- const i = {
- metadata: {
- version: 4.7,
- 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 && (i.userData = this.userData), t || (e.textures[this.uuid] = i), i;
- }
- /**
- * Frees the GPU-related resources allocated by this instance. Call this
- * method whenever this instance is no longer used in your app.
- *
- * @fires Texture#dispose
- */
- dispose() {
- this.dispatchEvent({ type: "dispose" });
- }
- /**
- * Transforms the given uv vector with the textures uv transformation matrix.
- *
- * @param {Vector2} uv - The uv vector.
- * @return {Vector2} The transformed uv vector.
- */
- transformUv(e) {
- if (this.mapping !== Qc) return e;
- if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1)
- switch (this.wrapS) {
- case Ri:
- e.x = e.x - Math.floor(e.x);
- break;
- case ii:
- e.x = e.x < 0 ? 0 : 1;
- break;
- case Er:
- 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 Ri:
- e.y = e.y - Math.floor(e.y);
- break;
- case ii:
- e.y = e.y < 0 ? 0 : 1;
- break;
- case Er:
- 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;
- }
- /**
- * Setting this property to `true` indicates the engine the texture
- * must be updated in the next render. This triggers a texture upload
- * to the GPU and ensures correct texture parameter configuration.
- *
- * @type {boolean}
- * @default false
- * @param {boolean} value
- */
- set needsUpdate(e) {
- e === !0 && (this.version++, this.source.needsUpdate = !0);
- }
- /**
- * Setting this property to `true` indicates the engine the PMREM
- * must be regenerated.
- *
- * @type {boolean}
- * @default false
- * @param {boolean} value
- */
- set needsPMREMUpdate(e) {
- e === !0 && this.pmremVersion++;
- }
-}
-Pt.DEFAULT_IMAGE = null;
-Pt.DEFAULT_MAPPING = Qc;
-Pt.DEFAULT_ANISOTROPY = 1;
-class Qe {
- /**
- * Constructs a new 4D vector.
- *
- * @param {number} [x=0] - The x value of this vector.
- * @param {number} [y=0] - The y value of this vector.
- * @param {number} [z=0] - The z value of this vector.
- * @param {number} [w=1] - The w value of this vector.
- */
- constructor(e = 0, t = 0, i = 0, s = 1) {
- Qe.prototype.isVector4 = !0, this.x = e, this.y = t, this.z = i, this.w = s;
- }
- /**
- * Alias for {@link Vector4#z}.
- *
- * @type {number}
- */
- get width() {
- return this.z;
- }
- set width(e) {
- this.z = e;
- }
- /**
- * Alias for {@link Vector4#w}.
- *
- * @type {number}
- */
- get height() {
- return this.w;
- }
- set height(e) {
- this.w = e;
- }
- /**
- * Sets the vector components.
- *
- * @param {number} x - The value of the x component.
- * @param {number} y - The value of the y component.
- * @param {number} z - The value of the z component.
- * @param {number} w - The value of the w component.
- * @return {Vector4} A reference to this vector.
- */
- set(e, t, i, s) {
- return this.x = e, this.y = t, this.z = i, this.w = s, this;
- }
- /**
- * Sets the vector components to the same value.
- *
- * @param {number} scalar - The value to set for all vector components.
- * @return {Vector4} A reference to this vector.
- */
- setScalar(e) {
- return this.x = e, this.y = e, this.z = e, this.w = e, this;
- }
- /**
- * Sets the vector's x component to the given value
- *
- * @param {number} x - The value to set.
- * @return {Vector4} A reference to this vector.
- */
- setX(e) {
- return this.x = e, this;
- }
- /**
- * Sets the vector's y component to the given value
- *
- * @param {number} y - The value to set.
- * @return {Vector4} A reference to this vector.
- */
- setY(e) {
- return this.y = e, this;
- }
- /**
- * Sets the vector's z component to the given value
- *
- * @param {number} z - The value to set.
- * @return {Vector4} A reference to this vector.
- */
- setZ(e) {
- return this.z = e, this;
- }
- /**
- * Sets the vector's w component to the given value
- *
- * @param {number} w - The value to set.
- * @return {Vector4} A reference to this vector.
- */
- setW(e) {
- return this.w = e, this;
- }
- /**
- * Allows to set a vector component with an index.
- *
- * @param {number} index - The component index. `0` equals to x, `1` equals to y,
- * `2` equals to z, `3` equals to w.
- * @param {number} value - The value to set.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Returns the value of the vector component which matches the given index.
- *
- * @param {number} index - The component index. `0` equals to x, `1` equals to y,
- * `2` equals to z, `3` equals to w.
- * @return {number} A vector component value.
- */
- 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);
- }
- }
- /**
- * Returns a new vector with copied values from this instance.
- *
- * @return {Vector4} A clone of this instance.
- */
- clone() {
- return new this.constructor(this.x, this.y, this.z, this.w);
- }
- /**
- * Copies the values of the given vector to this instance.
- *
- * @param {Vector3|Vector4} v - The vector to copy.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Adds the given vector to this instance.
- *
- * @param {Vector4} v - The vector to add.
- * @return {Vector4} A reference to this vector.
- */
- add(e) {
- return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this;
- }
- /**
- * Adds the given scalar value to all components of this instance.
- *
- * @param {number} s - The scalar to add.
- * @return {Vector4} A reference to this vector.
- */
- addScalar(e) {
- return this.x += e, this.y += e, this.z += e, this.w += e, this;
- }
- /**
- * Adds the given vectors and stores the result in this instance.
- *
- * @param {Vector4} a - The first vector.
- * @param {Vector4} b - The second vector.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Adds the given vector scaled by the given factor to this instance.
- *
- * @param {Vector4} v - The vector.
- * @param {number} s - The factor that scales `v`.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Subtracts the given vector from this instance.
- *
- * @param {Vector4} v - The vector to subtract.
- * @return {Vector4} A reference to this vector.
- */
- sub(e) {
- return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this;
- }
- /**
- * Subtracts the given scalar value from all components of this instance.
- *
- * @param {number} s - The scalar to subtract.
- * @return {Vector4} A reference to this vector.
- */
- subScalar(e) {
- return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this;
- }
- /**
- * Subtracts the given vectors and stores the result in this instance.
- *
- * @param {Vector4} a - The first vector.
- * @param {Vector4} b - The second vector.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Multiplies the given vector with this instance.
- *
- * @param {Vector4} v - The vector to multiply.
- * @return {Vector4} A reference to this vector.
- */
- multiply(e) {
- return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this;
- }
- /**
- * Multiplies the given scalar value with all components of this instance.
- *
- * @param {number} scalar - The scalar to multiply.
- * @return {Vector4} A reference to this vector.
- */
- multiplyScalar(e) {
- return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this;
- }
- /**
- * Multiplies this vector with the given 4x4 matrix.
- *
- * @param {Matrix4} m - The 4x4 matrix.
- * @return {Vector4} A reference to this vector.
- */
- applyMatrix4(e) {
- const t = this.x, i = this.y, s = this.z, r = this.w, a = e.elements;
- return this.x = a[0] * t + a[4] * i + a[8] * s + a[12] * r, this.y = a[1] * t + a[5] * i + a[9] * s + a[13] * r, this.z = a[2] * t + a[6] * i + a[10] * s + a[14] * r, this.w = a[3] * t + a[7] * i + a[11] * s + a[15] * r, this;
- }
- /**
- * Divides this instance by the given vector.
- *
- * @param {Vector4} v - The vector to divide.
- * @return {Vector4} A reference to this vector.
- */
- divide(e) {
- return this.x /= e.x, this.y /= e.y, this.z /= e.z, this.w /= e.w, this;
- }
- /**
- * Divides this vector by the given scalar.
- *
- * @param {number} scalar - The scalar to divide.
- * @return {Vector4} A reference to this vector.
- */
- divideScalar(e) {
- return this.multiplyScalar(1 / e);
- }
- /**
- * Sets the x, y and z components of this
- * vector to the quaternion's axis and w to the angle.
- *
- * @param {Quaternion} q - The Quaternion to set.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Sets the x, y and z components of this
- * vector to the axis of rotation and w to the angle.
- *
- * @param {Matrix4} m - A 4x4 matrix of which the upper left 3x3 matrix is a pure rotation matrix.
- * @return {Vector4} A reference to this vector.
- */
- setAxisAngleFromRotationMatrix(e) {
- let t, i, s, r;
- const a = e.elements, o = a[0], l = a[4], c = a[8], h = a[1], u = a[5], d = a[9], m = a[2], g = a[6], v = a[10];
- if (Math.abs(l - h) < 0.01 && Math.abs(c - m) < 0.01 && Math.abs(d - g) < 0.01) {
- if (Math.abs(l + h) < 0.1 && Math.abs(c + m) < 0.1 && Math.abs(d + g) < 0.1 && Math.abs(o + u + v - 3) < 0.1)
- return this.set(1, 0, 0, 0), this;
- t = Math.PI;
- const p = (o + 1) / 2, b = (u + 1) / 2, _ = (v + 1) / 2, E = (l + h) / 4, R = (c + m) / 4, T = (d + g) / 4;
- return p > b && p > _ ? p < 0.01 ? (i = 0, s = 0.707106781, r = 0.707106781) : (i = Math.sqrt(p), s = E / i, r = R / i) : b > _ ? b < 0.01 ? (i = 0.707106781, s = 0, r = 0.707106781) : (s = Math.sqrt(b), i = E / s, r = T / s) : _ < 0.01 ? (i = 0.707106781, s = 0.707106781, r = 0) : (r = Math.sqrt(_), i = R / r, s = T / r), this.set(i, s, r, t), this;
- }
- let f = Math.sqrt((g - d) * (g - d) + (c - m) * (c - m) + (h - l) * (h - l));
- return Math.abs(f) < 1e-3 && (f = 1), this.x = (g - d) / f, this.y = (c - m) / f, this.z = (h - l) / f, this.w = Math.acos((o + u + v - 1) / 2), this;
- }
- /**
- * Sets the vector components to the position elements of the
- * given transformation matrix.
- *
- * @param {Matrix4} m - The 4x4 matrix.
- * @return {Vector4} A reference to this vector.
- */
- setFromMatrixPosition(e) {
- const t = e.elements;
- return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], this;
- }
- /**
- * If this vector's x, y, z or w value is greater than the given vector's x, y, z or w
- * value, replace that value with the corresponding min value.
- *
- * @param {Vector4} v - The vector.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * If this vector's x, y, z or w value is less than the given vector's x, y, z or w
- * value, replace that value with the corresponding max value.
- *
- * @param {Vector4} v - The vector.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * If this vector's x, y, z or w value is greater than the max vector's x, y, z or w
- * value, it is replaced by the corresponding value.
- * If this vector's x, y, z or w value is less than the min vector's x, y, z or w value,
- * it is replaced by the corresponding value.
- *
- * @param {Vector4} min - The minimum x, y and z values.
- * @param {Vector4} max - The maximum x, y and z values in the desired range.
- * @return {Vector4} A reference to this vector.
- */
- clamp(e, t) {
- return this.x = ze(this.x, e.x, t.x), this.y = ze(this.y, e.y, t.y), this.z = ze(this.z, e.z, t.z), this.w = ze(this.w, e.w, t.w), this;
- }
- /**
- * If this vector's x, y, z or w values are greater than the max value, they are
- * replaced by the max value.
- * If this vector's x, y, z or w values are less than the min value, they are
- * replaced by the min value.
- *
- * @param {number} minVal - The minimum value the components will be clamped to.
- * @param {number} maxVal - The maximum value the components will be clamped to.
- * @return {Vector4} A reference to this vector.
- */
- clampScalar(e, t) {
- return this.x = ze(this.x, e, t), this.y = ze(this.y, e, t), this.z = ze(this.z, e, t), this.w = ze(this.w, e, t), this;
- }
- /**
- * If this vector's length is greater than the max value, it is replaced by
- * the max value.
- * If this vector's length is less than the min value, it is replaced by the
- * min value.
- *
- * @param {number} min - The minimum value the vector length will be clamped to.
- * @param {number} max - The maximum value the vector length will be clamped to.
- * @return {Vector4} A reference to this vector.
- */
- clampLength(e, t) {
- const i = this.length();
- return this.divideScalar(i || 1).multiplyScalar(ze(i, e, t));
- }
- /**
- * The components of this vector are rounded down to the nearest integer value.
- *
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * The components of this vector are rounded up to the nearest integer value.
- *
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * The components of this vector are rounded to the nearest integer value
- *
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * The components of this vector are rounded towards zero (up if negative,
- * down if positive) to an integer value.
- *
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Inverts this vector - i.e. sets x = -x, y = -y, z = -z, w = -w.
- *
- * @return {Vector4} A reference to this vector.
- */
- negate() {
- return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this;
- }
- /**
- * Calculates the dot product of the given vector with this instance.
- *
- * @param {Vector4} v - The vector to compute the dot product with.
- * @return {number} The result of the dot product.
- */
- dot(e) {
- return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w;
- }
- /**
- * Computes the square of the Euclidean length (straight-line length) from
- * (0, 0, 0, 0) to (x, y, z, w). If you are comparing the lengths of vectors, you should
- * compare the length squared instead as it is slightly more efficient to calculate.
- *
- * @return {number} The square length of this vector.
- */
- lengthSq() {
- return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;
- }
- /**
- * Computes the Euclidean length (straight-line length) from (0, 0, 0, 0) to (x, y, z, w).
- *
- * @return {number} The length of this vector.
- */
- length() {
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
- }
- /**
- * Computes the Manhattan length of this vector.
- *
- * @return {number} The length of this vector.
- */
- manhattanLength() {
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w);
- }
- /**
- * Converts this vector to a unit vector - that is, sets it equal to a vector
- * with the same direction as this one, but with a vector length of `1`.
- *
- * @return {Vector4} A reference to this vector.
- */
- normalize() {
- return this.divideScalar(this.length() || 1);
- }
- /**
- * Sets this vector to a vector with the same direction as this one, but
- * with the specified length.
- *
- * @param {number} length - The new length of this vector.
- * @return {Vector4} A reference to this vector.
- */
- setLength(e) {
- return this.normalize().multiplyScalar(e);
- }
- /**
- * Linearly interpolates between the given vector and this instance, where
- * alpha is the percent distance along the line - alpha = 0 will be this
- * vector, and alpha = 1 will be the given one.
- *
- * @param {Vector4} v - The vector to interpolate towards.
- * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Linearly interpolates between the given vectors, where alpha is the percent
- * distance along the line - alpha = 0 will be first vector, and alpha = 1 will
- * be the second one. The result is stored in this instance.
- *
- * @param {Vector4} v1 - The first vector.
- * @param {Vector4} v2 - The second vector.
- * @param {number} alpha - The interpolation factor, typically in the closed interval `[0, 1]`.
- * @return {Vector4} A reference to this vector.
- */
- lerpVectors(e, t, i) {
- return this.x = e.x + (t.x - e.x) * i, this.y = e.y + (t.y - e.y) * i, this.z = e.z + (t.z - e.z) * i, this.w = e.w + (t.w - e.w) * i, this;
- }
- /**
- * Returns `true` if this vector is equal with the given one.
- *
- * @param {Vector4} v - The vector to test for equality.
- * @return {boolean} Whether this vector is equal with the given one.
- */
- equals(e) {
- return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w;
- }
- /**
- * Sets this vector's x value to be `array[ offset ]`, y value to be `array[ offset + 1 ]`,
- * z value to be `array[ offset + 2 ]`, w value to be `array[ offset + 3 ]`.
- *
- * @param {Array} array - An array holding the vector component values.
- * @param {number} [offset=0] - The offset into the array.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Writes the components of this vector to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the vector components.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The vector components.
- */
- 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;
- }
- /**
- * Sets the components of this vector from the given buffer attribute.
- *
- * @param {BufferAttribute} attribute - The buffer attribute holding vector data.
- * @param {number} index - The index into the attribute.
- * @return {Vector4} A reference to this vector.
- */
- 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;
- }
- /**
- * Sets each component of this vector to a pseudo-random value between `0` and
- * `1`, excluding `1`.
- *
- * @return {Vector4} A reference to this vector.
- */
- 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 rd extends xs {
- /**
- * Render target options.
- *
- * @typedef {Object} RenderTarget~Options
- * @property {boolean} [generateMipmaps=false] - Whether to generate mipmaps or not.
- * @property {number} [magFilter=LinearFilter] - The mag filter.
- * @property {number} [minFilter=LinearFilter] - The min filter.
- * @property {number} [format=RGBAFormat] - The texture format.
- * @property {number} [type=UnsignedByteType] - The texture type.
- * @property {?string} [internalFormat=null] - The texture's internal format.
- * @property {number} [wrapS=ClampToEdgeWrapping] - The texture's uv wrapping mode.
- * @property {number} [wrapT=ClampToEdgeWrapping] - The texture's uv wrapping mode.
- * @property {number} [anisotropy=1] - The texture's anisotropy value.
- * @property {string} [colorSpace=NoColorSpace] - The texture's color space.
- * @property {boolean} [depthBuffer=true] - Whether to allocate a depth buffer or not.
- * @property {boolean} [stencilBuffer=false] - Whether to allocate a stencil buffer or not.
- * @property {boolean} [resolveDepthBuffer=true] - Whether to resolve the depth buffer or not.
- * @property {boolean} [resolveStencilBuffer=true] - Whether to resolve the stencil buffer or not.
- * @property {?Texture} [depthTexture=null] - Reference to a depth texture.
- * @property {number} [samples=0] - The MSAA samples count.
- * @property {number} [count=1] - Defines the number of color attachments . Must be at least `1`.
- * @property {number} [depth=1] - The texture depth.
- * @property {boolean} [multiview=false] - Whether this target is used for multiview rendering.
- */
- /**
- * Constructs a new render target.
- *
- * @param {number} [width=1] - The width of the render target.
- * @param {number} [height=1] - The height of the render target.
- * @param {RenderTarget~Options} [options] - The configuration object.
- */
- constructor(e = 1, t = 1, i = {}) {
- super(), i = Object.assign({
- generateMipmaps: !1,
- internalFormat: null,
- minFilter: Mt,
- depthBuffer: !0,
- stencilBuffer: !1,
- resolveDepthBuffer: !0,
- resolveStencilBuffer: !0,
- depthTexture: null,
- samples: 0,
- count: 1,
- depth: 1,
- multiview: !1
- }, i), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = i.depth, this.scissor = new Qe(0, 0, e, t), this.scissorTest = !1, this.viewport = new Qe(0, 0, e, t);
- const s = { width: e, height: t, depth: i.depth }, r = new Pt(s);
- this.textures = [];
- const a = i.count;
- for (let o = 0; o < a; o++)
- this.textures[o] = r.clone(), this.textures[o].isRenderTargetTexture = !0, this.textures[o].renderTarget = this;
- this._setTextureOptions(i), this.depthBuffer = i.depthBuffer, this.stencilBuffer = i.stencilBuffer, this.resolveDepthBuffer = i.resolveDepthBuffer, this.resolveStencilBuffer = i.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = i.depthTexture, this.samples = i.samples, this.multiview = i.multiview;
- }
- _setTextureOptions(e = {}) {
- const t = {
- minFilter: Mt,
- generateMipmaps: !1,
- flipY: !1,
- internalFormat: null
- };
- e.mapping !== void 0 && (t.mapping = e.mapping), e.wrapS !== void 0 && (t.wrapS = e.wrapS), e.wrapT !== void 0 && (t.wrapT = e.wrapT), e.wrapR !== void 0 && (t.wrapR = e.wrapR), e.magFilter !== void 0 && (t.magFilter = e.magFilter), e.minFilter !== void 0 && (t.minFilter = e.minFilter), e.format !== void 0 && (t.format = e.format), e.type !== void 0 && (t.type = e.type), e.anisotropy !== void 0 && (t.anisotropy = e.anisotropy), e.colorSpace !== void 0 && (t.colorSpace = e.colorSpace), e.flipY !== void 0 && (t.flipY = e.flipY), e.generateMipmaps !== void 0 && (t.generateMipmaps = e.generateMipmaps), e.internalFormat !== void 0 && (t.internalFormat = e.internalFormat);
- for (let i = 0; i < this.textures.length; i++)
- this.textures[i].setValues(t);
- }
- /**
- * The texture representing the default color attachment.
- *
- * @type {Texture}
- */
- get texture() {
- return this.textures[0];
- }
- set texture(e) {
- this.textures[0] = e;
- }
- set depthTexture(e) {
- this._depthTexture !== null && (this._depthTexture.renderTarget = null), e !== null && (e.renderTarget = this), this._depthTexture = e;
- }
- /**
- * Instead of saving the depth in a renderbuffer, a texture
- * can be used instead which is useful for further processing
- * e.g. in context of post-processing.
- *
- * @type {?DepthTexture}
- * @default null
- */
- get depthTexture() {
- return this._depthTexture;
- }
- /**
- * Sets the size of this render target.
- *
- * @param {number} width - The width.
- * @param {number} height - The height.
- * @param {number} [depth=1] - The depth.
- */
- setSize(e, t, i = 1) {
- if (this.width !== e || this.height !== t || this.depth !== i) {
- this.width = e, this.height = t, this.depth = i;
- for (let s = 0, r = this.textures.length; s < r; s++)
- this.textures[s].image.width = e, this.textures[s].image.height = t, this.textures[s].image.depth = i, this.textures[s].isData3DTexture !== !0 && (this.textures[s].isArrayTexture = this.textures[s].image.depth > 1);
- this.dispose();
- }
- this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t);
- }
- /**
- * Returns a new render target with copied values from this instance.
- *
- * @return {RenderTarget} A clone of this instance.
- */
- clone() {
- return new this.constructor().copy(this);
- }
- /**
- * Copies the settings of the given render target. This is a structural copy so
- * no resources are shared between render targets after the copy. That includes
- * all MRT textures and the depth texture.
- *
- * @param {RenderTarget} source - The render target to copy.
- * @return {RenderTarget} A reference to this instance.
- */
- 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 t = 0, i = e.textures.length; t < i; t++) {
- this.textures[t] = e.textures[t].clone(), this.textures[t].isRenderTargetTexture = !0, this.textures[t].renderTarget = this;
- const s = Object.assign({}, e.textures[t].image);
- this.textures[t].source = new Ho(s);
- }
- return this.depthBuffer = e.depthBuffer, this.stencilBuffer = e.stencilBuffer, this.resolveDepthBuffer = e.resolveDepthBuffer, this.resolveStencilBuffer = e.resolveStencilBuffer, e.depthTexture !== null && (this.depthTexture = e.depthTexture.clone()), this.samples = e.samples, this;
- }
- /**
- * Frees the GPU-related resources allocated by this instance. Call this
- * method whenever this instance is no longer used in your app.
- *
- * @fires RenderTarget#dispose
- */
- dispose() {
- this.dispatchEvent({ type: "dispose" });
- }
-}
-class yt extends rd {
- /**
- * Constructs a new 3D render target.
- *
- * @param {number} [width=1] - The width of the render target.
- * @param {number} [height=1] - The height of the render target.
- * @param {RenderTarget~Options} [options] - The configuration object.
- */
- constructor(e = 1, t = 1, i = {}) {
- super(e, t, i), this.isWebGLRenderTarget = !0;
- }
-}
-class uh extends Pt {
- /**
- * Constructs a new data array texture.
- *
- * @param {?TypedArray} [data=null] - The buffer data.
- * @param {number} [width=1] - The width of the texture.
- * @param {number} [height=1] - The height of the texture.
- * @param {number} [depth=1] - The depth of the texture.
- */
- constructor(e = null, t = 1, i = 1, s = 1) {
- super(null), this.isDataArrayTexture = !0, this.image = { data: e, width: t, height: i, depth: s }, this.magFilter = Nt, this.minFilter = Nt, this.wrapR = ii, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set();
- }
- /**
- * Describes that a specific layer of the texture needs to be updated.
- * Normally when {@link Texture#needsUpdate} is set to `true`, the
- * entire data texture array is sent to the GPU. Marking specific
- * layers will only transmit subsets of all mipmaps associated with a
- * specific depth in the array which is often much more performant.
- *
- * @param {number} layerIndex - The layer index that should be updated.
- */
- addLayerUpdate(e) {
- this.layerUpdates.add(e);
- }
- /**
- * Resets the layer updates registry.
- */
- clearLayerUpdates() {
- this.layerUpdates.clear();
- }
-}
-class ad extends Pt {
- /**
- * Constructs a new data array texture.
- *
- * @param {?TypedArray} [data=null] - The buffer data.
- * @param {number} [width=1] - The width of the texture.
- * @param {number} [height=1] - The height of the texture.
- * @param {number} [depth=1] - The depth of the texture.
- */
- constructor(e = null, t = 1, i = 1, s = 1) {
- super(null), this.isData3DTexture = !0, this.image = { data: e, width: t, height: i, depth: s }, this.magFilter = Nt, this.minFilter = Nt, this.wrapR = ii, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1;
- }
-}
-class Lt {
- /**
- * Constructs a new bounding box.
- *
- * @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.
- * @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.
- */
- constructor(e = new w(1 / 0, 1 / 0, 1 / 0), t = new w(-1 / 0, -1 / 0, -1 / 0)) {
- this.isBox3 = !0, this.min = e, this.max = t;
- }
- /**
- * Sets the lower and upper boundaries of this box.
- * Please note that this method only copies the values from the given objects.
- *
- * @param {Vector3} min - The lower boundary of the box.
- * @param {Vector3} max - The upper boundary of the box.
- * @return {Box3} A reference to this bounding box.
- */
- set(e, t) {
- return this.min.copy(e), this.max.copy(t), this;
- }
- /**
- * Sets the upper and lower bounds of this box so it encloses the position data
- * in the given array.
- *
- * @param {Array} array - An array holding 3D position data.
- * @return {Box3} A reference to this bounding box.
- */
- setFromArray(e) {
- this.makeEmpty();
- for (let t = 0, i = e.length; t < i; t += 3)
- this.expandByPoint(li.fromArray(e, t));
- return this;
- }
- /**
- * Sets the upper and lower bounds of this box so it encloses the position data
- * in the given buffer attribute.
- *
- * @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.
- * @return {Box3} A reference to this bounding box.
- */
- setFromBufferAttribute(e) {
- this.makeEmpty();
- for (let t = 0, i = e.count; t < i; t++)
- this.expandByPoint(li.fromBufferAttribute(e, t));
- return this;
- }
- /**
- * Sets the upper and lower bounds of this box so it encloses the position data
- * in the given array.
- *
- * @param {Array} points - An array holding 3D position data as instances of {@link Vector3}.
- * @return {Box3} A reference to this bounding box.
- */
- setFromPoints(e) {
- this.makeEmpty();
- for (let t = 0, i = e.length; t < i; t++)
- this.expandByPoint(e[t]);
- return this;
- }
- /**
- * Centers this box on the given center vector and sets this box's width, height and
- * depth to the given size values.
- *
- * @param {Vector3} center - The center of the box.
- * @param {Vector3} size - The x, y and z dimensions of the box.
- * @return {Box3} A reference to this bounding box.
- */
- setFromCenterAndSize(e, t) {
- const i = li.copy(t).multiplyScalar(0.5);
- return this.min.copy(e).sub(i), this.max.copy(e).add(i), this;
- }
- /**
- * Computes the world-axis-aligned bounding box for the given 3D object
- * (including its children), accounting for the object's, and children's,
- * world transforms. The function may result in a larger box than strictly necessary.
- *
- * @param {Object3D} object - The 3D object to compute the bounding box for.
- * @param {boolean} [precise=false] - If set to `true`, the method computes the smallest
- * world-axis-aligned bounding box at the expense of more computation.
- * @return {Box3} A reference to this bounding box.
- */
- setFromObject(e, t = !1) {
- return this.makeEmpty(), this.expandByObject(e, t);
- }
- /**
- * Returns a new box with copied values from this instance.
- *
- * @return {Box3} A clone of this instance.
- */
- clone() {
- return new this.constructor().copy(this);
- }
- /**
- * Copies the values of the given box to this instance.
- *
- * @param {Box3} box - The box to copy.
- * @return {Box3} A reference to this bounding box.
- */
- copy(e) {
- return this.min.copy(e.min), this.max.copy(e.max), this;
- }
- /**
- * Makes this box empty which means in encloses a zero space in 3D.
- *
- * @return {Box3} A reference to this bounding box.
- */
- makeEmpty() {
- return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;
- }
- /**
- * Returns true if this box includes zero points within its bounds.
- * Note that a box with equal lower and upper bounds still includes one
- * point, the one both bounds share.
- *
- * @return {boolean} Whether this box is empty or not.
- */
- isEmpty() {
- return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
- }
- /**
- * Returns the center point of this box.
- *
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} The center point.
- */
- getCenter(e) {
- return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(0.5);
- }
- /**
- * Returns the dimensions of this box.
- *
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} The size.
- */
- getSize(e) {
- return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min);
- }
- /**
- * Expands the boundaries of this box to include the given point.
- *
- * @param {Vector3} point - The point that should be included by the bounding box.
- * @return {Box3} A reference to this bounding box.
- */
- expandByPoint(e) {
- return this.min.min(e), this.max.max(e), this;
- }
- /**
- * Expands this box equilaterally by the given vector. The width of this
- * box will be expanded by the x component of the vector in both
- * directions. The height of this box will be expanded by the y component of
- * the vector in both directions. The depth of this box will be
- * expanded by the z component of the vector in both directions.
- *
- * @param {Vector3} vector - The vector that should expand the bounding box.
- * @return {Box3} A reference to this bounding box.
- */
- expandByVector(e) {
- return this.min.sub(e), this.max.add(e), this;
- }
- /**
- * Expands each dimension of the box by the given scalar. If negative, the
- * dimensions of the box will be contracted.
- *
- * @param {number} scalar - The scalar value that should expand the bounding box.
- * @return {Box3} A reference to this bounding box.
- */
- expandByScalar(e) {
- return this.min.addScalar(-e), this.max.addScalar(e), this;
- }
- /**
- * Expands the boundaries of this box to include the given 3D object and
- * its children, accounting for the object's, and children's, world
- * transforms. The function may result in a larger box than strictly
- * necessary (unless the precise parameter is set to true).
- *
- * @param {Object3D} object - The 3D object that should expand the bounding box.
- * @param {boolean} precise - If set to `true`, the method expands the bounding box
- * as little as necessary at the expense of more computation.
- * @return {Box3} A reference to this bounding box.
- */
- expandByObject(e, t = !1) {
- e.updateWorldMatrix(!1, !1);
- const i = e.geometry;
- if (i !== void 0) {
- const r = i.getAttribute("position");
- if (t === !0 && r !== void 0 && e.isInstancedMesh !== !0)
- for (let a = 0, o = r.count; a < o; a++)
- e.isMesh === !0 ? e.getVertexPosition(a, li) : li.fromBufferAttribute(r, a), li.applyMatrix4(e.matrixWorld), this.expandByPoint(li);
- else
- e.boundingBox !== void 0 ? (e.boundingBox === null && e.computeBoundingBox(), Fn.copy(e.boundingBox)) : (i.boundingBox === null && i.computeBoundingBox(), Fn.copy(i.boundingBox)), Fn.applyMatrix4(e.matrixWorld), this.union(Fn);
- }
- const s = e.children;
- for (let r = 0, a = s.length; r < a; r++)
- this.expandByObject(s[r], t);
- return this;
- }
- /**
- * Returns `true` if the given point lies within or on the boundaries of this box.
- *
- * @param {Vector3} point - The point to test.
- * @return {boolean} Whether the bounding box contains the given point or not.
- */
- containsPoint(e) {
- return e.x >= this.min.x && e.x <= this.max.x && e.y >= this.min.y && e.y <= this.max.y && e.z >= this.min.z && e.z <= this.max.z;
- }
- /**
- * Returns `true` if this bounding box includes the entirety of the given bounding box.
- * If this box and the given one are identical, this function also returns `true`.
- *
- * @param {Box3} box - The bounding box to test.
- * @return {boolean} Whether the bounding box contains the given bounding box or not.
- */
- containsBox(e) {
- return this.min.x <= e.min.x && e.max.x <= this.max.x && this.min.y <= e.min.y && e.max.y <= this.max.y && this.min.z <= e.min.z && e.max.z <= this.max.z;
- }
- /**
- * Returns a point as a proportion of this box's width, height and depth.
- *
- * @param {Vector3} point - A point in 3D space.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} A point as a proportion of this box's width, height and depth.
- */
- getParameter(e, t) {
- return t.set(
- (e.x - this.min.x) / (this.max.x - this.min.x),
- (e.y - this.min.y) / (this.max.y - this.min.y),
- (e.z - this.min.z) / (this.max.z - this.min.z)
- );
- }
- /**
- * Returns `true` if the given bounding box intersects with this bounding box.
- *
- * @param {Box3} box - The bounding box to test.
- * @return {boolean} Whether the given bounding box intersects with this bounding box.
- */
- intersectsBox(e) {
- return e.max.x >= this.min.x && e.min.x <= this.max.x && e.max.y >= this.min.y && e.min.y <= this.max.y && e.max.z >= this.min.z && e.min.z <= this.max.z;
- }
- /**
- * Returns `true` if the given bounding sphere intersects with this bounding box.
- *
- * @param {Sphere} sphere - The bounding sphere to test.
- * @return {boolean} Whether the given bounding sphere intersects with this bounding box.
- */
- intersectsSphere(e) {
- return this.clampPoint(e.center, li), li.distanceToSquared(e.center) <= e.radius * e.radius;
- }
- /**
- * Returns `true` if the given plane intersects with this bounding box.
- *
- * @param {Plane} plane - The plane to test.
- * @return {boolean} Whether the given plane intersects with this bounding box.
- */
- intersectsPlane(e) {
- let t, i;
- return e.normal.x > 0 ? (t = e.normal.x * this.min.x, i = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, i = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, i += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, i += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, i += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, i += e.normal.z * this.min.z), t <= -e.constant && i >= -e.constant;
- }
- /**
- * Returns `true` if the given triangle intersects with this bounding box.
- *
- * @param {Triangle} triangle - The triangle to test.
- * @return {boolean} Whether the given triangle intersects with this bounding box.
- */
- intersectsTriangle(e) {
- if (this.isEmpty())
- return !1;
- this.getCenter(cn), zn.subVectors(this.max, cn), Ss.subVectors(e.a, cn), Ts.subVectors(e.b, cn), Es.subVectors(e.c, cn), Xi.subVectors(Ts, Ss), qi.subVectors(Es, Ts), ls.subVectors(Ss, Es);
- let t = [
- 0,
- -Xi.z,
- Xi.y,
- 0,
- -qi.z,
- qi.y,
- 0,
- -ls.z,
- ls.y,
- Xi.z,
- 0,
- -Xi.x,
- qi.z,
- 0,
- -qi.x,
- ls.z,
- 0,
- -ls.x,
- -Xi.y,
- Xi.x,
- 0,
- -qi.y,
- qi.x,
- 0,
- -ls.y,
- ls.x,
- 0
- ];
- return !Xr(t, Ss, Ts, Es, zn) || (t = [1, 0, 0, 0, 1, 0, 0, 0, 1], !Xr(t, Ss, Ts, Es, zn)) ? !1 : (Hn.crossVectors(Xi, qi), t = [Hn.x, Hn.y, Hn.z], Xr(t, Ss, Ts, Es, zn));
- }
- /**
- * Clamps the given point within the bounds of this box.
- *
- * @param {Vector3} point - The point to clamp.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} The clamped point.
- */
- clampPoint(e, t) {
- return t.copy(e).clamp(this.min, this.max);
- }
- /**
- * Returns the euclidean distance from any edge of this box to the specified point. If
- * the given point lies inside of this box, the distance will be `0`.
- *
- * @param {Vector3} point - The point to compute the distance to.
- * @return {number} The euclidean distance.
- */
- distanceToPoint(e) {
- return this.clampPoint(e, li).distanceTo(e);
- }
- /**
- * Returns a bounding sphere that encloses this bounding box.
- *
- * @param {Sphere} target - The target sphere that is used to store the method's result.
- * @return {Sphere} The bounding sphere that encloses this bounding box.
- */
- getBoundingSphere(e) {
- return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(li).length() * 0.5), e;
- }
- /**
- * Computes the intersection of this bounding box and the given one, setting the upper
- * bound of this box to the lesser of the two boxes' upper bounds and the
- * lower bound of this box to the greater of the two boxes' lower bounds. If
- * there's no overlap, makes this box empty.
- *
- * @param {Box3} box - The bounding box to intersect with.
- * @return {Box3} A reference to this bounding box.
- */
- intersect(e) {
- return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this;
- }
- /**
- * Computes the union of this box and another and the given one, setting the upper
- * bound of this box to the greater of the two boxes' upper bounds and the
- * lower bound of this box to the lesser of the two boxes' lower bounds.
- *
- * @param {Box3} box - The bounding box that will be unioned with this instance.
- * @return {Box3} A reference to this bounding box.
- */
- union(e) {
- return this.min.min(e.min), this.max.max(e.max), this;
- }
- /**
- * Transforms this bounding box by the given 4x4 transformation matrix.
- *
- * @param {Matrix4} matrix - The transformation matrix.
- * @return {Box3} A reference to this bounding box.
- */
- applyMatrix4(e) {
- return this.isEmpty() ? this : (Ui[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), Ui[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), Ui[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), Ui[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), Ui[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), Ui[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), Ui[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), Ui[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(Ui), this);
- }
- /**
- * Adds the given offset to both the upper and lower bounds of this bounding box,
- * effectively moving it in 3D space.
- *
- * @param {Vector3} offset - The offset that should be used to translate the bounding box.
- * @return {Box3} A reference to this bounding box.
- */
- translate(e) {
- return this.min.add(e), this.max.add(e), this;
- }
- /**
- * Returns `true` if this bounding box is equal with the given one.
- *
- * @param {Box3} box - The box to test for equality.
- * @return {boolean} Whether this bounding box is equal with the given one.
- */
- equals(e) {
- return e.min.equals(this.min) && e.max.equals(this.max);
- }
- /**
- * Returns a serialized structure of the bounding box.
- *
- * @return {Object} Serialized structure with fields representing the object state.
- */
- toJSON() {
- return {
- min: this.min.toArray(),
- max: this.max.toArray()
- };
- }
- /**
- * Returns a serialized structure of the bounding box.
- *
- * @param {Object} json - The serialized json to set the box from.
- * @return {Box3} A reference to this bounding box.
- */
- fromJSON(e) {
- return this.min.fromArray(e.min), this.max.fromArray(e.max), this;
- }
-}
-const Ui = [
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w(),
- /* @__PURE__ */ new w()
-], li = /* @__PURE__ */ new w(), Fn = /* @__PURE__ */ new Lt(), Ss = /* @__PURE__ */ new w(), Ts = /* @__PURE__ */ new w(), Es = /* @__PURE__ */ new w(), Xi = /* @__PURE__ */ new w(), qi = /* @__PURE__ */ new w(), ls = /* @__PURE__ */ new w(), cn = /* @__PURE__ */ new w(), zn = /* @__PURE__ */ new w(), Hn = /* @__PURE__ */ new w(), cs = /* @__PURE__ */ new w();
-function Xr(n, e, t, i, s) {
- for (let r = 0, a = n.length - 3; r <= a; r += 3) {
- cs.fromArray(n, r);
- const o = s.x * Math.abs(cs.x) + s.y * Math.abs(cs.y) + s.z * Math.abs(cs.z), l = e.dot(cs), c = t.dot(cs), h = i.dot(cs);
- if (Math.max(-Math.max(l, c, h), Math.min(l, c, h)) > o)
- return !1;
- }
- return !0;
-}
-const od = /* @__PURE__ */ new Lt(), hn = /* @__PURE__ */ new w(), qr = /* @__PURE__ */ new w();
-class Li {
- /**
- * Constructs a new sphere.
- *
- * @param {Vector3} [center=(0,0,0)] - The center of the sphere
- * @param {number} [radius=-1] - The radius of the sphere.
- */
- constructor(e = new w(), t = -1) {
- this.isSphere = !0, this.center = e, this.radius = t;
- }
- /**
- * Sets the sphere's components by copying the given values.
- *
- * @param {Vector3} center - The center.
- * @param {number} radius - The radius.
- * @return {Sphere} A reference to this sphere.
- */
- set(e, t) {
- return this.center.copy(e), this.radius = t, this;
- }
- /**
- * Computes the minimum bounding sphere for list of points.
- * If the optional center point is given, it is used as the sphere's
- * center. Otherwise, the center of the axis-aligned bounding box
- * encompassing the points is calculated.
- *
- * @param {Array} points - A list of points in 3D space.
- * @param {Vector3} [optionalCenter] - The center of the sphere.
- * @return {Sphere} A reference to this sphere.
- */
- setFromPoints(e, t) {
- const i = this.center;
- t !== void 0 ? i.copy(t) : od.setFromPoints(e).getCenter(i);
- let s = 0;
- for (let r = 0, a = e.length; r < a; r++)
- s = Math.max(s, i.distanceToSquared(e[r]));
- return this.radius = Math.sqrt(s), this;
- }
- /**
- * Copies the values of the given sphere to this instance.
- *
- * @param {Sphere} sphere - The sphere to copy.
- * @return {Sphere} A reference to this sphere.
- */
- copy(e) {
- return this.center.copy(e.center), this.radius = e.radius, this;
- }
- /**
- * Returns `true` if the sphere is empty (the radius set to a negative number).
- *
- * Spheres with a radius of `0` contain only their center point and are not
- * considered to be empty.
- *
- * @return {boolean} Whether this sphere is empty or not.
- */
- isEmpty() {
- return this.radius < 0;
- }
- /**
- * Makes this sphere empty which means in encloses a zero space in 3D.
- *
- * @return {Sphere} A reference to this sphere.
- */
- makeEmpty() {
- return this.center.set(0, 0, 0), this.radius = -1, this;
- }
- /**
- * Returns `true` if this sphere contains the given point inclusive of
- * the surface of the sphere.
- *
- * @param {Vector3} point - The point to check.
- * @return {boolean} Whether this sphere contains the given point or not.
- */
- containsPoint(e) {
- return e.distanceToSquared(this.center) <= this.radius * this.radius;
- }
- /**
- * Returns the closest distance from the boundary of the sphere to the
- * given point. If the sphere contains the point, the distance will
- * be negative.
- *
- * @param {Vector3} point - The point to compute the distance to.
- * @return {number} The distance to the point.
- */
- distanceToPoint(e) {
- return e.distanceTo(this.center) - this.radius;
- }
- /**
- * Returns `true` if this sphere intersects with the given one.
- *
- * @param {Sphere} sphere - The sphere to test.
- * @return {boolean} Whether this sphere intersects with the given one or not.
- */
- intersectsSphere(e) {
- const t = this.radius + e.radius;
- return e.center.distanceToSquared(this.center) <= t * t;
- }
- /**
- * Returns `true` if this sphere intersects with the given box.
- *
- * @param {Box3} box - The box to test.
- * @return {boolean} Whether this sphere intersects with the given box or not.
- */
- intersectsBox(e) {
- return e.intersectsSphere(this);
- }
- /**
- * Returns `true` if this sphere intersects with the given plane.
- *
- * @param {Plane} plane - The plane to test.
- * @return {boolean} Whether this sphere intersects with the given plane or not.
- */
- intersectsPlane(e) {
- return Math.abs(e.distanceToPoint(this.center)) <= this.radius;
- }
- /**
- * Clamps a point within the sphere. If the point is outside the sphere, it
- * will clamp it to the closest point on the edge of the sphere. Points
- * already inside the sphere will not be affected.
- *
- * @param {Vector3} point - The plane to clamp.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} The clamped point.
- */
- clampPoint(e, t) {
- const i = this.center.distanceToSquared(e);
- return t.copy(e), i > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t;
- }
- /**
- * Returns a bounding box that encloses this sphere.
- *
- * @param {Box3} target - The target box that is used to store the method's result.
- * @return {Box3} The bounding box that encloses this sphere.
- */
- getBoundingBox(e) {
- return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e);
- }
- /**
- * Transforms this sphere with the given 4x4 transformation matrix.
- *
- * @param {Matrix4} matrix - The transformation matrix.
- * @return {Sphere} A reference to this sphere.
- */
- applyMatrix4(e) {
- return this.center.applyMatrix4(e), this.radius = this.radius * e.getMaxScaleOnAxis(), this;
- }
- /**
- * Translates the sphere's center by the given offset.
- *
- * @param {Vector3} offset - The offset.
- * @return {Sphere} A reference to this sphere.
- */
- translate(e) {
- return this.center.add(e), this;
- }
- /**
- * Expands the boundaries of this sphere to include the given point.
- *
- * @param {Vector3} point - The point to include.
- * @return {Sphere} A reference to this sphere.
- */
- expandByPoint(e) {
- if (this.isEmpty())
- return this.center.copy(e), this.radius = 0, this;
- hn.subVectors(e, this.center);
- const t = hn.lengthSq();
- if (t > this.radius * this.radius) {
- const i = Math.sqrt(t), s = (i - this.radius) * 0.5;
- this.center.addScaledVector(hn, s / i), this.radius += s;
- }
- return this;
- }
- /**
- * Expands this sphere to enclose both the original sphere and the given sphere.
- *
- * @param {Sphere} sphere - The sphere to include.
- * @return {Sphere} A reference to this sphere.
- */
- union(e) {
- return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : (qr.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(hn.copy(e.center).add(qr)), this.expandByPoint(hn.copy(e.center).sub(qr))), this);
- }
- /**
- * Returns `true` if this sphere is equal with the given one.
- *
- * @param {Sphere} sphere - The sphere to test for equality.
- * @return {boolean} Whether this bounding sphere is equal with the given one.
- */
- equals(e) {
- return e.center.equals(this.center) && e.radius === this.radius;
- }
- /**
- * Returns a new sphere with copied values from this instance.
- *
- * @return {Sphere} A clone of this instance.
- */
- clone() {
- return new this.constructor().copy(this);
- }
- /**
- * Returns a serialized structure of the bounding sphere.
- *
- * @return {Object} Serialized structure with fields representing the object state.
- */
- toJSON() {
- return {
- radius: this.radius,
- center: this.center.toArray()
- };
- }
- /**
- * Returns a serialized structure of the bounding sphere.
- *
- * @param {Object} json - The serialized json to set the sphere from.
- * @return {Box3} A reference to this bounding sphere.
- */
- fromJSON(e) {
- return this.radius = e.radius, this.center.fromArray(e.center), this;
- }
-}
-const Ni = /* @__PURE__ */ new w(), Yr = /* @__PURE__ */ new w(), Vn = /* @__PURE__ */ new w(), Yi = /* @__PURE__ */ new w(), Kr = /* @__PURE__ */ new w(), Gn = /* @__PURE__ */ new w(), Zr = /* @__PURE__ */ new w();
-class sn {
- /**
- * Constructs a new ray.
- *
- * @param {Vector3} [origin=(0,0,0)] - The origin of the ray.
- * @param {Vector3} [direction=(0,0,-1)] - The (normalized) direction of the ray.
- */
- constructor(e = new w(), t = new w(0, 0, -1)) {
- this.origin = e, this.direction = t;
- }
- /**
- * Sets the ray's components by copying the given values.
- *
- * @param {Vector3} origin - The origin.
- * @param {Vector3} direction - The direction.
- * @return {Ray} A reference to this ray.
- */
- set(e, t) {
- return this.origin.copy(e), this.direction.copy(t), this;
- }
- /**
- * Copies the values of the given ray to this instance.
- *
- * @param {Ray} ray - The ray to copy.
- * @return {Ray} A reference to this ray.
- */
- copy(e) {
- return this.origin.copy(e.origin), this.direction.copy(e.direction), this;
- }
- /**
- * Returns a vector that is located at a given distance along this ray.
- *
- * @param {number} t - The distance along the ray to retrieve a position for.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} A position on the ray.
- */
- at(e, t) {
- return t.copy(this.origin).addScaledVector(this.direction, e);
- }
- /**
- * Adjusts the direction of the ray to point at the given vector in world space.
- *
- * @param {Vector3} v - The target position.
- * @return {Ray} A reference to this ray.
- */
- lookAt(e) {
- return this.direction.copy(e).sub(this.origin).normalize(), this;
- }
- /**
- * Shift the origin of this ray along its direction by the given distance.
- *
- * @param {number} t - The distance along the ray to interpolate.
- * @return {Ray} A reference to this ray.
- */
- recast(e) {
- return this.origin.copy(this.at(e, Ni)), this;
- }
- /**
- * Returns the point along this ray that is closest to the given point.
- *
- * @param {Vector3} point - A point in 3D space to get the closet location on the ray for.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {Vector3} The closest point on this ray.
- */
- closestPointToPoint(e, t) {
- t.subVectors(e, this.origin);
- const i = t.dot(this.direction);
- return i < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, i);
- }
- /**
- * Returns the distance of the closest approach between this ray and the given point.
- *
- * @param {Vector3} point - A point in 3D space to compute the distance to.
- * @return {number} The distance.
- */
- distanceToPoint(e) {
- return Math.sqrt(this.distanceSqToPoint(e));
- }
- /**
- * Returns the squared distance of the closest approach between this ray and the given point.
- *
- * @param {Vector3} point - A point in 3D space to compute the distance to.
- * @return {number} The squared distance.
- */
- distanceSqToPoint(e) {
- const t = Ni.subVectors(e, this.origin).dot(this.direction);
- return t < 0 ? this.origin.distanceToSquared(e) : (Ni.copy(this.origin).addScaledVector(this.direction, t), Ni.distanceToSquared(e));
- }
- /**
- * Returns the squared distance between this ray and the given line segment.
- *
- * @param {Vector3} v0 - The start point of the line segment.
- * @param {Vector3} v1 - The end point of the line segment.
- * @param {Vector3} [optionalPointOnRay] - When provided, it receives the point on this ray that is closest to the segment.
- * @param {Vector3} [optionalPointOnSegment] - When provided, it receives the point on the line segment that is closest to this ray.
- * @return {number} The squared distance.
- */
- distanceSqToSegment(e, t, i, s) {
- Yr.copy(e).add(t).multiplyScalar(0.5), Vn.copy(t).sub(e).normalize(), Yi.copy(this.origin).sub(Yr);
- const r = e.distanceTo(t) * 0.5, a = -this.direction.dot(Vn), o = Yi.dot(this.direction), l = -Yi.dot(Vn), c = Yi.lengthSq(), h = Math.abs(1 - a * a);
- let u, d, m, g;
- if (h > 0)
- if (u = a * l - o, d = a * o - l, g = r * h, u >= 0)
- if (d >= -g)
- if (d <= g) {
- const v = 1 / h;
- u *= v, d *= v, m = u * (u + a * d + 2 * o) + d * (a * u + d + 2 * l) + c;
- } else
- d = r, u = Math.max(0, -(a * d + o)), m = -u * u + d * (d + 2 * l) + c;
- else
- d = -r, u = Math.max(0, -(a * d + o)), m = -u * u + d * (d + 2 * l) + c;
- else
- d <= -g ? (u = Math.max(0, -(-a * r + o)), d = u > 0 ? -r : Math.min(Math.max(-r, -l), r), m = -u * u + d * (d + 2 * l) + c) : d <= g ? (u = 0, d = Math.min(Math.max(-r, -l), r), m = d * (d + 2 * l) + c) : (u = Math.max(0, -(a * r + o)), d = u > 0 ? r : Math.min(Math.max(-r, -l), r), m = -u * u + d * (d + 2 * l) + c);
- else
- d = a > 0 ? -r : r, u = Math.max(0, -(a * d + o)), m = -u * u + d * (d + 2 * l) + c;
- return i && i.copy(this.origin).addScaledVector(this.direction, u), s && s.copy(Yr).addScaledVector(Vn, d), m;
- }
- /**
- * Intersects this ray with the given sphere, returning the intersection
- * point or `null` if there is no intersection.
- *
- * @param {Sphere} sphere - The sphere to intersect.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {?Vector3} The intersection point.
- */
- intersectSphere(e, t) {
- Ni.subVectors(e.center, this.origin);
- const i = Ni.dot(this.direction), s = Ni.dot(Ni) - i * i, r = e.radius * e.radius;
- if (s > r) return null;
- const a = Math.sqrt(r - s), o = i - a, l = i + a;
- return l < 0 ? null : o < 0 ? this.at(l, t) : this.at(o, t);
- }
- /**
- * Returns `true` if this ray intersects with the given sphere.
- *
- * @param {Sphere} sphere - The sphere to intersect.
- * @return {boolean} Whether this ray intersects with the given sphere or not.
- */
- intersectsSphere(e) {
- return e.radius < 0 ? !1 : this.distanceSqToPoint(e.center) <= e.radius * e.radius;
- }
- /**
- * Computes the distance from the ray's origin to the given plane. Returns `null` if the ray
- * does not intersect with the plane.
- *
- * @param {Plane} plane - The plane to compute the distance to.
- * @return {?number} Whether this ray intersects with the given sphere or not.
- */
- distanceToPlane(e) {
- const t = e.normal.dot(this.direction);
- if (t === 0)
- return e.distanceToPoint(this.origin) === 0 ? 0 : null;
- const i = -(this.origin.dot(e.normal) + e.constant) / t;
- return i >= 0 ? i : null;
- }
- /**
- * Intersects this ray with the given plane, returning the intersection
- * point or `null` if there is no intersection.
- *
- * @param {Plane} plane - The plane to intersect.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {?Vector3} The intersection point.
- */
- intersectPlane(e, t) {
- const i = this.distanceToPlane(e);
- return i === null ? null : this.at(i, t);
- }
- /**
- * Returns `true` if this ray intersects with the given plane.
- *
- * @param {Plane} plane - The plane to intersect.
- * @return {boolean} Whether this ray intersects with the given plane or not.
- */
- intersectsPlane(e) {
- const t = e.distanceToPoint(this.origin);
- return t === 0 || e.normal.dot(this.direction) * t < 0;
- }
- /**
- * Intersects this ray with the given bounding box, returning the intersection
- * point or `null` if there is no intersection.
- *
- * @param {Box3} box - The box to intersect.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {?Vector3} The intersection point.
- */
- intersectBox(e, t) {
- let i, s, r, a, o, l;
- const c = 1 / this.direction.x, h = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin;
- return c >= 0 ? (i = (e.min.x - d.x) * c, s = (e.max.x - d.x) * c) : (i = (e.max.x - d.x) * c, s = (e.min.x - d.x) * c), h >= 0 ? (r = (e.min.y - d.y) * h, a = (e.max.y - d.y) * h) : (r = (e.max.y - d.y) * h, a = (e.min.y - d.y) * h), i > a || r > s || ((r > i || isNaN(i)) && (i = r), (a < s || isNaN(s)) && (s = a), u >= 0 ? (o = (e.min.z - d.z) * u, l = (e.max.z - d.z) * u) : (o = (e.max.z - d.z) * u, l = (e.min.z - d.z) * u), i > l || o > s) || ((o > i || i !== i) && (i = o), (l < s || s !== s) && (s = l), s < 0) ? null : this.at(i >= 0 ? i : s, t);
- }
- /**
- * Returns `true` if this ray intersects with the given box.
- *
- * @param {Box3} box - The box to intersect.
- * @return {boolean} Whether this ray intersects with the given box or not.
- */
- intersectsBox(e) {
- return this.intersectBox(e, Ni) !== null;
- }
- /**
- * Intersects this ray with the given triangle, returning the intersection
- * point or `null` if there is no intersection.
- *
- * @param {Vector3} a - The first vertex of the triangle.
- * @param {Vector3} b - The second vertex of the triangle.
- * @param {Vector3} c - The third vertex of the triangle.
- * @param {boolean} backfaceCulling - Whether to use backface culling or not.
- * @param {Vector3} target - The target vector that is used to store the method's result.
- * @return {?Vector3} The intersection point.
- */
- intersectTriangle(e, t, i, s, r) {
- Kr.subVectors(t, e), Gn.subVectors(i, e), Zr.crossVectors(Kr, Gn);
- let a = this.direction.dot(Zr), o;
- if (a > 0) {
- if (s) return null;
- o = 1;
- } else if (a < 0)
- o = -1, a = -a;
- else
- return null;
- Yi.subVectors(this.origin, e);
- const l = o * this.direction.dot(Gn.crossVectors(Yi, Gn));
- if (l < 0)
- return null;
- const c = o * this.direction.dot(Kr.cross(Yi));
- if (c < 0 || l + c > a)
- return null;
- const h = -o * Yi.dot(Zr);
- return h < 0 ? null : this.at(h / a, r);
- }
- /**
- * Transforms this ray with the given 4x4 transformation matrix.
- *
- * @param {Matrix4} matrix4 - The transformation matrix.
- * @return {Ray} A reference to this ray.
- */
- applyMatrix4(e) {
- return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this;
- }
- /**
- * Returns `true` if this ray is equal with the given one.
- *
- * @param {Ray} ray - The ray to test for equality.
- * @return {boolean} Whether this ray is equal with the given one.
- */
- equals(e) {
- return e.origin.equals(this.origin) && e.direction.equals(this.direction);
- }
- /**
- * Returns a new ray with copied values from this instance.
- *
- * @return {Ray} A clone of this instance.
- */
- clone() {
- return new this.constructor().copy(this);
- }
-}
-class Ne {
- /**
- * Constructs a new 4x4 matrix. The arguments are supposed to be
- * in row-major order. If no arguments are provided, the constructor
- * initializes the matrix as an identity matrix.
- *
- * @param {number} [n11] - 1-1 matrix element.
- * @param {number} [n12] - 1-2 matrix element.
- * @param {number} [n13] - 1-3 matrix element.
- * @param {number} [n14] - 1-4 matrix element.
- * @param {number} [n21] - 2-1 matrix element.
- * @param {number} [n22] - 2-2 matrix element.
- * @param {number} [n23] - 2-3 matrix element.
- * @param {number} [n24] - 2-4 matrix element.
- * @param {number} [n31] - 3-1 matrix element.
- * @param {number} [n32] - 3-2 matrix element.
- * @param {number} [n33] - 3-3 matrix element.
- * @param {number} [n34] - 3-4 matrix element.
- * @param {number} [n41] - 4-1 matrix element.
- * @param {number} [n42] - 4-2 matrix element.
- * @param {number} [n43] - 4-3 matrix element.
- * @param {number} [n44] - 4-4 matrix element.
- */
- constructor(e, t, i, s, r, a, o, l, c, h, u, d, m, g, v, f) {
- Ne.prototype.isMatrix4 = !0, this.elements = [
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ], e !== void 0 && this.set(e, t, i, s, r, a, o, l, c, h, u, d, m, g, v, f);
- }
- /**
- * Sets the elements of the matrix.The arguments are supposed to be
- * in row-major order.
- *
- * @param {number} [n11] - 1-1 matrix element.
- * @param {number} [n12] - 1-2 matrix element.
- * @param {number} [n13] - 1-3 matrix element.
- * @param {number} [n14] - 1-4 matrix element.
- * @param {number} [n21] - 2-1 matrix element.
- * @param {number} [n22] - 2-2 matrix element.
- * @param {number} [n23] - 2-3 matrix element.
- * @param {number} [n24] - 2-4 matrix element.
- * @param {number} [n31] - 3-1 matrix element.
- * @param {number} [n32] - 3-2 matrix element.
- * @param {number} [n33] - 3-3 matrix element.
- * @param {number} [n34] - 3-4 matrix element.
- * @param {number} [n41] - 4-1 matrix element.
- * @param {number} [n42] - 4-2 matrix element.
- * @param {number} [n43] - 4-3 matrix element.
- * @param {number} [n44] - 4-4 matrix element.
- * @return {Matrix4} A reference to this matrix.
- */
- set(e, t, i, s, r, a, o, l, c, h, u, d, m, g, v, f) {
- const p = this.elements;
- return p[0] = e, p[4] = t, p[8] = i, p[12] = s, p[1] = r, p[5] = a, p[9] = o, p[13] = l, p[2] = c, p[6] = h, p[10] = u, p[14] = d, p[3] = m, p[7] = g, p[11] = v, p[15] = f, this;
- }
- /**
- * Sets this matrix to the 4x4 identity matrix.
- *
- * @return {Matrix4} A reference to this matrix.
- */
- identity() {
- return this.set(
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Returns a matrix with copied values from this instance.
- *
- * @return {Matrix4} A clone of this instance.
- */
- clone() {
- return new Ne().fromArray(this.elements);
- }
- /**
- * Copies the values of the given matrix to this instance.
- *
- * @param {Matrix4} m - The matrix to copy.
- * @return {Matrix4} A reference to this matrix.
- */
- copy(e) {
- const t = this.elements, i = e.elements;
- return t[0] = i[0], t[1] = i[1], t[2] = i[2], t[3] = i[3], t[4] = i[4], t[5] = i[5], t[6] = i[6], t[7] = i[7], t[8] = i[8], t[9] = i[9], t[10] = i[10], t[11] = i[11], t[12] = i[12], t[13] = i[13], t[14] = i[14], t[15] = i[15], this;
- }
- /**
- * Copies the translation component of the given matrix
- * into this matrix's translation component.
- *
- * @param {Matrix4} m - The matrix to copy the translation component.
- * @return {Matrix4} A reference to this matrix.
- */
- copyPosition(e) {
- const t = this.elements, i = e.elements;
- return t[12] = i[12], t[13] = i[13], t[14] = i[14], this;
- }
- /**
- * Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix.
- *
- * @param {Matrix3} m - The 3x3 matrix.
- * @return {Matrix4} A reference to this matrix.
- */
- setFromMatrix3(e) {
- const t = e.elements;
- return this.set(
- t[0],
- t[3],
- t[6],
- 0,
- t[1],
- t[4],
- t[7],
- 0,
- t[2],
- t[5],
- t[8],
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Extracts the basis of this matrix into the three axis vectors provided.
- *
- * @param {Vector3} xAxis - The basis's x axis.
- * @param {Vector3} yAxis - The basis's y axis.
- * @param {Vector3} zAxis - The basis's z axis.
- * @return {Matrix4} A reference to this matrix.
- */
- extractBasis(e, t, i) {
- return e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), i.setFromMatrixColumn(this, 2), this;
- }
- /**
- * Sets the given basis vectors to this matrix.
- *
- * @param {Vector3} xAxis - The basis's x axis.
- * @param {Vector3} yAxis - The basis's y axis.
- * @param {Vector3} zAxis - The basis's z axis.
- * @return {Matrix4} A reference to this matrix.
- */
- makeBasis(e, t, i) {
- return this.set(
- e.x,
- t.x,
- i.x,
- 0,
- e.y,
- t.y,
- i.y,
- 0,
- e.z,
- t.z,
- i.z,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Extracts the rotation component of the given matrix
- * into this matrix's rotation component.
- *
- * Note: This method does not support reflection matrices.
- *
- * @param {Matrix4} m - The matrix.
- * @return {Matrix4} A reference to this matrix.
- */
- extractRotation(e) {
- const t = this.elements, i = e.elements, s = 1 / ws.setFromMatrixColumn(e, 0).length(), r = 1 / ws.setFromMatrixColumn(e, 1).length(), a = 1 / ws.setFromMatrixColumn(e, 2).length();
- return t[0] = i[0] * s, t[1] = i[1] * s, t[2] = i[2] * s, t[3] = 0, t[4] = i[4] * r, t[5] = i[5] * r, t[6] = i[6] * r, t[7] = 0, t[8] = i[8] * a, t[9] = i[9] * a, t[10] = i[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
- }
- /**
- * Sets the rotation component (the upper left 3x3 matrix) of this matrix to
- * the rotation specified by the given Euler angles. The rest of
- * the matrix is set to the identity. Depending on the {@link Euler#order},
- * there are six possible outcomes. See [this page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix)
- * for a complete list.
- *
- * @param {Euler} euler - The Euler angles.
- * @return {Matrix4} A reference to this matrix.
- */
- makeRotationFromEuler(e) {
- const t = this.elements, i = e.x, s = e.y, r = e.z, a = Math.cos(i), o = Math.sin(i), l = Math.cos(s), c = Math.sin(s), h = Math.cos(r), u = Math.sin(r);
- if (e.order === "XYZ") {
- const d = a * h, m = a * u, g = o * h, v = o * u;
- t[0] = l * h, t[4] = -l * u, t[8] = c, t[1] = m + g * c, t[5] = d - v * c, t[9] = -o * l, t[2] = v - d * c, t[6] = g + m * c, t[10] = a * l;
- } else if (e.order === "YXZ") {
- const d = l * h, m = l * u, g = c * h, v = c * u;
- t[0] = d + v * o, t[4] = g * o - m, t[8] = a * c, t[1] = a * u, t[5] = a * h, t[9] = -o, t[2] = m * o - g, t[6] = v + d * o, t[10] = a * l;
- } else if (e.order === "ZXY") {
- const d = l * h, m = l * u, g = c * h, v = c * u;
- t[0] = d - v * o, t[4] = -a * u, t[8] = g + m * o, t[1] = m + g * o, t[5] = a * h, t[9] = v - d * o, t[2] = -a * c, t[6] = o, t[10] = a * l;
- } else if (e.order === "ZYX") {
- const d = a * h, m = a * u, g = o * h, v = o * u;
- t[0] = l * h, t[4] = g * c - m, t[8] = d * c + v, t[1] = l * u, t[5] = v * c + d, t[9] = m * c - g, t[2] = -c, t[6] = o * l, t[10] = a * l;
- } else if (e.order === "YZX") {
- const d = a * l, m = a * c, g = o * l, v = o * c;
- t[0] = l * h, t[4] = v - d * u, t[8] = g * u + m, t[1] = u, t[5] = a * h, t[9] = -o * h, t[2] = -c * h, t[6] = m * u + g, t[10] = d - v * u;
- } else if (e.order === "XZY") {
- const d = a * l, m = a * c, g = o * l, v = o * c;
- t[0] = l * h, t[4] = -u, t[8] = c * h, t[1] = d * u + v, t[5] = a * h, t[9] = m * u - g, t[2] = g * u - m, t[6] = o * h, t[10] = v * u + d;
- }
- return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this;
- }
- /**
- * Sets the rotation component of this matrix to the rotation specified by
- * the given Quaternion as outlined [here](https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion)
- * The rest of the matrix is set to the identity.
- *
- * @param {Quaternion} q - The Quaternion.
- * @return {Matrix4} A reference to this matrix.
- */
- makeRotationFromQuaternion(e) {
- return this.compose(ld, e, cd);
- }
- /**
- * Sets the rotation component of the transformation matrix, looking from `eye` towards
- * `target`, and oriented by the up-direction.
- *
- * @param {Vector3} eye - The eye vector.
- * @param {Vector3} target - The target vector.
- * @param {Vector3} up - The up vector.
- * @return {Matrix4} A reference to this matrix.
- */
- lookAt(e, t, i) {
- const s = this.elements;
- return Zt.subVectors(e, t), Zt.lengthSq() === 0 && (Zt.z = 1), Zt.normalize(), Ki.crossVectors(i, Zt), Ki.lengthSq() === 0 && (Math.abs(i.z) === 1 ? Zt.x += 1e-4 : Zt.z += 1e-4, Zt.normalize(), Ki.crossVectors(i, Zt)), Ki.normalize(), Wn.crossVectors(Zt, Ki), s[0] = Ki.x, s[4] = Wn.x, s[8] = Zt.x, s[1] = Ki.y, s[5] = Wn.y, s[9] = Zt.y, s[2] = Ki.z, s[6] = Wn.z, s[10] = Zt.z, this;
- }
- /**
- * Post-multiplies this matrix by the given 4x4 matrix.
- *
- * @param {Matrix4} m - The matrix to multiply with.
- * @return {Matrix4} A reference to this matrix.
- */
- multiply(e) {
- return this.multiplyMatrices(this, e);
- }
- /**
- * Pre-multiplies this matrix by the given 4x4 matrix.
- *
- * @param {Matrix4} m - The matrix to multiply with.
- * @return {Matrix4} A reference to this matrix.
- */
- premultiply(e) {
- return this.multiplyMatrices(e, this);
- }
- /**
- * Multiples the given 4x4 matrices and stores the result
- * in this matrix.
- *
- * @param {Matrix4} a - The first matrix.
- * @param {Matrix4} b - The second matrix.
- * @return {Matrix4} A reference to this matrix.
- */
- multiplyMatrices(e, t) {
- const i = e.elements, s = t.elements, r = this.elements, a = i[0], o = i[4], l = i[8], c = i[12], h = i[1], u = i[5], d = i[9], m = i[13], g = i[2], v = i[6], f = i[10], p = i[14], b = i[3], _ = i[7], E = i[11], R = i[15], T = s[0], A = s[4], I = s[8], S = s[12], M = s[1], L = s[5], N = s[9], z = s[13], H = s[2], j = s[6], q = s[10], te = s[14], G = s[3], Z = s[7], ne = s[11], Le = s[15];
- return r[0] = a * T + o * M + l * H + c * G, r[4] = a * A + o * L + l * j + c * Z, r[8] = a * I + o * N + l * q + c * ne, r[12] = a * S + o * z + l * te + c * Le, r[1] = h * T + u * M + d * H + m * G, r[5] = h * A + u * L + d * j + m * Z, r[9] = h * I + u * N + d * q + m * ne, r[13] = h * S + u * z + d * te + m * Le, r[2] = g * T + v * M + f * H + p * G, r[6] = g * A + v * L + f * j + p * Z, r[10] = g * I + v * N + f * q + p * ne, r[14] = g * S + v * z + f * te + p * Le, r[3] = b * T + _ * M + E * H + R * G, r[7] = b * A + _ * L + E * j + R * Z, r[11] = b * I + _ * N + E * q + R * ne, r[15] = b * S + _ * z + E * te + R * Le, this;
- }
- /**
- * Multiplies every component of the matrix by the given scalar.
- *
- * @param {number} s - The scalar.
- * @return {Matrix4} A reference to this matrix.
- */
- multiplyScalar(e) {
- const t = this.elements;
- return t[0] *= e, t[4] *= e, t[8] *= e, t[12] *= e, t[1] *= e, t[5] *= e, t[9] *= e, t[13] *= e, t[2] *= e, t[6] *= e, t[10] *= e, t[14] *= e, t[3] *= e, t[7] *= e, t[11] *= e, t[15] *= e, this;
- }
- /**
- * Computes and returns the determinant of this matrix.
- *
- * Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html).
- *
- * @return {number} The determinant.
- */
- determinant() {
- const e = this.elements, t = e[0], i = e[4], s = e[8], r = e[12], a = e[1], o = e[5], l = e[9], c = e[13], h = e[2], u = e[6], d = e[10], m = e[14], g = e[3], v = e[7], f = e[11], p = e[15];
- return g * (+r * l * u - s * c * u - r * o * d + i * c * d + s * o * m - i * l * m) + v * (+t * l * m - t * c * d + r * a * d - s * a * m + s * c * h - r * l * h) + f * (+t * c * u - t * o * m - r * a * u + i * a * m + r * o * h - i * c * h) + p * (-s * o * h - t * l * u + t * o * d + s * a * u - i * a * d + i * l * h);
- }
- /**
- * Transposes this matrix in place.
- *
- * @return {Matrix4} A reference to this matrix.
- */
- transpose() {
- const e = this.elements;
- let t;
- return t = e[1], e[1] = e[4], e[4] = t, t = e[2], e[2] = e[8], e[8] = t, t = e[6], e[6] = e[9], e[9] = t, t = e[3], e[3] = e[12], e[12] = t, t = e[7], e[7] = e[13], e[13] = t, t = e[11], e[11] = e[14], e[14] = t, this;
- }
- /**
- * Sets the position component for this matrix from the given vector,
- * without affecting the rest of the matrix.
- *
- * @param {number|Vector3} x - The x component of the vector or alternatively the vector object.
- * @param {number} y - The y component of the vector.
- * @param {number} z - The z component of the vector.
- * @return {Matrix4} A reference to this matrix.
- */
- setPosition(e, t, i) {
- const s = this.elements;
- return e.isVector3 ? (s[12] = e.x, s[13] = e.y, s[14] = e.z) : (s[12] = e, s[13] = t, s[14] = i), this;
- }
- /**
- * Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
- * You can not invert with a determinant of zero. If you attempt this, the method produces
- * a zero matrix instead.
- *
- * @return {Matrix4} A reference to this matrix.
- */
- invert() {
- const e = this.elements, t = e[0], i = e[1], s = e[2], r = e[3], a = e[4], o = e[5], l = e[6], c = e[7], h = e[8], u = e[9], d = e[10], m = e[11], g = e[12], v = e[13], f = e[14], p = e[15], b = u * f * c - v * d * c + v * l * m - o * f * m - u * l * p + o * d * p, _ = g * d * c - h * f * c - g * l * m + a * f * m + h * l * p - a * d * p, E = h * v * c - g * u * c + g * o * m - a * v * m - h * o * p + a * u * p, R = g * u * l - h * v * l - g * o * d + a * v * d + h * o * f - a * u * f, T = t * b + i * _ + s * E + r * R;
- if (T === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
- const A = 1 / T;
- return e[0] = b * A, e[1] = (v * d * r - u * f * r - v * s * m + i * f * m + u * s * p - i * d * p) * A, e[2] = (o * f * r - v * l * r + v * s * c - i * f * c - o * s * p + i * l * p) * A, e[3] = (u * l * r - o * d * r - u * s * c + i * d * c + o * s * m - i * l * m) * A, e[4] = _ * A, e[5] = (h * f * r - g * d * r + g * s * m - t * f * m - h * s * p + t * d * p) * A, e[6] = (g * l * r - a * f * r - g * s * c + t * f * c + a * s * p - t * l * p) * A, e[7] = (a * d * r - h * l * r + h * s * c - t * d * c - a * s * m + t * l * m) * A, e[8] = E * A, e[9] = (g * u * r - h * v * r - g * i * m + t * v * m + h * i * p - t * u * p) * A, e[10] = (a * v * r - g * o * r + g * i * c - t * v * c - a * i * p + t * o * p) * A, e[11] = (h * o * r - a * u * r - h * i * c + t * u * c + a * i * m - t * o * m) * A, e[12] = R * A, e[13] = (h * v * s - g * u * s + g * i * d - t * v * d - h * i * f + t * u * f) * A, e[14] = (g * o * s - a * v * s - g * i * l + t * v * l + a * i * f - t * o * f) * A, e[15] = (a * u * s - h * o * s + h * i * l - t * u * l - a * i * d + t * o * d) * A, this;
- }
- /**
- * Multiplies the columns of this matrix by the given vector.
- *
- * @param {Vector3} v - The scale vector.
- * @return {Matrix4} A reference to this matrix.
- */
- scale(e) {
- const t = this.elements, i = e.x, s = e.y, r = e.z;
- return t[0] *= i, t[4] *= s, t[8] *= r, t[1] *= i, t[5] *= s, t[9] *= r, t[2] *= i, t[6] *= s, t[10] *= r, t[3] *= i, t[7] *= s, t[11] *= r, this;
- }
- /**
- * Gets the maximum scale value of the three axes.
- *
- * @return {number} The maximum scale.
- */
- getMaxScaleOnAxis() {
- const e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], i = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], s = e[8] * e[8] + e[9] * e[9] + e[10] * e[10];
- return Math.sqrt(Math.max(t, i, s));
- }
- /**
- * Sets this matrix as a translation transform from the given vector.
- *
- * @param {number|Vector3} x - The amount to translate in the X axis or alternatively a translation vector.
- * @param {number} y - The amount to translate in the Y axis.
- * @param {number} z - The amount to translate in the z axis.
- * @return {Matrix4} A reference to this matrix.
- */
- makeTranslation(e, t, i) {
- return e.isVector3 ? this.set(
- 1,
- 0,
- 0,
- e.x,
- 0,
- 1,
- 0,
- e.y,
- 0,
- 0,
- 1,
- e.z,
- 0,
- 0,
- 0,
- 1
- ) : this.set(
- 1,
- 0,
- 0,
- e,
- 0,
- 1,
- 0,
- t,
- 0,
- 0,
- 1,
- i,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a rotational transformation around the X axis by
- * the given angle.
- *
- * @param {number} theta - The rotation in radians.
- * @return {Matrix4} A reference to this matrix.
- */
- makeRotationX(e) {
- const t = Math.cos(e), i = Math.sin(e);
- return this.set(
- 1,
- 0,
- 0,
- 0,
- 0,
- t,
- -i,
- 0,
- 0,
- i,
- t,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a rotational transformation around the Y axis by
- * the given angle.
- *
- * @param {number} theta - The rotation in radians.
- * @return {Matrix4} A reference to this matrix.
- */
- makeRotationY(e) {
- const t = Math.cos(e), i = Math.sin(e);
- return this.set(
- t,
- 0,
- i,
- 0,
- 0,
- 1,
- 0,
- 0,
- -i,
- 0,
- t,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a rotational transformation around the Z axis by
- * the given angle.
- *
- * @param {number} theta - The rotation in radians.
- * @return {Matrix4} A reference to this matrix.
- */
- makeRotationZ(e) {
- const t = Math.cos(e), i = Math.sin(e);
- return this.set(
- t,
- -i,
- 0,
- 0,
- i,
- t,
- 0,
- 0,
- 0,
- 0,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a rotational transformation around the given axis by
- * the given angle.
- *
- * This is a somewhat controversial but mathematically sound alternative to
- * rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199).
- *
- * @param {Vector3} axis - The normalized rotation axis.
- * @param {number} angle - The rotation in radians.
- * @return {Matrix4} A reference to this matrix.
- */
- makeRotationAxis(e, t) {
- const i = Math.cos(t), s = Math.sin(t), r = 1 - i, a = e.x, o = e.y, l = e.z, c = r * a, h = r * o;
- return this.set(
- c * a + i,
- c * o - s * l,
- c * l + s * o,
- 0,
- c * o + s * l,
- h * o + i,
- h * l - s * a,
- 0,
- c * l - s * o,
- h * l + s * a,
- r * l * l + i,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a scale transformation.
- *
- * @param {number} x - The amount to scale in the X axis.
- * @param {number} y - The amount to scale in the Y axis.
- * @param {number} z - The amount to scale in the Z axis.
- * @return {Matrix4} A reference to this matrix.
- */
- makeScale(e, t, i) {
- return this.set(
- e,
- 0,
- 0,
- 0,
- 0,
- t,
- 0,
- 0,
- 0,
- 0,
- i,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix as a shear transformation.
- *
- * @param {number} xy - The amount to shear X by Y.
- * @param {number} xz - The amount to shear X by Z.
- * @param {number} yx - The amount to shear Y by X.
- * @param {number} yz - The amount to shear Y by Z.
- * @param {number} zx - The amount to shear Z by X.
- * @param {number} zy - The amount to shear Z by Y.
- * @return {Matrix4} A reference to this matrix.
- */
- makeShear(e, t, i, s, r, a) {
- return this.set(
- 1,
- i,
- r,
- 0,
- e,
- 1,
- a,
- 0,
- t,
- s,
- 1,
- 0,
- 0,
- 0,
- 0,
- 1
- ), this;
- }
- /**
- * Sets this matrix to the transformation composed of the given position,
- * rotation (Quaternion) and scale.
- *
- * @param {Vector3} position - The position vector.
- * @param {Quaternion} quaternion - The rotation as a Quaternion.
- * @param {Vector3} scale - The scale vector.
- * @return {Matrix4} A reference to this matrix.
- */
- compose(e, t, i) {
- const s = this.elements, r = t._x, a = t._y, o = t._z, l = t._w, c = r + r, h = a + a, u = o + o, d = r * c, m = r * h, g = r * u, v = a * h, f = a * u, p = o * u, b = l * c, _ = l * h, E = l * u, R = i.x, T = i.y, A = i.z;
- return s[0] = (1 - (v + p)) * R, s[1] = (m + E) * R, s[2] = (g - _) * R, s[3] = 0, s[4] = (m - E) * T, s[5] = (1 - (d + p)) * T, s[6] = (f + b) * T, s[7] = 0, s[8] = (g + _) * A, s[9] = (f - b) * A, s[10] = (1 - (d + v)) * A, s[11] = 0, s[12] = e.x, s[13] = e.y, s[14] = e.z, s[15] = 1, this;
- }
- /**
- * Decomposes this matrix into its position, rotation and scale components
- * and provides the result in the given objects.
- *
- * Note: Not all matrices are decomposable in this way. For example, if an
- * object has a non-uniformly scaled parent, then the object's world matrix
- * may not be decomposable, and this method may not be appropriate.
- *
- * @param {Vector3} position - The position vector.
- * @param {Quaternion} quaternion - The rotation as a Quaternion.
- * @param {Vector3} scale - The scale vector.
- * @return {Matrix4} A reference to this matrix.
- */
- decompose(e, t, i) {
- const s = this.elements;
- let r = ws.set(s[0], s[1], s[2]).length();
- const a = ws.set(s[4], s[5], s[6]).length(), o = ws.set(s[8], s[9], s[10]).length();
- this.determinant() < 0 && (r = -r), e.x = s[12], e.y = s[13], e.z = s[14], ci.copy(this);
- const l = 1 / r, c = 1 / a, h = 1 / o;
- return ci.elements[0] *= l, ci.elements[1] *= l, ci.elements[2] *= l, ci.elements[4] *= c, ci.elements[5] *= c, ci.elements[6] *= c, ci.elements[8] *= h, ci.elements[9] *= h, ci.elements[10] *= h, t.setFromRotationMatrix(ci), i.x = r, i.y = a, i.z = o, this;
- }
- /**
- * Creates a perspective projection matrix. This is used internally by
- * {@link PerspectiveCamera#updateProjectionMatrix}.
-
- * @param {number} left - Left boundary of the viewing frustum at the near plane.
- * @param {number} right - Right boundary of the viewing frustum at the near plane.
- * @param {number} top - Top boundary of the viewing frustum at the near plane.
- * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.
- * @param {number} near - The distance from the camera to the near plane.
- * @param {number} far - The distance from the camera to the far plane.
- * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
- * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
- * @return {Matrix4} A reference to this matrix.
- */
- makePerspective(e, t, i, s, r, a, o = Ci, l = !1) {
- const c = this.elements, h = 2 * r / (t - e), u = 2 * r / (i - s), d = (t + e) / (t - e), m = (i + s) / (i - s);
- let g, v;
- if (l)
- g = r / (a - r), v = a * r / (a - r);
- else if (o === Ci)
- g = -(a + r) / (a - r), v = -2 * a * r / (a - r);
- else if (o === Cr)
- g = -a / (a - r), v = -a * r / (a - r);
- else
- throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o);
- return c[0] = h, c[4] = 0, c[8] = d, c[12] = 0, c[1] = 0, c[5] = u, c[9] = m, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = g, c[14] = v, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this;
- }
- /**
- * Creates a orthographic projection matrix. This is used internally by
- * {@link OrthographicCamera#updateProjectionMatrix}.
-
- * @param {number} left - Left boundary of the viewing frustum at the near plane.
- * @param {number} right - Right boundary of the viewing frustum at the near plane.
- * @param {number} top - Top boundary of the viewing frustum at the near plane.
- * @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.
- * @param {number} near - The distance from the camera to the near plane.
- * @param {number} far - The distance from the camera to the far plane.
- * @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
- * @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
- * @return {Matrix4} A reference to this matrix.
- */
- makeOrthographic(e, t, i, s, r, a, o = Ci, l = !1) {
- const c = this.elements, h = 2 / (t - e), u = 2 / (i - s), d = -(t + e) / (t - e), m = -(i + s) / (i - s);
- let g, v;
- if (l)
- g = 1 / (a - r), v = a / (a - r);
- else if (o === Ci)
- g = -2 / (a - r), v = -(a + r) / (a - r);
- else if (o === Cr)
- g = -1 / (a - r), v = -r / (a - r);
- else
- throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o);
- return c[0] = h, c[4] = 0, c[8] = 0, c[12] = d, c[1] = 0, c[5] = u, c[9] = 0, c[13] = m, c[2] = 0, c[6] = 0, c[10] = g, c[14] = v, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this;
- }
- /**
- * Returns `true` if this matrix is equal with the given one.
- *
- * @param {Matrix4} matrix - The matrix to test for equality.
- * @return {boolean} Whether this matrix is equal with the given one.
- */
- equals(e) {
- const t = this.elements, i = e.elements;
- for (let s = 0; s < 16; s++)
- if (t[s] !== i[s]) return !1;
- return !0;
- }
- /**
- * Sets the elements of the matrix from the given array.
- *
- * @param {Array} array - The matrix elements in column-major order.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Matrix4} A reference to this matrix.
- */
- fromArray(e, t = 0) {
- for (let i = 0; i < 16; i++)
- this.elements[i] = e[i + t];
- return this;
- }
- /**
- * Writes the elements of this matrix to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The matrix elements in column-major order.
- */
- toArray(e = [], t = 0) {
- const i = this.elements;
- return e[t] = i[0], e[t + 1] = i[1], e[t + 2] = i[2], e[t + 3] = i[3], e[t + 4] = i[4], e[t + 5] = i[5], e[t + 6] = i[6], e[t + 7] = i[7], e[t + 8] = i[8], e[t + 9] = i[9], e[t + 10] = i[10], e[t + 11] = i[11], e[t + 12] = i[12], e[t + 13] = i[13], e[t + 14] = i[14], e[t + 15] = i[15], e;
- }
-}
-const ws = /* @__PURE__ */ new w(), ci = /* @__PURE__ */ new Ne(), ld = /* @__PURE__ */ new w(0, 0, 0), cd = /* @__PURE__ */ new w(1, 1, 1), Ki = /* @__PURE__ */ new w(), Wn = /* @__PURE__ */ new w(), Zt = /* @__PURE__ */ new w(), Tl = /* @__PURE__ */ new Ne(), El = /* @__PURE__ */ new xi();
-class bi {
- /**
- * Constructs a new euler instance.
- *
- * @param {number} [x=0] - The angle of the x axis in radians.
- * @param {number} [y=0] - The angle of the y axis in radians.
- * @param {number} [z=0] - The angle of the z axis in radians.
- * @param {string} [order=Euler.DEFAULT_ORDER] - A string representing the order that the rotations are applied.
- */
- constructor(e = 0, t = 0, i = 0, s = bi.DEFAULT_ORDER) {
- this.isEuler = !0, this._x = e, this._y = t, this._z = i, this._order = s;
- }
- /**
- * The angle of the x axis in radians.
- *
- * @type {number}
- * @default 0
- */
- get x() {
- return this._x;
- }
- set x(e) {
- this._x = e, this._onChangeCallback();
- }
- /**
- * The angle of the y axis in radians.
- *
- * @type {number}
- * @default 0
- */
- get y() {
- return this._y;
- }
- set y(e) {
- this._y = e, this._onChangeCallback();
- }
- /**
- * The angle of the z axis in radians.
- *
- * @type {number}
- * @default 0
- */
- get z() {
- return this._z;
- }
- set z(e) {
- this._z = e, this._onChangeCallback();
- }
- /**
- * A string representing the order that the rotations are applied.
- *
- * @type {string}
- * @default 'XYZ'
- */
- get order() {
- return this._order;
- }
- set order(e) {
- this._order = e, this._onChangeCallback();
- }
- /**
- * Sets the Euler components.
- *
- * @param {number} x - The angle of the x axis in radians.
- * @param {number} y - The angle of the y axis in radians.
- * @param {number} z - The angle of the z axis in radians.
- * @param {string} [order] - A string representing the order that the rotations are applied.
- * @return {Euler} A reference to this Euler instance.
- */
- set(e, t, i, s = this._order) {
- return this._x = e, this._y = t, this._z = i, this._order = s, this._onChangeCallback(), this;
- }
- /**
- * Returns a new Euler instance with copied values from this instance.
- *
- * @return {Euler} A clone of this instance.
- */
- clone() {
- return new this.constructor(this._x, this._y, this._z, this._order);
- }
- /**
- * Copies the values of the given Euler instance to this instance.
- *
- * @param {Euler} euler - The Euler instance to copy.
- * @return {Euler} A reference to this Euler instance.
- */
- copy(e) {
- return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this;
- }
- /**
- * Sets the angles of this Euler instance from a pure rotation matrix.
- *
- * @param {Matrix4} m - A 4x4 matrix of which the upper 3x3 of matrix is a pure rotation matrix (i.e. unscaled).
- * @param {string} [order] - A string representing the order that the rotations are applied.
- * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
- * @return {Euler} A reference to this Euler instance.
- */
- setFromRotationMatrix(e, t = this._order, i = !0) {
- const s = e.elements, r = s[0], a = s[4], o = s[8], l = s[1], c = s[5], h = s[9], u = s[2], d = s[6], m = s[10];
- switch (t) {
- case "XYZ":
- this._y = Math.asin(ze(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-h, m), this._z = Math.atan2(-a, r)) : (this._x = Math.atan2(d, c), this._z = 0);
- break;
- case "YXZ":
- this._x = Math.asin(-ze(h, -1, 1)), Math.abs(h) < 0.9999999 ? (this._y = Math.atan2(o, m), this._z = Math.atan2(l, c)) : (this._y = Math.atan2(-u, r), this._z = 0);
- break;
- case "ZXY":
- this._x = Math.asin(ze(d, -1, 1)), Math.abs(d) < 0.9999999 ? (this._y = Math.atan2(-u, m), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(l, r));
- break;
- case "ZYX":
- this._y = Math.asin(-ze(u, -1, 1)), Math.abs(u) < 0.9999999 ? (this._x = Math.atan2(d, m), this._z = Math.atan2(l, r)) : (this._x = 0, this._z = Math.atan2(-a, c));
- break;
- case "YZX":
- this._z = Math.asin(ze(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(-h, c), this._y = Math.atan2(-u, r)) : (this._x = 0, this._y = Math.atan2(o, m));
- break;
- case "XZY":
- this._z = Math.asin(-ze(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(o, r)) : (this._x = Math.atan2(-h, m), this._y = 0);
- break;
- default:
- Se("Euler: .setFromRotationMatrix() encountered an unknown order: " + t);
- }
- return this._order = t, i === !0 && this._onChangeCallback(), this;
- }
- /**
- * Sets the angles of this Euler instance from a normalized quaternion.
- *
- * @param {Quaternion} q - A normalized Quaternion.
- * @param {string} [order] - A string representing the order that the rotations are applied.
- * @param {boolean} [update=true] - Whether the internal `onChange` callback should be executed or not.
- * @return {Euler} A reference to this Euler instance.
- */
- setFromQuaternion(e, t, i) {
- return Tl.makeRotationFromQuaternion(e), this.setFromRotationMatrix(Tl, t, i);
- }
- /**
- * Sets the angles of this Euler instance from the given vector.
- *
- * @param {Vector3} v - The vector.
- * @param {string} [order] - A string representing the order that the rotations are applied.
- * @return {Euler} A reference to this Euler instance.
- */
- setFromVector3(e, t = this._order) {
- return this.set(e.x, e.y, e.z, t);
- }
- /**
- * Resets the euler angle with a new order by creating a quaternion from this
- * euler angle and then setting this euler angle with the quaternion and the
- * new order.
- *
- * Warning: This discards revolution information.
- *
- * @param {string} [newOrder] - A string representing the new order that the rotations are applied.
- * @return {Euler} A reference to this Euler instance.
- */
- reorder(e) {
- return El.setFromEuler(this), this.setFromQuaternion(El, e);
- }
- /**
- * Returns `true` if this Euler instance is equal with the given one.
- *
- * @param {Euler} euler - The Euler instance to test for equality.
- * @return {boolean} Whether this Euler instance is equal with the given one.
- */
- equals(e) {
- return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order;
- }
- /**
- * Sets this Euler instance's components to values from the given array. The first three
- * entries of the array are assign to the x,y and z components. An optional fourth entry
- * defines the Euler order.
- *
- * @param {Array} array - An array holding the Euler component values.
- * @return {Euler} A reference to this Euler instance.
- */
- fromArray(e) {
- return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this;
- }
- /**
- * Writes the components of this Euler instance to the given array. If no array is provided,
- * the method returns a new instance.
- *
- * @param {Array} [array=[]] - The target array holding the Euler components.
- * @param {number} [offset=0] - Index of the first element in the array.
- * @return {Array} The Euler components.
- */
- toArray(e = [], t = 0) {
- return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e;
- }
- _onChange(e) {
- return this._onChangeCallback = e, this;
- }
- _onChangeCallback() {
- }
- *[Symbol.iterator]() {
- yield this._x, yield this._y, yield this._z, yield this._order;
- }
-}
-bi.DEFAULT_ORDER = "XYZ";
-class Vo {
- /**
- * Constructs a new layers instance, with membership
- * initially set to layer `0`.
- */
- constructor() {
- this.mask = 1;
- }
- /**
- * Sets membership to the given layer, and remove membership all other layers.
- *
- * @param {number} layer - The layer to set.
- */
- set(e) {
- this.mask = (1 << e | 0) >>> 0;
- }
- /**
- * Adds membership of the given layer.
- *
- * @param {number} layer - The layer to enable.
- */
- enable(e) {
- this.mask |= 1 << e | 0;
- }
- /**
- * Adds membership to all layers.
- */
- enableAll() {
- this.mask = -1;
- }
- /**
- * Toggles the membership of the given layer.
- *
- * @param {number} layer - The layer to toggle.
- */
- toggle(e) {
- this.mask ^= 1 << e | 0;
- }
- /**
- * Removes membership of the given layer.
- *
- * @param {number} layer - The layer to enable.
- */
- disable(e) {
- this.mask &= ~(1 << e | 0);
- }
- /**
- * Removes the membership from all layers.
- */
- disableAll() {
- this.mask = 0;
- }
- /**
- * Returns `true` if this and the given layers object have at least one
- * layer in common.
- *
- * @param {Layers} layers - The layers to test.
- * @return {boolean } Whether this and the given layers object have at least one layer in common or not.
- */
- test(e) {
- return (this.mask & e.mask) !== 0;
- }
- /**
- * Returns `true` if the given layer is enabled.
- *
- * @param {number} layer - The layer to test.
- * @return {boolean } Whether the given layer is enabled or not.
- */
- isEnabled(e) {
- return (this.mask & (1 << e | 0)) !== 0;
- }
-}
-let hd = 0;
-const wl = /* @__PURE__ */ new w(), Cs = /* @__PURE__ */ new xi(), Bi = /* @__PURE__ */ new Ne(), jn = /* @__PURE__ */ new w(), un = /* @__PURE__ */ new w(), ud = /* @__PURE__ */ new w(), dd = /* @__PURE__ */ new xi(), Cl = /* @__PURE__ */ new w(1, 0, 0), Al = /* @__PURE__ */ new w(0, 1, 0), Rl = /* @__PURE__ */ new w(0, 0, 1), Pl = { type: "added" }, pd = { type: "removed" }, As = { type: "childadded", child: null }, $r = { type: "childremoved", child: null };
-class mt extends xs {
- /**
- * Constructs a new 3D object.
- */
- constructor() {
- super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: hd++ }), this.uuid = gi(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = mt.DEFAULT_UP.clone();
- const e = new w(), t = new bi(), i = new xi(), s = new w(1, 1, 1);
- function r() {
- i.setFromEuler(t, !1);
- }
- function a() {
- t.setFromQuaternion(i, void 0, !1);
- }
- t._onChange(r), i._onChange(a), Object.defineProperties(this, {
- /**
- * Represents the object's local position.
- *
- * @name Object3D#position
- * @type {Vector3}
- * @default (0,0,0)
- */
- position: {
- configurable: !0,
- enumerable: !0,
- value: e
- },
- /**
- * Represents the object's local rotation as Euler angles, in radians.
- *
- * @name Object3D#rotation
- * @type {Euler}
- * @default (0,0,0)
- */
- rotation: {
- configurable: !0,
- enumerable: !0,
- value: t
- },
- /**
- * Represents the object's local rotation as Quaternions.
- *
- * @name Object3D#quaternion
- * @type {Quaternion}
- */
- quaternion: {
- configurable: !0,
- enumerable: !0,
- value: i
- },
- /**
- * Represents the object's local scale.
- *
- * @name Object3D#scale
- * @type {Vector3}
- * @default (1,1,1)
- */
- scale: {
- configurable: !0,
- enumerable: !0,
- value: s
- },
- /**
- * Represents the object's model-view matrix.
- *
- * @name Object3D#modelViewMatrix
- * @type {Matrix4}
- */
- modelViewMatrix: {
- value: new Ne()
- },
- /**
- * Represents the object's normal matrix.
- *
- * @name Object3D#normalMatrix
- * @type {Matrix3}
- */
- normalMatrix: {
- value: new ke()
- }
- }), this.matrix = new Ne(), this.matrixWorld = new Ne(), this.matrixAutoUpdate = mt.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = mt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new Vo(), this.visible = !0, this.castShadow = !1, this.receiveShadow = !1, this.frustumCulled = !0, this.renderOrder = 0, this.animations = [], this.customDepthMaterial = void 0, this.customDistanceMaterial = void 0, this.userData = {};
- }
- /**
- * A callback that is executed immediately before a 3D object is rendered to a shadow map.
- *
- * @param {Renderer|WebGLRenderer} renderer - The renderer.
- * @param {Object3D} object - The 3D object.
- * @param {Camera} camera - The camera that is used to render the scene.
- * @param {Camera} shadowCamera - The shadow camera.
- * @param {BufferGeometry} geometry - The 3D object's geometry.
- * @param {Material} depthMaterial - The depth material.
- * @param {Object} group - The geometry group data.
- */
- onBeforeShadow() {
- }
- /**
- * A callback that is executed immediately after a 3D object is rendered to a shadow map.
- *
- * @param {Renderer|WebGLRenderer} renderer - The renderer.
- * @param {Object3D} object - The 3D object.
- * @param {Camera} camera - The camera that is used to render the scene.
- * @param {Camera} shadowCamera - The shadow camera.
- * @param {BufferGeometry} geometry - The 3D object's geometry.
- * @param {Material} depthMaterial - The depth material.
- * @param {Object} group - The geometry group data.
- */
- onAfterShadow() {
- }
- /**
- * A callback that is executed immediately before a 3D object is rendered.
- *
- * @param {Renderer|WebGLRenderer} renderer - The renderer.
- * @param {Object3D} object - The 3D object.
- * @param {Camera} camera - The camera that is used to render the scene.
- * @param {BufferGeometry} geometry - The 3D object's geometry.
- * @param {Material} material - The 3D object's material.
- * @param {Object} group - The geometry group data.
- */
- onBeforeRender() {
- }
- /**
- * A callback that is executed immediately after a 3D object is rendered.
- *
- * @param {Renderer|WebGLRenderer} renderer - The renderer.
- * @param {Object3D} object - The 3D object.
- * @param {Camera} camera - The camera that is used to render the scene.
- * @param {BufferGeometry} geometry - The 3D object's geometry.
- * @param {Material} material - The 3D object's material.
- * @param {Object} group - The geometry group data.
- */
- onAfterRender() {
- }
- /**
- * Applies the given transformation matrix to the object and updates the object's position,
- * rotation and scale.
- *
- * @param {Matrix4} matrix - The transformation matrix.
- */
- applyMatrix4(e) {
- this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale);
- }
- /**
- * Applies a rotation represented by given the quaternion to the 3D object.
- *
- * @param {Quaternion} q - The quaternion.
- * @return {Object3D} A reference to this instance.
- */
- applyQuaternion(e) {
- return this.quaternion.premultiply(e), this;
- }
- /**
- * Sets the given rotation represented as an axis/angle couple to the 3D object.
- *
- * @param {Vector3} axis - The (normalized) axis vector.
- * @param {number} angle - The angle in radians.
- */
- setRotationFromAxisAngle(e, t) {
- this.quaternion.setFromAxisAngle(e, t);
- }
- /**
- * Sets the given rotation represented as Euler angles to the 3D object.
- *
- * @param {Euler} euler - The Euler angles.
- */
- setRotationFromEuler(e) {
- this.quaternion.setFromEuler(e, !0);
- }
- /**
- * Sets the given rotation represented as rotation matrix to the 3D object.
- *
- * @param {Matrix4} m - Although a 4x4 matrix is expected, the upper 3x3 portion must be
- * a pure rotation matrix (i.e, unscaled).
- */
- setRotationFromMatrix(e) {
- this.quaternion.setFromRotationMatrix(e);
- }
- /**
- * Sets the given rotation represented as a Quaternion to the 3D object.
- *
- * @param {Quaternion} q - The Quaternion
- */
- setRotationFromQuaternion(e) {
- this.quaternion.copy(e);
- }
- /**
- * Rotates the 3D object along an axis in local space.
- *
- * @param {Vector3} axis - The (normalized) axis vector.
- * @param {number} angle - The angle in radians.
- * @return {Object3D} A reference to this instance.
- */
- rotateOnAxis(e, t) {
- return Cs.setFromAxisAngle(e, t), this.quaternion.multiply(Cs), this;
- }
- /**
- * Rotates the 3D object along an axis in world space.
- *
- * @param {Vector3} axis - The (normalized) axis vector.
- * @param {number} angle - The angle in radians.
- * @return {Object3D} A reference to this instance.
- */
- rotateOnWorldAxis(e, t) {
- return Cs.setFromAxisAngle(e, t), this.quaternion.premultiply(Cs), this;
- }
- /**
- * Rotates the 3D object around its X axis in local space.
- *
- * @param {number} angle - The angle in radians.
- * @return {Object3D} A reference to this instance.
- */
- rotateX(e) {
- return this.rotateOnAxis(Cl, e);
- }
- /**
- * Rotates the 3D object around its Y axis in local space.
- *
- * @param {number} angle - The angle in radians.
- * @return {Object3D} A reference to this instance.
- */
- rotateY(e) {
- return this.rotateOnAxis(Al, e);
- }
- /**
- * Rotates the 3D object around its Z axis in local space.
- *
- * @param {number} angle - The angle in radians.
- * @return {Object3D} A reference to this instance.
- */
- rotateZ(e) {
- return this.rotateOnAxis(Rl, e);
- }
- /**
- * Translate the 3D object by a distance along the given axis in local space.
- *
- * @param {Vector3} axis - The (normalized) axis vector.
- * @param {number} distance - The distance in world units.
- * @return {Object3D} A reference to this instance.
- */
- translateOnAxis(e, t) {
- return wl.copy(e).applyQuaternion(this.quaternion), this.position.add(wl.multiplyScalar(t)), this;
- }
- /**
- * Translate the 3D object by a distance along its X-axis in local space.
- *
- * @param {number} distance - The distance in world units.
- * @return {Object3D} A reference to this instance.
- */
- translateX(e) {
- return this.translateOnAxis(Cl, e);
- }
- /**
- * Translate the 3D object by a distance along its Y-axis in local space.
- *
- * @param {number} distance - The distance in world units.
- * @return {Object3D} A reference to this instance.
- */
- translateY(e) {
- return this.translateOnAxis(Al, e);
- }
- /**
- * Translate the 3D object by a distance along its Z-axis in local space.
- *
- * @param {number} distance - The distance in world units.
- * @return {Object3D} A reference to this instance.
- */
- translateZ(e) {
- return this.translateOnAxis(Rl, e);
- }
- /**
- * Converts the given vector from this 3D object's local space to world space.
- *
- * @param {Vector3} vector - The vector to convert.
- * @return {Vector3} The converted vector.
- */
- localToWorld(e) {
- return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld);
- }
- /**
- * Converts the given vector from this 3D object's word space to local space.
- *
- * @param {Vector3} vector - The vector to convert.
- * @return {Vector3} The converted vector.
- */
- worldToLocal(e) {
- return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Bi.copy(this.matrixWorld).invert());
- }
- /**
- * Rotates the object to face a point in world space.
- *
- * This method does not support objects having non-uniformly-scaled parent(s).
- *
- * @param {number|Vector3} x - The x coordinate in world space. Alternatively, a vector representing a position in world space
- * @param {number} [y] - The y coordinate in world space.
- * @param {number} [z] - The z coordinate in world space.
- */
- lookAt(e, t, i) {
- e.isVector3 ? jn.copy(e) : jn.set(e, t, i);
- const s = this.parent;
- this.updateWorldMatrix(!0, !1), un.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Bi.lookAt(un, jn, this.up) : Bi.lookAt(jn, un, this.up), this.quaternion.setFromRotationMatrix(Bi), s && (Bi.extractRotation(s.matrixWorld), Cs.setFromRotationMatrix(Bi), this.quaternion.premultiply(Cs.invert()));
- }
- /**
- * Adds the given 3D object as a child to this 3D object. An arbitrary number of
- * objects may be added. Any current parent on an object passed in here will be
- * removed, since an object can have at most one parent.
- *
- * @fires Object3D#added
- * @fires Object3D#childadded
- * @param {Object3D} object - The 3D object to add.
- * @return {Object3D} A reference to this instance.
- */
- add(e) {
- if (arguments.length > 1) {
- for (let t = 0; t < arguments.length; t++)
- this.add(arguments[t]);
- return this;
- }
- return e === this ? (Ve("Object3D.add: object can't be added as a child of itself.", e), this) : (e && e.isObject3D ? (e.removeFromParent(), e.parent = this, this.children.push(e), e.dispatchEvent(Pl), As.child = e, this.dispatchEvent(As), As.child = null) : Ve("Object3D.add: object not an instance of THREE.Object3D.", e), this);
- }
- /**
- * Removes the given 3D object as child from this 3D object.
- * An arbitrary number of objects may be removed.
- *
- * @fires Object3D#removed
- * @fires Object3D#childremoved
- * @param {Object3D} object - The 3D object to remove.
- * @return {Object3D} A reference to this instance.
- */
- remove(e) {
- if (arguments.length > 1) {
- for (let i = 0; i < arguments.length; i++)
- this.remove(arguments[i]);
- return this;
- }
- const t = this.children.indexOf(e);
- return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(pd), $r.child = e, this.dispatchEvent($r), $r.child = null), this;
- }
- /**
- * Removes this 3D object from its current parent.
- *
- * @fires Object3D#removed
- * @fires Object3D#childremoved
- * @return {Object3D} A reference to this instance.
- */
- removeFromParent() {
- const e = this.parent;
- return e !== null && e.remove(this), this;
- }
- /**
- * Removes all child objects.
- *
- * @fires Object3D#removed
- * @fires Object3D#childremoved
- * @return {Object3D} A reference to this instance.
- */
- clear() {
- return this.remove(...this.children);
- }
- /**
- * Adds the given 3D object as a child of this 3D object, while maintaining the object's world
- * transform. This method does not support scene graphs having non-uniformly-scaled nodes(s).
- *
- * @fires Object3D#added
- * @fires Object3D#childadded
- * @param {Object3D} object - The 3D object to attach.
- * @return {Object3D} A reference to this instance.
- */
- attach(e) {
- return this.updateWorldMatrix(!0, !1), Bi.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Bi.multiply(e.parent.matrixWorld)), e.applyMatrix4(Bi), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(Pl), As.child = e, this.dispatchEvent(As), As.child = null, this;
- }
- /**
- * Searches through the 3D object and its children, starting with the 3D object
- * itself, and returns the first with a matching ID.
- *
- * @param {number} id - The id.
- * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.
- */
- getObjectById(e) {
- return this.getObjectByProperty("id", e);
- }
- /**
- * Searches through the 3D object and its children, starting with the 3D object
- * itself, and returns the first with a matching name.
- *
- * @param {string} name - The name.
- * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.
- */
- getObjectByName(e) {
- return this.getObjectByProperty("name", e);
- }
- /**
- * Searches through the 3D object and its children, starting with the 3D object
- * itself, and returns the first with a matching property value.
- *
- * @param {string} name - The name of the property.
- * @param {any} value - The value.
- * @return {Object3D|undefined} The found 3D object. Returns `undefined` if no 3D object has been found.
- */
- getObjectByProperty(e, t) {
- if (this[e] === t) return this;
- for (let i = 0, s = this.children.length; i < s; i++) {
- const r = this.children[i].getObjectByProperty(e, t);
- if (r !== void 0)
- return r;
- }
- }
- /**
- * Searches through the 3D object and its children, starting with the 3D object
- * itself, and returns all 3D objects with a matching property value.
- *
- * @param {string} name - The name of the property.
- * @param {any} value - The value.
- * @param {Array} result - The method stores the result in this array.
- * @return {Array} The found 3D objects.
- */
- getObjectsByProperty(e, t, i = []) {
- this[e] === t && i.push(this);
- const s = this.children;
- for (let r = 0, a = s.length; r < a; r++)
- s[r].getObjectsByProperty(e, t, i);
- return i;
- }
- /**
- * Returns a vector representing the position of the 3D object in world space.
- *
- * @param {Vector3} target - The target vector the result is stored to.
- * @return {Vector3} The 3D object's position in world space.
- */
- getWorldPosition(e) {
- return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld);
- }
- /**
- * Returns a Quaternion representing the position of the 3D object in world space.
- *
- * @param {Quaternion} target - The target Quaternion the result is stored to.
- * @return {Quaternion} The 3D object's rotation in world space.
- */
- getWorldQuaternion(e) {
- return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(un, e, ud), e;
- }
- /**
- * Returns a vector representing the scale of the 3D object in world space.
- *
- * @param {Vector3} target - The target vector the result is stored to.
- * @return {Vector3} The 3D object's scale in world space.
- */
- getWorldScale(e) {
- return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(un, dd, e), e;
- }
- /**
- * Returns a vector representing the ("look") direction of the 3D object in world space.
- *
- * @param {Vector3} target - The target vector the result is stored to.
- * @return {Vector3} The 3D object's direction in world space.
- */
- getWorldDirection(e) {
- this.updateWorldMatrix(!0, !1);
- const t = this.matrixWorld.elements;
- return e.set(t[8], t[9], t[10]).normalize();
- }
- /**
- * Abstract method to get intersections between a casted ray and this
- * 3D object. Renderable 3D objects such as {@link Mesh}, {@link Line} or {@link Points}
- * implement this method in order to use raycasting.
- *
- * @abstract
- * @param {Raycaster} raycaster - The raycaster.
- * @param {Array