1//#region viewer_src/camera_models.ts 2var e = [ 3 "SIMPLE_PINHOLE", 4 "PINHOLE", 5 "SIMPLE_RADIAL", 6 "RADIAL", 7 "OPENCV", 8 "OPENCV_FISHEYE", 9 "FULL_OPENCV", 10 "FOV", 11 "SIMPLE_RADIAL_FISHEYE", 12 "RADIAL_FISHEYE", 13 "THIN_PRISM_FISHEYE", 14 "RAD_TAN_THIN_PRISM_FISHEYE", 15 "SIMPLE_DIVISION", 16 "DIVISION", 17 "SIMPLE_FISHEYE", 18 "FISHEYE", 19 "EUCM", 20 "EQUIRECTANGULAR" 21], t = [ 22 3, 23 4, 24 4, 25 5, 26 8, 27 8, 28 12, 29 5, 30 4, 31 5, 32 12, 33 16, 34 4, 35 5, 36 3, 37 4, 38 6, 39 2 40]; 41function n(e, t) { 42 let n = Math.hypot(e, t); 43 if (n <= 2 ** -52) return [e, t]; 44 let r = Math.atan(n) / n; 45 return [e * r, t * r]; 46} 47function r(e, t, n) { 48 let r = e * e + t * t, i = r, a = 1; 49 for (let e of n) a += e * i, i *= r; 50 return [e * a, t * a]; 51} 52function i(e, t, n) { 53 return n ? [e[0] * t[0] + e[1], e[0] * t[1] + e[2]] : [e[0] * t[0] + e[2], e[1] * t[1] + e[3]]; 54} 55function a(e, t, n) { 56 let [r = 0, i = 0, a = 0, o = 0] = n, s = e * e, c = t * t, l = e * t, u = s + c, d = 1 + r * u + i * u * u; 57 return [e * d + 2 * a * l + o * (u + 2 * s), t * d + 2 * o * l + a * (u + 2 * c)]; 58} 59function o(e, t, n) { 60 let [r = 0, i = 0, a = 0, o = 0, s = 0, c = 0, l = 0, u = 0] = n, d = e * e, f = t * t, p = e * t, m = d + f, h = m * m, g = h * m, _ = (1 + r * m + i * h + s * g) / (1 + c * m + l * h + u * g); 61 return [e * _ + 2 * a * p + o * (m + 2 * d), t * _ + 2 * o * p + a * (m + 2 * f)]; 62} 63function s(e, t, n) { 64 let [r = 0, i = 0, a = 0, o = 0, s = 0, c = 0, l = 0, u = 0] = n, d = e * e, f = t * t, p = e * t, m = d + f, h = m * m, g = 1 + r * m + i * h + s * h * m + c * h * h; 65 return [e * g + 2 * a * p + o * (m + 2 * d) + l * m, t * g + 2 * o * p + a * (m + 2 * f) + u * m]; 66} 67function c(e, t, n) { 68 let r = e * e + t * t, i = r, a = 1; 69 for (let e = 0; e < 6; ++e) a += (n[e] ?? 0) * i, i *= r; 70 let o = e * a, s = t * a, c = o * o, l = s * s, u = o * s, d = c + l, f = d * d, p = n[6] ?? 0, m = n[7] ?? 0; 71 return [o + 2 * m * u + p * (d + 2 * c) + (n[8] ?? 0) * d + (n[9] ?? 0) * f, s + 2 * p * u + m * (d + 2 * l) + (n[10] ?? 0) * d + (n[11] ?? 0) * f]; 72} 73function l(e, t) { 74 let [l, u, d] = t, f = e.params, p = e.modelId; 75 if (p === 17) { 76 let e = Math.hypot(l, d); 77 if (e + Math.abs(u) < 2 ** -52) return null; 78 let t = Math.atan2(l, d), n = Math.atan2(-u, e); 79 return [(t / (2 * Math.PI) + .5) * f[0], (.5 - n / Math.PI) * f[1]]; 80 } 81 if (d < 2 ** -52) return null; 82 if (p === 12 || p === 13) { 83 let e = f[p === 12 ? 3 : 4], t = d * d - 4 * (l * l + u * u) * e; 84 if (t < 0) return null; 85 let n = 2 / (d + Math.sqrt(t)); 86 return p === 12 ? [f[0] * n * l + f[1], f[0] * n * u + f[2]] : [f[0] * n * l + f[2], f[1] * n * u + f[3]]; 87 } 88 if (p === 16) { 89 let e = f[5] * (l * l + u * u) + d * d; 90 if (e < 0) return null; 91 let t = f[4] * Math.sqrt(e) + (1 - f[4]) * d; 92 return t < 2 ** -52 ? null : [f[0] * l / t + f[2], f[1] * u / t + f[3]]; 93 } 94 if (p === 0) return i(f, [l / d, u / d], !0); 95 if (p === 1) return i(f, [l / d, u / d], !1); 96 if (p === 7) { 97 let e = l / d, t = u / d, n = e * e + t * t, r = f[4], a = r * r, o; 98 if (a < 1e-4) o = a * n / 3 - a / 12 + 1; 99 else if (n < 1e-4) { 100 let e = Math.tan(r / 2); 101 o = -2 * e * (4 * n * e * e - 3) / (3 * r); 102 } else o = Math.atan(Math.sqrt(n) * 2 * Math.tan(r / 2)) / (Math.sqrt(n) * r); 103 return i(f, [o * e, o * t], !1); 104 } 105 let m = [ 106 5, 107 8, 108 9, 109 10, 110 11, 111 14, 112 15 113 ].includes(p) ? n(l / d, u / d) : [l / d, u / d]; 114 switch (p) { 115 case 2: 116 m = r(m[0], m[1], [f[3]]); 117 break; 118 case 3: 119 m = r(m[0], m[1], f.slice(3, 5)); 120 break; 121 case 4: 122 m = a(m[0], m[1], f.slice(4)); 123 break; 124 case 5: 125 m = r(m[0], m[1], f.slice(4, 8)); 126 break; 127 case 6: 128 m = o(m[0], m[1], f.slice(4)); 129 break; 130 case 8: 131 m = r(m[0], m[1], [f[3]]); 132 break; 133 case 9: 134 m = r(m[0], m[1], f.slice(3, 5)); 135 break; 136 case 10: 137 m = s(m[0], m[1], f.slice(4)); 138 break; 139 case 11: 140 m = c(m[0], m[1], f.slice(4)); 141 break; 142 } 143 return [ 144 0, 145 2, 146 3, 147 8, 148 9, 149 14 150 ].includes(p) ? i(f, m, !0) : i(f, m, !1); 151} 152//#endregion 153//#region viewer_src/math.ts 154function u(e, t) { 155 return [ 156 e[0] * t[0] - e[1] * t[1] - e[2] * t[2] - e[3] * t[3], 157 e[0] * t[1] + e[1] * t[0] + e[2] * t[3] - e[3] * t[2], 158 e[0] * t[2] - e[1] * t[3] + e[2] * t[0] + e[3] * t[1], 159 e[0] * t[3] + e[1] * t[2] - e[2] * t[1] + e[3] * t[0] 160 ]; 161} 162function d(e, t) { 163 let [n, r, i, a] = e, o = 2 * (i * t[2] - a * t[1]), s = 2 * (a * t[0] - r * t[2]), c = 2 * (r * t[1] - i * t[0]); 164 return [ 165 t[0] + n * o + i * c - a * s, 166 t[1] + n * s + a * o - r * c, 167 t[2] + n * c + r * s - i * o 168 ]; 169} 170function f(e, t) { 171 let n = d(e.rotation, t.translation); 172 return { 173 rotation: u(e.rotation, t.rotation), 174 translation: [ 175 n[0] + e.translation[0], 176 n[1] + e.translation[1], 177 n[2] + e.translation[2] 178 ] 179 }; 180} 181function p(e, t) { 182 let n = d(e.rotation, t); 183 return [ 184 n[0] + e.translation[0], 185 n[1] + e.translation[1], 186 n[2] + e.translation[2] 187 ]; 188} 189function m(e) { 190 let [t, n, r, i] = e.rotation, a = d([ 191 t, 192 -n, 193 -r, 194 -i 195 ], e.translation); 196 return [ 197 -a[0], 198 -a[1], 199 -a[2] 200 ]; 201} 202function h(e, t) { 203 if (e.length === 0) return 0; 204 let n = [...e].sort((e, t) => e - t), r = Math.min(n.length - 1, Math.max(0, t * (n.length - 1))), i = Math.floor(r), a = Math.ceil(r); 205 return i === a ? n[i] ?? 0 : (n[i] ?? 0) * (a - r) + (n[a] ?? 0
205) * (r - i); 206} 207function g(e) { 208 if (e.length === 0) return 0; 209 let t = [...e].sort((e, t) => e - t), n = Math.floor(t.length / 2); 210 return t.length % 2 ? t[n] ?? 0 : ((t[n - 1] ?? 0) + (t[n] ?? 0)) / 2; 211} 212//#endregion 213//#region viewer_src/parser.ts 214var _ = class { 215 label; 216 view; 217 offset = 0; 218 constructor(e, t) { 219 this.label = t, this.view = new DataView(e); 220 } 221 require(e) { 222 if (e < 0 || this.offset + e > this.view.byteLength) throw Error(`${this.label} is truncated at byte ${this.offset}`); 223 } 224 u8() { 225 return this.require(1), this.view.getUint8(this.offset++); 226 } 227 i32() { 228 this.require(4); 229 let e = this.view.getInt32(this.offset, !0); 230 return this.offset += 4, e; 231 } 232 u32() { 233 this.require(4); 234 let e = this.view.getUint32(this.offset, !0); 235 return this.offset += 4, e; 236 } 237 u64() { 238 this.require(8); 239 let e = this.view.getBigUint64(this.offset, !0); 240 return this.offset += 8, e; 241 } 242 f64() { 243 this.require(8); 244 let e = this.view.getFloat64(this.offset, !0); 245 return this.offset += 8, e; 246 } 247 skip(e) { 248 this.require(e), this.offset += e; 249 } 250 count(e, t = 1) { 251 let n = this.u64(); 252 if (n > BigInt(2 ** 53 - 1)) throw Error(`${this.label} has an invalid ${e}`); 253 let r = Number(n); 254 if (r > Math.floor(this.remaining / t)) throw Error(`${this.label} has an invalid ${e}`); 255 return r; 256 } 257 string() { 258 let e = []; 259 for (;;) { 260 let t = this.u8(); 261 if (t === 0) break; 262 e.push(t); 263 } 264 return new TextDecoder("utf-8", { fatal: !0 }).decode(new Uint8Array(e)); 265 } 266 get remaining() { 267 return this.view.byteLength - this.offset; 268 } 269}; 270function v(e, t) { 271 return `${e}:${t}`; 272} 273function y(e) { 274 return [ 275 e.f64(), 276 e.f64(), 277 e.f64(), 278 e.f64() 279 ]; 280} 281function b(e) { 282 return [ 283 e.f64(), 284 e.f64(), 285 e.f64() 286 ]; 287} 288function x(e) { 289 let t = { 290 rotation: y(e), 291 translation: b(e) 292 }; 293 if (![...t.rotation, ...t.translation].every(Number.isFinite)) throw Error("Reconstruction contains a non-finite pose"); 294 return t; 295} 296function S(e) { 297 let n = new _(e, "cameras.bin"), r = n.count("camera count", 24), i = /* @__PURE__ */ new Map(); 298 for (let e = 0; e < r; ++e) { 299 let e = n.u32(), r = n.i32(), a = t[r]; 300 if (a === void 0) throw Error(`Unsupported camera model id ${r}`); 301 let o = n.u64(), s = n.u64(); 302 if (o > BigInt(2 ** 53 - 1) || s > BigInt(2 ** 53 - 1)) throw Error(`Camera ${e} has invalid dimensions`); 303 let c = Array.from({ length: a }, () => n.f64()); 304 if (o === 0n || s === 0n || !c.every(Number.isFinite)) throw Error(`Camera ${e} has invalid parameters`); 305 i.set(e, { 306 id: e, 307 modelId: r, 308 width: Number(o), 309 height: Number(s), 310 params: c 311 }); 312 } 313 if (n.remaining !== 0) throw Error("cameras.bin contains trailing data"); 314 return i; 315} 316function C(e) { 317 let t = new _(e, "rigs.bin"), n = t.count("rig count", 8), r = /* @__PURE__ */ new Map(); 318 for (let e = 0; e < n; ++e) { 319 let e = t.u32(), n = t.u32(); 320 if (n > t.remaining / 8) throw Error("rigs.bin has an invalid sensor count"); 321 let i = "", a = /* @__PURE__ */ new Map(); 322 n > 0 && (i = v(t.i32(), t.u32()), a.set(i, { 323 rotation: [ 324 1, 325 0, 326 0, 327 0 328 ], 329 translation: [ 330 0, 331 0, 332 0 333 ] 334 })); 335 for (let e = 1; e < n; ++e) { 336 let e = v(t.i32(), t.u32()); 337 a.set(e, t.u8() ? x(t) : null); 338 } 339 r.set(e, { 340 id: e, 341 refSensor: i, 342 sensors: a 343 }); 344 } 345 if (t.remaining !== 0) throw Error("rigs.bin contains trailing data"); 346 return r; 347} 348function w(e) { 349 let t = new _(e, "frames.bin"), n = t.count("frame count", 68), r = /* @__PURE__ */ new Map(); 350 for (let e = 0; e < n; ++e) { 351 let e = t.u32(), n = t.u32(), i = x(t), a = t.u32(); 352 if (a > t.remaining / 16) throw Error("frames.bin has an invalid data count"); 353 let o = Array.from({ length: a }, () => ({ 354 sensor: v(t.i32(), t.u32()), 355 dataId: t.u64() 356 })); 357 r.set(e, { 358 id: e, 359 rigId: n, 360 rigFromWorld: i, 361 data: o 362 }); 363 } 364 if (t.remaining !== 0) throw Error("frames.bin contains trailing data"); 365 return r; 366} 367function T(e, t, n) { 368 let r = new _(e, "images.bin"), i = r.count("image count", 72), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(); 369 if (n) for (let e of n.values()) for (let t of e.data) t.sensor.startsWith("0:") && o.set(t.dataId, e); 370 for (let e = 0; e < i; ++e) { 371 let e = r.u32(), i = x(r), s = r.u32(), c = r.string(), l = r.count("point2D count", 24), u = { 372 xy: new Float64Array(l * 2), 373 point3DIds: new BigUint64Array(l) 374 }; 375 for (let t = 0; t < l; ++t) { 376 let n = r.f64(), i = r.f64(); 377 if (!Number.isFinite(n) || !Number.isFinite(i)) throw Error(`Image ${e} has a non-finite observation`); 378 u.xy[t * 2] = n, u.xy[t * 2 + 1] = i, u.point3DIds[t] = r.u64(); 379 } 380 let d = i, p = e, m = s; 381 if (t && n) { 382 let n = o.get(BigInt(e)); 383 if (!n) throw Error(`No frame contains image ${e}`); 384 let r = t.get(n.rigId); 385 if (!r) throw Error(`Frame ${n.id} references missing rig ${n.rigId}`); 386 let i = r.sensors.get(v(0, s)); 387 if (i === void 0) throw Error(`Rig ${r.id} does not contain camera ${s}`); 388 if (i === null) throw Error(`Rig ${r.id} has no pose for camera ${s}`); 389 d = f(i, n.rigFromWorld), p = n.id, m = r.id; 390 } 391 a.set(e, { 392 id: e, 393 cameraId: s, 394 frameId: p, 395 rigId: m, 396 name: c, 397 camFromWorld: d, 398 points2D: u 399 }); 400 } 401 if (r.remaining !== 0) throw Error("images.bin contains trailing data"); 402 return a; 403} 404function E(e) { 405 let t = new _(e, "points3D.bin"), n = t.count("point3D count", 51); 406 if (n > 4294967295) throw Error("points3D.bin has too many points for this browser"); 407 let r = new BigUint64Array(n), i = new Uint32Array(n), a = 0, o = !0; 408 for (let e = 0; e < n; ++e) { 409 let n = t.u64(); 410 r[e] = n, o &&= e === 0 || r[e - 1] < n, t.skip(35); 411 let s = t.count("track length", 8); 412 if (s > 4294967295 || a + s > 4294967295) throw Error("points3D.bin has too many track elements for this browser"); 413 i[e] = s, a += s, t.skip(s * 8); 414 } 415 if (t.remaining !== 0) throw Error("points3D.bin contains trailing data"); 416 let s = r, c = null, l = null; 417 if (!o) { 418 l = new Uint32Array(n); 419 for (let e = 0; e < n; ++e) l[e] = e; 420 l.sort((e, t) => r[e] < r[t] ? -1 : +(r[e] > r[t])), s = new BigUint64Array(n), c = new Uint32Array(n); 421 for (let e = 0; e < n; ++e) { 422 let t = l[e]; 423 s[e] = r[t], c[t] = e; 424 } 425 } 426 for (let e = 1; e < n; ++e) if (s[e - 1] === s[e]) throw Error(`points3D.bin contains duplicate point id ${s[e]}`); 427 let u = { 428 ids: s, 429 xyz: new Float64Array(n * 3), 430 colors: new Uint8Array(n * 3), 431 errors: new Float32Array(n), 432 trackOffsets: new Uint32Array(n + 1), 433 trackImageIds: new Uint32Array(a), 434 trackPoint2DIdxs: new Uint32Array(a) 435 }; 436 for (let e = 0; e < n; ++e) { 437 let t = l?.[e] ?? e; 438 u.trackOffsets[e + 1] = u.trackOffsets[e] + i[t]; 439 } 440 let d = new _(e, "points3D.bin"); 441 d.count("point3D count", 51); 442 for (let e = 0; e < n; ++e) { 443 let t = c?.[e] ?? e, n = d.u64(), r = b(d), i = [ 444 d.u8(), 445 d.u8(), 446 d.u8()
447 ], a = d.f64(); 448 if (![...r, a].every(Number.isFinite)) throw Error(`Point ${n} contains non-finite values`); 449 u.xyz.set(r, t * 3), u.colors.set(i, t * 3), u.errors[t] = a; 450 let o = d.count("track length", 8), s = u.trackOffsets[t]; 451 for (let e = 0; e < o; ++e, ++s) u.trackImageIds[s] = d.u32(), u.trackPoint2DIdxs[s] = d.u32(); 452 } 453 return u; 454} 455function D(e) { 456 return e.replaceAll("\\", "/").replace(/^\.\//, "").replace(/\/+/g, "/"); 457} 458function O(e) { 459 let t = /* @__PURE__ */ new Map(); 460 for (let n of e) { 461 let e = D(n.path), r = e.lastIndexOf("/"), i = r < 0 ? "." : e.slice(0, r), a = e.slice(r + 1), o = t.get(i) ?? /* @__PURE__ */ new Map(); 462 o.set(a, n.file), t.set(i, o); 463 } 464 return [...t].filter(([, e]) => [ 465 "cameras.bin", 466 "images.bin", 467 "points3D.bin" 468 ].every((t) => e.has(t))).map(([e, t]) => ({ 469 path: e, 470 files: t 471 })).sort((e, t) => e.path.localeCompare(t.path)); 472} 473async function k(e) { 474 for (let t of [ 475 "cameras.bin", 476 "images.bin", 477 "points3D.bin" 478 ]) if (!e.has(t)) throw Error(`Missing ${t}`); 479 let t = e.has("rigs.bin"), n = e.has("frames.bin"); 480 if (t !== n) throw Error("Modern reconstructions require both rigs.bin and frames.bin"); 481 let r = await Promise.all([ 482 e.get("cameras.bin").arrayBuffer(), 483 e.get("images.bin").arrayBuffer(), 484 e.get("points3D.bin").arrayBuffer(), 485 t ? e.get("rigs.bin").arrayBuffer() : Promise.resolve(null), 486 n ? e.get("frames.bin").arrayBuffer() : Promise.resolve(null) 487 ]), i = r[3] ? C(r[3]) : null, a = r[4] ? w(r[4]) : null, o = !!(i && a && (i.size > 0 || a.size > 0)), s = o ? i : null, c = o ? a : null, l = S(r[0]), u = T(r[1], s, c); 488 for (let e of u.values()) if (!l.has(e.cameraId)) throw Error(`Image ${e.id} references missing camera ${e.cameraId}`); 489 return { 490 cameras: l, 491 images: u, 492 points3D: E(r[2]), 493 modernRigFormat: o 494 }; 495} 496function A(e) { 497 return e.points2D.point3DIds.length; 498} 499function ee(e, t) { 500 if (t < 0 || t >= A(e)) return; 501 let n = e.points2D.point3DIds[t]; 502 return { 503 xy: [e.points2D.xy[t * 2], e.points2D.xy[t * 2 + 1]], 504 point3DId: n === 18446744073709551615n ? null : n 505 }; 506} 507function te(e) { 508 return e.ids.length; 509} 510function j(e, t) { 511 return e.trackOffsets[t + 1] - e.trackOffsets[t]; 512} 513function ne(e, t) { 514 if (t < 0 || t >= te(e)) throw RangeError(`Invalid 3D point index ${t}`); 515 let n = Array.from({ length: j(e, t) }, (n, r) => { 516 let i = e.trackOffsets[t] + r; 517 return { 518 imageId: e.trackImageIds[i], 519 point2DIdx: e.trackPoint2DIdxs[i] 520 }; 521 }); 522 return { 523 id: e.ids[t], 524 xyz: [ 525 e.xyz[t * 3], 526 e.xyz[t * 3 + 1], 527 e.xyz[t * 3 + 2] 528 ], 529 color: [ 530 e.colors[t * 3], 531 e.colors[t * 3 + 1], 532 e.colors[t * 3 + 2] 533 ], 534 error: e.errors[t], 535 track: n 536 }; 537} 538function re(e, t) { 539 let n = 0, r = e.ids.length; 540 for (; n < r;) { 541 let i = n + Math.floor((r - n) / 2); 542 e.ids[i] < t ? n = i + 1 : r = i; 543 } 544 return n < e.ids.length && e.ids[n] === t ? n : -1; 545} 546var M = { 547 LEFT: 0, 548 MIDDLE: 1, 549 RIGHT: 2, 550 ROTATE: 0, 551 DOLLY: 1, 552 PAN: 2 553}, ie = { 554 ROTATE: 0, 555 PAN: 1, 556 DOLLY_PAN: 2, 557 DOLLY_ROTATE: 3 558}, ae = 1e3, oe = 1001, se = 1002, N = 1003, ce = 1004, le = 1005, P = 1006, ue = 1007, de = 1008, fe = 1009, pe = 1010, me = 1011, he = 1012, ge = 1013, _e = 1014, ve = 1015, ye = 1016, be = 1017, xe = 1018, Se = 1020, Ce = 35902, we = 35899, Te = 1021, Ee = 1022, De = 1023, Oe = 1026, ke = 1027, Ae = 1028, je = 1029, F = 1030, Me = 1031, Ne = 1033, Pe = 33776, I = 33777, Fe = 33778, L = 33779, Ie = 35840, R = 35841, z = 35842, Le = 35843, Re = 36196, ze = 37492, Be = 37496, Ve = 37488, He = 37489, Ue = 37490, We = 37491, Ge = 37808, Ke = 37809, qe = 37810, Je = 37811, Ye = 37812, Xe = 37813, Ze = 37814, Qe = 37815, $e = 37816, et = 37817, tt = 37818, nt = 37819, rt = 37820, it = 37821, at = 36492, ot = 36494, st = 36495, ct = 36283, lt = 36284, ut = 36285, dt = 36286, ft = 2300, pt = 2301, mt = 2302, ht = 2303, gt = 2400, _t = 2401, vt = 2402, yt = 3200, bt = "srgb", xt = "srgb-linear", St = "linear", Ct = "srgb", wt = 7680, Tt = 35044, Et = 2e3; 559function Dt(e) { 560 for (let t = e.length - 1; t >= 0; --t) if (e[t] >= 65535) return !0; 561 return !1; 562} 563function Ot(e) { 564 return ArrayBuffer.isView(e) && !(e instanceof DataView); 565} 566function kt(e) { 567 return document.createElementNS("http://www.w3.org/1999/xhtml", e); 568} 569function At() { 570 let e = kt("canvas"); 571 return e.style.display = "block", e; 572} 573var jt = {}; 574function Mt(...e) { 575 let t = "THREE." + e.shift(); 576 console.log(t, ...e); 577} 578function Nt(e) { 579 let t = e[0]; 580 if (typeof t == "string" && t.startsWith("TSL:")) { 581 let t = e[1]; 582 t && t.isStackTrace ? e[0] += " " + t.getLocation() : e[1] = "Stack trace not available. Enable \"THREE.Node.captureStackTrace\" to capture stack traces."; 583 } 584 return e; 585} 586function B(...e) { 587 e = Nt(e); 588 let t = "THREE." + e.shift(); 589 { 590 let n = e[0]; 591 n && n.isStackTrace ? console.warn(n.getError(t)) : console.warn(t, ...e); 592 } 593} 594function V(...e) { 595 e = Nt(e); 596 let t = "THREE." + e.shift(); 597 { 598 let n = e[0]; 599 n && n.isStackTrace ? console.error(n.getError(t)) : console.error(t, ...e); 600 } 601} 602function Pt(...e) { 603 let t = e.join(" "); 604 t in jt || (jt[t] = !0, B(...e)); 605} 606function Ft(e, t, n) { 607 return new Promise(function(r, i) { 608 function a() {
609 switch (e.clientWaitSync(t, e.SYNC_FLUSH_COMMANDS_BIT, 0)) { 610 case e.WAIT_FAILED: 611 i(); 612 break; 613 case e.TIMEOUT_EXPIRED: 614 setTimeout(a, n); 615 break; 616 default: r(); 617 } 618 } 619 setTimeout(a, n); 620 }); 621} 622var It = { 623 0: 1, 624 2: 6, 625 4: 7, 626 3: 5, 627 1: 0, 628 6: 2, 629 7: 4, 630 5: 3 631}, Lt = class { 632 addEventListener(e, t) { 633 this._listeners === void 0 && (this._listeners = {}); 634 let n = this._listeners; 635 n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t); 636 } 637 hasEventListener(e, t) { 638 let n = this._listeners; 639 return n !== void 0 && n[e] !== void 0 && n[e].indexOf(t) !== -1; 640 } 641 removeEventListener(e, t) { 642 let n = this._listeners; 643 if (n === void 0) return; 644 let r = n[e]; 645 if (r !== void 0) { 646 let e = r.indexOf(t); 647 e !== -1 && r.splice(e, 1); 648 } 649 } 650 dispatchEvent(e) { 651 let t = this._listeners; 652 if (t === void 0) return; 653 let n = t[e.type]; 654 if (n !== void 0) { 655 e.target = this; 656 let t = n.slice(0); 657 for (let n = 0, r = t.length; n < r; n++) t[n].call(this, e); 658 e.target = null; 659 } 660 } 661}, Rt = /* @__PURE__ */ "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".split("."), zt = 1234567, Bt = Math.PI / 180, Vt = 180 / Math.PI; 662function Ht() { 663 let e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0; 664 return (Rt[e & 255] + Rt[e >> 8 & 255] + Rt[e >> 16 & 255] + Rt[e >> 24 & 255] + "-" + Rt[t & 255] + Rt[t >> 8 & 255] + "-" + Rt[t >> 16 & 15 | 64] + Rt[t >> 24 & 255] + "-" + Rt[n & 63 | 128] + Rt[n >> 8 & 255] + "-" + Rt[n >> 16 & 255] + Rt[n >> 24 & 255] + Rt[r & 255] + Rt[r >> 8 & 255] + Rt[r >> 16 & 255] + Rt[r >> 24 & 255]).toLowerCase(); 665} 666function H(e, t, n) { 667 return Math.max(t, Math.min(n, e)); 668} 669function Ut(e, t) { 670 return (e % t + t) % t; 671} 672function Wt(e, t, n, r, i) { 673 return r + (e - t) * (i - r) / (n - t); 674} 675function Gt(e, t, n) { 676 return e === t ? 0 : (n - e) / (t - e); 677} 678function Kt(e, t, n) { 679 return (1 - n) * e + n * t; 680} 681function qt(e, t, n, r) { 682 return Kt(e, t, 1 - Math.exp(-n * r)); 683} 684function Jt(e, t = 1) { 685 return t - Math.abs(Ut(e, t * 2) - t); 686} 687function Yt(e, t, n) { 688 return e <= t ? 0 : e >= n ? 1 : (e = (e - t) / (n - t), e * e * (3 - 2 * e)); 689} 690function Xt(e, t, n) { 691 return e <= t ? 0 : e >= n ? 1 : (e = (e - t) / (n - t), e * e * e * (e * (e * 6 - 15) + 10)); 692} 693function Zt(e, t) { 694 return e + Math.floor(Math.random() * (t - e + 1)); 695} 696function Qt(e, t) { 697 return e + Math.random() * (t - e); 698} 699function $t(e) { 700 return e * (.5 - Math.random()); 701} 702function en(e) { 703 e !== void 0 && (zt = e); 704 let t = zt += 1831565813; 705 return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296; 706} 707function tn(e) { 708 return e * Bt; 709} 710function nn(e) { 711 return e * Vt; 712} 713function rn(e) { 714 return (e & e - 1) == 0 && e !== 0; 715} 716function an(e) { 717 return 2 ** Math.ceil(Math.log(e) / Math.LN2); 718} 719function on(e) { 720 return 2 ** Math.floor(Math.log(e) / Math.LN2); 721} 722function sn(e, t, n, r, i) { 723 let a = Math.cos, o = Math.sin, s = a(n / 2), c = o(n / 2), l = a((t + r) / 2), u = o((t + r) / 2), d = a((t - r) / 2), f = o((t - r) / 2), p = a((r - t) / 2), m = o((r - t) / 2); 724 switch (i) { 725 case "XYX": 726 e.set(s * u, c * d, c * f, s * l); 727 break; 728 case "YZY": 729 e.set(c * f, s * u, c * d, s * l); 730 break; 731 case "ZXZ": 732 e.set(c * d, c * f, s * u, s * l); 733 break; 734 case "XZX": 735 e.set(s * u, c * m, c * p, s * l); 736 break; 737 case "YXY": 738 e.set(c * p, s * u, c * m, s * l); 739 break; 740 case "ZYZ": 741 e.set(c * m, c * p, s * u, s * l); 742 break; 743 default: B("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: " + i); 744 } 745} 746function cn(e, t) { 747 switch (t.constructor) { 748 case Float32Array: return e; 749 case Uint32Array: return e / 4294967295; 750 case Uint16Array: return e / 65535; 751 case Uint8Array: return e / 255; 752 case Int32Array: return Math.max(e / 2147483647, -1); 753 case Int16Array: return Math.max(e / 32767, -1); 754 case Int8Array: return Math.max(e / 127, -1); 755 default: throw Error("THREE.MathUtils: Invalid component type."); 756 } 757} 758function U(e, t) { 759 switch (t.constructor) { 760 case Float32Array: return e; 761 case Uint32Array: return Math.round(e * 4294967295); 762 case Uint16Array: return Math.round(e * 65535); 763 case Uint8Array: return Math.round(e * 255); 764 case Int32Array: return Math.round(e * 2147483647); 765 case Int16Array: return Math.round(e * 32767); 766 case Int8Array: return Math.round(e * 127); 767 default: throw Error("THREE.MathUtils: Invalid component type."); 768 } 769} 770var ln = { 771 DEG2RAD: Bt, 772 RAD2DEG: Vt, 773 generateUUID: Ht, 774 clamp: H, 775 euclideanModulo: Ut, 776 mapLinear: Wt, 777 inverseLerp: Gt, 778 lerp: Kt, 779 damp: qt, 780 pingpong: Jt, 781 smoothstep: Yt, 782 smootherstep: Xt, 783 randInt: Zt, 784 randFloat: Qt, 785 randFloatSpread: $t, 786 seededRandom: en, 787 degToRad: tn, 788 radToDeg: nn, 789 isPowerOfTwo: rn, 790 ceilPowerOfTwo: an, 791 floorPowerOfTwo: on, 792 setQuaternionFromProperEuler: sn, 793 normalize: U, 794 denormalize: cn 795}, W = class e { 796 static { 797 e.prototype.isVector2 = !0; 798 } 799 constructor(e = 0, t = 0) { 800 this.x = e, this.y = t; 801 } 802 get width() { 803 return this.x; 804 } 805 set width(e) { 806 this.x = e; 807 } 808 get height() { 809 return this.y; 810 } 811 set height(e) { 812 this.y = e; 813 } 814 set(e, t) { 815 return this.x = e, this.y = t, this; 816 } 817 setScalar(e) { 818 return this.x = e, this.y = e, this; 819 } 820 setX(e) { 821 return this.x = e, this; 822 } 823 setY(e) { 824 return this.y = e, this; 825 } 826 setComponent(e, t) { 827 switch (e) { 828 case 0: 829 this.x = t; 830 break; 831 case 1: 832 this.y = t; 833 break; 834 default: throw Error("THREE.Vector2: index is out of range: " + e); 835 } 836 return this; 837 } 838 getComponent(e) { 839 switch (e) { 840 case 0: return this.x; 841 case 1: return this.y; 842 default: throw Error("THREE.Vector2: index is out of range: " + e); 843 } 844 } 845 clone() { 846 return new this.constructor(this.x, this.y); 847 } 848 copy(e) { 849 return this.x = e.x, this.y = e.y, this; 850 } 851 add(e) { 852 return this.x += e.x, this.y += e.y, this; 853 } 854 addScalar(e) { 855 return this.x += e, this.y += e, this; 856 } 857 addVectors(e, t) { 858 return this.x = e.x + t.x, this.y = e.y + t.y, this; 859 } 860 addScaledVector(e, t) { 861 return this.x += e.x * t, this.y += e.y * t, this; 862 } 863 sub(e) { 864 return this.x -= e.x, this.y -= e.y, this; 865 } 866 subScalar(e) { 867 return this.x -= e, this.y -= e, this; 868 } 869 subVectors(e, t) {
870 return this.x = e.x - t.x, this.y = e.y - t.y, this; 871 } 872 multiply(e) { 873 return this.x *= e.x, this.y *= e.y, this; 874 } 875 multiplyScalar(e) { 876 return this.x *= e, this.y *= e, this; 877 } 878 divide(e) { 879 return this.x /= e.x, this.y /= e.y, this; 880 } 881 divideScalar(e) { 882 return this.multiplyScalar(1 / e); 883 } 884 applyMatrix3(e) { 885 let t = this.x, n = this.y, r = e.elements; 886 return this.x = r[0] * t + r[3] * n + r[6], this.y = r[1] * t + r[4] * n + r[7], this; 887 } 888 min(e) { 889 return this.x = Math.min(this.x, e.x), this.y = Math.min(this.y, e.y), this; 890 } 891 max(e) { 892 return this.x = Math.max(this.x, e.x), this.y = Math.max(this.y, e.y), this; 893 } 894 clamp(e, t) { 895 return this.x = H(this.x, e.x, t.x), this.y = H(this.y, e.y, t.y), this; 896 } 897 clampScalar(e, t) { 898 return this.x = H(this.x, e, t), this.y = H(this.y, e, t), this; 899 } 900 clampLength(e, t) { 901 let n = this.length(); 902 return this.divideScalar(n || 1).multiplyScalar(H(n, e, t)); 903 } 904 floor() { 905 return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this; 906 } 907 ceil() { 908 return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this; 909 } 910 round() { 911 return this.x = Math.round(this.x), this.y = Math.round(this.y), this; 912 } 913 roundToZero() { 914 return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this; 915 } 916 negate() { 917 return this.x = -this.x, this.y = -this.y, this; 918 } 919 dot(e) { 920 return this.x * e.x + this.y * e.y; 921 } 922 cross(e) { 923 return this.x * e.y - this.y * e.x; 924 } 925 lengthSq() { 926 return this.x * this.x + this.y * this.y; 927 } 928 length() { 929 return Math.sqrt(this.x * this.x + this.y * this.y); 930 } 931 manhattanLength() { 932 return Math.abs(this.x) + Math.abs(this.y); 933 } 934 normalize() { 935 return this.divideScalar(this.length() || 1); 936 } 937 angle() { 938 return Math.atan2(-this.y, -this.x) + Math.PI; 939 } 940 angleTo(e) { 941 let t = Math.sqrt(this.lengthSq() * e.lengthSq()); 942 if (t === 0) return Math.PI / 2; 943 let n = this.dot(e) / t; 944 return Math.acos(H(n, -1, 1)); 945 } 946 distanceTo(e) { 947 return Math.sqrt(this.distanceToSquared(e)); 948 } 949 distanceToSquared(e) { 950 let t = this.x - e.x, n = this.y - e.y; 951 return t * t + n * n; 952 } 953 manhattanDistanceTo(e) { 954 return Math.abs(this.x - e.x) + Math.abs(this.y - e.y); 955 } 956 setLength(e) { 957 return this.normalize().multiplyScalar(e); 958 } 959 lerp(e, t) { 960 return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this; 961 } 962 lerpVectors(e, t, n) { 963 return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this; 964 } 965 equals(e) { 966 return e.x === this.x && e.y === this.y; 967 } 968 fromArray(e, t = 0) { 969 return this.x = e[t], this.y = e[t + 1], this; 970 } 971 toArray(e = [], t = 0) { 972 return e[t] = this.x, e[t + 1] = this.y, e; 973 } 974 fromBufferAttribute(e, t) { 975 return this.x = e.getX(t), this.y = e.getY(t), this; 976 } 977 rotateAround(e, t) { 978 let n = Math.cos(t), r = Math.sin(t), i = this.x - e.x, a = this.y - e.y; 979 return this.x = i * n - a * r + e.x, this.y = i * r + a * n + e.y, this; 980 } 981 random() { 982 return this.x = Math.random(), this.y = Math.random(), this; 983 } 984 *[Symbol.iterator]() { 985 yield this.x, yield this.y; 986 } 987}, un = class { 988 constructor(e = 0, t = 0, n = 0, r = 1) { 989 this.isQuaternion = !0, this._x = e, this._y = t, this._z = n, this._w = r; 990 } 991 static slerpFlat(e, t, n, r, i, a, o) { 992 let s = n[r + 0], c = n[r + 1], l = n[r + 2], u = n[r + 3], d = i[a + 0], f = i[a + 1], p = i[a + 2], m = i[a + 3]; 993 if (u !== m || s !== d || c !== f || l !== p) { 994 let e = s * d + c * f + l * p + u * m; 995 e < 0 && (d = -d, f = -f, p = -p, m = -m, e = -e); 996 let t = 1 - o; 997 if (e < .9995) { 998 let n = Math.acos(e), r = Math.sin(n); 999 t = Math.sin(t * n) / r, o = Math.sin(o * n) / r, s = s * t + d * o, c = c * t + f * o, l = l * t + p * o, u = u * t + m * o; 1000 } else { 1001 s = s * t + d * o, c = c * t + f * o, l = l * t + p * o, u = u * t + m * o; 1002 let e = 1 / Math.sqrt(s * s + c * c + l * l + u * u); 1003 s *= e, c *= e, l *= e, u *= e; 1004 } 1005 } 1006 e[t] = s, e[t + 1] = c, e[t + 2] = l, e[t + 3] = u; 1007 } 1008 static multiplyQuaternionsFlat(e, t, n, r, i, a) { 1009 let o = n[r], s = n[r + 1], c = n[r + 2], l = n[r + 3], u = i[a], d = i[a + 1], f = i[a + 2], p
1009= i[a + 3]; 1010 return e[t] = o * p + l * u + s * f - c * d, e[t + 1] = s * p + l * d + c * u - o * f, e[t + 2] = c * p + l * f + o * d - s * u, e[t + 3] = l * p - o * u - s * d - c * f, e; 1011 } 1012 get x() { 1013 return this._x; 1014 } 1015 set x(e) { 1016 this._x = e, this._onChangeCallback(); 1017 } 1018 get y() { 1019 return this._y; 1020 } 1021 set y(e) { 1022 this._y = e, this._onChangeCallback(); 1023 } 1024 get z() { 1025 return this._z; 1026 } 1027 set z(e) { 1028 this._z = e, this._onChangeCallback(); 1029 } 1030 get w() { 1031 return this._w; 1032 } 1033 set w(e) { 1034 this._w = e, this._onChangeCallback(); 1035 } 1036 set(e, t, n, r) { 1037 return this._x = e, this._y = t, this._z = n, this._w = r, this._onChangeCallback(), this; 1038 } 1039 clone() { 1040 return new this.constructor(this._x, this._y, this._z, this._w); 1041 } 1042 copy(e) { 1043 return this._x = e.x, this._y = e.y, this._z = e.z, this._w = e.w, this._onChangeCallback(), this; 1044 } 1045 setFromEuler(e, t = !0) { 1046 let n = e._x, r = e._y, i = e._z, a = e._order, o = Math.cos, s = Math.sin, c = o(n / 2), l = o(r / 2), u = o(i / 2), d = s(n / 2), f = s(r / 2), p = s(i / 2); 1047 switch (a) { 1048 case "XYZ": 1049 this._x = d * l * u + c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u - d * f * p; 1050 break; 1051 case "YXZ": 1052 this._x = d * l * u + c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u + d * f * p; 1053 break; 1054 case "ZXY": 1055 this._x = d * l * u - c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u - d * f * p; 1056 break; 1057 case "ZYX": 1058 this._x = d * l * u - c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u + d * f * p; 1059 break; 1060 case "YZX": 1061 this._x = d * l * u + c * f * p, this._y = c * f * u + d * l * p, this._z = c * l * p - d * f * u, this._w = c * l * u - d * f * p; 1062 break; 1063 case "XZY": 1064 this._x = d * l * u - c * f * p, this._y = c * f * u - d * l * p, this._z = c * l * p + d * f * u, this._w = c * l * u + d * f * p; 1065 break; 1066 default: B("Quaternion: .setFromEuler() encountered an unknown order: " + a); 1067 } 1068 return t === !0 && this._onChangeCallback(), this; 1069 } 1070 setFromAxisAngle(e, t) { 1071 let n = t / 2, r = Math.sin(n); 1072 return this._x = e.x * r, this._y = e.y * r, this._z = e.z * r, this._w = Math.cos(n), this._onChangeCallback(), this; 1073 } 1074 setFromRotationMatrix(e) { 1075 let t = e.elements, n = t[0], r = t[4], i = t[8], a = t[1], o = t[5], s = t[9], c = t[2], l = t[6], u = t[10], d = n + o + u; 1076 if (d > 0) { 1077 let e = .5 / Math.sqrt(d + 1); 1078 this._w = .25 / e, this._x = (l - s) * e, this._y = (i - c) * e, this._z = (a - r) * e; 1079 } else if (n > o && n > u) { 1080 let e = 2 * Math.sqrt(1 + n - o - u); 1081 this._w = (l - s) / e, this._x = .25 * e, this._y = (r + a) / e, this._z = (i + c) / e; 1082 } else if (o > u) { 1083 let e = 2 * Math.sqrt(1 + o - n - u); 1084 this._w = (i - c) / e, this._x = (r + a) / e, this._y = .25 * e, this._z = (s + l) / e; 1085 } else { 1086 let e = 2 * Math.sqrt(1 + u - n - o); 1087 this._w = (a - r) / e, this._x = (i + c) / e, this._y = (s + l) / e, this._z = .25 * e; 1088 } 1089 return this._onChangeCallback(), this; 1090 } 1091 setFromUnitVectors(e, t) { 1092 let n = e.dot(t) + 1; 1093 return n < 1e-8 ? (n = 0, Math.abs(e.x) > Math.abs(e.z) ? (this._x = -e.y, this._y = e.x, this._z = 0, this._w = n) : (this._x = 0, this._y = -e.z, this._z = e.y, this._w = n)) : (this._x = e.y * t.z - e.z * t.y, this._y = e.z * t.x - e.x * t.z, this._z = e.x * t.y - e.y * t.x, this._w = n), this.normalize(); 1094 } 1095 angleTo(e) { 1096 return 2 * Math.acos(Math.abs(H(this.dot(e), -1, 1))); 1097 } 1098 rotateTowards(e, t) { 1099 let n = this.angleTo(e); 1100 if (n === 0) return this; 1101 let r = Math.min(1, t / n); 1102 return this.slerp(e, r), this; 1103 } 1104 identity() { 1105 return this.set(0, 0, 0, 1); 1106 } 1107 invert() { 1108 return this.conjugate(); 1109 } 1110 conjugate() { 1111 return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this; 1112 } 1113 dot(e) { 1114 return this._x * e._x + this._y * e._y + this._z * e._z + this._w * e._w; 1115 } 1116 lengthSq() { 1117 return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w; 1118 } 1119 length() { 1120 return Math.sqrt(this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w); 1121 } 1122 normalize() { 1123 let e = this.length(); 1124 return e === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (e = 1 / e, this._x *= e, this._y *= e, this._z *= e, this._w *= e), this._onChangeCallback(), this; 1125 } 1126 multiply(e) { 1127 return this.multiplyQuaternions(this, e); 1128 } 1129 premultiply(e) { 1130 return this.multiplyQuaternions(e, this); 1131 } 1132 multiplyQuaternions(e, t) { 1133 let n = e._x, r = e._y, i = e._z, a = e._w, o = t._x, s = t._y, c = t._z, l = t._w; 1134 return this._x = n * l + a * o + r * c - i * s, this._y = r * l + a * s + i * o - n * c, this._z = i * l + a * c + n * s - r * o, this._w = a * l - n * o - r * s - i * c, this._onChangeCallback(), this; 1135 } 1136 slerp(e, t) { 1137 let n = e._x, r = e._y, i = e._z, a = e._w, o = this.dot(e); 1138 o < 0 && (n = -n, r = -r, i = -i, a = -a, o = -o); 1139 let s = 1 - t; 1140 if (o < .9995) { 1141 let e = Math.acos(o), c = Math.sin(e); 1142 s = Math.sin(s * e) / c, t = Math.sin(t * e) / c, this._x = this._x * s + n * t, this._y = this._y * s + r * t, this._z = this._z * s + i * t, this._w = this._w * s + a * t, this._onChangeCallback(); 1143 } else this._x = this._x * s + n * t, this._y = this._y * s + r * t, this._z = this._z * s + i * t, this._w = this._w * s + a * t, this.normalize(); 1144 return this; 1145 } 1146 slerpQuaternions(e, t, n) { 1147 return this.copy(e).slerp(t, n); 1148 } 1149 random() { 1150 let e = 2 * Math.PI * Math.random(), t = 2 * Math.PI * Math.random(), n = Math.random(), r = Math.sqrt(1 - n), i = Math.sqrt(n); 1151 return this.set(r * Math.sin(e), r * Math.cos(e), i * Math.sin(t), i * Math.cos(t)); 1152 } 1153 equals(e) { 1154 return e._x === this._x && e._y === this._y && e._z === this._z && e._w === this._w; 1155 } 1156 fromArray(e, t = 0) { 1157 return this._x = e[t], this._y = e[t + 1], this._z = e[t + 2], this._w = e[t + 3], this._onChangeCallback(), this; 1158 } 1159 toArray(e = [], t = 0) { 1160 return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._w, e; 1161 } 1162 fromBufferAttribute(e, t) { 1163 return this._x = e.getX(t), this._y = e.getY(t), this._z = e.getZ(t), this._w = e.getW(t), this._onChangeCallback(), this; 1164 } 1165 toJSON() { 1166 return this.toArray(); 1167 } 1168 _onChange(e) { 1169 return this._onChangeCallback = e, this; 1170 } 1171 _onChangeCallback() {} 1172 *[Symbol.iterator]() { 1173 yield this._x, yield this._y, yield this._z, yield this._w; 1174 } 1175}, G = class e { 1176 static { 1177 e.prototype.isVector3 = !0; 1178 } 1179 constructor(e = 0, t = 0, n = 0) { 1180 this.x = e, this.y = t, this.z = n; 1181 } 1182 set(e, t, n) { 1183 return n === void 0 && (n = this.z), this.x = e, this.y = t, this.z = n, this; 1184 } 1185 setScalar(e) { 1186 return this.x = e, this.y = e, this.z = e, this; 1187 } 1188 setX(e) { 1189 return this.x = e, this; 1190 } 1191 setY(e) { 1192 return this.y = e, this; 1193 } 1194 setZ(e) { 1195 return this.z = e, this; 1196 } 1197 setComponent(e, t) { 1198 switch (e) { 1199 case 0: 1200 this.x = t; 1201 break; 1202 case 1: 1203 this.y = t; 1204 break; 1205 case 2: 1206 this.z = t; 1207 break; 1208 default: throw Error("THREE.Vector3: index is out of range: " + e); 1209 } 1210 return this; 1211 } 1212 getComponent(e) { 1213 switch (e) { 1214 case 0: return this.x; 1215 case 1: return this.y; 1216 case 2: return this.z; 1217 default: throw Error("THREE.Vector3: index is out of range: " + e); 1218 } 1219 } 1220 clone() { 1221 return new this.constructor(this.x, this.y, this.z); 1222 } 1223 copy(e) { 1224 return this.x = e.x, this.y = e.y, this.z = e.z, this; 1225 } 1226 add(e) { 1227 return this.x += e.x, this.y += e.y, this.z += e.z, this; 1228 } 1229 addScalar(e) { 1230 return this.x += e, this.y += e, this.z += e, this; 1231 } 1232 addVectors(e, t) { 1233 return this.x = e.x + t.x, this.y = e.y + t.y, this.z = e.z + t.z, this; 1234 } 1235 addScaledVector(e, t) { 1236 return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this; 1237 } 1238 sub(e) { 1239 return this.x -= e.x, this.y -= e.y, this.z -= e.z, this; 1240 } 1241 subScalar(e) { 1242 return this.x -= e, this.y -= e, this.z -= e, this; 1243 } 1244 subVectors(e, t) {
vendor: 9,971 bytes, lines 1245-1513
1245 return this.x = e.x - t.x, this.y = e.y - t.y, this.z = e.z - t.z, this; 1246 } 1247 multiply(e) { 1248 return this.x *= e.x, this.y *= e.y, this.z *= e.z, this; 1249 } 1250 multiplyScalar(e) { 1251 return this.x *= e, this.y *= e, this.z *= e, this; 1252 } 1253 multiplyVectors(e, t) { 1254 return this.x = e.x * t.x, this.y = e.y * t.y, this.z = e.z * t.z, this; 1255 } 1256 applyEuler(e) { 1257 return this.applyQuaternion(fn.setFromEuler(e)); 1258 } 1259 applyAxisAngle(e, t) { 1260 return this.applyQuaternion(fn.setFromAxisAngle(e, t)); 1261 } 1262 applyMatrix3(e) { 1263 let t = this.x, n = this.y, r = this.z, i = e.elements; 1264 return this.x = i[0] * t + i[3] * n + i[6] * r, this.y = i[1] * t + i[4] * n + i[7] * r, this.z = i[2] * t + i[5] * n + i[8] * r, this; 1265 } 1266 applyNormalMatrix(e) { 1267 return this.applyMatrix3(e).normalize(); 1268 } 1269 applyMatrix4(e) { 1270 let t = this.x, n = this.y, r = this.z, i = e.elements, a = 1 / (i[3] * t + i[7] * n + i[11] * r + i[15]); 1271 return this.x = (i[0] * t + i[4] * n + i[8] * r + i[12]) * a, this.y = (i[1] * t + i[5] * n + i[9] * r + i[13]) * a, this.z = (i[2] * t + i[6] * n + i[10] * r + i[14]) * a, this; 1272 } 1273 applyQuaternion(e) { 1274 let t = this.x, n = this.y, r = this.z, i = e.x, a = e.y, o = e.z, s = e.w, c = 2 * (a * r - o * n), l = 2 * (o * t - i * r), u = 2 * (i * n - a * t); 1275 return this.x = t + s * c + a * u - o * l, this.y = n + s * l + o * c - i * u, this.z = r + s * u + i * l - a * c, this; 1276 } 1277 project(e) { 1278 return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix); 1279 } 1280 unproject(e) { 1281 return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld); 1282 } 1283 transformDirection(e) { 1284 let t = this.x, n = this.y, r = this.z, i = e.elements; 1285 return this.x = i[0] * t + i[4] * n + i[8] * r, this.y = i[1] * t + i[5] * n + i[9] * r, this.z = i[2] * t + i[6] * n + i[10] * r, this.normalize(); 1286 } 1287 divide(e) { 1288 return this.x /= e.x, this.y /= e.y, this.z /= e.z, this; 1289 } 1290 divideScalar(e) { 1291 return this.multiplyScalar(1 / e); 1292 } 1293 min(e) { 1294 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; 1295 } 1296 max(e) { 1297 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; 1298 } 1299 clamp(e, t) { 1300 return this.x = H(this.x, e.x, t.x), this.y = H(this.y, e.y, t.y), this.z = H(this.z, e.z, t.z), this; 1301 } 1302 clampScalar(e, t) { 1303 return this.x = H(this.x, e, t), this.y = H(this.y, e, t), this.z = H(this.z, e, t), this; 1304 } 1305 clampLength(e, t) { 1306 let n = this.length(); 1307 return this.divideScalar(n || 1).multiplyScalar(H(n, e, t)); 1308 } 1309 floor() { 1310 return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this; 1311 } 1312 ceil() { 1313 return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this; 1314 } 1315 round() { 1316 return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this; 1317 } 1318 roundToZero() { 1319 return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this; 1320 } 1321 negate() { 1322 return this.x = -this.x, this.y = -this.y, this.z = -this.z, this; 1323 } 1324 dot(e) { 1325 return this.x * e.x + this.y * e.y + this.z * e.z; 1326 } 1327 lengthSq() { 1328 return this.x * this.x + this.y * this.y + this.z * this.z; 1329 } 1330 length() { 1331 return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); 1332 } 1333 manhattanLength() { 1334 return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z); 1335 } 1336 normalize() { 1337 return this.divideScalar(this.length() || 1); 1338 } 1339 setLength(e) { 1340 return this.normalize().multiplyScalar(e); 1341 } 1342 lerp(e, t) { 1343 return this.x += (e.x - this.x) * t, this.y += (e.y - this.y) * t, this.z += (e.z - this.z) * t, this; 1344 } 1345 lerpVectors(e, t, n) { 1346 return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this; 1347 } 1348 cross(e) { 1349 return this.crossVectors(this, e); 1350 } 1351 crossVectors(e, t) { 1352 let n = e.x, r = e.y, i = e.z, a = t.x, o = t.y, s = t.z; 1353 return this.x = r * s - i * o, this.y = i * a - n * s, this.z = n * o - r * a, this; 1354 } 1355 projectOnVector(e) { 1356 let t = e.lengthSq(); 1357 if (t === 0) return this.set(0, 0, 0); 1358 let n = e.dot(this) / t; 1359 return this.copy(e).multiplyScalar(n); 1360 } 1361 projectOnPlane(e) { 1362 return dn.copy(this).projectOnVector(e), this.sub(dn); 1363 } 1364 reflect(e) { 1365 return this.sub(dn.copy(e).multiplyScalar(2 * this.dot(e))); 1366 } 1367 angleTo(e) { 1368 let t = Math.sqrt(this.lengthSq() * e.lengthSq()); 1369 if (t === 0) return Math.PI / 2; 1370 let n = this.dot(e) / t; 1371 return Math.acos(H(n, -1, 1)); 1372 } 1373 distanceTo(e) { 1374 return Math.sqrt(this.distanceToSquared(e)); 1375 } 1376 distanceToSquared(e) { 1377 let t = this.x - e.x, n = this.y - e.y, r = this.z - e.z; 1378 return t * t + n * n + r * r; 1379 } 1380 manhattanDistanceTo(e) { 1381 return Math.abs(this.x - e.x) + Math.abs(this.y - e.y) + Math.abs(this.z - e.z); 1382 } 1383 setFromSpherical(e) { 1384 return this.setFromSphericalCoords(e.radius, e.phi, e.theta); 1385 } 1386 setFromSphericalCoords(e, t, n) { 1387 let r = Math.sin(t) * e; 1388 return this.x = r * Math.sin(n), this.y = Math.cos(t) * e, this.z = r * Math.cos(n), this; 1389 } 1390 setFromCylindrical(e) { 1391 return this.setFromCylindricalCoords(e.radius, e.theta, e.y); 1392 } 1393 setFromCylindricalCoords(e, t, n) { 1394 return this.x = e * Math.sin(t), this.y = n, this.z = e * Math.cos(t), this; 1395 } 1396 setFromMatrixPosition(e) { 1397 let t = e.elements; 1398 return this.x = t[12], this.y = t[13], this.z = t[14], this; 1399 } 1400 setFromMatrixScale(e) { 1401 let t = this.setFromMatrixColumn(e, 0).length(), n = this.setFromMatrixColumn(e, 1).length(), r = this.setFromMatrixColumn(e, 2).length(); 1402 return this.x = t, this.y = n, this.z = r, this; 1403 } 1404 setFromMatrixColumn(e, t) { 1405 return this.fromArray(e.elements, t * 4); 1406 } 1407 setFromMatrix3Column(e, t) { 1408 return this.fromArray(e.elements, t * 3); 1409 } 1410 setFromEuler(e) { 1411 return this.x = e._x, this.y = e._y, this.z = e._z, this; 1412 } 1413 setFromColor(e) { 1414 return this.x = e.r, this.y = e.g, this.z = e.b, this; 1415 } 1416 equals(e) { 1417 return e.x === this.x && e.y === this.y && e.z === this.z; 1418 } 1419 fromArray(e, t = 0) { 1420 return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this; 1421 } 1422 toArray(e = [], t = 0) { 1423 return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e; 1424 } 1425 fromBufferAttribute(e, t) { 1426 return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this; 1427 } 1428 random() { 1429 return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this; 1430 } 1431 randomDirection() { 1432 let e = Math.random() * Math.PI * 2, t = Math.random() * 2 - 1, n = Math.sqrt(1 - t * t); 1433 return this.x = n * Math.cos(e), this.y = t, this.z = n * Math.sin(e), this; 1434 } 1435 *[Symbol.iterator]() { 1436 yield this.x, yield this.y, yield this.z; 1437 } 1438}, dn = /*@__PURE__*/ new G(), fn = /*@__PURE__*/ new un(), K = class e { 1439 static { 1440 e.prototype.isMatrix3 = !0; 1441 } 1442 constructor(e, t, n, r, i, a, o, s, c) { 1443 this.elements = [ 1444 1, 1445 0, 1446 0, 1447 0, 1448 1, 1449 0, 1450 0, 1451 0, 1452 1 1453 ], e !== void 0 && this.set(e, t, n, r, i, a, o, s, c); 1454 } 1455 set(e, t, n, r, i, a, o, s, c) { 1456 let l = this.elements; 1457 return l[0] = e, l[1] = r, l[2] = o, l[3] = t, l[4] = i, l[5] = s, l[6] = n, l[7] = a, l[8] = c, this; 1458 } 1459 identity() { 1460 return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this; 1461 } 1462 copy(e) { 1463 let t = this.elements, n = e.elements; 1464 return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], this; 1465 } 1466 extractBasis(e, t, n) { 1467 return e.setFromMatrix3Column(this, 0), t.setFromMatrix3Column(this, 1), n.setFromMatrix3Column(this, 2), this; 1468 } 1469 setFromMatrix4(e) { 1470 let t = e.elements; 1471 return this.set(t[0], t[4], t[8], t[1], t[5], t[9], t[2], t[6], t[10]), this; 1472 } 1473 multiply(e) { 1474 return this.multiplyMatrices(this, e); 1475 } 1476 premultiply(e) { 1477 return this.multiplyMatrices(e, this); 1478 } 1479 multiplyMatrices(e, t) { 1480 let n = e.elements, r = t.elements, i = this.elements, a = n[0], o = n[3], s = n[6], c = n[1], l = n[4], u = n[7], d = n[2], f = n[5], p = n[8], m = r[0], h = r[3], g = r[6], _ = r[1], v = r[4], y = r[7], b = r[2], x = r[5], S = r[8]; 1481 return i[0] = a * m + o * _ + s * b, i[3] = a * h + o * v + s * x, i[6] = a * g + o * y + s * S, i[1] = c * m + l * _ + u * b, i[4] = c * h + l * v + u * x, i[7] = c * g + l * y + u * S, i[2] = d * m + f * _ + p * b, i[5] = d * h + f * v + p * x, i[8] = d * g + f * y + p * S, this; 1482 } 1483 multiplyScalar(e) { 1484 let t = this.elements; 1485 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; 1486 } 1487 determinant() { 1488 let e = this.elements, t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8]; 1489 return t * a * l - t * o * c - n * i * l + n * o * s + r * i * c - r * a * s; 1490 } 1491 invert() { 1492 let e = this.elements, t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = l * a - o * c, d = o * s - l * i, f = c * i - a * s, p = t * u + n * d + r * f; 1493 if (p === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0); 1494 let m = 1 / p; 1495 return e[0] = u * m, e[1] = (r * c - l * n) * m, e[2] = (o * n - r * a) * m, e[3] = d * m, e[4] = (l * t - r * s) * m, e[5] = (r * i - o * t) * m, e[6] = f * m, e[7] = (n * s - c * t) * m, e[8] = (a * t - n * i) * m, this; 1496 } 1497 transpose() { 1498 let e, t = this.elements; 1499 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; 1500 } 1501 getNormalMatrix(e) { 1502 return this.setFromMatrix4(e).invert().transpose(); 1503 } 1504 transposeIntoArray(e) { 1505 let t = this.elements; 1506 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; 1507 } 1508 setUvTransform(e, t, n, r, i, a, o) { 1509 let s = Math.cos(i), c = Math.sin(i); 1510 return this.set(n * s, n * c, -n * (s * a + c * o) + a + e, -r * c, r * s, -r * (-c * a + s * o) + o + t, 0, 0, 1), this; 1511 } 1512 scale(e, t) { 1513 return Pt("Matrix3: .scale() is deprecated. Use .makeScale() instead."), this.premultiply(
1513pn.makeScale(e, t)), this; 1514 } 1515 rotate(e) { 1516 return Pt("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."), this.premultiply(pn.makeRotation(-e)), this; 1517 } 1518 translate(e, t) { 1519 return Pt("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."), this.premultiply(pn.makeTranslation(e, t)), this; 1520 } 1521 makeTranslation(e, t) { 1522 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; 1523 } 1524 makeRotation(e) { 1525 let t = Math.cos(e), n = Math.sin(e); 1526 return this.set(t, -n, 0, n, t, 0, 0, 0, 1), this; 1527 } 1528 makeScale(e, t) { 1529 return this.set(e, 0, 0, 0, t, 0, 0, 0, 1), this; 1530 } 1531 equals(e) { 1532 let t = this.elements, n = e.elements; 1533 for (let e = 0; e < 9; e++) if (t[e] !== n[e]) return !1; 1534 return !0; 1535 } 1536 fromArray(e, t = 0) { 1537 for (let n = 0; n < 9; n++) this.elements[n] = e[n + t]; 1538 return this; 1539 } 1540 toArray(e = [], t = 0) { 1541 let n = this.elements; 1542 return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e; 1543 } 1544 clone() { 1545 return new this.constructor().fromArray(this.elements); 1546 } 1547}, pn = /*@__PURE__*/ new K(), mn = /*@__PURE__*/ new K().set(.4123908, .3575843, .1804808, .212639, .7151687, .0721923, .0193308, .1191948, .9505322), hn = /*@__PURE__*/ new K().set(3.2409699, -1.5373832, -.4986108, -.9692436, 1.8759675, .0415551, .0556301, -.203977, 1.0569715); 1548function gn() { 1549 let e = { 1550 enabled: !0, 1551 workingColorSpace: xt, 1552 spaces: {}, 1553 convert: function(e, t, n) { 1554 return this.enabled === !1 || t === n || !t || !n ? e : (this.spaces[t].transfer === "srgb" && (e.r = _n(e.r), e.g = _n(e.g), e.b = _n(e.b)), this.spaces[t].primaries !== this.spaces[n].primaries && (e.applyMatrix3(this.spaces[t].toXYZ), e.applyMatrix3(this.spaces[n].fromXYZ)), this.spaces[n].transfer === "srgb" && (e.r = vn(e.r), e.g = vn(e.g), e.b = vn(e.b)), e); 1555 }, 1556 workingToColorSpace: function(e, t) { 1557 return this.convert(e, this.workingColorSpace, t); 1558 }, 1559 colorSpaceToWorking: function(e, t) { 1560 return this.convert(e, t, this.workingColorSpace); 1561 }, 1562 getPrimaries: function(e) { 1563 return this.spaces[e].primaries; 1564 }, 1565 getTransfer: function(e) { 1566 return e === "" ? St : this.spaces[e].transfer; 1567 }, 1568 getToneMappingMode: function(e) { 1569 return this.spaces[e].outputColorSpaceConfig.toneMappingMode || "standard"; 1570 }, 1571 getLuminanceCoefficients: function(e, t = this.workingColorSpace) { 1572 return e.fromArray(this.spaces[t].luminanceCoefficients); 1573 }, 1574 define: function(e) { 1575 Object.assign(this.spaces, e); 1576 }, 1577 _getMatrix: function(e, t, n) { 1578 return e.copy(this.spaces[t].toXYZ).multiply(this.spaces[n].fromXYZ); 1579 }, 1580 _getDrawingBufferColorSpace: function(e) { 1581 return this.spaces[e].outputColorSpaceConfig.drawingBufferColorSpace; 1582 }, 1583 _getUnpackColorSpace: function(e = this.workingColorSpace) { 1584 return this.spaces[e].workingColorSpaceConfig.unpackColorSpace; 1585 }, 1586 fromWorkingColorSpace: function(t, n) { 1587 return Pt("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."), e.workingToColorSpace(t, n); 1588 }, 1589 toWorkingColorSpace: function(t, n) { 1590 return Pt("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."), e.colorSpaceToWorking(t, n); 1591 } 1592 }, t = [ 1593 .64, 1594 .33, 1595 .3, 1596 .6, 1597 .15, 1598 .06 1599 ], n = [ 1600 .2126, 1601 .7152, 1602 .0722 1603 ], r = [.3127, .329]; 1604 return e.define({ 1605 [xt]: { 1606 primaries: t, 1607 whitePoint: r, 1608 transfer: St, 1609 toXYZ: mn, 1610 fromXYZ: hn, 1611 luminanceCoefficients: n, 1612 workingColorSpaceConfig: { unpackColorSpace: bt }, 1613 outputColorSpaceConfig: { drawingBufferColorSpace: bt } 1614 }, 1615 [bt]: { 1616 primaries: t, 1617 whitePoint: r, 1618 transfer: Ct, 1619 toXYZ: mn, 1620 fromXYZ: hn, 1621 luminanceCoefficients: n, 1622 outputColorSpaceConfig: { drawingBufferColorSpace: bt } 1623 } 1624 }), e; 1625} 1626var q = /*@__PURE__*/ gn(); 1627function _n(e) { 1628 return e < .04045 ? e * .0773993808 : (e * .9478672986 + .0521327014) ** 2.4; 1629} 1630function vn(e) { 1631 return e < .0031308 ? e * 12.92 : 1.055 * e ** .41666 - .055; 1632} 1633var yn, bn = class { 1634 static getDataURL(e, t = "image/png") { 1635 if (/^data:/i.test(e.src) || typeof HTMLCanvasElement > "u") return e.src; 1636 let n; 1637 if (e instanceof HTMLCanvasElement) n = e; 1638 else { 1639 yn === void 0 && (yn = kt("canvas")), yn.width = e.width, yn.height = e.height; 1640 let t = yn.getContext("2d"); 1641 e instanceof ImageData ? t.putImageData(e, 0, 0) : t.drawImage(e, 0, 0, e.width, e.height), n = yn; 1642 } 1643 return n.toDataURL(t); 1644 } 1645 static sRGBToLinear(e) { 1646 if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap) { 1647 let t = kt("canvas"); 1648 t.width = e.width, t.height = e.height; 1649 let n = t.getContext("2d"); 1650 n.drawImage(e, 0, 0, e.width, e.height); 1651 let r = n.getImageData(0, 0, e.width, e.height), i = r.data; 1652 for (let e = 0; e < i.length; e++) i[e] = _n(i[e] / 255) * 255; 1653 return n.putImageData(r, 0, 0), t; 1654 } else if (e.data) { 1655 let t = e.data.slice(0); 1656 for (let e = 0; e < t.length; e++) t instanceof Uint8Array || t instanceof Uint8ClampedArray ? t[e] = Math.floor(_n(t[e] / 255) * 255) : t[e] = _n(t[e]); 1657 return { 1658 data: t, 1659 width: e.width, 1660 height: e.height 1661 }; 1662 } else return B("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."), e; 1663 } 1664}, xn = 0, Sn = class { 1665 constructor(e = null) { 1666 this.isSource = !0, Object.defineProperty(this, "id", { value: xn++ }), this.uuid = Ht(), this.data = e, this.dataReady = !0, this.version = 0; 1667 } 1668 getSize(e) { 1669 let t = this.data; 1670 return typeof HTMLVideoElement < "u" && t instanceof HTMLVideoElement ? e.set(t.videoWidth, t.videoHeight, 0) : typeof VideoFrame < "u" && t instanceof VideoFrame ? e.set(t.displayWidth, t.dis
1670playHeight, 0) : t === null ? e.set(0, 0, 0) : e.set(t.width, t.height, t.depth || 0), e; 1671 } 1672 set needsUpdate(e) { 1673 e === !0 && this.version++; 1674 } 1675 toJSON(e) { 1676 let t = e === void 0 || typeof e == "string"; 1677 if (!t && e.images[this.uuid] !== void 0) return e.images[this.uuid]; 1678 let n = { 1679 uuid: this.uuid, 1680 url: "" 1681 }, r = this.data; 1682 if (r !== null) { 1683 let e; 1684 if (Array.isArray(r)) { 1685 e = []; 1686 for (let t = 0, n = r.length; t < n; t++) r[t].isDataTexture ? e.push(Cn(r[t].image)) : e.push(Cn(r[t])); 1687 } else e = Cn(r); 1688 n.url = e; 1689 } 1690 return t || (e.images[this.uuid] = n), n; 1691 } 1692}; 1693function Cn(e) { 1694 return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap ? bn.getDataURL(e) : e.data ? { 1695 data: Array.from(e.data), 1696 width: e.width, 1697 height: e.height, 1698 type: e.data.constructor.name 1699 } : (B("Texture: Unable to serialize Texture."), {}); 1700} 1701var wn = 0, Tn = /*@__PURE__*/ new G(), En = class e extends Lt { 1702 constructor(t = e.DEFAULT_IMAGE, n = e.DEFAULT_MAPPING, r = oe, i = oe, a = P, o = de, s = De, c = fe, l = e.DEFAULT_ANISOTROPY, u = "") { 1703 super(), this.isTexture = !0, Object.defineProperty(this, "id", { value: wn++ }), this.uuid = Ht(), this.name = "", this.source = new Sn(t), this.mipmaps = [], this.mapping = n, this.channel = 0, this.wrapS = r, this.wrapT = i, this.magFilter = a, this.minFilter = o, this.anisotropy = l, this.format = s, this.internalFormat = null, this.type = c, this.offset = new W(0, 0), this.repeat = new W(1, 1), this.center = new W(0, 0), this.rotation = 0, this.matrixAutoUpdate = !0, this.matrix = new K(), this.generateMipmaps = !0, this.premultiplyAlpha = !1, this.flipY = !0, this.unpackAlignment = 4, this.colorSpace = u, this.userData = {}, this.updateRanges = [], this.version = 0, this.onUpdate = null, this.renderTarget = null, this.isRenderTargetTexture = !1, this.isArrayTexture = !!(t && t.depth && t.depth > 1), this.pmremVersion = 0, this.normalized = !1; 1704 } 1705 get width() { 1706 return this.source.getSize(Tn).x; 1707 } 1708 get height() { 1709 return this.source.getSize(Tn).y; 1710 } 1711 get depth() { 1712 return this.source.getSize(Tn).z; 1713 } 1714 get image() { 1715 return this.source.data; 1716 } 1717 set image(e) { 1718 this.source.data = e; 1719 } 1720 updateMatrix() { 1721 this.matrix.setUvTransform(this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y); 1722 } 1723 addUpdateRange(e, t) { 1724 this.updateRanges.push({ 1725 start: e, 1726 count: t 1727 }); 1728 } 1729 clearUpdateRanges() { 1730 this.updateRanges.length = 0; 1731 } 1732 clone() { 1733 return new this.constructor().copy(this); 1734 } 1735 copy(e) { 1736 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.normalized = e.normalized, 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; 1737 } 1738 setValues(e) { 1739 for (let t in e) { 1740 let n = e[t]; 1741 if (n === void 0) { 1742 B(`Texture.setValues(): parameter '${t}' has value of undefined.`); 1743 continue; 1744 } 1745 let r = this[t]; 1746 if (r === void 0) { 1747 B(`Texture.setValues(): property '${t}' does not exist.`); 1748 continue; 1749 } 1750 r && n && r.isVector2 && n.isVector2 || r && n && r.isVector3 && n.isVector3 || r && n && r.isMatrix3 && n.isMatrix3 ? r.copy(n) : this[t] = n; 1751 } 1752 } 1753 toJSON(e) { 1754 let t = e === void 0 || typeof e == "string"; 1755 if (!t && e.textures[this.uuid] !== void 0) return e.textures[this.uuid]; 1756 let n = { 1757 metadata: { 1758 version: 4.7, 1759 type: "Texture", 1760 generator: "Texture.toJSON" 1761 }, 1762 uuid: this.uuid, 1763 name: this.name, 1764 image: this.source.toJSON(e).uuid, 1765 mapping: this.mapping, 1766 channel: this.channel, 1767 repeat: [this.repeat.x, this.repeat.y], 1768 offset: [this.offset.x, this.offset.y], 1769 center: [this.center.x, this.center.y], 1770 rotation: this.rotation, 1771 wrap: [this.wrapS, this.wrapT], 1772 format: this.format, 1773 internalFormat: this.internalFormat, 1774 type: this.type, 1775 normalized: this.normalized, 1776 colorSpace: this.colorSpace, 1777 minFilter: this.minFilter, 1778 magFilter: this.magFilter, 1779 anisotropy: this.anisotropy, 1780 flipY: this.flipY, 1781 generateMipmaps: this.generateMipmaps, 1782 premultiplyAlpha: this.premultiplyAlpha, 1783 unpackAlignment: this.unpackAlignment 1784 }; 1785 return Object.keys(this.userData).length > 0 && (n.userData = this.userData), t || (e.textures[this.uuid] = n), n; 1786 } 1787 dispose() { 1788 this.dispatchEvent({ type: "dispose" }); 1789 } 1790 transformUv(e) { 1791 if (this.mapping !== 300) return e;
1792 if (e.applyMatrix3(this.matrix), e.x < 0 || e.x > 1) switch (this.wrapS) { 1793 case ae: 1794 e.x -= Math.floor(e.x); 1795 break; 1796 case oe: 1797 e.x = e.x < 0 ? 0 : 1; 1798 break; 1799 case se: 1800 Math.abs(Math.floor(e.x) % 2) === 1 ? e.x = Math.ceil(e.x) - e.x : e.x -= Math.floor(e.x); 1801 break; 1802 } 1803 if (e.y < 0 || e.y > 1) switch (this.wrapT) { 1804 case ae: 1805 e.y -= Math.floor(e.y); 1806 break; 1807 case oe: 1808 e.y = e.y < 0 ? 0 : 1; 1809 break; 1810 case se: 1811 Math.abs(Math.floor(e.y) % 2) === 1 ? e.y = Math.ceil(e.y) - e.y : e.y -= Math.floor(e.y); 1812 break; 1813 } 1814 return this.flipY && (e.y = 1 - e.y), e; 1815 } 1816 set needsUpdate(e) { 1817 e === !0 && (this.version++, this.source.needsUpdate = !0); 1818 } 1819 set needsPMREMUpdate(e) { 1820 e === !0 && this.pmremVersion++; 1821 } 1822}; 1823En.DEFAULT_IMAGE = null, En.DEFAULT_MAPPING = 300, En.DEFAULT_ANISOTROPY = 1; 1824var J = class e { 1825 static { 1826 e.prototype.isVector4 = !0; 1827 } 1828 constructor(e = 0, t = 0, n = 0, r = 1) { 1829 this.x = e, this.y = t, this.z = n, this.w = r; 1830 } 1831 get width() { 1832 return this.z; 1833 } 1834 set width(e) { 1835 this.z = e; 1836 } 1837 get height() { 1838 return this.w; 1839 } 1840 set height(e) { 1841 this.w = e; 1842 } 1843 set(e, t, n, r) { 1844 return this.x = e, this.y = t, this.z = n, this.w = r, this; 1845 } 1846 setScalar(e) { 1847 return this.x = e, this.y = e, this.z = e, this.w = e, this; 1848 } 1849 setX(e) { 1850 return this.x = e, this; 1851 } 1852 setY(e) { 1853 return this.y = e, this; 1854 } 1855 setZ(e) { 1856 return this.z = e, this; 1857 } 1858 setW(e) { 1859 return this.w = e, this; 1860 } 1861 setComponent(e, t) { 1862 switch (e) { 1863 case 0: 1864 this.x = t; 1865 break; 1866 case 1: 1867 this.y = t; 1868 break; 1869 case 2: 1870 this.z = t; 1871 break; 1872 case 3: 1873 this.w = t; 1874 break; 1875 default: throw Error("THREE.Vector4: index is out of range: " + e); 1876 } 1877 return this; 1878 } 1879 getComponent(e) { 1880 switch (e) { 1881 case 0: return this.x; 1882 case 1: return this.y; 1883 case 2: return this.z; 1884 case 3: return this.w; 1885 default: throw Error("THREE.Vector4: index is out of range: " + e); 1886 } 1887 } 1888 clone() { 1889 return new this.constructor(this.x, this.y, this.z, this.w); 1890 } 1891 copy(e) { 1892 return this.x = e.x, this.y = e.y, this.z = e.z, this.w = e.w === void 0 ? 1 : e.w, this; 1893 } 1894 add(e) { 1895 return this.x += e.x, this.y += e.y, this.z += e.z, this.w += e.w, this; 1896 } 1897 addScalar(e) { 1898 return this.x += e, this.y += e, this.z += e, this.w += e, this; 1899 } 1900 addVectors(e, t) { 1901 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; 1902 } 1903 addScaledVector(e, t) { 1904 return this.x += e.x * t, this.y += e.y * t, this.z += e.z * t, this.w += e.w * t, this; 1905 } 1906 sub(e) { 1907 return this.x -= e.x, this.y -= e.y, this.z -= e.z, this.w -= e.w, this; 1908 } 1909 subScalar(e) { 1910 return this.x -= e, this.y -= e, this.z -= e, this.w -= e, this; 1911 } 1912 subVectors(e, t) { 1913 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; 1914 } 1915 multiply(e) { 1916 return this.x *= e.x, this.y *= e.y, this.z *= e.z, this.w *= e.w, this; 1917 } 1918 multiplyScalar(e) { 1919 return this.x *= e, this.y *= e, this.z *= e, this.w *= e, this; 1920 } 1921 applyMatrix4(e) { 1922 let t = this.x, n = this.y, r = this.z, i = this.w, a = e.elements; 1923 return this.x = a[0] * t + a[4] * n + a[8] * r + a[12] * i, this.y = a[1] * t + a[5] * n + a[9] * r + a[13] * i, this.z = a[2] * t + a[6] * n + a[10] * r + a[14] * i, this.w = a[3] * t + a[7] * n + a[11] * r + a[15] * i, this; 1924 } 1925 divide(e) { 1926 return this.x /= e.x, this.y /= e.y, this.z /= e.z, this.w /= e.w, this; 1927 } 1928 divideScalar(e) { 1929 return this.multiplyScalar(1 / e); 1930 } 1931 setAxisAngleFromQuaternion(e) { 1932 this.w = 2 * Math.acos(e.w); 1933 let t = Math.sqrt(1 - e.w * e.w); 1934 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; 1935 } 1936 setAxisAngleFromRotationMatrix(e) { 1937 let t, n, r, i, a = .01, o = .1, s = e.elements, c = s[0], l = s[4], u = s[8], d = s[1], f = s[5], p = s[9], m = s[2], h = s[6], g = s[10]; 1938 if (Math.abs(l - d) < a && Math.abs(u - m) < a && Math.abs(p - h) < a) { 1939 if (Math.abs(l + d) < o && Math.abs(u + m) < o && Math.abs(p + h) < o && Math.abs(c + f + g - 3) < o) return this.set(1, 0, 0, 0), this; 1940 t = Math.PI; 1941 let e = (c + 1) / 2, s = (f + 1) / 2, _ = (g + 1) / 2, v = (l + d) / 4, y = (u + m) / 4, b = (p + h) / 4; 1942 return e > s && e > _ ? e < a ? (n = 0, r = .707106781, i = .707106781) : (n = Math.sqrt(e), r = v / n, i = y / n) : s > _ ? s < a ? (n = .707106781, r = 0, i = .707106781) : (r = Math.sqrt(s), n = v / r, i = b / r) : _ < a ? (n = .707106781, r = .707106781, i = 0) : (i = Math.sqrt(_), n = y / i, r = b / i), this.set(n, r, i, t), this; 1943 } 1944 let _ = Math.sqrt((h - p) * (h - p) + (u - m) * (u - m) + (d - l) * (d - l)); 1945 return Math.abs(_) < .001 && (_ = 1), this.x = (h - p) / _, this.y = (u - m) / _, this.z = (d - l) / _, this.w = Math.acos((c + f + g - 1) / 2), this; 1946 } 1947 setFromMatrixPosition(e) { 1948 let t = e.elements; 1949 return this.x = t[12], this.y = t[13], this.z = t[14], this.w = t[15], this; 1950 } 1951 min(e) { 1952 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; 1953 } 1954 max(e) { 1955 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; 1956 } 1957 clamp(e, t) { 1958 return this.x = H(this.x, e.x, t.x), this.y = H(this.y, e.y, t.y), this.z = H(this.z, e.z, t.z), this.w = H(this.w, e.w, t.w), this; 1959 } 1960 clampScalar(e, t) { 1961 return this.x = H(this.x, e, t), this.y = H(this.y, e, t), this.z = H(this.z, e, t), this.w = H(this.w, e, t), this; 1962 } 1963 clampLength(e, t) { 1964 let n = this.length(); 1965 return this.divideScalar(n || 1).multiplyScalar(H(n, e, t)); 1966 } 1967 floor() { 1968 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; 1969 } 1970 ceil() { 1971 return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.
1971ceil(this.z), this.w = Math.ceil(this.w), this; 1972 } 1973 round() { 1974 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; 1975 } 1976 roundToZero() { 1977 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; 1978 } 1979 negate() { 1980 return this.x = -this.x, this.y = -this.y, this.z = -this.z, this.w = -this.w, this; 1981 } 1982 dot(e) { 1983 return this.x * e.x + this.y * e.y + this.z * e.z + this.w * e.w; 1984 } 1985 lengthSq() { 1986 return this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w; 1987 } 1988 length() { 1989 return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w); 1990 } 1991 manhattanLength() { 1992 return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z) + Math.abs(this.w); 1993 } 1994 normalize() { 1995 return this.divideScalar(this.length() || 1); 1996 } 1997 setLength(e) { 1998 return this.normalize().multiplyScalar(e); 1999 } 2000 lerp(e, t) { 2001 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; 2002 } 2003 lerpVectors(e, t, n) { 2004 return this.x = e.x + (t.x - e.x) * n, this.y = e.y + (t.y - e.y) * n, this.z = e.z + (t.z - e.z) * n, this.w = e.w + (t.w - e.w) * n, this; 2005 } 2006 equals(e) { 2007 return e.x === this.x && e.y === this.y && e.z === this.z && e.w === this.w; 2008 } 2009 fromArray(e, t = 0) { 2010 return this.x = e[t], this.y = e[t + 1], this.z = e[t + 2], this.w = e[t + 3], this; 2011 } 2012 toArray(e = [], t = 0) { 2013 return e[t] = this.x, e[t + 1] = this.y, e[t + 2] = this.z, e[t + 3] = this.w, e; 2014 } 2015 fromBufferAttribute(e, t) { 2016 return this.x = e.getX(t), this.y = e.getY(t), this.z = e.getZ(t), this.w = e.getW(t), this; 2017 } 2018 random() { 2019 return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this.w = Math.random(), this; 2020 } 2021 *[Symbol.iterator]() { 2022 yield this.x, yield this.y, yield this.z, yield this.w; 2023 } 2024}, Dn = class extends Lt { 2025 constructor(e = 1, t = 1, n = {}) { 2026 super(), n = Object.assign({ 2027 generateMipmaps: !1, 2028 internalFormat: null, 2029 minFilter: P, 2030 depthBuffer: !0, 2031 stencilBuffer: !1, 2032 resolveDepthBuffer: !0, 2033 resolveStencilBuffer: !0, 2034 depthTexture: null, 2035 samples: 0, 2036 count: 1, 2037 depth: 1, 2038 multiview: !1, 2039 useArrayDepthTexture: !1 2040 }, n), this.isRenderTarget = !0, this.width = e, this.height = t, this.depth = n.depth, this.scissor = new J(0, 0, e, t), this.scissorTest = !1, this.viewport = new J(0, 0, e, t), this.textures = []; 2041 let r = new En({ 2042 width: e, 2043 height: t, 2044 depth: n.depth 2045 }), i = n.count; 2046 for (let e = 0; e < i; e++) this.textures[e] = r.clone(), this.textures[e].isRenderTargetTexture = !0, this.textures[e].renderTarget = this; 2047 this._setTextureOptions(n), this.depthBuffer = n.depthBuffer, this.stencilBuffer = n.stencilBuffer, this.resolveDepthBuffer = n.resolveDepthBuffer, this.resolveStencilBuffer = n.resolveStencilBuffer, this._depthTexture = null, this.depthTexture = n.depthTexture, this.samples = n.samples, this.multiview = n.multiview, this.useArrayDepthTexture = n.useArrayDepthTexture; 2048 } 2049 _setTextureOptions(e = {}) { 2050 let t = { 2051 minFilter: P, 2052 generateMipmaps: !1, 2053 flipY: !1, 2054 internalFormat: null 2055 }; 2056 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); 2057 for (let e = 0; e < this.textures.length; e++) this.textures[e].setValues(t); 2058 } 2059 get texture() { 2060 return this.textures[0]; 2061 } 2062 set texture(e) { 2063 this.textures[0] = e; 2064 } 2065 set depthTexture(e) { 2066 this._depthTexture !== null && (this._depthTexture.renderTarget = null), e !== null && (e.renderTarget = this), this._depthTexture = e; 2067 } 2068 get depthTexture() { 2069 return this._depthTexture; 2070 } 2071 setSize(e, t, n = 1) { 2072 if (this.width !== e || this.height !== t || this.depth !== n) { 2073 this.width = e, this.height = t, this.depth = n; 2074 for (let r = 0, i = this.textures.length; r < i; r++) this.textures[r].image.width = e, this.textures[r].image.height = t, this.textures[r].image.depth = n, this.textures[r].isData3DTexture !== !0 && (this.textures[r].isArrayTexture = this.textures[r].image.depth > 1); 2075 this.dispose(); 2076 } 2077 this.viewport.set(0, 0, e, t), this.scissor.set(0, 0, e, t); 2078 } 2079 clone() { 2080 return new this.constructor().copy(this); 2081 } 2082 copy(e) { 2083 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; 2084 for (let t = 0, n = e.textures.length; t < n; t++) { 2085 this.textures[t] = e.textures[t].clone(), this.textures[t].isRenderTargetTexture = !0, this.textures[t].renderTarget = this; 2086 let n = Object.assign({}, e.textures[t].image); 2087 this.textures[t].source = new Sn(n); 2088 } 2089 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.multiview = e.multiview, this.useArrayDepthTexture = e.useArrayDepthTexture, this; 2090 } 2091 dispose() { 2092 this.dispatchEvent({ type: "dispose" }); 2093 } 2094}, On = class extends Dn { 2095 constructor(e = 1, t = 1, n = {}) {
2096 super(e, t, n), this.isWebGLRenderTarget = !0; 2097 } 2098}, kn = class extends En { 2099 constructor(e = null, t = 1, n = 1, r = 1) { 2100 super(null), this.isDataArrayTexture = !0, this.image = { 2101 data: e, 2102 width: t, 2103 height: n, 2104 depth: r 2105 }, this.magFilter = N, this.minFilter = N, this.wrapR = oe, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1, this.layerUpdates = /* @__PURE__ */ new Set(); 2106 } 2107 addLayerUpdate(e) { 2108 this.layerUpdates.add(e); 2109 } 2110 clearLayerUpdates() { 2111 this.layerUpdates.clear(); 2112 } 2113}, An = class extends En { 2114 constructor(e = null, t = 1, n = 1, r = 1) { 2115 super(null), this.isData3DTexture = !0, this.image = { 2116 data: e, 2117 width: t, 2118 height: n, 2119 depth: r 2120 }, this.magFilter = N, this.minFilter = N, this.wrapR = oe, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; 2121 } 2122}, jn = class e { 2123 static { 2124 e.prototype.isMatrix4 = !0; 2125 } 2126 constructor(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) { 2127 this.elements = [ 2128 1, 2129 0, 2130 0, 2131 0, 2132 0, 2133 1, 2134 0, 2135 0, 2136 0, 2137 0, 2138 1, 2139 0, 2140 0, 2141 0, 2142 0, 2143 1 2144 ], e !== void 0 && this.set(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h); 2145 } 2146 set(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) { 2147 let g = this.elements; 2148 return g[0] = e, g[4] = t, g[8] = n, g[12] = r, g[1] = i, g[5] = a, g[9] = o, g[13] = s, g[2] = c, g[6] = l, g[10] = u, g[14] = d, g[3] = f, g[7] = p, g[11] = m, g[15] = h, this; 2149 } 2150 identity() { 2151 return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; 2152 } 2153 clone() { 2154 return new e().fromArray(this.elements); 2155 } 2156 copy(e) { 2157 let t = this.elements, n = e.elements; 2158 return t[0] = n[0], t[1] = n[1], t[2] = n[2], t[3] = n[3], t[4] = n[4], t[5] = n[5], t[6] = n[6], t[7] = n[7], t[8] = n[8], t[9] = n[9], t[10] = n[10], t[11] = n[11], t[12] = n[12], t[13] = n[13], t[14] = n[14], t[15] = n[15], this; 2159 } 2160 copyPosition(e) { 2161 let t = this.elements, n = e.elements; 2162 return t[12] = n[12], t[13] = n[13], t[14] = n[14], this; 2163 } 2164 setFromMatrix3(e) { 2165 let t = e.elements; 2166 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; 2167 } 2168 extractBasis(e, t, n) { 2169 return this.determinantAffine() === 0 ? (e.set(1, 0, 0), t.set(0, 1, 0), n.set(0, 0, 1), this) : (e.setFromMatrixColumn(this, 0), t.setFromMatrixColumn(this, 1), n.setFromMatrixColumn(this, 2), this); 2170 } 2171 makeBasis(e, t, n) { 2172 return this.set(e.x, t.x, n.x, 0, e.y, t.y, n.y, 0, e.z, t.z, n.z, 0, 0, 0, 0, 1), this; 2173 } 2174 extractRotation(e) { 2175 if (e.determinantAffine() === 0) return this.identity(); 2176 let t = this.elements, n = e.elements, r = 1 / Mn.setFromMatrixColumn(e, 0).length(), i = 1 / Mn.setFromMatrixColumn(e, 1).length(), a = 1 / Mn.setFromMatrixColumn(e, 2).length(); 2177 return t[0] = n[0] * r, t[1] = n[1] * r, t[2] = n[2] * r, t[3] = 0, t[4] = n[4] * i, t[5] = n[5] * i, t[6] = n[6] * i, t[7] = 0, t[8] = n[8] * a, t[9] = n[9] * a, t[10] = n[10] * a, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; 2178 } 2179 makeRotationFromEuler(e) { 2180 let t = this.elements, n = e.x, r = e.y, i = e.z, a = Math.cos(n), o = Math.sin(n), s = Math.cos(r), c = Math.sin(r), l = Math.cos(i), u = Math.sin(i); 2181 if (e.order === "XYZ") { 2182 let e = a * l, n = a * u, r = o * l, i = o * u; 2183 t[0] = s * l, t[4] = -s * u, t[8] = c, t[1] = n + r * c, t[5] = e - i * c, t[9] = -o * s, t[2] = i - e * c, t[6] = r + n * c, t[10] = a * s; 2184 } else if (e.order === "YXZ") { 2185 let e = s * l, n = s * u, r = c * l, i = c * u; 2186 t[0] = e + i * o, t[4] = r * o - n, t[8] = a * c, t[1] = a * u, t[5] = a * l, t[9] = -o, t[2] = n * o - r, t[6] = i + e * o, t[10] = a * s; 2187 } else if (e.order === "ZXY") { 2188 let e = s * l, n = s * u, r = c * l, i = c * u; 2189 t[0] = e - i * o, t[4] = -a * u, t[8] = r + n * o, t[1] = n + r * o, t[5] = a * l, t[9] = i - e * o, t[2] = -a * c, t[6] = o, t[10] = a * s; 2190 } else if (e.order === "ZYX") { 2191 let e = a * l, n = a * u, r = o * l, i = o * u; 2192 t[0] = s * l, t[4] = r * c - n, t[8] = e * c + i, t[1] = s * u, t[5] = i * c + e, t[9] = n * c - r, t[2] = -c, t[6] = o * s, t[10] = a * s; 2193 } else if (e.order === "YZX") { 2194 let e = a * s, n = a * c, r = o * s, i = o * c; 2195 t[0] = s * l, t[4] = i - e * u, t[8] = r * u + n, t[1] = u, t[5] = a * l, t[9] = -o * l, t[2] = -c * l, t[6] = n * u + r, t[10] = e - i * u; 2196 } else if (e.order === "XZY") { 2197 let e = a * s, n = a * c, r = o * s, i = o * c; 2198 t[0] = s * l, t[4] = -u, t[8] = c * l, t[1] = e * u + i, t[5] = a * l, t[9] = n * u - r, t[2] = r * u - n, t[6] = o * l, t[10] = i * u + e; 2199 } 2200 return t[3] = 0, t[7] = 0, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, this; 2201 } 2202 makeRotationFromQuaternion(e) { 2203 return this.compose(Pn, e, Fn); 2204 } 2205 lookAt(e, t, n) { 2206 let r = this.elements; 2207 return Rn.subVectors(e, t), Rn.lengthSq() === 0 && (Rn.z = 1), Rn.normalize(), In.crossVectors(n, Rn), In.lengthSq() === 0 && (Math.abs(n.z) === 1 ? Rn.x += 1e-4 : Rn.z += 1e-4, Rn.normalize(), In.crossVectors(n, Rn)), In.normalize(), Ln.crossVectors(Rn, In), r[0] = In.x, r[4] = Ln.x, r[8] = Rn.x, r[1] = In.y, r[5] = Ln.y, r[9] = Rn.y, r[2] = In.z, r[6] = Ln.z, r[10] = Rn.z, this; 2208 } 2209 multiply(e) { 2210 return this.multiplyMatrices(this, e); 2211 } 2212 premultiply(e) { 2213 return this.multiplyMatrices(e, this); 2214 } 2215 multiplyMatrices(e, t) { 2216 let n = e.elements, r = t.elements, i = this.elements, a = n[0], o = n[4], s = n[8], c = n[12], l = n[1], u = n[5], d = n[9], f = n[13], p = n[2], m = n[6], h = n[10], g = n[14], _ = n[3], v = n[7], y = n[
221611], b = n[15], x = r[0], S = r[4], C = r[8], w = r[12], T = r[1], E = r[5], D = r[9], O = r[13], k = r[2], A = r[6], ee = r[10], te = r[14], j = r[3], ne = r[7], re = r[11], M = r[15]; 2217 return i[0] = a * x + o * T + s * k + c * j, i[4] = a * S + o * E + s * A + c * ne, i[8] = a * C + o * D + s * ee + c * re, i[12] = a * w + o * O + s * te + c * M, i[1] = l * x + u * T + d * k + f * j, i[5] = l * S + u * E + d * A + f * ne, i[9] = l * C + u * D + d * ee + f * re, i[13] = l * w + u * O + d * te + f * M, i[2] = p * x + m * T + h * k + g * j, i[6] = p * S + m * E + h * A + g * ne, i[10] = p * C + m * D + h * ee + g * re, i[14] = p * w + m * O + h * te + g * M, i[3] = _ * x + v * T + y * k + b * j, i[7] = _ * S + v * E + y * A + b * ne, i[11] = _ * C + v * D + y * ee + b * re, i[15] = _ * w + v * O + y * te + b * M, this; 2218 } 2219 multiplyScalar(e) { 2220 let t = this.elements; 2221 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; 2222 } 2223 determinant() { 2224 let e = this.elements, t = e[0], n = e[4], r = e[8], i = e[12], a = e[1], o = e[5], s = e[9], c = e[13], l = e[2], u = e[6], d = e[10], f = e[14], p = e[3], m = e[7], h = e[11], g = e[15], _ = s * f - c * d, v = o * f - c * u, y = o * d - s * u, b = a * f - c * l, x = a * d - s * l, S = a * u - o * l; 2225 return t * (m * _ - h * v + g * y) - n * (p * _ - h * b + g * x) + r * (p * v - m * b + g * S) - i * (p * y - m * x + h * S); 2226 } 2227 determinantAffine() { 2228 let e = this.elements, t = e[0], n = e[4], r = e[8], i = e[1], a = e[5], o = e[9], s = e[2], c = e[6], l = e[10]; 2229 return t * (a * l - o * c) - n * (i * l - o * s) + r * (i * c - a * s); 2230 } 2231 transpose() { 2232 let e = this.elements, t; 2233 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; 2234 } 2235 setPosition(e, t, n) { 2236 let r = this.elements; 2237 return e.isVector3 ? (r[12] = e.x, r[13] = e.y, r[14] = e.z) : (r[12] = e, r[13] = t, r[14] = n), this; 2238 } 2239 invert() { 2240 let e = this.elements, t = e[0], n = e[1], r = e[2], i = e[3], a = e[4], o = e[5], s = e[6], c = e[7], l = e[8], u = e[9], d = e[10], f = e[11], p = e[12], m = e[13], h = e[14], g = e[15], _ = t * o - n * a, v = t * s - r * a, y = t * c - i * a, b = n * s - r * o, x = n * c - i * o, S = r * c - i * s, C = l * m - u * p, w = l * h - d * p, T = l * g - f * p, E = u * h - d * m, D = u * g - f * m, O = d * g - f * h, k = _ * O - v * D + y * E + b * T - x * w + S * C; 2241 if (k === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 2242 let A = 1 / k; 2243 return e[0] = (o * O - s * D + c * E) * A, e[1] = (r * D - n * O - i * E) * A, e[2] = (m * S - h * x + g * b) * A, e[3] = (d * x - u * S - f * b) * A, e[4] = (s * T - a * O - c * w) * A, e[5] = (t * O - r * T + i * w) * A, e[6] = (h * y - p * S - g * v) * A, e[7] = (l * S - d * y + f * v) * A, e[8] = (a * D - o * T + c * C) * A, e[9] = (n * T - t * D - i * C) * A, e[10] = (p * x - m * y + g * _) * A, e[11] = (u * y - l * x - f * _) * A, e[12] = (o * w - a * E - s * C) * A, e[13] = (t * E - n * w + r * C) * A, e[14] = (m * v - p * b - h * _) * A, e[15] = (l * b - u * v + d * _) * A, this; 2244 } 2245 scale(e) { 2246 let t = this.elements, n = e.x, r = e.y, i = e.z; 2247 return t[0] *= n, t[4] *= r, t[8] *= i, t[1] *= n, t[5] *= r, t[9] *= i, t[2] *= n, t[6] *= r, t[10] *= i, t[3] *= n, t[7] *= r, t[11] *= i, this; 2248 } 2249 getMaxScaleOnAxis() { 2250 let e = this.elements, t = e[0] * e[0] + e[1] * e[1] + e[2] * e[2], n = e[4] * e[4] + e[5] * e[5] + e[6] * e[6], r = e[8] * e[8] + e[9] * e[9] + e[10] * e[10]; 2251 return Math.sqrt(Math.max(t, n, r)); 2252 } 2253 makeTranslation(e, t, n) { 2254 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, n, 0, 0, 0, 1), this; 2255 } 2256 makeRotationX(e) { 2257 let t = Math.cos(e), n = Math.sin(e); 2258 return this.set(1, 0, 0, 0, 0, t, -n, 0, 0, n, t, 0, 0, 0, 0, 1), this; 2259 } 2260 makeRotationY(e) {
2261 let t = Math.cos(e), n = Math.sin(e); 2262 return this.set(t, 0, n, 0, 0, 1, 0, 0, -n, 0, t, 0, 0, 0, 0, 1), this; 2263 } 2264 makeRotationZ(e) { 2265 let t = Math.cos(e), n = Math.sin(e); 2266 return this.set(t, -n, 0, 0, n, t, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this; 2267 } 2268 makeRotationAxis(e, t) { 2269 let n = Math.cos(t), r = Math.sin(t), i = 1 - n, a = e.x, o = e.y, s = e.z, c = i * a, l = i * o; 2270 return this.set(c * a + n, c * o - r * s, c * s + r * o, 0, c * o + r * s, l * o + n, l * s - r * a, 0, c * s - r * o, l * s + r * a, i * s * s + n, 0, 0, 0, 0, 1), this; 2271 } 2272 makeScale(e, t, n) { 2273 return this.set(e, 0, 0, 0, 0, t, 0, 0, 0, 0, n, 0, 0, 0, 0, 1), this; 2274 } 2275 makeShear(e, t, n, r, i, a) { 2276 return this.set(1, n, i, 0, e, 1, a, 0, t, r, 1, 0, 0, 0, 0, 1), this; 2277 } 2278 compose(e, t, n) { 2279 let r = this.elements, i = t._x, a = t._y, o = t._z, s = t._w, c = i + i, l = a + a, u = o + o, d = i * c, f = i * l, p = i * u, m = a * l, h = a * u, g = o * u, _ = s * c, v = s * l, y = s * u, b = n.x, x = n.y, S = n.z; 2280 return r[0] = (1 - (m + g)) * b, r[1] = (f + y) * b, r[2] = (p - v) * b, r[3] = 0, r[4] = (f - y) * x, r[5] = (1 - (d + g)) * x, r[6] = (h + _) * x, r[7] = 0, r[8] = (p + v) * S, r[9] = (h - _) * S, r[10] = (1 - (d + m)) * S, r[11] = 0, r[12] = e.x, r[13] = e.y, r[14] = e.z, r[15] = 1, this; 2281 } 2282 decompose(e, t, n) { 2283 let r = this.elements; 2284 e.x = r[12], e.y = r[13], e.z = r[14]; 2285 let i = this.determinantAffine(); 2286 if (i === 0) return n.set(1, 1, 1), t.identity(), this; 2287 let a = Mn.set(r[0], r[1], r[2]).length(), o = Mn.set(r[4], r[5], r[6]).length(), s = Mn.set(r[8], r[9], r[10]).length(); 2288 i < 0 && (a = -a), Nn.copy(this); 2289 let c = 1 / a, l = 1 / o, u = 1 / s; 2290 return Nn.elements[0] *= c, Nn.elements[1] *= c, Nn.elements[2] *= c, Nn.elements[4] *= l, Nn.elements[5] *= l, Nn.elements[6] *= l, Nn.elements[8] *= u, Nn.elements[9] *= u, Nn.elements[10] *= u, t.setFromRotationMatrix(Nn), n.x = a, n.y = o, n.z = s, this; 2291 } 2292 makePerspective(e, t, n, r, i, a, o = Et, s = !1) { 2293 let c = this.elements, l = 2 * i / (t - e), u = 2 * i / (n - r), d = (t + e) / (t - e), f = (n + r) / (n - r), p, m; 2294 if (s) p = i / (a - i), m = a * i / (a - i); 2295 else if (o === 2e3) p = -(a + i) / (a - i), m = -2 * a * i / (a - i); 2296 else if (o === 2001) p = -a / (a - i), m = -a * i / (a - i); 2297 else throw Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: " + o); 2298 return c[0] = l, c[4] = 0, c[8] = d, c[12] = 0, c[1] = 0, c[5] = u, c[9] = f, c[13] = 0, c[2] = 0, c[6] = 0, c[10] = p, c[14] = m, c[3] = 0, c[7] = 0, c[11] = -1, c[15] = 0, this; 2299 } 2300 makeOrthographic(e, t, n, r, i, a, o = Et, s = !1) { 2301 let c = this.elements, l = 2 / (t - e), u = 2 / (n - r), d = -(t + e) / (t - e), f = -(n + r) / (n - r), p, m; 2302 if (s) p = 1 / (a - i), m = a / (a - i); 2303 else if (o === 2e3) p = -2 / (a - i), m = -(a + i) / (a - i); 2304 else if (o === 2001) p = -1 / (a - i), m = -i / (a - i); 2305 else throw Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: " + o); 2306 return c[0] = l, c[4] = 0, c[8] = 0, c[12] = d, c[1] = 0, c[5] = u, c[9] = 0, c[13] = f, c[2] = 0, c[6] = 0, c[10] = p, c[14] = m, c[3] = 0, c[7] = 0, c[11] = 0, c[15] = 1, this; 2307 } 2308 equals(e) { 2309 let t = this.elements, n = e.elements; 2310 for (let e = 0; e < 16; e++) if (t[e] !== n[e]) return !1; 2311 return !0; 2312 } 2313 fromArray(e, t = 0) { 2314 for (let n = 0; n < 16; n++) this.elements[n] = e[n + t]; 2315 return this; 2316 } 2317 toArray(e = [], t = 0) { 2318 let n = this.elements; 2319 return e[t] = n[0], e[t + 1] = n[1], e[t + 2] = n[2], e[t + 3] = n[3], e[t + 4] = n[4], e[t + 5] = n[5], e[t + 6] = n[6], e[t + 7] = n[7], e[t + 8] = n[8], e[t + 9] = n[9], e[t + 10] = n[10], e[t + 11] = n[11], e[t + 12] = n[12], e[t + 13] = n[13], e[t + 14] = n[14], e[t + 15] = n[15], e; 2320 } 2321}, Mn = /*@__PURE__*/ new G(), Nn = /*@__PURE__*/ new jn(), Pn = /*@__PURE__*/ new G(0, 0, 0), Fn = /*@__PURE__*/ new G(1, 1, 1), In = /*@__PURE__*/ new G(), Ln = /*@__PURE__*/ new G(), Rn = /*@__PURE__*/ new G(), zn = /*@__PURE__*/ new jn(), Bn = /*@__PURE__*/ new un(), Vn = class e { 2322 constructor(t = 0, n = 0, r = 0, i = e.DEFAULT_ORDER) { 2323 this.isEuler = !0, this._x = t, this._y = n, this._z = r, this._order = i; 2324 } 2325 get x() { 2326 return this._x; 2327 } 2328 set x(e) { 2329 this._x = e, this._onChangeCallback(); 2330 } 2331 get y() { 2332 return this._y; 2333 } 2334 set y(e) { 2335 this._y = e, this._onChangeCallback(); 2336 } 2337 get z() { 2338 return this._z; 2339 } 2340 set z(e) { 2341 this._z = e, this._onChangeCallback(); 2342 } 2343 get order() { 2344 return this._order;
vendor: 4,079 bytes, lines 2345-2453
2345 } 2346 set order(e) { 2347 this._order = e, this._onChangeCallback(); 2348 } 2349 set(e, t, n, r = this._order) { 2350 return this._x = e, this._y = t, this._z = n, this._order = r, this._onChangeCallback(), this; 2351 } 2352 clone() { 2353 return new this.constructor(this._x, this._y, this._z, this._order); 2354 } 2355 copy(e) { 2356 return this._x = e._x, this._y = e._y, this._z = e._z, this._order = e._order, this._onChangeCallback(), this; 2357 } 2358 setFromRotationMatrix(e, t = this._order, n = !0) { 2359 let r = e.elements, i = r[0], a = r[4], o = r[8], s = r[1], c = r[5], l = r[9], u = r[2], d = r[6], f = r[10]; 2360 switch (t) { 2361 case "XYZ": 2362 this._y = Math.asin(H(o, -1, 1)), Math.abs(o) < .9999999 ? (this._x = Math.atan2(-l, f), this._z = Math.atan2(-a, i)) : (this._x = Math.atan2(d, c), this._z = 0); 2363 break; 2364 case "YXZ": 2365 this._x = Math.asin(-H(l, -1, 1)), Math.abs(l) < .9999999 ? (this._y = Math.atan2(o, f), this._z = Math.atan2(s, c)) : (this._y = Math.atan2(-u, i), this._z = 0); 2366 break; 2367 case "ZXY": 2368 this._x = Math.asin(H(d, -1, 1)), Math.abs(d) < .9999999 ? (this._y = Math.atan2(-u, f), this._z = Math.atan2(-a, c)) : (this._y = 0, this._z = Math.atan2(s, i)); 2369 break; 2370 case "ZYX": 2371 this._y = Math.asin(-H(u, -1, 1)), Math.abs(u) < .9999999 ? (this._x = Math.atan2(d, f), this._z = Math.atan2(s, i)) : (this._x = 0, this._z = Math.atan2(-a, c)); 2372 break; 2373 case "YZX": 2374 this._z = Math.asin(H(s, -1, 1)), Math.abs(s) < .9999999 ? (this._x = Math.atan2(-l, c), this._y = Math.atan2(-u, i)) : (this._x = 0, this._y = Math.atan2(o, f)); 2375 break; 2376 case "XZY": 2377 this._z = Math.asin(-H(a, -1, 1)), Math.abs(a) < .9999999 ? (this._x = Math.atan2(d, c), this._y = Math.atan2(o, i)) : (this._x = Math.atan2(-l, f), this._y = 0); 2378 break; 2379 default: B("Euler: .setFromRotationMatrix() encountered an unknown order: " + t); 2380 } 2381 return this._order = t, n === !0 && this._onChangeCallback(), this; 2382 } 2383 setFromQuaternion(e, t, n) { 2384 return zn.makeRotationFromQuaternion(e), this.setFromRotationMatrix(zn, t, n); 2385 } 2386 setFromVector3(e, t = this._order) { 2387 return this.set(e.x, e.y, e.z, t); 2388 } 2389 reorder(e) { 2390 return Bn.setFromEuler(this), this.setFromQuaternion(Bn, e); 2391 } 2392 equals(e) { 2393 return e._x === this._x && e._y === this._y && e._z === this._z && e._order === this._order; 2394 } 2395 fromArray(e) { 2396 return this._x = e[0], this._y = e[1], this._z = e[2], e[3] !== void 0 && (this._order = e[3]), this._onChangeCallback(), this; 2397 } 2398 toArray(e = [], t = 0) { 2399 return e[t] = this._x, e[t + 1] = this._y, e[t + 2] = this._z, e[t + 3] = this._order, e; 2400 } 2401 _onChange(e) { 2402 return this._onChangeCallback = e, this; 2403 } 2404 _onChangeCallback() {} 2405 *[Symbol.iterator]() { 2406 yield this._x, yield this._y, yield this._z, yield this._order; 2407 } 2408}; 2409Vn.DEFAULT_ORDER = "XYZ"; 2410var Hn = class { 2411 constructor() { 2412 this.mask = 1; 2413 } 2414 set(e) { 2415 this.mask = (1 << e | 0) >>> 0; 2416 } 2417 enable(e) { 2418 this.mask |= 1 << e | 0; 2419 } 2420 enableAll() { 2421 this.mask = -1; 2422 } 2423 toggle(e) { 2424 this.mask ^= 1 << e | 0; 2425 } 2426 disable(e) { 2427 this.mask &= ~(1 << e | 0); 2428 } 2429 disableAll() { 2430 this.mask = 0; 2431 } 2432 test(e) { 2433 return (this.mask & e.mask) !== 0; 2434 } 2435 isEnabled(e) { 2436 return (this.mask & (1 << e | 0)) != 0; 2437 } 2438}, Un = 0, Wn = /*@__PURE__*/ new G(), Gn = /*@__PURE__*/ new un(), Kn = /*@__PURE__*/ new jn(), qn = /*@__PURE__*/ new G(), Jn = /*@__PURE__*/ new G(), Yn = /*@__PURE__*/ new G(), Xn = /*@__PURE__*/ new un(), Zn = /*@__PURE__*/ new G(1, 0, 0), Qn = /*@__PURE__*/ new G(0, 1, 0), $n = /*@__PURE__*/ new G(0, 0, 1), er = { type: "added" }, tr = { type: "removed" }, nr = { 2439 type: "childadded", 2440 child: null 2441}, rr = { 2442 type: "childremoved", 2443 child: null 2444}, ir = class e extends Lt { 2445 constructor() { 2446 super(), this.isObject3D = !0, Object.defineProperty(this, "id", { value: Un++ }), this.uuid = Ht(), this.name = "", this.type = "Object3D", this.parent = null, this.children = [], this.up = e.DEFAULT_UP.clone(); 2447 let t = new G(), n = new Vn(), r = new un(), i = new G(1, 1, 1); 2448 function a() { 2449 r.setFromEuler(n, !1); 2450 } 2451 function o() { 2452 n.setFromQuaternion(r, void 0, !1); 2453 }
2454 n._onChange(a), r._onChange(o), Object.defineProperties(this, { 2455 position: { 2456 configurable: !0, 2457 enumerable: !0, 2458 value: t 2459 }, 2460 rotation: { 2461 configurable: !0, 2462 enumerable: !0, 2463 value: n 2464 }, 2465 quaternion: { 2466 configurable: !0, 2467 enumerable: !0, 2468 value: r 2469 }, 2470 scale: { 2471 configurable: !0, 2472 enumerable: !0, 2473 value: i 2474 }, 2475 modelViewMatrix: { value: new jn() }, 2476 normalMatrix: { value: new K() } 2477 }), this.matrix = new jn(), this.matrixWorld = new jn(), this.matrixAutoUpdate = e.DEFAULT_MATRIX_AUTO_UPDATE, this.matrixWorldAutoUpdate = e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE, this.matrixWorldNeedsUpdate = !1, this.layers = new Hn(), 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.static = !1, this.userData = {}, this.pivot = null; 2478 } 2479 onBeforeShadow() {} 2480 onAfterShadow() {} 2481 onBeforeRender() {} 2482 onAfterRender() {} 2483 applyMatrix4(e) { 2484 this.matrixAutoUpdate && this.updateMatrix(), this.matrix.premultiply(e), this.matrix.decompose(this.position, this.quaternion, this.scale); 2485 } 2486 applyQuaternion(e) { 2487 return this.quaternion.premultiply(e), this; 2488 } 2489 setRotationFromAxisAngle(e, t) { 2490 this.quaternion.setFromAxisAngle(e, t); 2491 } 2492 setRotationFromEuler(e) { 2493 this.quaternion.setFromEuler(e, !0); 2494 } 2495 setRotationFromMatrix(e) { 2496 this.quaternion.setFromRotationMatrix(e); 2497 } 2498 setRotationFromQuaternion(e) { 2499 this.quaternion.copy(e); 2500 } 2501 rotateOnAxis(e, t) { 2502 return Gn.setFromAxisAngle(e, t), this.quaternion.multiply(Gn), this; 2503 } 2504 rotateOnWorldAxis(e, t) { 2505 return Gn.setFromAxisAngle(e, t), this.quaternion.premultiply(Gn), this; 2506 } 2507 rotateX(e) { 2508 return this.rotateOnAxis(Zn, e); 2509 } 2510 rotateY(e) { 2511 return this.rotateOnAxis(Qn, e); 2512 } 2513 rotateZ(e) { 2514 return this.rotateOnAxis($n, e); 2515 } 2516 translateOnAxis(e, t) { 2517 return Wn.copy(e).applyQuaternion(this.quaternion), this.position.add(Wn.multiplyScalar(t)), this; 2518 } 2519 translateX(e) { 2520 return this.translateOnAxis(Zn, e); 2521 } 2522 translateY(e) { 2523 return this.translateOnAxis(Qn, e); 2524 } 2525 translateZ(e) { 2526 return this.translateOnAxis($n, e); 2527 } 2528 localToWorld(e) { 2529 return this.updateWorldMatrix(!0, !1), e.applyMatrix4(this.matrixWorld); 2530 } 2531 worldToLocal(e) { 2532 return this.updateWorldMatrix(!0, !1), e.applyMatrix4(Kn.copy(this.matrixWorld).invert()); 2533 } 2534 lookAt(e, t, n) { 2535 e.isVector3 ? qn.copy(e) : qn.set(e, t, n); 2536 let r = this.parent; 2537 this.updateWorldMatrix(!0, !1), Jn.setFromMatrixPosition(this.matrixWorld), this.isCamera || this.isLight ? Kn.lookAt(Jn, qn, this.up) : Kn.lookAt(qn, Jn, this.up), this.quaternion.setFromRotationMatrix(Kn), r && (Kn.extractRotation(r.matrixWorld), Gn.setFromRotationMatrix(Kn), this.quaternion.premultiply(Gn.invert())); 2538 } 2539 add(e) { 2540 if (arguments.length > 1) { 2541 for (let e = 0; e < arguments.length; e++) this.add(arguments[e]); 2542 return this; 2543 } 2544 return e === this ? (V("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(er), nr.child = e, this.dispatchEvent(nr), nr.child = null) : V("Object3D.add: object not an instance of THREE.Object3D.", e), this); 2545 } 2546 remove(e) { 2547 if (arguments.length > 1) { 2548 for (let e = 0; e < arguments.length; e++) this.remove(arguments[e]); 2549 return this; 2550 } 2551 let t = this.children.indexOf(e); 2552 return t !== -1 && (e.parent = null, this.children.splice(t, 1), e.dispatchEvent(tr), rr.child = e, this.dispatchEvent(rr), rr.child = null), this; 2553 } 2554 removeFromParent() { 2555 let e = this.parent; 2556 return e !== null && e.remove(this), this; 2557 } 2558 clear() { 2559 return this.remove(...this.children); 2560 } 2561 attach(e) { 2562 return this.updateWorldMatrix(!0, !1), Kn.copy(this.matrixWorld).invert(), e.parent !== null && (e.parent.updateWorldMatrix(!0, !1), Kn.multiply(e.parent.matrixWorld)), e.applyMatrix4(Kn), e.removeFromParent(), e.parent = this, this.children.push(e), e.updateWorldMatrix(!1, !0), e.dispatchEvent(er), nr.child = e, this.dispatchEvent(nr), nr.child = null, this; 2563 } 2564 getObjectById(e) { 2565 return this.getObjectByProperty("id", e); 2566 } 2567 getObjectByName(e) { 2568 return this.getObjectByProperty("name", e); 2569 } 2570 getObjectByProperty(e, t) { 2571 if (this[e] === t) return this; 2572 for (let n = 0, r = this.children.length; n < r; n++) { 2573 let r = this.children[n].getObjectByProperty(e, t); 2574 if (r !== void 0) return r; 2575 } 2576 } 2577 getObjectsByProperty(e, t, n = []) { 2578 this[e] === t && n.push(this); 2579 let r = this.children; 2580 for (let i = 0, a = r.length; i < a; i++) r[i].getObjectsByProperty(e, t, n); 2581 return n; 2582 } 2583 getWorldPosition(e) { 2584 return this.updateWorldMatrix(!0, !1), e.setFromMatrixPosition(this.matrixWorld); 2585 } 2586 getWorldQuaternion(e) { 2587 return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Jn, e, Yn), e; 2588 } 2589 getWorldScale(e) { 2590 return this.updateWorldMatrix(!0, !1), this.matrixWorld.decompose(Jn, Xn, e), e; 2591 } 2592 getWorldDirection(e) { 2593 this.updateWorldMatrix(!0, !1); 2594 let t = this.matrixWorld.elements; 2595 return e.set(t[8], t[9], t[10]).normalize(); 2596 } 2597 raycast() {} 2598 traverse(e) { 2599 e(this); 2600 let t = this.children; 2601 for (let n = 0, r = t.length; n < r; n++) t[n].traverse(e); 2602 } 2603 traverseVisible(e) { 2604 if (this.visible === !1) return; 2605 e(this); 2606 let t = this.children; 2607 for (let n = 0, r = t.length; n < r; n++) t[n].traverseVisible(e); 2608 } 2609 traverseAncestors(e) { 2610 let t = this.parent; 2611 t !== null && (e(t), t.traverseAncestors(e)); 2612 } 2613 updateMatrix() { 2614 this.matrix.compose(this.position, this.quaternion, this.scale); 2615 let e = this.pivot; 2616 if (e !== null) { 2617 let t = e.x, n = e.y, r = e.z, i = this.matrix.elements; 2618 i[12] += t - i[0] * t - i[4] * n - i[8] * r, i[13] += n - i[1] * t - i[5] * n - i[9] * r, i[14] += r - i[2] * t - i[6] * n - i[10] * r; 2619 } 2620 this.matrixWorldNeedsUpdate = !0; 2621 } 2622 updateMatrixWorld(e) { 2623 this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || e) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix
2623) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, e = !0); 2624 let t = this.children; 2625 for (let n = 0, r = t.length; n < r; n++) t[n].updateMatrixWorld(e); 2626 } 2627 updateWorldMatrix(e, t, n = !1) { 2628 let r = this.parent; 2629 if (e === !0 && r !== null && r.updateWorldMatrix(!0, !1), this.matrixAutoUpdate && this.updateMatrix(), (this.matrixWorldNeedsUpdate || n) && (this.matrixWorldAutoUpdate === !0 && (this.parent === null ? this.matrixWorld.copy(this.matrix) : this.matrixWorld.multiplyMatrices(this.parent.matrixWorld, this.matrix)), this.matrixWorldNeedsUpdate = !1, n = !0), t === !0) { 2630 let e = this.children; 2631 for (let t = 0, r = e.length; t < r; t++) e[t].updateWorldMatrix(!1, !0, n); 2632 } 2633 } 2634 toJSON(e) { 2635 let t = e === void 0 || typeof e == "string", n = {}; 2636 t && (e = { 2637 geometries: {}, 2638 materials: {}, 2639 textures: {}, 2640 images: {}, 2641 shapes: {}, 2642 skeletons: {}, 2643 animations: {}, 2644 nodes: {} 2645 }, n.metadata = { 2646 version: 4.7, 2647 type: "Object", 2648 generator: "Object3D.toJSON" 2649 }); 2650 let r = {}; 2651 r.uuid = this.uuid, r.type = this.type, this.name !== "" && (r.name = this.name), this.castShadow === !0 && (r.castShadow = !0), this.receiveShadow === !0 && (r.receiveShadow = !0), this.visible === !1 && (r.visible = !1), this.frustumCulled === !1 && (r.frustumCulled = !1), this.renderOrder !== 0 && (r.renderOrder = this.renderOrder), this.static !== !1 && (r.static = this.static), Object.keys(this.userData).length > 0 && (r.userData = this.userData), r.layers = this.layers.mask, r.matrix = this.matrix.toArray(), r.up = this.up.toArray(), this.pivot !== null && (r.pivot = this.pivot.toArray()), this.matrixAutoUpdate === !1 && (r.matrixAutoUpdate = !1), this.morphTargetDictionary !== void 0 && (r.morphTargetDictionary = Object.assign({}, this.morphTargetDictionary)), this.morphTargetInfluences !== void 0 && (r.morphTargetInfluences = this.morphTargetInfluences.slice()), this.isInstancedMesh && (r.type = "InstancedMesh", r.count = this.count, r.instanceMatrix = this.instanceMatrix.toJSON(), this.instanceColor !== null && (r.instanceColor = this.instanceColor.toJSON())), this.isBatchedMesh && (r.type = "BatchedMesh", r.perObjectFrustumCulled = this.perObjectFrustumCulled, r.sortObjects = this.sortObjects, r.drawRanges = this._drawRanges, r.reservedRanges = this._reservedRanges, r.geometryInfo = this._geometryInfo.map((e) => ({ 2652 ...e, 2653 boundingBox: e.boundingBox ? e.boundingBox.toJSON() : void 0, 2654 boundingSphere: e.boundingSphere ? e.boundingSphere.toJSON() : void 0 2655 })), r.instanceInfo = this._instanceInfo.map((e) => ({ ...e })), r.availableInstanceIds = this._availableInstanceIds.slice(), r.availableGeometryIds = this._availableGeometryIds.slice(), r.nextIndexStart = this._nextIndexStart, r.nextVertexStart = this._nextVertexStart, r.geometryCount = this._geometryCount, r.maxInstanceCount = this._maxInstanceCount, r.maxVertexCount = this._maxVertexCount, r.maxIndexCount = this._maxIndexCount, r.geometryInitialized = this._geometryInitialized, r.matricesTexture = this._matricesTexture.toJSON(e), r.indirectTexture = this._indirectTexture.toJSON(e), this._colorsTexture !== null && (r.colorsTexture = this._colorsTexture.toJSON(e)), this.boundingSphere !== null && (r.boundingSphere = this.boundingSphere.toJSON()), this.boundingBox !== null && (r.boundingBox = this.boundingBox.toJSON())); 2656 function i(t, n) { 2657 return t[n.uuid] === void 0 && (t[n.uuid] = n.toJSON(e)), n.uuid; 2658 } 2659 if (this.isScene) this.background && (this.background.isColor ? r.background = this.background.toJSON() : this.background.isTexture && (r.background = this.background.toJSON(e).uuid)), this.environment && this.environment.isTexture && this.environment.isRenderTargetTexture !== !0 && (r.environment = this.environment.toJSON(e).uuid); 2660 else if (this.isMesh || this.isLine || this.isPoints) { 2661 r.geometry = i(e.geometries, this.geometry); 2662 let t = this.geometry.parameters; 2663 if (t !== void 0 && t.shapes !== void 0) { 2664 let n = t.shapes; 2665 if (Array.isArray(n)) for (let t = 0, r = n.length; t < r; t++) { 2666 let r = n[t]; 2667 i(e.shapes, r); 2668 } 2669 else i(e.shapes, n); 2670 } 2671 } 2672 if (this.isSkinnedMesh && (r.bindMode = this.bindMode, r.bindMatrix = this.bindMatrix.toArray(), this.skeleton !== void 0 && (i(e.skeletons, this.skeleton), r.skeleton = this.skeleton.uuid)), this.material !== void 0) if (Array.isArray(this.material)) { 2673 let t = []; 2674 for (let n = 0, r = this.material.length; n < r; n++) t.push(i(e.materials, this.material[n])); 2675 r.material = t; 2676 } else r.material = i(e.materials, this.material); 2677 if (this.children.length > 0) { 2678 r.children = []; 2679 for (let t = 0; t < this.children.length; t++) r.children.push(this.children[t].toJSON(e).object); 2680 } 2681 if (this.animations.length > 0) { 2682 r.animations = []; 2683 for (let t = 0; t < this.animations.length; t++) { 2684 let n = this.animations[t]; 2685 r.animations.push(i(e.animations, n)); 2686 } 2687 } 2688 if (t) { 2689 let t = a(e.geometries), r = a(e.materials), i = a(e.textures), o = a(e.images), s = a(e.shapes), c = a(e.skeletons), l = a(e.animations), u = a(e.nodes); 2690 t.length > 0 && (n.geometries = t), r.length > 0 && (n.materials = r), i.length > 0 && (n.textures = i), o.length > 0 && (n.images = o), s.length >
2690 0 && (n.shapes = s), c.length > 0 && (n.skeletons = c), l.length > 0 && (n.animations = l), u.length > 0 && (n.nodes = u); 2691 } 2692 return n.object = r, n; 2693 function a(e) { 2694 let t = []; 2695 for (let n in e) { 2696 let r = e[n]; 2697 delete r.metadata, t.push(r); 2698 } 2699 return t; 2700 } 2701 } 2702 clone(e) { 2703 return new this.constructor().copy(this, e); 2704 } 2705 copy(e, t = !0) { 2706 if (this.name = e.name, this.up.copy(e.up), this.position.copy(e.position), this.rotation.order = e.rotation.order, this.quaternion.copy(e.quaternion), this.scale.copy(e.scale), this.pivot = e.pivot === null ? null : e.pivot.clone(), this.matrix.copy(e.matrix), this.matrixWorld.copy(e.matrixWorld), this.matrixAutoUpdate = e.matrixAutoUpdate, this.matrixWorldAutoUpdate = e.matrixWorldAutoUpdate, this.matrixWorldNeedsUpdate = e.matrixWorldNeedsUpdate, this.layers.mask = e.layers.mask, this.visible = e.visible, this.castShadow = e.castShadow, this.receiveShadow = e.receiveShadow, this.frustumCulled = e.frustumCulled, this.renderOrder = e.renderOrder, this.static = e.static, this.animations = e.animations.slice(), this.userData = JSON.parse(JSON.stringify(e.userData)), t === !0) for (let t = 0; t < e.children.length; t++) { 2707 let n = e.children[t]; 2708 this.add(n.clone()); 2709 } 2710 return this; 2711 } 2712}; 2713ir.DEFAULT_UP = /*@__PURE__*/ new G(0, 1, 0), ir.DEFAULT_MATRIX_AUTO_UPDATE = !0, ir.DEFAULT_MATRIX_WORLD_AUTO_UPDATE = !0; 2714var ar = class extends ir { 2715 constructor() { 2716 super(), this.isGroup = !0, this.type = "Group"; 2717 } 2718}, or = { type: "move" }, sr = class { 2719 constructor() { 2720 this._targetRay = null, this._grip = null, this._hand = null; 2721 } 2722 getHandSpace() { 2723 return this._hand === null && (this._hand = new ar(), this._hand.matrixAutoUpdate = !1, this._hand.visible = !1, this._hand.joints = {}, this._hand.inputState = { pinching: !1 }), this._hand; 2724 } 2725 getTargetRaySpace() { 2726 return this._targetRay === null && (this._targetRay = new ar(), this._targetRay.matrixAutoUpdate = !1, this._targetRay.visible = !1, this._targetRay.hasLinearVelocity = !1, this._targetRay.linearVelocity = new G(), this._targetRay.hasAngularVelocity = !1, this._targetRay.angularVelocity = new G()), this._targetRay; 2727 } 2728 getGripSpace() { 2729 return this._grip === null && (this._grip = new ar(), this._grip.matrixAutoUpdate = !1, this._grip.visible = !1, this._grip.hasLinearVelocity = !1, this._grip.linearVelocity = new G(), this._grip.hasAngularVelocity = !1, this._grip.angularVelocity = new G(), this._grip.eventsEnabled = !1), this._grip; 2730 } 2731 dispatchEvent(e) { 2732 return this._targetRay !== null && this._targetRay.dispatchEvent(e), this._grip !== null && this._grip.dispatchEvent(e), this._hand !== null && this._hand.dispatchEvent(e), this; 2733 } 2734 connect(e) { 2735 if (e && e.hand) { 2736 let t = this._hand; 2737 if (t) for (let n of e.hand.values()) this._getHandJoint(t, n); 2738 } 2739 return this.dispatchEvent({ 2740 type: "connected", 2741 data: e 2742 }), this; 2743 } 2744 disconnect(e) { 2745 return this.dispatchEvent({ 2746 type: "disconnected", 2747 data: e 2748 }), this._targetRay !== null && (this._targetRay.visible = !1), this._grip !== null && (this._grip.visible = !1), this._hand !== null && (this._hand.visible = !1), this; 2749 } 2750 update(e, t, n) { 2751 let r = null, i = null, a = null, o = this._targetRay, s = this._grip, c = this._hand; 2752 if (e && t.session.visibilityState !== "visible-blurred") { 2753 if (c && e.hand) { 2754 a = !0; 2755 for (let r of e.hand.values()) { 2756 let e = t.getJointPose(r, n), i = this._getHandJoint(c, r); 2757 e !== null && (i.matrix.fromArray(e.transform.matrix), i.matrix.decompose(i.position, i.rotation, i.scale), i.matrixWorldNeedsUpdate = !0, i.jointRadius = e.radius), i.visible = e !== null; 2758 } 2759 let r = c.joints["index-finger-tip"], i = c.joints["thumb-tip"], o = r.position.distanceTo(i.position); 2760 c.inputState.pinching && o > .025 ? (c.inputState.pinching = !1, this.dispatchEvent({ 2761 type: "pinchend", 2762 handedness: e.handedness, 2763 target: this 2764 })) : !c.inputState.pinching && o <= .015 && (c.inputState.pinching = !0, this.dispatchEvent({ 2765 type: "pinchstart", 2766 handedness: e.handedness, 2767 target: this 2768 })); 2769 } else s !== null && e.gripSpace && (i = t.getPose(e.gripSpace, n), i !== null && (s.matrix.fromArray(i.transform.matrix), s.matrix.decompose(s.position, s.rotation, s.scale), s.matrixWorldNeedsUpdate = !0, i.linearVelocity ? (s.hasLinearVelocity = !0, s.linearVelocity.copy(i.linearVelocity)) : s.hasLinearVelocity = !1, i.angularVelocity ? (s.hasAngularVelocity = !0, s.angularVelocity.copy(i.angularVelocity)) : s.hasAngularVelocity = !1, s.eventsEnabled && s.dispatchEvent({ 2770 type: "gripUpdated", 2771 data: e, 2772 target: this 2773 }))); 2774 o !== null && (r = t.getPose(e.targetRaySpace, n), r === null && i !== null && (r = i), r !== null && (o.matrix.fromArray(r.transform.matrix), o.matrix.decompose(o.position, o.rotation, o.scale), o.matrixWorldNeedsUpdate = !0, r.linearVelocity ? (o.hasLinearVelocity = !0, o.linearVelocity.copy(r.linearVelocity)) : o.hasLinearVelocity = !1, r.angularVelocity ? (o.hasAngularVelocity = !0, o.angularVelocity.copy(r.angularVelocity)) : o.hasAngularVelocity = !1, this.dispatchEvent(or))); 2775 } 2776 return o !== null && (o.visible = r !== null), s !== null && (s.visible = i !== null), c !== null && (c.visible = a !== null), this; 2777 } 2778 _getHandJoint(e, t) { 2779 if (e.joints[t.jointName] === void 0) { 2780 let n = new ar(); 2781 n.matrixAutoUpdate = !1, n.visible = !1, e.joints[t.jointName] = n, e.add(n); 2782 } 2783 return e.joints[t.jointName]; 2784 } 2785}, cr = { 2786 aliceblue: 15792383, 2787 antiquewhite: 16444375, 2788 aqua: 65535, 2789 aquamarine: 8388564, 2790 azure: 15794175, 2791 beige: 16119260, 2792 bisque: 16770244, 2793 black: 0, 2794 blanchedalmond: 16772045, 2795 blue: 255, 2796 blueviolet: 9055202, 2797 brown: 10824234, 2798 burlywood: 14596231, 2799 cadetblue: 6266528, 2800 chartreuse: 8388352, 2801 chocolate: 13789470, 2802 coral: 16744272, 2803 cornflowerblue: 6591981, 2804 cornsilk: 16775388, 2805 crimson: 14423100, 2806 cyan: 65535, 2807 darkblue: 139, 2808 darkcyan: 35723, 2809 darkgoldenrod: 12092939, 2810 darkgray: 11119017, 2811 darkgreen: 25600, 2812 darkgrey: 11119017, 2813 darkkhaki: 12433259, 2814 darkmagenta: 9109643, 2815 darkolivegreen: 5597999, 2816 darkorange: 16747520, 2817 darkorchid: 10040012, 2818 darkred: 9109504, 2819 darksalmon: 15308410, 2820 darkseagreen: 9419919, 2821 darkslateblue: 4734347, 2822 darkslategray: 3100495, 2823 darkslategrey: 3100495, 2824 darkturquoise: 52945, 2825 darkviolet: 9699539, 2826 deeppink: 16716947, 2827 deepskyblue: 49151, 2828 dimgray: 6908265, 2829 dimgrey: 6908265, 2830 dodgerblue: 2003199, 2831 firebrick: 11674146, 2832 floralwhite: 16775920, 2833 forestgreen: 2263842, 2834 fuchsia: 16711935, 2835 gainsboro: 14474460, 2836 ghostwhite: 16316671, 2837 gold: 16766720, 2838 goldenrod: 14329120, 2839 gray: 8421504, 2840 green: 32768, 2841 greenyellow: 11403055, 2842 grey: 8421504, 2843 honeydew: 15794160, 2844 hotpink: 16738740, 2845 indianred: 13458524, 2846 indigo: 4915330, 2847 ivory: 16777200, 2848 khaki: 15787660, 2849 lavender: 15132410, 2850 lavenderblush: 16773365, 2851 lawngreen: 8190976, 2852 lemonchiffon: 16775885, 2853 lightblue: 11393254, 2854 lightcoral: 15761536, 2855 lightcyan: 14745599, 2856 lightgoldenrodyellow: 16448210, 2857 lightgray: 13882323, 2858 lightgreen: 9498256, 2859 lightgrey: 13882323, 2860 lightpink: 16758465, 2861 lightsalmon: 16752762, 2862 lightseagreen: 2142890, 2863 lightskyblue: 8900346, 2864 lightslategray: 7833753, 2865 lightslategrey: 7833753, 2866 lightsteelblue: 11584734, 2867 lightyellow: 16777184, 2868 lime: 65280, 2869 limegreen: 3329330, 2870 linen: 16445670, 2871 magenta: 16711935, 2872 maroon: 8388608, 2873 mediumaquamarine: 6737322, 2874 mediumblue: 205, 2875 mediumorchid: 12211667, 2876 mediumpurple: 9662683, 2877 mediumseagreen: 3978097, 2878 mediumslateblue: 8087790, 2879 mediumspringgreen: 64154, 2880 mediumturquoise: 4772300, 2881 mediumvioletred: 13047173, 2882 midnightblue: 1644912, 2883 mintcream: 16121850, 2884 mistyrose: 16770273, 2885 moccasin: 16770229, 2886 navajowhite: 16768685, 2887 navy: 128, 2888 oldlace: 16643558, 2889 olive: 8421376, 2890 olivedrab: 7048739, 2891 orange: 16753920, 2892 orangered: 16729344, 2893 orchid: 14315734, 2894 palegoldenrod: 15657130, 2895 palegreen: 10025880, 2896 paleturquoise: 11529966, 2897 palevioletred: 14381203, 2898 papayawhip: 16773077, 2899 peachpuff: 16767673, 2900 peru: 13468991, 2901 pink: 16761035, 2902 plum: 14524637, 2903 powderblue: 11591910, 2904 purple: 8388736, 2905 rebeccapurple: 6697881, 2906 red: 16711680, 2907 rosybrown: 12357519, 2908 royalblue: 4286945,
vendor: 8,991 bytes, lines 2909-3128
2909 saddlebrown: 9127187, 2910 salmon: 16416882, 2911 sandybrown: 16032864, 2912 seagreen: 3050327, 2913 seashell: 16774638, 2914 sienna: 10506797, 2915 silver: 12632256, 2916 skyblue: 8900331, 2917 slateblue: 6970061, 2918 slategray: 7372944, 2919 slategrey: 7372944, 2920 snow: 16775930, 2921 springgreen: 65407, 2922 steelblue: 4620980, 2923 tan: 13808780, 2924 teal: 32896, 2925 thistle: 14204888, 2926 tomato: 16737095, 2927 turquoise: 4251856, 2928 violet: 15631086, 2929 wheat: 16113331, 2930 white: 16777215, 2931 whitesmoke: 16119285, 2932 yellow: 16776960, 2933 yellowgreen: 10145074 2934}, lr = { 2935 h: 0, 2936 s: 0, 2937 l: 0 2938}, ur = { 2939 h: 0, 2940 s: 0, 2941 l: 0 2942}; 2943function dr(e, t, n) { 2944 return n < 0 && (n += 1), n > 1 && --n, n < 1 / 6 ? e + (t - e) * 6 * n : n < 1 / 2 ? t : n < 2 / 3 ? e + (t - e) * 6 * (2 / 3 - n) : e; 2945} 2946var Y = class { 2947 constructor(e, t, n) { 2948 return this.isColor = !0, this.r = 1, this.g = 1, this.b = 1, this.set(e, t, n); 2949 } 2950 set(e, t, n) { 2951 if (t === void 0 && n === void 0) { 2952 let t = e; 2953 t && t.isColor ? this.copy(t) : typeof t == "number" ? this.setHex(t) : typeof t == "string" && this.setStyle(t); 2954 } else this.setRGB(e, t, n); 2955 return this; 2956 } 2957 setScalar(e) { 2958 return this.r = e, this.g = e, this.b = e, this; 2959 } 2960 setHex(e, t = bt) { 2961 return e = Math.floor(e), this.r = (e >> 16 & 255) / 255, this.g = (e >> 8 & 255) / 255, this.b = (e & 255) / 255, q.colorSpaceToWorking(this, t), this; 2962 } 2963 setRGB(e, t, n, r = q.workingColorSpace) { 2964 return this.r = e, this.g = t, this.b = n, q.colorSpaceToWorking(this, r), this; 2965 } 2966 setHSL(e, t, n, r = q.workingColorSpace) { 2967 if (e = Ut(e, 1), t = H(t, 0, 1), n = H(n, 0, 1), t === 0) this.r = this.g = this.b = n; 2968 else { 2969 let r = n <= .5 ? n * (1 + t) : n + t - n * t, i = 2 * n - r; 2970 this.r = dr(i, r, e + 1 / 3), this.g = dr(i, r, e), this.b = dr(i, r, e - 1 / 3); 2971 } 2972 return q.colorSpaceToWorking(this, r), this; 2973 } 2974 setStyle(e, t = bt) { 2975 function n(t) { 2976 t !== void 0 && parseFloat(t) < 1 && B("Color: Alpha component of " + e + " will be ignored."); 2977 } 2978 let r; 2979 if (r = /^(\w+)\(([^\)]*)\)/.exec(e)) { 2980 let i, a = r[1], o = r[2]; 2981 switch (a) { 2982 case "rgb": 2983 case "rgba": 2984 if (i = /^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(i[4]), this.setRGB(Math.min(255, parseInt(i[1], 10)) / 255, Math.min(255, parseInt(i[2], 10)) / 255, Math.min(255, parseInt(i[3], 10)) / 255, t); 2985 if (i = /^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(i[4]), this.setRGB(Math.min(100, parseInt(i[1], 10)) / 100, Math.min(100, parseInt(i[2], 10)) / 100, Math.min(100, parseInt(i[3], 10)) / 100, t); 2986 break; 2987 case "hsl": 2988 case "hsla": 2989 if (i = /^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)) return n(i[4]), this.setHSL(parseFloat(i[1]) / 360, parseFloat(i[2]) / 100, parseFloat(i[3]) / 100, t); 2990 break; 2991 default: B("Color: Unknown color model " + e); 2992 } 2993 } else if (r = /^\#([A-Fa-f\d]+)$/.exec(e)) { 2994 let n = r[1], i = n.length; 2995 if (i === 3) return this.setRGB(parseInt(n.charAt(0), 16) / 15, parseInt(n.charAt(1), 16) / 15, parseInt(n.charAt(2), 16) / 15, t); 2996 if (i === 6) return this.setHex(parseInt(n, 16), t); 2997 B("Color: Invalid hex color " + e); 2998 } else if (e && e.length > 0) return this.setColorName(e, t); 2999 return this; 3000 } 3001 setColorName(e, t = bt) { 3002 let n = cr[e.toLowerCase()]; 3003 return n === void 0 ? B("Color: Unknown color " + e) : this.setHex(n, t), this; 3004 } 3005 clone() { 3006 return new this.constructor(this.r, this.g, this.b); 3007 } 3008 copy(e) { 3009 return this.r = e.r, this.g = e.g, this.b = e.b, this; 3010 } 3011 copySRGBToLinear(e) { 3012 return this.r = _n(e.r), this.g = _n(e.g), this.b = _n(e.b), this; 3013 } 3014 copyLinearToSRGB(e) { 3015 return this.r = vn(e.r), this.g = vn(e.g), this.b = vn(e.b), this; 3016 } 3017 convertSRGBToLinear() { 3018 return this.copySRGBToLinear(this), this; 3019 } 3020 convertLinearToSRGB() { 3021 return this.copyLinearToSRGB(this), this; 3022 } 3023 getHex(e = bt) { 3024 return q.workingToColorSpace(fr.copy(this), e), Math.round(H(fr.r * 255, 0, 255)) * 65536 + Math.round(H(fr.g * 255, 0, 255)) * 256 + Math.round(H(fr.b * 255, 0, 255)); 3025 } 3026 getHexString(e = bt) { 3027 return ("000000" + this.getHex(e).toString(16)).slice(-6); 3028 } 3029 getHSL(e, t = q.workingColorSpace) { 3030 q.workingToColorSpace(fr.copy(this), t); 3031 let n = fr.r, r = fr.g, i = fr.b, a = Math.max(n, r, i), o = Math.min(n, r, i), s, c, l = (o + a) / 2; 3032 if (o === a) s = 0, c = 0; 3033 else { 3034 let e = a - o; 3035 switch (c = l <= .5 ? e / (a + o) : e / (2 - a - o), a) { 3036 case n: 3037 s = (r - i) / e + (r < i ? 6 : 0); 3038 break; 3039 case r: 3040 s = (i - n) / e + 2; 3041 break; 3042 case i: 3043 s = (n - r) / e + 4; 3044 break; 3045 } 3046 s /= 6; 3047 } 3048 return e.h = s, e.s = c, e.l = l, e; 3049 } 3050 getRGB(e, t = q.workingColorSpace) { 3051 return q.workingToColorSpace(fr.copy(this), t), e.r = fr.r, e.g = fr.g, e.b = fr.b, e; 3052 } 3053 getStyle(e = bt) { 3054 q.workingToColorSpace(fr.copy(this), e); 3055 let t = fr.r, n = fr.g, r = fr.b; 3056 return e === "srgb" ? `rgb(${Math.round(t * 255)},${Math.round(n * 255)},${Math.round(r * 255)})` : `color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`; 3057 } 3058 offsetHSL(e, t, n) { 3059 return this.getHSL(lr), this.setHSL(lr.h + e, lr.s + t, lr.l + n); 3060 } 3061 add(e) { 3062 return this.r += e.r, this.g += e.g, this.b += e.b, this; 3063 } 3064 addColors(e, t) { 3065 return this.r = e.r + t.r, this.g = e.g + t.g, this.b = e.b + t.b, this; 3066 } 3067 addScalar(e) { 3068 return this.r += e, this.g += e, this.b += e, this; 3069 } 3070 sub(e) { 3071 return this.r = Math.max(0, this.r - e.r), this.g = Math.max(0, this.g - e.g), this.b = Math.max(0, this.b - e.b), this; 3072 } 3073 multiply(e) { 3074 return this.r *= e.r, this.g *= e.g, this.b *= e.b, this; 3075 } 3076 multiplyScalar(e) { 3077 return this.r *= e, this.g *= e, this.b *= e, this; 3078 } 3079 lerp(e, t) { 3080 return this.r += (e.r - this.r) * t, this.g += (e.g - this.g) * t, this.b += (e.b - this.b) * t, this; 3081 } 3082 lerpColors(e, t, n) { 3083 return this.r = e.r + (t.r - e.r) * n, this.g = e.g + (t.g - e.g) * n, this.b = e.b + (t.b - e.b) * n, this; 3084 } 3085 lerpHSL(e, t) { 3086 this.getHSL(lr), e.getHSL(ur); 3087 let n = Kt(lr.h, ur.h, t), r = Kt(lr.s, ur.s, t), i = Kt(lr.l, ur.l, t); 3088 return this.setHSL(n, r, i), this; 3089 } 3090 setFromVector3(e) { 3091 return this.r = e.x, this.g = e.y, this.b = e.z, this; 3092 } 3093 applyMatrix3(e) { 3094 let t = this.r, n = this.g, r = this.b, i = e.elements; 3095 return this.r = i[0] * t + i[3] * n + i[6] * r, this.g = i[1] * t + i[4] * n + i[7] * r, this.b = i[2] * t + i[5] * n + i[8] * r, this; 3096 } 3097 equals(e) { 3098 return e.r === this.r && e.g === this.g && e.b === this.b; 3099 } 3100 fromArray(e, t = 0) { 3101 return this.r = e[t], this.g = e[t + 1], this.b = e[t + 2], this; 3102 } 3103 toArray(e = [], t = 0) { 3104 return e[t] = this.r, e[t + 1] = this.g, e[t + 2] = this.b, e; 3105 } 3106 fromBufferAttribute(e, t) { 3107 return this.r = e.getX(t), this.g = e.getY(t), this.b = e.getZ(t), this; 3108 } 3109 toJSON() { 3110 return this.getHex(); 3111 } 3112 *[Symbol.iterator]() { 3113 yield this.r, yield this.g, yield this.b; 3114 } 3115}, fr = /*@__PURE__*/ new Y(); 3116Y.NAMES = cr; 3117var pr = class extends ir { 3118 constructor() { 3119 super(), this.isScene = !0, this.type = "Scene", this.background = null, this.environment = null, this.fog = null, this.backgroundBlurriness = 0, this.backgroundIntensity = 1, this.backgroundRotation = new Vn(), this.environmentIntensity = 1, this.environmentRotation = new Vn(), this.overrideMaterial = null, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); 3120 } 3121 copy(e, t) { 3122 return super.copy(e, t), e.background !== null && (this.background = e.background.clone()), e.environment !== null && (this.environment = e.environment.clone()), e.fog !== null && (this.fog = e.fog.clone()), this.backgroundBlurriness = e.backgroundBlurriness, this.backgroundIntensity = e.backgroundIntensity, this.backgroundRotation.copy(e.backgroundRotation), this.environmentIntensity = e.environmentIntensity, this.environmentRotation.copy(e.environmentRotation), e.overrideMaterial !== null && (this.overrideMaterial = e.overrideMaterial.clone()), this.matrixAutoUpdate = e.matrixAutoUpdate, this; 3123 } 3124 toJSON(e) { 3125 let t = super.toJSON(e); 3126 return this.fog !== null && (t.object.fog = this.fog.toJSON()), this.backgroundBlurriness > 0 && (t.object.backgroundBlurriness = this.backgroundBlurriness), this.backgroundIntensity !== 1 && (t.object.backgroundIntensity = this.backgroundIntensity), t.object.backgroundRotation = this.backgroundRotation.toArray(), this.environmentIntensity !== 1 && (t.object.environmentIntensity = this.environmentIntensity), t.object.environmentRotation = this.environmentRotation.toArray(), t; 3127 } 3128}, mr = /*@__PURE__*/ new G(), hr = /*@__PURE__*/ new G(), gr = /*@__PURE__*/ new G(), _r = /*@__PURE__*/ new G(), vr = /*@__PURE__*/ new G(), yr = /*@__PURE__*/ new G(), br = /*@__PURE__*/ new G(), xr = /*@__PURE__*/ new G(), Sr = /*@__PURE__*/ new G(), Cr = /*@__PURE__*/ new G(), wr = /*@__PURE__*/ new J(), Tr = /*@__PURE__*/ new J(), Er = /*@__PURE__*/ new J(), Dr = class e {
3129 constructor(e = new G(), t = new G(), n = new G()) { 3130 this.a = e, this.b = t, this.c = n; 3131 } 3132 static getNormal(e, t, n, r) { 3133 r.subVectors(n, t), mr.subVectors(e, t), r.cross(mr); 3134 let i = r.lengthSq(); 3135 return i > 0 ? r.multiplyScalar(1 / Math.sqrt(i)) : r.set(0, 0, 0); 3136 } 3137 static getBarycoord(e, t, n, r, i) { 3138 mr.subVectors(r, t), hr.subVectors(n, t), gr.subVectors(e, t); 3139 let a = mr.dot(mr), o = mr.dot(hr), s = mr.dot(gr), c = hr.dot(hr), l = hr.dot(gr), u = a * c - o * o; 3140 if (u === 0) return i.set(0, 0, 0), null; 3141 let d = 1 / u, f = (c * s - o * l) * d, p = (a * l - o * s) * d; 3142 return i.set(1 - f - p, p, f); 3143 } 3144 static containsPoint(e, t, n, r) { 3145 return this.getBarycoord(e, t, n, r, _r) !== null && _r.x >= 0 && _r.y >= 0 && _r.x + _r.y <= 1; 3146 } 3147 static getInterpolation(e, t, n, r, i, a, o, s) { 3148 return this.getBarycoord(e, t, n, r, _r) === null ? (s.x = 0, s.y = 0, "z" in s && (s.z = 0), "w" in s && (s.w = 0), null) : (s.setScalar(0), s.addScaledVector(i, _r.x), s.addScaledVector(a, _r.y), s.addScaledVector(o, _r.z), s); 3149 } 3150 static getInterpolatedAttribute(e, t, n, r, i, a) { 3151 return wr.setScalar(0), Tr.setScalar(0), Er.setScalar(0), wr.fromBufferAttribute(e, t), Tr.fromBufferAttribute(e, n), Er.fromBufferAttribute(e, r), a.setScalar(0), a.addScaledVector(wr, i.x), a.addScaledVector(Tr, i.y), a.addScaledVector(Er, i.z), a; 3152 } 3153 static isFrontFacing(e, t, n, r) { 3154 return mr.subVectors(n, t), hr.subVectors(e, t), mr.cross(hr).dot(r) < 0; 3155 } 3156 set(e, t, n) { 3157 return this.a.copy(e), this.b.copy(t), this.c.copy(n), this; 3158 } 3159 setFromPointsAndIndices(e, t, n, r) { 3160 return this.a.copy(e[t]), this.b.copy(e[n]), this.c.copy(e[r]), this; 3161 } 3162 setFromAttributeAndIndices(e, t, n, r) { 3163 return this.a.fromBufferAttribute(e, t), this.b.fromBufferAttribute(e, n), this.c.fromBufferAttribute(e, r), this; 3164 } 3165 clone() { 3166 return new this.constructor().copy(this); 3167 } 3168 copy(e) { 3169 return this.a.copy(e.a), this.b.copy(e.b), this.c.copy(e.c), this; 3170 } 3171 getArea() { 3172 return mr.subVectors(this.c, this.b), hr.subVectors(this.a, this.b), mr.cross(hr).length() * .5; 3173 } 3174 getMidpoint(e) { 3175 return e.addVectors(this.a, this.b).add(this.c).multiplyScalar(1 / 3); 3176 } 3177 getNormal(t) { 3178 return e.getNormal(this.a, this.b, this.c, t); 3179 } 3180 getPlane(e) { 3181 return e.setFromCoplanarPoints(this.a, this.b, this.c); 3182 } 3183 getBarycoord(t, n) { 3184 return e.getBarycoord(t, this.a, this.b, this.c, n); 3185 } 3186 getInterpolation(t, n, r, i, a) { 3187 return e.getInterpolation(t, this.a, this.b, this.c, n, r, i, a); 3188 } 3189 containsPoint(t) { 3190 return e.containsPoint(t, this.a, this.b, this.c); 3191 } 3192 isFrontFacing(t) { 3193 return e.isFrontFacing(this.a, this.b, this.c, t); 3194 } 3195 intersectsBox(e) { 3196 return e.intersectsTriangle(this); 3197 } 3198 closestPointToPoint(e, t) { 3199 let n = this.a, r = this.b, i = this.c, a, o; 3200 vr.subVectors(r, n), yr.subVectors(i, n), xr.subVectors(e, n); 3201 let s = vr.dot(xr), c = yr.dot(xr); 3202 if (s <= 0 && c <= 0) return t.copy(n); 3203 Sr.subVectors(e, r); 3204 let l = vr.dot(Sr), u = yr.dot(Sr); 3205 if (l >= 0 && u <= l) return t.copy(r); 3206 let d = s * u - l * c; 3207 if (d <= 0 && s >= 0 && l <= 0) return a = s / (s - l), t.copy(n).addScaledVector(vr, a); 3208 Cr.subVectors(e, i); 3209 let f = vr.dot(Cr), p = yr.dot(Cr); 3210 if (p >= 0 && f <= p) return t.copy(i); 3211 let m = f * c - s * p; 3212 if (m <= 0 && c >= 0 && p <= 0) return o = c / (c - p), t.copy(n).addScaledVector(yr, o); 3213 let h = l * p - f * u; 3214 if (h <= 0 && u - l >= 0 && f - p >= 0) return br.subVectors(i, r), o = (u - l) / (u - l + (f - p)), t.copy(r).addScaledVector(br, o); 3215 let g = 1 / (h + m + d); 3216 return a = m * g, o = d * g, t.copy(n).addScaledVector(vr, a).addScaledVector(yr, o); 3217 } 3218 equals(e) { 3219 return e.a.equals(this.a) && e.b.equals(this.b) && e.c.equals(this.c); 3220 } 3221}, Or = class { 3222 constructor(e = new G(Infinity, Infinity, Infinity), t = new G(-Infinity, -Infinity, -Infinity)) { 3223 this.isBox3 = !0, this.min = e, this.max = t; 3224 } 3225 set(e, t) { 3226 return this.min.copy(e), this.max.copy(t), this; 3227 } 3228 setFromArray(e) { 3229 this.makeEmpty(); 3230 for (let t = 0, n = e.length; t < n; t += 3) this.expandByPoint(Ar.fromArray(e, t)); 3231 return this; 3232 } 3233 setFromBufferAttribute(e) { 3234 this.makeEmpty(); 3235 for (let t = 0, n = e.count; t < n; t++) this.expandByPoint(Ar.fromBufferAttribute(e, t)); 3236 return this; 3237 } 3238 setFromPoints(e) { 3239 this.makeEmpty(); 3240 for (let t = 0, n = e.length; t < n; t++) this.expandByPoint(e[t]); 3241 return this; 3242 } 3243 setFromCenterAndSize(e, t) { 3244 let n = Ar.copy(t).multiplyScalar(.5); 3245 return this.min.copy(e).sub(n), this.max.copy(e).add(n), this; 3246 } 3247 setFromObject(e, t = !1) { 3248 return this.makeEmpty(), this.expandByObject(e, t); 3249 } 3250 clone() { 3251 return new this.constructor().copy(this); 3252 } 3253 copy(e) { 3254 return this.min.copy(e.min), this.max.copy(e.max), this; 3255 } 3256 makeEmpty() { 3257 return this.min.x = this.min.y = this.min.z = Infinity, this.max.x = this.max.y = this.max.z = -Infinity, this; 3258 } 3259 isEmpty() { 3260 return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
vendor: 6,747 bytes, lines 3261-3440
3261 } 3262 getCenter(e) { 3263 return this.isEmpty() ? e.set(0, 0, 0) : e.addVectors(this.min, this.max).multiplyScalar(.5); 3264 } 3265 getSize(e) { 3266 return this.isEmpty() ? e.set(0, 0, 0) : e.subVectors(this.max, this.min); 3267 } 3268 expandByPoint(e) { 3269 return this.min.min(e), this.max.max(e), this; 3270 } 3271 expandByVector(e) { 3272 return this.min.sub(e), this.max.add(e), this; 3273 } 3274 expandByScalar(e) { 3275 return this.min.addScalar(-e), this.max.addScalar(e), this; 3276 } 3277 expandByObject(e, t = !1) { 3278 e.updateWorldMatrix(!1, !1); 3279 let n = e.geometry; 3280 if (n !== void 0) { 3281 let r = n.getAttribute("position"); 3282 if (t === !0 && r !== void 0 && e.isInstancedMesh !== !0) for (let t = 0, n = r.count; t < n; t++) e.isMesh === !0 ? e.getVertexPosition(t, Ar) : Ar.fromBufferAttribute(r, t), Ar.applyMatrix4(e.matrixWorld), this.expandByPoint(Ar); 3283 else e.boundingBox === void 0 ? (n.boundingBox === null && n.computeBoundingBox(), jr.copy(n.boundingBox)) : (e.boundingBox === null && e.computeBoundingBox(), jr.copy(e.boundingBox)), jr.applyMatrix4(e.matrixWorld), this.union(jr); 3284 } 3285 let r = e.children; 3286 for (let e = 0, n = r.length; e < n; e++) this.expandByObject(r[e], t); 3287 return this; 3288 } 3289 containsPoint(e) { 3290 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; 3291 } 3292 containsBox(e) { 3293 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; 3294 } 3295 getParameter(e, t) { 3296 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)); 3297 } 3298 intersectsBox(e) { 3299 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; 3300 } 3301 intersectsSphere(e) { 3302 return this.clampPoint(e.center, Ar), Ar.distanceToSquared(e.center) <= e.radius * e.radius; 3303 } 3304 intersectsPlane(e) { 3305 let t, n; 3306 return e.normal.x > 0 ? (t = e.normal.x * this.min.x, n = e.normal.x * this.max.x) : (t = e.normal.x * this.max.x, n = e.normal.x * this.min.x), e.normal.y > 0 ? (t += e.normal.y * this.min.y, n += e.normal.y * this.max.y) : (t += e.normal.y * this.max.y, n += e.normal.y * this.min.y), e.normal.z > 0 ? (t += e.normal.z * this.min.z, n += e.normal.z * this.max.z) : (t += e.normal.z * this.max.z, n += e.normal.z * this.min.z), t <= -e.constant && n >= -e.constant; 3307 } 3308 intersectsTriangle(e) { 3309 if (this.isEmpty()) return !1; 3310 this.getCenter(Rr), zr.subVectors(this.max, Rr), Mr.subVectors(e.a, Rr), Nr.subVectors(e.b, Rr), Pr.subVectors(e.c, Rr), Fr.subVectors(Nr, Mr), Ir.subVectors(Pr, Nr), Lr.subVectors(Mr, Pr); 3311 let t = [ 3312 0, 3313 -Fr.z, 3314 Fr.y, 3315 0, 3316 -Ir.z, 3317 Ir.y, 3318 0, 3319 -Lr.z, 3320 Lr.y, 3321 Fr.z, 3322 0, 3323 -Fr.x, 3324 Ir.z, 3325 0, 3326 -Ir.x, 3327 Lr.z, 3328 0, 3329 -Lr.x, 3330 -Fr.y, 3331 Fr.x, 3332 0, 3333 -Ir.y, 3334 Ir.x, 3335 0, 3336 -Lr.y, 3337 Lr.x, 3338 0 3339 ]; 3340 return !Hr(t, Mr, Nr, Pr, zr) || (t = [ 3341 1, 3342 0, 3343 0, 3344 0, 3345 1, 3346 0, 3347 0, 3348 0, 3349 1 3350 ], !Hr(t, Mr, Nr, Pr, zr)) ? !1 : (Br.crossVectors(Fr, Ir), t = [ 3351 Br.x, 3352 Br.y, 3353 Br.z 3354 ], Hr(t, Mr, Nr, Pr, zr)); 3355 } 3356 clampPoint(e, t) { 3357 return t.copy(e).clamp(this.min, this.max); 3358 } 3359 distanceToPoint(e) { 3360 return this.clampPoint(e, Ar).distanceTo(e); 3361 } 3362 getBoundingSphere(e) { 3363 return this.isEmpty() ? e.makeEmpty() : (this.getCenter(e.center), e.radius = this.getSize(Ar).length() * .5), e; 3364 } 3365 intersect(e) { 3366 return this.min.max(e.min), this.max.min(e.max), this.isEmpty() && this.makeEmpty(), this; 3367 } 3368 union(e) { 3369 return this.min.min(e.min), this.max.max(e.max), this; 3370 } 3371 applyMatrix4(e) { 3372 return this.isEmpty() ? this : (kr[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(e), kr[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(e), kr[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(e), kr[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(e), kr[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(e), kr[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(e), kr[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(e), kr[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(e), this.setFromPoints(kr), this); 3373 } 3374 translate(e) { 3375 return this.min.add(e), this.max.add(e), this; 3376 } 3377 equals(e) { 3378 return e.min.equals(this.min) && e.max.equals(this.max); 3379 } 3380 toJSON() { 3381 return { 3382 min: this.min.toArray(), 3383 max: this.max.toArray() 3384 }; 3385 } 3386 fromJSON(e) { 3387 return this.min.fromArray(e.min), this.max.fromArray(e.max), this; 3388 } 3389}, kr = [ 3390 /*@__PURE__*/ new G(), 3391 /*@__PURE__*/ new G(), 3392 /*@__PURE__*/ new G(), 3393 /*@__PURE__*/ new G(), 3394 /*@__PURE__*/ new G(), 3395 /*@__PURE__*/ new G(), 3396 /*@__PURE__*/ new G(), 3397 /*@__PURE__*/ new G() 3398], Ar = /*@__PURE__*/ new G(), jr = /*@__PURE__*/ new Or(), Mr = /*@__PURE__*/ new G(), Nr = /*@__PURE__*/ new G(), Pr = /*@__PURE__*/ new G(), Fr = /*@__PURE__*/ new G(), Ir = /*@__PURE__*/ new G(), Lr = /*@__PURE__*/ new G(), Rr = /*@__PURE__*/ new G(), zr = /*@__PURE__*/ new G(), Br = /*@__PURE__*/ new G(), Vr = /*@__PURE__*/ new G(); 3399function Hr(e, t, n, r, i) { 3400 for (let a = 0, o = e.length - 3; a <= o; a += 3) { 3401 Vr.fromArray(e, a); 3402 let o = i.x * Math.abs(Vr.x) + i.y * Math.abs(Vr.y) + i.z * Math.abs(Vr.z), s = t.dot(Vr), c = n.dot(Vr), l = r.dot(Vr); 3403 if (Math.max(-Math.max(s, c, l), Math.min(s, c, l)) > o) return !1; 3404 } 3405 return !0; 3406} 3407var Ur = /*@__PURE__*/ new G(), Wr = /*@__PURE__*/ new W(), Gr = 0, Kr = class extends Lt { 3408 constructor(e, t, n = !1) { 3409 if (super(), Array.isArray(e)) throw TypeError("THREE.BufferAttribute: array should be a Typed Array."); 3410 this.isBufferAttribute = !0, Object.defineProperty(this, "id", { value: Gr++ }), this.name = "", this.array = e, this.itemSize = t, this.count = e === void 0 ? 0 : e.length / t, this.normalized = n, this.usage = Tt, this.updateRanges = [], this.gpuType = ve, this.version = 0; 3411 } 3412 onUploadCallback() {} 3413 set needsUpdate(e) { 3414 e === !0 && this.version++; 3415 } 3416 setUsage(e) { 3417 return this.usage = e, this; 3418 } 3419 addUpdateRange(e, t) { 3420 this.updateRanges.push({ 3421 start: e, 3422 count: t 3423 }); 3424 } 3425 clearUpdateRanges() { 3426 this.updateRanges.length = 0; 3427 } 3428 copy(e) { 3429 return this.name = e.name, this.array = new e.array.constructor(e.array), this.itemSize = e.itemSize, this.count = e.count, this.normalized = e.normalized, this.usage = e.usage, this.gpuType = e.gpuType, this; 3430 } 3431 copyAt(e, t, n) { 3432 e *= this.itemSize, n *= t.itemSize; 3433 for (let r = 0, i = this.itemSize; r < i; r++) this.array[e + r] = t.array[n + r]; 3434 return this; 3435 } 3436 copyArray(e) { 3437 return this.array.set(e), this; 3438 } 3439 applyMatrix3(e) { 3440 if (this.itemSize === 2) for (let t = 0, n = this.count; t < n;
3440 t++) Wr.fromBufferAttribute(this, t), Wr.applyMatrix3(e), this.setXY(t, Wr.x, Wr.y); 3441 else if (this.itemSize === 3) for (let t = 0, n = this.count; t < n; t++) Ur.fromBufferAttribute(this, t), Ur.applyMatrix3(e), this.setXYZ(t, Ur.x, Ur.y, Ur.z); 3442 return this; 3443 } 3444 applyMatrix4(e) { 3445 for (let t = 0, n = this.count; t < n; t++) Ur.fromBufferAttribute(this, t), Ur.applyMatrix4(e), this.setXYZ(t, Ur.x, Ur.y, Ur.z); 3446 return this; 3447 } 3448 applyNormalMatrix(e) { 3449 for (let t = 0, n = this.count; t < n; t++) Ur.fromBufferAttribute(this, t), Ur.applyNormalMatrix(e), this.setXYZ(t, Ur.x, Ur.y, Ur.z); 3450 return this; 3451 } 3452 transformDirection(e) { 3453 for (let t = 0, n = this.count; t < n; t++) Ur.fromBufferAttribute(this, t), Ur.transformDirection(e), this.setXYZ(t, Ur.x, Ur.y, Ur.z); 3454 return this; 3455 } 3456 set(e, t = 0) { 3457 return this.array.set(e, t), this; 3458 } 3459 getComponent(e, t) { 3460 let n = this.array[e * this.itemSize + t]; 3461 return this.normalized && (n = cn(n, this.array)), n; 3462 } 3463 setComponent(e, t, n) { 3464 return this.normalized && (n = U(n, this.array)), this.array[e * this.itemSize + t] = n, this; 3465 } 3466 getX(e) { 3467 let t = this.array[e * this.itemSize]; 3468 return this.normalized && (t = cn(t, this.array)), t; 3469 } 3470 setX(e, t) { 3471 return this.normalized && (t = U(t, this.array)), this.array[e * this.itemSize] = t, this; 3472 } 3473 getY(e) { 3474 let t = this.array[e * this.itemSize + 1]; 3475 return this.normalized && (t = cn(t, this.array)), t; 3476 } 3477 setY(e, t) { 3478 return this.normalized && (t = U(t, this.array)), this.array[e * this.itemSize + 1] = t, this; 3479 } 3480 getZ(e) { 3481 let t = this.array[e * this.itemSize + 2]; 3482 return this.normalized && (t = cn(t, this.array)), t; 3483 } 3484 setZ(e, t) { 3485 return this.normalized && (t = U(t, this.array)), this.array[e * this.itemSize + 2] = t, this; 3486 } 3487 getW(e) { 3488 let t = this.array[e * this.itemSize + 3]; 3489 return this.normalized && (t = cn(t, this.array)), t; 3490 } 3491 setW(e, t) { 3492 return this.normalized && (t = U(t, this.array)), this.array[e * this.itemSize + 3] = t, this; 3493 } 3494 setXY(e, t, n) { 3495 return e *= this.itemSize, this.normalized && (t = U(t, this.array), n = U(n, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this; 3496 } 3497 setXYZ(e, t, n, r) { 3498 return e *= this.itemSize, this.normalized && (t = U(t, this.array), n = U(n, this.array), r = U(r, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this; 3499 } 3500 setXYZW(e, t, n, r, i) { 3501 return e *= this.itemSize, this.normalized && (t = U(t, this.array), n = U(n, this.array), r = U(r, this.array), i = U(i, this.array)), this.array[e + 0] = t, this.array[e + 1] = n, this.array[e + 2] = r, this.array[e + 3] = i, this; 3502 } 3503 onUpload(e) { 3504 return this.onUploadCallback = e, this; 3505 } 3506 clone() { 3507 return new this.constructor(this.array, this.itemSize).copy(this); 3508 } 3509 toJSON() { 3510 let e = { 3511 itemSize: this.itemSize, 3512 type: this.array.constructor.name, 3513 array: Array.from(this.array), 3514 normalized: this.normalized 3515 }; 3516 return this.name !== "" && (e.name = this.name), this.usage !== 35044 && (e.usage = this.usage), e; 3517 } 3518 dispose() { 3519 this.dispatchEvent({ type: "dispose" }); 3520 } 3521}, qr = class extends Kr { 3522 constructor(e, t, n) { 3523 super(new Uint16Array(e), t, n); 3524 } 3525}, Jr = class extends Kr { 3526 constructor(e, t, n) { 3527 super(new Uint32Array(e), t, n); 3528 } 3529}, X = class extends Kr { 3530 constructor(e, t, n) { 3531 super(new Float32Array(e), t, n); 3532 } 3533}, Yr = /*@__PURE__*/ new Or(), Xr = /*@__PURE__*/ new G(), Zr = /*@__PURE__*/ new G(), Qr = class { 3534 constructor(e = new G(), t = -1) { 3535 this.isSphere = !0, this.center = e, this.radius = t; 3536 } 3537 set(e, t) { 3538 return this.center.copy(e), this.radius = t, this; 3539 } 3540 setFromPoints(e, t) { 3541 let n = this.center; 3542 t === void 0 ? Yr.setFromPoints(e).getCenter(n) : n.copy(t); 3543 let r = 0; 3544 for (let t = 0, i = e.length; t < i; t++) r = Math.max(r, n.distanceToSquared(e[t])); 3545 return this.radius = Math.sqrt(r), this; 3546 } 3547 copy(e) { 3548 return this.center.copy(e.center), this.radius = e.radius, this; 3549 } 3550 isEmpty() { 3551 return this.radius < 0; 3552 } 3553 makeEmpty() { 3554 return this.center.set(0, 0, 0), this.radius = -1, this; 3555 } 3556 containsPoint(e) { 3557 return e.distanceToSquared(this.center) <= this.radius * this.radius; 3558 } 3559 distanceToPoint(e) { 3560 return e.distanceTo(this.center) - this.radius; 3561 } 3562 intersectsSphere(e) { 3563 let t = this.radius + e.radius; 3564 return e.center.distanceToSquared(this.center) <= t * t; 3565 } 3566 intersectsBox(e) { 3567 return e.intersectsSphere(this); 3568 } 3569 intersectsPlane(e) { 3570 return Math.abs(e.distanceToPoint(this.center)) <= this.radius; 3571 } 3572 clampPoint(e, t) { 3573 let n = this.center.distanceToSquared(e); 3574 return t.copy(e), n > this.radius * this.radius && (t.sub(this.center).normalize(), t.multiplyScalar(this.radius).add(this.center)), t;
3575 } 3576 getBoundingBox(e) { 3577 return this.isEmpty() ? (e.makeEmpty(), e) : (e.set(this.center, this.center), e.expandByScalar(this.radius), e); 3578 } 3579 applyMatrix4(e) { 3580 return this.center.applyMatrix4(e), this.radius *= e.getMaxScaleOnAxis(), this; 3581 } 3582 translate(e) { 3583 return this.center.add(e), this; 3584 } 3585 expandByPoint(e) { 3586 if (this.isEmpty()) return this.center.copy(e), this.radius = 0, this; 3587 Xr.subVectors(e, this.center); 3588 let t = Xr.lengthSq(); 3589 if (t > this.radius * this.radius) { 3590 let e = Math.sqrt(t), n = (e - this.radius) * .5; 3591 this.center.addScaledVector(Xr, n / e), this.radius += n; 3592 } 3593 return this; 3594 } 3595 union(e) { 3596 return e.isEmpty() ? this : this.isEmpty() ? (this.copy(e), this) : (this.center.equals(e.center) === !0 ? this.radius = Math.max(this.radius, e.radius) : (Zr.subVectors(e.center, this.center).setLength(e.radius), this.expandByPoint(Xr.copy(e.center).add(Zr)), this.expandByPoint(Xr.copy(e.center).sub(Zr))), this); 3597 } 3598 equals(e) { 3599 return e.center.equals(this.center) && e.radius === this.radius; 3600 } 3601 clone() { 3602 return new this.constructor().copy(this); 3603 } 3604 toJSON() { 3605 return { 3606 radius: this.radius, 3607 center: this.center.toArray() 3608 }; 3609 } 3610 fromJSON(e) { 3611 return this.radius = e.radius, this.center.fromArray(e.center), this; 3612 } 3613}, $r = 0, ei = /*@__PURE__*/ new jn(), ti = /*@__PURE__*/ new ir(), ni = /*@__PURE__*/ new G(), ri = /*@__PURE__*/ new Or(), ii = /*@__PURE__*/ new Or(), ai = /*@__PURE__*/ new G(), oi = class e extends Lt { 3614 constructor() { 3615 super(), this.isBufferGeometry = !0, Object.defineProperty(this, "id", { value: $r++ }), this.uuid = Ht(), this.name = "", this.type = "BufferGeometry", this.index = null, this.indirect = null, this.indirectOffset = 0, this.attributes = {}, this.morphAttributes = {}, this.morphTargetsRelative = !1, this.groups = [], this.boundingBox = null, this.boundingSphere = null, this.drawRange = { 3616 start: 0, 3617 count: Infinity 3618 }, this.userData = {}, this._transformed = !1; 3619 } 3620 getIndex() { 3621 return this.index; 3622 } 3623 setIndex(e) { 3624 return Array.isArray(e) ? this.index = new (Dt(e) ? Jr : qr)(e, 1) : this.index = e, this; 3625 } 3626 setIndirect(e, t = 0) { 3627 return this.indirect = e, this.indirectOffset = t, this; 3628 } 3629 getIndirect() { 3630 return this.indirect; 3631 } 3632 getAttribute(e) { 3633 return this.attributes[e]; 3634 } 3635 setAttribute(e, t) { 3636 return this.attributes[e] = t, this; 3637 } 3638 deleteAttribute(e) { 3639 return delete this.attributes[e], this; 3640 } 3641 hasAttribute(e) { 3642 return this.attributes[e] !== void 0; 3643 } 3644 addGroup(e, t, n = 0) { 3645 this.groups.push({ 3646 start: e, 3647 count: t, 3648 materialIndex: n 3649 }); 3650 } 3651 clearGroups() { 3652 this.groups = []; 3653 } 3654 setDrawRange(e, t) { 3655 this.drawRange.start = e, this.drawRange.count = t; 3656 } 3657 applyMatrix4(e) { 3658 let t = this.attributes.position; 3659 t !== void 0 && (t.applyMatrix4(e), t.needsUpdate = !0); 3660 let n = this.attributes.normal; 3661 if (n !== void 0) { 3662 let t = new K().getNormalMatrix(e); 3663 n.applyNormalMatrix(t), n.needsUpdate = !0; 3664 } 3665 let r = this.attributes.tangent; 3666 return r !== void 0 && (r.transformDirection(e), r.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this._transformed = !0, this; 3667 } 3668 applyQuaternion(e) { 3669 return ei.makeRotationFromQuaternion(e), this.applyMatrix4(ei), this; 3670 } 3671 rotateX(e) { 3672 return ei.makeRotationX(e), this.applyMatrix4(ei), this; 3673 } 3674 rotateY(e) { 3675 return ei.makeRotationY(e), this.applyMatrix4(ei), this; 3676 } 3677 rotateZ(e) { 3678 return ei.makeRotationZ(e), this.applyMatrix4(ei), this; 3679 } 3680 translate(e, t, n) { 3681 return ei.makeTranslation(e, t, n), this.applyMatrix4(ei), this; 3682 } 3683 scale(e, t, n) { 3684 return ei.makeScale(e, t, n), this.applyMatrix4(ei), this; 3685 } 3686 lookAt(e) { 3687 return ti.lookAt(e), ti.updateMatrix(), this.applyMatrix4(ti.matrix), this; 3688 } 3689 center() { 3690 return this.computeBoundingBox(), this.boundingBox.getCenter(ni).negate(), this.translate(ni.x, ni.y, ni.z), this; 3691 } 3692 setFromPoints(e) { 3693 let t = this.getAttribute("position"); 3694 if (t === void 0) { 3695 let t = []; 3696 for (let n = 0, r = e.length; n < r; n++) { 3697 let r = e[n]; 3698 t.push(r.x, r.y, r.z || 0); 3699 } 3700 this.setAttribute("position", new X(t, 3)); 3701 } else { 3702 let n = Math.min(e.length, t.count); 3703 for (let r = 0; r < n; r++) { 3704 let n = e[r]; 3705 t.setXYZ(r, n.x, n.y, n.z || 0); 3706 } 3707 e.length > t.count && B("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."), t.needsUpdate = !0; 3708 } 3709 return this; 3710 } 3711 computeBoundingBox() { 3712 this.boundingBox === null && (this.boundingBox = new Or()); 3713 let e = this.attributes.position, t = this.morphAttributes.position; 3714 if (e && e.isGLBufferAttribute) { 3715 V("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.", this), this.boundingBox.set(new G(-Infinity, -Infinity, -Infinity), new G(Infinity, Infinity, Infinity)); 3716 return; 3717 } 3718 if (e !== void 0) { 3719 if (this.boundingBox.setFromBufferAttribute(e), t) for (let e = 0, n = t.length; e < n; e++) { 3720 let n = t[e]; 3721 ri.setFromBufferAttribute(n), this.morphTargetsRelative ? (ai.addVectors(this.boundingBox.min, ri.min), this.boundingBox.expandByPoint(ai), ai.addVectors(this.boundingBox.max, ri.max), this.boundingBox.expandByPoint(ai)) : (this.boundingBox.expandByPoint(ri.min), this.boundingBox.expandByPoint(ri.max)); 3722 } 3723 } else this.boundingBox.makeEmpty(); 3724 (isNaN(this.boundingBox.min.x) || isNaN(this.boundingBox.min.y) || isNaN(this.boundingBox.min.z)) && V("BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.", this); 3725 } 3726 computeBoundingSphere() { 3727 this.boundingSphere === null && (this.boundingSphere = new Qr()); 3728 let e = this.attributes.position, t = this.morphAttributes.position; 3729 if (e && e.isGLBufferAttribute) { 3730 V("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.", this), this.boundingSphere.set(new G(), Infinity); 3731 return; 3732 } 3733 if (e) { 3734 let n = this.boundingSphere.center; 3735 if (ri.setFromBufferAttribute(e), t) for (let e = 0, n = t.length; e < n; e++) { 3736 let n = t[e]; 3737 ii.setFromBufferAttribute(n), this.morphTargetsRelative ? (ai.addVectors(ri.min, ii.min), ri.expandByPoint(ai), ai.addVectors(ri.max, ii.max), ri.expandByPoint(ai)) : (ri.expandByPoint(ii.min), ri.expandByPoint(ii.max)); 3738 } 3739 ri.getCenter(n); 3740 let r = 0; 3741 for (let t = 0, i = e.count; t < i; t++) ai.fromBufferAttribute(e, t), r = Math.max(r, n.distanceToSquared(ai)); 3742 if (t) for (let i = 0, a = t.length; i < a; i++) { 3743 let a = t[i], o = this.morphTargetsRelative; 3744 for (let t = 0, i = a.count; t < i; t++) ai.fromBufferAttribute(a, t), o && (ni.fromBufferAttribute(e, t), ai.add(ni)), r = Math.max(r, n.distanceToSquared(ai)); 3745 } 3746 this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && V("BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.", this); 3747 } 3748 } 3749 computeTangents() { 3750 let e = this.index, t = this.attributes; 3751 if (e === null || t.position === void 0 || t.normal === void 0 || t.uv === void 0) { 3752 V("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)"); 3753 return; 3754 } 3755 let n = t.position, r = t.normal, i = t.uv, a = this.getAttribute("tangent"); 3756 (a === void 0 || a.count !== n.count) && (a = new Kr(new Float32Array(4 * n.count), 4), this.setAttribute("tangent", a)); 3757 let o = [], s = []; 3758 for (let e = 0; e < n.count; e++) o[e] = new G(), s[e] = new G(); 3759 let c = new G(), l = new G(), u = new G(), d = new W(), f = new W(), p = new W(), m = new G(), h = new G(); 3760 function g(e, t, r) { 3761 c.fromBufferAttribute(n, e), l.fromBufferAttribute(n, t), u.fromBufferAttribute(n, r), d.fromBufferAttribute(i, e), f.fromBufferAttribute(i, t), p.fromBufferAttribute(i, r), l.sub(c), u.sub(c), f.sub(d), p.sub(d); 3762 let a = 1 / (f.x * p.y - p.x * f.y); 3763 isFinite(a) && (m.copy(l).multiplyScalar(p.y).addScaledVector(u, -f.y).multiplyScalar(a), h.copy(u).multiplyScalar(f.x).addScaledVector(l, -p.x).multiplyScalar(a), o[e].add(m), o[t].add(m), o[r].add(m), s[e].add(h), s[t].add(h), s[r].add(h)); 3764 } 3765 let _ = this.groups; 3766 _.length === 0 && (_ = [{ 3767 start: 0, 3768 count: e.count 3769 }]); 3770 for (let t = 0, n = _.length; t < n; ++t) { 3771 let n = _[t], r = n.start, i = n.count; 3772 for (let t = r, n = r + i; t < n; t += 3) g(e.getX(t + 0), e.getX(t + 1), e.getX(t + 2)); 3773 } 3774 let v = new G(), y = new G(), b = new G(), x = new G(); 3775 function S(e) { 3776 b.fromBufferAttribute(r, e), x.copy(b); 3777 let t = o[e]; 3778 v.copy(t), v.sub(b.multiplyScalar(b.dot(t))).normalize(), y.crossVectors(x, t); 3779 let n = y.dot(s[e]) < 0 ? -1 : 1; 3780 a.setXYZW(e, v.x, v.y, v.z, n); 3781 } 3782 for (let t = 0, n = _.length; t < n; ++t) { 3783 let n = _[t], r = n.start, i = n.count; 3784 for (let t = r, n = r + i; t < n; t += 3) S(e.getX(t + 0)), S(e.getX(t + 1)), S(e.getX(t + 2)); 3785 } 3786 this._transformed = !0; 3787 } 3788 computeVertexNormals() { 3789 let e = this.index, t = this.getAttribute("position"); 3790 if (t !== void 0) { 3791 let n = this.getAttribute("normal"); 3792 if (n === void 0 || n.count !== t.count) n = new Kr(new Float32Array(t.count * 3), 3), this.setAttribute("normal", n); 3793 else for (let e = 0, t = n.count; e < t; e++) n.setXYZ(e, 0, 0, 0); 3794 let r = new G(), i = new G(), a = new G(), o = new G(), s = new G(), c = new G(), l = new G(), u = new G(); 3795 if (e) for (let d = 0, f = e.count; d < f; d += 3) { 3796 let f = e.getX(d + 0), p = e.getX(d + 1), m = e.getX(d + 2); 3797 r.fromBufferAttribute(t, f), i.fromBufferAttribute(t, p), a.fromBufferAttribute(t, m), l.subVectors(a, i), u.subVectors(r, i), l.cross(u), o.fromBufferAttribute(n, f), s.fromBufferAttribute(n, p), c.fromBufferAttribute(n, m), o.add(l), s.add(l), c.add(l), n.setXYZ(f, o.x, o.y, o.z), n.setXYZ(p, s.x, s.y, s.z), n.setXYZ(m, c.x, c.y, c.z); 3798 } 3799 else for (let e = 0, o = t.count; e < o; e += 3) r.fromBufferAttribute(t, e + 0), i.fromBufferAttribute(t, e + 1), a.fromBufferAttribute(t, e + 2), l.subVectors(a, i), u.subVectors(r, i), l.cross(u), n.setXYZ(e + 0, l.x, l.y, l.z), n.setXYZ(e + 1, l.x, l.y, l.z), n.setXYZ(e + 2, l.x, l.y, l.z); 3800 this.normalizeNormals(), n.needsUpdate = !0; 3801 } 3802 } 3803 normalizeNormals() { 3804 let e = this.attributes.normal; 3805 for (let t = 0, n = e.count; t < n; t++) ai.fromBufferAttribute(e, t), ai.normalize(), e.setXYZ(t, ai.x, ai.y, ai.z); 3806 } 3807 toNonIndexed() { 3808 function t(e, t) { 3809 let n = e.array, r = e.itemSize, i = e.normalized, a = new n.constructor(t.length * r), o = 0, s = 0; 3810 for (let i = 0, c = t.length; i < c; i++) { 3811 o = e.isInterleavedBufferAttribute ? t[i] * e.data.stride + e.offset : t[i] * r; 3812 for (let e = 0; e < r; e++) a[s++] = n[o++]; 3813 } 3814 return new Kr(a, r, i); 3815 } 3816 if (this.index === null) return B("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."), this; 3817 let n = new e(), r = this.index.array, i = this.attributes; 3818 for (let e in i) { 3819 let a = i[e], o = t(a, r); 3820 n.setAttribute(e, o); 3821 } 3822 let a = this.morphAttributes; 3823 for (let e in a) { 3824 let i = [], o = a[e]; 3825 for (let e = 0, n = o.length; e < n; e++) { 3826 let n = o[e], a = t(n, r); 3827 i.push(a); 3828 } 3829 n.morphAttributes[e] = i; 3830 } 3831 n.morphTargetsRelative = this.morphTargetsRelative; 3832 let o = this.groups; 3833 for (let e = 0, t = o.length; e < t; e++) { 3834 let t = o[e]; 3835 n.addGroup(t.start, t.count, t.materialIndex); 3836 } 3837 return n; 3838 } 3839 toJSON() { 3840 let e = { metadata: { 3841 version: 4.7, 3842 type: "BufferGeometry", 3843 generator: "BufferGeometry.toJSON" 3844 } }; 3845 if (e.uuid = this.uuid, e.type = this.parameters !== void 0 && this._transformed === !0 ? "BufferGeometry" : this.type, this.name !== "" && (e.name = this.name), Object.keys(this.userData).length > 0 && (e.userData = this.userData), this.parameters !== void 0 && this._transformed !== !0) { 3846 let t = this.parameters; 3847 for (let n in t) t[n] !== void 0 && (e[n] = t[n]); 3848 return e; 3849 } 3850 e.data = { attributes: {} }; 3851 let t = this.index; 3852 t !== null && (e.data.index = { 3853 type: t.array.constructor.name, 3854 array: Array.prototype.slice.call(t.array) 3855 }); 3856 let n = this.attributes; 3857 for (let t in n) { 3858 let r = n[t]; 3859 e.data.attributes[t] = r.toJSON(e.data); 3860 } 3861 let r = {}, i = !1; 3862 for (let t in this.morphAttributes) { 3863 let n = this.morphAttributes[t], a = []; 3864 for (let t = 0, r = n.length; t < r; t++) { 3865 let r = n[t]; 3866 a.push(r.toJSON(e.data)); 3867 } 3868 a.length > 0 && (r[t] = a, i = !0); 3869 } 3870 i && (e.data.morphAttributes = r, e.data.morphTargetsRelative = this.morphTargetsRelative); 3871 let a = this.groups; 3872 a.length > 0 && (e.data.groups = JSON.parse(JSON.stringify(a))); 3873 let o = this.boundingSphere; 3874 return o !== null && (e.data.boundingSphere = o.toJSON()), e; 3875 } 3876 clone() { 3877 return new this.constructor().copy(this); 3878 } 3879 copy(e) { 3880 this.index = null, this.attributes = {}, this.morphAttributes = {}, this.groups = [], this.boundingBox = null, this.boundingSphere = null; 3881 let t = {}; 3882 this.name = e.name; 3883 let n = e.index; 3884 n !== null && this.setIndex(n.clone()); 3885 let r = e.attributes; 3886 for (let e in r) { 3887 let n = r[e]; 3888 this.setAttribute(e, n.clone(t)); 3889 } 3890 let i = e.morphAttributes; 3891 for (let e in i) { 3892 let n = [], r = i[e]; 3893 for (let e = 0, i = r.length; e < i; e++) n.push(r[e].clone(t)); 3894 this.morphAttributes[e] = n; 3895 } 3896 this.morphTargetsRelative = e.morphTargetsRelative; 3897 let a = e.groups; 3898 for (let e = 0, t = a.length; e < t; e++) { 3899 let t = a[e]; 3900 this.addGroup(t.start, t.count, t.materialIndex); 3901 }
vendor: 15,585 bytes, lines 3902-4100
3902 let o = e.boundingBox; 3903 o !== null && (this.boundingBox = o.clone()); 3904 let s = e.boundingSphere; 3905 return s !== null && (this.boundingSphere = s.clone()), this.drawRange.start = e.drawRange.start, this.drawRange.count = e.drawRange.count, this.userData = e.userData, this._transformed = e._transformed, this; 3906 } 3907 dispose() { 3908 this.dispatchEvent({ type: "dispose" }); 3909 } 3910}, si = class { 3911 constructor(e, t) { 3912 this.isInterleavedBuffer = !0, this.array = e, this.stride = t, this.count = e === void 0 ? 0 : e.length / t, this.usage = Tt, this.updateRanges = [], this.version = 0, this.uuid = Ht(); 3913 } 3914 onUploadCallback() {} 3915 set needsUpdate(e) { 3916 e === !0 && this.version++; 3917 } 3918 setUsage(e) { 3919 return this.usage = e, this; 3920 } 3921 addUpdateRange(e, t) { 3922 this.updateRanges.push({ 3923 start: e, 3924 count: t 3925 }); 3926 } 3927 clearUpdateRanges() { 3928 this.updateRanges.length = 0; 3929 } 3930 copy(e) { 3931 return this.array = new e.array.constructor(e.array), this.count = e.count, this.stride = e.stride, this.usage = e.usage, this; 3932 } 3933 copyAt(e, t, n) { 3934 e *= this.stride, n *= t.stride; 3935 for (let r = 0, i = this.stride; r < i; r++) this.array[e + r] = t.array[n + r]; 3936 return this; 3937 } 3938 set(e, t = 0) { 3939 return this.array.set(e, t), this; 3940 } 3941 clone(e) { 3942 e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Ht()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = this.array.slice(0).buffer); 3943 let t = new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]), n = new this.constructor(t, this.stride); 3944 return n.setUsage(this.usage), n; 3945 } 3946 onUpload(e) { 3947 return this.onUploadCallback = e, this; 3948 } 3949 toJSON(e) { 3950 return e.arrayBuffers === void 0 && (e.arrayBuffers = {}), this.array.buffer._uuid === void 0 && (this.array.buffer._uuid = Ht()), e.arrayBuffers[this.array.buffer._uuid] === void 0 && (e.arrayBuffers[this.array.buffer._uuid] = Array.from(new Uint32Array(this.array.buffer))), { 3951 uuid: this.uuid, 3952 buffer: this.array.buffer._uuid, 3953 type: this.array.constructor.name, 3954 stride: this.stride 3955 }; 3956 } 3957}, ci = /*@__PURE__*/ new G(), li = class e { 3958 constructor(e, t, n, r = !1) { 3959 this.isInterleavedBufferAttribute = !0, this.name = "", this.data = e, this.itemSize = t, this.offset = n, this.normalized = r; 3960 } 3961 get count() { 3962 return this.data.count; 3963 } 3964 get array() { 3965 return this.data.array; 3966 } 3967 set needsUpdate(e) { 3968 this.data.needsUpdate = e; 3969 } 3970 applyMatrix4(e) { 3971 for (let t = 0, n = this.data.count; t < n; t++) ci.fromBufferAttribute(this, t), ci.applyMatrix4(e), this.setXYZ(t, ci.x, ci.y, ci.z); 3972 return this; 3973 } 3974 applyNormalMatrix(e) { 3975 for (let t = 0, n = this.count; t < n; t++) ci.fromBufferAttribute(this, t), ci.applyNormalMatrix(e), this.setXYZ(t, ci.x, ci.y, ci.z); 3976 return this; 3977 } 3978 transformDirection(e) { 3979 for (let t = 0, n = this.count; t < n; t++) ci.fromBufferAttribute(this, t), ci.transformDirection(e), this.setXYZ(t, ci.x, ci.y, ci.z); 3980 return this; 3981 } 3982 getComponent(e, t) { 3983 let n = this.array[e * this.data.stride + this.offset + t]; 3984 return this.normalized && (n = cn(n, this.array)), n; 3985 } 3986 setComponent(e, t, n) { 3987 return this.normalized && (n = U(n, this.array)), this.data.array[e * this.data.stride + this.offset + t] = n, this; 3988 } 3989 setX(e, t) { 3990 return this.normalized && (t = U(t, this.array)), this.data.array[e * this.data.stride + this.offset] = t, this; 3991 } 3992 setY(e, t) { 3993 return this.normalized && (t = U(t, this.array)), this.data.array[e * this.data.stride + this.offset + 1] = t, this; 3994 } 3995 setZ(e, t) { 3996 return this.normalized && (t = U(t, this.array)), this.data.array[e * this.data.stride + this.offset + 2] = t, this; 3997 } 3998 setW(e, t) { 3999 return this.normalized && (t = U(t, this.array)), this.data.array[e * this.data.stride + this.offset + 3] = t, this; 4000 } 4001 getX(e) { 4002 let t = this.data.array[e * this.data.stride + this.offset]; 4003 return this.normalized && (t = cn(t, this.array)), t; 4004 } 4005 getY(e) { 4006 let t = this.data.array[e * this.data.stride + this.offset + 1]; 4007 return this.normalized && (t = cn(t, this.array)), t; 4008 } 4009 getZ(e) { 4010 let t = this.data.array[e * this.data.stride + this.offset + 2]; 4011 return this.normalized && (t = cn(t, this.array)), t; 4012 } 4013 getW(e) { 4014 let t = this.data.array[e * this.data.stride + this.offset + 3]; 4015 return this.normalized && (t = cn(t, this.array)), t; 4016 } 4017 setXY(e, t, n) { 4018 return e = e * this.data.stride + this.offset, this.normalized && (t = U(t, this.array), n = U(n, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this; 4019 } 4020 setXYZ(e, t, n, r) { 4021 return e = e * this.data.stride + this.offset, this.normalized && (t = U(t, this.array), n = U(n, this.array), r = U(r, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = r, this; 4022 } 4023 setXYZW(e, t, n, r, i) { 4024 return e = e * this.data.stride + this.offset, this.normalized && (t = U(t, this.array), n = U(n, this.array), r = U(r, this.array), i = U(i, this.array)), this.data.array[e + 0] = t, this.data.array[e + 1] = n, this.data.array[e + 2] = r, this.data.array[e + 3] = i, this; 4025 } 4026 clone(t) { 4027 if (t === void 0) { 4028 Mt("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data."); 4029 let e = []; 4030 for (let t = 0; t < this.count; t++) { 4031 let n = t * this.data.stride + this.offset; 4032 for (let t = 0; t < this.itemSize; t++) e.push(this.data.array[n + t]); 4033 } 4034 return new Kr(new this.array.constructor(e), this.itemSize, this.normalized); 4035 } else return t.interleavedBuffers === void 0 && (t.interleavedBuffers = {}), t.interleavedBuffers[this.data.uuid] === void 0 && (t.interleavedBuffers[this.data.uuid] = this.data.clone(t)), new e(t.interleavedBuffers[this.data.uuid], this.itemSize, this.offset, this.normalized); 4036 } 4037 toJSON(e) { 4038 if (e === void 0) { 4039 Mt("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data."); 4040 let e = []; 4041 for (let t = 0; t < this.count; t++) { 4042 let n = t * this.data.stride + this.offset; 4043 for (let t = 0; t < this.itemSize; t++) e.push(this.data.array[n + t]); 4044 } 4045 return { 4046 itemSize: this.itemSize, 4047 type: this.array.constructor.name, 4048 array: e, 4049 normalized: this.normalized 4050 }; 4051 } else return e.interleavedBuffers === void 0 && (e.interleavedBuffers = {}), e.interleavedBuffers[this.data.uuid] === void 0 && (e.interleavedBuffers[this.data.uuid] = this.data.toJSON(e)), { 4052 isInterleavedBufferAttribute: !0, 4053 itemSize: this.itemSize, 4054 data: this.data.uuid, 4055 offset: this.offset, 4056 normalized: this.normalized 4057 }; 4058 } 4059}, ui = 0, di = class extends Lt { 4060 constructor() { 4061 super(), this.isMaterial = !0, Object.defineProperty(this, "id", { value: ui++ }), this.uuid = Ht(), this.name = "", this.type = "Material", this.blending = 1, this.side = 0, this.vertexColors = !1, this.opacity = 1, this.transparent = !1, this.alphaHash = !1, this.blendSrc = 204, this.blendDst = 205, this.blendEquation = 100, this.blendSrcAlpha = null, this.blendDstAlpha = null, this.blendEquationAlpha = null, this.blendColor = new Y(0, 0, 0), this.blendAlpha = 0, this.depthFunc = 3, this.depthTest = !0, this.depthWrite = !0, this.stencilWriteMask = 255, this.stencilFunc = 519, this.stencilRef = 0, this.stencilFuncMask = 255, this.stencilFail = wt, this.stencilZFail = wt, this.stencilZPass = wt, this.stencilWrite = !1, this.clippingPlanes = null, this.clipIntersection = !1, this.clipShadows = !1, this.shadowSide = null, this.colorWrite = !0, this.precision = null, this.polygonOffset = !1, this.polygonOffsetFactor = 0, this.polygonOffsetUnits = 0, this.dithering = !1, this.alphaToCoverage = !1, this.premultipliedAlpha = !1, this.forceSinglePass = !1, this.allowOverride = !0, this.visible = !0, this.toneMapped = !0, this.userData = {}, this.version = 0, this._alphaTest = 0; 4062 } 4063 get alphaTest() { 4064 return this._alphaTest; 4065 } 4066 set alphaTest(e) { 4067 this._alphaTest > 0 != e > 0 && this.version++, this._alphaTest = e; 4068 } 4069 onBeforeRender() {} 4070 onBeforeCompile() {} 4071 customProgramCacheKey() { 4072 return this.onBeforeCompile.toString(); 4073 } 4074 setValues(e) { 4075 if (e !== void 0) for (let t in e) { 4076 let n = e[t]; 4077 if (n === void 0) { 4078 B(`Material: parameter '${t}' has value of undefined.`); 4079 continue; 4080 } 4081 let r = this[t]; 4082 if (r === void 0) { 4083 B(`Material: '${t}' is not a property of THREE.${this.type}.`); 4084 continue; 4085 } 4086 r && r.isColor ? r.set(n) : r && r.isVector2 && n && n.isVector2 || r && r.isEuler && n && n.isEuler || r && r.isVector3 && n && n.isVector3 ? r.copy(n) : this[t] = n; 4087 } 4088 } 4089 toJSON(e) { 4090 let t = e === void 0 || typeof e == "string"; 4091 t && (e = { 4092 textures: {}, 4093 images: {} 4094 }); 4095 let n = { metadata: { 4096 version: 4.7, 4097 type: "Material", 4098 generator: "Material.toJSON" 4099 } }; 4100 n.uuid = this.uuid, n.type = this.type, this.name !== "" && (n.name = this.name), this.color && this.color.isColor && (n.color = this.color.getHex()), this.roughness !== void 0 && (n.roughness = this.roughness), this.metalness !== void 0 && (n.metalness = this.metalness), this.sheen !== void 0 && (n.sheen = this.sheen), this.sheenColor && this.sheenColor.isColor && (n.sheenColor = this.sheenColor.getHex()), this.sheenRoughness !== void 0 && (n.sheenRoughness = this.sheenRoughness), this.emissive && this.emissive.isColor && (n.emissive = this.emissive.getHex()), this.emissiveIntensity !== void 0 && this.emissiveIntensity !== 1 && (n.emissiveIntensity = this.emissiveIntensity), this.specular && this.specular.isColor && (n.specular = this.specular.getHex()), this.specularIntensity !== void 0 && (n.specularIntensity = this.specularIntensity), this.specularColor && this.specularColor.isColor && (n.specularColor = this.specularColor.getHex()), this.shininess !== void 0 && (n.shininess = this.shininess), this.clearcoat !== void 0 && (n.clearcoat = this.clearcoat), this.clearcoatRoughness !== void 0 && (n.clearcoatRoughness = this.clearcoatRoughness), this.clearcoatMap && this.clearcoatMap.isTexture && (n.clearcoatMap = this.clearcoatMap.toJSON(e).uuid), this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture && (n.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON(e).uuid), this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture && (n.clearcoatNormalMap = this.clearcoatNormalMap.toJSON(e).uuid, n.clearcoatNormalScale = this.clearcoatNormalScale.toArray()), this.sheenColorMap && this.sheenColorMap.isTexture && (n.sheenColorMap = this.sheenColorMap.toJSON(e).uuid), this.sheenRoughnessMap && this.sheenRoughnessMap.isTexture && (n.sheenRoughnessMap = this.sheenRoughnessMap.toJSON(e).uuid), this.dispersion !== void 0 && (n.dispersion = this.dispersion), this.iridescence !== void 0 && (n.iridescence = this.iridescence), this.iridescenceIOR !== void 0 && (n.iridescenceIOR = this.iridescenceIOR), this.iridescenceThicknessRange !== void 0 && (n.iridescenceThicknessRange = this.iridescenceThicknessRange), this.iridescenceMap && this.iridescenceMap.isTexture && (n.iridescenceMap = this.iridescenceMap.toJSON(e).uuid), this.iridescenceThicknessMap && this.iridescenceThicknessMap.isTexture && (n.iridescenceThicknessMap = this.iridescenceThicknessMap.toJSON(e).uuid), this.anisotropy !== void 0 && (n.anisotropy = this.anisotropy), this.anisotropyRotation !== void 0 && (n.anisotropyRotation = this.anisotropyRotation), this.anisotropyMap && this.anisotropyMap.isTexture && (n.anisotropyMap = this.anisotropyMap.toJSON(e).uuid), this.map && this.map.isTexture && (n.map = this.map.toJSON(e).uuid), this.matcap && this.matcap.isTexture && (n.matcap = this.matcap.toJSON(e).uuid), this.alphaMap && this.alphaMap.isTexture && (n.alphaMap = this.alphaMap.toJSON(e).uuid), this.lightMap && this.lightMap.isTexture && (n.lightMap = this.lightMap.toJSON(e).uuid, n.lightMapIntensity = this.lightMapIntensity), this.aoMap && this.aoMap.isTexture && (n.aoMap = this.aoMap.toJSON(e).uuid, n.aoMapIntensity = this.aoMapIntensity), this.bumpMap && this.bumpMap.isTexture && (n.bumpMap = this.bumpMap.toJSON(e).uuid, n.bumpScale = this.bumpScale), this.normalMap && this.normalMap.isTexture && (n.normalMap = this.normalMap.toJSON(e).uuid, n.normalMapType = this.normalMapType, n.normalScale = this.normalScale.toArray()), this.displacementMap && this.displacementMap.isTexture && (n.displacementMap = this.displacementMap.toJSON(e).uuid, n.displacementScale = this.displacementScale, n.displacementBias = this.displacementBias), this.roughnessMap && this.roughnessMap.isTexture && (n.roughnessMap = this.roughnessMap.toJSON(e).uuid), this.metalnessMap && this.metalnessMap.isTexture && (n.metalnessMap = this.metalnessMap.toJSON(e).uuid), this.emissiveMap && this.emissiveMap.isTexture && (n.emissiveMap = this.emissiveMap.toJSON(e).uuid), this.specularMap && this.specularMap.isTexture && (n.specularMap = this.specularMap.toJSON(e).uuid), this.specularIntensityMap && this.specularIntensityMap.isTexture && (n.specularIntensityMap = this.specularIntensityMap.toJSON(e).uuid), this.specularColorMap && this.specularColorMap.isTexture && (n.specularColorMap = this.specularColorMap.toJSON(e).uuid), this.envMap && this.envMap.isTexture && (n.envMap = this.envMap.toJSON(e).uuid, this.combine !== void 0 && (n.combine = this.combine)), this.envMapRotation !== void 0 && (n.envMapRotation = this.envMapRotation.toArray()), this.envMapIntensity !== void 0 && (n.envMapIntensity = this.envMapIntensity), this.reflectivity !== void 0 && (n.reflectivity = this.reflectivity), this.refractionRatio !== void 0 && (n.refractionRatio = this.refractionRatio), this.gradientMap && this.gradientMap.isTexture && (n.gradientMap = this.gradientMap.toJSON(e).uuid), this.transmission !== void 0 && (n.transmission = this.transmission), this.transmissionMap && this.transmissionMap.isTexture && (n.transmissionMap = this.transmissionMap.toJSON(e).uuid), this.thickness !== void 0 && (n.thickness = this.thickness), this.thicknessMap && this.thicknessMap.isTexture && (n.thicknessMap = this.thicknessMap.toJSON(e).uuid), this.attenuationDistance !== void 0 && this.attenuationDistance !== Infinity && (n.attenuationDistance = this.attenuationDistance), this.attenuationColor !== void 0 && (n.attenuationColor = this.attenuationColor.getHex()), this.size !== void 0 && (n.size = this.size), this.shadowSide !== null && (n.shadowSide = this.shadowSide), this.sizeAttenuation !== void 0 && (n.sizeAttenuation = this.sizeAttenuation), this.blending !== 1 && (n.blending = this.blending), this.side !== 0 && (n.side = this.side), this.vertexColors === !0 && (n.vertexColors = !0), this.opacity < 1 && (n.opacity = this.opacity), this.transparent === !0 && (n.transparent = !0), this.blendSrc !== 204 && (n.blendSrc = this.blendSrc), this.blendDst !== 205 && (n.blendDst = this.blendDst), this.blendEquation !== 100 && (n.blendEquation = this.blendEquation), this.blendSrcAlpha !== null && (n.blendSrcAlpha = this.blendSrcAlpha), this.blendDstAlpha !== null && (n.blendDstAlpha = this.blendDstAlpha), this.blendEquationAlpha !== null && (n.blendEquationAlpha = this.blendEquationAlpha), this.blendColor && this.blendColor.isColor && (n.blendColor = this.blendColor.getHex()), this.blendAlpha !== 0 && (n.blendAlpha = this.blendAlpha), this.depthFunc !== 3 && (n.depthFunc = this.depthFunc), this.depthTest === !1 && (n.depthTest = this.depthTest), this.depthWrite === !1 && (n.depthWrite = this.depthWrite), this.colorWrite === !1 && (n.colorWrite = this.colorWrite), this.stencilWriteMask !== 25
41005 && (n.stencilWriteMask = this.stencilWriteMask), this.stencilFunc !== 519 && (n.stencilFunc = this.stencilFunc), this.stencilRef !== 0 && (n.stencilRef = this.stencilRef), this.stencilFuncMask !== 255 && (n.stencilFuncMask = this.stencilFuncMask), this.stencilFail !== 7680 && (n.stencilFail = this.stencilFail), this.stencilZFail !== 7680 && (n.stencilZFail = this.stencilZFail), this.stencilZPass !== 7680 && (n.stencilZPass = this.stencilZPass), this.stencilWrite === !0 && (n.stencilWrite = this.stencilWrite), this.rotation !== void 0 && this.rotation !== 0 && (n.rotation = this.rotation), this.polygonOffset === !0 && (n.polygonOffset = !0), this.polygonOffsetFactor !== 0 && (n.polygonOffsetFactor = this.polygonOffsetFactor), this.polygonOffsetUnits !== 0 && (n.polygonOffsetUnits = this.polygonOffsetUnits), this.linewidth !== void 0 && this.linewidth !== 1 && (n.linewidth = this.linewidth), this.dashSize !== void 0 && (n.dashSize = this.dashSize), this.gapSize !== void 0 && (n.gapSize = this.gapSize), this.scale !== void 0 && (n.scale = this.scale), this.dithering === !0 && (n.dithering = !0), this.alphaTest > 0 && (n.alphaTest = this.alphaTest), this.alphaHash === !0 && (n.alphaHash = !0), this.alphaToCoverage === !0 && (n.alphaToCoverage = !0), this.premultipliedAlpha === !0 && (n.premultipliedAlpha = !0), this.forceSinglePass === !0 && (n.forceSinglePass = !0), this.allowOverride === !1 && (n.allowOverride = !1), this.wireframe === !0 && (n.wireframe = !0), this.wireframeLinewidth > 1 && (n.wireframeLinewidth = this.wireframeLinewidth), this.wireframeLinecap !== "round" && (n.wireframeLinecap = this.wireframeLinecap), this.wireframeLinejoin !== "round" && (n.wireframeLinejoin = this.wireframeLinejoin), this.flatShading === !0 && (n.flatShading = !0), this.visible === !1 && (n.visible = !1), this.toneMapped === !1 && (n.toneMapped = !1), this.fog === !1 && (n.fog = !1), Object.keys(this.userData).length > 0 && (n.userData = this.userData); 4101 function r(e) { 4102 let t = []; 4103 for (let n in e) { 4104 let r = e[n]; 4105 delete r.metadata, t.push(r); 4106 } 4107 return t; 4108 } 4109 if (t) { 4110 let t = r(e.textures), i = r(e.images); 4111 t.length > 0 && (n.textures = t), i.length > 0 && (n.images = i); 4112 } 4113 return n; 4114 } 4115 fromJSON(e, t) { 4116 if (e.uuid !== void 0 && (this.uuid = e.uuid), e.name !== void 0 && (this.name = e.name), e.color !== void 0 && this.color !== void 0 && this.color.setHex(e.color), e.roughness !== void 0 && (this.roughness = e.roughness), e.metalness !== void 0 && (this.metalness = e.metalness), e.sheen !== void 0 && (this.sheen = e.sheen), e.sheenColor !== void 0 && (this.sheenColor = new Y().setHex(e.sheenColor)), e.sheenRoughness !== void 0 && (this.sheenRoughness = e.sheenRoughness), e.emissive !== void 0 && this.emissive !== void 0 && this.emissive.setHex(e.emissive), e.specular !== void 0 && this.specular !== void 0 && this.specular.setHex(e.specular), e.specularIntensity !== void 0 && (this.specularIntensity = e.specularIntensity), e.specularColor !== void 0 && this.specularColor !== void 0 && this.specularColor.setHex(e.specularColor), e.shininess !== void 0 && (this.shininess = e.shininess), e.clearcoat !== void 0 && (this.clearcoat = e.clearcoat), e.clearcoatRoughness !== void 0 && (this.clearcoatRoughness = e.clearcoatRoughness), e.dispersion !== void 0 && (this.dispersion = e.dispersion), e.iridescence !== void 0 && (this.iridescence = e.iridescence), e.iridescenceIOR !== void 0 && (this.iridescenceIOR = e.iridescenceIOR), e.iridescenceThicknessRange !== void 0 && (this.iridescenceThicknessRange = e.iridescenceThicknessRange), e.transmission !== void 0 && (this.transmission = e.transmission), e.thickness !== void 0 && (this.thickness = e.thickness), e.attenuationDistance !== void 0 && (this.attenuationDistance = e.attenuationDistance), e.attenuationColor !== void 0 && this.attenuationColor !== void 0 && this.attenuationColor.setHex(e.attenuationColor), e.anisotropy !== void 0 && (this.anisotropy = e.anisotropy), e.anisotropyRotation !== void 0 && (this.anisotropyRotation = e.anisotropyRotation), e.fog !== void 0 && (this.fog = e.fog), e.flatShading !== void 0 && (this.flatShading = e.flatShading), e.blending !== void 0 && (this.blending = e.blending), e.combine !== void 0 && (this.combine = e.combine), e.side !== void 0 && (this.side = e.side), e.shadowSide !== void 0 && (this.shadowSide = e.shadowSide), e.opacity !== void 0 && (this.opacity = e.opacity), e.transparent !== void 0 && (this.transparent = e.transparent), e.alphaTest !== void 0 && (this.alphaTest = e.alphaTest), e.alphaHash !== void 0 && (this.alphaHash = e.alphaHash), e.depthFunc !== void 0 && (this.depthFunc = e.depthFunc), e.depthTest !== void 0 && (this.depthTest = e.depthTest), e.depthWrite !== void 0 && (this.depthWrite = e.depthWrite), e.colorWrite !== void 0 && (this.colorWrite = e.colorWrite), e.blendSrc !== void 0 && (this.blendSrc = e.blendSrc), e.blendDst !== void 0 && (this.blendDst = e.blendDst), e.blendEquation !== void 0 && (this.blendEquation = e.blendEquation), e.blendSrcAlpha !== void 0 && (this.blendSrcAlpha = e.blendSrcAlpha), e.blendDstAlpha !== void 0 && (this.blendDstAlpha = e.blendDstAlpha), e.blendEquationAlpha !== void 0 && (this.blendEquationAlpha = e.blendEquationAlpha), e.blendColor !== void 0 && this.blendColor !== void 0 && this.blendColor.setHex(e.blendColor), e.blendAlpha !== void 0 && (this.blendAlpha = e.blendAlpha), e.stencilWriteMask !== void 0 && (this.stencilWriteMask = e.stencilWriteMask), e.stencilFunc !== void 0 && (this.stencilFunc = e.stencilFunc), e.stencilRef !== void 0 && (this.stencilRef = e.stencilRef), e.stencilFuncMask !== void 0 && (this.stencilFuncMask = e.stencilFuncMask), e.stencilFail
4116!== void 0 && (this.stencilFail = e.stencilFail), e.stencilZFail !== void 0 && (this.stencilZFail = e.stencilZFail), e.stencilZPass !== void 0 && (this.stencilZPass = e.stencilZPass), e.stencilWrite !== void 0 && (this.stencilWrite = e.stencilWrite), e.wireframe !== void 0 && (this.wireframe = e.wireframe), e.wireframeLinewidth !== void 0 && (this.wireframeLinewidth = e.wireframeLinewidth), e.wireframeLinecap !== void 0 && (this.wireframeLinecap = e.wireframeLinecap), e.wireframeLinejoin !== void 0 && (this.wireframeLinejoin = e.wireframeLinejoin), e.rotation !== void 0 && (this.rotation = e.rotation), e.linewidth !== void 0 && (this.linewidth = e.linewidth), e.dashSize !== void 0 && (this.dashSize = e.dashSize), e.gapSize !== void 0 && (this.gapSize = e.gapSize), e.scale !== void 0 && (this.scale = e.scale), e.polygonOffset !== void 0 && (this.polygonOffset = e.polygonOffset), e.polygonOffsetFactor !== void 0 && (this.polygonOffsetFactor = e.polygonOffsetFactor), e.polygonOffsetUnits !== void 0 && (this.polygonOffsetUnits = e.polygonOffsetUnits), e.dithering !== void 0 && (this.dithering = e.dithering), e.alphaToCoverage !== void 0 && (this.alphaToCoverage = e.alphaToCoverage), e.premultipliedAlpha !== void 0 && (this.premultipliedAlpha = e.premultipliedAlpha), e.forceSinglePass !== void 0 && (this.forceSinglePass = e.forceSinglePass), e.allowOverride !== void 0 && (this.allowOverride = e.allowOverride), e.visible !== void 0 && (this.visible = e.visible), e.toneMapped !== void 0 && (this.toneMapped = e.toneMapped), e.userData !== void 0 && (this.userData = e.userData), e.vertexColors !== void 0 && (typeof e.vertexColors == "number" ? this.vertexColors = e.vertexColors > 0 : this.vertexColors = e.vertexColors), e.size !== void 0 && (this.size = e.size), e.sizeAttenuation !== void 0 && (this.sizeAttenuation = e.sizeAttenuation), e.map !== void 0 && (this.map = t[e.map] || null), e.matcap !== void 0 && (this.matcap = t[e.matcap] || null), e.alphaMap !== void 0 && (this.alphaMap = t[e.alphaMap] || null), e.bumpMap !== void 0 && (this.bumpMap = t[e.bumpMap] || null), e.bumpScale !== void 0 && (this.bumpScale = e.bumpScale), e.normalMap !== void 0 && (this.normalMap = t[e.normalMap] || null), e.normalMapType !== void 0 && (this.normalMapType = e.normalMapType), e.normalScale !== void 0) { 4117 let t = e.normalScale; 4118 Array.isArray(t) === !1 && (t = [t, t]), this.normalScale = new W().fromArray(t); 4119 } 4120 return e.displacementMap !== void 0 && (this.displacementMap = t[e.displacementMap] || null), e.displacementScale !== void 0 && (this.displacementScale = e.displacementScale), e.displacementBias !== void 0 && (this.displacementBias = e.displacementBias), e.roughnessMap !== void 0 && (this.roughnessMap = t[e.roughnessMap] || null), e.metalnessMap !== void 0 && (this.metalnessMap = t[e.metalnessMap] || null), e.emissiveMap !== void 0 && (this.emissiveMap = t[e.emissiveMap] || null), e.emissiveIntensity !== void 0 && (this.emissiveIntensity = e.emissiveIntensity), e.specularMap !== void 0 && (this.specularMap = t[e.specularMap] || null), e.specularIntensityMap !== void 0 && (this.specularIntensityMap = t[e.specularIntensityMap] || null), e.specularColorMap !== void 0 && (this.specularColorMap = t[e.specularColorMap] || null), e.envMap !== void 0 && (this.envMap = t[e.envMap] || null), e.envMapRotation !== void 0 && this.envMapRotation.fromArray(e.envMapRotation), e.envMapIntensity !== void 0 && (this.envMapIntensity = e.envMapIntensity), e.reflectivity !== void 0 && (this.reflectivity = e.reflectivity), e.refractionRatio !== void 0 && (this.refractionRatio = e.refractionRatio), e.lightMap !== void 0 && (this.lightMap = t[e.lightMap] || null), e.lightMapIntensity !== void 0 && (this.lightMapIntensity = e.lightMapIntensity), e.aoMap !== void 0 && (this.aoMap = t[e.aoMap] || null), e.aoMapIntensity !== void 0 && (this.aoMapIntensity = e.aoMapIntensity), e.gradientMap !== void 0 && (this.gradientMap = t[e.gradientMap] || null), e.clearcoatMap !== void 0 && (this.clearcoatMap = t[e.clearcoatMap] || null), e.clearcoatRoughnessMap !== void 0 && (this.clearcoatRoughnessMap = t[e.clearcoatRoughnessMap] || null), e.clearcoatNormalMap !== void 0 && (this.clearcoatNormalMap = t[e.clearcoatNormalMap] || null), e.clearcoatNormalScale !== void 0 && (this.clearcoatNormalScale = new W().fromArray(e.clearcoatNormalScale)), e.iridescenceMap !== void 0 && (this.iridescenceMap = t[e.iridescenceMap] || null), e.iridescenceThicknessMap !== void 0 && (this.iridescenceThicknessMap = t[e.iridescenceThicknessMap] || null), e.transmissionMap !== void 0 && (this.transmissionMap = t[e.transmissionMap] || null), e.thicknessMap !== void 0 && (this.thicknessMap = t[e.thicknessMap] || null), e.anisotropyMap !== void 0 && (this.anisotropyMap = t[e.anisotropyMap] || null), e.sheenColorMap !== void 0 && (this.sheenColorMap = t[e.sheenColorMap] || null), e.sheenRoughnessMap !== void 0 && (this.sheenRoughnessMap = t[e.sheenRoughnessMap] || null), this; 4121 } 4122 clone() { 4123 return new this.constructor().copy(this); 4124 } 4125 copy(e) { 4126 this.name = e.name, this.blending = e.blending, this.side = e.side, this.vertexColors = e.vertexColors, this.opacity = e.opacity, this.transparent = e.transparent, this.blendSrc = e.blendSrc, this.blendDst = e.blendDst, this.blendEquation = e.blendEquation, this.blendSrcAlpha = e.blendSrcAlpha, this.blendDstAlpha = e.blendDstAlpha, this.blendEquationAlpha = e.blendEquationAlpha, this.blendColor.copy(e.blendColor), this.blendAlpha = e.blendAlpha, this.depthFunc = e.depthFunc, this.depthTest = e.depthTest, this.depthWrite = e.depthWrite, this.stencilWriteMask = e.stencilWriteMask, this.stencilFunc = e.stencilFunc, this.stencilRef = e.stencilRef, this.stencilFuncMask = e.stencilFuncMask, this.stencilFail = e.stencilFail, this.stencilZFail = e.stencilZFail, this.stencilZPass = e.stencilZPass, this.stencilWrite = e.stencilWrite; 4127 let t = e.clippingPlanes, n = null; 4128 if (t !== null) { 4129 let e = t.length; 4130 n = Array(e); 4131 for (let r = 0; r !== e; ++r) n[r] = t[r].clone(); 4132 } 4133 return this.clippingPlanes = n, this.clipIntersection = e.clipIntersection, this.clipShadows = e.clipShadows, this.shadowSide = e.shadowSide, this.colorWrite = e.colorWrite, this.precision = e.precision, this.polygonOffset = e.polygonOffset, this.polygonOffsetFactor = e.polygonOffsetFactor, this.polygonOffsetUnits = e.polygonOffsetUnits, this.dithering = e.dithering, this.alphaTest = e.alphaTest, this.alphaHash = e.alphaHash, this.alphaToCoverage = e.alphaToCoverage, this.premultipliedAlpha = e.premultipliedAlpha, this.forceSinglePass = e.forceSinglePass, this.allowOverride = e.allowOverride, this.visible = e.visible, this.toneMapped = e.toneMapped, this.userData = JSON.parse(JSON.stringify(e.userData)), this; 4134 } 4135 dispose() { 4136 this.dispatchEvent({ type: "dispose" }); 4137 } 4138 set needsUpdate(e) { 4139 e === !0 && this.version++; 4140 } 4141}, fi = /*@__PURE__*/ new G(), pi = /*@__PURE__*/ new G(), mi = /*@__PURE__*/ new G(), hi = /*@__PURE__*/ new G(), gi = /*@__PURE__*/ new G(), _i = /*@__PURE__*/ new G(), vi = /*@__PURE__*/ new G(), yi = class { 4142 constructor(e = new G(), t = new G(0, 0, -1)) { 4143 this.origin = e, this.direction = t; 4144 } 4145 set(e, t) { 4146 return this.origin.copy(e), this.direction.copy(t), this; 4147 } 4148 copy(e) { 4149 return this.origin.copy(e.origin), this.direction.copy(e.direction), this; 4150 } 4151 at(e, t) { 4152 return t.copy(this.origin).addScaledVector(this.direction, e); 4153 } 4154 lookAt(e) { 4155 return this.direction.copy(e).sub(this.origin).normalize(), this; 4156 } 4157 recast(e) { 4158 return this.origin.copy(this.at(e, fi)), this; 4159 } 4160 closestPointToPoint(e, t) { 4161 t.subVectors(e, this.origin); 4162 let n = t.dot(this.direction); 4163 return n < 0 ? t.copy(this.origin) : t.copy(this.origin).addScaledVector(this.direction, n); 4164 } 4165 distanceToPoint(e) { 4166 return Math.sqrt(this.distanceSqToPoint(e)); 4167 } 4168 distanceSqToPoint(e) { 4169 let t = fi.subVectors(e, this.origin).dot(this.direction); 4170 return t < 0 ? this.origin.distanceToSquared(e) : (fi.copy(this.origin).addScaledVector(this.direction, t), fi.distanceToSquared(e)); 4171 } 4172 distanceSqToSegment(e, t, n, r) { 4173 pi.copy(e).add(t).multiplyScalar(.5), mi.copy(t).sub(e).normalize(), hi.copy(this.origin).sub(pi); 4174 let i = e.distanceTo(t) * .5, a = -this.direction.dot(mi), o = hi.dot(this.direction), s = -hi.dot(mi), c = hi.lengthSq(), l = Math.abs(1 - a * a), u, d, f, p; 4175 if (l > 0) if (u = a * s - o, d = a * o - s, p = i * l, u >= 0) if (d >= -p) if (d <= p) { 4176 let e = 1 / l; 4177 u *= e, d *= e, f = u * (u + a * d + 2 * o) + d * (a * u + d + 2 * s) + c; 4178 } else d = i, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * s) + c; 4179 else d = -i, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * s) + c; 4180 else d <= -p ? (u = Math.max(0, -(-a * i + o)), d = u > 0 ? -i : Math.min(Math.max(-i, -s), i), f = -u * u + d * (d + 2 * s) + c) : d <= p ? (u = 0, d = Math.min(Math.max(-i, -s), i), f = d * (d + 2 * s) + c) : (u = Math.max(0, -(a * i + o)), d = u > 0 ? i : Math.min(Math.max(-i, -s), i), f = -u * u + d * (d + 2 * s) + c); 4181 else d = a > 0 ? -i : i, u = Math.max(0, -(a * d + o)), f = -u * u + d * (d + 2 * s) + c; 4182 return n && n.copy(this.origin).addScaledVector(this.direction, u), r && r.copy(pi).addScaledVector(mi, d), f; 4183 }
4184 intersectSphere(e, t) { 4185 fi.subVectors(e.center, this.origin); 4186 let n = fi.dot(this.direction), r = fi.dot(fi) - n * n, i = e.radius * e.radius; 4187 if (r > i) return null; 4188 let a = Math.sqrt(i - r), o = n - a, s = n + a; 4189 return s < 0 ? null : o < 0 ? this.at(s, t) : this.at(o, t); 4190 } 4191 intersectsSphere(e) { 4192 return e.radius < 0 ? !1 : this.distanceSqToPoint(e.center) <= e.radius * e.radius; 4193 } 4194 distanceToPlane(e) { 4195 let t = e.normal.dot(this.direction); 4196 if (t === 0) return e.distanceToPoint(this.origin) === 0 ? 0 : null; 4197 let n = -(this.origin.dot(e.normal) + e.constant) / t; 4198 return n >= 0 ? n : null; 4199 } 4200 intersectPlane(e, t) { 4201 let n = this.distanceToPlane(e); 4202 return n === null ? null : this.at(n, t); 4203 } 4204 intersectsPlane(e) { 4205 let t = e.distanceToPoint(this.origin); 4206 return t === 0 || e.normal.dot(this.direction) * t < 0; 4207 } 4208 intersectBox(e, t) { 4209 let n, r, i, a, o, s, c = 1 / this.direction.x, l = 1 / this.direction.y, u = 1 / this.direction.z, d = this.origin; 4210 return c >= 0 ? (n = (e.min.x - d.x) * c, r = (e.max.x - d.x) * c) : (n = (e.max.x - d.x) * c, r = (e.min.x - d.x) * c), l >= 0 ? (i = (e.min.y - d.y) * l, a = (e.max.y - d.y) * l) : (i = (e.max.y - d.y) * l, a = (e.min.y - d.y) * l), n > a || i > r || ((i > n || isNaN(n)) && (n = i), (a < r || isNaN(r)) && (r = a), u >= 0 ? (o = (e.min.z - d.z) * u, s = (e.max.z - d.z) * u) : (o = (e.max.z - d.z) * u, s = (e.min.z - d.z) * u), n > s || o > r) || ((o > n || n !== n) && (n = o), (s < r || r !== r) && (r = s), r < 0) ? null : this.at(n >= 0 ? n : r, t); 4211 } 4212 intersectsBox(e) { 4213 return this.intersectBox(e, fi) !== null; 4214 } 4215 intersectTriangle(e, t, n, r, i) { 4216 gi.subVectors(t, e), _i.subVectors(n, e), vi.crossVectors(gi, _i); 4217 let a = this.direction.dot(vi), o; 4218 if (a > 0) { 4219 if (r) return null; 4220 o = 1; 4221 } else if (a < 0) o = -1, a = -a; 4222 else return null; 4223 hi.subVectors(this.origin, e); 4224 let s = o * this.direction.dot(_i.crossVectors(hi, _i)); 4225 if (s < 0) return null; 4226 let c = o * this.direction.dot(gi.cross(hi)); 4227 if (c < 0 || s + c > a) return null; 4228 let l = -o * hi.dot(vi); 4229 return l < 0 ? null : this.at(l / a, i); 4230 } 4231 applyMatrix4(e) { 4232 return this.origin.applyMatrix4(e), this.direction.transformDirection(e), this; 4233 } 4234 equals(e) { 4235 return e.origin.equals(this.origin) && e.direction.equals(this.direction); 4236 } 4237 clone() { 4238 return new this.constructor().copy(this); 4239 } 4240}, bi = class extends di { 4241 constructor(e) { 4242 super(), this.isMeshBasicMaterial = !0, this.type = "MeshBasicMaterial", this.color = new Y(16777215), this.map = null, this.lightMap = null, this.lightMapIntensity = 1, this.aoMap = null, this.aoMapIntensity = 1, this.specularMap = null, this.alphaMap = null, this.envMap = null, this.envMapRotation = new Vn(), this.combine = 0, this.reflectivity = 1, this.refractionRatio = .98, this.wireframe = !1, this.wireframeLinewidth = 1, this.wireframeLinecap = "round", this.wireframeLinejoin = "round", this.fog = !0, this.setValues(e); 4243 } 4244 copy(e) { 4245 return super.copy(e), this.color.copy(e.color), this.map = e.map, this.lightMap = e.lightMap, this.lightMapIntensity = e.lightMapIntensity, this.aoMap = e.aoMap, this.aoMapIntensity = e.aoMapIntensity, this.specularMap = e.specularMap, this.alphaMap = e.alphaMap, this.envMap = e.envMap, this.envMapRotation.copy(e.envMapRotation), this.combine = e.combine, this.reflectivity = e.reflectivity, this.refractionRatio = e.refractionRatio, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.wireframeLinecap = e.wireframeLinecap, this.wireframeLinejoin = e.wireframeLinejoin, this.fog = e.fog, this; 4246 } 4247}, xi = /*@__PURE__*/ new jn(), Si = /*@__PURE__*/ new yi(), Ci = /*@__PURE__*/ new Qr(), wi = /*@__PURE__*/ new G(), Ti = /*@__PURE__*/ new G(), Ei = /*@__PURE__*/ new G(), Di = /*@__PURE__*/ new G(), Oi = /*@__PURE__*/ new G(), ki = /*@__PURE__*/ new G(), Ai = /*@__PURE__*/ new G(), ji = /*@__PURE__*/ new G(), Mi = class extends ir { 4248 constructor(e = new oi(), t = new bi()) { 4249 super(), this.isMesh = !0, this.type = "Mesh", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.count = 1, this.updateMorphTargets(); 4250 } 4251 copy(e, t) { 4252 return super.copy(e, t), e.morphTargetInfluences !== void 0 && (this.morphTargetInfluences = e.morphTargetInfluences.slice()), e.morphTargetDictionary !== void 0 && (this.morphTargetDictionary = Object.assign({}, e.morphTargetDictionary)), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this; 4253 } 4254 updateMorphTargets() { 4255 let e = this.geometry.morphAttributes, t = Object.keys(e); 4256 if (t.length > 0) { 4257 let n = e[t[0]]; 4258 if (n !== void 0) { 4259 this.morphTargetInfluences = [], this.morphTargetDictionary = {}; 4260 for (let e = 0, t = n.length; e < t; e++) { 4261 let t = n[e].name || String(e); 4262 this.morphTargetInfluences.push(0), this.morphTargetDictionary[t] = e; 4263 } 4264 } 4265 } 4266 } 4267 getVertexPosition(e, t) { 4268 let n = this.geometry, r = n.attributes.position, i = n.morphAttributes.position, a = n.morphTargetsRelative; 4269 t.fromBufferAttribute(r, e); 4270 let o = this.morphTargetInfluences; 4271 if (i && o) { 4272 ki.set(0, 0, 0); 4273 for (let n = 0, r = i.length; n < r; n++) { 4274 let r = o[n], s = i[n]; 4275 r !== 0 && (Oi.fromBufferAttribute(s, e), a ? ki.addScaledVector(Oi, r) : ki.addScaledVector(Oi.sub(t), r)); 4276 } 4277 t.add(ki); 4278 } 4279 return t; 4280 } 4281 raycast(e, t) { 4282 let n = this.geometry, r = this.material, i = this.matrixWorld; 4283 r !== void 0 && (n.boundingSphere === null && n.computeBoundingSphere(), Ci.copy(n.boundingSphere), Ci.applyMatrix4(i), Si.copy(e.ray).recast(e.near), !(Ci.containsPoint(Si.origin) === !1 && (Si.intersectSphere(Ci, wi) === null || Si.origin.distanceToSquared(wi) > (e.far - e.near) ** 2)) && (xi.copy(i).invert(), Si.copy(e.ray).applyMatrix4(xi), !(n.boundingBox !== null && Si.intersectsBox(n.boundingBox) === !1) && this._computeIntersections(e, t, Si))); 4284 } 4285 _computeIntersections(e, t, n) { 4286 let r, i = this.geometry, a = this.material, o = i.index, s = i.attributes.position, c = i.attributes.uv, l = i.attributes.uv1, u = i.attributes.normal, d = i.groups, f = i.drawRange; 4287 if (o !== null) if (Array.isArray(a)) for (let i = 0, s = d.length; i < s; i++) { 4288 let s = d[i], p = a[s.materialIndex], m = Math.max(s.start, f.start), h = Math.min(o.count, Math.min(s.start + s.count, f.start + f.count)); 4289 for (let i = m, a = h; i < a; i += 3) { 4290 let a = o.getX(i), d = o.getX(i + 1), f = o.getX(i + 2); 4291 r = Pi(this, p, e, n, c, l, u, a, d, f), r && (r.faceIndex = Math.floor(i / 3), r.face.materialIndex = s.materialIndex, t.push(r)); 4292 } 4293 } 4294 else { 4295 let i = Math.max(0, f.start), s = Math.min(o.count, f.start + f.count); 4296 for (let d = i, f = s; d < f; d += 3) { 4297 let i = o.getX(d), s = o.getX(d + 1), f = o.getX(d + 2); 4298 r = Pi(this, a, e, n, c, l, u, i, s, f), r && (r.faceIndex = Math.floor(d / 3), t.push(r)); 4299 } 4300 } 4301 else if (s !== void 0) if (Array.isArray(a)) for (let i = 0, o = d.length; i < o; i++) { 4302 let o = d[i], p = a[o.materialIndex], m = Math.max(o.start, f.start), h = Math.min(s.count, Math.min(o.start + o.count, f.start + f.count)); 4303 for (let i = m, a = h; i < a; i += 3) { 4304 let a = i, s = i + 1, d = i + 2; 4305 r = Pi(this, p, e, n, c, l, u, a, s, d), r && (r.faceIndex = Math.floor(i / 3), r.face.materialIndex = o.materialIndex, t.push(r)); 4306 } 4307 } 4308 else { 4309 let i = Math.max(0, f.start), o = Math.min(s.count, f.start + f.count); 4310 for (let s = i, d = o; s < d; s += 3) { 4311 let i = s, o = s + 1, d = s + 2; 4312 r = Pi(this, a, e, n, c, l, u, i, o, d), r && (r.faceIndex = Math.floor(s / 3), t.push(r)); 4313 } 4314 } 4315 } 4316}; 4317function Ni(e, t, n, r, i, a, o, s) { 4318 let c; 4319 if (c = t.side === 1 ? r.intersectTriangle(o, a, i, !0, s) : r.intersectTriangle(i, a, o, t.side === 0, s), c === null) return null; 4320 ji.copy(s), ji.applyMatrix4(e.matrixWorld); 4321 let l = n.ray.origin.distanceTo(ji); 4322 return l < n.near || l > n.far ? null : { 4323 distance: l, 4324 point: ji.clone(), 4325 object: e 4326 }; 4327} 4328function Pi(e, t, n, r, i, a, o, s, c, l) { 4329 e.getVertexPosition(s, Ti), e.getVertexPosition(c, Ei), e.getVertexPosition(l, Di); 4330 let u = Ni(e, t, n, r, Ti, Ei, Di, Ai); 4331 if (u) { 4332 let e = new G(); 4333 Dr.getBarycoord(Ai, Ti, Ei, Di, e), i && (u.uv = Dr.getInterpolatedAttribute(i, s, c, l, e, new W())), a && (u.uv1 = Dr.getInterpolatedAttribute(a, s, c, l, e, new W())), o && (u.normal = Dr.getInterpolatedAttribute(o, s, c, l, e, new G()), u.normal.dot(r.direction) > 0 && u.normal.multiplyScalar(-1)); 4334 let t = { 4335 a: s, 4336 b: c, 4337 c: l, 4338 normal: new G(), 4339 materialIndex: 0 4340 }; 4341 Dr.getNormal(Ti, Ei, Di, t.normal), u.face = t, u.barycoord = e; 4342 } 4343 return u; 4344}
4345var Fi = class extends En { 4346 constructor(e = null, t = 1, n = 1, r, i, a, o, s, c = N, l = N, u, d) { 4347 super(null, a, o, s, c, l, r, i, u, d), this.isDataTexture = !0, this.image = { 4348 data: e, 4349 width: t, 4350 height: n 4351 }, this.generateMipmaps = !1, this.flipY = !1, this.unpackAlignment = 1; 4352 } 4353}, Ii = /*@__PURE__*/ new G(), Li = /*@__PURE__*/ new G(), Ri = /*@__PURE__*/ new K(), zi = class { 4354 constructor(e = new G(1, 0, 0), t = 0) { 4355 this.isPlane = !0, this.normal = e, this.constant = t; 4356 } 4357 set(e, t) { 4358 return this.normal.copy(e), this.constant = t, this; 4359 } 4360 setComponents(e, t, n, r) { 4361 return this.normal.set(e, t, n), this.constant = r, this; 4362 } 4363 setFromNormalAndCoplanarPoint(e, t) { 4364 return this.normal.copy(e), this.constant = -t.dot(this.normal), this; 4365 } 4366 setFromCoplanarPoints(e, t, n) { 4367 let r = Ii.subVectors(n, t).cross(Li.subVectors(e, t)).normalize(); 4368 return this.setFromNormalAndCoplanarPoint(r, e), this; 4369 } 4370 copy(e) { 4371 return this.normal.copy(e.normal), this.constant = e.constant, this; 4372 } 4373 normalize() { 4374 let e = 1 / this.normal.length(); 4375 return this.normal.multiplyScalar(e), this.constant *= e, this; 4376 } 4377 negate() { 4378 return this.constant *= -1, this.normal.negate(), this; 4379 } 4380 distanceToPoint(e) { 4381 return this.normal.dot(e) + this.constant; 4382 } 4383 distanceToSphere(e) { 4384 return this.distanceToPoint(e.center) - e.radius; 4385 } 4386 projectPoint(e, t) { 4387 return t.copy(e).addScaledVector(this.normal, -this.distanceToPoint(e)); 4388 } 4389 intersectLine(e, t, n = !0) { 4390 let r = e.delta(Ii), i = this.normal.dot(r); 4391 if (i === 0) return this.distanceToPoint(e.start) === 0 ? t.copy(e.start) : null; 4392 let a = -(e.start.dot(this.normal) + this.constant) / i; 4393 return n === !0 && (a < 0 || a > 1) ? null : t.copy(e.start).addScaledVector(r, a); 4394 } 4395 intersectsLine(e) { 4396 let t = this.distanceToPoint(e.start), n = this.distanceToPoint(e.end); 4397 return t < 0 && n > 0 || n < 0 && t > 0; 4398 } 4399 intersectsBox(e) { 4400 return e.intersectsPlane(this); 4401 } 4402 intersectsSphere(e) { 4403 return e.intersectsPlane(this); 4404 } 4405 coplanarPoint(e) { 4406 return e.copy(this.normal).multiplyScalar(-this.constant); 4407 } 4408 applyMatrix4(e, t) { 4409 let n = t || Ri.getNormalMatrix(e), r = this.coplanarPoint(Ii).applyMatrix4(e), i = this.normal.applyMatrix3(n).normalize(); 4410 return this.constant = -r.dot(i), this; 4411 } 4412 translate(e) { 4413 return this.constant -= e.dot(this.normal), this; 4414 } 4415 equals(e) { 4416 return e.normal.equals(this.normal) && e.constant === this.constant; 4417 } 4418 clone() { 4419 return new this.constructor().copy(this); 4420 } 4421}, Bi = /*@__PURE__*/ new Qr(), Vi = /*@__PURE__*/ new W(.5, .5), Hi = /*@__PURE__*/ new G(), Ui = class { 4422 constructor(e = new zi(), t = new zi(), n = new zi(), r = new zi(), i = new zi(), a = new zi()) { 4423 this.planes = [ 4424 e, 4425 t, 4426 n, 4427 r, 4428 i, 4429 a 4430 ]; 4431 } 4432 set(e, t, n, r, i, a) { 4433 let o = this.planes; 4434 return o[0].copy(e), o[1].copy(t), o[2].copy(n), o[3].copy(r), o[4].copy(i), o[5].copy(a), this; 4435 } 4436 copy(e) { 4437 let t = this.planes; 4438 for (let n = 0; n < 6; n++) t[n].copy(e.planes[n]); 4439 return this; 4440 } 4441 setFromProjectionMatrix(e, t = Et, n = !1) { 4442 let r = this.planes, i = e.elements, a = i[0], o = i[1], s = i[2], c = i[3], l = i[4], u = i[5], d = i[6], f = i[7], p = i[8], m = i[9], h = i[10], g = i[11], _ = i[12], v = i[13], y = i[14], b = i[15]; 4443 if (r[0].setComponents(c - a, f - l, g - p, b - _).normalize(), r[1].setComponents(c + a, f + l, g + p, b + _).normalize(), r[2].setComponents(c + o, f + u, g + m, b + v).normalize(), r[3].setComponents(c - o, f - u, g - m, b - v).normalize(), n) r[4].setComponents(s, d, h, y).normalize(), r[5].setComponents(c - s, f - d, g - h, b -
4443y).normalize(); 4444 else if (r[4].setComponents(c - s, f - d, g - h, b - y).normalize(), t === 2e3) r[5].setComponents(c + s, f + d, g + h, b + y).normalize(); 4445 else if (t === 2001) r[5].setComponents(s, d, h, y).normalize(); 4446 else throw Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: " + t); 4447 return this; 4448 } 4449 intersectsObject(e) { 4450 if (e.boundingSphere !== void 0) e.boundingSphere === null && e.computeBoundingSphere(), Bi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld); 4451 else { 4452 let t = e.geometry; 4453 t.boundingSphere === null && t.computeBoundingSphere(), Bi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld); 4454 } 4455 return this.intersectsSphere(Bi); 4456 } 4457 intersectsSprite(e) { 4458 return Bi.center.set(0, 0, 0), Bi.radius = .7071067811865476 + Vi.distanceTo(e.center), Bi.applyMatrix4(e.matrixWorld), this.intersectsSphere(Bi); 4459 } 4460 intersectsSphere(e) { 4461 let t = this.planes, n = e.center, r = -e.radius; 4462 for (let e = 0; e < 6; e++) if (t[e].distanceToPoint(n) < r) return !1; 4463 return !0; 4464 } 4465 intersectsBox(e) { 4466 let t = this.planes; 4467 for (let n = 0; n < 6; n++) { 4468 let r = t[n]; 4469 if (Hi.x = r.normal.x > 0 ? e.max.x : e.min.x, Hi.y = r.normal.y > 0 ? e.max.y : e.min.y, Hi.z = r.normal.z > 0 ? e.max.z : e.min.z, r.distanceToPoint(Hi) < 0) return !1; 4470 } 4471 return !0; 4472 } 4473 containsPoint(e) { 4474 let t = this.planes; 4475 for (let n = 0; n < 6; n++) if (t[n].distanceToPoint(e) < 0) return !1; 4476 return !0; 4477 } 4478 clone() { 4479 return new this.constructor().copy(this); 4480 } 4481}, Wi = class extends di { 4482 constructor(e) { 4483 super(), this.isLineBasicMaterial = !0, this.type = "LineBasicMaterial", this.color = new Y(16777215), this.map = null, this.linewidth = 1, this.linecap = "round", this.linejoin = "round", this.fog = !0, this.setValues(e); 4484 } 4485 copy(e) { 4486 return super.copy(e), this.color.copy(e.color), this.map = e.map, this.linewidth = e.linewidth, this.linecap = e.linecap, this.linejoin = e.linejoin, this.fog = e.fog, this; 4487 } 4488}, Gi = /*@__PURE__*/ new G(), Ki = /*@__PURE__*/ new G(), qi = /*@__PURE__*/ new jn(), Ji = /*@__PURE__*/ new yi(), Yi = /*@__PURE__*/ new Qr(), Xi = /*@__PURE__*/ new G(), Zi = /*@__PURE__*/ new G(), Qi = class extends ir { 4489 constructor(e = new oi(), t = new Wi()) { 4490 super(), this.isLine = !0, this.type = "Line", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.updateMorphTargets(); 4491 } 4492 copy(e, t) { 4493 return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this; 4494 } 4495 computeLineDistances() { 4496 let e = this.geometry; 4497 if (e.index === null) { 4498 let t = e.attributes.position, n = [0]; 4499 for (let e = 1, r = t.count; e < r; e++) Gi.fromBufferAttribute(t, e - 1), Ki.fromBufferAttribute(t, e), n[e] = n[e - 1], n[e] += Gi.distanceTo(Ki); 4500 e.setAttribute("lineDistance", new X(n, 1)); 4501 } else B("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); 4502 return this; 4503 } 4504 raycast(e, t) { 4505 let n = this.geometry, r = this.matrixWorld, i = e.params.Line.threshold, a = n.drawRange; 4506 if (n.boundingSphere === null && n.computeBoundingSphere(), Yi.copy(n.boundingSphere), Yi.applyMatrix4(r), Yi.radius += i, e.ray.intersectsSphere(Yi) === !1) return; 4507 qi.copy(r).invert(), Ji.copy(e.ray).applyMatrix4(qi); 4508 let o = i / ((this.scale.x + this.scale.y + this.scale.z) / 3), s = o * o, c = this.isLineSegments ? 2 : 1, l = n.index, u = n.attributes.position; 4509 if (l !== null) { 4510 let n = Math.max(0, a.start), r = Math.min(l.count, a.start + a.count); 4511 for (let i = n, a = r - 1; i < a; i += c) { 4512 let n = l.getX(i), r = l.getX(i + 1), a = $i(this, e, Ji, s, n, r, i); 4513 a && t.push(a); 4514 } 4515 if (this.isLineLoop) { 4516 let i = l.getX(r - 1), a = l.getX(n), o = $i(this, e, Ji, s, i, a, r - 1); 4517 o && t.push(o); 4518 } 4519 } else { 4520 let n = Math.max(0, a.start), r = Math.min(u.count, a.start + a.count); 4521 for (let i = n, a = r - 1; i < a; i += c) { 4522 let n = $i(this, e, Ji, s, i, i + 1, i); 4523 n && t.push(n); 4524 } 4525 if (this.isLineLoop) { 4526 let i = $i(this, e, Ji, s, r - 1, n, r - 1); 4527 i && t.push(i); 4528 } 4529 } 4530 } 4531 updateMorphTargets() { 4532 let e = this.geometry.morphAttributes, t = Object.keys(e); 4533 if (t.length > 0) { 4534 let n = e[t[0]]; 4535 if (n !== void 0) { 4536 this.morphTargetInfluences = [], this.morphTargetDictionary = {}; 4537 for (let e = 0, t = n.length; e < t; e++) { 4538 let t = n[e].name || String(e); 4539 this.morphTargetInfluences.push(0), this.morphTargetDictionary[t] = e; 4540 } 4541 } 4542 } 4543 } 4544}; 4545function $i(e, t, n, r, i, a, o) { 4546 let s = e.geometry.attributes.position; 4547 if (Gi.fromBufferAttribute(s, i), Ki.fromBufferAttribute(s, a), n.distanceSqToSegment(Gi, Ki, Xi, Zi) > r) return; 4548 Xi.applyMatrix4(e.matrixWorld); 4549 let c = t.ray.origin.distanceTo(Xi); 4550 if (!(c < t.near || c > t.far)) return { 4551 distance: c,
4552 point: Zi.clone().applyMatrix4(e.matrixWorld), 4553 index: o, 4554 face: null, 4555 faceIndex: null, 4556 barycoord: null, 4557 object: e 4558 }; 4559} 4560var ea = /*@__PURE__*/ new G(), ta = /*@__PURE__*/ new G(), na = class extends Qi { 4561 constructor(e, t) { 4562 super(e, t), this.isLineSegments = !0, this.type = "LineSegments"; 4563 } 4564 computeLineDistances() { 4565 let e = this.geometry; 4566 if (e.index === null) { 4567 let t = e.attributes.position, n = []; 4568 for (let e = 0, r = t.count; e < r; e += 2) ea.fromBufferAttribute(t, e), ta.fromBufferAttribute(t, e + 1), n[e] = e === 0 ? 0 : n[e - 1], n[e + 1] = n[e] + ea.distanceTo(ta); 4569 e.setAttribute("lineDistance", new X(n, 1)); 4570 } else B("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry."); 4571 return this; 4572 } 4573}, ra = class extends di { 4574 constructor(e) { 4575 super(), this.isPointsMaterial = !0, this.type = "PointsMaterial", this.color = new Y(16777215), this.map = null, this.alphaMap = null, this.size = 1, this.sizeAttenuation = !0, this.fog = !0, this.setValues(e); 4576 } 4577 copy(e) { 4578 return super.copy(e), this.color.copy(e.color), this.map = e.map, this.alphaMap = e.alphaMap, this.size = e.size, this.sizeAttenuation = e.sizeAttenuation, this.fog = e.fog, this; 4579 } 4580}, ia = /*@__PURE__*/ new jn(), aa = /*@__PURE__*/ new yi(), oa = /*@__PURE__*/ new Qr(), sa = /*@__PURE__*/ new G(), ca = class extends ir { 4581 constructor(e = new oi(), t = new ra()) { 4582 super(), this.isPoints = !0, this.type = "Points", this.geometry = e, this.material = t, this.morphTargetDictionary = void 0, this.morphTargetInfluences = void 0, this.updateMorphTargets(); 4583 } 4584 copy(e, t) { 4585 return super.copy(e, t), this.material = Array.isArray(e.material) ? e.material.slice() : e.material, this.geometry = e.geometry, this; 4586 } 4587 raycast(e, t) { 4588 let n = this.geometry, r = this.matrixWorld, i = e.params.Points.threshold, a = n.drawRange; 4589 if (n.boundingSphere === null && n.computeBoundingSphere(), oa.copy(n.boundingSphere), oa.applyMatrix4(r), oa.radius += i, e.ray.intersectsSphere(oa) === !1) return; 4590 ia.copy(r).invert(), aa.copy(e.ray).applyMatrix4(ia); 4591 let o = i / ((this.scale.x + this.scale.y + this.scale.z) / 3), s = o * o, c = n.index, l = n.attributes.position; 4592 if (c !== null) { 4593 let n = Math.max(0, a.start), i = Math.min(c.count, a.start + a.count); 4594 for (let a = n, o = i; a < o; a++) { 4595 let n = c.getX(a); 4596 sa.fromBufferAttribute(l, n), la(sa, n, s, r, e, t, this); 4597 } 4598 } else { 4599 let n = Math.max(0, a.start), i = Math.min(l.count, a.start + a.count); 4600 for (let a = n, o = i; a < o; a++) sa.fromBufferAttribute(l, a), la(sa, a, s, r, e, t, this); 4601 } 4602 } 4603 updateMorphTargets() { 4604 let e = this.geometry.morphAttributes, t = Object.keys(e); 4605 if (t.length > 0) { 4606 let n = e[t[0]]; 4607 if (n !== void 0) { 4608 this.morphTargetInfluences = [], this.morphTargetDictionary = {}; 4609 for (let e = 0, t = n.length; e < t; e++) { 4610 let t = n[e].name || String(e); 4611 this.morphTargetInfluences.push(0), this.morphTargetDictionary[t] = e; 4612 } 4613 } 4614 } 4615 } 4616}; 4617function la(e, t, n, r, i, a, o) { 4618 let s = aa.distanceSqToPoint(e); 4619 if (s < n) { 4620 let n = new G(); 4621 aa.closestPointToPoint(e, n), n.applyMatrix4(r); 4622 let c = i.ray.origin.distanceTo(n); 4623 if (c < i.near || c > i.far) return; 4624 a.push({ 4625 distance: c, 4626 distanceToRay: Math.sqrt(s), 4627 point: n, 4628 index: t, 4629 face: null, 4630 faceIndex: null, 4631 barycoord: null, 4632 object: o 4633 }); 4634 } 4635} 4636var ua = class extends En { 4637 constructor(e = [], t = 301, n, r, i, a, o, s, c, l) { 4638 super(e, t, n, r, i, a, o, s, c, l), this.isCubeTexture = !0, this.flipY = !1; 4639 } 4640 get images() { 4641 return this.image; 4642 } 4643 set images(e) { 4644 this.image = e; 4645 } 4646}, da = class extends En { 4647 constructor(e, t, n = _e, r, i, a, o = N, s = N, c, l = Oe, u = 1) { 4648 if (l !== 1026 && l !== 1027) throw Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat"); 4649 super({ 4650 width: e, 4651 height: t, 4652 depth: u 4653 }, r, i, a, o, s, l, n, c), this.isDepthTexture = !0, this.flipY = !1, this.generateMipmaps = !1, this.compareFunction = null; 4654 } 4655 copy(e) { 4656 return super.copy(e), this.source = new Sn(Object.assign({}, e.image)), this.compareFunction = e.compareFunction, this; 4657 } 4658 toJSON(e) { 4659 let t = super.toJSON(e); 4660 return this.compareFunction !== null && (t.compareFunction = this.compareFunction), t; 4661 } 4662}, fa = class extends da { 4663 constructor(e, t = _e, n = 301, r, i, a = N, o = N, s, c = Oe) { 4664 let l = { 4665 width: e, 4666 height: e, 4667 depth: 1 4668 }, u = [ 4669 l, 4670 l, 4671 l, 4672 l, 4673 l, 4674 l 4675 ]; 4676 super(e, e, t, n, r, i, a, o, s, c), this.image = u, this.isCubeDepthTexture = !0, this.isCubeTexture = !0; 4677 } 4678 get images() { 4679 return this.image; 4680 } 4681 set images(e) { 4682 this.image = e; 4683 } 4684}
4684, pa = class extends En { 4685 constructor(e = null) { 4686 super(), this.sourceTexture = e, this.isExternalTexture = !0; 4687 } 4688 copy(e) { 4689 return super.copy(e), this.sourceTexture = e.sourceTexture, this; 4690 } 4691}, ma = class e extends oi { 4692 constructor(e = 1, t = 1, n = 1, r = 1, i = 1, a = 1) { 4693 super(), this.type = "BoxGeometry", this.parameters = { 4694 width: e, 4695 height: t, 4696 depth: n, 4697 widthSegments: r, 4698 heightSegments: i, 4699 depthSegments: a 4700 }; 4701 let o = this; 4702 r = Math.floor(r), i = Math.floor(i), a = Math.floor(a); 4703 let s = [], c = [], l = [], u = [], d = 0, f = 0; 4704 p("z", "y", "x", -1, -1, n, t, e, a, i, 0), p("z", "y", "x", 1, -1, n, t, -e, a, i, 1), p("x", "z", "y", 1, 1, e, n, t, r, a, 2), p("x", "z", "y", 1, -1, e, n, -t, r, a, 3), p("x", "y", "z", 1, -1, e, t, n, r, i, 4), p("x", "y", "z", -1, -1, e, t, -n, r, i, 5), this.setIndex(s), this.setAttribute("position", new X(c, 3)), this.setAttribute("normal", new X(l, 3)), this.setAttribute("uv", new X(u, 2)); 4705 function p(e, t, n, r, i, a, p, m, h, g, _) { 4706 let v = a / h, y = p / g, b = a / 2, x = p / 2, S = m / 2, C = h + 1, w = g + 1, T = 0, E = 0, D = new G(); 4707 for (let a = 0; a < w; a++) { 4708 let o = a * y - x; 4709 for (let s = 0; s < C; s++) D[e] = (s * v - b) * r, D[t] = o * i, D[n] = S, c.push(D.x, D.y, D.z), D[e] = 0, D[t] = 0, D[n] = m > 0 ? 1 : -1, l.push(D.x, D.y, D.z), u.push(s / h), u.push(1 - a / g), T += 1; 4710 } 4711 for (let e = 0; e < g; e++) for (let t = 0; t < h; t++) { 4712 let n = d + t + C * e, r = d + t + C * (e + 1), i = d + (t + 1) + C * (e + 1), a = d + (t + 1) + C * e; 4713 s.push(n, r, a), s.push(r, i, a), E += 6; 4714 } 4715 o.addGroup(f, E, _), f += E, d += T; 4716 } 4717 } 4718 copy(e) { 4719 return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; 4720 } 4721 static fromJSON(t) { 4722 return new e(t.width, t.height, t.depth, t.widthSegments, t.heightSegments, t.depthSegments); 4723 } 4724}, ha = class e extends oi { 4725 constructor(e = 1, t = 1, n = 1, r = 1) { 4726 super(), this.type = "PlaneGeometry", this.parameters = { 4727 width: e, 4728 height: t, 4729 widthSegments: n, 4730 heightSegments: r 4731 }; 4732 let i = e / 2, a = t / 2, o = Math.floor(n), s = Math.floor(r), c = o + 1, l = s + 1, u = e / o, d = t / s, f = [], p = [], m = [], h = []; 4733 for (let e = 0; e < l; e++) { 4734 let t = e * d - a; 4735 for (let n = 0; n < c; n++) { 4736 let r = n * u - i; 4737 p.push(r, -t, 0), m.push(0, 0, 1), h.push(n / o), h.push(1 - e / s); 4738 } 4739 } 4740 for (let e = 0; e < s; e++) for (let t = 0; t < o; t++) { 4741 let n = t + c * e, r = t + c * (e + 1), i = t + 1 + c * (e + 1), a = t + 1 + c * e; 4742 f.push(n, r, a), f.push(r, i, a); 4743 } 4744 this.setIndex(f), this.setAttribute("position", new X(p, 3)), this.setAttribute("normal", new X(m, 3)), this.setAttribute("uv", new X(h, 2)); 4745 } 4746 copy(e) { 4747 return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; 4748 } 4749 static fromJSON(t) { 4750 return new e(t.width, t.height, t.widthSegments, t.heightSegments); 4751 } 4752}, ga = class extends oi { 4753 constructor(e = null) { 4754 if (super(), this.type = "WireframeGeometry", this.parameters = { geometry: e }, e !== null) { 4755 let t = [], n = /* @__PURE__ */ new Set(), r = new G(), i = new G(); 4756 if (e.index !== null) { 4757 let a = e.attributes.position, o = e.index, s = e.groups; 4758 s.length === 0 && (s = [{ 4759 start: 0, 4760 count: o.count, 4761 materialIndex: 0 4762 }]); 4763 for (let e = 0, c = s.length; e < c; ++e) { 4764 let c = s[e], l = c.start, u = c.count; 4765 for (let e = l, s = l + u; e < s; e += 3) for (let s = 0; s < 3; s++) { 4766 let c = o.getX(e + s), l = o.getX(e + (s + 1) % 3); 4767 r.fromBufferAttribute(a, c), i.fromBufferAttribute(a, l), _a(r, i, n) === !0 && (t.push(r.x, r.y, r.z), t.push(i.x, i.y, i.z)); 4768 } 4769 } 4770 } else { 4771 let a = e.attributes.position; 4772 for (let e = 0, o = a.count / 3; e < o; e++) for (let o = 0; o < 3; o++) { 4773 let s = 3 * e + o, c = 3 * e + (o + 1) % 3; 4774 r.fromBufferAttribute(a, s), i.fromBufferAttribute(a, c), _a(r, i, n) === !0 && (t.push(r.x, r.y, r.z), t.push(i.x, i.y, i.z)); 4775 } 4776 } 4777 this.setAttribute("position", new X(t, 3)); 4778 } 4779 } 4780 copy(e) { 4781 return super.copy(e), this.parameters = Object.assign({}, e.parameters), this; 4782 } 4783}; 4784function _a(e, t, n) { 4785 let r = `${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`, i = `${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`; 4786 return n.has(r) === !0 || n.has(i) === !0 ? !1 : (n.add(r), n.add(i), !0); 4787} 4788function va(e) { 4789 let t = {}; 4790 for (let n in e) { 4791 t[n] = {}; 4792 for (let r in e[n]) { 4793 let i = e[n][r]; 4794 if (ba(i)) i.isRenderTargetTexture ? (B("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."), t[n][r] = null) : t[n][r] = i.clone(); 4795 else if (Array.isArray(i)) if (ba(i[0])) { 4796 let e = []; 4797 for (let t = 0, n = i.length; t < n; t++) e[t] = i[t].clone(); 4798 t[n][r] = e; 4799 } else t[n][r] = i.slice(); 4800 else t[n][r] = i; 4801 } 4802 } 4803 return t; 4804} 4805function ya(e) { 4806 let t = {}; 4807 for (let n = 0; n < e.length; n++) { 4808 let r = va(e[n]); 4809 for (let e in r) t[e] = r[e]; 4810 } 4811 return t; 4812} 4813function ba(e) { 4814 return e && (e.isColor || e.isMatrix3 || e.isMatrix4 || e.isVector2 || e.isVector3 || e.isVector4 || e.isTexture || e.isQuaternion); 4815} 4816function xa(e) { 4817 let t = []; 4818 for (let n = 0; n < e.length; n++) t.push(e[n].clone()); 4819 return t; 4820} 4821function Sa(e) { 4822 let t = e.getRenderTarget(); 4823 return t === null ? e.outputColorSpace : t.isXRRenderTarget === !0 ? t.texture.colorSpace : q.workingColorSpace; 4824} 4825var Ca = { 4826 clone: va, 4827 merge: ya 4828}, wa = "void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", Ta = "void main() {\n gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}", Ea = class extends di { 4829 constructor(e) { 4830 super(), this.isShaderMaterial = !0, this.type = "ShaderMaterial", this.defines = {}, this.uniforms = {}, this.uniformsGroups = [], this.vertexShader = wa, this.fragmentShader = Ta, this.linewidth = 1, this.wireframe = !1, this.wireframeLinewidth = 1, this.fog = !1, this.lights = !1, this.clipping = !1, this.forceSinglePass = !0, this.extensions = { 4831 clipCullDistance: !1, 4832 multiDraw: !1 4833 }, this.defaultAttributeValues = { 4834 color: [ 4835 1, 4836 1, 4837 1 4838 ], 4839 uv: [0, 0], 4840 uv1: [0, 0] 4841 }, this.index0AttributeName = void 0, this.uniformsNeedUpdate = !1, this.glslVersion = null, e !== void 0 && this.setValues(e); 4842 } 4843 copy(e) { 4844 return super.copy(e), this.fragmentShader = e.fragmentShader, this.vertexShader = e.vertexShader, this.uniforms = va(e.uniforms), this.uniformsGroups = xa(e.uniformsGroups), this.defines = Object.assign({}, e.defines), this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this.fog = e.fog, this.lights = e.lights, this.clipping = e.clipping, this.extensions = Object.assign({}, e.extensions), this.glslVersion = e.glslVersion, this.defaultAttributeValues = Object.assign({}, e.defaultAttributeValues), this.index0AttributeName = e.index0AttributeName, this.uniformsNeedUpdate = e.uniformsNeedUpdate, this; 4845 } 4846 toJSON(e) { 4847 let t = super.toJSON(e); 4848 t.glslVersion = this.glslVersion, t.uniforms = {}; 4849 for (let n in this.uniforms) { 4850 let r = this.uniforms[n].value; 4851 r && r.isTexture ? t.uniforms[n] = { 4852 type: "t", 4853 value: r.toJSON(e).uuid 4854 } : r && r.isColor ? t.uniforms[n] = { 4855 type: "c", 4856 value: r.getHex() 4857 } : r && r.isVector2 ? t.uniforms[n] = { 4858 type: "v2", 4859 value: r.toArray() 4860 } : r && r.isVector3 ? t.uniforms[n] = { 4861 type: "v3", 4862 value: r.toArray() 4863 } : r && r.isVector4 ? t.uniforms[n] = { 4864 type: "v4", 4865 value: r.toArray() 4866 } : r && r.isMatrix3 ? t.uniforms[n] = { 4867 type: "m3", 4868 value: r.toArray() 4869 } : r && r.isMatrix4 ? t.uniforms[n] = { 4870 type: "m4", 4871 value: r.toArray() 4872 } : t.uniforms[n] = { value: r }; 4873 } 4874 Object.keys(this.defines).length > 0 && (t.defines = this.defines), t.vertexShader = this.vertexShader, t.fragmentShader = this.fragmentShader, t.lights = this.lights, t.clipping = this.clipping; 4875 let n = {};
4876 for (let e in this.extensions) this.extensions[e] === !0 && (n[e] = !0); 4877 return Object.keys(n).length > 0 && (t.extensions = n), t; 4878 } 4879 fromJSON(e, t) { 4880 if (super.fromJSON(e, t), e.uniforms !== void 0) for (let n in e.uniforms) { 4881 let r = e.uniforms[n]; 4882 switch (this.uniforms[n] = {}, r.type) { 4883 case "t": 4884 this.uniforms[n].value = t[r.value] || null; 4885 break; 4886 case "c": 4887 this.uniforms[n].value = new Y().setHex(r.value); 4888 break; 4889 case "v2": 4890 this.uniforms[n].value = new W().fromArray(r.value); 4891 break; 4892 case "v3": 4893 this.uniforms[n].value = new G().fromArray(r.value); 4894 break; 4895 case "v4": 4896 this.uniforms[n].value = new J().fromArray(r.value); 4897 break; 4898 case "m3": 4899 this.uniforms[n].value = new K().fromArray(r.value); 4900 break; 4901 case "m4": 4902 this.uniforms[n].value = new jn().fromArray(r.value); 4903 break; 4904 default: this.uniforms[n].value = r.value; 4905 } 4906 } 4907 if (e.defines !== void 0 && (this.defines = e.defines), e.vertexShader !== void 0 && (this.vertexShader = e.vertexShader), e.fragmentShader !== void 0 && (this.fragmentShader = e.fragmentShader), e.glslVersion !== void 0 && (this.glslVersion = e.glslVersion), e.extensions !== void 0) for (let t in e.extensions) this.extensions[t] = e.extensions[t]; 4908 return e.lights !== void 0 && (this.lights = e.lights), e.clipping !== void 0 && (this.clipping = e.clipping), this; 4909 } 4910}, Da = class extends Ea { 4911 constructor(e) { 4912 super(e), this.isRawShaderMaterial = !0, this.type = "RawShaderMaterial"; 4913 } 4914}, Oa = class extends di { 4915 constructor(e) { 4916 super(), this.isMeshDepthMaterial = !0, this.type = "MeshDepthMaterial", this.depthPacking = yt, this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.wireframe = !1, this.wireframeLinewidth = 1, this.setValues(e); 4917 } 4918 copy(e) { 4919 return super.copy(e), this.depthPacking = e.depthPacking, this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this.wireframe = e.wireframe, this.wireframeLinewidth = e.wireframeLinewidth, this; 4920 } 4921}, ka = class extends di { 4922 constructor(e) { 4923 super(), this.isMeshDistanceMaterial = !0, this.type = "MeshDistanceMaterial", this.map = null, this.alphaMap = null, this.displacementMap = null, this.displacementScale = 1, this.displacementBias = 0, this.setValues(e); 4924 } 4925 copy(e) { 4926 return super.copy(e), this.map = e.map, this.alphaMap = e.alphaMap, this.displacementMap = e.displacementMap, this.displacementScale = e.displacementScale, this.displacementBias = e.displacementBias, this; 4927 } 4928}; 4929function Aa(e, t) { 4930 return !e || e.constructor === t ? e : typeof t.BYTES_PER_ELEMENT == "number" ? new t(e) : Array.prototype.slice.call(e); 4931} 4932var ja = class { 4933 constructor(e, t, n, r) { 4934 this.parameterPositions = e, this._cachedIndex = 0, this.resultBuffer = r === void 0 ? new t.constructor(n) : r, this.sampleValues = t, this.valueSize = n, this.settings = null, this.DefaultSettings_ = {}; 4935 } 4936 evaluate(e) { 4937 let t = this.parameterPositions, n = this._cachedIndex, r = t[n], i = t[n - 1]; 4938 validate_interval: { 4939 seek: { 4940 let a; 4941 linear_scan: { 4942 forward_scan: if (!(e < r)) { 4943 for (let a = n + 2;;) { 4944 if (r === void 0) { 4945 if (e < i) break forward_scan; 4946 return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1); 4947 } 4948 if (n === a) break; 4949 if (i = r, r = t[++n], e < r) break seek; 4950 } 4951 a = t.length; 4952 break linear_scan; 4953 } 4954 if (!(e >= i)) { 4955 let o = t[1]; 4956 e < o && (n = 2, i = o); 4957 for (let a = n - 2;;) { 4958 if (i === void 0) return this._cachedIndex = 0, this.copySampleValue_(0); 4959 if (n === a) break; 4960 if (r = i, i = t[--n - 1], e >= i) break seek; 4961 } 4962 a = n, n = 0; 4963 break linear_scan; 4964 } 4965 break validate_interval; 4966 } 4967 for (; n < a;) { 4968 let r = n + a >>> 1; 4969 e < t[r] ? a = r : n = r + 1; 4970 } 4971 if (r = t[n], i = t[n - 1], i === void 0) return this._cachedIndex = 0, this.copySampleValue_(0); 4972 if (r === void 0) return n = t.length, this._cachedIndex = n, this.copySampleValue_(n - 1); 4973 } 4974 this._cachedIndex = n, this.intervalChanged_(n, i, r); 4975 } 4976 return this.interpolate_(n, i, e, r); 4977 } 4978 getSettings_() { 4979 return this.settings || this.DefaultSettings_; 4980 } 4981 copySampleValue_(e) { 4982 let t = this.resultBuffer, n = this.sampleValues, r = this.valueSize, i = e * r; 4983 for (let e = 0; e !== r; ++e) t[e] = n[i + e]; 4984 return t; 4985 } 4986 interpolate_() { 4987 throw Error("THREE.Interpolant: Call to abstract method."); 4988 } 4989 intervalChanged_() {} 4990}, Ma = class extends ja { 4991 constructor(e, t, n, r) { 4992 super(e, t, n, r), this._weightPrev = -0, this._offsetPrev = -0, this._weightNext = -0, this._offsetNext = -0, this.DefaultSettings_ = { 4993 endingStart: gt, 4994 endingEnd: gt 4995 }; 4996 } 4997 intervalChanged_(e, t, n) { 4998 let r = this.parameterPositions, i = e - 2, a = e + 1, o = r[i], s = r[a]; 4999 if (o === void 0) switch (this.getSettings_().endingStart) { 5000 case _t: 5001 i = e, o = 2 * t - n; 5002 break; 5003 case vt: 5004 i = r.length - 2, o = t + r[i] - r[i + 1]; 5005 break; 5006 default: i = e, o = n; 5007 } 5008 if (s === void 0) switch (this.getSettings_().endingEnd) { 5009 case _t: 5010 a = e, s = 2 * n - t; 5011 break; 5012 case vt: 5013 a = 1, s = n + r[1] - r[0]; 5014 break; 5015 default: a = e - 1, s = t; 5016 } 5017 let c = (n - t) * .5, l = this.valueSize; 5018 this._weightPrev = c / (t - o), this._weightNext = c / (s - n), this._offsetPrev = i * l, this._offsetNext = a * l; 5019 } 5020 interpolate_(e, t, n, r) { 5021 let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = e * o, c = s - o, l = this._offsetPrev, u = this._offsetNext, d = this._weightPrev, f = this._weightNext, p = (n - t) / (r - t), m = p * p, h = m * p, g = -d * h + 2 * d * m - d * p, _ = (1 + d) * h + (-1.5 - 2 * d) * m + (-.5 + d) * p + 1, v = (-1 - f) * h + (1.5 + f) * m + .5 * p, y = f * h - f * m; 5022 for (let e = 0; e !== o; ++e) i[e] = g * a[l + e] + _ * a[c + e] + v * a[s + e] + y * a[u + e]; 5023 return i; 5024 } 5025}, Na = class extends ja { 5026 constructor(e, t, n, r) { 5027 super(e, t, n, r); 5028 } 5029 interpolate_(e, t, n, r) { 5030 let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = e * o, c = s - o, l = (n - t) / (r - t), u = 1 - l; 5031 for (let e = 0; e !== o; ++e) i[e] = a[c + e] * u + a[s + e] * l; 5032 return i; 5033 } 5034}, Pa = class extends ja { 5035 constructor(e, t, n, r) { 5036 super(e, t, n, r); 5037 } 5038 interpolate_(e) { 5039 return this.copySampleValue_(e - 1); 5040 } 5041}, Fa = class extends ja { 5042 interpolate_(e, t, n, r) { 5043 let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = e * o, c = s - o, l = this.inTangents, u = this.outTangents; 5044 if (!l || !u) { 5045 let e = (n - t) / (r - t), l = 1 - e; 5046 for (let t = 0; t !== o; ++t) i[t] = a[c + t] * l + a[s + t] * e; 5047 return i; 5048 } 5049 let d = o * 2, f = e - 1; 5050 for (let p = 0; p !== o; ++p) { 5051 let o = a[c + p], m = a[s + p], h = f * d + p * 2, g = u[h], _ = u[h + 1], v = e * d + p * 2, y = l[v], b = l[v + 1], x = (n - t) / (r - t), S, C, w, T, E; 5052 for (let e = 0; e < 8; e++) { 5053 S = x * x, C = S * x, w = 1 - x, T = w * w, E = T * w; 5054 let e = E * t + 3 * T * x * g + 3 * w * S * y + C * r - n; 5055 if (Math.abs(e) < 1e-10) break; 5056 let i = 3 * T * (g - t) + 6 * w * x * (y - g) + 3 * S * (r - y); 5057 if (Math.abs(i) < 1e-10) break; 5058 x -= e / i, x = Math.max(0, Math.min(1, x)); 5059 } 5060 i[p] = E * o + 3 * T * x * _ + 3 * w * S * b + C * m; 5061 } 5062 return i; 5063 } 5064}, Ia = class { 5065 constructor(e, t, n, r) { 5066 if (e === void 0) throw Error("THREE.KeyframeTrack: track name is undefined"); 5067 if (t === void 0 || t.length === 0) throw Error("THREE.KeyframeTrack: no keyframes in track named " + e); 5068 this.name = e, this.times = Aa(t, this.TimeBufferType), this.values = Aa(n, this.ValueBufferType), this.setInterpolation(r || this.DefaultInterpolation); 5069 } 5070 static toJSON(e) { 5071 let t = e.constructor, n; 5072 if (t.toJSON !== this.toJSON) n = t.toJSON(e); 5073 else { 5074 n = { 5075 name: e.name, 5076 times: Aa(e.times, Array), 5077 values: Aa(e.values, Array) 5078 }; 5079 let t = e.getInterpolation(); 5080 t !== e.DefaultInterpolation && (n.interpolation = t); 5081 } 5082 return n.type = e.ValueTypeName, n; 5083 } 5084 InterpolantFactoryMethodDiscrete(e) { 5085 return new Pa(this.times, this.values, this.getValueSize(), e); 5086 } 5087 InterpolantFactoryMethodLinear(e) { 5088 return new Na(this.times, this.values, this.getValueSize(), e); 5089 } 5090 InterpolantFactoryMethodSmooth(e) { 5091 return new Ma(this.times, this.values, this.getValueSize(), e); 5092 } 5093 InterpolantFactoryMethodBezier(e) { 5094 let t = new Fa(this.times, this.values, this.getValueSize(), e); 5095 return this.settings && (t.inTangents = this.settings.inTangents, t.outTangents = this.settings.outTangents), t; 5096 } 5097 setInterpolation(e) { 5098 let t; 5099 switch (e) { 5100 case ft: 5101 t = this.InterpolantFactoryMethodDiscrete; 5102 break; 5103 case pt: 5104 t = this.InterpolantFactoryMethodLinear; 5105 break; 5106 case mt: 5107 t = this.InterpolantFactoryMethodSmooth; 5108 break; 5109 case ht: 5110 t = this.InterpolantFactoryMethodBezier; 5111 break; 5112 } 5113 if (t === void 0) { 5114 let t = "unsupported interpolation for " + this.ValueTypeName + " keyframe track named " + this.name; 5115 if (this.createInterpolant === void 0) if (e !== this.DefaultInterpolation) this.setInterpolation(this.DefaultInterpolation); 5116 else throw Error(t); 5117 return B("KeyframeTrack:", t), this; 5118 } 5119 return this.createInterpolant = t, this; 5120 } 5121 getInterpolation() { 5122 switch (this.createInterpolant) { 5123 case this.InterpolantFactoryMethodDiscrete: return ft; 5124 case this.InterpolantFactoryMethodLinear: return pt; 5125 case this.InterpolantFactoryMethodSmooth: return mt; 5126 case this.InterpolantFactoryMethodBezier: return ht; 5127 } 5128 } 5129 getValueSize() { 5130 return this.values.length / this.times.length; 5131 } 5132 shift(e) { 5133 if (e !== 0) { 5134 let t = this.times; 5135 for (let n = 0, r = t.length; n !== r; ++n) t[n] += e; 5136 } 5137 return this; 5138 } 5139 scale(e) { 5140 if (e !== 1) { 5141 let t = this.times; 5142 for (let n = 0, r = t.length; n !== r; ++n) t[n] *= e; 5143 } 5144 return this; 5145 } 5146 trim(e, t) { 5147 let n = this.times, r = n.length, i = 0, a = r - 1; 5148 for (; i !== r && n[i] < e;) ++i; 5149 for (; a !== -1 && n[a] > t;) --a; 5150 if (++a, i !== 0 || a !== r) { 5151 i >= a && (a = Math.max(a, 1), i = a - 1); 5152 let e = this.getValueSize(); 5153 this.times = n.slice(i, a), this.values = this.values.slice(i * e, a * e); 5154 } 5155 return this; 5156 } 5157 validate() { 5158 let e = !0, t = this.getValueSize(); 5159 t - Math.floor(t) !== 0 && (V("KeyframeTrack: Invalid value size in track.", this), e = !1); 5160 let n = this.times, r = this.values, i = n.length; 5161 i === 0 && (V("KeyframeTrack: Track is empty.", this), e = !1); 5162 let a = null; 5163 for (let t = 0; t !== i; t++) { 5164 let r = n[t]; 5165 if (typeof r == "number" && isNaN(r)) { 5166 V("KeyframeTrack: Time is not a valid number.", this, t, r), e = !1; 5167 break; 5168 }
5169 if (a !== null && a > r) { 5170 V("KeyframeTrack: Out of order keys.", this, t, r, a), e = !1; 5171 break; 5172 } 5173 a = r; 5174 } 5175 if (r !== void 0 && Ot(r)) for (let t = 0, n = r.length; t !== n; ++t) { 5176 let n = r[t]; 5177 if (isNaN(n)) { 5178 V("KeyframeTrack: Value is not a valid number.", this, t, n), e = !1; 5179 break; 5180 } 5181 } 5182 return e; 5183 } 5184 optimize() { 5185 let e = this.times.slice(), t = this.values.slice(), n = this.getValueSize(), r = this.getInterpolation() === mt, i = e.length - 1, a = 1; 5186 for (let o = 1; o < i; ++o) { 5187 let i = !1, s = e[o]; 5188 if (s !== e[o + 1] && (o !== 1 || s !== e[0])) if (r) i = !0; 5189 else { 5190 let e = o * n, r = e - n, a = e + n; 5191 for (let o = 0; o !== n; ++o) { 5192 let n = t[e + o]; 5193 if (n !== t[r + o] || n !== t[a + o]) { 5194 i = !0; 5195 break; 5196 } 5197 } 5198 } 5199 if (i) { 5200 if (o !== a) { 5201 e[a] = e[o]; 5202 let r = o * n, i = a * n; 5203 for (let e = 0; e !== n; ++e) t[i + e] = t[r + e]; 5204 } 5205 ++a; 5206 } 5207 } 5208 if (i > 0) { 5209 e[a] = e[i]; 5210 for (let e = i * n, r = a * n, o = 0; o !== n; ++o) t[r + o] = t[e + o]; 5211 ++a; 5212 } 5213 return a === e.length ? (this.times = e, this.values = t) : (this.times = e.slice(0, a), this.values = t.slice(0, a * n)), this; 5214 } 5215 clone() { 5216 let e = this.times.slice(), t = this.values.slice(), n = this.constructor, r = new n(this.name, e, t); 5217 return r.createInterpolant = this.createInterpolant, r; 5218 } 5219}; 5220Ia.prototype.ValueTypeName = "", Ia.prototype.TimeBufferType = Float32Array, Ia.prototype.ValueBufferType = Float32Array, Ia.prototype.DefaultInterpolation = pt; 5221var La = class extends Ia { 5222 constructor(e, t, n) { 5223 super(e, t, n); 5224 } 5225}; 5226La.prototype.ValueTypeName = "bool", La.prototype.ValueBufferType = Array, La.prototype.DefaultInterpolation = ft, La.prototype.InterpolantFactoryMethodLinear = void 0, La.prototype.InterpolantFactoryMethodSmooth = void 0; 5227var Ra = class extends Ia { 5228 constructor(e, t, n, r) { 5229 super(e, t, n, r); 5230 } 5231}; 5232Ra.prototype.ValueTypeName = "color"; 5233var za = class extends Ia { 5234 constructor(e, t, n, r) { 5235 super(e, t, n, r); 5236 } 5237}; 5238za.prototype.ValueTypeName = "number"; 5239var Ba = class extends ja { 5240 constructor(e, t, n, r) { 5241 super(e, t, n, r); 5242 } 5243 interpolate_(e, t, n, r) { 5244 let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = (n - t) / (r - t), c = e * o; 5245 for (let e = c + o; c !== e; c += 4) un.slerpFlat(i, 0, a, c - o, a, c, s); 5246 return i; 5247 } 5248}, Va = class extends Ia { 5249 constructor(e, t, n, r) { 5250 super(e, t, n, r); 5251 } 5252 InterpolantFactoryMethodLinear(e) { 5253 return new Ba(this.times, this.values, this.getValueSize(), e); 5254 } 5255}; 5256Va.prototype.ValueTypeName = "quaternion", Va.prototype.InterpolantFactoryMethodSmooth = void 0; 5257var Ha = class extends Ia { 5258 constructor(e, t, n) { 5259 super(e, t, n); 5260 } 5261}; 5262Ha.prototype.ValueTypeName = "string", Ha.prototype.ValueBufferType = Array, Ha.prototype.DefaultInterpolation = ft, Ha.prototype.InterpolantFactoryMethodLinear = void 0, Ha.prototype.InterpolantFactoryMethodSmooth = void 0; 5263var Ua = class extends Ia { 5264 constructor(e, t, n, r) { 5265 super(e, t, n, r); 5266 } 5267}; 5268Ua.prototype.ValueTypeName = "vector"; 5269var Wa = /*@__PURE__*/ new class { 5270 constructor(e, t, n) { 5271 let r = this, i = !1, a = 0, o = 0, s, c = []; 5272 this.onStart = void 0, this.onLoad = e, this.onProgress = t, this.onError = n, this._abortController = null, this.itemStart = function(e) { 5273 o++, i === !1 && r.onStart !== void 0 && r.onStart(e, a, o), i = !0; 5274 }, this.itemEnd = function(e) { 5275 a++, r.onProgress !== void 0 && r.onProgress(e, a, o), a === o && (i = !1, r.onLoad !== void 0 && r.onLoad()); 5276 }, this.itemError = function(e) { 5277 r.onError !== void 0 && r.onError(e); 5278 }, this.resolveURL = function(e) { 5279 return e = e.normalize("NFC"), s ? s(e) : e; 5280 }, this.setURLModifier = function(e) { 5281 return s = e, this; 5282 }, this.addHandler = function(e, t) { 5283 return c.push(e, t), this; 5284 }, this.removeHandler = function(e) { 5285 let t = c.indexOf(e); 5286 return t !== -1 && c.splice(t, 2), this; 5287 }, this.getHandler = function(e) { 5288 for (let t = 0, n = c.length; t < n; t += 2) { 5289 let n = c[t], r = c[t + 1]; 5290 if (n.global && (n.lastIndex = 0), n.test(e)) return r; 5291 } 5292 return null; 5293 }, this.abort = function() { 5294 return this.abortController.abort(), this._abortController = null, this; 5295 }; 5296 } 5297 get abortController() { 5298 return this._abortController ||= new AbortController(), this._abortController; 5299 } 5300}(), Ga = class { 5301 constructor(e) { 5302 this.manager = e === void 0 ? Wa : e, this.crossOrigin = "anonymous", this.withCredentials = !1, this.path = "", this.resourcePath = "", this.requestHeader = {}, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); 5303 } 5304 load() {} 5305 loadAsync(e, t) { 5306 let n = this; 5307 return new Promise(function(r, i) { 5308 n.load(e, r, t, i); 5309 }); 5310 } 5311 parse() {} 5312 setCrossOrigin(e) { 5313 return this.crossOrigin = e, this; 5314 } 5315 setWithCredentials(e) { 5316 return this.withCredentials = e, this; 5317 } 5318 setPath(e) { 5319 return this.path = e, this; 5320 } 5321 setResourcePath(e) { 5322 return this.resourcePath = e, this; 5323 } 5324 setRequestHeader(e) { 5325 return this.requestHeader = e, this; 5326 } 5327 abort() { 5328 return this; 5329 } 5330}; 5331Ga.DEFAULT_MATERIAL_NAME = "__DEFAULT"; 5332var Ka = /*@__PURE__*/ new G(), qa = /*@__PURE__*/ new un(), Ja = /*@__PURE__*/ new G(), Ya = class extends ir { 5333 constructor() { 5334 super(), this.isCamera = !0, this.type = "Camera", this.matrixWorldInverse = new jn(), this.projectionMatrix = new jn(), this.projectionMatrixInverse = new jn(), this.coordinateSystem = Et, this._reversedDepth = !1; 5335 } 5336 get reversedDepth() { 5337 return this._reversedDepth; 5338 } 5339 copy(e, t) { 5340 return super.copy(e, t), this.matrixWorldInverse.copy(e.matrixWorldInverse), this.projectionMatrix.copy(e.projectionMatrix), this.projectionMatrixInverse.copy(e.projectionMatrixInverse), this.coordinateSystem = e.coordinateSystem, this; 5341 } 5342 getWorldDirection(e) { 5343 return super.getWorldDirection(e).negate(); 5344 } 5345 updateMatrixWorld(e) { 5346 super.updateMatrixWorld(e), this.matrixWorld.decompose(Ka, qa, Ja), Ja.x === 1 && Ja.y === 1 && Ja.z === 1 ? this.matrixWorldInverse.copy(this.matrixWorld).invert() : this.matrixWorldInverse.compose(Ka, qa, Ja.set(1, 1, 1)).invert(); 5347 } 5348 updateWorldMatrix(e, t, n = !1) { 5349 super.updateWorldMatrix(e, t, n), this.matrixWorld.decompose(Ka, qa, Ja), Ja.x === 1 && Ja.y === 1 && Ja.z === 1 ? this.matrixWorldInverse.copy(this.matrixWorld).invert() : this.matrixWorldInverse.compose(Ka, qa, Ja.set(1, 1, 1)).invert(); 5350 } 5351 clone() { 5352 return new this.constructor().copy(this); 5353 } 5354}, Xa = /*@__PURE__*/ new G(), Za = /*@__PURE__*/ new W(), Qa = /*@__PURE__*/ new W(), $a = class extends Ya { 5355 constructor(e = 50, t = 1, n = .1, r = 2e3) { 5356 super(), this.isPerspectiveCamera = !0, this.type = "PerspectiveCamera", this.fov = e, this.zoom = 1, this.near = n, this.far = r, this.focus = 10, this.aspect = t, this.view = null, this.filmGauge = 35, this.filmOffset = 0, this.updateProjectionMatrix(); 5357 } 5358 copy(e, t) { 5359 return super.copy(e, t), this.fov = e.fov, this.zoom = e.zoom, this.near = e.near, this.far = e.far, this.focus = e.focus, this.aspect = e.aspect, this.view = e.view === null ? null : Object.assign({}, e.view), this.filmGauge = e.filmGauge, this.filmOffset = e.filmOffset, this; 5360 } 5361 setFocalLength(e) { 5362 let t = .5 * this.getFilmHeight() / e; 5363 this.fov = Vt * 2 * Math.atan(t), this.updateProjectionMatrix(); 5364 } 5365 getFocalLength() { 5366 let e = Math.tan(Bt * .5 * this.fov); 5367 return .5 * this.getFilmHeight() / e; 5368 }
5369 getEffectiveFOV() { 5370 return Vt * 2 * Math.atan(Math.tan(Bt * .5 * this.fov) / this.zoom); 5371 } 5372 getFilmWidth() { 5373 return this.filmGauge * Math.min(this.aspect, 1); 5374 } 5375 getFilmHeight() { 5376 return this.filmGauge / Math.max(this.aspect, 1); 5377 } 5378 getViewBounds(e, t, n) { 5379 Xa.set(-1, -1, .5).applyMatrix4(this.projectionMatrixInverse), t.set(Xa.x, Xa.y).multiplyScalar(-e / Xa.z), Xa.set(1, 1, .5).applyMatrix4(this.projectionMatrixInverse), n.set(Xa.x, Xa.y).multiplyScalar(-e / Xa.z); 5380 } 5381 getViewSize(e, t) { 5382 return this.getViewBounds(e, Za, Qa), t.subVectors(Qa, Za); 5383 } 5384 setViewOffset(e, t, n, r, i, a) { 5385 this.aspect = e / t, this.view === null && (this.view = { 5386 enabled: !0, 5387 fullWidth: 1, 5388 fullHeight: 1, 5389 offsetX: 0, 5390 offsetY: 0, 5391 width: 1, 5392 height: 1 5393 }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = r, this.view.width = i, this.view.height = a, this.updateProjectionMatrix(); 5394 } 5395 clearViewOffset() { 5396 this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); 5397 } 5398 updateProjectionMatrix() { 5399 let e = this.near, t = e * Math.tan(Bt * .5 * this.fov) / this.zoom, n = 2 * t, r = this.aspect * n, i = -.5 * r, a = this.view; 5400 if (this.view !== null && this.view.enabled) { 5401 let e = a.fullWidth, o = a.fullHeight; 5402 i += a.offsetX * r / e, t -= a.offsetY * n / o, r *= a.width / e, n *= a.height / o; 5403 } 5404 let o = this.filmOffset; 5405 o !== 0 && (i += e * o / this.getFilmWidth()), this.projectionMatrix.makePerspective(i, i + r, t, t - n, e, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); 5406 } 5407 toJSON(e) { 5408 let t = super.toJSON(e); 5409 return t.object.fov = this.fov, t.object.zoom = this.zoom, t.object.near = this.near, t.object.far = this.far, t.object.focus = this.focus, t.object.aspect = this.aspect, this.view !== null && (t.object.view = Object.assign({}, this.view)), t.object.filmGauge = this.filmGauge, t.object.filmOffset = this.filmOffset, t; 5410 } 5411}, eo = class extends Ya { 5412 constructor(e = -1, t = 1, n = 1, r = -1, i = .1, a = 2e3) { 5413 super(), this.isOrthographicCamera = !0, this.type = "OrthographicCamera", this.zoom = 1, this.view = null, this.left = e, this.right = t, this.top = n, this.bottom = r, this.near = i, this.far = a, this.updateProjectionMatrix(); 5414 } 5415 copy(e, t) { 5416 return super.copy(e, t), this.left = e.left, this.right = e.right, this.top = e.top, this.bottom = e.bottom, this.near = e.near, this.far = e.far, this.zoom = e.zoom, this.view = e.view === null ? null : Object.assign({}, e.view), this; 5417 } 5418 setViewOffset(e, t, n, r, i, a) { 5419 this.view === null && (this.view = { 5420 enabled: !0, 5421 fullWidth: 1, 5422 fullHeight: 1, 5423 offsetX: 0, 5424 offsetY: 0, 5425 width: 1, 5426 height: 1 5427 }), this.view.enabled = !0, this.view.fullWidth = e, this.view.fullHeight = t, this.view.offsetX = n, this.view.offsetY = r, this.view.width = i, this.view.height = a, this.updateProjectionMatrix(); 5428 } 5429 clearViewOffset() { 5430 this.view !== null && (this.view.enabled = !1), this.updateProjectionMatrix(); 5431 } 5432 updateProjectionMatrix() { 5433 let e = (this.right - this.left) / (2 * this.zoom), t = (this.top - this.bottom) / (2 * this.zoom), n = (this.right + this.left) / 2, r = (this.top + this.bottom) / 2, i = n - e, a = n + e, o = r + t, s = r - t; 5434 if (this.view !== null && this.view.enabled) { 5435 let e = (this.right - this.left) / this.view.fullWidth / this.zoom, t = (this.top - this.bottom) / this.view.fullHeight / this.zoom; 5436 i += e * this.view.offsetX, a = i + e * this.view.width, o -= t * this.view.offsetY, s = o - t * this.view.height; 5437 } 5438 this.projectionMatrix.makeOrthographic(i, a, o, s, this.near, this.far, this.coordinateSystem, this.reversedDepth), this.projectionMatrixInverse.copy(this.projectionMatrix).invert(); 5439 } 5440 toJSON(e) { 5441 let t = super.toJSON(e); 5442 return t.object.zoom = this.zoom, t.object.left = this.left, t.object.right = this.right, t.object.top = this.top, t.object.bottom = this.bottom, t.object.near = this.near, t.object.far = this.far, this.view !== null && (t.object.view = Object.assign({}, this.view)), t; 5443 } 5444}, to = class extends oi { 5445 constructor() { 5446 super(), this.isInstancedBufferGeometry = !0, this.type = "InstancedBufferGeometry", this.instanceCount = Infinity; 5447 } 5448 copy(e) { 5449 return super.copy(e), this.instanceCount = e.instanceCount, this; 5450 } 5451 toJSON() { 5452 let e = super.toJSON(); 5453 return e.instanceCount = this.instanceCount, e.isInstancedBufferGeometry = !0, e; 5454 } 5455}, no = -90, ro = 1, io = class extends ir { 5456 constructor(e, t, n) { 5457 super(), this.type = "CubeCamera", this.renderTarget = n, this.coordinateSystem = null, this.activeMipmapLevel = 0; 5458 let r = new $a(no, ro, e, t); 5459 r.layers = this.layers, this.add(r); 5460 let i = new $a(no, ro, e, t); 5461 i.layers = this.layers, this.add(i); 5462 let a = new $a(no, ro, e, t); 5463 a.layers = this.layers, this.add(a); 5464 let o = new $a(no, ro, e, t); 5465 o.layers = this.layers, this.add(o); 5466 let s = new $a(no, ro, e, t); 5467 s.layers = this.layers, this.add(s); 5468 let c = new $a(no, ro, e, t);
5469 c.layers = this.layers, this.add(c); 5470 } 5471 updateCoordinateSystem() { 5472 let e = this.coordinateSystem, t = this.children.concat(), [n, r, i, a, o, s] = t; 5473 for (let e of t) this.remove(e); 5474 if (e === 2e3) n.up.set(0, 1, 0), n.lookAt(1, 0, 0), r.up.set(0, 1, 0), r.lookAt(-1, 0, 0), i.up.set(0, 0, -1), i.lookAt(0, 1, 0), a.up.set(0, 0, 1), a.lookAt(0, -1, 0), o.up.set(0, 1, 0), o.lookAt(0, 0, 1), s.up.set(0, 1, 0), s.lookAt(0, 0, -1); 5475 else if (e === 2001) n.up.set(0, -1, 0), n.lookAt(-1, 0, 0), r.up.set(0, -1, 0), r.lookAt(1, 0, 0), i.up.set(0, 0, 1), i.lookAt(0, 1, 0), a.up.set(0, 0, -1), a.lookAt(0, -1, 0), o.up.set(0, -1, 0), o.lookAt(0, 0, 1), s.up.set(0, -1, 0), s.lookAt(0, 0, -1); 5476 else throw Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: " + e); 5477 for (let e of t) this.add(e), e.updateMatrixWorld(); 5478 } 5479 update(e, t) { 5480 this.parent === null && this.updateMatrixWorld(); 5481 let { renderTarget: n, activeMipmapLevel: r } = this; 5482 this.coordinateSystem !== e.coordinateSystem && (this.coordinateSystem = e.coordinateSystem, this.updateCoordinateSystem()); 5483 let [i, a, o, s, c, l] = this.children, u = e.getRenderTarget(), d = e.getActiveCubeFace(), f = e.getActiveMipmapLevel(), p = e.xr.enabled; 5484 e.xr.enabled = !1; 5485 let m = n.texture.generateMipmaps; 5486 n.texture.generateMipmaps = !1; 5487 let h = !1; 5488 h = e.isWebGLRenderer === !0 ? e.state.buffers.depth.getReversed() : e.reversedDepthBuffer, e.setRenderTarget(n, 0, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, i), e.setRenderTarget(n, 1, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, a), e.setRenderTarget(n, 2, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, o), e.setRenderTarget(n, 3, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, s), e.setRenderTarget(n, 4, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, c), n.texture.generateMipmaps = m, e.setRenderTarget(n, 5, r), h && e.autoClear === !1 && e.clearDepth(), e.render(t, l), e.setRenderTarget(u, d, f), e.xr.enabled = p, n.texture.needsPMREMUpdate = !0; 5489 } 5490}, ao = class extends $a { 5491 constructor(e = []) { 5492 super(), this.isArrayCamera = !0, this.isMultiViewCamera = !1, this.cameras = e; 5493 } 5494}, oo = "\\[\\]\\.:\\/", so = /* @__PURE__ */ RegExp("[\\[\\]\\.:\\/]", "g"), co = "[^\\[\\]\\.:\\/]", lo = "[^" + oo.replace("\\.", "") + "]", uo = /*@__PURE__*/ "((?:WC+[\\/:])*)".replace("WC", co), fo = /*@__PURE__*/ "(WCOD+)?".replace("WCOD", lo), po = /*@__PURE__*/ "(?:\\.(WC+)(?:\\[(.+)\\])?)?".replace("WC", co), mo = /*@__PURE__*/ "\\.(WC+)(?:\\[(.+)\\])?".replace("WC", co), ho = RegExp("^" + uo + fo + po + mo + "$"), go = [ 5495 "material", 5496 "materials", 5497 "bones", 5498 "map" 5499], _o = class { 5500 constructor(e, t, n) { 5501 let r = n || vo.parseTrackName(t); 5502 this._targetGroup = e, this._bindings = e.subscribe_(t, r); 5503 } 5504 getValue(e, t) { 5505 this.bind(); 5506 let n = this._targetGroup.nCachedObjects_, r = this._bindings[n]; 5507 r !== void 0 && r.getValue(e, t); 5508 } 5509 setValue(e, t) { 5510 let n = this._bindings; 5511 for (let r = this._targetGroup.nCachedObjects_, i = n.length; r !== i; ++r) n[r].setValue(e, t); 5512 } 5513 bind() { 5514 let e = this._bindings; 5515 for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t) e[t].bind(); 5516 } 5517 unbind() { 5518 let e = this._bindings; 5519 for (let t = this._targetGroup.nCachedObjects_, n = e.length; t !== n; ++t) e[t].unbind(); 5520 } 5521}, vo = class e { 5522 constructor(t, n, r) { 5523 this.path = n, this.parsedPath = r || e.parseTrackName(n), this.node = e.findNode(t, this.parsedPath.nodeName), this.rootNode = t, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; 5524 } 5525 static create(t, n, r) { 5526 return t && t.isAnimationObjectGroup ? new e.Composite(t, n, r) : new e(t, n, r); 5527 } 5528 static sanitizeNodeName(e) { 5529 return e.replace(/\s/g, "_").replace(so, ""); 5530 } 5531 static parseTrackName(e) { 5532 let t = ho.exec(e); 5533 if (t === null) throw Error("THREE.PropertyBinding: Cannot parse trackName: " + e); 5534 let n = { 5535 nodeName: t[2], 5536 objectName: t[3], 5537 objectIndex: t[4], 5538 propertyName: t[5], 5539 propertyIndex: t[6] 5540 }, r = n.nodeName && n.nodeName.lastIndexOf("."); 5541 if (r !== void 0 && r !== -1) { 5542 let e = n.nodeName.substring(r + 1); 5543 go.indexOf(e) !== -1 && (n.nodeName = n.nodeName.substring(0, r), n.objectName = e); 5544 } 5545 if (n.propertyName === null || n.propertyName.length === 0) throw Error("THREE.PropertyBinding: can not parse propertyName from trackName: " + e); 5546 return n; 5547 } 5548 static findNode(e, t) { 5549 if (t === void 0 || t === "" || t === "." || t === -1 || t === e.name || t === e.uuid) return e; 5550 if (e.skeleton) { 5551 let n = e.skeleton.getBoneByName(t); 5552 if (n !== void 0) return n; 5553 } 5554 if (e.children) { 5555 let n = function(e) { 5556 for (let r = 0; r < e.length; r++) { 5557 let i = e[r]; 5558 if (i.name === t || i.uuid === t) return i; 5559 let a = n(i.children); 5560 if (a) return a; 5561 } 5562 return null; 5563 }, r = n(e.children); 5564 if (r) return r; 5565 } 5566 return null; 5567 } 5568 _getValue_unavailable() {} 5569 _setValue_unavailable() {} 5570 _getValue_direct(e, t) { 5571 e[t] = this.targetObject[this.propertyName]; 5572 } 5573 _getValue_array(e, t) { 5574 let n = this.resolvedProperty; 5575 for (let r = 0, i = n.length; r !== i; ++r) e[t++] = n[r]; 5576 } 5577 _getValue_arrayElement(e, t) { 5578 e[t] = this.resolvedProperty[this.propertyIndex]; 5579 } 5580 _getValue_toArray(e, t) { 5581 this.resolvedProperty.toArray(e, t); 5582 } 5583 _setValue_direct(e, t) { 5584 this.targetObject[this.propertyName] = e[t]; 5585 } 5586 _setValue_direct_setNeedsUpdate(e, t) { 5587 this.targetObject[this.propertyName] = e[t], this.targetObject.needsUpdate = !0; 5588 } 5589 _setValue_direct_setMatrixWorldNeedsUpdate(e, t) { 5590 this.targetObject[this.propertyName] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; 5591 } 5592 _setValue_array(e, t) { 5593 let n = this.resolvedProperty; 5594 for (let r = 0, i = n.length; r !== i; ++r) n[r] = e[t++]; 5595 } 5596 _setValue_array_setNeedsUpdate(e, t) { 5597 let n = this.resolvedProperty; 5598 for (let r = 0, i = n.length; r !== i; ++r) n[r] = e[t++]; 5599 this.targetObject.needsUpdate = !0; 5600 }
5601 _setValue_array_setMatrixWorldNeedsUpdate(e, t) { 5602 let n = this.resolvedProperty; 5603 for (let r = 0, i = n.length; r !== i; ++r) n[r] = e[t++]; 5604 this.targetObject.matrixWorldNeedsUpdate = !0; 5605 } 5606 _setValue_arrayElement(e, t) { 5607 this.resolvedProperty[this.propertyIndex] = e[t]; 5608 } 5609 _setValue_arrayElement_setNeedsUpdate(e, t) { 5610 this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.needsUpdate = !0; 5611 } 5612 _setValue_arrayElement_setMatrixWorldNeedsUpdate(e, t) { 5613 this.resolvedProperty[this.propertyIndex] = e[t], this.targetObject.matrixWorldNeedsUpdate = !0; 5614 } 5615 _setValue_fromArray(e, t) { 5616 this.resolvedProperty.fromArray(e, t); 5617 } 5618 _setValue_fromArray_setNeedsUpdate(e, t) { 5619 this.resolvedProperty.fromArray(e, t), this.targetObject.needsUpdate = !0; 5620 } 5621 _setValue_fromArray_setMatrixWorldNeedsUpdate(e, t) { 5622 this.resolvedProperty.fromArray(e, t), this.targetObject.matrixWorldNeedsUpdate = !0; 5623 } 5624 _getValue_unbound(e, t) { 5625 this.bind(), this.getValue(e, t); 5626 } 5627 _setValue_unbound(e, t) { 5628 this.bind(), this.setValue(e, t); 5629 } 5630 bind() { 5631 let t = this.node, n = this.parsedPath, r = n.objectName, i = n.propertyName, a = n.propertyIndex; 5632 if (t || (t = e.findNode(this.rootNode, n.nodeName), this.node = t), this.getValue = this._getValue_unavailable, this.setValue = this._setValue_unavailable, !t) { 5633 B("PropertyBinding: No target node found for track: " + this.path + "."); 5634 return; 5635 } 5636 if (r) { 5637 let e = n.objectIndex; 5638 switch (r) { 5639 case "materials": 5640 if (!t.material) { 5641 V("PropertyBinding: Can not bind to material as node does not have a material.", this); 5642 return; 5643 } 5644 if (!t.material.materials) { 5645 V("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.", this); 5646 return; 5647 } 5648 t = t.material.materials; 5649 break; 5650 case "bones": 5651 if (!t.skeleton) { 5652 V("PropertyBinding: Can not bind to bones as node does not have a skeleton.", this); 5653 return; 5654 } 5655 t = t.skeleton.bones; 5656 for (let n = 0; n < t.length; n++) if (t[n].name === e) { 5657 e = n; 5658 break; 5659 } 5660 break; 5661 case "map": 5662 if ("map" in t) { 5663 t = t.map; 5664 break; 5665 } 5666 if (!t.material) { 5667 V("PropertyBinding: Can not bind to material as node does not have a material.", this); 5668 return; 5669 } 5670 if (!t.material.map) { 5671 V("PropertyBinding: Can not bind to material.map as node.material does not have a map.", this); 5672 return; 5673 } 5674 t = t.material.map; 5675 break; 5676 default: 5677 if (t[r] === void 0) { 5678 V("PropertyBinding: Can not bind to objectName of node undefined.", this); 5679 return; 5680 } 5681 t = t[r]; 5682 } 5683 if (e !== void 0) { 5684 if (t[e] === void 0) { 5685 V("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.", this, t); 5686 return; 5687 } 5688 t = t[e]; 5689 } 5690 } 5691 let o = t[i]; 5692 if (o === void 0) { 5693 let e = n.nodeName; 5694 V("PropertyBinding: Trying to update property for track: " + e + "." + i + " but it wasn't found.", t); 5695 return; 5696 } 5697 let s = this.Versioning.None; 5698 this.targetObject = t, t.isMaterial === !0 ? s = this.Versioning.NeedsUpdate : t.isObject3D === !0 && (s = this.Versioning.MatrixWorldNeedsUpdate); 5699 let c = this.BindingType.Direct; 5700 if (a !== void 0) { 5701 if (i === "morphTargetInfluences") { 5702 if (!t.geometry) { 5703 V("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.", this); 5704 return; 5705 } 5706 if (!t.geometry.morphAttributes) { 5707 V("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.", this); 5708 return; 5709 } 5710 t.morphTargetDictionary[a] !== void 0 && (a = t.morphTargetDictionary[a]); 5711 } 5712 c = this.BindingType.ArrayElement, this.resolvedProperty = o, this.propertyIndex = a; 5713 } else o.fromArray !== void 0 && o.toArray !== void 0 ? (c = this.BindingType.HasFromToArray, this.resolvedProperty = o) : Array.isArray(o) ? (c = this.BindingType.EntireArray, this.resolvedProperty = o) : this.propertyName = i; 5714 this.getValue = this.GetterByBindingType[c], this.setValue = this.SetterByBindingTypeAndVersioning[c][s]; 5715 } 5716 unbind() { 5717 this.node = null, this.getValue = this._getValue_unbound, this.setValue = this._setValue_unbound; 5718 } 5719}; 5720vo.Composite = _o, vo.prototype.BindingType = { 5721 Direct: 0, 5722 EntireArray: 1, 5723 ArrayElement: 2, 5724 HasFromToArray: 3 5725}, vo.prototype.Versioning = { 5726 None: 0, 5727 NeedsUpdate: 1, 5728 MatrixWorldNeedsUpdate: 2 5729}, vo.prototype.GetterByBindingType = [ 5730 vo.prototype._getValue_direct, 5731 vo.prototype._getValue_array, 5732 vo.prototype._getValue_arrayElement, 5733 vo.prototype._getValue_toArray 5734], vo.prototype.SetterByBindingTypeAndVersioning = [ 5735 [ 5736 vo.prototype._setValue_direct, 5737 vo.prototype._setValue_direct_setNeedsUpdate, 5738 vo.prototype._setValue_direct_setMatrixWorldNeedsUpdate 5739 ], 5740 [ 5741 vo.prototype._setValue_array, 5742 vo.prototype._setValue_array_setNeedsUpdate,
5743 vo.prototype._setValue_array_setMatrixWorldNeedsUpdate 5744 ], 5745 [ 5746 vo.prototype._setValue_arrayElement, 5747 vo.prototype._setValue_arrayElement_setNeedsUpdate, 5748 vo.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate 5749 ], 5750 [ 5751 vo.prototype._setValue_fromArray, 5752 vo.prototype._setValue_fromArray_setNeedsUpdate, 5753 vo.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate 5754 ] 5755]; 5756var yo = class extends si { 5757 constructor(e, t, n = 1) { 5758 super(e, t), this.isInstancedInterleavedBuffer = !0, this.meshPerAttribute = n; 5759 } 5760 copy(e) { 5761 return super.copy(e), this.meshPerAttribute = e.meshPerAttribute, this; 5762 } 5763 clone(e) { 5764 let t = super.clone(e); 5765 return t.meshPerAttribute = this.meshPerAttribute, t; 5766 } 5767 toJSON(e) { 5768 let t = super.toJSON(e); 5769 return t.isInstancedInterleavedBuffer = !0, t.meshPerAttribute = this.meshPerAttribute, t; 5770 } 5771}, bo = class { 5772 constructor(e = 1, t = 0, n = 0) { 5773 this.radius = e, this.phi = t, this.theta = n; 5774 } 5775 set(e, t, n) { 5776 return this.radius = e, this.phi = t, this.theta = n, this; 5777 } 5778 copy(e) { 5779 return this.radius = e.radius, this.phi = e.phi, this.theta = e.theta, this; 5780 } 5781 makeSafe() { 5782 let e = 1e-6; 5783 return this.phi = H(this.phi, e, Math.PI - e), this; 5784 } 5785 setFromVector3(e) { 5786 return this.setFromCartesianCoords(e.x, e.y, e.z); 5787 } 5788 setFromCartesianCoords(e, t, n) { 5789 return this.radius = Math.sqrt(e * e + t * t + n * n), this.radius === 0 ? (this.theta = 0, this.phi = 0) : (this.theta = Math.atan2(e, n), this.phi = Math.acos(H(t / this.radius, -1, 1))), this; 5790 } 5791 clone() { 5792 return new this.constructor().copy(this); 5793 } 5794}; 5795(class e { 5796 static { 5797 e.prototype.isMatrix2 = !0; 5798 } 5799 constructor(e, t, n, r) { 5800 this.elements = [ 5801 1, 5802 0, 5803 0, 5804 1 5805 ], e !== void 0 && this.set(e, t, n, r); 5806 } 5807 identity() { 5808 return this.set(1, 0, 0, 1), this; 5809 } 5810 fromArray(e, t = 0) { 5811 for (let n = 0; n < 4; n++) this.elements[n] = e[n + t]; 5812 return this; 5813 } 5814 set(e, t, n, r) { 5815 let i = this.elements; 5816 return i[0] = e, i[2] = t, i[1] = n, i[3] = r, this; 5817 } 5818}); 5819var xo = /*@__PURE__*/ new G(), So = /*@__PURE__*/ new G(), Co = /*@__PURE__*/ new G(), wo = /*@__PURE__*/ new G(), To = /*@__PURE__*/ new G(), Eo = /*@__PURE__*/ new G(), Do = /*@__PURE__*/ new G(), Oo = class { 5820 constructor(e = new G(), t = new G()) { 5821 this.start = e, this.end = t; 5822 } 5823 set(e, t) { 5824 return this.start.copy(e), this.end.copy(t), this; 5825 } 5826 copy(e) { 5827 return this.start.copy(e.start), this.end.copy(e.end), this; 5828 } 5829 getCenter(e) { 5830 return e.addVectors(this.start, this.end).multiplyScalar(.5); 5831 } 5832 delta(e) { 5833 return e.subVectors(this.end, this.start); 5834 } 5835 distanceSq() { 5836 return this.start.distanceToSquared(this.end); 5837 } 5838 distance() { 5839 return this.start.distanceTo(this.end); 5840 } 5841 at(e, t) { 5842 return this.delta(t).multiplyScalar(e).add(this.start); 5843 } 5844 closestPointToPointParameter(e, t) { 5845 xo.subVectors(e, this.start), So.subVectors(this.end, this.start); 5846 let n = So.dot(So); 5847 if (n === 0) return 0; 5848 let r = So.dot(xo) / n; 5849 return t && (r = H(r, 0, 1)), r; 5850 } 5851 closestPointToPoint(e, t, n) { 5852 let r = this.closestPointToPointParameter(e, t); 5853 return this.delta(n).multiplyScalar(r).add(this.start); 5854 } 5855 distanceSqToLine3(e, t = Eo, n = Do) { 5856 let r = 1e-8 * 1e-8, i, a, o = this.start, s = e.start, c = this.end, l = e.end; 5857 Co.subVectors(c, o), wo.subVectors(l, s), To.subVectors(o, s); 5858 let u = Co.dot(Co), d = wo.dot(wo), f = wo.dot(To); 5859 if (u <= r && d <= r) return t.copy(o), n.copy(s), t.sub(n), t.dot(t); 5860 if (u <= r) i = 0, a = f / d, a = H(a, 0, 1); 5861 else { 5862 let e = Co.dot(To); 5863 if (d <= r) a = 0, i = H(-e / u, 0, 1); 5864 else { 5865 let t = Co.dot(wo), n = u * d - t * t; 5866 i = n === 0 ? 0 : H((t * f - e * d) / n, 0, 1), a = (t * i + f) / d, a < 0 ? (a = 0, i = H(-e / u, 0, 1)) : a > 1 && (a = 1, i = H((t - e) / u, 0, 1)); 5867 } 5868 } 5869 return t.copy(o).addScaledVector(Co, i), n.copy(s).addScaledVector(wo, a), t.distanceToSquared(n); 5870 } 5871 applyMatrix4(e) { 5872 return this.start.applyMatrix4(e), this.end.applyMatrix4(e), this; 5873 } 5874 equals(e) { 5875 return e.start.equals(this.start) && e.end.equals(this.end); 5876 } 5877 clone() { 5878 return new this.constructor().copy(this); 5879 } 5880}, ko = class extends Lt { 5881 constructor(e, t = null) { 5882 super(), this.object = e, this.domElement = t, this.enabled = !0, this.state = -1, this.keys = {}, this.mouseButtons = { 5883 LEFT: null, 5884 MIDDLE: null, 5885 RIGHT: null 5886 }, this.touches = { 5887 ONE: null, 5888 TWO: null 5889 }; 5890 } 5891 connect(e) { 5892 if (e === void 0) { 5893 B("Controls: connect() now requires an element."); 5894 return; 5895 } 5896 this.domElement !== null && this.disconnect(), this.domElement = e; 5897 } 5898 disconnect() {} 5899 dispose() {}
5900 update() {} 5901}; 5902function Ao(e, t, n, r) { 5903 let i = jo(r); 5904 switch (n) { 5905 case Te: return e * t; 5906 case Ae: return e * t / i.components * i.byteLength; 5907 case je: return e * t / i.components * i.byteLength; 5908 case F: return e * t * 2 / i.components * i.byteLength; 5909 case Me: return e * t * 2 / i.components * i.byteLength; 5910 case Ee: return e * t * 3 / i.components * i.byteLength; 5911 case De: return e * t * 4 / i.components * i.byteLength; 5912 case Ne: return e * t * 4 / i.components * i.byteLength; 5913 case Pe: 5914 case I: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 8; 5915 case Fe: 5916 case L: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16; 5917 case R: 5918 case Le: return Math.max(e, 16) * Math.max(t, 8) / 4; 5919 case Ie: 5920 case z: return Math.max(e, 8) * Math.max(t, 8) / 2; 5921 case Re: 5922 case ze: 5923 case Ve: 5924 case He: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 8; 5925 case Be: 5926 case Ue: 5927 case We: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16; 5928 case Ge: return Math.floor((e + 3) / 4) * Math.floor((t + 3) / 4) * 16; 5929 case Ke: return Math.floor((e + 4) / 5) * Math.floor((t + 3) / 4) * 16; 5930 case qe: return Math.floor((e + 4) / 5) * Math.floor((t + 4) / 5) * 16; 5931 case Je: return Math.floor((e + 5) / 6) * Math.floor((t + 4) / 5) * 16; 5932 case Ye: return Math.floor((e + 5) / 6) * Math.floor((t + 5) / 6) * 16; 5933 case Xe: return Math.floor((e + 7) / 8) * Math.floor((t + 4) / 5) * 16; 5934 case Ze: return Math.floor((e + 7) / 8) * Math.floor((t + 5) / 6) * 16; 5935 case Qe: return Math.floor((e + 7) / 8) * Math.floor((t + 7) / 8) * 16; 5936 case $e: return Math.floor((e + 9) / 10) * Math.floor((t + 4) / 5) * 16; 5937 case et: return Math.floor((e + 9) / 10) * Math.floor((t + 5) / 6) * 16; 5938 case tt: return Math.floor((e + 9) / 10) * Math.floor((t + 7) / 8) * 16; 5939 case nt: return Math.floor((e + 9) / 10) * Math.floor((t + 9) / 10) * 16; 5940 case rt: return Math.floor((e + 11) / 12) * Math.floor((t + 9) / 10) * 16; 5941 case it: return Math.floor((e + 11) / 12) * Math.floor((t + 11) / 12) * 16; 5942 case at: 5943 case ot: 5944 case st: return Math.ceil(e / 4) * Math.ceil(t / 4) * 16; 5945 case ct: 5946 case lt: return Math.ceil(e / 4) * Math.ceil(t / 4) * 8; 5947 case ut: 5948 case dt: return Math.ceil(e / 4) * Math.ceil(t / 4) * 16; 5949 } 5950 throw Error(`Unable to determine texture byte length for ${n} format.`); 5951} 5952function jo(e) { 5953 switch (e) { 5954 case fe: 5955 case pe: return { 5956 byteLength: 1, 5957 components: 1 5958 }; 5959 case he: 5960 case me: 5961 case ye: return { 5962 byteLength: 2, 5963 components: 1 5964 }; 5965 case be: 5966 case xe: return { 5967 byteLength: 2, 5968 components: 4 5969 }; 5970 case _e: 5971 case ge: 5972 case ve: return { 5973 byteLength: 4, 5974 components: 1 5975 }; 5976 case Ce: 5977 case we: return { 5978 byteLength: 4, 5979 components: 3 5980 }; 5981 } 5982 throw Error(`THREE.TextureUtils: Unknown texture type ${e}.`); 5983} 5984typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register", { detail: { revision: "185" } })), typeof window < "u" && (window.__THREE__ ? B("WARNING: Multiple instances of Three.js being imported.") : window.__THREE__ = "185"); 5985//#endregion 5986//#region node_modules/three/build/three.module.js 5987function Mo() { 5988 let e = null, t = !1, n = null, r = null; 5989 function i(t, a) { 5990 n(t, a), r = e.requestAnimationFrame(i); 5991 } 5992 return { 5993 start: function() { 5994 t !== !0 && n !== null && e !== null && (r = e.requestAnimationFrame(i), t = !0); 5995 }, 5996 stop: function() { 5997 e !== null && e.cancelAnimationFrame(r), t = !1; 5998 }, 5999 setAnimationLoop: function(e) { 6000 n = e; 6001 }, 6002 setContext: function(t) { 6003 e = t; 6004 } 6005 }; 6006} 6007function No(e) { 6008 let t = /* @__PURE__ */ new WeakMap(); 6009 function n(t, n) { 6010 let r = t.array, i = t.usage, a = r.byteLength, o = e.createBuffer(); 6011 e.bindBuffer(n, o), e.bufferData(n, r, i), t.onUploadCallback(); 6012 let s; 6013 if (r instanceof Float32Array) s = e.FLOAT; 6014 else if (typeof Float16Array < "u" && r instanceof Float16Array) s = e.HALF_FLOAT; 6015 else if (r instanceof Uint16Array) s = t.isFloat16BufferAttribute ? e.HALF_FLOAT : e.UNSIGNED_SHORT; 6016 else if (r instanceof Int16Array) s = e.SHORT; 6017 else if (r instanceof Uint32Array) s = e.UNSIGNED_INT; 6018 else if (r instanceof Int32Array) s = e.INT; 6019 else if (r instanceof Int8Array) s = e.BYTE; 6020 else if (r instanceof Uint8Array) s = e.UNSIGNED_BYTE; 6021 else if (r instanceof Uint8ClampedArray) s = e.UNSIGNED_BYTE; 6022 else throw Error("THREE.WebGLAttributes: Unsupported buffer data format: " + r); 6023 return { 6024 buffer: o, 6025 type: s, 6026 bytesPerElement: r.BYTES_PER_ELEMENT, 6027 version: t.version, 6028 size: a 6029 }; 6030 } 6031 function r(t, n, r) { 6032 let i = n.array, a = n.updateRanges; 6033 if (e.bindBuffer(r, t), a.length === 0) e.bufferSubData(r, 0, i); 6034 else { 6035 a.sort((e, t) => e.start - t.start); 6036 let t = 0; 6037 for (let e = 1; e < a.length; e++) { 6038 let n = a[t], r = a[e]; 6039 r.start <= n.start + n.count + 1 ? n.count = Math.max(n.count, r.start + r.count - n.start) : (++t, a[t] = r); 6040 } 6041 a.length = t + 1; 6042 for (let t = 0, n = a.length; t < n; t++) { 6043 let n = a[t]; 6044 e.bufferSubData(r, n.start * i.BYTES_PER_ELEMENT, i, n.start, n.count); 6045 } 6046 n.clearUpdateRanges(); 6047 } 6048 n.onUploadCallback(); 6049 } 6050 function i(e) { 6051 return e.isInterleavedBufferAttribute && (e = e.data), t.get(e); 6052 } 6053 function a(n) { 6054 n.isInterleavedBufferAttribute && (n = n.data); 6055 let r = t.get(n); 6056 r && (e.deleteBuffer(r.buffer), t.delete(n)); 6057 } 6058 function o(e, i) { 6059 if (e.isInterleavedBufferAttribute && (e = e.data), e.isGLBufferAttribute) { 6060 let n = t.get(e); 6061 (!n || n.version < e.version) && t.set(e, { 6062 buffer: e.buffer, 6063 type: e.type, 6064 bytesPerElement: e.elementSize, 6065 version: e.version 6066 }); 6067 return; 6068 } 6069 let a = t.get(e); 6070 if (a === void 0) t.set(e, n(e, i)); 6071 else if (a.version < e.version) { 6072 if (a.size !== e.array.byteLength) throw Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported."); 6073 r(a.buffer, e, i), a.version = e.version; 6074 } 6075 } 6076 return { 6077 get: i, 6078 remove: a, 6079 update: o 6080 }; 6081} 6082var Z = { 6083 alphahash_fragment: "#ifdef USE_ALPHAHASH\n if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;\n#endif", 6084 alphahash_pars_fragment: "#ifdef USE_ALPHAHASH\n const float ALPHA_HASH_SCALE = 0.05;\n float hash2D( vec2 value ) {\n return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );\n }\n float hash3D( vec3 value ) {\n return hash2D( vec2( hash2D( value.xy ), value.z ) );\n }\n float getAlphaHashThreshold( vec3 position ) {\n float maxDeriv = max(\n length( dFdx( position.xyz ) ),\n length( dFdy( position.xyz ) )\n );\n float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );\n vec2 pixScales = vec2(\n exp2( floor( log2( pixScale ) ) ),\n exp2( ceil( log2( pixScale ) ) )\n );\n vec2 alpha = vec2(\n hash3D( floor( pixScales.x * position.xyz ) ),\n hash3D( floor( pixScales.y * position.xyz ) )\n );\n float lerpFactor = fract( log2( pixScale ) );\n float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;\n float a = min( lerpFactor, 1.0 - lerpFactor );\n vec3 cases = vec3(\n x * x / ( 2.0 * a * ( 1.0 - a ) ),\n ( x - 0.5 * a ) / ( 1.0 - a ),\n 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )\n );\n float threshold = ( x < ( 1.0 - a ) )\n ? ( ( x < a ) ? cases.x : cases.y )\n : cases.z;\n return clamp( threshold , 1.0e-6, 1.0 );\n }\n#endif", 6085 alphamap_fragment: "#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;\n#endif", 6086 alphamap_pars_fragment: "#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif", 6087 alphatest_fragment: "#ifdef USE_ALPHATEST\n #ifdef ALPHA_TO_COVERAGE\n diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n if ( diffuseColor.a < alphaTest ) discard;\n #endif\n#endif", 6088 alphatest_pars_fragment: "#ifdef USE_ALPHATEST\n uniform float alphaTest;\n#endif", 6089 aomap_fragment: "#ifdef USE_AOMAP\n float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;\n reflectedLight.indirectDiffuse *= ambientOcclusion;\n #if defined( USE_CLEARCOAT ) \n clearcoatSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_SHEEN ) \n sheenSpecularIndirect *= ambientOcclusion;\n #endif\n #if defined( USE_ENVMAP ) && defined( STANDARD )\n float dotNV = saturate( dot
6089( geometryNormal, geometryViewDir ) );\n reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );\n #endif\n#endif", 6090 aomap_pars_fragment: "#ifdef USE_AOMAP\n uniform sampler2D aoMap;\n uniform float aoMapIntensity;\n#endif", 6091 batching_pars_vertex: "#ifdef USE_BATCHING\n #if ! defined( GL_ANGLE_multi_draw )\n #define gl_DrawID _gl_DrawID\n uniform int _gl_DrawID;\n #endif\n uniform highp sampler2D batchingTexture;\n uniform highp usampler2D batchingIdTexture;\n mat4 getBatchingMatrix( const in float i ) {\n int size = textureSize( batchingTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n float getIndirectIndex( const in int i ) {\n int size = textureSize( batchingIdTexture, 0 ).x;\n int x = i % size;\n int y = i / size;\n return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );\n }\n#endif\n#ifdef USE_BATCHING_COLOR\n uniform sampler2D batchingColorTexture;\n vec4 getBatchingColor( const in float i ) {\n int size = textureSize( batchingColorTexture, 0 ).x;\n int j = int( i );\n int x = j % size;\n int y = j / size;\n return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );\n }\n#endif", 6092 batching_vertex: "#ifdef USE_BATCHING\n mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );\n#endif", 6093 begin_vertex: "vec3 transformed = vec3( position );\n#ifdef USE_ALPHAHASH\n vPosition = vec3( position );\n#endif", 6094 beginnormal_vertex: "vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n vec3 objectTangent = vec3( tangent.xyz );\n#endif", 6095 bsdfs: "float G_BlinnPhong_Implicit( ) {\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( specularColor, 1.0, dotVH );\n float G = G_BlinnPhong_Implicit( );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated", 6096 iridescence_fragment: "#ifdef USE_IRIDESCENCE\n const mat3 XYZ_TO_REC709 = mat3(\n 3.2404542, -0.9692660, 0.0556434,\n -1.5371385, 1.8760108, -0.2040259,\n -0.4985314, 0.0415560, 1.0572252\n );\n vec3 Fresnel0ToIor( vec3 fresnel0 ) {\n vec3 sqrtF0 = sqrt( fresnel0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n }\n vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );\n }\n float IorToFresnel0( float transmittedIor, float incidentIor ) {\n return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));\n }\n vec3 evalSensitivity( float OPD, vec3 shift ) {\n float phase = 2.0 * PI * OPD * 1.0e-9;\n vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );\n vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );\n vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );\n vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );\n xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );\n xyz /= 1.0685e-7;\n vec3 rgb = XYZ_TO_REC709 * xyz;\n return rgb;\n }\n vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {\n vec3 I;\n float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );\n float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );\n float cosTheta2Sq = 1.0 - sinTheta2Sq;\n if ( cosTheta2Sq < 0.0 ) {\n return vec3( 1.0 );\n }\n float cosTheta2 = sqrt( cosTheta2Sq );\n float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
6096\n float R12 = F_Schlick( R0, 1.0, cosTheta1 );\n float T121 = 1.0 - R12;\n float phi12 = 0.0;\n if ( iridescenceIOR < outsideIOR ) phi12 = PI;\n float phi21 = PI - phi12;\n vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );\n vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );\n vec3 phi23 = vec3( 0.0 );\n if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;\n if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;\n if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;\n float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\n vec3 phi = vec3( phi21 ) + phi23;\n vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );\n vec3 r123 = sqrt( R123 );\n vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );\n vec3 C0 = R12 + Rs;\n I = C0;\n vec3 Cm = Rs - T121;\n for ( int m = 1; m <= 2; ++ m ) {\n Cm *= r123;\n vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );\n I += Cm * Sm;\n }\n return max( I, vec3( 0.0 ) );\n }\n#endif", 6097 bumpmap_pars_fragment: "#ifdef USE_BUMPMAP\n uniform sampler2D bumpMap;\n uniform float bumpScale;\n vec2 dHdxy_fwd() {\n vec2 dSTdx = dFdx( vBumpMapUv );\n vec2 dSTdy = dFdy( vBumpMapUv );\n float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;\n float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;\n float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;\n return vec2( dBx, dBy );\n }\n vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {\n vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );\n vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );\n vec3 vN = surf_norm;\n vec3 R1 = cross( vSigmaY, vN );\n vec3 R2 = cross( vN, vSigmaX );\n float fDet = dot( vSigmaX, R1 ) * faceDirection;\n vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n return normalize( abs( fDet ) * surf_norm - vGrad );\n }\n#endif", 6098 clipping_planes_fragment: "#if NUM_CLIPPING_PLANES > 0\n vec4 plane;\n #ifdef ALPHA_TO_COVERAGE\n float distanceToPlane, distanceGradient;\n float clipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n if ( clipOpacity == 0.0 ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n float unionClipOpacity = 1.0;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;\n distanceGradient = fwidth( distanceToPlane ) / 2.0;\n unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );\n }\n #pragma unroll_loop_end\n clipOpacity *= 1.0 - unionClipOpacity;\n #endif\n diffuseColor.a *= clipOpacity;\n if ( diffuseColor.a == 0.0 ) discard;\n #else\n #pragma unroll_loop_start\n for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n }\n #pragma unroll_loop_end\n #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n bool clipped = true;\n #pragma unroll_loop_start\n for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n plane = clippingPlanes[ i ];\n clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n }\n #pragma unroll_loop_end\n if ( clipped ) discard;\n #endif\n #endif\n#endif", 6099 clipping_planes_pars_fragment: "#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif", 6100 clipping_planes_pars_vertex: "#if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n#endif", 6101 clipping_planes_vertex: "#if NUM_CLIPPING_PLANES > 0\n vClipPosition = - mvPosition.xyz;\n#endif", 6102 color_fragment: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n diffuseColor *= vColor;\n#endif", 6103 color_pars_fragment: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )\n varying vec4 vColor;\n#endif", 6104 color_pars_vertex: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n varying vec4 vColor;\n#endif", 6105 color_vertex: "#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )\n vColor = vec4( 1.0 );\n#endif\n#ifdef USE_COLOR_ALPHA\n vColor *= color;\n#elif defined( USE_COLOR )\n vColor.rgb *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\n vColor.rgb *= instanceColor.rgb;\n#endif\n#ifdef USE_BATCHING_COLOR\n vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );\n#endif", 6106 common: "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n const highp float a = 12.9898, b = 78.233, c = 43758.5453;\n highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n return fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n float precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n float precisionSafeLength( vec3 v ) {\n float maxComponent = max3( abs( v ) );\n return length( v / maxComponent ) * maxComponent;\n }\n#endif\nstruct IncidentLight {\n vec3 color;\n vec3 direction;\n bool visible;\n};\nstruct ReflectedLight {\n vec3 directDiffuse;\n vec3 directSpecular;\n vec3 indirectDiffuse;\n vec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n varying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n return m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n return vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated", 6107 cube_uv_reflection_fragment: "#ifdef ENVMAP_TYPE_CUBE_UV\n #define cubeUV_minMipLevel 4.0\n #define cubeUV_minTileSize 16.0\n float getFace( vec3 direction ) {\n vec3 absDirection = abs( direction );\n float face = - 1.0;\n if ( absDirection.x > absDirection.z ) {\n if ( absDirection.x > absDirection.y )\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if ( absDirection.z > absDirection.y )\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n }\n vec2 getUV( vec3 direction, float face ) {\n vec2 uv;\n if ( face == 0.0 ) {\n uv = vec2( direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 1.0 ) {\n uv = vec2( - direction.x, - direction.z ) / abs( direction.y );\n } else if ( face == 2.0 ) {\n uv = vec2( - direction.x, direction.y ) / abs( direction.z );\n } else if ( face == 3.0 ) {\n uv = vec2( - direction.z, direction.y ) / abs( direction.x );\n } else if ( face == 4.0 ) {\n uv = vec2( - direction.x, direction.z ) / abs( direction.y );\n } else {\n uv = vec2( direction.x, direction.y ) / abs( direction.z );\n }\n return 0.5 * ( uv + 1.0 );\n }\n vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {\n float face = getFace( direction );\n float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );\n mipInt = max( mipInt, cubeUV_minMipLevel );\n float faceSize = exp2( mipInt );\n highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;\n if ( face > 2.0 ) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n uv.x += filterInt * 3.0 * cubeUV_minTileSize;\n uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );\n uv.x *= CUBEUV_TEXEL_WIDTH;\n uv.y *= CUBEUV_TEXEL_HEIGHT;\n #ifdef texture2DGradEXT\n return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;\n #else\n return texture2D( envMap, uv ).rgb;\n #endif\n }\n #define cubeUV_r0 1.0\n #define cubeUV_m0 - 2.0\n #define cubeUV_r1 0.8\n #define cubeUV_m1 - 1.0\n #define cubeUV_r4 0.4\n #define cubeUV_m4 2.0\n #define cubeUV_r5 0.305\n #define cubeUV_m5 3.0\n #define cubeUV_r6 0.21\n #define cubeUV_m6 4.0\n float roughnessToMip( float roughness ) {\n float mip = 0.0;\n if ( roughness >= cubeUV_r1 ) {\n mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;\n } else if ( roughness >= cubeUV_r4 ) {\n mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;\n } else if ( roughness >= cubeUV_r5 ) {\n mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;\n } else if ( roughness >= cubeUV_r6 ) {\n mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;\n } else {\n mip = - 2.0 * log2( 1.16 * roughness ); }\n return mip;\n }\n vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {\n float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );\n float mipF = fract( mip );\n float mipInt = floor( mip );\n vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );\n if ( mipF == 0.0 ) {\n return vec4( color0, 1.0 );\n } else {\n vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );\n return vec4( mix( color0, color1, mipF ), 1.0 );\n }\n }\n#endif", 6108 defaultnormal_vertex: "vec3 transformedNormal = objectNormal;\n#ifdef USE_TANGENT\n vec3 transformedTangent = objectTangent;\n#endif\n#ifdef USE_BATCHING\n mat3 bm = mat3( batchingMatrix );
6108\n transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );\n transformedNormal = bm * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = bm * transformedTangent;\n #endif\n#endif\n#ifdef USE_INSTANCING\n mat3 im = mat3( instanceMatrix );\n transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );\n transformedNormal = im * transformedNormal;\n #ifdef USE_TANGENT\n transformedTangent = im * transformedTangent;\n #endif\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n transformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;\n#endif", 6109 displacementmap_pars_vertex: "#ifdef USE_DISPLACEMENTMAP\n uniform sampler2D displacementMap;\n uniform float displacementScale;\n uniform float displacementBias;\n#endif", 6110 displacementmap_vertex: "#ifdef USE_DISPLACEMENTMAP\n transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );\n#endif", 6111 emissivemap_fragment: "#ifdef USE_EMISSIVEMAP\n vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );\n #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE\n emissiveColor = sRGBTransferEOTF( emissiveColor );\n #endif\n totalEmissiveRadiance *= emissiveColor.rgb;\n#endif", 6112 emissivemap_pars_fragment: "#ifdef USE_EMISSIVEMAP\n uniform sampler2D emissiveMap;\n#endif", 6113 colorspace_fragment: "gl_FragColor = linearToOutputTexel( gl_FragColor );", 6114 colorspace_pars_fragment: "vec4 LinearTransferOETF( in vec4 value ) {\n return value;\n}\nvec4 sRGBTransferEOTF( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 sRGBTransferOETF( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}", 6115 envmap_fragment: "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vec3 cameraToFrag;\n if ( isOrthographic ) {\n cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n } else {\n cameraToFrag = normalize( vWorldPosition - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vec3 reflectVec = reflect( cameraToFrag, worldNormal );\n #else\n vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n #endif\n #else\n vec3 reflectVec = vReflect;\n #endif\n #ifdef ENVMAP_TYPE_CUBE\n vec4 envColor = textureCube( envMap, envMapRotation * reflectVec );\n #ifdef ENVMAP_BLENDING_MULTIPLY\n outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_MIX )\n outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n #elif defined( ENVMAP_BLENDING_ADD )\n outgoingLight += envColor.xyz * specularStrength * reflectivity;\n #endif\n #endif\n#endif", 6116 envmap_common_pars_fragment: "#ifdef USE_ENVMAP\n uniform float envMapIntensity;\n uniform mat3 envMapRotation;\n #ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n #else\n uniform sampler2D envMap;\n #endif\n#endif", 6117 envmap_pars_fragment: "#ifdef USE_ENVMAP\n uniform float reflectivity;\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n varying vec3 vWorldPosition;\n uniform float refractionRatio;\n #else\n varying vec3 vReflect;\n #endif\n#endif", 6118 envmap_pars_vertex: "#ifdef USE_ENVMAP\n #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )\n #define ENV_WORLDPOS\n #endif\n #ifdef ENV_WORLDPOS\n \n varying vec3 vWorldPosition;\n #else\n varying vec3 vReflect;\n uniform float refractionRatio;\n #endif\n#endif", 6119 envmap_physical_pars_fragment: "#ifdef USE_ENVMAP\n vec3 getIBLIrradiance( const in vec3 normal ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );\n return PI * envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 reflectVec = reflect( - viewDir, normal );
6119\n reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );\n reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix );\n vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );\n return envMapColor.rgb * envMapIntensity;\n #else\n return vec3( 0.0 );\n #endif\n }\n #ifdef USE_ANISOTROPY\n vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {\n #ifdef ENVMAP_TYPE_CUBE_UV\n vec3 bentNormal = cross( bitangent, viewDir );\n bentNormal = normalize( cross( bentNormal, bitangent ) );\n bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );\n return getIBLRadiance( viewDir, bentNormal, roughness );\n #else\n return vec3( 0.0 );\n #endif\n }\n #endif\n#endif", 6120 envmap_vertex: "#ifdef USE_ENVMAP\n #ifdef ENV_WORLDPOS\n vWorldPosition = worldPosition.xyz;\n #else\n vec3 cameraToVertex;\n if ( isOrthographic ) {\n cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n }
6120 else {\n cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n }\n vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #ifdef ENVMAP_MODE_REFLECTION\n vReflect = reflect( cameraToVertex, worldNormal );\n #else\n vReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n #endif\n #endif\n#endif", 6121 fog_vertex: "#ifdef USE_FOG\n vFogDepth = - mvPosition.z;\n#endif", 6122 fog_pars_vertex: "#ifdef USE_FOG\n varying float vFogDepth;\n#endif", 6123 fog_fragment: "#ifdef USE_FOG\n #ifdef FOG_EXP2\n float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );\n #else\n float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );\n #endif\n gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif", 6124 fog_pars_fragment: "#ifdef USE_FOG\n uniform vec3 fogColor;\n varying float vFogDepth;\n #ifdef FOG_EXP2\n uniform float fogDensity;\n #else\n uniform float fogNear;\n uniform float fogFar;\n #endif\n#endif", 6125 gradientmap_pars_fragment: "#ifdef USE_GRADIENTMAP\n uniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n float dotNL = dot( normal, lightDirection );\n vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n #ifdef USE_GRADIENTMAP\n return vec3( texture2D( gradientMap, coord ).r );\n #else\n vec2 fw = fwidth( coord ) * 0.5;\n return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );\n #endif\n}", 6126 lightmap_pars_fragment: "#ifdef USE_LIGHTMAP\n uniform sampler2D lightMap;\n uniform float lightMapIntensity;\n#endif", 6127 lights_lambert_fragment: "LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;", 6128 lights_lambert_pars_fragment: "varying vec3 vViewPosition;\nstruct LambertMaterial {\n vec3 diffuseColor;\n float specularStrength;\n};\nvoid RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert", 6129 lights_pars_begin: "uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\n#if defined( USE_LIGHT_PROBES )\n uniform vec3 lightProbe[ 9 ];\n#endif\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n float x = normal.x, y = normal.y, z = normal.z;\n vec3 result = shCoefficients[ 0 ] * 0.886227;\n result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n return result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {\n vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n return irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n vec3 irradiance = ambientLightColor;\n return irradiance;\n}\nfloat getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if ( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n}\nfloat getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {\n return smoothstep( coneCosine, penumbraCosine, angleCosine );\n}\n#if NUM_DIR_LIGHTS > 0\n struct DirectionalLight {\n vec3 direction;\n vec3 color;\n };\n uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {\n light.color = directionalLight.color;\n light.direction = directionalLight.direction;\n light.visible = true;\n }\n#endif\n#if NUM_POINT_LIGHTS > 0\n struct PointLight {\n vec3 position;\n vec3 color;\n float distance;\n float decay;\n };\n uniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = pointLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float lightDistance = length( lVector );\n light.color = pointLight.color;\n light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n }
6129\n#endif\n#if NUM_SPOT_LIGHTS > 0\n struct SpotLight {\n vec3 position;\n vec3 direction;\n vec3 color;\n float distance;\n float decay;\n float coneCos;\n float penumbraCos;\n };\n uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {\n vec3 lVector = spotLight.position - geometryPosition;\n light.direction = normalize( lVector );\n float angleCos = dot( light.direction, spotLight.direction );\n float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n if ( spotAttenuation > 0.0 ) {\n float lightDistance = length( lVector );\n light.color = spotLight.color * spotAttenuation;\n light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );\n light.visible = ( light.color != vec3( 0.0 ) );\n } else {\n light.color = vec3( 0.0 );\n light.visible = false;\n }\n }\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n struct RectAreaLight {\n vec3 color;\n vec3 position;\n vec3 halfWidth;\n vec3 halfHeight;\n };\n uniform sampler2D ltc_1; uniform sampler2D ltc_2;\n uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n struct HemisphereLight {\n vec3 direction;\n vec3 skyColor;\n vec3 groundColor;\n };\n uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {\n float dotNL = dot( normal, hemiLight.direction );\n float hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n return irradiance;\n }\n#endif\n#include <lightprobes_pars_fragment>", 6130 lights_toon_fragment: "ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;", 6131 lights_toon_pars_fragment: "varying vec3 vViewPosition;\nstruct ToonMaterial {\n vec3 diffuseColor;\n};\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon", 6132 lights_phong_fragment: "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;", 6133 lights_phong_pars_fragment: "varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\n vec3 diffuseColor;\n vec3 specularColor;\n float specularShininess;\n float specularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong", 6134 lights_physical_fragment: "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.metalness = metalnessFactor;\nvec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\nmaterial.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;\nmaterial.roughness = min( material.roughness, 1.0 );\n#ifdef IOR\n material.ior = ior;\n #ifdef USE_SPECULAR\n float specularIntensityFactor = specularIntensity;\n vec3 specularColorFactor = specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;\n #endif\n material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );\n #else\n float specularIntensityFactor = 1.0;\n vec3 specularColorFactor = vec3( 1.0 );\n material.specularF90 = 1.0;\n #endif\n material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n#else\n material.specularColor = vec3( 0.04 );\n material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );\n material.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\n material.clearcoat = clearcoat;
6134\n material.clearcoatRoughness = clearcoatRoughness;\n material.clearcoatF0 = vec3( 0.04 );\n material.clearcoatF90 = 1.0;\n #ifdef USE_CLEARCOATMAP\n material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;\n #endif\n #ifdef USE_CLEARCOAT_ROUGHNESSMAP\n material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;\n #endif\n material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n material.clearcoatRoughness += geometryRoughness;\n material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n#endif\n#ifdef USE_DISPERSION\n material.dispersion = dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n material.iridescence = iridescence;\n material.iridescenceIOR = iridescenceIOR;\n #ifdef USE_IRIDESCENCEMAP\n material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;\n #endif\n #ifdef USE_IRIDESCENCE_THICKNESSMAP\n material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;\n #else\n material.iridescenceThickness = iridescenceThicknessMaximum;\n #endif\n#endif\n#ifdef USE_SHEEN\n material.sheenColor = sheenColor;\n #ifdef USE_SHEEN_COLORMAP\n material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;\n #endif\n material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 );\n #ifdef USE_SHEEN_ROUGHNESSMAP\n material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n #ifdef USE_ANISOTROPYMAP\n mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );\n vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;\n vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;\n #else\n vec2 anisotropyV = anisotropyVector;\n #endif\n material.anisotropy = length( anisotropyV );\n if( material.anisotropy == 0.0 ) {\n anisotropyV = vec2( 1.0, 0.0 );\n } else {\n anisotropyV /= material.anisotropy;\n material.anisotropy = saturate( material.anisotropy );\n }\n material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );\n material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;\n material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;\n#endif", 6135 lights_physical_pars_fragment: "uniform sampler2D dfgLUT;\nstruct PhysicalMaterial {\n vec3 diffuseColor;\n vec3 diffuseContribution;\n vec3 specularColor;\n vec3 specularColorBlended;\n float roughness;\n float metalness;\n float specularF90;\n float dispersion;\n #ifdef USE_CLEARCOAT\n float clearcoat;\n float clearcoatRoughness;\n vec3 clearcoatF0;\n float clearcoatF90;\n #endif\n #ifdef USE_IRIDESCENCE\n float iridescence;\n float iridescenceIOR;\n float iridescenceThickness;\n vec3 iridescenceFresnel;\n vec3 iridescenceF0;\n vec3 iridescenceFresnelDielectric;\n vec3 iridescenceFresnelMetallic;\n #endif\n #ifdef USE_SHEEN\n vec3 sheenColor;\n float sheenRoughness;\n #endif\n #ifdef IOR\n float ior;\n #endif\n #ifdef USE_TRANSMISSION\n float transmission;\n float transmissionAlpha;\n float thickness;\n float attenuationDistance;\n vec3 attenuationColor;\n #endif\n #ifdef USE_ANISOTROPY\n float anisotropy;\n float alphaT;\n vec3 anisotropyT;\n vec3 anisotropyB;\n #endif\n};\nvec3 clearcoatSpecularDirect = vec3( 0.0 );\nvec3 clearcoatSpecularIndirect = vec3( 0.0 );\nvec3 sheenSpecularDirect = vec3( 0.0 );\nvec3 sheenSpecularIndirect = vec3(0.0 );\nvec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {\n float x = clamp( 1.0 - dotVH, 0.0, 1.0 );\n float x2 = x * x;\n float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );\n return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );\n}\nfloat V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n#ifdef USE_ANISOTROPY\n float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {\n float gv = dotNL * length( vec3( alphaT * dotTV, alph
6135aB * dotBV, dotNV ) );\n float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n }\n float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {\n float a2 = alphaT * alphaB;\n highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );\n highp float v2 = dot( v, v );\n float w2 = a2 / v2;\n return RECIPROCAL_PI * a2 * pow2 ( w2 );\n }\n#endif\n#ifdef USE_CLEARCOAT\n vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {\n vec3 f0 = material.clearcoatF0;\n float f90 = material.clearcoatF90;\n float roughness = material.clearcoatRoughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( V * D );\n }\n#endif\nvec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 f0 = material.specularColorBlended;\n float f90 = material.specularF90;\n float roughness = material.roughness;\n float alpha = pow2( roughness );\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotVH = saturate( dot( viewDir, halfDir ) );\n vec3 F = F_Schlick( f0, f90, dotVH );\n #ifdef USE_IRIDESCENCE\n F = mix( F, material.iridescenceFresnel, material.iridescence );\n #endif\n #ifdef USE_ANISOTROPY\n float dotTL = dot( material.anisotropyT, lightDir );\n float dotTV = dot( material.anisotropyT, viewDir );\n float dotTH = dot( material.anisotropyT, halfDir );\n float dotBL = dot( material.anisotropyB, lightDir );\n float dotBV = dot( material.anisotropyB, viewDir );\n float dotBH = dot( material.anisotropyB, halfDir );\n float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );\n float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );\n #else\n float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n #endif\n return F * ( V * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x >
6135 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 );\n mat3 mat = mInv * transpose( mat3( T1, T2, N ) );\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n return vec3( result );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie( float roughness, float dotNH ) {\n float alpha = pow2( roughness );\n float invAlpha = 1.0 / alpha;\n float cos2h = dotNH * dotNH;\n float sin2h = max( 1.0 - cos2h, 0.0078125 );\n return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );\n}\nfloat V_Neubelt( float dotNV, float dotNL ) {\n return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );\n}\nvec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {\n vec3 halfDir = normalize( lightDir + viewDir );\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float D = D_Charlie( sheenRoughness, dotNH );\n float V = V_Neubelt( dotNV, dotNL );\n return sheenColor * ( D * V );\n}\n#endif\nfloat IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n float r2 = roughness * roughness;\n float rInv = 1.0 / ( roughness + 0.1 );\n float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;\n float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;\n float DG = exp( a * dotNV + b );\n return saturate( DG );\n}\nvec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n return specularColor * fab.x + specularF90 * fab.y;\n}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#else\nvoid computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n#endif\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;\n #ifdef USE_IRIDESCENCE\n vec3 Fr = mix( specularColor, iridescenceF0, iridescence );\n #else\n vec3 Fr = specularColor;\n #endif\n vec3 FssEss = Fr * fab.x + specularF90 * fab.y;\n float Ess = fab.x + fab.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nvec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {\n vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
6135\n float dotNL = saturate( dot( normal, lightDir ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;\n vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;\n vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;\n vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y;\n float Ess_V = dfgV.x + dfgV.y;\n float Ess_L = dfgL.x + dfgL.y;\n float Ems_V = 1.0 - Ess_V;\n float Ems_L = 1.0 - Ess_L;\n vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;\n vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON );\n float compensationFactor = Ems_V * Ems_L;\n vec3 multiScatter = Fms * compensationFactor;\n return singleScatter + multiScatter;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 normal = geometryNormal;\n vec3 viewDir = geometryViewDir;\n vec3 position = geometryPosition;\n vec3 lightPos = rectAreaLight.position;\n vec3 halfWidth = rectAreaLight.halfWidth;\n vec3 halfHeight = rectAreaLight.halfHeight;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.roughness;\n vec3 rectCoords[ 4 ];\n rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n vec2 uv = LTC_Uv( normal, viewDir, roughness );\n vec4 t1 = texture2D( ltc_1, uv );\n vec4 t2 = texture2D( ltc_2, uv );\n mat3 mInv = mat3(\n vec3( t1.x, 0, t1.y ),\n vec3( 0, 1, 0 ),\n vec3( t1.z, 0, t1.w )\n );\n vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y );\n reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n #ifdef USE_CLEARCOAT\n vec3 Ncc = geometryClearcoatNormal;\n vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness );\n vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat );\n vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat );\n mat3 mInvClearcoat = mat3(\n vec3( t1Clearcoat.x, 0, t1Clearcoat.y ),\n vec3( 0, 1, 0 ),\n vec3( t1Clearcoat.z, 0, t1Clearcoat.w )\n );\n vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y;\n clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords );\n #endif\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n float dotNL = saturate( dot( geometryNormal, directLight.direction ) );\n vec3 irradiance = dotNL * directLight.color;\n #ifdef USE_CLEARCOAT\n float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );\n vec3 ccIrradiance = dotNLcc * directLight.color;\n clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );\n #endif\n #ifdef USE_SHEEN\n \n sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );\n \n float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );\n \n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );\n \n irradiance *= sheenEnergyComp;\n \n #endif\n reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );\n reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n diffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectDiffuse += diffuse;\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n #ifdef USE_CLEARCOAT\n clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );\n #endif\n #ifdef USE_SHEEN\n sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI;\n #endif\n vec3 singleScatteringDielectric = vec3( 0.0 );\n vec3 multiScatteringDielectric = vec3( 0.0 );\n vec3 singleScatteringMetallic = vec3( 0.0 );\n vec3 multiScatteringMetallic = vec3( 0.0 );
6135\n #ifdef USE_IRIDESCENCE\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #else\n computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );\n computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );\n #endif\n vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );\n vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );\n vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;\n vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );\n vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n vec3 indirectSpecular = radiance * singleScattering;\n indirectSpecular += multiScattering * cosineWeightedIrradiance;\n vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;\n #ifdef USE_SHEEN\n float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );\n float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;\n indirectSpecular *= sheenEnergyComp;\n indirectDiffuse *= sheenEnergyComp;\n #endif\n reflectedLight.indirectSpecular += indirectSpecular;\n reflectedLight.indirectDiffuse += indirectDiffuse;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}", 6136 lights_fragment_begin: "\nvec3 geometryPosition = - vViewPosition;\nvec3 geometryNormal = normal;\nvec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\nvec3 geometryClearcoatNormal = vec3( 0.0 );\n#ifdef USE_CLEARCOAT\n geometryClearcoatNormal = clearcoatNormal;\n#endif\n#ifdef USE_IRIDESCENCE\n float dotNVi = saturate( dot( normal, geometryViewDir ) );\n if ( material.iridescenceThickness == 0.0 ) {\n material.iridescence = 0.0;\n } else {\n material.iridescence = saturate( material.iridescence );\n }\n if ( material.iridescence > 0.0 ) {\n material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );\n material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );\n material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );\n material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );\n }\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n PointLight pointLight;\n #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n PointLightShadow pointLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n pointLight = pointLights[ i ];\n getPointLightInfo( pointLight, geometryPosition, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n pointLightShadow = pointLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }
6136\n #pragma unroll_loop_end\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n SpotLight spotLight;\n vec4 spotColor;\n vec3 spotLightCoord;\n bool inSpotLightMap;\n #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n spotLight = spotLights[ i ];\n getSpotLightInfo( spotLight, geometryPosition, directLight );\n #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX\n #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS\n #else\n #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )\n #endif\n #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )\n spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;\n inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );\n spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );\n directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;\n #endif\n #undef SPOT_LIGHT_MAP_INDEX\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n spotLightShadow = spotLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n DirectionalLight directionalLight;\n #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLightShadow;\n #endif\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n directionalLight = directionalLights[ i ];\n getDirectionalLightInfo( directionalLight, directLight );\n #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n directionalLightShadow = directionalLightShadows[ i ];\n directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n #endif\n RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n RectAreaLight rectAreaLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n rectAreaLight = rectAreaLights[ i ];\n RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n }\n #pragma unroll_loop_end\n#endif\n#if defined( RE_IndirectDiffuse )\n vec3 iblIrradiance = vec3( 0.0 );\n vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n #if defined( USE_LIGHT_PROBES )\n irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );\n #endif\n #if ( NUM_HEMI_LIGHTS > 0 )\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );\n }\n #pragma unroll_loop_end\n #endif\n #ifdef USE_LIGHT_PROBES_GRID\n vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz;\n vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix );\n irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal );\n #endif\n#endif\n#if defined( RE_IndirectSpecular )\n vec3 radiance = vec3( 0.0 );\n vec3 clearcoatRadiance = vec3( 0.0 );\n#endif", 6137 lights_fragment_maps: "#if defined( RE_IndirectDiffuse )\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n irradiance += lightMapIrradiance;\n #endif\n #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV )\n #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG )\n iblIrradiance += getIBLIrradiance( geometryNormal );\n #endif\n #endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n #ifdef USE_ANISOTROPY\n radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );\n #else\n radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );\n #endif\n #ifdef USE_CLEARCOAT\n clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );\n #endif\n#endif", 6138 lights_fragment_end: "#if defined( RE_IndirectDiffuse )\n #if defined( LAMBERT ) || defined( PHONG )\n irradiance += iblIrradiance;\n #endif\n RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );\n#endif", 6139 lightprobes_pars_fragment: "#ifdef USE_LIGHT_PROBES_GRID\nuniform highp sampler3D probesSH;\nuniform vec3 probesMin;\nuniform vec3 probesMax;\nuniform vec3 probesResolution;\nvec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {\n vec3 res = probesResolution;\n vec3 gridRange = probesMax - probesMin;\n vec3 resMinusOne = res - 1.0;\n vec3 probeSpacing = gridRange / resMinusOne;\n vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5;\n vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 );\n uvw = uvw * resMinusOne / res + 0.5 / res;\n float nz = res.z;\n float paddedSlices = nz + 2.0;\n float atlasDepth = 7.0 * paddedSlices;\n float uvZBase = uvw.z * nz + 1.0;\n vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) );\n vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) );\n vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) );\n vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) );\n vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) );\n vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) );\n vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) );\n vec3 c0 = s0.xyz;\n vec3 c1 = vec3( s0.w, s1.xy );\n vec3 c2 = vec3( s1.zw, s2.x );\n vec3 c3 = s2.yzw;\n vec3 c4 = s3.xyz;\n vec3 c5 = vec3( s3.w, s4.xy );\n vec3 c6 = vec3( s4.zw, s5.x );\n vec3 c7 = s5.yzw;\n vec3 c8 = s6.xyz;\n float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z;\n vec3 result = c0 * 0.886227;\n result += c1 * 2.0 * 0.511664 * y;\n result += c2 * 2.0 * 0.511664 * z;\n result += c3 * 2.0 * 0.511664 * x;\n result += c4 * 2.0 * 0.429043 * x * y;\n result += c5 * 2.0 * 0.429043 * y * z;\n result += c6 * ( 0.743125 * z * z - 0.247708 );\n result += c7 * 2.0 * 0.429043 * x * z;\n result += c8 * 0.429043 * ( x * x - y * y );\n return max( result, vec3( 0.0 ) );\n}\n#endif", 6140 logdepthbuf_fragment: "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n#endif", 6141 logdepthbuf_pars_fragment: "#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )\n uniform float logDepthBufFC;\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif", 6142 logdepthbuf_pars_vertex: "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n varying float vFragDepth;\n varying float vIsPerspective;\n#endif", 6143 logdepthbuf_vertex: "#ifdef USE_LOGARITHMIC_DEPTH_BUFFER\n vFragDepth = 1.0 + gl_Position.w;\n vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n#endif", 6144 map_fragment: "#ifdef USE_MAP\n vec4 sampledDiffuseColor = texture2D( map, vMapUv );\n #ifdef DECODE_VIDEO_TEXTURE\n sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );\n #endif\n diffuseColor *= sampledDiffuseColor;\n#endif", 6145 map_pars_fragment: "#ifdef USE_MAP\n uniform sampler2D map;\n#endif", 6146 map_particle_fragment: "#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n #if defined( USE_POINTS_UV )\n vec2 uv = vUv;\n #else\n vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n #endif\n#endif\n#ifdef USE_MAP\n diffuseColor *= texture2D( map, uv );\n#endif\n#ifdef USE_ALPHAMAP\n diffuseColor.a *= texture2D( alphaMap, uv ).g;\n#endif", 6147 map_particle_pars_fragment: "#if defined( USE_POINTS_UV )\n varying vec2 vUv;\n#else\n #if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n uniform mat3 uvTransform;\n #endif\n#endif\n#ifdef USE_MAP\n uniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\n uniform sampler2D alphaMap;\n#endif", 6148 metalnessmap_fragment: "float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );\n metalnessFactor *= texelMetalness.b;\n#endif", 6149 metalnessmap_pars_fragment: "#ifdef USE_METALNESSMAP\n uniform sampler2D metalnessMap;\n#endif", 6150 morphinstance_vertex: "#ifdef USE_INSTANCING_MORPH\n float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;\n }\n#endif", 6151 morphcolor_vertex: "#if defined( USE_MORPHCOLORS )\n vColor *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n #if defined( USE_COLOR_ALPHA )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];\n #elif defined( USE_COLOR )\n if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];\n #endif\n }\n#endif", 6152 morphnormal_vertex: "#ifdef USE_MORPHNORMALS\n objectNormal *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];\n }\n#endif", 6153 morphtarget_pars_vertex: "#ifdef USE_MORPHTARGETS\n #ifndef USE_INSTANCING_MORPH\n uniform float morphTargetBaseInfluence;\n uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];\n #endif\n uniform sampler2DArray morphTargetsTexture;\n uniform ivec2 morphTargetsTextureSize;\n vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {\n int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\n int y = texelIndex / morphTargetsTextureSize.x;\n int x = texelIndex - y * morphTargetsTextureSize.x;\n ivec3 morphUV = ivec3( x, y, morphTargetIndex );\n return texelFetch( morphTargetsTexture, morphUV, 0 );\n }\n#endif", 6154 morphtarget_vertex: "#ifdef USE_MORPHTARGETS\n transformed *= morphTargetBaseInfluence;\n for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {\n if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];\n }\n#endif", 6155 normal_fragment_begin: "float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\n vec3 fdx = dFdx( vViewPosition );\n vec3 fdy = dFdy( vViewPosition );\n vec3 normal = normalize( cross( fdx, fdy ) );\n#else\n vec3 normal = normalize( vNormal );\n #ifdef DOUBLE_SIDED\n normal *= faceDirection;\n #endif\n#endif\n#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )\n #ifdef USE_TANGENT\n mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn = getTangentFrame( - vViewPosition, normal,\n #if defined( USE_NORMALMAP )\n vNormalMapUv\n #elif defined( USE_CLEARCOAT_NORMALMAP )\n vClearcoatNormalMapUv\n #else\n vUv\n #endif\n );\n #endif\n #ifdef DOUBLE_SIDED\n tbn[0] *= faceDirection;\n tbn[1] *= faceDirection;\n #endif\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n #ifdef USE_TANGENT\n mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );\n #else\n mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );\n #endif\n #ifdef DOUBLE_SIDED\n tbn2[0] *= faceDirection;\n tbn2[1] *= faceDirection;\n #endif\n#endif\nvec3 nonPerturbedNormal = normal;", 6156 normal_fragment_maps: "#ifdef USE_NORMALMAP_OBJECTSPACE\n normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #ifdef FLIP_SIDED\n normal = - normal;\n #endif\n #ifdef DOUBLE_SIDED\n normal = normal * faceDirection;\n #endif\n normal = normalize( normalMatrix * normal );\n#elif defined( USE_NORMALMAP_TANGENTSPACE )\n vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;\n #if defined( USE_PACKED_NORMALMAP )\n mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) );\n #endif\n mapN.xy *= normalScale;\n normal = normalize( tbn * mapN );
6156\n#elif defined( USE_BUMPMAP )\n normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );\n#endif", 6157 normal_pars_fragment: "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif", 6158 normal_pars_vertex: "#ifndef FLAT_SHADED\n varying vec3 vNormal;\n #ifdef USE_TANGENT\n varying vec3 vTangent;\n varying vec3 vBitangent;\n #endif\n#endif", 6159 normal_vertex: "#ifndef FLAT_SHADED\n vNormal = normalize( transformedNormal );\n #ifdef USE_TANGENT\n vTangent = normalize( transformedTangent );\n vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n #ifdef FLIP_SIDED\n vBitangent = - vBitangent;\n #endif\n #endif\n#endif", 6160 normalmap_pars_fragment: "#ifdef USE_NORMALMAP\n uniform sampler2D normalMap;\n uniform vec2 normalScale;\n#endif\n#ifdef USE_NORMALMAP_OBJECTSPACE\n uniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )\n mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {\n vec3 q0 = dFdx( eye_pos.xyz );\n vec3 q1 = dFdy( eye_pos.xyz );\n vec2 st0 = dFdx( uv.st );\n vec2 st1 = dFdy( uv.st );\n vec3 N = surf_norm;\n vec3 q1perp = cross( q1, N );\n vec3 q0perp = cross( N, q0 );\n vec3 T = q1perp * st0.x + q0perp * st1.x;\n vec3 B = q1perp * st0.y + q0perp * st1.y;\n float det = max( dot( T, T ), dot( B, B ) );\n float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );\n return mat3( T * scale, B * scale, N );\n }\n#endif", 6161 clearcoat_normal_fragment_begin: "#ifdef USE_CLEARCOAT\n vec3 clearcoatNormal = nonPerturbedNormal;\n#endif", 6162 clearcoat_normal_fragment_maps: "#ifdef USE_CLEARCOAT_NORMALMAP\n vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;\n clearcoatMapN.xy *= clearcoatNormalScale;\n clearcoatNormal = normalize( tbn2 * clearcoatMapN );\n#endif", 6163 clearcoat_pars_fragment: "#ifdef USE_CLEARCOATMAP\n uniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform sampler2D clearcoatNormalMap;\n uniform vec2 clearcoatNormalScale;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform sampler2D clearcoatRoughnessMap;\n#endif", 6164 iridescence_pars_fragment: "#ifdef USE_IRIDESCENCEMAP\n uniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform sampler2D iridescenceThicknessMap;\n#endif", 6165 opaque_fragment: "#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.transmissionAlpha;\n#endif\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );", 6166 packing: "vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;\nconst float Inv255 = 1. / 255.;\nconst vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );\nconst vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );\nconst vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );\nconst vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );\nvec4 packDepthToRGBA( const in float v ) {\n if( v <= 0.0 )\n return vec4( 0., 0., 0., 0. );\n if( v >= 1.0 )\n return vec4( 1., 1., 1., 1. );\n float vuf;\n float af = modf( v * PackFactors.a, vuf );\n float bf = modf( vuf * ShiftRight8, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );\n}\nvec3 packDepthToRGB( const in float v ) {\n if( v <= 0.0 )\n return vec3( 0., 0., 0. );\n if( v >= 1.0 )\n return vec3( 1., 1., 1. );\n float vuf;\n float bf = modf( v * PackFactors.b, vuf );\n float gf = modf( vuf * ShiftRight8, vuf );\n return vec3( vuf * Inv255, gf * PackUpscale, bf );\n}\nvec2 packDepthToRG( const in float v ) {\n if( v <= 0.0 )\n return vec2( 0., 0. );\n if( v >= 1.0 )\n return vec2( 1., 1. );\n float vuf;\n float gf = modf( v * 256., vuf );\n return vec2( vuf * Inv255, gf );\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n return dot( v, UnpackFactors4 );\n}\nfloat unpackRGBToDepth( const in vec3 v ) {\n return dot( v, UnpackFactors3 );\n}\nfloat unpackRGToDepth( const in vec2 v ) {\n return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;\n}\nvec4 pack2HalfToRGBA( const in vec2 v ) {\n vec4 r = vec4( v.x, fract( v.x * 25
61665.0 ), v.y, fract( v.y * 255.0 ) );\n return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );\n}\nvec2 unpackRGBATo2Half( const in vec4 v ) {\n return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n \n return depth * ( far - near ) - far;\n #else\n return depth * ( near - far ) - near;\n #endif\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {\n \n #ifdef USE_REVERSED_DEPTH_BUFFER\n return ( near * far ) / ( ( near - far ) * depth - near );\n #else\n return ( near * far ) / ( ( far - near ) * depth - far );\n #endif\n}", 6167 premultiplied_alpha_fragment: "#ifdef PREMULTIPLIED_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif", 6168 project_vertex: "vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_BATCHING\n mvPosition = batchingMatrix * mvPosition;\n#endif\n#ifdef USE_INSTANCING\n mvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;", 6169 dithering_fragment: "#ifdef DITHERING\n gl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif", 6170 dithering_pars_fragment: "#ifdef DITHERING\n vec3 dithering( vec3 color ) {\n float grid_position = rand( gl_FragCoord.xy );\n vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n return color + dither_shift_RGB;\n }\n#endif", 6171 roughnessmap_fragment: "float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );\n roughnessFactor *= texelRoughness.g;\n#endif", 6172 roughnessmap_pars_fragment: "#ifdef USE_ROUGHNESSMAP\n uniform sampler2D roughnessMap;\n#endif", 6173 shadowmap_pars_fragment: "#if NUM_SPOT_LIGHT_COORDS > 0\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\n uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #else\n uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #else\n uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #elif defined( SHADOWMAP_TYPE_BASIC )\n uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float interleavedGradientNoise( vec2 position ) {\n return fract( 52.9829189 * fract( dot
6173( position, vec2( 0.06711056, 0.00583715 ) ) ) );\n }\n vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {\n const float goldenAngle = 2.399963229728653;\n float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );\n float theta = float( sampleIndex ) * goldenAngle + phi;\n return vec2( cos( theta ), sin( theta ) ) * r;\n }\n #endif\n #if defined( SHADOWMAP_TYPE_PCF )\n float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n shadowCoord.z += shadowBias;\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n float radius = shadowRadius * texelSize.x;\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n shadow = (\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +\n texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_VSM )\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;\n float mean = distribution.x;\n float variance = distribution.y * distribution.y;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float hard_shadow = step( mean, shadowCoord.z );\n #else\n float hard_shadow = step( shadowCoord.z, mean );\n #endif\n \n if ( hard_shadow == 1.0 ) {\n shadow = 1.0;\n } else {\n variance = max( variance, 0.0000001 );\n float d = shadowCoord.z - mean;\n float p_max = variance / ( variance + d * d );\n p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );\n shadow = max( hard_shadow, p_max );\n }\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #else\n float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n float shadow = 1.0;\n shadowCoord.xyz /= shadowCoord.w;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadowCoord.z -= shadowBias;\n #else\n shadowCoord.z += shadowBias;\n #endif\n bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\n bool frustumTest = inFrustum && shadowCoord.z <= 1.0;\n if ( frustumTest ) {\n float depth = texture2D( shadowMap, shadowCoord.xy ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n shadow = step( depth, shadowCoord.z );\n #else\n shadow = step( shadowCoord.z, depth );\n #endif\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #if defined( SHADOWMAP_TYPE_PCF )\n float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 bd3D = normalize( lightToPosition );\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
6173\n dp -= shadowBias;\n #else\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n #endif\n float texelSize = shadowRadius / shadowMapSize.x;\n vec3 absDir = abs( bd3D );\n vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );\n tangent = normalize( cross( bd3D, tangent ) );\n vec3 bitangent = cross( bd3D, tangent );\n float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2;\n vec2 sample0 = vogelDiskSample( 0, 5, phi );\n vec2 sample1 = vogelDiskSample( 1, 5, phi );\n vec2 sample2 = vogelDiskSample( 2, 5, phi );\n vec2 sample3 = vogelDiskSample( 3, 5, phi );\n vec2 sample4 = vogelDiskSample( 4, 5, phi );\n shadow = (\n texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) +\n texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) )\n ) * 0.2;\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #elif defined( SHADOWMAP_TYPE_BASIC )\n float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n float shadow = 1.0;\n vec3 lightToPosition = shadowCoord.xyz;\n vec3 absVec = abs( lightToPosition );\n float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );\n if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {\n float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );\n dp += shadowBias;\n vec3 bd3D = normalize( lightToPosition );\n float depth = textureCube( shadowMap, bd3D ).r;\n #ifdef USE_REVERSED_DEPTH_BUFFER\n depth = 1.0 - depth;\n #endif\n shadow = step( dp, depth );\n }\n return mix( 1.0, shadow, shadowIntensity );\n }\n #endif\n #endif\n#endif", 6174 shadowmap_pars_vertex: "#if NUM_SPOT_LIGHT_COORDS > 0\n uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];\n varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];\n#endif\n#ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n struct DirectionalLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n struct SpotLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n };\n uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n struct PointLightShadow {\n float shadowIntensity;\n float shadowBias;\n float shadowNormalBias;\n float shadowRadius;\n vec2 shadowMapSize;\n float shadowCameraNear;\n float shadowCameraFar;\n };\n uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n #endif\n#endif", 6175 shadowmap_vertex: "#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )\n #ifdef HAS_NORMAL\n vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );\n #else\n vec3 shadowWorldNormal = vec3( 0.0 );\n #endif\n vec4 shadowWorldPosition;\n#endif\n#if defined( USE_SHADOWMAP )\n #if NUM_DIR_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n }
6175\n #pragma unroll_loop_end\n #endif\n#endif\n#if NUM_SPOT_LIGHT_COORDS > 0\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {\n shadowWorldPosition = worldPosition;\n #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;\n #endif\n vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;\n }\n #pragma unroll_loop_end\n#endif", 6176 shadowmask_pars_fragment: "float getShadowMask() {\n float shadow = 1.0;\n #ifdef USE_SHADOWMAP\n #if NUM_DIR_LIGHT_SHADOWS > 0\n DirectionalLightShadow directionalLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n directionalLight = directionalLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_SPOT_LIGHT_SHADOWS > 0\n SpotLightShadow spotLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n spotLight = spotLightShadows[ i ];\n shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )\n PointLightShadow pointLight;\n #pragma unroll_loop_start\n for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n pointLight = pointLightShadows[ i ];\n shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n }\n #pragma unroll_loop_end\n #endif\n #endif\n return shadow;\n}", 6177 skinbase_vertex: "#ifdef USE_SKINNING\n mat4 boneMatX = getBoneMatrix( skinIndex.x );\n mat4 boneMatY = getBoneMatrix( skinIndex.y );\n mat4 boneMatZ = getBoneMatrix( skinIndex.z );\n mat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif", 6178 skinning_pars_vertex: "#ifdef USE_SKINNING\n uniform mat4 bindMatrix;\n uniform mat4 bindMatrixInverse;\n uniform highp sampler2D boneTexture;\n mat4 getBoneMatrix( const in float i ) {\n int size = textureSize( boneTexture, 0 ).x;\n int j = int( i ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n#endif", 6179 skinning_vertex: "#ifdef USE_SKINNING\n vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n vec4 skinned = vec4( 0.0 );\n skinned += boneMatX * skinVertex * skinWeight.x;\n skinned += boneMatY * skinVertex * skinWeight.y;\n skinned += boneMatZ * skinVertex * skinWeight.z;\n skinned += boneMatW * skinVertex * skinWeight.w;\n transformed = ( bindMatrixInverse * skinned ).xyz;\n#endif", 6180 skinnormal_vertex: "#ifdef USE_SKINNING\n mat4 skinMatrix = mat4( 0.0 );\n skinMatrix += skinWeight.x * boneMatX;\n skinMatrix += skinWeight.y * boneMatY;\n skinMatrix += skinWeight.z * boneMatZ;\n skinMatrix += skinWeight.w * boneMatW;\n skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n #ifdef USE_TANGENT\n objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n #endif\n#endif", 6181 specularmap_fragment: "float specularStrength;\n#ifdef USE_SPECULARMAP\n vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );\n specularStrength = texelSpecular.r;\n#else\n specularStrength = 1.0;\n#endif", 6182 specularmap_pars_fragment: "#ifdef USE_SPECULARMAP\n uniform sampler2D specularMap;\n#endif", 6183 tonemapping_fragment: "#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif", 6184 tonemapping_pars_fragment: "#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;
6184\nvec3 LinearToneMapping( vec3 color ) {\n return saturate( toneMappingExposure * color );\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\nvec3 CineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 RRTAndODTFit( vec3 v ) {\n vec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n return a / b;\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n const mat3 ACESInputMat = mat3(\n vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),\n vec3( 0.04823, 0.01566, 0.83777 )\n );\n const mat3 ACESOutputMat = mat3(\n vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),\n vec3( -0.07367, -0.00605, 1.07602 )\n );\n color *= toneMappingExposure / 0.6;\n color = ACESInputMat * color;\n color = RRTAndODTFit( color );\n color = ACESOutputMat * color;\n return saturate( color );\n}\nconst mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(\n vec3( 1.6605, - 0.1246, - 0.0182 ),\n vec3( - 0.5876, 1.1329, - 0.1006 ),\n vec3( - 0.0728, - 0.0083, 1.1187 )\n);\nconst mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(\n vec3( 0.6274, 0.0691, 0.0164 ),\n vec3( 0.3293, 0.9195, 0.0880 ),\n vec3( 0.0433, 0.0113, 0.8956 )\n);\nvec3 agxDefaultContrastApprox( vec3 x ) {\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n return + 15.5 * x4 * x2\n - 40.14 * x4 * x\n + 31.96 * x4\n - 6.868 * x2 * x\n + 0.4298 * x2\n + 0.1191 * x\n - 0.00232;\n}\nvec3 AgXToneMapping( vec3 color ) {\n const mat3 AgXInsetMatrix = mat3(\n vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),\n vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),\n vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )\n );
6184\n const mat3 AgXOutsetMatrix = mat3(\n vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),\n vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),\n vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )\n );\n const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;\n color *= toneMappingExposure;\n color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;\n color = AgXInsetMatrix * color;\n color = max( color, 1e-10 ); color = log2( color );\n color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );\n color = clamp( color, 0.0, 1.0 );\n color = agxDefaultContrastApprox( color );\n color = AgXOutsetMatrix * color;\n color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );\n color = LINEAR_REC2020_TO_LINEAR_SRGB * color;\n color = clamp( color, 0.0, 1.0 );\n return color;\n}\nvec3 NeutralToneMapping( vec3 color ) {\n const float StartCompression = 0.8 - 0.04;\n const float Desaturation = 0.15;\n color *= toneMappingExposure;\n float x = min( color.r, min( color.g, color.b ) );\n float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;\n color -= offset;\n float peak = max( color.r, max( color.g, color.b ) );\n if ( peak < StartCompression ) return color;\n float d = 1. - StartCompression;\n float newPeak = 1. - d * d / ( peak + d - StartCompression );\n color *= newPeak / peak;\n float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );\n return mix( color, vec3( newPeak ), g );\n}\nvec3 CustomToneMapping( vec3 color ) { return color; }", 6185 transmission_fragment: "#ifdef USE_TRANSMISSION\n material.transmission = transmission;\n material.transmissionAlpha = 1.0;\n material.thickness = thickness;\n material.attenuationDistance = attenuationDistance;\n material.attenuationColor = attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;\n #endif\n #ifdef USE_THICKNESSMAP\n material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;\n #endif\n vec3 pos = vWorldPosition;\n vec3 v = normalize( cameraPosition - pos );\n vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix );\n vec4 transmitted = getIBLVolumeRefraction(\n n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,\n pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,\n material.attenuationColor, material.attenuationDistance );\n material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );\n totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );\n#endif", 6186 transmission_pars_fragment: "#ifdef USE_TRANSMISSION\n uniform float transmission;\n uniform float thickness;\n uniform float attenuationDistance;\n uniform vec3 attenuationColor;\n #ifdef USE_TRANSMISSIONMAP\n uniform sampler2D transmissionMap;\n #endif\n #ifdef USE_THICKNESSMAP\n uniform sampler2D thicknessMap;\n #endif\n uniform vec2 transmissionSamplerSize;\n uniform sampler2D transmissionSamplerMap;\n uniform mat4 modelMatrix;\n uniform mat4 projectionMatrix;\n varying vec3 vWorldPosition;\n float w0( float a ) {\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );\n }\n float w1( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );\n }\n float w2( float a ){\n return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );\n }\n float w3( float a ) {\n return ( 1.0 / 6.0 ) * ( a * a * a );\n }\n float g0( float a ) {\n return w0( a ) + w1( a );\n }\n float g1( float a ) {\n return w2( a ) + w3( a );\n }\n float h0( float a ) {\n return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );\n }\n float h1( float a ) {\n return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );\n }\n vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {\n uv = uv * texelSize.zw + 0.5;\n vec2 iuv = floor( uv );\n vec2 fuv = fract( uv );\n float g0x = g0( fuv.x );\n float g1x = g1( fuv.x );\n float h0x = h0( fuv.x );\n float h1x = h1( fuv.x );\n float h0y = h0( fuv.y );\n float h1y = h1( fuv.y );\n vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;\n vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;\n return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +\n g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );\n }\n vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {\n vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );\n vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );\n vec2 fLodSizeInv = 1.0 / fLodSize;\n vec2 cLodSizeInv = 1.0 / cLodSize;\n vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );\n vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );\n return mix( fSample, cSample, fract( lod ) );\n }\n vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {\n vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );\n vec3 modelScale;\n modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );\n modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );\n modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );\n return normalize( refractionVector ) * thickness * modelScale;\n }\n float applyIorToRoughness( const in float roughness, const in float ior ) {\n return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );\n }\n vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {\n float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );\n return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );\n }\n vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {\n if ( isinf( attenuationDistance ) ) {\n return vec3( 1.0 );\n } else {\n vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;\n vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;\n }\n }\n vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\n const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\n const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,\n const in vec3 attenuationColor, const in float attenuationDistance ) {\n vec4 transmittedLight;\n vec3 transmittance;\n #ifdef USE_DISPERSION\n float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;\n vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );\n for ( int i = 0; i < 3; i ++ ) {\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );\n transmittedLight[ i ] = transmissionSample[ i ];\n transmittedLight.a += transmissionSample.a;\n transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];\n }\n transmittedLight.a /= 3.0;\n #else\n vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );\n vec3 refractedRayExit = position + transmissionRay;\n vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );\n vec2 refractionCoords = ndcPos.xy / ndcPos.w;\n refractionCoords += 1.0;\n refractionCoords /= 2.0;\n transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );\n transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );\n #endif\n vec3 attenuatedColor = transmittance * transmittedLight.rgb;\n vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );\n float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;\n return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );\n }\n#endif", 6187 uv_pars_fragment: "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n varying vec2 vMapUv;
6187\n#endif\n#ifdef USE_ALPHAMAP\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif", 6188 uv_pars_vertex: "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n varying vec2 vUv;\n#endif\n#ifdef USE_MAP\n uniform mat3 mapTransform;\n varying vec2 vMapUv;\n#endif\n#ifdef USE_ALPHAMAP\n uniform mat3 alphaMapTransform;\n varying vec2 vAlphaMapUv;\n#endif\n#ifdef USE_LIGHTMAP\n uniform mat3 lightMapTransform;\n varying vec2 vLightMapUv;\n#endif\n#ifdef USE_AOMAP\n uniform mat3 aoMapTransform;\n varying vec2 vAoMapUv;\n#endif\n#ifdef USE_BUMPMAP\n uniform mat3 bumpMapTransform;\n varying vec2 vBumpMapUv;\n#endif\n#ifdef USE_NORMALMAP\n uniform mat3 normalMapTransform;\n varying vec2 vNormalMapUv;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n uniform mat3 displacementMapTransform;\n varying vec2 vDisplacementMapUv;\n#endif\n#ifdef USE_EMISSIVEMAP\n uniform mat3 emissiveMapTransform;\n varying vec2 vEmissiveMapUv;\n#endif\n#ifdef USE_METALNESSMAP\n uniform mat3 metalnessMapTransform;\n varying vec2 vMetalnessMapUv;\n#endif\n#ifdef USE_ROUGHNESSMAP\n uniform mat3 roughnessMapTransform;\n varying vec2 vRoughnessMapUv;\n#endif\n#ifdef USE_ANISOTROPYMAP\n uniform mat3 anisotropyMapTransform;\n varying vec2 vAnisotropyMapUv;\n#endif\n#ifdef USE_CLEARCOATMAP\n uniform mat3 clearcoatMapTransform;\n varying vec2 vClearcoatMapUv;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n uniform mat3 clearcoatNormalMapTransform;\n varying vec2 vClearcoatNormalMapUv;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n uniform mat3 clearcoatRoughnessMapTransform;\n varying vec2 vClearcoatRoughnessMapUv;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n uniform mat3 sheenColorMapTransform;\n varying vec2 vSheenColorMapUv;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n uniform mat3 sheenRoughnessMapTransform;\n varying vec2 vSheenRoughnessMapUv;\n#endif\n#ifdef USE_IRIDESCENCEMAP\n uniform mat3 iridescenceMapTransform;\n varying vec2 vIridescenceMapUv;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n uniform mat3 iridescenceThicknessMapTransform;\n varying vec2 vIridescenceThicknessMapUv;\n#endif\n#ifdef USE_SPECULARMAP\n uniform mat3 specularMapTransform;\n varying vec2 vSpecularMapUv;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n uniform mat3 specularColorMapTransform;\n varying vec2 vSpecularColorMapUv;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n uniform mat3 specularIntensityMapTransform;\n varying vec2 vSpecularIntensityMapUv;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n uniform mat3 transmissionMapTransform;\n varying vec2 vTransmissionMapUv;\n#endif\n#ifdef USE_THICKNESSMAP\n uniform mat3 thicknessMapTransform;\n varying vec2 vThicknessMapUv;\n#endif", 6189 uv_vertex: "#if defined( USE_UV ) || defined( USE_ANISOTROPY )\n vUv = vec3( uv, 1 ).xy;\n#endif\n#ifdef USE_MAP\n vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ALPHAMAP\n vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_LIGHTMAP\n vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_AOMAP\n vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_BUMPMAP\n vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_NORMALMAP\n vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_DISPLACEMENTMAP\n vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_EMISSIVEMAP\n vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_METALNESSMAP\n vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ROUGHNESSMAP\n vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_ANISOTROPYMAP\n vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOATMAP\n vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\n vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
6189\n#endif\n#ifdef USE_IRIDESCENCEMAP\n vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\n vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_COLORMAP\n vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SHEEN_ROUGHNESSMAP\n vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULARMAP\n vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_COLORMAP\n vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_SPECULAR_INTENSITYMAP\n vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_TRANSMISSIONMAP\n vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;\n#endif\n#ifdef USE_THICKNESSMAP\n vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;\n#endif", 6190 worldpos_vertex: "#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0\n vec4 worldPosition = vec4( transformed, 1.0 );\n #ifdef USE_BATCHING\n worldPosition = batchingMatrix * worldPosition;\n #endif\n #ifdef USE_INSTANCING\n worldPosition = instanceMatrix * worldPosition;\n #endif\n worldPosition = modelMatrix * worldPosition;\n#endif", 6191 background_vert: "varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n gl_Position = vec4( position.xy, 1.0, 1.0 );\n}", 6192 background_frag: "uniform sampler2D t2D;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\n vec4 texColor = texture2D( t2D, vUv );\n #ifdef DECODE_VIDEO_TEXTURE\n texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}", 6193 backgroundCube_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}", 6194 backgroundCube_frag: "#ifdef ENVMAP_TYPE_CUBE\n uniform samplerCube envMap;\n#elif defined( ENVMAP_TYPE_CUBE_UV )\n uniform sampler2D envMap;\n#endif\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nuniform mat3 backgroundRotation;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n #ifdef ENVMAP_TYPE_CUBE\n vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection );\n #elif defined( ENVMAP_TYPE_CUBE_UV )\n vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );\n #else\n vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n #endif\n texColor.rgb *= backgroundIntensity;\n gl_FragColor = texColor;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}", 6195 cube_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n gl_Position.z = gl_Position.w;\n}", 6196 cube_frag: "uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n gl_FragColor = texColor;\n gl_FragColor.a *= opacity;\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}", 6197 depth_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vHighPrecisionZW = gl_Position.zw;\n}", 6198 depth_frag: "#if DEPTH_PACKING == 3200\n uniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec2 vHighPrecisionZW;\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #if DEPTH_PACKING == 3200\n diffuseColor.a = opacity;\n #endif\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <logdepthbuf_fragment>\n #ifdef USE_REVERSED_DEPTH_BUFFER\n float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];\n #else\n float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;\n #endif\n #if DEPTH_PACKING == 3200\n gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n #elif DEPTH_PACKING == 3201\n gl_FragColor = packDepthToRGBA( fragCoordZ );\n #elif DEPTH_PACKING == 3202\n gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );\n #elif DEPTH_PACKING == 3203\n gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );\n #endif\n}", 6199 distance_vert: "#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <skinbase_vertex>\n #include <morphinstance_vertex>\n #ifdef USE_DISPLACEMENTMAP\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <worldpos_vertex>\n #include <clipping_planes_vertex>\n vWorldPosition = worldPosition.xyz;\n}", 6200 distance_frag: "#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 1.0 );\n #include <clipping_planes_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n float dist = length( vWorldPosition - referencePosition );\n dist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n dist = saturate( dist );\n gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );\n}", 6201 equirect_vert: "varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vWorldDirection = transformDirection( position, modelMatrix );\n #include <begin_vertex>\n #include <project_vertex>\n}", 6202 equirect_frag: "uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n vec3 direction = normalize( vWorldDirection );\n vec2 sampleUV = equirectUv( direction );\n gl_FragColor = texture2D( tEquirect, sampleUV );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n}", 6203 linedashed_vert: "uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n vLineDistance = scale * lineDistance;\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}", 6204 linedashed_frag: "uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n if ( mod( vLineDistance, totalSize ) > dashSize ) {\n discard;\n }\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}", 6205 meshbasic_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #endif\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <fog_vertex>\n}", 6206 meshbasic_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n varying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n #ifdef USE_LIGHTMAP\n vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );\n reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;\n #else\n reflectedLight.indirectDiffuse += vec3( 1.0 );\n #endif\n #include <aomap_fragment>\n reflectedLight.indirectDiffuse *= diffuseColor.rgb;\n vec3 outgoingLight = reflectedLight.indirectDiffuse;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}", 6207 meshlambert_vert: "#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}", 6208 meshlambert_frag: "#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_lambert_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}", 6209 meshmatcap_vert: "#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #inclu
6209de <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n vViewPosition = - mvPosition.xyz;\n}", 6210 meshmatcap_frag: "#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n #ifdef USE_MATCAP\n vec4 matcapColor = texture2D( matcap, uv );\n #else\n vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );\n #endif\n vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}", 6211 meshnormal_vert: "#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n vViewPosition = - mvPosition.xyz;\n#endif\n}", 6212 meshnormal_frag: "#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )\n varying vec3 vViewPosition;\n#endif\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );\n #include <clipping_planes_fragment>\n #include <logdepthbuf_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );\n #ifdef OPAQUE\n gl_FragColor.a = 1.0;\n #endif\n}", 6213 meshphong_vert: "#define PHONG\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <envmap_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}", 6214 meshphong_frag: "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <specularmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_phong_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n #include <envmap_fragment>\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}", 6215 meshphysical_vert: "#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\n varying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n#ifdef USE_TRANSMISSION\n vWorldPosition = worldPosition.xyz;\n#endif\n}", 6216 meshphysical_frag: "#define STANDARD\n#ifdef PHYSICAL\n #define IOR\n #define USE_SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\n uniform float ior;\n#endif\n#ifdef USE_SPECULAR\n uniform float specularIntensity;\n uniform vec3 specularColor;\n #ifdef USE_SPECULAR_COLORMAP\n uniform sampler2D specularColorMap;\n #endif\n #ifdef USE_SPECULAR_INTENSITYMAP\n uniform sampler2D specularIntensityMap;\n #endif\n#endif\n#ifdef USE_CLEARCOAT\n uniform float clearcoat;
6216\n uniform float clearcoatRoughness;\n#endif\n#ifdef USE_DISPERSION\n uniform float dispersion;\n#endif\n#ifdef USE_IRIDESCENCE\n uniform float iridescence;\n uniform float iridescenceIOR;\n uniform float iridescenceThicknessMinimum;\n uniform float iridescenceThicknessMaximum;\n#endif\n#ifdef USE_SHEEN\n uniform vec3 sheenColor;\n uniform float sheenRoughness;\n #ifdef USE_SHEEN_COLORMAP\n uniform sampler2D sheenColorMap;\n #endif\n #ifdef USE_SHEEN_ROUGHNESSMAP\n uniform sampler2D sheenRoughnessMap;\n #endif\n#endif\n#ifdef USE_ANISOTROPY\n uniform vec2 anisotropyVector;\n #ifdef USE_ANISOTROPYMAP\n uniform sampler2D anisotropyMap;\n #endif\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <roughnessmap_fragment>\n #include <metalnessmap_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <clearcoat_normal_fragment_begin>\n #include <clearcoat_normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_physical_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\n vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n #include <transmission_fragment>\n vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n #ifdef USE_SHEEN\n \n outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;\n \n #endif\n #ifdef USE_CLEARCOAT\n float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );\n vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );\n outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
vendor: 16,384 bytes, lines 6216-6610
6216\n #endif\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}", 6217 meshtoon_vert: "#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <batching_pars_vertex>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <normal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <displacementmap_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n vViewPosition = - mvPosition.xyz;\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}", 6218 meshtoon_frag: "#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n vec3 totalEmissiveRadiance = emissive;\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <color_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n #include <normal_fragment_begin>\n #include <normal_fragment_maps>\n #include <emissivemap_fragment>\n #include <lights_toon_fragment>\n #include <lights_fragment_begin>\n #include <lights_fragment_maps>\n #include <lights_fragment_end>\n #include <aomap_fragment>\n vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n #include <dithering_fragment>\n}", 6219 points_vert: "uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#ifdef USE_POINTS_UV\n varying vec2 vUv;\n uniform mat3 uvTransform;\n#endif\nvoid main() {\n #ifdef USE_POINTS_UV\n vUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n #endif\n #include <color_vertex>\n #include <morphinstance_vertex>\n #include <morphcolor_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <project_vertex>\n gl_PointSize = size;\n #ifdef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n #endif\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <worldpos_vertex>\n #include <fog_vertex>\n}", 6220 points_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_particle_fragment>\n #include <color_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}", 6221 shadow_vert: "#include <common>\n#include <batching_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n #include <batching_vertex>\n #include <beginnormal_vertex>\n #include <morphinstance_vertex>\n #include <morphnormal_vertex>\n #include <skinbase_vertex>\n #include <skinnormal_vertex>\n #include <defaultnormal_vertex>\n #include <begin_vertex>\n #include <morphtarget_vertex>\n #include <skinning_vertex>\n #include <project_vertex>\n #include <logdepthbuf_vertex>\n #include <worldpos_vertex>\n #include <shadowmap_vertex>\n #include <fog_vertex>\n}", 6222 shadow_frag: "uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <logdepthbuf_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n #include <logdepthbuf_fragment>\n gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n}", 6223 sprite_vert: "uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n #include <uv_vertex>\n vec4 mvPosition = modelViewMatrix[ 3 ];\n vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );\n #ifndef USE_SIZEATTENUATION\n bool isPerspective = isPerspectiveMatrix( projectionMatrix );\n if ( isPerspective ) scale *= - mvPosition.z;\n #endif\n vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n vec2 rotatedPosition;\n rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n mvPosition.xy += rotatedPosition;\n gl_Position = projectionMatrix * mvPosition;\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n}", 6224 sprite_frag: "uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <alphahash_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n vec4 diffuseColor = vec4( diffuse, opacity );\n #include <clipping_planes_fragment>\n vec3 outgoingLight = vec3( 0.0 );\n #include <logdepthbuf_fragment>\n #include <map_fragment>\n #include <alphamap_fragment>\n #include <alphatest_fragment>\n #include <alphahash_fragment>\n outgoingLight = diffuseColor.rgb;\n #include <opaque_fragment>\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n}" 6225}, Q = { 6226 common: { 6227 diffuse: { value: /*@__PURE__*/ new Y(16777215) }, 6228 opacity: { value: 1 }, 6229 map: { value: null }, 6230 mapTransform: { value: /*@__PURE__*/ new K() }, 6231 alphaMap: { value: null }, 6232 alphaMapTransform: { value: /*@__PURE__*/ new K() }, 6233 alphaTest: { value: 0 } 6234 }, 6235 specularmap: { 6236 specularMap: { value: null }, 6237 specularMapTransform: { value: /*@__PURE__*/ new K() } 6238 }, 6239 envmap: { 6240 envMap: { value: null }, 6241 envMapRotation: { value: /*@__PURE__*/ new K() }, 6242 reflectivity: { value: 1 }, 6243 ior: { value: 1.5 }, 6244 refractionRatio: { value: .98 }, 6245 dfgLUT: { value: null } 6246 }, 6247 aomap: { 6248 aoMap: { value: null }, 6249 aoMapIntensity: { value: 1 }, 6250 aoMapTransform: { value: /*@__PURE__*/ new K() } 6251 }, 6252 lightmap: { 6253 lightMap: { value: null }, 6254 lightMapIntensity: { value: 1 }, 6255 lightMapTransform: { value: /*@__PURE__*/ new K() } 6256 }, 6257 bumpmap: { 6258 bumpMap: { value: null }, 6259 bumpMapTransform: { value: /*@__PURE__*/ new K() }, 6260 bumpScale: { value: 1 } 6261 }, 6262 normalmap: { 6263 normalMap: { value: null }, 6264 normalMapTransform: { value: /*@__PURE__*/ new K() }, 6265 normalScale: { value: /*@__PURE__*/ new W(1, 1) } 6266 }, 6267 displacementmap: { 6268 displacementMap: { value: null }, 6269 displacementMapTransform: { value: /*@__PURE__*/ new K() }, 6270 displacementScale: { value: 1 }, 6271 displacementBias: { value: 0 } 6272 }, 6273 emissivemap: { 6274 emissiveMap: { value: null }, 6275 emissiveMapTransform: { value: /*@__PURE__*/ new K() } 6276 }, 6277 metalnessmap: { 6278 metalnessMap: { value: null }, 6279 metalnessMapTransform: { value: /*@__PURE__*/ new K() } 6280 }, 6281 roughnessmap: { 6282 roughnessMap: { value: null }, 6283 roughnessMapTransform: { value: /*@__PURE__*/ new K() } 6284 }, 6285 gradientmap: { gradientMap: { value: null } }, 6286 fog: { 6287 fogDensity: { value: 25e-5 }, 6288 fogNear: { value: 1 }, 6289 fogFar: { value: 2e3 }, 6290 fogColor: { value: /*@__PURE__*/ new Y(16777215) } 6291 }, 6292 lights: { 6293 ambientLightColor: { value: [] }, 6294 lightProbe: { value: [] }, 6295 directionalLights: { 6296 value: [], 6297 properties: { 6298 direction: {}, 6299 color: {} 6300 } 6301 }, 6302 directionalLightShadows: { 6303 value: [], 6304 properties: { 6305 shadowIntensity: 1, 6306 shadowBias: {}, 6307 shadowNormalBias: {}, 6308 shadowRadius: {}, 6309 shadowMapSize: {} 6310 } 6311 }, 6312 directionalShadowMatrix: { value: [] }, 6313 spotLights: { 6314 value: [], 6315 properties: { 6316 color: {}, 6317 position: {}, 6318 direction: {}, 6319 distance: {}, 6320 coneCos: {}, 6321 penumbraCos: {}, 6322 decay: {} 6323 } 6324 }, 6325 spotLightShadows: { 6326 value: [], 6327 properties: { 6328 shadowIntensity: 1, 6329 shadowBias: {}, 6330 shadowNormalBias: {}, 6331 shadowRadius: {}, 6332 shadowMapSize: {} 6333 } 6334 }, 6335 spotLightMap: { value: [] }, 6336 spotLightMatrix: { value: [] }, 6337 pointLights: { 6338 value: [], 6339 properties: { 6340 color: {}, 6341 position: {}, 6342 decay: {}, 6343 distance: {} 6344 } 6345 }, 6346 pointLightShadows: { 6347 value: [], 6348 properties: { 6349 shadowIntensity: 1, 6350 shadowBias: {}, 6351 shadowNormalBias: {}, 6352 shadowRadius: {}, 6353 shadowMapSize: {}, 6354 shadowCameraNear: {}, 6355 shadowCameraFar: {} 6356 } 6357 }, 6358 pointShadowMatrix: { value: [] }, 6359 hemisphereLights: { 6360 value: [], 6361 properties: { 6362 direction: {}, 6363 skyColor: {}, 6364 groundColor: {} 6365 } 6366 }, 6367 rectAreaLights: { 6368 value: [], 6369 properties: { 6370 color: {}, 6371 position: {}, 6372 width: {}, 6373 height: {} 6374 } 6375 }, 6376 ltc_1: { value: null }, 6377 ltc_2: { value: null }, 6378 probesSH: { value: null }, 6379 probesMin: { value: /*@__PURE__*/ new G() }, 6380 probesMax: { value: /*@__PURE__*/ new G() }, 6381 probesResolution: { value: /*@__PURE__*/ new G() } 6382 }, 6383 points: { 6384 diffuse: { value: /*@__PURE__*/ new Y(16777215) }, 6385 opacity: { value: 1 }, 6386 size: { value: 1 }, 6387 scale: { value: 1 }, 6388 map: { value: null }, 6389 alphaMap: { value: null }, 6390 alphaMapTransform: { value: /*@__PURE__*/ new K() }, 6391 alphaTest: { value: 0 }, 6392 uvTransform: { value: /*@__PURE__*/ new K() } 6393 }, 6394 sprite: { 6395 diffuse: { value: /*@__PURE__*/ new Y(16777215) }, 6396 opacity: { value: 1 }, 6397 center: { value: /*@__PURE__*/ new W(.5, .5) }, 6398 rotation: { value: 0 }, 6399 map: { value: null }, 6400 mapTransform: { value: /*@__PURE__*/ new K() }, 6401 alphaMap: { value: null }, 6402 alphaMapTransform: { value: /*@__PURE__*/ new K() }, 6403 alphaTest: { value: 0 } 6404 } 6405}, Po = { 6406 basic: { 6407 uniforms: /*@__PURE__*/ ya([ 6408 Q.common, 6409 Q.specularmap, 6410 Q.envmap, 6411 Q.aomap, 6412 Q.lightmap, 6413 Q.fog 6414 ]), 6415 vertexShader: Z.meshbasic_vert, 6416 fragmentShader: Z.meshbasic_frag 6417 }, 6418 lambert: { 6419 uniforms: /*@__PURE__*/ ya([ 6420 Q.common, 6421 Q.specularmap, 6422 Q.envmap, 6423 Q.aomap, 6424 Q.lightmap, 6425 Q.emissivemap, 6426 Q.bumpmap, 6427 Q.normalmap, 6428 Q.displacementmap, 6429 Q.fog, 6430 Q.lights, 6431 { 6432 emissive: { value: /*@__PURE__*/ new Y(0) }, 6433 envMapIntensity: { value: 1 } 6434 } 6435 ]), 6436 vertexShader: Z.meshlambert_vert, 6437 fragmentShader: Z.meshlambert_frag 6438 }, 6439 phong: { 6440 uniforms: /*@__PURE__*/ ya([ 6441 Q.common, 6442 Q.specularmap, 6443 Q.envmap, 6444 Q.aomap, 6445 Q.lightmap, 6446 Q.emissivemap, 6447 Q.bumpmap, 6448 Q.normalmap, 6449 Q.displacementmap, 6450 Q.fog, 6451 Q.lights, 6452 { 6453 emissive: { value: /*@__PURE__*/ new Y(0) }, 6454 specular: { value: /*@__PURE__*/ new Y(1118481) }, 6455 shininess: { value: 30 }, 6456 envMapIntensity: { value: 1 } 6457 } 6458 ]), 6459 vertexShader: Z.meshphong_vert, 6460 fragmentShader: Z.meshphong_frag 6461 }, 6462 standard: { 6463 uniforms: /*@__PURE__*/ ya([ 6464 Q.common, 6465 Q.envmap, 6466 Q.aomap, 6467 Q.lightmap, 6468 Q.emissivemap, 6469 Q.bumpmap, 6470 Q.normalmap, 6471 Q.displacementmap, 6472 Q.roughnessmap, 6473 Q.metalnessmap, 6474 Q.fog, 6475 Q.lights, 6476 { 6477 emissive: { value: /*@__PURE__*/ new Y(0) }, 6478 roughness: { value: 1 }, 6479 metalness: { value: 0 }, 6480 envMapIntensity: { value: 1 } 6481 } 6482 ]), 6483 vertexShader: Z.meshphysical_vert, 6484 fragmentShader: Z.meshphysical_frag 6485 }, 6486 toon: { 6487 uniforms: /*@__PURE__*/ ya([ 6488 Q.common, 6489 Q.aomap, 6490 Q.lightmap, 6491 Q.emissivemap, 6492 Q.bumpmap, 6493 Q.normalmap, 6494 Q.displacementmap, 6495 Q.gradientmap, 6496 Q.fog, 6497 Q.lights, 6498 { emissive: { value: /*@__PURE__*/ new Y(0) } } 6499 ]), 6500 vertexShader: Z.meshtoon_vert, 6501 fragmentShader: Z.meshtoon_frag 6502 }, 6503 matcap: { 6504 uniforms: /*@__PURE__*/ ya([ 6505 Q.common, 6506 Q.bumpmap, 6507 Q.normalmap, 6508 Q.displacementmap, 6509 Q.fog, 6510 { matcap: { value: null } } 6511 ]), 6512 vertexShader: Z.meshmatcap_vert, 6513 fragmentShader: Z.meshmatcap_frag 6514 }, 6515 points: { 6516 uniforms: /*@__PURE__*/ ya([Q.points, Q.fog]), 6517 vertexShader: Z.points_vert, 6518 fragmentShader: Z.points_frag 6519 }, 6520 dashed: { 6521 uniforms: /*@__PURE__*/ ya([ 6522 Q.common, 6523 Q.fog, 6524 { 6525 scale: { value: 1 }, 6526 dashSize: { value: 1 }, 6527 totalSize: { value: 2 } 6528 } 6529 ]), 6530 vertexShader: Z.linedashed_vert, 6531 fragmentShader: Z.linedashed_frag 6532 }, 6533 depth: { 6534 uniforms: /*@__PURE__*/ ya([Q.common, Q.displacementmap]), 6535 vertexShader: Z.depth_vert, 6536 fragmentShader: Z.depth_frag 6537 }, 6538 normal: { 6539 uniforms: /*@__PURE__*/ ya([ 6540 Q.common, 6541 Q.bumpmap, 6542 Q.normalmap, 6543 Q.displacementmap, 6544 { opacity: { value: 1 } } 6545 ]), 6546 vertexShader: Z.meshnormal_vert, 6547 fragmentShader: Z.meshnormal_frag 6548 }, 6549 sprite: { 6550 uniforms: /*@__PURE__*/ ya([Q.sprite, Q.fog]), 6551 vertexShader: Z.sprite_vert, 6552 fragmentShader: Z.sprite_frag 6553 }, 6554 background: { 6555 uniforms: { 6556 uvTransform: { value: /*@__PURE__*/ new K() }, 6557 t2D: { value: null }, 6558 backgroundIntensity: { value: 1 } 6559 }, 6560 vertexShader: Z.background_vert, 6561 fragmentShader: Z.background_frag 6562 }, 6563 backgroundCube: { 6564 uniforms: { 6565 envMap: { value: null }, 6566 backgroundBlurriness: { value: 0 }, 6567 backgroundIntensity: { value: 1 }, 6568 backgroundRotation: { value: /*@__PURE__*/ new K() } 6569 }, 6570 vertexShader: Z.backgroundCube_vert, 6571 fragmentShader: Z.backgroundCube_frag 6572 }, 6573 cube: { 6574 uniforms: { 6575 tCube: { value: null }, 6576 tFlip: { value: -1 }, 6577 opacity: { value: 1 } 6578 }, 6579 vertexShader: Z.cube_vert, 6580 fragmentShader: Z.cube_frag 6581 }, 6582 equirect: { 6583 uniforms: { tEquirect: { value: null } }, 6584 vertexShader: Z.equirect_vert, 6585 fragmentShader: Z.equirect_frag 6586 }, 6587 distance: { 6588 uniforms: /*@__PURE__*/ ya([ 6589 Q.common, 6590 Q.displacementmap, 6591 { 6592 referencePosition: { value: /*@__PURE__*/ new G() }, 6593 nearDistance: { value: 1 }, 6594 farDistance: { value: 1e3 } 6595 } 6596 ]), 6597 vertexShader: Z.distance_vert, 6598 fragmentShader: Z.distance_frag 6599 }, 6600 shadow: { 6601 uniforms: /*@__PURE__*/ ya([ 6602 Q.lights, 6603 Q.fog, 6604 { 6605 color: { value: /*@__PURE__*/ new Y(0) }, 6606 opacity: { value: 1 } 6607 } 6608 ]), 6609 vertexShader: Z.shadow_vert, 6610 fragment
6610Shader: Z.shadow_frag 6611 } 6612}; 6613Po.physical = { 6614 uniforms: /*@__PURE__*/ ya([Po.standard.uniforms, { 6615 clearcoat: { value: 0 }, 6616 clearcoatMap: { value: null }, 6617 clearcoatMapTransform: { value: /*@__PURE__*/ new K() }, 6618 clearcoatNormalMap: { value: null }, 6619 clearcoatNormalMapTransform: { value: /*@__PURE__*/ new K() }, 6620 clearcoatNormalScale: { value: /*@__PURE__*/ new W(1, 1) }, 6621 clearcoatRoughness: { value: 0 }, 6622 clearcoatRoughnessMap: { value: null }, 6623 clearcoatRoughnessMapTransform: { value: /*@__PURE__*/ new K() }, 6624 dispersion: { value: 0 }, 6625 iridescence: { value: 0 }, 6626 iridescenceMap: { value: null }, 6627 iridescenceMapTransform: { value: /*@__PURE__*/ new K() }, 6628 iridescenceIOR: { value: 1.3 }, 6629 iridescenceThicknessMinimum: { value: 100 }, 6630 iridescenceThicknessMaximum: { value: 400 }, 6631 iridescenceThicknessMap: { value: null }, 6632 iridescenceThicknessMapTransform: { value: /*@__PURE__*/ new K() }, 6633 sheen: { value: 0 }, 6634 sheenColor: { value: /*@__PURE__*/ new Y(0) }, 6635 sheenColorMap: { value: null }, 6636 sheenColorMapTransform: { value: /*@__PURE__*/ new K() }, 6637 sheenRoughness: { value: 1 }, 6638 sheenRoughnessMap: { value: null }, 6639 sheenRoughnessMapTransform: { value: /*@__PURE__*/ new K() }, 6640 transmission: { value: 0 }, 6641 transmissionMap: { value: null }, 6642 transmissionMapTransform: { value: /*@__PURE__*/ new K() }, 6643 transmissionSamplerSize: { value: /*@__PURE__*/ new W() }, 6644 transmissionSamplerMap: { value: null }, 6645 thickness: { value: 0 }, 6646 thicknessMap: { value: null }, 6647 thicknessMapTransform: { value: /*@__PURE__*/ new K() }, 6648 attenuationDistance: { value: 0 }, 6649 attenuationColor: { value: /*@__PURE__*/ new Y(0) }, 6650 specularColor: { value: /*@__PURE__*/ new Y(1, 1, 1) }, 6651 specularColorMap: { value: null }, 6652 specularColorMapTransform: { value: /*@__PURE__*/ new K() }, 6653 specularIntensity: { value: 1 }, 6654 specularIntensityMap: { value: null }, 6655 specularIntensityMapTransform: { value: /*@__PURE__*/ new K() }, 6656 anisotropyVector: { value: /*@__PURE__*/ new W() }, 6657 anisotropyMap: { value: null }, 6658 anisotropyMapTransform: { value: /*@__PURE__*/ new K() } 6659 }]), 6660 vertexShader: Z.meshphysical_vert, 6661 fragmentShader: Z.meshphysical_frag 6662}; 6663var Fo = { 6664 r: 0, 6665 b: 0, 6666 g: 0 6667}, Io = /*@__PURE__*/ new jn(), Lo = /*@__PURE__*/ new K(); 6668Lo.set(-1, 0, 0, 0, 1, 0, 0, 0, 1); 6669function Ro(e, t, n, r, i, a) { 6670 let o = new Y(0), s = i === !0 ? 0 : 1, c, l, u = null, d = 0, f = null; 6671 function p(e) { 6672 let n = e.isScene === !0 ? e.background : null; 6673 if (n && n.isTexture) { 6674 let r = e.backgroundBlurriness > 0; 6675 n = t.get(n, r); 6676 } 6677 return n; 6678 } 6679 function m(t) { 6680 let r = !1, i = p(t); 6681 i === null ? g(o, s) : i && i.isColor && (g(i, 1), r = !0); 6682 let c = e.xr.getEnvironmentBlendMode(); 6683 c === "additive" ? n.buffers.color.setClear(0, 0, 0, 1, a) : c === "alpha-blend" && n.buffers.color.setClear(0, 0, 0, 0, a), (e.autoClear || r) && (n.buffers.depth.setTest(!0), n.buffers.depth.setMask(!0), n.buffers.color.setMask(!0), e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil)); 6684 } 6685 function h(t, n) { 6686 let i = p(n); 6687 i && (i.isCubeTexture || i.mapping === 306) ? (l === void 0 && (l = new Mi(new ma(1, 1, 1), new Ea({ 6688 name: "BackgroundCubeMaterial", 6689 uniforms: va(Po.backgroundCube.uniforms), 6690 vertexShader: Po.backgroundCube.vertexShader, 6691 fragmentShader: Po.backgroundCube.fragmentShader, 6692 side: 1, 6693 depthTest: !1, 6694 depthWrite: !1, 6695 fog: !1, 6696 allowOverride: !1 6697 })), l.geometry.deleteAttribute("normal"), l.geometry.deleteAttribute("uv"), l.onBeforeRender = function(e, t, n) { 6698 this.matrixWorld.copyPosition(n.matrixWorld); 6699 }, Object.defineProperty(l.material, "envMap", { get: function() { 6700 return this.uniforms.envMap.value; 6701 } }), r.update(l)), l.material.uniforms.envMap.value = i, l.material.uniforms.backgroundBlurriness.value = n.backgroundBlurriness, l.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, l.material.uniforms.backgroundRotation.value.setFromMatrix4(Io.makeRotationFromEuler(n.backgroundRotation)).transpose(), i.isCubeTexture && i.isRenderTargetTexture === !1 && l.material.uniforms.backgroundRotation.value.premultiply(Lo), l.material.toneMapped = q.getTransfer(i.colorSpace) !== Ct, (u !== i || d !== i.version || f !== e.toneMapping) && (l.material.needsUpdate = !0, u = i, d = i.version, f = e.toneMapping), l.layers.enableAll(), t.unshift(l, l.geometry, l.material, 0, 0, null)) : i && i.isTexture && (c === void 0 && (c = new Mi(new ha(2, 2), new Ea({
6702 name: "BackgroundMaterial", 6703 uniforms: va(Po.background.uniforms), 6704 vertexShader: Po.background.vertexShader, 6705 fragmentShader: Po.background.fragmentShader, 6706 side: 0, 6707 depthTest: !1, 6708 depthWrite: !1, 6709 fog: !1, 6710 allowOverride: !1 6711 })), c.geometry.deleteAttribute("normal"), Object.defineProperty(c.material, "map", { get: function() { 6712 return this.uniforms.t2D.value; 6713 } }), r.update(c)), c.material.uniforms.t2D.value = i, c.material.uniforms.backgroundIntensity.value = n.backgroundIntensity, c.material.toneMapped = q.getTransfer(i.colorSpace) !== Ct, i.matrixAutoUpdate === !0 && i.updateMatrix(), c.material.uniforms.uvTransform.value.copy(i.matrix), (u !== i || d !== i.version || f !== e.toneMapping) && (c.material.needsUpdate = !0, u = i, d = i.version, f = e.toneMapping), c.layers.enableAll(), t.unshift(c, c.geometry, c.material, 0, 0, null)); 6714 } 6715 function g(t, r) { 6716 t.getRGB(Fo, Sa(e)), n.buffers.color.setClear(Fo.r, Fo.g, Fo.b, r, a); 6717 } 6718 function _() { 6719 l !== void 0 && (l.geometry.dispose(), l.material.dispose(), l = void 0), c !== void 0 && (c.geometry.dispose(), c.material.dispose(), c = void 0); 6720 } 6721 return { 6722 getClearColor: function() { 6723 return o; 6724 }, 6725 setClearColor: function(e, t = 1) { 6726 o.set(e), s = t, g(o, s); 6727 }, 6728 getClearAlpha: function() { 6729 return s; 6730 }, 6731 setClearAlpha: function(e) { 6732 s = e, g(o, s); 6733 }, 6734 render: m, 6735 addToRenderList: h, 6736 dispose: _ 6737 }; 6738} 6739function zo(e, t) { 6740 let n = e.getParameter(e.MAX_VERTEX_ATTRIBS), r = {}, i = f(null), a = i, o = !1; 6741 function s(n, r, i, s, c) { 6742 let u = !1, f = d(n, s, i, r); 6743 a !== f && (a = f, l(a.object)), u = p(n, s, i, c), u && m(n, s, i, c), c !== null && t.update(c, e.ELEMENT_ARRAY_BUFFER), (u || o) && (o = !1, b(n, r, i, s), c !== null && e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, t.get(c).buffer)); 6744 } 6745 function c() { 6746 return e.createVertexArray(); 6747 } 6748 function l(t) { 6749 return e.bindVertexArray(t); 6750 } 6751 function u(t) { 6752 return e.deleteVertexArray(t); 6753 } 6754 function d(e, t, n, i) { 6755 let a = i.wireframe === !0, o = r[t.id]; 6756 o === void 0 && (o = {}, r[t.id] = o); 6757 let s = e.isInstancedMesh === !0 ? e.id : 0, l = o[s]; 6758 l === void 0 && (l = {}, o[s] = l); 6759 let u = l[n.id]; 6760 u === void 0 && (u = {}, l[n.id] = u); 6761 let d = u[a]; 6762 return d === void 0 && (d = f(c()), u[a] = d), d; 6763 } 6764 function f(e) { 6765 let t = [], r = [], i = []; 6766 for (let e = 0; e < n; e++) t[e] = 0, r[e] = 0, i[e] = 0; 6767 return { 6768 geometry: null, 6769 program: null, 6770 wireframe: !1, 6771 newAttributes: t, 6772 enabledAttributes: r, 6773 attributeDivisors: i, 6774 object: e, 6775 attributes: {}, 6776 index: null 6777 }; 6778 } 6779 function p(e, t, n, r) { 6780 let i = a.attributes, o = t.attributes, s = 0, c = n.getAttributes(); 6781 for (let t in c) if (c[t].location >= 0) { 6782 let n = i[t], r = o[t]; 6783 if (r === void 0 && (t === "instanceMatrix" && e.instanceMatrix && (r = e.instanceMatrix), t === "instanceColor" && e.instanceColor && (r = e.instanceColor)), n === void 0 || n.attribute !== r || r && n.data !== r.data) return !0; 6784 s++; 6785 } 6786 return a.attributesNum !== s || a.index !== r; 6787 } 6788 function m(e, t, n, r) { 6789 let i = {}, o = t.attributes, s = 0, c = n.getAttributes(); 6790 for (let t in c) if (c[t].location >= 0) { 6791 let n = o[t]; 6792 n === void 0 && (t === "instanceMatrix" && e.instanceMatrix && (n = e.instanceMatrix), t === "instanceColor" && e.instanceColor && (n = e.instanceColor)); 6793 let r = {}; 6794 r.attribute = n, n && n.data && (r.data = n.data), i[t] = r, s++; 6795 } 6796 a.attributes = i, a.attributesNum = s, a.index = r; 6797 } 6798 function h() { 6799 let e = a.newAttributes; 6800 for (let t = 0, n = e.length; t < n; t++) e[t] = 0; 6801 } 6802 function g(e) { 6803 _(e, 0); 6804 } 6805 function _(t, n) { 6806 let r = a.newAttributes, i = a.enabledAttributes, o = a.attributeDivisors; 6807 r[t] = 1, i[t] === 0 && (e.enableVertexAttribArray(t), i[t] = 1), o[t] !== n && (e.vertexAttribDivisor(t, n), o[t] = n); 6808 } 6809 function v() { 6810 let t = a.newAttributes, n = a.enabledAttributes; 6811 for (let r = 0, i = n.length; r < i; r++) n[r] !== t[r] && (e.disableVertexAttribArray(r), n[r] = 0); 6812 } 6813 function y(t, n, r, i, a, o, s) { 6814 s === !0 ? e.vertexAttribIPointer(t, n, r, a, o) : e.vertexAttribPointer(t, n, r, i, a, o); 6815 } 6816 function b(n, r, i, a) { 6817 h(); 6818 let o = a.attributes, s = i.getAttributes(), c = r.defaultAttributeValues; 6819 for (let r in s) { 6820 let i = s[r]; 6821 if (i.location >= 0) { 6822 let s = o[r]; 6823 if (s === void 0 && (r === "instanceMatrix" && n.instanceMatrix && (s = n.instanceMatrix), r === "instanceColor" && n.instanceColor && (s = n.instanceColor)), s !== void 0) { 6824 let r = s.normalized, o = s.itemSize, c = t.get(s); 6825 if (c === void 0) continue; 6826 let l = c.buffer, u = c.type, d = c.bytesPerElement, f = u === e.INT || u === e.UNSIGNED_INT || s.gpuType === 1013; 6827 if (s.isInterleavedBufferAttribute) { 6828 let t = s.data, c = t.stride, p = s.offset; 6829 if (t.isInstancedInterleavedBuffer) { 6830 for (let e = 0; e < i.locationSize; e++) _(i.location + e, t.meshPerAttribute); 6831 n.isInstancedMesh !== !0 && a._maxInstanceCount === void 0 && (a._maxInstanceCount = t.meshPerAttribute * t.count); 6832 } else for (let e = 0; e < i.locationSize; e++) g(i.location + e); 6833 e.bindBuffer(e.ARRAY_BUFFER, l); 6834 for (let e = 0; e < i.locationSize; e++) y(i.location + e, o / i.locationSize, u, r, c * d, (p + o / i.locationSize * e) * d, f); 6835 } else { 6836 if (s.isInstancedBufferAttribute) { 6837 for (let e = 0; e < i.locationSize; e++) _(i.location + e, s.meshPerAttribute); 6838 n.isInstancedMesh !== !0 && a._maxInstanceCount === void 0 && (a._maxInstanceCount = s.meshPerAttribute * s.count); 6839 } else for (let e = 0; e < i.locationSize; e++) g(i.location + e); 6840 e.bindBuffer(e.ARRAY_BUFFER, l); 6841 for (let e = 0; e < i.locationSize; e++) y(i.location + e, o / i.locationSize, u, r, o * d, o / i.locationSize * e * d, f); 6842 } 6843 } else if (c !== void 0) { 6844 let t = c[r]; 6845 if (t !== void 0) switch (t.length) { 6846 case 2: 6847 e.vertexAttrib2fv(i.location, t); 6848 break; 6849 case 3: 6850 e.vertexAttrib3fv(i.location, t); 6851 break; 6852 case 4: 6853 e.vertexAttrib4fv(i.location, t); 6854 break; 6855 default: e.vertexAttrib1fv(i.location, t); 6856 } 6857 } 6858 } 6859 } 6860 v(); 6861 } 6862 function x() { 6863 T(); 6864 for (let e in r) { 6865 let t = r[e]; 6866 for (let e in t) { 6867 let n = t[e]; 6868 for (let e in n) { 6869 let t = n[e]; 6870 for (let e in t) u(t[e].object), delete t[e]; 6871 delete n[e]; 6872 } 6873 } 6874 delete r[e]; 6875 } 6876 } 6877 function S(e) { 6878 if (r[e.id] === void 0) return; 6879 let t = r[e.id]; 6880 for (let e in t) { 6881 let n = t[e]; 6882 for (let e in n) { 6883 let t = n[e]; 6884 for (let e in t) u(t[e].object), delete t[e]; 6885 delete n[e]; 6886 } 6887 } 6888 delete r[e.id]; 6889 } 6890 function C(e) { 6891 for (let t in r) { 6892 let n = r[t]; 6893 for (let t in n) { 6894 let r = n[t]; 6895 if (r[e.id] === void 0) continue; 6896 let i = r[e.id]; 6897 for (let e in i) u(i[e].object), delete i[e]; 6898 delete r[e.id]; 6899 } 6900 } 6901 } 6902 function w(e) { 6903 for (let t in r) { 6904 let n = r[t], i = e.isInstancedMesh === !0 ? e.id : 0, a = n[i]; 6905 if (a !== void 0) { 6906 for (let e in a) { 6907 let t = a[e]; 6908 for (let e in t) u(t[e].object), delete t[e]; 6909 delete a[e]; 6910 } 6911 delete n[i], Object.keys(n).length === 0 && delete r[t]; 6912 } 6913 } 6914 } 6915 function T() { 6916 E(), o = !0, a !== i && (a = i, l(a.object)); 6917 } 6918 function E() { 6919 i.geometry = null, i.program = null, i.wireframe = !1; 6920 } 6921 return { 6922 setup: s, 6923 reset: T, 6924 resetDefaultState: E, 6925 dispose: x, 6926 releaseStatesOfGeometry: S, 6927 releaseStatesOfObject: w, 6928 releaseStatesOfProgram: C, 6929 initAttributes: h, 6930 enableAttribute: g, 6931 disableUnusedAttributes: v 6932 }; 6933} 6934function Bo(e, t, n) { 6935 let r; 6936 function i(e) { 6937 r = e; 6938 } 6939 function a(t, i) { 6940 e.drawArrays(r, t, i), n.update(i, r, 1); 6941 } 6942 function o(t, i, a) { 6943 a !== 0 && (e.drawArraysInstanced(r, t, i, a), n.update(i, r, a)); 6944 } 6945 function s(e, i, a) { 6946 if (a === 0) return; 6947 t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r, e, 0, i, 0, a); 6948 let o = 0; 6949 for (let e = 0; e < a; e++) o += i[e]; 6950 n.update(o, r, 1); 6951 } 6952 this.setMode = i, this.render = a, this.renderInstances = o, this.renderMultiDraw = s; 6953} 6954function Vo(e, t, n, r) { 6955 let i; 6956 function a() { 6957 if (i !== void 0) return i; 6958 if (t.has("EXT_texture_filter_anisotropic") === !0) { 6959 let n = t.get("EXT_texture_filter_anisotropic"); 6960 i = e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT); 6961 } else i = 0; 6962 return i; 6963 } 6964 function o(t) { 6965 return !(t !== 1023 && r.convert(t) !== e.getParameter(e.IMPLEMENTATION_COLOR_READ_FORMAT)); 6966 } 6967 function s(n) { 6968 let i = n === 1016 && (t.has("EXT_color_buffer_half_float") || t.has("EXT_color_buffer_float")); 6969 return !(n !== 1009 && r.convert(n) !== e.getParameter(e.IMPLEMENTATION_COLOR_READ_TYPE) && n !== 1015 && !i); 6970 } 6971 function c(t) { 6972 if (t === "highp") { 6973 if (e.getShaderPrecisionFormat(e.VERTEX_SHADER, e.HIGH_FLOAT).precision > 0 && e.getShaderPrecisionFormat(e.FRAGMENT_SHADER, e.HIGH_FLOAT).precision > 0) return "highp"; 6974 t = "mediump"; 6975 } 6976 return t === "mediump" && e.getShaderPrecisionFormat(e.VERTEX_SHADER, e.MEDIUM_FLOAT).precision > 0 && e.getShaderPrecisionFormat(e.FRAGMENT_SHADER, e.MEDIUM_FLOAT).precision > 0 ? "mediump" : "lowp"; 6977 } 6978 let l = n.precision === void 0 ? "highp" : n.precision, u = c(l); 6979 u !== l && (B("WebGLRenderer:", l, "not supported, using", u, "instead."), l = u); 6980 let d = n.logarithmicDepthBuffer === !0, f = n.reversedDepthBuffer === !0 && t.has("EXT_clip_control"); 6981 n.reversedDepthBuffer === !0 && f === !1 && B("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer."); 6982 let p = e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS), m = e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS), h = e.getParameter(e.MAX_TEXTURE_SIZE), g = e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE), _ = e.getParameter(e.MAX_VERTEX_ATTRIBS), v = e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS), y = e.getParameter(e.MAX_VARYING_VECTORS), b = e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS), x = e.getParameter(e.MAX_SAMPLES), S = e.getParameter(e.SAMPLES); 6983 return {
6984 isWebGL2: !0, 6985 getMaxAnisotropy: a, 6986 getMaxPrecision: c, 6987 textureFormatReadable: o, 6988 textureTypeReadable: s, 6989 precision: l, 6990 logarithmicDepthBuffer: d, 6991 reversedDepthBuffer: f, 6992 maxTextures: p, 6993 maxVertexTextures: m, 6994 maxTextureSize: h, 6995 maxCubemapSize: g, 6996 maxAttributes: _, 6997 maxVertexUniforms: v, 6998 maxVaryings: y, 6999 maxFragmentUniforms: b, 7000 maxSamples: x, 7001 samples: S 7002 }; 7003} 7004function Ho(e) { 7005 let t = this, n = null, r = 0, i = !1, a = !1, o = new zi(), s = new K(), c = { 7006 value: null, 7007 needsUpdate: !1 7008 }; 7009 this.uniform = c, this.numPlanes = 0, this.numIntersection = 0, this.init = function(e, t) { 7010 let n = e.length !== 0 || t || r !== 0 || i; 7011 return i = t, r = e.length, n; 7012 }, this.beginShadows = function() { 7013 a = !0, u(null); 7014 }, this.endShadows = function() { 7015 a = !1; 7016 }, this.setGlobalState = function(e, t) { 7017 n = u(e, t, 0); 7018 }, this.setState = function(t, o, s) { 7019 let d = t.clippingPlanes, f = t.clipIntersection, p = t.clipShadows, m = e.get(t); 7020 if (!i || d === null || d.length === 0 || a && !p) a ? u(null) : l(); 7021 else { 7022 let e = a ? 0 : r, t = e * 4, i = m.clippingState || null; 7023 c.value = i, i = u(d, o, t, s); 7024 for (let e = 0; e !== t; ++e) i[e] = n[e]; 7025 m.clippingState = i, this.numIntersection = f ? this.numPlanes : 0, this.numPlanes += e; 7026 } 7027 }; 7028 function l() { 7029 c.value !== n && (c.value = n, c.needsUpdate = r > 0), t.numPlanes = r, t.numIntersection = 0; 7030 } 7031 function u(e, n, r, i) { 7032 let a = e === null ? 0 : e.length, l = null; 7033 if (a !== 0) { 7034 if (l = c.value, i !== !0 || l === null) { 7035 let t = r + a * 4, i = n.matrixWorldInverse; 7036 s.getNormalMatrix(i), (l === null || l.length < t) && (l = new Float32Array(t)); 7037 for (let t = 0, n = r; t !== a; ++t, n += 4) o.copy(e[t]).applyMatrix4(i, s), o.normal.toArray(l, n), l[n + 3] = o.constant; 7038 } 7039 c.value = l, c.needsUpdate = !0; 7040 } 7041 return t.numPlanes = a, t.numIntersection = 0, l; 7042 } 7043} 7044var Uo = 4, Wo = [ 7045 .125, 7046 .215, 7047 .35, 7048 .446, 7049 .526, 7050 .582 7051], Go = 20, Ko = 256, qo = /*@__PURE__*/ new eo(), Jo = /*@__PURE__*/ new Y(), Yo = null, Xo = 0, Zo = 0, Qo = !1, $o = /*@__PURE__*/ new G(), es = class { 7052 constructor(e) { 7053 this._renderer = e, this._pingPongRenderTarget = null, this._lodMax = 0, this._cubeSize = 0, this._sizeLods = [], this._sigmas = [], this._lodMeshes = [], this._backgroundBox = null, this._cubemapMaterial = null, this._equirectMaterial = null, this._blurMaterial = null, this._ggxMaterial = null; 7054 } 7055 fromScene(e, t = 0, n = .1, r = 100, i = {}) { 7056 let { size: a = 256, position: o = $o } = i; 7057 Yo = this._renderer.getRenderTarget(), Xo = this._renderer.getActiveCubeFace(), Zo = this._renderer.getActiveMipmapLevel(), Qo = this._renderer.xr.enabled, this._renderer.xr.enabled = !1, this._setSize(a); 7058 let s = this._allocateTargets(); 7059 return s.depthBuffer = !0, this._sceneToCubeUV(e, n, r, s, o), t > 0 && this._blur(s, 0, 0, t), this._applyPMREM(s), this._cleanup(s), s; 7060 } 7061 fromEquirectangular(e, t = null) { 7062 return this._fromTexture(e, t); 7063 } 7064 fromCubemap(e, t = null) { 7065 return this._fromTexture(e, t); 7066 } 7067 compileCubemapShader() { 7068 this._cubemapMaterial === null && (this._cubemapMaterial = ss(), this._compileMaterial(this._cubemapMaterial)); 7069 } 7070 compileEquirectangularShader() { 7071 this._equirectMaterial === null && (this._equirectMaterial = os(), this._compileMaterial(this._equirectMaterial)); 7072 } 7073 dispose() { 7074 this._dispose(), this._cubemapMaterial !== null && this._cubemapMaterial.dispose(), this._equirectMaterial !== null && this._equirectMaterial.dispose(), this._backgroundBox !== null && (this._backgroundBox.geometry.dispose(), this._backgroundBox.material.dispose()); 7075 } 7076 _setSize(e) { 7077 this._lodMax = Math.floor(Math.log2(e)), this._cubeSize = 2 ** this._lodMax; 7078 } 7079 _dispose() { 7080 this._blurMaterial !== null && this._blurMaterial.dispose(), this._ggxMaterial !== null && this._ggxMaterial.dispose(), this._pingPongRenderTarget !== null && this._pingPongRenderTarget.dispose(); 7081 for (let e = 0; e < this._lodMeshes.length; e++) this._lodMeshes[e].geometry.dispose(); 7082 } 7083 _cleanup(e) { 7084 this._renderer.setRenderTarget(Yo, Xo, Zo), this._renderer.xr.enabled = Qo, e.scissorTest = !1, rs(e, 0, 0, e.width, e.height); 7085 } 7086 _fromTexture(e, t) { 7087 e.mapping === 301 || e.mapping === 302 ? this._setSize(e.image.length === 0 ? 16 : e.image[0].width || e.image[0].image.width) : this._setSize(e.image.width / 4), Yo = this._renderer.getRenderTarget(), Xo = this._renderer.getActiveCubeFace(), Zo = this._renderer.getActiveMipmapLevel(), Qo = this._renderer.xr.enabled, this._renderer.xr.enabled = !1; 7088 let n = t || this._allocateTargets(); 7089 return this._textureToCubeUV(e, n), this._applyPMREM(n), this._cleanup(n), n; 7090 } 7091 _allocateTargets() { 7092 let e = 3 * Math.max(this._cubeSize, 112), t = 4 * this._cubeSize, n = { 7093 magFilter: P, 7094 minFilter: P, 7095 generateMipmaps: !1, 7096 type: ye, 7097 format: De, 7098 colorSpace: xt, 7099 depthBuffer: !1 7100 }, r = ns(e, t, n); 7101 if (this._pingPongRenderTarget === null || this._pingPongRenderTarget.width !== e || this._pingPongRenderTarget.height !== t) { 7102 this._pingPongRenderTarget !== null && this._dispose(), this._pingPongRenderTarget = ns(e, t, n); 7103 let { _lodMax: r } = this; 7104 ({lodMeshes: this._lodMeshes, sizeLods: this._sizeLods, sigmas: this._sigmas} = ts(r)), this._blurMaterial = as(r, e, t), this._ggxMaterial = is(r, e, t); 7105 } 7106 return r; 7107 } 7108 _compileMaterial(e) { 7109 let t = new Mi(new oi(), e); 7110 this._renderer.compile(t, qo); 7111 } 7112 _sceneToCubeUV(e, t, n, r, i) { 7113 let a = new $a(90, 1, t, n), o = [ 7114 1, 7115 -1, 7116 1, 7117 1, 7118 1, 7119 1 7120 ], s = [ 7121 1, 7122 1, 7123 1, 7124 -1, 7125 -1, 7126 -1 7127 ], c = this._renderer, l = c.autoClear, u = c.toneMapping; 7128 c.getClearColor(Jo), c.toneMapping = 0, c.autoClear = !1, c.state.buffers.depth.getReversed() && (c.setRenderTarget(r), c.clearDepth(), c.setRenderTarget(null)), this._backgroundBox === null && (this._backgroundBox = new Mi(new ma(), new bi({
vendor: 4,510 bytes, lines 7129-7245
7129 name: "PMREM.Background", 7130 side: 1, 7131 depthWrite: !1, 7132 depthTest: !1 7133 }))); 7134 let d = this._backgroundBox, f = d.material, p = !1, m = e.background; 7135 m ? m.isColor && (f.color.copy(m), e.background = null, p = !0) : (f.color.copy(Jo), p = !0); 7136 for (let t = 0; t < 6; t++) { 7137 let n = t % 3; 7138 n === 0 ? (a.up.set(0, o[t], 0), a.position.set(i.x, i.y, i.z), a.lookAt(i.x + s[t], i.y, i.z)) : n === 1 ? (a.up.set(0, 0, o[t]), a.position.set(i.x, i.y, i.z), a.lookAt(i.x, i.y + s[t], i.z)) : (a.up.set(0, o[t], 0), a.position.set(i.x, i.y, i.z), a.lookAt(i.x, i.y, i.z + s[t])); 7139 let l = this._cubeSize; 7140 rs(r, n * l, t > 2 ? l : 0, l, l), c.setRenderTarget(r), p && c.render(d, a), c.render(e, a); 7141 } 7142 c.toneMapping = u, c.autoClear = l, e.background = m; 7143 } 7144 _textureToCubeUV(e, t) { 7145 let n = this._renderer, r = e.mapping === 301 || e.mapping === 302; 7146 r ? (this._cubemapMaterial === null && (this._cubemapMaterial = ss()), this._cubemapMaterial.uniforms.flipEnvMap.value = e.isRenderTargetTexture === !1 ? -1 : 1) : this._equirectMaterial === null && (this._equirectMaterial = os()); 7147 let i = r ? this._cubemapMaterial : this._equirectMaterial, a = this._lodMeshes[0]; 7148 a.material = i; 7149 let o = i.uniforms; 7150 o.envMap.value = e; 7151 let s = this._cubeSize; 7152 rs(t, 0, 0, 3 * s, 2 * s), n.setRenderTarget(t), n.render(a, qo); 7153 } 7154 _applyPMREM(e) { 7155 let t = this._renderer, n = t.autoClear; 7156 t.autoClear = !1; 7157 let r = this._lodMeshes.length; 7158 for (let t = 1; t < r; t++) this._applyGGXFilter(e, t - 1, t); 7159 t.autoClear = n; 7160 } 7161 _applyGGXFilter(e, t, n) { 7162 let r = this._renderer, i = this._pingPongRenderTarget, a = this._ggxMaterial, o = this._lodMeshes[n]; 7163 o.material = a; 7164 let s = a.uniforms, c = n / (this._lodMeshes.length - 1), l = t / (this._lodMeshes.length - 1), u = Math.sqrt(c * c - l * l) * (0 + c * 1.25), { _lodMax: d } = this, f = this._sizeLods[n], p = 3 * f * (n > d - Uo ? n - d + Uo : 0), m = 4 * (this._cubeSize - f); 7165 s.envMap.value = e.texture, s.roughness.value = u, s.mipInt.value = d - t, rs(i, p, m, 3 * f, 2 * f), r.setRenderTarget(i), r.render(o, qo), s.envMap.value = i.texture, s.roughness.value = 0, s.mipInt.value = d - n, rs(e, p, m, 3 * f, 2 * f), r.setRenderTarget(e), r.render(o, qo); 7166 } 7167 _blur(e, t, n, r, i) { 7168 let a = this._pingPongRenderTarget; 7169 this._halfBlur(e, a, t, n, r, "latitudinal", i), this._halfBlur(a, e, n, n, r, "longitudinal", i); 7170 } 7171 _halfBlur(e, t, n, r, i, a, o) { 7172 let s = this._renderer, c = this._blurMaterial; 7173 a !== "latitudinal" && a !== "longitudinal" && V("blur direction must be either latitudinal or longitudinal!"); 7174 let l = this._lodMeshes[r]; 7175 l.material = c; 7176 let u = c.uniforms, d = this._sizeLods[n] - 1, f = isFinite(i) ? Math.PI / (2 * d) : 2 * Math.PI / (2 * Go - 1), p = i / f, m = isFinite(i) ? 1 + Math.floor(3 * p) : Go; 7177 m > Go && B(`sigmaRadians, ${i}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Go}`); 7178 let h = [], g = 0; 7179 for (let e = 0; e < Go; ++e) { 7180 let t = e / p, n = Math.exp(-t * t / 2); 7181 h.push(n), e === 0 ? g += n : e < m && (g += 2 * n); 7182 } 7183 for (let e = 0; e < h.length; e++) h[e] = h[e] / g; 7184 u.envMap.value = e.texture, u.samples.value = m, u.weights.value = h, u.latitudinal.value = a === "latitudinal", o && (u.poleAxis.value = o); 7185 let { _lodMax: _ } = this; 7186 u.dTheta.value = f, u.mipInt.value = _ - n; 7187 let v = this._sizeLods[r]; 7188 rs(t, 3 * v * (r > _ - Uo ? r - _ + Uo : 0), 4 * (this._cubeSize - v), 3 * v, 2 * v), s.setRenderTarget(t), s.render(l, qo); 7189 } 7190}; 7191function ts(e) { 7192 let t = [], n = [], r = [], i = e, a = e - Uo + 1 + Wo.length; 7193 for (let o = 0; o < a; o++) { 7194 let a = 2 ** i; 7195 t.push(a); 7196 let s = 1 / a; 7197 o > e - Uo ? s = Wo[o - e + Uo - 1] : o === 0 && (s = 0), n.push(s); 7198 let c = 1 / (a - 2), l = -c, u = 1 + c, d = [ 7199 l, 7200 l, 7201 u, 7202 l, 7203 u, 7204 u, 7205 l, 7206 l, 7207 u, 7208 u, 7209 l, 7210 u 7211 ], f = /* @__PURE__ */ new Float32Array(108), p = /* @__PURE__ */ new Float32Array(72), m = /* @__PURE__ */ new Float32Array(36); 7212 for (let e = 0; e < 6; e++) { 7213 let t = e % 3 * 2 / 3 - 1, n = e > 2 ? 0 : -1, r = [ 7214 t, 7215 n, 7216 0, 7217 t + 2 / 3, 7218 n, 7219 0, 7220 t + 2 / 3, 7221 n + 1, 7222 0, 7223 t, 7224 n, 7225 0, 7226 t + 2 / 3, 7227 n + 1, 7228 0, 7229 t, 7230 n + 1, 7231 0 7232 ]; 7233 f.set(r, 18 * e), p.set(d, 12 * e); 7234 let i = [ 7235 e, 7236 e, 7237 e, 7238 e, 7239 e, 7240 e 7241 ]; 7242 m.set(i, 6 * e); 7243 } 7244 let h = new oi(); 7245 h.setAttribute("position", new Kr(f, 3)), h.setAttribute("uv", new
7245Kr(p, 2)), h.setAttribute("faceIndex", new Kr(m, 1)), r.push(new Mi(h, null)), i > Uo && i--; 7246 } 7247 return { 7248 lodMeshes: r, 7249 sizeLods: t, 7250 sigmas: n 7251 }; 7252} 7253function ns(e, t, n) { 7254 let r = new On(e, t, n); 7255 return r.texture.mapping = 306, r.texture.name = "PMREM.cubeUv", r.scissorTest = !0, r; 7256} 7257function rs(e, t, n, r, i) { 7258 e.viewport.set(t, n, r, i), e.scissor.set(t, n, r, i); 7259} 7260function is(e, t, n) { 7261 return new Ea({ 7262 name: "PMREMGGXConvolution", 7263 defines: { 7264 GGX_SAMPLES: Ko, 7265 CUBEUV_TEXEL_WIDTH: 1 / t, 7266 CUBEUV_TEXEL_HEIGHT: 1 / n, 7267 CUBEUV_MAX_MIP: `${e}.0` 7268 }, 7269 uniforms: { 7270 envMap: { value: null }, 7271 roughness: { value: 0 }, 7272 mipInt: { value: 0 } 7273 }, 7274 vertexShader: cs(), 7275 fragmentShader: "\n\n precision highp float;\n precision highp int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform float roughness;\n uniform float mipInt;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include <cube_uv_reflection_fragment>\n\n #define PI 3.14159265359\n\n // Van der Corput radical inverse\n float radicalInverse_VdC(uint bits) {\n bits = (bits << 16u) | (bits >> 16u);\n bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\n bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\n bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\n bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\n return float(bits) * 2.3283064365386963e-10; // / 0x100000000\n }\n\n // Hammersley sequence\n vec2 hammersley(uint i, uint N) {\n return vec2(float(i) / float(N), radicalInverse_VdC(i));\n }\n\n // GGX VNDF importance sampling (Eric Heitz 2018)\n // \"Sampling the GGX Distribution of Visible Normals\"\n // https://jcgt.org/published/0007/04/01/\n vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {\
vendor: 4,837 bytes, lines 7275-7312
7275n float alpha = roughness * roughness;\n\n // Section 4.1: Orthonormal basis\n vec3 T1 = vec3(1.0, 0.0, 0.0);\n vec3 T2 = cross(V, T1);\n\n // Section 4.2: Parameterization of projected area\n float r = sqrt(Xi.x);\n float phi = 2.0 * PI * Xi.y;\n float t1 = r * cos(phi);\n float t2 = r * sin(phi);\n float s = 0.5 * (1.0 + V.z);\n t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;\n\n // Section 4.3: Reprojection onto hemisphere\n vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V;\n\n // Section 3.4: Transform back to ellipsoid configuration\n return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));\n }\n\n void main() {\n vec3 N = normalize(vOutputDirection);\n vec3 V = N; // Assume view direction equals normal for pre-filtering\n\n vec3 prefilteredColor = vec3(0.0);\n float totalWeight = 0.0;\n\n // For very low roughness, just sample the environment directly\n if (roughness < 0.001) {\n gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);\n return;\n }\n\n // Tangent space basis for VNDF sampling\n vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);\n vec3 tangent = normalize(cross(up, N));\n vec3 bitangent = cross(N, tangent);\n\n for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {\n vec2 Xi = hammersley(i, uint(GGX_SAMPLES));\n\n // For PMREM, V = N, so in tangent space V is always (0, 0, 1)\n vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);\n\n // Transform H back to world space\n vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);\n vec3 L = normalize(2.0 * dot(V, H) * H - V);\n\n float NdotL = max(dot(N, L), 0.0);\n\n if(NdotL > 0.0) {\n // Sample environment at fixed mip level\n // VNDF importance sampling handles the distribution filtering\n vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);\n\n // Weight by NdotL for the split-sum approximation\n // VNDF PDF naturally accounts for the visible microfacet distribution\n prefilteredColor += sampleColor * NdotL;\n totalWeight += NdotL;\n }\n }\n\n if (totalWeight > 0.0) {\n prefilteredColor = prefilteredColor / totalWeight;\n }\n\n gl_FragColor = vec4(prefilteredColor, 1.0);\n }\n ", 7276 blending: 0, 7277 depthTest: !1, 7278 depthWrite: !1 7279 }); 7280} 7281function as(e, t, n) { 7282 let r = new Float32Array(Go), i = new G(0, 1, 0); 7283 return new Ea({ 7284 name: "SphericalGaussianBlur", 7285 defines: { 7286 n: Go, 7287 CUBEUV_TEXEL_WIDTH: 1 / t, 7288 CUBEUV_TEXEL_HEIGHT: 1 / n, 7289 CUBEUV_MAX_MIP: `${e}.0` 7290 }, 7291 uniforms: { 7292 envMap: { value: null }, 7293 samples: { value: 1 }, 7294 weights: { value: r }, 7295 latitudinal: { value: !1 }, 7296 dTheta: { value: 0 }, 7297 mipInt: { value: 0 }, 7298 poleAxis: { value: i } 7299 }, 7300 vertexShader: cs(), 7301 fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform int samples;\n uniform float weights[ n ];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform float mipInt;\n uniform vec3 poleAxis;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include <cube_uv_reflection_fragment>\n\n vec3 getSample( float theta, vec3 axis ) {\n\n float cosTheta = cos( theta );\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross( axis, vOutputDirection ) * sin( theta )\n + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );\n\n return bilinearCubeUV( envMap, sampleDirection, mipInt );\n\n }\n\n void main() {\n\n vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );\n\n if ( all( equal( axis, vec3( 0.0 ) ) ) ) {\n\n axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );\n\n }\n\n axis = normalize( axis );\n\n gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );\n gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );\n\n for ( int i = 1; i < n; i++ ) {\n\n if ( i >= samples ) {\n\n break;\n\n }\n\n float theta = dTheta * float( i );\n gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );\n gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );\n\n }\n\n }\n ", 7302 blending: 0, 7303 depthTest: !1, 7304 depthWrite: !1 7305 }); 7306} 7307function os() { 7308 return new Ea({ 7309 name: "EquirectangularToCubeUV", 7310 uniforms: { envMap: { value: null } }, 7311 vertexShader: cs(), 7312 fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n\n #include <common>\n\n void main() {\n\n vec3 outputDirection = normalize( vOutputDirection );\n vec2 uv = equirectUv( outputDirection );
7312\n\n gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );\n\n }\n ", 7313 blending: 0, 7314 depthTest: !1, 7315 depthWrite: !1 7316 }); 7317} 7318function ss() { 7319 return new Ea({ 7320 name: "CubemapToCubeUV", 7321 uniforms: { 7322 envMap: { value: null }, 7323 flipEnvMap: { value: -1 } 7324 }, 7325 vertexShader: cs(), 7326 fragmentShader: "\n\n precision mediump float;\n precision mediump int;\n\n uniform float flipEnvMap;\n\n varying vec3 vOutputDirection;\n\n uniform samplerCube envMap;\n\n void main() {\n\n gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );\n\n }\n ", 7327 blending: 0, 7328 depthTest: !1, 7329 depthWrite: !1 7330 }); 7331} 7332function cs() { 7333 return "\n\n precision mediump float;\n precision mediump int;\n\n attribute float faceIndex;\n\n varying vec3 vOutputDirection;\n\n // RH coordinate system; PMREM face-indexing convention\n vec3 getDirection( vec2 uv, float face ) {\n\n uv = 2.0 * uv - 1.0;\n\n vec3 direction = vec3( uv, 1.0 );\n\n if ( face == 0.0 ) {\n\n direction = direction.zyx; // ( 1, v, u ) pos x\n\n } else if ( face == 1.0 ) {\n\n direction = direction.xzy;\n direction.xz *= -1.0; // ( -u, 1, -v ) pos y\n\n } else if ( face == 2.0 ) {\n\n direction.x *= -1.0; // ( -u, v, 1 ) pos z\n\n } else if ( face == 3.0 ) {\n\n direction = direction.zyx;\n direction.xz *= -1.0; // ( -1, v, -u ) neg x\n\n } else if ( face == 4.0 ) {\n\n direction = direction.xzy;\n direction.xy *= -1.0; // ( -u, -1, v ) neg y\n\n } else if ( face == 5.0 ) {\n\n direction.z *= -1.0; // ( u, v, -1 ) neg z\n\n }\n\n return direction;\n\n }\n\n void main() {\n\n vOutputDirection = getDirection( uv, faceIndex );\n gl_Position = vec4( position, 1.0 );\n\n }\n "; 7334} 7335var ls = class extends On { 7336 constructor(e = 1, t = {}) { 7337 super(e, e, t), this.isWebGLCubeRenderTarget = !0; 7338 let n = { 7339 width: e, 7340 height: e, 7341 depth: 1 7342 }, r = [ 7343 n, 7344 n, 7345 n, 7346 n, 7347 n, 7348 n 7349 ]; 7350 this.texture = new ua(r), this._setTextureOptions(t), this.texture.isRenderTargetTexture = !0; 7351 } 7352 fromEquirectangularTexture(e, t) { 7353 this.texture.type = t.type, this.texture.colorSpace = t.colorSpace, this.texture.generateMipmaps = t.generateMipmaps, this.texture.minFilter = t.minFilter, this.texture.magFilter = t.magFilter; 7354 let n = { 7355 uniforms: { tEquirect: { value: null } }, 7356 vertexShader: "\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection( position, modelMatrix );\n\n #include <begin_vertex>\n #include <project_vertex>\n\n }\n ", 7357 fragmentShader: "\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include <common>\n\n void main() {\n\n vec3 direction = normalize( vWorldDirection );\n\n vec2 sampleUV = equirectUv( direction );\n\n gl_FragColor = texture2D( tEquirect, sampleUV );\n\n }\n " 7358 }, r = new ma(5, 5, 5), i = new Ea({ 7359 name: "CubemapFromEquirect", 7360 uniforms: va(n.uniforms), 7361 vertexShader: n.vertexShader, 7362 fragmentShader: n.fragmentShader, 7363 side: 1, 7364 blending: 0 7365 }); 7366 i.uniforms.tEquirect.value = t; 7367 let a = new Mi(r, i), o = t.minFilter; 7368 return t.minFilter === 1008 && (t.minFilter = P), new io(1, 10, this).update(e, a), t.minFilter = o, a.geometry.dispose(), a.material.dispose(), this; 7369 } 7370 clear(e, t = !0, n = !0, r = !0) { 7371 let i = e.getRenderTarget(); 7372 for (let i = 0; i < 6; i++) e.setRenderTarget(this, i), e.clear(t, n, r); 7373 e.setRenderTarget(i); 7374 } 7375}; 7376function us(e) { 7377 let t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = null; 7378 function i(e, t = !1) { 7379 return e == null ? null : t ? o(e) : a(e); 7380 } 7381 function a(n) { 7382 if (n && n.isTexture) { 7383 let r = n.mapping; 7384 if (r === 303 || r === 304) if (t.has(n)) { 7385 let e = t.get(n).texture; 7386 return s(e, n.mapping); 7387 } else { 7388 let r = n.image; 7389 if (r && r.height > 0) { 7390 let i = new ls(r.height); 7391 return i.fromEquirectangularTexture(e, n), t.set(n, i), n.addEventListener("dispose", l), s(i.texture, n.mapping); 7392 } else return null; 7393 } 7394 } 7395 return n; 7396 } 7397 function o(t) { 7398 if (t && t.isTexture) { 7399 let i = t.mapping, a = i === 303 || i === 304, o = i === 301 || i === 302; 7400 if (a || o) { 7401 let i = n.get(t), s = i === void 0 ? 0 : i.texture.pmremVersion; 7402 if (t.isRenderTargetTexture && t.pmremVersion !== s) return r === null && (r = new es(e)), i = a ? r.fromEquirectangular(t, i) : r.fromCubemap(t, i), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), i.texture; 7403 if (i !== void 0) return i.texture; 7404 { 7405 let s = t.image; 7406 return a && s && s.height > 0 || o && s && c(s) ? (r === null && (r = new es(e)), i = a ? r.fromEquirectangular(t) : r.fromCubemap(t), i.texture.pmremVersion = t.pmremVersion, n.set(t, i), t.addEventListener("dispose", u), i.texture) : null; 7407 } 7408 } 7409 } 7410 return t; 7411 } 7412 function s(e, t) { 7413 return t === 303 ? e.mapping = 301 : t === 304 && (e.mapping = 302), e; 7414 } 7415 function c(e) { 7416 let t = 0; 7417 for (let n = 0; n < 6; n++) e[n] !== void 0 && t++; 7418 return t === 6; 7419 } 7420 function l(e) { 7421 let n = e.target; 7422 n.removeEventListener("dispose", l); 7423 let r = t.get(n); 7424 r !== void 0 && (t.delete(n), r.dispose()); 7425 } 7426 function u(e) { 7427 let t = e.target; 7428 t.removeEventListener("dispose", u); 7429 let r = n.get(t); 7430 r !== void 0 && (n.delete(t), r.dispose()); 7431 } 7432 function d() { 7433 t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r !== null && (r.dispose(), r = null); 7434 } 7435 return { 7436 get: i, 7437 dispose: d 7438 }; 7439} 7440function ds(e) { 7441 let t = {}; 7442 function n(n) { 7443 if (t[n] !== void 0) return t[n]; 7444 let r = e.getExtension(n); 7445 return t[n] = r, r; 7446 } 7447 return { 7448 has: function(e) { 7449 return n(e) !== null; 7450 }, 7451 init: function() { 7452 n("EXT_color_buffer_float"), n("WEBGL_clip_cull_distance"), n("OES_texture_float_linear"), n("EXT_color_buffer_half_float"), n("WEBGL_multisampled_render_to_texture"), n("WEBGL_render_shared_exponent"); 7453 }, 7454 get: function(e) { 7455 let t = n(e); 7456 return t === null && Pt("WebGLRenderer: " + e + " extension not supported."), t; 7457 } 7458 }; 7459} 7460function fs(e, t, n, r) { 7461 let i = {}, a = /* @__PURE__ */ new WeakMap(); 7462 function o(e) { 7463 let s = e.target; 7464 s.index !== null && t.remove(s.index); 7465 for (let e in s.attributes) t.remove(s.attributes[e]); 7466 s.removeEventListener("dispose", o), delete i[s.id]; 7467 let c = a.get(s); 7468 c && (t.remove(c), a.delete(s)), r.releaseStatesOfGeometry(s), s.isInstancedBufferGeometry === !0 && delete s._maxInstanceCount, n.memory.geometries--; 7469 } 7470 function s(e, t) { 7471 return i[t.id] === !0 ? t : (t.addEventListener("dispose", o), i[t.id] = !0, n.memory.geometries++, t); 7472 } 7473 function c(n) { 7474 let r = n.attributes; 7475 for (let n in r) t.update(r[n], e.ARRAY_BUFFER); 7476 } 7477 function l(e) { 7478 let n = [], r = e.index, i = e.attributes.position, o = 0; 7479 if (i === void 0) return; 7480 if (r !== null) { 7481 let e = r.array; 7482 o = r.version; 7483 for (let t = 0, r = e.length; t < r; t += 3) { 7484 let r = e[t + 0], i = e[t + 1], a = e[t + 2]; 7485 n.push(r, i, i, a, a, r); 7486 } 7487 } else { 7488 let e = i.array; 7489 o = i.version; 7490 for (let t = 0, r = e.length / 3 - 1; t < r; t += 3) { 7491 let e = t + 0, r = t + 1, i = t + 2; 7492 n.push(e, r, r, i, i, e); 7493 } 7494 } 7495 let s = new (i.count >= 65535 ? Jr : qr)(n, 1); 7496 s.version = o; 7497 let c = a.get(e);
7498 c && t.remove(c), a.set(e, s); 7499 } 7500 function u(e) { 7501 let t = a.get(e); 7502 if (t) { 7503 let n = e.index; 7504 n !== null && t.version < n.version && l(e); 7505 } else l(e); 7506 return a.get(e); 7507 } 7508 return { 7509 get: s, 7510 update: c, 7511 getWireframeAttribute: u 7512 }; 7513} 7514function ps(e, t, n) { 7515 let r; 7516 function i(e) { 7517 r = e; 7518 } 7519 let a, o; 7520 function s(e) { 7521 a = e.type, o = e.bytesPerElement; 7522 } 7523 function c(t, i) { 7524 e.drawElements(r, i, a, t * o), n.update(i, r, 1); 7525 } 7526 function l(t, i, s) { 7527 s !== 0 && (e.drawElementsInstanced(r, i, a, t * o, s), n.update(i, r, s)); 7528 } 7529 function u(e, i, o) { 7530 if (o === 0) return; 7531 t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r, i, 0, a, e, 0, o); 7532 let s = 0; 7533 for (let e = 0; e < o; e++) s += i[e]; 7534 n.update(s, r, 1); 7535 } 7536 this.setMode = i, this.setIndex = s, this.render = c, this.renderInstances = l, this.renderMultiDraw = u; 7537} 7538function ms(e) { 7539 let t = { 7540 geometries: 0, 7541 textures: 0 7542 }, n = { 7543 frame: 0, 7544 calls: 0, 7545 triangles: 0, 7546 points: 0, 7547 lines: 0 7548 }; 7549 function r(t, r, i) { 7550 switch (n.calls++, r) { 7551 case e.TRIANGLES: 7552 n.triangles += t / 3 * i; 7553 break; 7554 case e.LINES: 7555 n.lines += t / 2 * i; 7556 break; 7557 case e.LINE_STRIP: 7558 n.lines += i * (t - 1); 7559 break; 7560 case e.LINE_LOOP: 7561 n.lines += i * t; 7562 break; 7563 case e.POINTS: 7564 n.points += i * t; 7565 break; 7566 default: 7567 V("WebGLInfo: Unknown draw mode:", r); 7568 break; 7569 } 7570 } 7571 function i() { 7572 n.calls = 0, n.triangles = 0, n.points = 0, n.lines = 0; 7573 } 7574 return { 7575 memory: t, 7576 render: n, 7577 programs: null, 7578 autoReset: !0, 7579 reset: i, 7580 update: r 7581 }; 7582} 7583function hs(e, t, n) { 7584 let r = /* @__PURE__ */ new WeakMap(), i = new J(); 7585 function a(a, o, s) { 7586 let c = a.morphTargetInfluences, l = o.morphAttributes.position || o.morphAttributes.normal || o.morphAttributes.color, u = l === void 0 ? 0 : l.length, d = r.get(o); 7587 if (d === void 0 || d.count !== u) { 7588 d !== void 0 && d.texture.dispose(); 7589 let e = o.morphAttributes.position !== void 0, n = o.morphAttributes.normal !== void 0, a = o.morphAttributes.color !== void 0, s = o.morphAttributes.position || [], c = o.morphAttributes.normal || [], l = o.morphAttributes.color || [], f = 0; 7590 e === !0 && (f = 1), n === !0 && (f = 2), a === !0 && (f = 3); 7591 let p = o.attributes.position.count * f, m = 1; 7592 p > t.maxTextureSize && (m = Math.ceil(p / t.maxTextureSize), p = t.maxTextureSize); 7593 let h = new Float32Array(p * m * 4 * u), g = new kn(h, p, m, u); 7594 g.type = ve, g.needsUpdate = !0; 7595 let _ = f * 4; 7596 for (let t = 0; t < u; t++) { 7597 let r = s[t], o = c[t], u = l[t], d = p * m * 4 * t; 7598 for (let t = 0; t < r.count; t++) { 7599 let s = t * _; 7600 e === !0 && (i.fromBufferAttribute(r, t), h[d + s + 0] = i.x, h[d + s + 1] = i.y, h[d + s + 2] = i.z, h[d + s + 3] = 0), n === !0 && (i.fromBufferAttribute(o, t), h[d + s + 4] = i.x, h[d + s + 5] = i.y, h[d + s + 6] = i.z, h[d + s + 7] = 0), a === !0 && (i.fromBufferAttribute(u, t), h[d + s + 8] = i.x, h[d + s + 9] = i.y, h[d + s + 10] = i.z, h[d + s + 11] = u.itemSize === 4 ? i.w : 1); 7601 } 7602 } 7603 d = { 7604 count: u, 7605 texture: g, 7606 size: new W(p, m) 7607 }, r.set(o, d); 7608 function v() { 7609 g.dispose(), r.delete(o), o.removeEventListener("dispose", v); 7610 } 7611 o.addEventListener("dispose", v); 7612 } 7613 if (a.isInstancedMesh === !0 && a.morphTexture !== null) s.getUniforms().setValue(e, "morphTexture", a.morphTexture, n); 7614 else { 7615 let t = 0; 7616 for (let e = 0; e < c.length; e++) t += c[e]; 7617 let n = o.morphTargetsRelative ? 1 : 1 - t; 7618 s.getUniforms().setValue(e, "morphTargetBaseInfluence", n), s.getUniforms().setValue(e, "morphTargetInfluences", c); 7619 } 7620 s.getUniforms().setValue(e, "morphTargetsTexture", d.texture, n), s.getUniforms().setValue(e, "morphTargetsTextureSize", d.size); 7621 } 7622 return { update: a }; 7623} 7624function gs(e, t, n, r, i) { 7625 let a = /* @__PURE__ */ new WeakMap(); 7626 function o(r) { 7627 let o = i.render.frame, s = r.geometry, l = t.get(r, s); 7628 if (a.get(l) !== o && (t.update(l), a.set(l, o)), r.isInstancedMesh && (r.hasEventListener("dispose", c) === !1 && r.addEventListener("dispose", c), a.get(r) !== o && (n.update(r.instanceMatrix, e.ARRAY_BUFFER), r.instanceColor !== null && n.update(r.instanceColor, e.ARRAY_BUFFER), a.set(r, o))), r.isSkinnedMesh) { 7629 let e = r.skeleton;
7630 a.get(e) !== o && (e.update(), a.set(e, o)); 7631 } 7632 return l; 7633 } 7634 function s() { 7635 a = /* @__PURE__ */ new WeakMap(); 7636 } 7637 function c(e) { 7638 let t = e.target; 7639 t.removeEventListener("dispose", c), r.releaseStatesOfObject(t), n.remove(t.instanceMatrix), t.instanceColor !== null && n.remove(t.instanceColor); 7640 } 7641 return { 7642 update: o, 7643 dispose: s 7644 }; 7645} 7646var _s = { 7647 1: "LINEAR_TONE_MAPPING", 7648 2: "REINHARD_TONE_MAPPING", 7649 3: "CINEON_TONE_MAPPING", 7650 4: "ACES_FILMIC_TONE_MAPPING", 7651 6: "AGX_TONE_MAPPING", 7652 7: "NEUTRAL_TONE_MAPPING", 7653 5: "CUSTOM_TONE_MAPPING" 7654}; 7655function vs(e, t, n, r, i, a) { 7656 let o = new On(t, n, { 7657 type: e, 7658 depthBuffer: i, 7659 stencilBuffer: a, 7660 samples: r ? 4 : 0, 7661 depthTexture: i ? new da(t, n) : void 0 7662 }), s = new On(t, n, { 7663 type: ye, 7664 depthBuffer: !1, 7665 stencilBuffer: !1 7666 }), c = new oi(); 7667 c.setAttribute("position", new X([ 7668 -1, 7669 3, 7670 0, 7671 -1, 7672 -1, 7673 0, 7674 3, 7675 -1, 7676 0 7677 ], 3)), c.setAttribute("uv", new X([ 7678 0, 7679 2, 7680 0, 7681 0, 7682 2, 7683 0 7684 ], 2)); 7685 let l = new Da({ 7686 uniforms: { tDiffuse: { value: null } }, 7687 vertexShader: "\n precision highp float;\n\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }", 7688 fragmentShader: "\n precision highp float;\n\n uniform sampler2D tDiffuse;\n\n varying vec2 vUv;\n\n #include <tonemapping_pars_fragment>\n #include <colorspace_pars_fragment>\n\n void main() {\n gl_FragColor = texture2D( tDiffuse, vUv );\n\n #ifdef LINEAR_TONE_MAPPING\n gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );\n #elif defined( REINHARD_TONE_MAPPING )\n gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );\n #elif defined( CINEON_TONE_MAPPING )\n gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );\n #elif defined( ACES_FILMIC_TONE_MAPPING )\n gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );\n #elif defined( AGX_TONE_MAPPING )\n gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );\n #elif defined( NEUTRAL_TONE_MAPPING )\n gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );\n #elif defined( CUSTOM_TONE_MAPPING )\n gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );\n #endif\n\n #ifdef SRGB_TRANSFER\n gl_FragColor = sRGBTransferOETF( gl_FragColor );\n #endif\n }", 7689 depthTest: !1, 7690 depthWrite: !1 7691 }), u = new Mi(c, l), d = new eo(-1, 1, 1, -1, 0, 1), f = null, p = null, m = !1, h, g = null, _ = [], v = !1; 7692 this.setSize = function(e, t) { 7693 o.setSize(e, t), s.setSize(e, t); 7694 for (let n = 0; n < _.length; n++) { 7695 let r = _[n]; 7696 r.setSize && r.setSize(e, t); 7697 } 7698 }, this.setEffects = function(e) { 7699 _ = e, v = _.length > 0 && _[0].isRenderPass === !0; 7700 let t = o.width, n = o.height; 7701 for (let e = 0; e < _.length; e++) { 7702 let r = _[e]; 7703 r.setSize && r.setSize(t, n); 7704 } 7705 }, this.begin = function(e, t) { 7706 if (m || e.toneMapping === 0 && _.length === 0) return !1; 7707 if (g = t, t !== null) { 7708 let e = t.width, n = t.height; 7709 (o.width !== e || o.height !== n) && this.setSize(e, n); 7710 } 7711 return v === !1 && e.setRenderTarget(o), h = e.toneMapping, e.toneMapping = 0, !0; 7712 }, this.hasRenderPass = function() { 7713 return v; 7714 }, this.end = function(e, t) { 7715 e.toneMapping = h, m = !0; 7716 let n = o, r = s; 7717 for (let i = 0; i < _.length; i++) { 7718 let a = _[i]; 7719 if (a.enabled !== !1 && (a.render(e, r, n, t), a.needsSwap !== !1)) { 7720 let e = n; 7721 n = r, r = e; 7722 } 7723 } 7724 if (f !== e.outputColorSpace || p !== e.toneMapping) { 7725 f = e.outputColorSpace, p = e.toneMapping, l.defines = {}, q.getTransfer(f) === "srgb" && (l.defines.SRGB_TRANSFER = ""); 7726 let t = _s[p]; 7727 t && (l.defines[t] = ""), l.needsUpdate = !0; 7728 } 7729 l.uniforms.tDiffuse.value = n.texture, e.setRenderTarget(g), e.render(u, d), g = null, m = !1; 7730 }, this.isCompositing = function() { 7731 return m; 7732 }, this.dispose = function() { 7733 o.depthTexture && o.depthTexture.dispose(), o.dispose(), s.dispose(), c.dispose(), l.dispose(); 7734 }; 7735} 7736var ys = /*@__PURE__*/ new En(), bs = /*@__PURE__*/ new da(1, 1), xs = /*@__PURE__*/ new kn(), Ss = /*@__PURE__*/ new An(), Cs = /*@__PURE__*/ new ua(), ws = [], Ts = [], Es = /* @__PURE__ */ new Float32Array(16), Ds = /* @__PURE__ */ new Float32Array(9), Os = /* @__PURE__ */ new Float32Array(4); 7737function ks(e, t, n) { 7738 let r = e[0]; 7739 if (r <= 0 || r > 0) return e; 7740 let i = t * n, a = ws[i]; 7741 if (a === void 0 && (a = new Float32Array(i), ws[i] = a), t !== 0) { 7742 r.toArray(a, 0); 7743 for (let r = 1, i = 0; r !== t; ++r) i += n, e[r].toArray(a, i); 7744 } 7745 return a; 7746} 7747function As(e, t) { 7748 if (e.length !== t.length) return !1; 7749 for (let n = 0, r = e.length; n < r; n++) if (e[n] !== t[n]) return !1; 7750 return !0; 7751} 7752function js(e, t) { 7753 for (let n = 0, r = t.length; n < r; n++) e[n] = t[n]; 7754} 7755function Ms(e, t) { 7756 let n = Ts[t]; 7757 n === void 0 && (n = new Int32Array(t), Ts[t] = n); 7758 for (let r = 0; r !== t; ++r) n[r] = e.allocateTextureUnit(); 7759 return n; 7760} 7761function Ns(e, t) { 7762 let n = this.cache; 7763 n[0] !== t && (e.uniform1f(this.addr, t), n[0] = t); 7764} 7765function Ps(e, t) { 7766 let n = this.cache; 7767 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y) && (e.uniform2f(this.addr, t.x, t.y), n[0] = t.x, n[1] = t.y); 7768 else { 7769 if (As(n, t)) return; 7770 e.uniform2fv(this.addr, t), js(n, t); 7771 } 7772} 7773function Fs(e, t) { 7774 let n = this.cache; 7775 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) && (e.uniform3f(this.addr, t.x, t.y, t.z), n[0] = t.x, n[1] = t.y, n[2] = t.z); 7776 else if (t.r !== void 0) (n[0] !== t.r || n[1] !== t.g || n[2] !== t.b) && (e.uniform3f(this.addr, t.r, t.g, t.b), n[0] = t.r, n[1] = t.g, n[2] = t.b); 7777 else { 7778 if (As(n, t)) return; 7779 e.uniform3fv(this.addr, t), js(n, t); 7780 } 7781} 7782function Is(e, t) { 7783 let n = this.cache; 7784 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) && (e.uniform4f(this.addr, t.x, t.y, t.z, t.w), n[0] = t.x, n[1] = t.y, n[2] = t.z, n[3] = t.w); 7785 else { 7786 if (As(n, t)) return; 7787 e.uniform4fv(this.addr, t), js(n, t); 7788 } 7789} 7790function Ls(e, t) { 7791 let n = this.cache, r = t.elements; 7792 if (r === void 0) { 7793 if (As(n, t)) return; 7794 e.uniformMatrix2fv(this.addr, !1, t), js(n, t); 7795 } else { 7796 if (As(n, r)) return; 7797 Os.set(r), e.uniformMatrix2fv(this.addr, !1, Os), js(n, r); 7798 } 7799} 7800function Rs(e, t) { 7801 let n = this.cache, r = t.elements; 7802 if (r === void 0) { 7803 if (As(n, t)) return; 7804 e.uniformMatrix3fv(this.addr, !1, t), js(n, t); 7805 } else { 7806 if (As(n, r)) return; 7807 Ds.set(r), e.uniformMatrix3fv(this.addr, !1, Ds), js(n, r); 7808 } 7809} 7810function zs(e, t) { 7811 let n = this.cache, r = t.elements; 7812 if (r === void 0) { 7813 if (As(n, t)) return; 7814 e.uniformMatrix4fv(this.addr, !1, t), js(n, t); 7815 } else { 7816 if (As(n, r)) return; 7817 Es.set(r), e.uniformMatrix4fv(this.addr, !1, Es), js(n, r); 7818 } 7819} 7820function Bs(e, t) { 7821 let n = this.cache; 7822 n[0] !== t && (e.uniform1i(this.addr, t), n[0] = t); 7823} 7824function Vs(e, t) { 7825 let n = this.cache; 7826 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y) && (e.uniform2i(this.addr, t.x, t.y), n[0] = t.x, n[1] = t.y); 7827 else { 7828 if (As(n, t)) return; 7829 e.uniform2iv(this.addr, t), js(n, t); 7830 } 7831} 7832function Hs(e, t) { 7833 let n = this.cache; 7834 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) && (e.uniform3i(this.addr, t.x, t.y, t.z), n[0] = t.x, n[1] = t.y, n[2] = t.z); 7835 else { 7836 if (As(n, t)) return; 7837 e.uniform3iv(this.addr, t), js(n, t); 7838 } 7839} 7840function Us(e, t) { 7841 let n = this.cache; 7842 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) && (e.uniform4i(this.addr, t.x, t.y, t.z, t.w), n[0] = t.x, n[1] = t.y, n[2] = t.z, n[3] = t.w); 7843 else { 7844 if (As(n, t)) return; 7845 e.uniform4iv(this.addr, t), js(n, t); 7846 } 7847} 7848function Ws(e, t) { 7849 let n = this.cache; 7850 n[0] !== t && (e.uniform1ui(this.addr, t), n[0] = t); 7851} 7852function Gs(e, t) { 7853 let n = this.cache; 7854 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y) && (e.uniform2ui(this.addr, t.x, t.y), n[0] = t.x, n[1] = t.y); 7855 else { 7856 if (As(n, t)) return; 7857 e.uniform2uiv(this.addr, t), js(n, t); 7858 } 7859} 7860function Ks(e, t) { 7861 let n = this.cache; 7862 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z) && (e.uniform3ui(this.addr, t.x, t.y, t.z), n[0] = t.x, n[1] = t.y, n[2] = t.z); 7863 else { 7864 if (As(n, t)) return; 7865 e.uniform3uiv(this.addr, t), js(n, t); 7866 } 7867} 7868function qs(e, t) { 7869 let n = this.cache; 7870 if (t.x !== void 0) (n[0] !== t.x || n[1] !== t.y || n[2] !== t.z || n[3] !== t.w) && (e.uniform4ui(this.addr, t.x, t.y, t.z, t.w), n[0] = t.x, n[1] = t.y, n[2] = t.z, n[3] = t.w); 7871 else { 7872 if (As(n, t)) return; 7873 e.uniform4uiv(this.addr, t), js(n, t); 7874 } 7875} 7876function Js(e, t, n) { 7877 let r = this.cache, i = n.allocateTextureUnit(); 7878 r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i); 7879 let a; 7880 this.type === e.SAMPLER_2D_SHADOW ? (bs.compareFunction = n.isReversedDepthBuffer() ? 518 : 515, a = bs) : a = ys, n.setTexture2D(t || a, i); 7881} 7882function Ys(e, t, n) { 7883 let r = this.cache, i = n.allocateTextureUnit(); 7884 r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture3D(t || Ss, i); 7885} 7886function Xs(e, t, n) { 7887 let r = this.cache, i = n.allocateTextureUnit(); 7888 r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTextureCube(t || Cs, i); 7889} 7890function Zs(e, t, n) { 7891 let r = this.cache, i = n.allocateTextureUnit(); 7892 r[0] !== i && (e.uniform1i(this.addr, i), r[0] = i), n.setTexture2DArray(t || xs, i); 7893} 7894function Qs(e) { 7895 switch (e) { 7896 case 5126: return Ns; 7897 case 35664: return Ps; 7898 case 35665: return Fs;
7899 case 35666: return Is; 7900 case 35674: return Ls; 7901 case 35675: return Rs; 7902 case 35676: return zs; 7903 case 5124: 7904 case 35670: return Bs; 7905 case 35667: 7906 case 35671: return Vs; 7907 case 35668: 7908 case 35672: return Hs; 7909 case 35669: 7910 case 35673: return Us; 7911 case 5125: return Ws; 7912 case 36294: return Gs; 7913 case 36295: return Ks; 7914 case 36296: return qs; 7915 case 35678: 7916 case 36198: 7917 case 36298: 7918 case 36306: 7919 case 35682: return Js; 7920 case 35679: 7921 case 36299: 7922 case 36307: return Ys; 7923 case 35680: 7924 case 36300: 7925 case 36308: 7926 case 36293: return Xs; 7927 case 36289: 7928 case 36303: 7929 case 36311: 7930 case 36292: return Zs; 7931 } 7932} 7933function $s(e, t) { 7934 e.uniform1fv(this.addr, t); 7935} 7936function ec(e, t) { 7937 let n = ks(t, this.size, 2); 7938 e.uniform2fv(this.addr, n); 7939} 7940function tc(e, t) { 7941 let n = ks(t, this.size, 3); 7942 e.uniform3fv(this.addr, n); 7943} 7944function nc(e, t) { 7945 let n = ks(t, this.size, 4); 7946 e.uniform4fv(this.addr, n); 7947} 7948function rc(e, t) { 7949 let n = ks(t, this.size, 4); 7950 e.uniformMatrix2fv(this.addr, !1, n); 7951} 7952function ic(e, t) { 7953 let n = ks(t, this.size, 9); 7954 e.uniformMatrix3fv(this.addr, !1, n); 7955} 7956function ac(e, t) { 7957 let n = ks(t, this.size, 16); 7958 e.uniformMatrix4fv(this.addr, !1, n); 7959} 7960function oc(e, t) { 7961 e.uniform1iv(this.addr, t); 7962} 7963function sc(e, t) { 7964 e.uniform2iv(this.addr, t); 7965} 7966function cc(e, t) { 7967 e.uniform3iv(this.addr, t); 7968} 7969function lc(e, t) { 7970 e.uniform4iv(this.addr, t); 7971} 7972function uc(e, t) { 7973 e.uniform1uiv(this.addr, t); 7974} 7975function dc(e, t) { 7976 e.uniform2uiv(this.addr, t); 7977} 7978function fc(e, t) { 7979 e.uniform3uiv(this.addr, t); 7980} 7981function pc(e, t) { 7982 e.uniform4uiv(this.addr, t); 7983} 7984function mc(e, t, n) { 7985 let r = this.cache, i = t.length, a = Ms(n, i); 7986 As(r, a) || (e.uniform1iv(this.addr, a), js(r, a)); 7987 let o; 7988 o = this.type === e.SAMPLER_2D_SHADOW ? bs : ys; 7989 for (let e = 0; e !== i; ++e) n.setTexture2D(t[e] || o, a[e]); 7990} 7991function hc(e, t, n) { 7992 let r = this.cache, i = t.length, a = Ms(n, i); 7993 As(r, a) || (e.uniform1iv(this.addr, a), js(r, a)); 7994 for (let e = 0; e !== i; ++e) n.setTexture3D(t[e] || Ss, a[e]); 7995} 7996function gc(e, t, n) { 7997 let r = this.cache, i = t.length, a = Ms(n, i); 7998 As(r, a) || (e.uniform1iv(this.addr, a), js(r, a)); 7999 for (let e = 0; e !== i; ++e) n.setTextureCube(t[e] || Cs, a[e]); 8000} 8001function _c(e, t, n) { 8002 let r = this.cache, i = t.length, a = Ms(n, i); 8003 As(r, a) || (e.uniform1iv(this.addr, a), js(r, a)); 8004 for (let e = 0; e !== i; ++e) n.setTexture2DArray(t[e] || xs, a[e]); 8005} 8006function vc(e) { 8007 switch (e) { 8008 case 5126: return $s; 8009 case 35664: return ec; 8010 case 35665: return tc; 8011 case 35666: return nc; 8012 case 35674: return rc; 8013 case 35675: return ic; 8014 case 35676: return ac; 8015 case 5124: 8016 case 35670: return oc; 8017 case 35667: 8018 case 35671: return sc; 8019 case 35668: 8020 case 35672: return cc; 8021 case 35669: 8022 case 35673: return lc; 8023 case 5125: return uc; 8024 case 36294: return dc; 8025 case 36295: return fc; 8026 case 36296: return pc; 8027 case 35678: 8028 case 36198: 8029 case 36298: 8030 case 36306: 8031 case 35682: return mc; 8032 case 35679: 8033 case 36299: 8034 case 36307: return hc; 8035 case 35680: 8036 case 36300: 8037 case 36308: 8038 case 36293: return gc; 8039 case 36289: 8040 case 36303: 8041 case 36311: 8042 case 36292: return _c; 8043 } 8044} 8045var yc = class { 8046 constructor(e, t, n) { 8047 this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.setValue = Qs(t.type); 8048 } 8049}, bc = class { 8050 constructor(e, t, n) { 8051 this.id = e, this.addr = n, this.cache = [], this.type = t.type, this.size = t.size, this.setValue = vc(t.type); 8052 } 8053}, xc = class { 8054 constructor(e) { 8055 this.id = e, this.seq = [], this.map = {}; 8056 } 8057 setValue(e, t, n) { 8058 let r = this.seq; 8059 for (let i = 0, a = r.length; i !== a; ++i) { 8060 let a = r[i]; 8061 a.setValue(e, t[a.id], n); 8062 } 8063 } 8064}, Sc = /(\w+)(\])?(\[|\.)?/g; 8065function Cc(e, t) { 8066 e.seq.push(t), e.map[t.id] = t; 8067} 8068function wc(e, t, n) { 8069 let r = e.name, i = r.length; 8070 for (Sc.lastIndex = 0;;) { 8071 let a = Sc.exec(r), o = Sc.lastIndex, s = a[1], c = a[2] === "]", l = a[3]; 8072 if (c && (s |= 0), l === void 0 || l === "[" && o + 2 === i) { 8073 Cc(n, l === void 0 ? new yc(s, e, t) : new bc(s, e, t)); 8074 break; 8075 } else { 8076 let e = n.map[s]; 8077 e === void 0 && (e = new xc(s), Cc(n, e)), n = e; 8078 } 8079 } 8080} 8081var Tc = class { 8082 constructor(e, t) { 8083 this.seq = [], this.map = {}; 8084 let n = e.getProgramParameter(t, e.ACTIVE_UNIFORMS); 8085 for (let r = 0; r < n; ++r) { 8086 let n = e.getActiveUniform(t, r); 8087 wc(n, e.getUniformLocation(t, n.name), this); 8088 } 8089 let r = [], i = []; 8090 for (let t of this.seq) t.type === e.SAMPLER_2D_SHADOW || t.type === e.SAMPLER_CUBE_SHADOW || t.type === e.SAMPLER_2D_ARRAY_SHADOW ? r.push(t) : i.push(t); 8091 r.length > 0 && (this.seq = r.concat(i)); 8092 } 8093 setValue(e, t, n, r) { 8094 let i = this.map[t]; 8095 i !== void 0 && i.setValue(e, n, r); 8096 } 8097 setOptional(e, t, n) { 8098 let r = t[n]; 8099 r !== void 0 && this.setValue(e, n, r); 8100 } 8101 static upload(e, t, n, r) { 8102 for (let i = 0, a = t.length; i !== a; ++i) { 8103 let a = t[i], o = n[a.id]; 8104 o.needsUpdate !== !1 && a.setValue(e, o.value, r); 8105 } 8106 } 8107 static seqWithValue(e, t) { 8108 let n = []; 8109 for (let r = 0, i = e.length; r !== i; ++r) { 8110 let i = e[r]; 8111 i.id in t && n.push(i); 8112 } 8113 return n; 8114 } 8115}; 8116function Ec(e, t, n) { 8117 let r = e.createShader(t); 8118 return e.shaderSource(r, n), e.compileShader(r), r; 8119} 8120var Dc = 37297, Oc = 0; 8121function kc(e, t) { 8122 let n = e.split("\n"), r = [], i = Math.max(t - 6, 0), a = Math.min(t + 6, n.length); 8123 for (let e = i; e < a; e++) { 8124 let i = e + 1; 8125 r.push(`${i === t ? ">" : " "} ${i}: ${n[e]}`); 8126 } 8127 return r.join("\n"); 8128} 8129var Ac = /*@__PURE__*/ new K(); 8130function jc(e) { 8131 q._getMatrix(Ac, q.workingColorSpace, e); 8132 let t = `mat3( ${Ac.elements.map((e) => e.toFixed(4))} )`; 8133 switch (q.getTransfer(e)) { 8134 case St: return [t, "LinearTransferOETF"]; 8135 case Ct: return [t, "sRGBTransferOETF"]; 8136 default: return B("WebGLProgram: Unsupported color space: ", e), [t, "LinearTransferOETF"]; 8137 } 8138} 8139function Mc(e, t, n) { 8140 let r = e.getShaderParameter(t, e.COMPILE_STATUS), i = (e.getShaderInfoLog(t) || "").trim(); 8141 if (r && i === "") return ""; 8142 let a = /ERROR: 0:(\d+)/.exec(i); 8143 if (a) { 8144 let r = parseInt(a[1]); 8145 return n.toUpperCase() + "\n\n" + i + "\n\n" + kc(e.getShaderSource(t), r); 8146 } else return i; 8147} 8148function Nc(e, t) { 8149 let n = jc(t); 8150 return [ 8151 `vec4 ${e}( vec4 value ) {`, 8152 ` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`, 8153 "}" 8154 ].join("\n"); 8155} 8156var Pc = { 8157 1: "Linear", 8158 2: "Reinhard", 8159 3: "Cineon", 8160 4: "ACESFilmic", 8161 6: "AgX", 8162 7: "Neutral", 8163 5: "Custom" 8164}; 8165function Fc(e, t) { 8166 let n = Pc[t]; 8167 return n === void 0 ? (B("WebGLProgram: Unsupported toneMapping:", t), "vec3 " + e + "( vec3 color ) { return LinearToneMapping( color ); }") : "vec3 " + e + "( vec3 color ) { return " + n + "ToneMapping( color ); }"; 8168} 8169var Ic = /*@__PURE__*/ new G(); 8170function Lc() { 8171 return q.getLuminanceCoefficients(Ic), [ 8172 "float luminance( const in vec3 rgb ) {", 8173 ` const vec3 weights = vec3( ${Ic.x.toFixed(4)}, ${Ic.y.toFixed(4)}, ${Ic.z.toFixed(4)} );`, 8174 " return dot( weights, rgb );", 8175 "}" 8176 ].join("\n"); 8177} 8178function Rc(e) {
8179 return [e.extensionClipCullDistance ? "#extension GL_ANGLE_clip_cull_distance : require" : "", e.extensionMultiDraw ? "#extension GL_ANGLE_multi_draw : require" : ""].filter(Vc).join("\n"); 8180} 8181function zc(e) { 8182 let t = []; 8183 for (let n in e) { 8184 let r = e[n]; 8185 r !== !1 && t.push("#define " + n + " " + r); 8186 } 8187 return t.join("\n"); 8188} 8189function Bc(e, t) { 8190 let n = {}, r = e.getProgramParameter(t, e.ACTIVE_ATTRIBUTES); 8191 for (let i = 0; i < r; i++) { 8192 let r = e.getActiveAttrib(t, i), a = r.name, o = 1; 8193 r.type === e.FLOAT_MAT2 && (o = 2), r.type === e.FLOAT_MAT3 && (o = 3), r.type === e.FLOAT_MAT4 && (o = 4), n[a] = { 8194 type: r.type, 8195 location: e.getAttribLocation(t, a), 8196 locationSize: o 8197 }; 8198 } 8199 return n; 8200} 8201function Vc(e) { 8202 return e !== ""; 8203} 8204function Hc(e, t) { 8205 let n = t.numSpotLightShadows + t.numSpotLightMaps - t.numSpotLightShadowsWithMaps; 8206 return e.replace(/NUM_DIR_LIGHTS/g, t.numDirLights).replace(/NUM_SPOT_LIGHTS/g, t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g, t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g, n).replace(/NUM_RECT_AREA_LIGHTS/g, t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g, t.numPointLights).replace(/NUM_HEMI_LIGHTS/g, t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g, t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g, t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g, t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g, t.numPointLightShadows); 8207} 8208function Uc(e, t) { 8209 return e.replace(/NUM_CLIPPING_PLANES/g, t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g, t.numClippingPlanes - t.numClipIntersection); 8210} 8211var Wc = /^[ \t]*#include +<([\w\d./]+)>/gm; 8212function Gc(e) { 8213 return e.replace(Wc, qc); 8214} 8215var Kc = /* @__PURE__ */ new Map(); 8216function qc(e, t) { 8217 let n = Z[t]; 8218 if (n === void 0) { 8219 let e = Kc.get(t); 8220 if (e !== void 0) n = Z[e], B("WebGLRenderer: Shader chunk \"%s\" has been deprecated. Use \"%s\" instead.", t, e); 8221 else throw Error("THREE.WebGLProgram: Can not resolve #include <" + t + ">"); 8222 } 8223 return Gc(n); 8224} 8225var Jc = /#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g; 8226function Yc(e) { 8227 return e.replace(Jc, Xc); 8228} 8229function Xc(e, t, n, r) { 8230 let i = ""; 8231 for (let e = parseInt(t); e < parseInt(n); e++) i += r.replace(/\[\s*i\s*\]/g, "[ " + e + " ]").replace(/UNROLLED_LOOP_INDEX/g, e); 8232 return i; 8233} 8234function Zc(e) { 8235 let t = `precision ${e.precision} float; 8236 precision ${e.precision} int; 8237 precision ${e.precision} sampler2D; 8238 precision ${e.precision} samplerCube; 8239 precision ${e.precision} sampler3D; 8240 precision ${e.precision} sampler2DArray; 8241 precision ${e.precision} sampler2DShadow; 8242 precision ${e.precision} samplerCubeShadow; 8243 precision ${e.precision} sampler2DArrayShadow; 8244 precision ${e.precision} isampler2D; 8245 precision ${e.precision} isampler3D; 8246 precision ${e.precision} isamplerCube; 8247 precision ${e.precision} isampler2DArray; 8248 precision ${e.precision} usampler2D; 8249 precision ${e.precision} usampler3D; 8250 precision ${e.precision} usamplerCube; 8251 precision ${e.precision} usampler2DArray; 8252 `; 8253 return e.precision === "highp" ? t += "\n#define HIGH_PRECISION" : e.precision === "mediump" ? t += "\n#define MEDIUM_PRECISION" : e.precision === "lowp" && (t += "\n#define LOW_PRECISION"), t; 8254} 8255var Qc = { 8256 1: "SHADOWMAP_TYPE_PCF", 8257 3: "SHADOWMAP_TYPE_VSM" 8258}; 8259function $c(e) { 8260 return Qc[e.shadowMapType] || "SHADOWMAP_TYPE_BASIC"; 8261} 8262var el = { 8263 301: "ENVMAP_TYPE_CUBE", 8264 302: "ENVMAP_TYPE_CUBE", 8265 306: "ENVMAP_TYPE_CUBE_UV" 8266}; 8267function tl(e) { 8268 return e.envMap === !1 ? "ENVMAP_TYPE_CUBE" : el[e.envMapMode] || "ENVMAP_TYPE_CUBE"; 8269} 8270var nl = { 302: "ENVMAP_MODE_REFRACTION" }; 8271function rl(e) { 8272 return e.envMap === !1 ? "ENVMAP_MODE_REFLECTION" : nl[e.envMapMode] || "ENVMAP_MODE_REFLECTION"; 8273} 8274var il = { 8275 0: "ENVMAP_BLENDING_MULTIPLY", 8276 1: "ENVMAP_BLENDING_MIX", 8277 2: "ENVMAP_BLENDING_ADD" 8278}; 8279function al(e) { 8280 return e.envMap === !1 ? "ENVMAP_BLENDING_NONE" : il[e.combine] || "ENVMAP_BLENDING_NONE"; 8281} 8282function ol(e) { 8283 let t = e.envMapCubeUVHeight; 8284 if (t === null) return null; 8285 let n = Math.log2(t) - 2, r = 1 / t; 8286 return { 8287 texelWidth: 1 / (3 * Math.max(2 ** n, 112)), 8288 texelHeight: r, 8289 maxMip: n 8290 }; 8291} 8292function sl(e, t, n, r) { 8293 let i = e.getContext(), a = n.defines, o = n.vertexShader, s = n.fragmentShader, c = $c(n), l = tl(n), u = rl(n), d = al(n), f = ol(n), p = Rc(n), m = zc(a), h = i.createProgram(), g, _, v = n.glslVersion ? "#version " + n.glslVersion + "\n" : ""; 8294 n.isRawShaderMaterial ? (g = [ 8295 "#define SHADER_TYPE " + n.shaderType, 8296 "#define SHADER_NAME " + n.shaderName, 8297 m 8298 ].filter(Vc).join("\n"), g.length > 0 && (g += "\n"), _ = [ 8299 "#define SHADER_TYPE " + n.shaderType, 8300 "#define SHADER_NAME " + n.shaderName, 8301 m 8302 ].filter(Vc).join("\n"), _.length > 0 && (_ += "\n")) : (g = [ 8303 Zc(n), 8304 "#define SHADER_TYPE " + n.shaderType, 8305 "#define SHADER_NAME " + n.shaderName, 8306 m,
vendor: 7,563 bytes, lines 8307-8463
8307 n.extensionClipCullDistance ? "#define USE_CLIP_DISTANCE" : "", 8308 n.batching ? "#define USE_BATCHING" : "", 8309 n.batchingColor ? "#define USE_BATCHING_COLOR" : "", 8310 n.instancing ? "#define USE_INSTANCING" : "", 8311 n.instancingColor ? "#define USE_INSTANCING_COLOR" : "", 8312 n.instancingMorph ? "#define USE_INSTANCING_MORPH" : "", 8313 n.useFog && n.fog ? "#define USE_FOG" : "", 8314 n.useFog && n.fogExp2 ? "#define FOG_EXP2" : "", 8315 n.map ? "#define USE_MAP" : "", 8316 n.envMap ? "#define USE_ENVMAP" : "", 8317 n.envMap ? "#define " + u : "", 8318 n.lightMap ? "#define USE_LIGHTMAP" : "", 8319 n.aoMap ? "#define USE_AOMAP" : "", 8320 n.bumpMap ? "#define USE_BUMPMAP" : "", 8321 n.normalMap ? "#define USE_NORMALMAP" : "", 8322 n.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", 8323 n.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", 8324 n.displacementMap ? "#define USE_DISPLACEMENTMAP" : "", 8325 n.emissiveMap ? "#define USE_EMISSIVEMAP" : "", 8326 n.anisotropy ? "#define USE_ANISOTROPY" : "", 8327 n.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "", 8328 n.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", 8329 n.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", 8330 n.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", 8331 n.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "", 8332 n.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "", 8333 n.specularMap ? "#define USE_SPECULARMAP" : "", 8334 n.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "", 8335 n.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "", 8336 n.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", 8337 n.metalnessMap ? "#define USE_METALNESSMAP" : "", 8338 n.alphaMap ? "#define USE_ALPHAMAP" : "", 8339 n.alphaHash ? "#define USE_ALPHAHASH" : "", 8340 n.transmission ? "#define USE_TRANSMISSION" : "", 8341 n.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", 8342 n.thicknessMap ? "#define USE_THICKNESSMAP" : "", 8343 n.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "", 8344 n.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "", 8345 n.mapUv ? "#define MAP_UV " + n.mapUv : "", 8346 n.alphaMapUv ? "#define ALPHAMAP_UV " + n.alphaMapUv : "", 8347 n.lightMapUv ? "#define LIGHTMAP_UV " + n.lightMapUv : "", 8348 n.aoMapUv ? "#define AOMAP_UV " + n.aoMapUv : "", 8349 n.emissiveMapUv ? "#define EMISSIVEMAP_UV " + n.emissiveMapUv : "", 8350 n.bumpMapUv ? "#define BUMPMAP_UV " + n.bumpMapUv : "", 8351 n.normalMapUv ? "#define NORMALMAP_UV " + n.normalMapUv : "", 8352 n.displacementMapUv ? "#define DISPLACEMENTMAP_UV " + n.displacementMapUv : "", 8353 n.metalnessMapUv ? "#define METALNESSMAP_UV " + n.metalnessMapUv : "", 8354 n.roughnessMapUv ? "#define ROUGHNESSMAP_UV " + n.roughnessMapUv : "", 8355 n.anisotropyMapUv ? "#define ANISOTROPYMAP_UV " + n.anisotropyMapUv : "", 8356 n.clearcoatMapUv ? "#define CLEARCOATMAP_UV " + n.clearcoatMapUv : "", 8357 n.clearcoatNormalMapUv ? "#define CLEARCOAT_NORMALMAP_UV " + n.clearcoatNormalMapUv : "", 8358 n.clearcoatRoughnessMapUv ? "#define CLEARCOAT_ROUGHNESSMAP_UV " + n.clearcoatRoughnessMapUv : "", 8359 n.iridescenceMapUv ? "#define IRIDESCENCEMAP_UV " + n.iridescenceMapUv : "", 8360 n.iridescenceThicknessMapUv ? "#define IRIDESCENCE_THICKNESSMAP_UV " + n.iridescenceThicknessMapUv : "", 8361 n.sheenColorMapUv ? "#define SHEEN_COLORMAP_UV " + n.sheenColorMapUv : "", 8362 n.sheenRoughnessMapUv ? "#define SHEEN_ROUGHNESSMAP_UV " + n.sheenRoughnessMapUv : "", 8363 n.specularMapUv ? "#define SPECULARMAP_UV " + n.specularMapUv : "", 8364 n.specularColorMapUv ? "#define SPECULAR_COLORMAP_UV " + n.specularColorMapUv : "", 8365 n.specularIntensityMapUv ? "#define SPECULAR_INTENSITYMAP_UV " + n.specularIntensityMapUv : "", 8366 n.transmissionMapUv ? "#define TRANSMISSIONMAP_UV " + n.transmissionMapUv : "", 8367 n.thicknessMapUv ? "#define THICKNESSMAP_UV " + n.thicknessMapUv : "", 8368 n.vertexTangents && n.flatShading === !1 ? "#define USE_TANGENT" : "", 8369 n.vertexNormals ? "#define HAS_NORMAL" : "", 8370 n.vertexColors ? "#define USE_COLOR" : "", 8371 n.vertexAlphas ? "#define USE_COLOR_ALPHA" : "", 8372 n.vertexUv1s ? "#define USE_UV1" : "", 8373 n.vertexUv2s ? "#define USE_UV2" : "", 8374 n.vertexUv3s ? "#define USE_UV3" : "", 8375 n.pointsUvs ? "#define USE_POINTS_UV" : "", 8376 n.flatShading ? "#define FLAT_SHADED" : "", 8377 n.skinning ? "#define USE_SKINNING" : "", 8378 n.morphTargets ? "#define USE_MORPHTARGETS" : "", 8379 n.morphNormals && n.flatShading === !1 ? "#define USE_MORPHNORMALS" : "", 8380 n.morphColors ? "#define USE_MORPHCOLORS" : "", 8381 n.morphTargetsCount > 0 ? "#define MORPHTARGETS_TEXTURE_STRIDE " + n.morphTextureStride : "", 8382 n.morphTargetsCount > 0 ? "#define MORPHTARGETS_COUNT " + n.morphTargetsCount : "", 8383 n.doubleSided ? "#define DOUBLE_SIDED" : "", 8384 n.flipSided ? "#define FLIP_SIDED" : "", 8385 n.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", 8386 n.shadowMapEnabled ? "#define " + c : "", 8387 n.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "", 8388 n.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "", 8389 n.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "", 8390 n.reversedDepthBuffer ? "#define USE_REVERSED_DEPTH_BUFFER" : "", 8391 "uniform mat4 modelMatrix;", 8392 "uniform mat4 modelViewMatrix;", 8393 "uniform mat4 projectionMatrix;", 8394 "uniform mat4 viewMatrix;", 8395 "uniform mat3 normalMatrix;", 8396 "uniform vec3 cameraPosition;", 8397 "uniform bool isOrthographic;", 8398 "#ifdef USE_INSTANCING", 8399 " attribute mat4 instanceMatrix;", 8400 "#endif", 8401 "#ifdef USE_INSTANCING_COLOR", 8402 " attribute vec3 instanceColor;", 8403 "#endif", 8404 "#ifdef USE_INSTANCING_MORPH", 8405 " uniform sampler2D morphTexture;", 8406 "#endif", 8407 "attribute vec3 position;", 8408 "attribute vec3 normal;", 8409 "attribute vec2 uv;", 8410 "#ifdef USE_UV1", 8411 " attribute vec2 uv1;", 8412 "#endif", 8413 "#ifdef USE_UV2", 8414 " attribute vec2 uv2;", 8415 "#endif", 8416 "#ifdef USE_UV3", 8417 " attribute vec2 uv3;", 8418 "#endif", 8419 "#ifdef USE_TANGENT", 8420 " attribute vec4 tangent;", 8421 "#endif", 8422 "#if defined( USE_COLOR_ALPHA )", 8423 " attribute vec4 color;", 8424 "#elif defined( USE_COLOR )", 8425 " attribute vec3 color;", 8426 "#endif", 8427 "#ifdef USE_SKINNING", 8428 " attribute vec4 skinIndex;", 8429 " attribute vec4 skinWeight;", 8430 "#endif", 8431 "\n" 8432 ].filter(Vc).join("\n"), _ = [ 8433 Zc(n), 8434 "#define SHADER_TYPE " + n.shaderType, 8435 "#define SHADER_NAME " + n.shaderName, 8436 m, 8437 n.useFog && n.fog ? "#define USE_FOG" : "", 8438 n.useFog && n.fogExp2 ? "#define FOG_EXP2" : "", 8439 n.alphaToCoverage ? "#define ALPHA_TO_COVERAGE" : "", 8440 n.map ? "#define USE_MAP" : "", 8441 n.matcap ? "#define USE_MATCAP" : "", 8442 n.envMap ? "#define USE_ENVMAP" : "", 8443 n.envMap ? "#define " + l : "", 8444 n.envMap ? "#define " + u : "", 8445 n.envMap ? "#define " + d : "", 8446 f ? "#define CUBEUV_TEXEL_WIDTH " + f.texelWidth : "", 8447 f ? "#define CUBEUV_TEXEL_HEIGHT " + f.texelHeight : "", 8448 f ? "#define CUBEUV_MAX_MIP " + f.maxMip + ".0" : "", 8449 n.lightMap ? "#define USE_LIGHTMAP" : "", 8450 n.aoMap ? "#define USE_AOMAP" : "", 8451 n.bumpMap ? "#define USE_BUMPMAP" : "", 8452 n.normalMap ? "#define USE_NORMALMAP" : "", 8453 n.normalMapObjectSpace ? "#define USE_NORMALMAP_OBJECTSPACE" : "", 8454 n.normalMapTangentSpace ? "#define USE_NORMALMAP_TANGENTSPACE" : "", 8455 n.packedNormalMap ? "#define USE_PACKED_NORMALMAP" : "", 8456 n.emissiveMap ? "#define USE_EMISSIVEMAP" : "", 8457 n.anisotropy ? "#define USE_ANISOTROPY" : "", 8458 n.anisotropyMap ? "#define USE_ANISOTROPYMAP" : "", 8459 n.clearcoat ? "#define USE_CLEARCOAT" : "", 8460 n.clearcoatMap ? "#define USE_CLEARCOATMAP" : "", 8461 n.clearcoatRoughnessMap ? "#define USE_CLEARCOAT_ROUGHNESSMAP" : "", 8462 n.clearcoatNormalMap ? "#define USE_CLEARCOAT_NORMALMAP" : "", 8463 n.dispersion ? "#define USE_DISPERSION" : "",
vendor: 4,121 bytes, lines 8464-8539
8464 n.iridescence ? "#define USE_IRIDESCENCE" : "", 8465 n.iridescenceMap ? "#define USE_IRIDESCENCEMAP" : "", 8466 n.iridescenceThicknessMap ? "#define USE_IRIDESCENCE_THICKNESSMAP" : "", 8467 n.specularMap ? "#define USE_SPECULARMAP" : "", 8468 n.specularColorMap ? "#define USE_SPECULAR_COLORMAP" : "", 8469 n.specularIntensityMap ? "#define USE_SPECULAR_INTENSITYMAP" : "", 8470 n.roughnessMap ? "#define USE_ROUGHNESSMAP" : "", 8471 n.metalnessMap ? "#define USE_METALNESSMAP" : "", 8472 n.alphaMap ? "#define USE_ALPHAMAP" : "", 8473 n.alphaTest ? "#define USE_ALPHATEST" : "", 8474 n.alphaHash ? "#define USE_ALPHAHASH" : "", 8475 n.sheen ? "#define USE_SHEEN" : "", 8476 n.sheenColorMap ? "#define USE_SHEEN_COLORMAP" : "", 8477 n.sheenRoughnessMap ? "#define USE_SHEEN_ROUGHNESSMAP" : "", 8478 n.transmission ? "#define USE_TRANSMISSION" : "", 8479 n.transmissionMap ? "#define USE_TRANSMISSIONMAP" : "", 8480 n.thicknessMap ? "#define USE_THICKNESSMAP" : "", 8481 n.vertexTangents && n.flatShading === !1 ? "#define USE_TANGENT" : "", 8482 n.vertexColors || n.instancingColor ? "#define USE_COLOR" : "", 8483 n.vertexAlphas || n.batchingColor ? "#define USE_COLOR_ALPHA" : "", 8484 n.vertexUv1s ? "#define USE_UV1" : "", 8485 n.vertexUv2s ? "#define USE_UV2" : "", 8486 n.vertexUv3s ? "#define USE_UV3" : "", 8487 n.pointsUvs ? "#define USE_POINTS_UV" : "", 8488 n.gradientMap ? "#define USE_GRADIENTMAP" : "", 8489 n.flatShading ? "#define FLAT_SHADED" : "", 8490 n.doubleSided ? "#define DOUBLE_SIDED" : "", 8491 n.flipSided ? "#define FLIP_SIDED" : "", 8492 n.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", 8493 n.shadowMapEnabled ? "#define " + c : "", 8494 n.premultipliedAlpha ? "#define PREMULTIPLIED_ALPHA" : "", 8495 n.numLightProbes > 0 ? "#define USE_LIGHT_PROBES" : "", 8496 n.numLightProbeGrids > 0 ? "#define USE_LIGHT_PROBES_GRID" : "", 8497 n.decodeVideoTexture ? "#define DECODE_VIDEO_TEXTURE" : "", 8498 n.decodeVideoTextureEmissive ? "#define DECODE_VIDEO_TEXTURE_EMISSIVE" : "", 8499 n.logarithmicDepthBuffer ? "#define USE_LOGARITHMIC_DEPTH_BUFFER" : "", 8500 n.reversedDepthBuffer ? "#define USE_REVERSED_DEPTH_BUFFER" : "", 8501 "uniform mat4 viewMatrix;", 8502 "uniform vec3 cameraPosition;", 8503 "uniform bool isOrthographic;", 8504 n.toneMapping === 0 ? "" : "#define TONE_MAPPING", 8505 n.toneMapping === 0 ? "" : Z.tonemapping_pars_fragment, 8506 n.toneMapping === 0 ? "" : Fc("toneMapping", n.toneMapping), 8507 n.dithering ? "#define DITHERING" : "", 8508 n.opaque ? "#define OPAQUE" : "", 8509 Z.colorspace_pars_fragment, 8510 Nc("linearToOutputTexel", n.outputColorSpace), 8511 Lc(), 8512 n.useDepthPacking ? "#define DEPTH_PACKING " + n.depthPacking : "", 8513 "\n" 8514 ].filter(Vc).join("\n")), o = Gc(o), o = Hc(o, n), o = Uc(o, n), s = Gc(s), s = Hc(s, n), s = Uc(s, n), o = Yc(o), s = Yc(s), n.isRawShaderMaterial !== !0 && (v = "#version 300 es\n", g = [ 8515 p, 8516 "#define attribute in", 8517 "#define varying out", 8518 "#define texture2D texture" 8519 ].join("\n") + "\n" + g, _ = [ 8520 "#define varying in", 8521 n.glslVersion === "300 es" ? "" : "layout(location = 0) out highp vec4 pc_fragColor;", 8522 n.glslVersion === "300 es" ? "" : "#define gl_FragColor pc_fragColor", 8523 "#define gl_FragDepthEXT gl_FragDepth", 8524 "#define texture2D texture", 8525 "#define textureCube texture", 8526 "#define texture2DProj textureProj", 8527 "#define texture2DLodEXT textureLod", 8528 "#define texture2DProjLodEXT textureProjLod", 8529 "#define textureCubeLodEXT textureLod", 8530 "#define texture2DGradEXT textureGrad", 8531 "#define texture2DProjGradEXT textureProjGrad", 8532 "#define textureCubeGradEXT textureGrad" 8533 ].join("\n") + "\n" + _); 8534 let y = v + g + o, b = v + _ + s, x = Ec(i, i.VERTEX_SHADER, y), S = Ec(i, i.FRAGMENT_SHADER, b); 8535 i.attachShader(h, x), i.attachShader(h, S), n.index0AttributeName === void 0 ? n.hasPositionAttribute === !0 && i.bindAttribLocation(h, 0, "position") : i.bindAttribLocation(h, 0, n.index0AttributeName), i.linkProgram(h); 8536 function C(t) { 8537 if (e.debug.checkShaderErrors) { 8538 let n = i.getProgramInfoLog(h) || "", r = i.getShaderInfoLog(x) || "", a = i.getShaderInfoLog(S) || "", o = n.trim(), s = r.trim(), c = a.trim(), l = !0, u = !0; 8539 if (i.getProgramParameter(h, i.LINK_STATUS) === !1) if (l = !1, typeof e.debug.onSha
8539derError == "function") e.debug.onShaderError(i, h, x, S); 8540 else { 8541 let e = Mc(i, x, "vertex"), n = Mc(i, S, "fragment"); 8542 V("WebGLProgram: Shader Error " + i.getError() + " - VALIDATE_STATUS " + i.getProgramParameter(h, i.VALIDATE_STATUS) + "\n\nMaterial Name: " + t.name + "\nMaterial Type: " + t.type + "\n\nProgram Info Log: " + o + "\n" + e + "\n" + n); 8543 } 8544 else o === "" ? (s === "" || c === "") && (u = !1) : B("WebGLProgram: Program Info Log:", o); 8545 u && (t.diagnostics = { 8546 runnable: l, 8547 programLog: o, 8548 vertexShader: { 8549 log: s, 8550 prefix: g 8551 }, 8552 fragmentShader: { 8553 log: c, 8554 prefix: _ 8555 } 8556 }); 8557 } 8558 i.deleteShader(x), i.deleteShader(S), w = new Tc(i, h), T = Bc(i, h); 8559 } 8560 let w; 8561 this.getUniforms = function() { 8562 return w === void 0 && C(this), w; 8563 }; 8564 let T; 8565 this.getAttributes = function() { 8566 return T === void 0 && C(this), T; 8567 }; 8568 let E = n.rendererExtensionParallelShaderCompile === !1; 8569 return this.isReady = function() { 8570 return E === !1 && (E = i.getProgramParameter(h, Dc)), E; 8571 }, this.destroy = function() { 8572 r.releaseStatesOfProgram(this), i.deleteProgram(h), this.program = void 0; 8573 }, this.type = n.shaderType, this.name = n.shaderName, this.id = Oc++, this.cacheKey = t, this.usedTimes = 1, this.program = h, this.vertexShader = x, this.fragmentShader = S, this; 8574} 8575var cl = 0, ll = class { 8576 constructor() { 8577 this.shaderCache = /* @__PURE__ */ new Map(), this.materialCache = /* @__PURE__ */ new Map(); 8578 } 8579 update(e, t, n) { 8580 let r = this._getShaderCacheForMaterial(e); 8581 return r.has(t) === !1 && (r.add(t), t.usedTimes++), r.has(n) === !1 && (r.add(n), n.usedTimes++), this; 8582 } 8583 remove(e) { 8584 let t = this.materialCache.get(e); 8585 for (let e of t) e.usedTimes--, e.usedTimes === 0 && this.shaderCache.delete(e.code); 8586 return this.materialCache.delete(e), this; 8587 } 8588 getVertexShaderStage(e) { 8589 return this._getShaderStage(e.vertexShader); 8590 } 8591 getFragmentShaderStage(e) { 8592 return this._getShaderStage(e.fragmentShader); 8593 } 8594 dispose() { 8595 this.shaderCache.clear(), this.materialCache.clear(); 8596 } 8597 _getShaderCacheForMaterial(e) { 8598 let t = this.materialCache, n = t.get(e); 8599 return n === void 0 && (n = /* @__PURE__ */ new Set(), t.set(e, n)), n; 8600 } 8601 _getShaderStage(e) { 8602 let t = this.shaderCache, n = t.get(e); 8603 return n === void 0 && (n = new ul(e), t.set(e, n)), n; 8604 } 8605}, ul = class { 8606 constructor(e) { 8607 this.id = cl++, this.code = e, this.usedTimes = 0; 8608 } 8609}; 8610function dl(e) { 8611 return e === 1030 || e === 37490 || e === 36285; 8612} 8613function fl(e, t, n, r, i, a) { 8614 let o = new Hn(), s = new ll(), c = /* @__PURE__ */ new Set(), l = [], u = /* @__PURE__ */ new Map(), d = r.logarithmicDepthBuffer, f = r.precision, p = { 8615 MeshDepthMaterial: "depth", 8616 MeshDistanceMaterial: "distance", 8617 MeshNormalMaterial: "normal", 8618 MeshBasicMaterial: "basic", 8619 MeshLambertMaterial: "lambert", 8620 MeshPhongMaterial: "phong", 8621 MeshToonMaterial: "toon", 8622 MeshStandardMaterial: "physical", 8623 MeshPhysicalMaterial: "physical", 8624 MeshMatcapMaterial: "matcap", 8625 LineBasicMaterial: "basic", 8626 LineDashedMaterial: "dashed", 8627 PointsMaterial: "points", 8628 ShadowMaterial: "shadow", 8629 SpriteMaterial: "sprite" 8630 }; 8631 function m(e) { 8632 return c.add(e), e === 0 ? "uv" : `uv${e}`; 8633 } 8634 function h(i, o, l, u, h, g) { 8635 let _ = u.fog, v = h.geometry, y = i.isMeshStandardMaterial || i.isMeshLambertMaterial || i.isMeshPhongMaterial ? u.environment : null, b = i.isMeshStandardMaterial || i.isMeshLambertMaterial && !i.envMap || i.isMeshPhongMaterial && !i.envMap, x = t.get(i.envMap || y, b), S = x && x.mapping === 306 ? x.image.height : null, C = p[i.type]; 8636 i.precision !== null && (f = r.getMaxPrecision(i.precision), f !== i.precision && B("WebGLProgram.getParameters:", i.precision, "not supported, using", f, "instead.")); 8637 let w = v.morphAttributes.position || v.morphAttributes.normal || v.morphAttributes.color, T = w === void 0 ? 0 : w.length, E = 0; 8638 v.morphAttributes.position !== void 0 && (E = 1), v.morphAttributes.normal !== void 0 && (E = 2), v.morphAttributes.color !== void 0 && (E = 3); 8639 let D, O, k, A; 8640 if (C) { 8641 let e = Po[C]; 8642 D = e.vertexShader, O = e.fragmentShader; 8643 } else { 8644 D = i.vertexShader, O = i.fragmentShader; 8645 let e = s.getVertexShaderStage(i), t = s.getFragmentShaderStage(i); 8646 s.update(i, e, t), k = e.id, A = t.id; 8647 } 8648 let ee = e.getRenderTarget(), te = e.state.buffers.depth.getReversed(), j = h.isInstancedMesh === !0, ne = h.isBatchedMesh === !0, re = !!i.map, M = !!i.matcap, ie = !!x, ae = !!i.aoMap, oe = !!i.lightMap, se = !!i.bumpMap && i.wireframe === !1, N = !!i.normalMap, ce = !!i.displacementMap, le = !!i.emissiveMap, P = !!i.metalnessMap, ue = !!i.roughnessMap, de = i.anisotropy > 0, fe = i.clearcoat > 0, pe = i.dispersion > 0, me = i.iridescence > 0, he = i.sheen > 0, ge = i.transmission > 0, _e = de && !!i.anisotropyMap, ve = fe && !!i.clearcoatMap, ye = fe && !!i.clearcoatNormalMap, be = fe && !!i.clearcoatRoughnessMap, xe = me && !!i.iridescenceMap, Se = me && !!i.iridescenceThicknessMap, Ce = he && !!i.sheenColorMap, we = he && !!i.sheenRoughnessMap, Te = !!i.specularMap, Ee = !!i.specularColorMap, De = !!i.specularIntensityMap, Oe = ge && !!i.transmissionMap, ke = ge && !!i.thicknessMap, Ae = !!i.gradientMap, je = !!i.alphaMap, F = i.alph
vendor: 4,895 bytes, lines 8648-8770
8648aTest > 0, Me = !!i.alphaHash, Ne = !!i.extensions, Pe = 0; 8649 i.toneMapped && (ee === null || ee.isXRRenderTarget === !0) && (Pe = e.toneMapping); 8650 let I = { 8651 shaderID: C, 8652 shaderType: i.type, 8653 shaderName: i.name, 8654 vertexShader: D, 8655 fragmentShader: O, 8656 defines: i.defines, 8657 customVertexShaderID: k, 8658 customFragmentShaderID: A, 8659 isRawShaderMaterial: i.isRawShaderMaterial === !0, 8660 glslVersion: i.glslVersion, 8661 precision: f, 8662 batching: ne, 8663 batchingColor: ne && h._colorsTexture !== null, 8664 instancing: j, 8665 instancingColor: j && h.instanceColor !== null, 8666 instancingMorph: j && h.morphTexture !== null, 8667 outputColorSpace: ee === null ? e.outputColorSpace : ee.isXRRenderTarget === !0 ? ee.texture.colorSpace : q.workingColorSpace, 8668 alphaToCoverage: !!i.alphaToCoverage, 8669 map: re, 8670 matcap: M, 8671 envMap: ie, 8672 envMapMode: ie && x.mapping, 8673 envMapCubeUVHeight: S, 8674 aoMap: ae, 8675 lightMap: oe, 8676 bumpMap: se, 8677 normalMap: N, 8678 displacementMap: ce, 8679 emissiveMap: le, 8680 normalMapObjectSpace: N && i.normalMapType === 1, 8681 normalMapTangentSpace: N && i.normalMapType === 0, 8682 packedNormalMap: N && i.normalMapType === 0 && dl(i.normalMap.format), 8683 metalnessMap: P, 8684 roughnessMap: ue, 8685 anisotropy: de, 8686 anisotropyMap: _e, 8687 clearcoat: fe, 8688 clearcoatMap: ve, 8689 clearcoatNormalMap: ye, 8690 clearcoatRoughnessMap: be, 8691 dispersion: pe, 8692 iridescence: me, 8693 iridescenceMap: xe, 8694 iridescenceThicknessMap: Se, 8695 sheen: he, 8696 sheenColorMap: Ce, 8697 sheenRoughnessMap: we, 8698 specularMap: Te, 8699 specularColorMap: Ee, 8700 specularIntensityMap: De, 8701 transmission: ge, 8702 transmissionMap: Oe, 8703 thicknessMap: ke, 8704 gradientMap: Ae, 8705 opaque: i.transparent === !1 && i.blending === 1 && i.alphaToCoverage === !1, 8706 alphaMap: je, 8707 alphaTest: F, 8708 alphaHash: Me, 8709 combine: i.combine, 8710 mapUv: re && m(i.map.channel), 8711 aoMapUv: ae && m(i.aoMap.channel), 8712 lightMapUv: oe && m(i.lightMap.channel), 8713 bumpMapUv: se && m(i.bumpMap.channel), 8714 normalMapUv: N && m(i.normalMap.channel), 8715 displacementMapUv: ce && m(i.displacementMap.channel), 8716 emissiveMapUv: le && m(i.emissiveMap.channel), 8717 metalnessMapUv: P && m(i.metalnessMap.channel), 8718 roughnessMapUv: ue && m(i.roughnessMap.channel), 8719 anisotropyMapUv: _e && m(i.anisotropyMap.channel), 8720 clearcoatMapUv: ve && m(i.clearcoatMap.channel), 8721 clearcoatNormalMapUv: ye && m(i.clearcoatNormalMap.channel), 8722 clearcoatRoughnessMapUv: be && m(i.clearcoatRoughnessMap.channel), 8723 iridescenceMapUv: xe && m(i.iridescenceMap.channel), 8724 iridescenceThicknessMapUv: Se && m(i.iridescenceThicknessMap.channel), 8725 sheenColorMapUv: Ce && m(i.sheenColorMap.channel), 8726 sheenRoughnessMapUv: we && m(i.sheenRoughnessMap.channel), 8727 specularMapUv: Te && m(i.specularMap.channel), 8728 specularColorMapUv: Ee && m(i.specularColorMap.channel), 8729 specularIntensityMapUv: De && m(i.specularIntensityMap.channel), 8730 transmissionMapUv: Oe && m(i.transmissionMap.channel), 8731 thicknessMapUv: ke && m(i.thicknessMap.channel), 8732 alphaMapUv: je && m(i.alphaMap.channel), 8733 vertexTangents: !!v.attributes.tangent && (N || de), 8734 vertexNormals: !!v.attributes.normal, 8735 vertexColors: i.vertexColors, 8736 vertexAlphas: i.vertexColors === !0 && !!v.attributes.color && v.attributes.color.itemSize === 4, 8737 pointsUvs: h.isPoints === !0 && !!v.attributes.uv && (re || je), 8738 fog: !!_, 8739 useFog: i.fog === !0, 8740 fogExp2: !!_ && _.isFogExp2, 8741 flatShading: i.wireframe === !1 && (i.flatShading === !0 || v.attributes.normal === void 0 && N === !1 && (i.isMeshLambertMaterial || i.isMeshPhongMaterial || i.isMeshStandardMaterial || i.isMeshPhysicalMaterial)), 8742 sizeAttenuation: i.sizeAttenuation === !0, 8743 logarithmicDepthBuffer: d, 8744 reversedDepthBuffer: te, 8745 skinning: h.isSkinnedMesh === !0, 8746 hasPositionAttribute: v.attributes.position !== void 0, 8747 morphTargets: v.morphAttributes.position !== void 0, 8748 morphNormals: v.morphAttributes.normal !== void 0, 8749 morphColors: v.morphAttributes.color !== void 0, 8750 morphTargetsCount: T, 8751 morphTextureStride: E, 8752 numDirLights: o.directional.length, 8753 numPointLights: o.point.length, 8754 numSpotLights: o.spot.length, 8755 numSpotLightMaps: o.spotLightMap.length, 8756 numRectAreaLights: o.rectArea.length, 8757 numHemiLights: o.hemi.length, 8758 numDirLightShadows: o.directionalShadowMap.length, 8759 numPointLightShadows: o.pointShadowMap.length, 8760 numSpotLightShadows: o.spotShadowMap.length, 8761 numSpotLightShadowsWithMaps: o.numSpotLightShadowsWithMaps, 8762 numLightProbes: o.numLightProbes, 8763 numLightProbeGrids: g.length, 8764 numClippingPlanes: a.numPlanes, 8765 numClipIntersection: a.numIntersection, 8766 dithering: i.dithering, 8767 shadowMapEnabled: e.shadowMap.enabled && l.length > 0, 8768 shadowMapType: e.shadowMap.type, 8769 toneMapping: Pe, 8770 decodeVideoTexture: re && i.map.isVideoTexture === !0 && q.getTransfer(i.map.colorSpace)
8770=== "srgb", 8771 decodeVideoTextureEmissive: le && i.emissiveMap.isVideoTexture === !0 && q.getTransfer(i.emissiveMap.colorSpace) === "srgb", 8772 premultipliedAlpha: i.premultipliedAlpha, 8773 doubleSided: i.side === 2, 8774 flipSided: i.side === 1, 8775 useDepthPacking: i.depthPacking >= 0, 8776 depthPacking: i.depthPacking || 0, 8777 index0AttributeName: i.index0AttributeName, 8778 extensionClipCullDistance: Ne && i.extensions.clipCullDistance === !0 && n.has("WEBGL_clip_cull_distance"), 8779 extensionMultiDraw: (Ne && i.extensions.multiDraw === !0 || ne) && n.has("WEBGL_multi_draw"), 8780 rendererExtensionParallelShaderCompile: n.has("KHR_parallel_shader_compile"), 8781 customProgramCacheKey: i.customProgramCacheKey() 8782 }; 8783 return I.vertexUv1s = c.has(1), I.vertexUv2s = c.has(2), I.vertexUv3s = c.has(3), c.clear(), I; 8784 } 8785 function g(t) { 8786 let n = []; 8787 if (t.shaderID ? n.push(t.shaderID) : (n.push(t.customVertexShaderID), n.push(t.customFragmentShaderID)), t.defines !== void 0) for (let e in t.defines) n.push(e), n.push(t.defines[e]); 8788 return t.isRawShaderMaterial === !1 && (_(n, t), v(n, t), n.push(e.outputColorSpace)), n.push(t.customProgramCacheKey), n.join(); 8789 } 8790 function _(e, t) { 8791 e.push(t.precision), e.push(t.outputColorSpace), e.push(t.envMapMode), e.push(t.envMapCubeUVHeight), e.push(t.mapUv), e.push(t.alphaMapUv), e.push(t.lightMapUv), e.push(t.aoMapUv), e.push(t.bumpMapUv), e.push(t.normalMapUv), e.push(t.displacementMapUv), e.push(t.emissiveMapUv), e.push(t.metalnessMapUv), e.push(t.roughnessMapUv), e.push(t.anisotropyMapUv), e.push(t.clearcoatMapUv), e.push(t.clearcoatNormalMapUv), e.push(t.clearcoatRoughnessMapUv), e.push(t.iridescenceMapUv), e.push(t.iridescenceThicknessMapUv), e.push(t.sheenColorMapUv), e.push(t.sheenRoughnessMapUv), e.push(t.specularMapUv), e.push(t.specularColorMapUv), e.push(t.specularIntensityMapUv), e.push(t.transmissionMapUv), e.push(t.thicknessMapUv), e.push(t.combine), e.push(t.fogExp2), e.push(t.sizeAttenuation), e.push(t.morphTargetsCount), e.push(t.morphAttributeCount), e.push(t.numDirLights), e.push(t.numPointLights), e.push(t.numSpotLights), e.push(t.numSpotLightMaps), e.push(t.numHemiLights), e.push(t.numRectAreaLights), e.push(t.numDirLightShadows), e.push(t.numPointLightShadows), e.push(t.numSpotLightShadows), e.push(t.numSpotLightShadowsWithMaps), e.push(t.numLightProbes), e.push(t.shadowMapType), e.push(t.toneMapping), e.push(t.numClippingPlanes), e.push(t.numClipIntersection), e.push(t.depthPacking); 8792 } 8793 function v(e, t) { 8794 o.disableAll(), t.instancing && o.enable(0), t.instancingColor && o.enable(1), t.instancingMorph && o.enable(2), t.matcap && o.enable(3), t.envMap && o.enable(4), t.normalMapObjectSpace && o.enable(5), t.normalMapTangentSpace && o.enable(6), t.clearcoat && o.enable(7), t.iridescence && o.enable(8), t.alphaTest && o.enable(9), t.vertexColors && o.enable(10), t.vertexAlphas && o.enable(11), t.vertexUv1s && o.enable(12), t.vertexUv2s && o.enable(13), t.vertexUv3s && o.enable(14), t.vertexTangents && o.enable(15), t.anisotropy && o.enable(16), t.alphaHash && o.enable(17), t.batching && o.enable(18), t.dispersion && o.enable(19), t.batchingColor && o.enable(20), t.gradientMap && o.enable(21), t.packedNormalMap && o.enable(22), t.vertexNormals && o.enable(23), e.push(o.mask), o.disableAll(), t.fog && o.enable(0), t.useFog && o.enable(1), t.flatShading && o.enable(2), t.logarithmicDepthBuffer && o.enable(3), t.reversedDepthBuffer && o.enable(4), t.skinning && o.enable(5), t.morphTargets && o.enable(6), t.morphNormals && o.enable(7), t.morphColors && o.enable(8), t.premultipliedAlpha && o.enable(9), t.shadowMapEnabled && o.enable(10), t.doubleSided && o.enable(11), t.flipSided && o.enable(12), t.useDepthPacking && o.enable(13), t.dithering && o.enable(14), t.transmission && o.enable(15), t.sheen && o.enable(16), t.opaque && o.enable(17), t.pointsUvs && o.enable(18), t.decodeVideoTexture && o.enable(19), t.decodeVideoTextureEmissive && o.enable(20), t.alphaToCoverage && o.enable(21), t.numLightProbeGrids > 0 && o.enable(22), t.hasPositionAttribute && o.enable(23), e.push(o.mask); 8795 } 8796 function y(e) { 8797 let t = p[e.type], n; 8798 if (t) { 8799 let e = Po[t]; 8800 n = Ca.clone(e.uniforms); 8801 } else n = e.uniforms; 8802 return n; 8803 } 8804 function b(t, n) { 8805 let r = u.get(n); 8806 return r === void 0 ? (r = new sl(e, n, t, i), l.push(r), u.set(n, r)) : ++r.usedTimes, r; 8807 } 8808 function x(e) { 8809 if (--e.usedTimes === 0) { 8810 let t = l.indexOf(e);
8811 l[t] = l[l.length - 1], l.pop(), u.delete(e.cacheKey), e.destroy(); 8812 } 8813 } 8814 function S(e) { 8815 s.remove(e); 8816 } 8817 function C() { 8818 s.dispose(); 8819 } 8820 return { 8821 getParameters: h, 8822 getProgramCacheKey: g, 8823 getUniforms: y, 8824 acquireProgram: b, 8825 releaseProgram: x, 8826 releaseShaderCache: S, 8827 programs: l, 8828 dispose: C 8829 }; 8830} 8831function pl() { 8832 let e = /* @__PURE__ */ new WeakMap(); 8833 function t(t) { 8834 return e.has(t); 8835 } 8836 function n(t) { 8837 let n = e.get(t); 8838 return n === void 0 && (n = {}, e.set(t, n)), n; 8839 } 8840 function r(t) { 8841 e.delete(t); 8842 } 8843 function i(t, n, r) { 8844 e.get(t)[n] = r; 8845 } 8846 function a() { 8847 e = /* @__PURE__ */ new WeakMap(); 8848 } 8849 return { 8850 has: t, 8851 get: n, 8852 remove: r, 8853 update: i, 8854 dispose: a 8855 }; 8856} 8857function ml(e, t) { 8858 return e.groupOrder === t.groupOrder ? e.renderOrder === t.renderOrder ? e.material.id === t.material.id ? e.materialVariant === t.materialVariant ? e.z === t.z ? e.id - t.id : e.z - t.z : e.materialVariant - t.materialVariant : e.material.id - t.material.id : e.renderOrder - t.renderOrder : e.groupOrder - t.groupOrder; 8859} 8860function hl(e, t) { 8861 return e.groupOrder === t.groupOrder ? e.renderOrder === t.renderOrder ? e.z === t.z ? e.id - t.id : t.z - e.z : e.renderOrder - t.renderOrder : e.groupOrder - t.groupOrder; 8862} 8863function gl() { 8864 let e = [], t = 0, n = [], r = [], i = []; 8865 function a() { 8866 t = 0, n.length = 0, r.length = 0, i.length = 0; 8867 } 8868 function o(e) { 8869 let t = 0; 8870 return e.isInstancedMesh && (t += 2), e.isSkinnedMesh && (t += 1), t; 8871 } 8872 function s(n, r, i, a, s, c) { 8873 let l = e[t]; 8874 return l === void 0 ? (l = { 8875 id: n.id, 8876 object: n, 8877 geometry: r, 8878 material: i, 8879 materialVariant: o(n), 8880 groupOrder: a, 8881 renderOrder: n.renderOrder, 8882 z: s, 8883 group: c 8884 }, e[t] = l) : (l.id = n.id, l.object = n, l.geometry = r, l.material = i, l.materialVariant = o(n), l.groupOrder = a, l.renderOrder = n.renderOrder, l.z = s, l.group = c), t++, l; 8885 } 8886 function c(e, t, a, o, c, l) { 8887 let u = s(e, t, a, o, c, l); 8888 a.transmission > 0 ? r.push(u) : a.transparent === !0 ? i.push(u) : n.push(u); 8889 } 8890 function l(e, t, a, o, c, l) { 8891 let u = s(e, t, a, o, c, l); 8892 a.transmission > 0 ? r.unshift(u) : a.transparent === !0 ? i.unshift(u) : n.unshift(u); 8893 } 8894 function u(e, t, a) { 8895 n.length > 1 && n.sort(e || ml), r.length > 1 && r.sort(t || hl), i.length > 1 && i.sort(t || hl), a && (n.reverse(), r.reverse(), i.reverse()); 8896 } 8897 function d() { 8898 for (let n = t, r = e.length; n < r; n++) { 8899 let t = e[n]; 8900 if (t.id === null) break; 8901 t.id = null, t.object = null, t.geometry = null, t.material = null, t.group = null; 8902 } 8903 } 8904 return { 8905 opaque: n, 8906 transmissive: r, 8907 transparent: i, 8908 init: a, 8909 push: c, 8910 unshift: l, 8911 finish: d, 8912 sort: u 8913 }; 8914} 8915function _l() { 8916 let e = /* @__PURE__ */ new WeakMap(); 8917 function t(t, n) { 8918 let r = e.get(t), i; 8919 return r === void 0 ? (i = new gl(), e.set(t, [i])) : n >= r.length ? (i = new gl(), r.push(i)) : i = r[n], i; 8920 } 8921 function n() { 8922 e = /* @__PURE__ */ new WeakMap(); 8923 } 8924 return { 8925 get: t, 8926 dispose: n 8927 }; 8928} 8929function vl() { 8930 let e = {}; 8931 return { get: function(t) { 8932 if (e[t.id] !== void 0) return e[t.id]; 8933 let n; 8934 switch (t.type) { 8935 case "DirectionalLight": 8936 n = { 8937 direction: new G(), 8938 color: new Y() 8939 }; 8940 break; 8941 case "SpotLight": 8942 n = { 8943 position: new G(), 8944 direction: new G(), 8945 color: new Y(), 8946 distance: 0, 8947 coneCos: 0, 8948 penumbraCos: 0, 8949 decay: 0 8950 }; 8951 break; 8952 case "PointLight": 8953 n = { 8954 position: new G(), 8955 color: new Y(), 8956 distance: 0, 8957 decay: 0 8958 }; 8959 break; 8960 case "HemisphereLight": 8961 n = { 8962 direction: new G(), 8963 skyColor: new Y(), 8964 groundColor: new Y() 8965 }; 8966 break; 8967 case "RectAreaLight": 8968 n = { 8969 color: new Y(), 8970 position: new G(), 8971 halfWidth: new G(), 8972 halfHeight: new G() 8973 }; 8974 break; 8975 } 8976 return e[t.id] = n, n; 8977 } }; 8978} 8979function yl() { 8980 let e = {}; 8981 return { get: function(t) { 8982 if (e[t.id] !== void 0) return e[t.id]; 8983 let n; 8984 switch (t.type) { 8985 case "DirectionalLight": 8986 n = { 8987 shadowIntensity: 1, 8988 shadowBias: 0, 8989 shadowNormalBias: 0, 8990 shadowRadius: 1, 8991 shadowMapSize: new W() 8992 }; 8993 break; 8994 case "SpotLight": 8995 n = { 8996 shadowIntensity: 1, 8997 shadowBias: 0, 8998 shadowNormalBias: 0, 8999 shadowRadius: 1, 9000 shadowMapSize: new W() 9001 }; 9002 break; 9003 case "PointLight": 9004 n = { 9005 shadowIntensity: 1, 9006 shadowBias: 0, 9007 shadowNormalBias: 0, 9008 shadowRadius: 1, 9009 shadowMapSize: new W(), 9010 shadowCameraNear: 1, 9011 shadowCameraFar: 1e3 9012 }; 9013 break; 9014 } 9015 return e[t.id] = n, n; 9016 } }; 9017} 9018var bl = 0; 9019function xl(e, t) { 9020 return (t.castShadow ? 2 : 0) - (e.castShadow ? 2 : 0) + +!!t.map - !!e.map; 9021} 9022function Sl(e) { 9023 let t = new vl(), n = yl(), r = { 9024 version: 0, 9025 hash: { 9026 directionalLength: -1, 9027 pointLength: -1, 9028 spotLength: -1, 9029 rectAreaLength: -1, 9030 hemiLength: -1, 9031 numDirectionalShadows: -1, 9032 numPointShadows: -1, 9033 numSpotShadows: -1, 9034 numSpotMaps: -1, 9035 numLightProbes: -1 9036 }, 9037 ambient: [ 9038 0, 9039 0, 9040 0 9041 ], 9042 probe: [], 9043 directional: [], 9044 directionalShadow: [], 9045 directionalShadowMap: [], 9046 directionalShadowMatrix: [], 9047 spot: [], 9048 spotLightMap: [], 9049 spotShadow: [], 9050 spotShadowMap: [], 9051 spotLightMatrix: [], 9052 rectArea: [], 9053 rectAreaLTC1: null, 9054 rectAreaLTC2: null, 9055 point: [], 9056 pointShadow: [], 9057 pointShadowMap: [], 9058 pointShadowMatrix: [], 9059 hemi: [], 9060 numSpotLightShadowsWithMaps: 0, 9061 numLightProbes: 0 9062 }; 9063 for (let e = 0; e < 9; e++) r.probe.push(new G()); 9064 let i = new G(), a = new jn(), o = new jn(); 9065 function s(i) { 9066 let a = 0, o = 0, s = 0; 9067 for (let e = 0; e < 9; e++) r.probe[e].set(0, 0, 0); 9068 let c = 0, l = 0, u = 0, d = 0, f = 0, p = 0, m = 0, h = 0, g = 0, _ = 0, v = 0; 9069 i.sort(xl); 9070 for (let e = 0, y = i.length; e < y; e++) { 9071 let y = i[e], b = y.color, x = y.intensity, S = y.distance, C = null; 9072 if (y.shadow && y.shadow.map && (C = y.shadow.map.texture.format === 1030 ? y.shadow.map.texture : y.shadow.map.depthTexture || y.shadow.map.texture), y.isAmbientLight) a += b.r * x, o += b.g * x, s += b.b * x; 9073 else if (y.isLightProbe) { 9074 for (let e = 0; e < 9; e++) r.probe[e].addScaledVector(y.sh.coefficients[e], x);
9075 v++; 9076 } else if (y.isDirectionalLight) { 9077 let e = t.get(y); 9078 if (e.color.copy(y.color).multiplyScalar(y.intensity), y.castShadow) { 9079 let e = y.shadow, t = n.get(y); 9080 t.shadowIntensity = e.intensity, t.shadowBias = e.bias, t.shadowNormalBias = e.normalBias, t.shadowRadius = e.radius, t.shadowMapSize = e.mapSize, r.directionalShadow[c] = t, r.directionalShadowMap[c] = C, r.directionalShadowMatrix[c] = y.shadow.matrix, p++; 9081 } 9082 r.directional[c] = e, c++; 9083 } else if (y.isSpotLight) { 9084 let e = t.get(y); 9085 e.position.setFromMatrixPosition(y.matrixWorld), e.color.copy(b).multiplyScalar(x), e.distance = S, e.coneCos = Math.cos(y.angle), e.penumbraCos = Math.cos(y.angle * (1 - y.penumbra)), e.decay = y.decay, r.spot[u] = e; 9086 let i = y.shadow; 9087 if (y.map && (r.spotLightMap[g] = y.map, g++, i.updateMatrices(y), y.castShadow && _++), r.spotLightMatrix[u] = i.matrix, y.castShadow) { 9088 let e = n.get(y); 9089 e.shadowIntensity = i.intensity, e.shadowBias = i.bias, e.shadowNormalBias = i.normalBias, e.shadowRadius = i.radius, e.shadowMapSize = i.mapSize, r.spotShadow[u] = e, r.spotShadowMap[u] = C, h++; 9090 } 9091 u++; 9092 } else if (y.isRectAreaLight) { 9093 let e = t.get(y); 9094 e.color.copy(b).multiplyScalar(x), e.halfWidth.set(y.width * .5, 0, 0), e.halfHeight.set(0, y.height * .5, 0), r.rectArea[d] = e, d++; 9095 } else if (y.isPointLight) { 9096 let e = t.get(y); 9097 if (e.color.copy(y.color).multiplyScalar(y.intensity), e.distance = y.distance, e.decay = y.decay, y.castShadow) { 9098 let e = y.shadow, t = n.get(y); 9099 t.shadowIntensity = e.intensity, t.shadowBias = e.bias, t.shadowNormalBias = e.normalBias, t.shadowRadius = e.radius, t.shadowMapSize = e.mapSize, t.shadowCameraNear = e.camera.near, t.shadowCameraFar = e.camera.far, r.pointShadow[l] = t, r.pointShadowMap[l] = C, r.pointShadowMatrix[l] = y.shadow.matrix, m++; 9100 } 9101 r.point[l] = e, l++; 9102 } else if (y.isHemisphereLight) { 9103 let e = t.get(y); 9104 e.skyColor.copy(y.color).multiplyScalar(x), e.groundColor.copy(y.groundColor).multiplyScalar(x), r.hemi[f] = e, f++; 9105 } 9106 } 9107 d > 0 && (e.has("OES_texture_float_linear") === !0 ? (r.rectAreaLTC1 = Q.LTC_FLOAT_1, r.rectAreaLTC2 = Q.LTC_FLOAT_2) : (r.rectAreaLTC1 = Q.LTC_HALF_1, r.rectAreaLTC2 = Q.LTC_HALF_2)), r.ambient[0] = a, r.ambient[1] = o, r.ambient[2] = s; 9108 let y = r.hash; 9109 (y.directionalLength !== c || y.pointLength !== l || y.spotLength !== u || y.rectAreaLength !== d || y.hemiLength !== f || y.numDirectionalShadows !== p || y.numPointShadows !== m || y.numSpotShadows !== h || y.numSpotMaps !== g || y.numLightProbes !== v) && (r.directional.length = c, r.spot.length = u, r.rectArea.length = d, r.point.length = l, r.hemi.length = f, r.directionalShadow.length = p, r.directionalShadowMap.length = p, r.pointShadow.length = m, r.pointShadowMap.length = m, r.spotShadow.length = h, r.spotShadowMap.length = h, r.directionalShadowMatrix.length = p, r.pointShadowMatrix.length = m, r.spotLightMatrix.length = h + g - _, r.spotLightMap.length = g, r.numSpotLightShadowsWithMaps = _, r.numLightProbes = v, y.directionalLength = c, y.pointLength = l, y.spotLength = u, y.rectAreaLength = d, y.hemiLength = f, y.numDirectionalShadows = p, y.numPointShadows = m, y.numSpotShadows = h, y.numSpotMaps = g, y.numLightProbes = v, r.version = bl++); 9110 } 9111 function c(e, t) { 9112 let n = 0, s = 0, c = 0, l = 0, u = 0, d = t.matrixWorldInverse; 9113 for (let t = 0, f = e.length; t < f; t++) { 9114 let f = e[t]; 9115 if (f.isDirectionalLight) { 9116 let e = r.directional[n]; 9117 e.direction.setFromMatrixPosition(f.matrixWorld), i.setFromMatrixPosition(f.target.matrixWorld), e.direction.sub(i), e.direction.transformDirection(d), n++; 9118 } else if (f.isSpotLight) { 9119 let e = r.spot[c]; 9120 e.position.setFromMatrixPosition(f.matrixWorld), e.position.applyMatrix4(d), e.direction.setFromMatrixPosition(f.matrixWorld), i.setFromMatrixPosition(f.target.matrixWorld), e.direction.sub(i), e.direction.transformDirection(d), c++; 9121 } else if (f.isRectAreaLight) { 9122 let e = r.rectArea[l]; 9123 e.position.setFromMatrixPosition(f.matrixWorld), e.position.applyMatrix4(d), o.identity(), a.copy(f.matrixWorld), a.premultiply(d), o.extractRotation(a), e.halfWidth.set(f.width * .5, 0, 0), e.halfHeight.set(0, f.height * .5, 0), e.halfWidth.applyMatrix4(o), e.halfHeight.applyMatrix4(o), l++; 9124 } else if (f.isPointLight) { 9125 let e = r.point[s]; 9126 e.position.setFromMatrixPosition(f.matrixWorld), e.position.applyMatrix4(d), s++; 9127 } else if (f.isHemisphereLight) { 9128 let e = r.hemi[u]; 9129 e.direction.setFromMatrixPosition(f.matrixWorld), e.direction.transformDirection(d), u++; 9130 } 9131 } 9132 } 9133 return { 9134 setup: s, 9135 setupView: c, 9136 state: r 9137 }; 9138} 9139function Cl(e) { 9140 let t = new Sl(e), n = [], r = [], i = []; 9141 function a(e) { 9142 d.camera = e, n.length = 0, r.length = 0, i.length = 0; 9143 } 9144 function o(e) { 9145 n.push(e); 9146 } 9147 function s(e) { 9148 r.push(e); 9149 } 9150 function c(e) { 9151 i.push(e); 9152 } 9153 function l() { 9154 t.setup(n); 9155 } 9156 function u(e) { 9157 t.setupView(n, e); 9158 } 9159 let d = { 9160 lightsArray: n, 9161 shadowsArray: r, 9162 lightProbeGridArray: i, 9163 camera: null, 9164 lights: t, 9165 transmissionRenderTarget: {}, 9166 textureUnits: 0 9167 }; 9168 return { 9169 init: a, 9170 state: d, 9171 setupLights: l, 9172 setupLightsView: u, 9173 pushLight: o, 9174 pushShadow: s, 9175 pushLightProbeGrid: c 9176 }; 9177} 9178function wl(e) { 9179 let t = /* @__PURE__ */ new WeakMap(); 9180 function n(n, r = 0) { 9181 let i = t.get(n), a; 9182 return i === void 0 ? (a = new Cl(e), t.set(n, [a])) : r >= i.length ? (a = new Cl(e), i.push(a)) : a = i[r], a; 9183 } 9184 function r() { 9185 t = /* @__PURE__ */ new WeakMap(); 9186 } 9187 return { 9188 get: n, 9189 dispose: r 9190 }; 9191} 9192var Tl = "void main() {\n gl_Position = vec4( position, 1.0 );\n}", El = "uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;
9192\nvoid main() {\n const float samples = float( VSM_SAMPLES );\n float mean = 0.0;\n float squared_mean = 0.0;\n float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );\n float uvStart = samples <= 1.0 ? 0.0 : - 1.0;\n for ( float i = 0.0; i < samples; i ++ ) {\n float uvOffset = uvStart + i * uvStride;\n #ifdef HORIZONTAL_PASS\n vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n #else\n float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;\n mean += depth;\n squared_mean += depth * depth;\n #endif\n }\n mean = mean / samples;\n squared_mean = squared_mean / samples;\n float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );\n gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );\n}", Dl = [ 9193 /*@__PURE__*/ new G(1, 0, 0), 9194 /*@__PURE__*/ new G(-1, 0, 0), 9195 /*@__PURE__*/ new G(0, 1, 0), 9196 /*@__PURE__*/ new G(0, -1, 0), 9197 /*@__PURE__*/ new G(0, 0, 1), 9198 /*@__PURE__*/ new G(0, 0, -1) 9199], Ol = [ 9200 /*@__PURE__*/ new G(0, -1, 0), 9201 /*@__PURE__*/ new G(0, -1, 0), 9202 /*@__PURE__*/ new G(0, 0, 1), 9203 /*@__PURE__*/ new G(0, 0, -1), 9204 /*@__PURE__*/ new G(0, -1, 0), 9205 /*@__PURE__*/ new G(0, -1, 0) 9206], kl = /*@__PURE__*/ new jn(), Al = /*@__PURE__*/ new G(), jl = /*@__PURE__*/ new G(); 9207function Ml(e, t, n) { 9208 let r = new Ui(), i = new W(), a = new W(), o = new J(), s = new Oa(), c = new ka(), l = {}, u = n.maxTextureSize, d = { 9209 0: 1, 9210 1: 0, 9211 2: 2 9212 }, f = new Ea({ 9213 defines: { VSM_SAMPLES: 8 }, 9214 uniforms: { 9215 shadow_pass: { value: null }, 9216 resolution: { value: new W() }, 9217 radius: { value: 4 } 9218 }, 9219 vertexShader: Tl, 9220 fragmentShader: El 9221 }), p = f.clone(); 9222 p.defines.HORIZONTAL_PASS = 1; 9223 let m = new oi(); 9224 m.setAttribute("position", new Kr(new Float32Array([ 9225 -1, 9226 -1, 9227 .5, 9228 3, 9229 -1, 9230 .5, 9231 -1, 9232 3, 9233 .5 9234 ]), 3)); 9235 let h = new Mi(m, f), g = this; 9236 this.enabled = !1, this.autoUpdate = !0, this.needsUpdate = !1, this.type = 1; 9237 let _ = this.type; 9238 this.render = function(t, n, s) { 9239 if (g.enabled === !1 || g.autoUpdate === !1 && g.needsUpdate === !1 || t.length === 0) return; 9240 this.type === 2 && (B("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."), this.type = 1); 9241 let c = e.getRenderTarget(), l = e.getActiveCubeFace(), d = e.getActiveMipmapLevel(), f = e.state; 9242 f.setBlending(0), f.buffers.depth.getReversed() === !0 ? f.buffers.color.setClear(0, 0, 0, 0) : f.buffers.color.setClear(1, 1, 1, 1), f.buffers.depth.setTest(!0), f.setScissorTest(!1); 9243 let p = _ !== this.type; 9244 p && n.traverse(function(e) { 9245 e.material && (Array.isArray(e.material) ? e.material.forEach((e) => e.needsUpdate = !0) : e.material.needsUpdate = !0); 9246 }); 9247 for (let c = 0, l = t.length; c < l; c++) { 9248 let l = t[c], d = l.shadow; 9249 if (d === void 0) { 9250 B("WebGLShadowMap:", l, "has no shadow."); 9251 continue; 9252 } 9253 if (d.autoUpdate === !1 && d.needsUpdate === !1) continue; 9254 i.copy(d.mapSize); 9255 let m = d.getFrameExtents(); 9256 i.multiply(m), a.copy(d.mapSize), (i.x > u || i.y > u) && (i.x > u && (a.x = Math.floor(u / m.x), i.x = a.x * m.x, d.mapSize.x = a.x), i.y > u && (a.y = Math.floor(u / m.y), i.y = a.y * m.y, d.mapSize.y = a.y)); 9257 let h = e.state.buffers.depth.getReversed(); 9258 if (d.camera._reversedDepth = h, d.map === null || p === !0) { 9259 if (d.map !== null && (d.map.depthTexture !== null && (d.map.depthTexture.dispose(), d.map.depthTexture = null), d.map.dispose()), this.type === 3) { 9260 if (l.isPointLight) { 9261 B("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead."); 9262 continue; 9263 } 9264 d.map = new On(i.x, i.y, { 9265 format: F, 9266 type: ye, 9267 minFilter: P, 9268 magFilter: P, 9269 generateMipmaps: !1 9270 }), d.map.texture.name = l.name + ".shadowMap", d.map.depthTexture = new da(i.x, i.y, ve), d.map.depthTexture.name = l.name + ".shadowMapDepth", d.map.depthTexture.format = Oe, d.map.depthTexture.compareFunction = null, d.map.depthTexture.minFilter = N, d.map.depthTexture.magFilter = N; 9271 } else l.isPointLight ? (d.map = new ls(i.x), d.map.depthTexture = new fa(i.x, _e)) : (d.map = new On(i.x, i.y), d.map.depthTexture = new da(i.x, i.y, _e)), d.map.depthTexture.name = l.name + ".shadowMap", d.map.depthTexture.format = Oe, this.type === 1 ? (d.map.depthTexture.compareFunction = h ? 518 : 515, d.map.depthTexture.minFilter = P, d.map.depthTexture.magFilter = P) : (d.map.depthTexture.compareFunction = null, d.map.depthTexture.minFilter = N, d.map.depthTexture.magFilter = N); 9272 d.camera.updateProjectionMatrix(); 9273 }
9274 let g = d.map.isWebGLCubeRenderTarget ? 6 : 1; 9275 for (let t = 0; t < g; t++) { 9276 if (d.map.isWebGLCubeRenderTarget) e.setRenderTarget(d.map, t), e.clear(); 9277 else { 9278 t === 0 && (e.setRenderTarget(d.map), e.clear()); 9279 let n = d.getViewport(t); 9280 o.set(a.x * n.x, a.y * n.y, a.x * n.z, a.y * n.w), f.viewport(o); 9281 } 9282 if (l.isPointLight) { 9283 let e = d.camera, n = d.matrix, r = l.distance || e.far; 9284 r !== e.far && (e.far = r, e.updateProjectionMatrix()), Al.setFromMatrixPosition(l.matrixWorld), e.position.copy(Al), jl.copy(e.position), jl.add(Dl[t]), e.up.copy(Ol[t]), e.lookAt(jl), e.updateMatrixWorld(), n.makeTranslation(-Al.x, -Al.y, -Al.z), kl.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse), d._frustum.setFromProjectionMatrix(kl, e.coordinateSystem, e.reversedDepth); 9285 } else d.updateMatrices(l); 9286 r = d.getFrustum(), b(n, s, d.camera, l, this.type); 9287 } 9288 d.isPointLightShadow !== !0 && this.type === 3 && v(d, s), d.needsUpdate = !1; 9289 } 9290 _ = this.type, g.needsUpdate = !1, e.setRenderTarget(c, l, d); 9291 }; 9292 function v(n, r) { 9293 let a = t.update(h); 9294 f.defines.VSM_SAMPLES !== n.blurSamples && (f.defines.VSM_SAMPLES = n.blurSamples, p.defines.VSM_SAMPLES = n.blurSamples, f.needsUpdate = !0, p.needsUpdate = !0), n.mapPass === null && (n.mapPass = new On(i.x, i.y, { 9295 format: F, 9296 type: ye 9297 })), f.uniforms.shadow_pass.value = n.map.depthTexture, f.uniforms.resolution.value = n.mapSize, f.uniforms.radius.value = n.radius, e.setRenderTarget(n.mapPass), e.clear(), e.renderBufferDirect(r, null, a, f, h, null), p.uniforms.shadow_pass.value = n.mapPass.texture, p.uniforms.resolution.value = n.mapSize, p.uniforms.radius.value = n.radius, e.setRenderTarget(n.map), e.clear(), e.renderBufferDirect(r, null, a, p, h, null); 9298 } 9299 function y(t, n, r, i) { 9300 let a = null, o = r.isPointLight === !0 ? t.customDistanceMaterial : t.customDepthMaterial; 9301 if (o !== void 0) a = o; 9302 else if (a = r.isPointLight === !0 ? c : s, e.localClippingEnabled && n.clipShadows === !0 && Array.isArray(n.clippingPlanes) && n.clippingPlanes.length !== 0 || n.displacementMap && n.displacementScale !== 0 || n.alphaMap && n.alphaTest > 0 || n.map && n.alphaTest > 0 || n.alphaToCoverage === !0) { 9303 let e = a.uuid, t = n.uuid, r = l[e]; 9304 r === void 0 && (r = {}, l[e] = r); 9305 let i = r[t]; 9306 i === void 0 && (i = a.clone(), r[t] = i, n.addEventListener("dispose", x)), a = i; 9307 } 9308 if (a.visible = n.visible, a.wireframe = n.wireframe, i === 3 ? a.side = n.shadowSide === null ? n.side : n.shadowSide : a.side = n.shadowSide === null ? d[n.side] : n.shadowSide, a.alphaMap = n.alphaMap, a.alphaTest = n.alphaToCoverage === !0 ? .5 : n.alphaTest, a.map = n.map, a.clipShadows = n.clipShadows, a.clippingPlanes = n.clippingPlanes, a.clipIntersection = n.clipIntersection, a.displacementMap = n.displacementMap, a.displacementScale = n.displacementScale, a.displacementBias = n.displacementBias, a.wireframeLinewidth = n.wireframeLinewidth, a.linewidth = n.linewidth, r.isPointLight === !0 && a.isMeshDistanceMaterial === !0) { 9309 let t = e.properties.get(a); 9310 t.light = r; 9311 } 9312 return a; 9313 } 9314 function b(n, i, a, o, s) { 9315 if (n.visible === !1) return; 9316 if (n.layers.test(i.layers) && (n.isMesh || n.isLine || n.isPoints) && (n.castShadow || n.receiveShadow && s === 3) && (!n.frustumCulled || r.intersectsObject(n))) { 9317 n.modelViewMatrix.multiplyMatrices(a.matrixWorldInverse, n.matrixWorld); 9318 let r = t.update(n), c = n.material; 9319 if (Array.isArray(c)) { 9320 let t = r.groups; 9321 for (let l = 0, u = t.length; l < u; l++) { 9322 let u = t[l], d = c[u.materialIndex]; 9323 if (d && d.visible) { 9324 let t = y(n, d, o, s); 9325 n.onBeforeShadow(e, n, i, a, r, t, u), e.renderBufferDirect(a, null, r, t, n, u), n.onAfterShadow(e, n, i, a, r, t, u); 9326 } 9327 } 9328 } else if (c.visible) { 9329 let t = y(n, c, o, s); 9330 n.onBeforeShadow(e, n, i, a, r, t, null), e.renderBufferDirect(a, null, r, t, n, null), n.onAfterShadow(e, n, i, a, r, t, null); 9331 } 9332 } 9333 let c = n.children; 9334 for (let e = 0, t = c.length; e < t; e++) b(c[e], i, a, o, s); 9335 } 9336 function x(e) { 9337 e.target.removeEventListener("dispose", x); 9338 for (let t in l) { 9339 let n = l[t], r = e.target.uuid; 9340 r in n && (n[r].dispose(), delete n[r]); 9341 } 9342 } 9343} 9344function Nl(e, t) { 9345 function n() {
9346 let t = !1, n = new J(), r = null, i = new J(0, 0, 0, 0); 9347 return { 9348 setMask: function(n) { 9349 r !== n && !t && (e.colorMask(n, n, n, n), r = n); 9350 }, 9351 setLocked: function(e) { 9352 t = e; 9353 }, 9354 setClear: function(t, r, a, o, s) { 9355 s === !0 && (t *= o, r *= o, a *= o), n.set(t, r, a, o), i.equals(n) === !1 && (e.clearColor(t, r, a, o), i.copy(n)); 9356 }, 9357 reset: function() { 9358 t = !1, r = null, i.set(-1, 0, 0, 0); 9359 } 9360 }; 9361 } 9362 function r() { 9363 let n = !1, r = !1, i = null, a = null, o = null; 9364 return { 9365 setReversed: function(e) { 9366 if (r !== e) { 9367 let n = t.get("EXT_clip_control"); 9368 e ? n.clipControlEXT(n.LOWER_LEFT_EXT, n.ZERO_TO_ONE_EXT) : n.clipControlEXT(n.LOWER_LEFT_EXT, n.NEGATIVE_ONE_TO_ONE_EXT), r = e; 9369 let i = o; 9370 o = null, this.setClear(i); 9371 } 9372 }, 9373 getReversed: function() { 9374 return r; 9375 }, 9376 setTest: function(t) { 9377 t ? P(e.DEPTH_TEST) : ue(e.DEPTH_TEST); 9378 }, 9379 setMask: function(t) { 9380 i !== t && !n && (e.depthMask(t), i = t); 9381 }, 9382 setFunc: function(t) { 9383 if (r && (t = It[t]), a !== t) { 9384 switch (t) { 9385 case 0: 9386 e.depthFunc(e.NEVER); 9387 break; 9388 case 1: 9389 e.depthFunc(e.ALWAYS); 9390 break; 9391 case 2: 9392 e.depthFunc(e.LESS); 9393 break; 9394 case 3: 9395 e.depthFunc(e.LEQUAL); 9396 break; 9397 case 4: 9398 e.depthFunc(e.EQUAL); 9399 break; 9400 case 5: 9401 e.depthFunc(e.GEQUAL); 9402 break; 9403 case 6: 9404 e.depthFunc(e.GREATER); 9405 break; 9406 case 7: 9407 e.depthFunc(e.NOTEQUAL); 9408 break; 9409 default: e.depthFunc(e.LEQUAL); 9410 } 9411 a = t; 9412 } 9413 }, 9414 setLocked: function(e) { 9415 n = e; 9416 }, 9417 setClear: function(t) { 9418 o !== t && (o = t, r && (t = 1 - t), e.clearDepth(t)); 9419 }, 9420 reset: function() { 9421 n = !1, i = null, a = null, o = null, r = !1; 9422 } 9423 }; 9424 } 9425 function i() { 9426 let t = !1, n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = null; 9427 return { 9428 setTest: function(n) {
9429 t || (n ? P(e.STENCIL_TEST) : ue(e.STENCIL_TEST)); 9430 }, 9431 setMask: function(r) { 9432 n !== r && !t && (e.stencilMask(r), n = r); 9433 }, 9434 setFunc: function(t, n, o) { 9435 (r !== t || i !== n || a !== o) && (e.stencilFunc(t, n, o), r = t, i = n, a = o); 9436 }, 9437 setOp: function(t, n, r) { 9438 (o !== t || s !== n || c !== r) && (e.stencilOp(t, n, r), o = t, s = n, c = r); 9439 }, 9440 setLocked: function(e) { 9441 t = e; 9442 }, 9443 setClear: function(t) { 9444 l !== t && (e.clearStencil(t), l = t); 9445 }, 9446 reset: function() { 9447 t = !1, n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = null; 9448 } 9449 }; 9450 } 9451 let a = new n(), o = new r(), s = new i(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = {}, d = {}, f = {}, p = /* @__PURE__ */ new WeakMap(), m = [], h = null, g = !1, _ = null, v = null, y = null, b = null, x = null, S = null, C = null, w = new Y(0, 0, 0), T = 0, E = !1, D = null, O = null, k = null, A = null, ee = null, te = e.getParameter(e.MAX_COMBINED_TEXTURE_IMAGE_UNITS), j = !1, ne = 0, re = e.getParameter(e.VERSION); 9452 re.indexOf("WebGL") === -1 ? re.indexOf("OpenGL ES") !== -1 && (ne = parseFloat(/^OpenGL ES (\d)/.exec(re)[1]), j = ne >= 2) : (ne = parseFloat(/^WebGL (\d)/.exec(re)[1]), j = ne >= 1); 9453 let M = null, ie = {}, ae = e.getParameter(e.SCISSOR_BOX), oe = e.getParameter(e.VIEWPORT), se = new J().fromArray(ae), N = new J().fromArray(oe); 9454 function ce(t, n, r, i) { 9455 let a = /* @__PURE__ */ new Uint8Array(4), o = e.createTexture(); 9456 e.bindTexture(t, o), e.texParameteri(t, e.TEXTURE_MIN_FILTER, e.NEAREST), e.texParameteri(t, e.TEXTURE_MAG_FILTER, e.NEAREST); 9457 for (let o = 0; o < r; o++) t === e.TEXTURE_3D || t === e.TEXTURE_2D_ARRAY ? e.texImage3D(n, 0, e.RGBA, 1, 1, i, 0, e.RGBA, e.UNSIGNED_BYTE, a) : e.texImage2D(n + o, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, a); 9458 return o; 9459 } 9460 let le = {}; 9461 le[e.TEXTURE_2D] = ce(e.TEXTURE_2D, e.TEXTURE_2D, 1), le[e.TEXTURE_CUBE_MAP] = ce(e.TEXTURE_CUBE_MAP, e.TEXTURE_CUBE_MAP_POSITIVE_X, 6), le[e.TEXTURE_2D_ARRAY] = ce(e.TEXTURE_2D_ARRAY, e.TEXTURE_2D_ARRAY, 1, 1), le[e.TEXTURE_3D] = ce(e.TEXTURE_3D, e.TEXTURE_3D, 1, 1), a.setClear(0, 0, 0, 1), o.setClear(1), s.setClear(0), P(e.DEPTH_TEST), o.setFunc(3), ve(!1), ye(1), P(e.CULL_FACE), ge(0); 9462 function P(t) { 9463 u[t] !== !0 && (e.enable(t), u[t] = !0); 9464 } 9465 function ue(t) { 9466 u[t] !== !1 && (e.disable(t), u[t] = !1); 9467 } 9468 function de(t, n) { 9469 return f[t] === n ? !1 : (e.bindFramebuffer(t, n), f[t] = n, t === e.DRAW_FRAMEBUFFER && (f[e.FRAMEBUFFER] = n), t === e.FRAMEBUFFER && (f[e.DRAW_FRAMEBUFFER] = n), !0); 9470 } 9471 function fe(t, n) { 9472 let r = m, i = !1; 9473 if (t) { 9474 r = p.get(n), r === void 0 && (r = [], p.set(n, r)); 9475 let a = t.textures; 9476 if (r.length !== a.length || r[0] !== e.COLOR_ATTACHMENT0) { 9477 for (let t = 0, n = a.length; t < n; t++) r[t] = e.COLOR_ATTACHMENT0 + t; 9478 r.length = a.length, i = !0; 9479 } 9480 } else r[0] !== e.BACK && (r[0] = e.BACK, i = !0); 9481 i && e.drawBuffers(r); 9482 } 9483 function pe(t) { 9484 return h === t ? !1 : (e.useProgram(t), h = t, !0); 9485 } 9486 let me = { 9487 100: e.FUNC_ADD, 9488 101: e.FUNC_SUBTRACT, 9489 102: e.FUNC_REVERSE_SUBTRACT 9490 }; 9491 me[103] = e.MIN, me[104] = e.MAX; 9492 let he = { 9493 200: e.ZERO, 9494 201: e.ONE, 9495 202: e.SRC_COLOR, 9496 204: e.SRC_ALPHA, 9497 210: e.SRC_ALPHA_SATURATE, 9498 208: e.DST_COLOR, 9499 206: e.DST_ALPHA, 9500 203: e.ONE_MINUS_SRC_COLOR, 9501 205: e.ONE_MINUS_SRC_ALPHA, 9502 209: e.ONE_MINUS_DST_COLOR, 9503 207: e.ONE_MINUS_DST_ALPHA, 9504 211: e.CONSTANT_COLOR, 9505 212: e.ONE_MINUS_CONSTANT_COLOR, 9506 213: e.CONSTANT_ALPHA, 9507 214: e.ONE_MINUS_CONSTANT_ALPHA 9508 }; 9509 function ge(t, n, r, i, a, o, s, c, l, u) { 9510 if (t === 0) { 9511 g === !0 && (ue(e.BLEND), g = !1); 9512 return; 9513 } 9514 if (g === !1 && (P(e.BLEND), g = !0), t !== 5) { 9515 if (t !== _ || u !== E) { 9516 if ((v !== 100 || x !== 100) && (e.blendEquation(e.FUNC_ADD), v = 100, x = 100), u) switch (t) { 9517 case 1: 9518 e.blendFuncSeparate(e.ONE, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA); 9519 break; 9520 case 2: 9521 e.blendFunc(e.ONE, e.ONE); 9522 break; 9523 case 3: 9524 e.blendFuncSeparate(e.ZERO, e.ONE_MINUS_SRC_COLOR, e.ZERO, e.ONE); 9525 break; 9526 case 4: 9527 e.blendFuncSeparate(e.DST_COLOR, e.ONE_MINUS_SRC_ALPHA, e.ZERO, e.ONE); 9528 break; 9529 default: 9530 V("WebGLState: Invalid blending: ", t); 9531 break; 9532 } 9533 else switch (t) { 9534 case 1: 9535 e.blendFuncSeparate(e.SRC_ALPHA, e.ONE_MINUS_SRC_ALPHA, e.ONE, e.ONE_MINUS_SRC_ALPHA); 9536 break; 9537 case 2: 9538 e.blendFuncSeparate(e.SRC_ALPHA, e.ONE, e.ONE, e.ONE); 9539 break; 9540 case 3: 9541 V("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true"); 9542 break; 9543 case 4: 9544 V("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true"); 9545 break; 9546 default: 9547 V("WebGLState: Invalid blending: ", t); 9548 break; 9549 } 9550 y = null, b = null, S = null, C = null, w.set(0, 0, 0), T = 0, _ = t, E = u; 9551 } 9552 return; 9553 } 9554 a ||= n, o ||= r, s ||= i, (n !== v || a !== x) && (e.blendEquationSeparate(me[n], me[a]), v = n, x = a), (r !== y || i !== b || o !== S || s !== C) && (e.blendFuncSeparate(he[r], he[i], he[o], he[s]), y = r, b = i, S = o, C = s), (c.equals(w) === !1 || l !== T) && (e.blendColor
9554(c.r, c.g, c.b, l), w.copy(c), T = l), _ = t, E = !1; 9555 } 9556 function _e(t, n) { 9557 t.side === 2 ? ue(e.CULL_FACE) : P(e.CULL_FACE); 9558 let r = t.side === 1; 9559 n && (r = !r), ve(r), t.blending === 1 && t.transparent === !1 ? ge(0) : ge(t.blending, t.blendEquation, t.blendSrc, t.blendDst, t.blendEquationAlpha, t.blendSrcAlpha, t.blendDstAlpha, t.blendColor, t.blendAlpha, t.premultipliedAlpha), o.setFunc(t.depthFunc), o.setTest(t.depthTest), o.setMask(t.depthWrite), a.setMask(t.colorWrite); 9560 let i = t.stencilWrite; 9561 s.setTest(i), i && (s.setMask(t.stencilWriteMask), s.setFunc(t.stencilFunc, t.stencilRef, t.stencilFuncMask), s.setOp(t.stencilFail, t.stencilZFail, t.stencilZPass)), xe(t.polygonOffset, t.polygonOffsetFactor, t.polygonOffsetUnits), t.alphaToCoverage === !0 ? P(e.SAMPLE_ALPHA_TO_COVERAGE) : ue(e.SAMPLE_ALPHA_TO_COVERAGE); 9562 } 9563 function ve(t) { 9564 D !== t && (t ? e.frontFace(e.CW) : e.frontFace(e.CCW), D = t); 9565 } 9566 function ye(t) { 9567 t === 0 ? ue(e.CULL_FACE) : (P(e.CULL_FACE), t !== O && (t === 1 ? e.cullFace(e.BACK) : t === 2 ? e.cullFace(e.FRONT) : e.cullFace(e.FRONT_AND_BACK))), O = t; 9568 } 9569 function be(t) { 9570 t !== k && (j && e.lineWidth(t), k = t); 9571 } 9572 function xe(t, n, r) { 9573 t ? (P(e.POLYGON_OFFSET_FILL), (A !== n || ee !== r) && (A = n, ee = r, o.getReversed() && (n = -n), e.polygonOffset(n, r))) : ue(e.POLYGON_OFFSET_FILL); 9574 } 9575 function Se(t) { 9576 t ? P(e.SCISSOR_TEST) : ue(e.SCISSOR_TEST); 9577 } 9578 function Ce(t) { 9579 t === void 0 && (t = e.TEXTURE0 + te - 1), M !== t && (e.activeTexture(t), M = t); 9580 } 9581 function we(t, n, r) { 9582 r === void 0 && (r = M === null ? e.TEXTURE0 + te - 1 : M); 9583 let i = ie[r]; 9584 i === void 0 && (i = { 9585 type: void 0, 9586 texture: void 0 9587 }, ie[r] = i), (i.type !== t || i.texture !== n) && (M !== r && (e.activeTexture(r), M = r), e.bindTexture(t, n || le[t]), i.type = t, i.texture = n); 9588 } 9589 function Te() { 9590 let t = ie[M]; 9591 t !== void 0 && t.type !== void 0 && (e.bindTexture(t.type, null), t.type = void 0, t.texture = void 0); 9592 } 9593 function Ee() { 9594 try { 9595 e.compressedTexImage2D(...arguments); 9596 } catch (e) { 9597 V("WebGLState:", e); 9598 } 9599 } 9600 function De() { 9601 try { 9602 e.compressedTexImage3D(...arguments); 9603 } catch (e) { 9604 V("WebGLState:", e); 9605 } 9606 } 9607 function Oe() { 9608 try { 9609 e.texSubImage2D(...arguments); 9610 } catch (e) { 9611 V("WebGLState:", e); 9612 } 9613 } 9614 function ke() { 9615 try { 9616 e.texSubImage3D(...arguments); 9617 } catch (e) { 9618 V("WebGLState:", e); 9619 } 9620 } 9621 function Ae() { 9622 try { 9623 e.compressedTexSubImage2D(...arguments); 9624 } catch (e) { 9625 V("WebGLState:", e); 9626 } 9627 } 9628 function je() { 9629 try { 9630 e.compressedTexSubImage3D(...arguments); 9631 } catch (e) { 9632 V("WebGLState:", e); 9633 } 9634 } 9635 function F() { 9636 try { 9637 e.texStorage2D(...arguments); 9638 } catch (e) { 9639 V("WebGLState:", e); 9640 } 9641 } 9642 function Me() { 9643 try { 9644 e.texStorage3D(...arguments); 9645 } catch (e) { 9646 V("WebGLState:", e); 9647 } 9648 } 9649 function Ne() { 9650 try { 9651 e.texImage2D(...arguments); 9652 } catch (e) { 9653 V("WebGLState:", e); 9654 } 9655 } 9656 function Pe() { 9657 try { 9658 e.texImage3D(...arguments); 9659 } catch (e) { 9660 V("WebGLState:", e); 9661 } 9662 } 9663 function I(t) { 9664 return d[t] === void 0 ? e.getParameter(t) : d[t]; 9665 } 9666 function Fe(t, n) { 9667 d[t] !== n && (e.pixelStorei(t, n), d[t] = n); 9668 } 9669 function L(t) { 9670 se.equals(t) === !1 && (e.scissor(t.x, t.y, t.z, t.w), se.copy(t)); 9671 } 9672 function Ie(t) { 9673 N.equals(t) === !1 && (e.viewport(t.x, t.y, t.z, t.w), N.copy(t)); 9674 } 9675 function R(t, n) { 9676 let r = l.get(n); 9677 r === void 0 && (r = /* @__PURE__ */ new WeakMap(), l.set(n, r)); 9678 let i = r.get(t); 9679 i === void 0 && (i = e.getUniformBlockIndex(n, t.name), r.set(t, i)); 9680 } 9681 function z(t, n) { 9682 let r = l.get(n).get(t); 9683 c.get(n) !== r && (e.uniformBlockBinding(n, r, t.__bindingPointIndex), c.set(n, r)); 9684 } 9685 function Le() { 9686 e.disable(e.BLEND), e.disable(e.CULL_FACE), e.disable(e.DEPTH_TEST), e.disable(e.POLYGON_OFFSET_FILL), e.disable(e.SCISSOR_TEST), e.disable(e.STENCIL_TEST), e.disable(e.SAMPLE_ALPHA_TO_COVERAGE), e.blendEquation(e.FUNC_ADD), e.blendFunc(e.ONE, e.ZERO), e.blendFuncSeparate(e.ONE, e.ZERO, e.ONE, e.ZERO), e.blendColor(0, 0, 0, 0), e.colorMask(!0, !0, !0, !0), e.clearColor(0, 0, 0, 0), e.depthMask(!0), e.depthFunc(e.LESS), o.setReversed(!1), e.clearDepth(1), e.stencilMask(4294967295), e.stencilFunc(e.ALWAYS, 0, 4294967295), e.stencilOp(e.KEEP, e.KEEP, e.KEEP), e.clearStencil(0), e.cullFace(e.BACK), e.frontFace(e.CCW), e.polygonOffset(0, 0), e.activeTexture(e.TEXTURE0), e.bindFramebuffer(e.FRAMEBUFFER, null), e.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), e.bindFramebuffer(e.READ_FRAMEBUFFER, null), e.useProgram(null), e.lineWidth(1), e.scissor(0, 0, e.canvas.width, e.canvas.height), e.viewport(0, 0, e.canvas.width, e.canvas.height), e.pixelStorei(e.PACK_ALIGNMENT, 4), e.pixelStorei(e.UNPACK_ALIGNMENT, 4), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, e.BROWSER_DEFAULT_WEBGL), e.pixelStorei(e.PACK_ROW_LENGTH, 0), e.pixelStorei(e.PACK_SKIP_PIXELS, 0), e.pixelStorei(e.PACK_SKIP_ROWS, 0), e.pixelStorei(e.UNPACK_ROW_LENGTH, 0), e.pixelStorei(e.UNPACK_IMAGE_HEIGHT, 0), e.pixelStorei(e.UNPACK_SKIP_PIXELS, 0), e.pixelStorei(e.UNPACK_SKIP_ROWS, 0), e.pixelStorei(e.UNPACK_SKIP_IMAGES, 0), u = {}, d = {}, M = null, ie = {}, f = {}, p = /* @__PURE__ */ new WeakMap(), m = [], h = null, g = !1, _ = null, v = null, y = null, b = null, x = null, S = null, C = null, w = new Y(0, 0, 0), T = 0, E = !1, D = null, O = null, k = null, A = null, ee = null, se.set(0, 0, e.canvas.width, e.canvas.height), N.set(0, 0, e.canvas.width, e.canvas.height), a.reset(), o.reset(), s.reset(); 9687 } 9688 return { 9689 buffers: { 9690 color: a, 9691 depth: o, 9692 stencil: s 9693 }, 9694 enable: P, 9695 disable: ue, 9696 bindFramebuffer: de, 9697 drawBuffers: fe, 9698 useProgram: pe, 9699 setBlending: ge, 9700 setMaterial: _e, 9701 setFlipSided: ve, 9702 setCullFace: ye, 9703 setLineWidth: be, 9704 setPolygonOffset: xe, 9705 setScissorTest: Se, 9706 activeTexture: Ce, 9707 bindTexture: we, 9708 unbindTexture: Te, 9709 compressedTexImage2D: Ee, 9710 compressedTexImage3D: De, 9711 texImage2D: Ne, 9712 texImage3D: Pe, 9713 pixelStorei: Fe, 9714 getParameter: I, 9715 updateUBOMapping: R, 9716 uniformBlockBinding: z, 9717 texStorage2D: F, 9718 texStorage3D: Me, 9719 texSubImage2D: Oe, 9720 texSubImage3D: ke, 9721 compressedTexSubImage2D: Ae, 9722 compressedTexSubImage3D: je, 9723 scissor: L, 9724 viewport: Ie, 9725 reset: Le 9726 }; 9727} 9728function Pl(e, t, n, r, i, a, o) { 9729 let s = t.has("WEBGL_multisampled_render_to_texture") ? t.get("WEBGL_multisampled_render_to_texture") : null, c = typeof navigator > "u" ? !1 : /OculusBrowser/g.test(navigator.userAgent), l = new W(), u = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new Set(), f, p = /* @__PURE__ */ new WeakMap(), m = !1; 9730 try { 9731 m = typeof OffscreenCanvas < "u" && new OffscreenCanvas(1, 1).getContext("2d") !== null; 9732 } catch {} 9733 function h(e, t) { 9734 return m ? new OffscreenCanvas(e, t) : kt("canvas"); 9735 } 9736 function g(e, t, n) { 9737 let r = 1, i = I(e); 9738 if ((i.width > n || i.height > n) && (r = n / Math.max(i.width, i.height)), r < 1) if (typeof HTMLImageElement < "u" && e instanceof HTMLImageElement || typeof HTMLCanvasElement < "u" && e instanceof HTMLCanvasElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || typeof VideoFrame < "u" && e instanceof VideoFrame) { 9739 let n = Math.floor(r * i.width), a = Math.floor(r * i.height); 9740 f === void 0 && (f = h(n, a)); 9741 let o = t ? h(n, a) : f; 9742 return o.width = n, o.height = a, o.getContext("2d").drawImage(e, 0, 0, n, a), B("WebGLRenderer: Texture has been resized from (" + i.width + "x" + i.height + ") to (" + n + "x" + a + ")."), o; 9743 } else return "data" in e && B("WebGLRenderer: Image in DataTexture is too big (" + i.width + "x" + i.height + ")."), e; 9744 return e; 9745 } 9746 function _(e) { 9747 return e.generateMipmaps; 9748 } 9749 function v(t) { 9750 e.generateMipmap(t); 9751 } 9752 function y(t) {
9753 return t.isWebGLCubeRenderTarget ? e.TEXTURE_CUBE_MAP : t.isWebGL3DRenderTarget ? e.TEXTURE_3D : t.isWebGLArrayRenderTarget || t.isCompressedArrayTexture ? e.TEXTURE_2D_ARRAY : e.TEXTURE_2D; 9754 } 9755 function b(n, r, i, a, o, s = !1) { 9756 if (n !== null) { 9757 if (e[n] !== void 0) return e[n]; 9758 B("WebGLRenderer: Attempt to use non-existing WebGL internal format '" + n + "'"); 9759 } 9760 let c; 9761 a && (c = t.get("EXT_texture_norm16"), c || B("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension")); 9762 let l = r; 9763 if (r === e.RED && (i === e.FLOAT && (l = e.R32F), i === e.HALF_FLOAT && (l = e.R16F), i === e.UNSIGNED_BYTE && (l = e.R8), i === e.UNSIGNED_SHORT && c && (l = c.R16_EXT), i === e.SHORT && c && (l = c.R16_SNORM_EXT)), r === e.RED_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.R8UI), i === e.UNSIGNED_SHORT && (l = e.R16UI), i === e.UNSIGNED_INT && (l = e.R32UI), i === e.BYTE && (l = e.R8I), i === e.SHORT && (l = e.R16I), i === e.INT && (l = e.R32I)), r === e.RG && (i === e.FLOAT && (l = e.RG32F), i === e.HALF_FLOAT && (l = e.RG16F), i === e.UNSIGNED_BYTE && (l = e.RG8), i === e.UNSIGNED_SHORT && c && (l = c.RG16_EXT), i === e.SHORT && c && (l = c.RG16_SNORM_EXT)), r === e.RG_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RG8UI), i === e.UNSIGNED_SHORT && (l = e.RG16UI), i === e.UNSIGNED_INT && (l = e.RG32UI), i === e.BYTE && (l = e.RG8I), i === e.SHORT && (l = e.RG16I), i === e.INT && (l = e.RG32I)), r === e.RGB_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RGB8UI), i === e.UNSIGNED_SHORT && (l = e.RGB16UI), i === e.UNSIGNED_INT && (l = e.RGB32UI), i === e.BYTE && (l = e.RGB8I), i === e.SHORT && (l = e.RGB16I), i === e.INT && (l = e.RGB32I)), r === e.RGBA_INTEGER && (i === e.UNSIGNED_BYTE && (l = e.RGBA8UI), i === e.UNSIGNED_SHORT && (l = e.RGBA16UI), i === e.UNSIGNED_INT && (l = e.RGBA32UI), i === e.BYTE && (l = e.RGBA8I), i === e.SHORT && (l = e.RGBA16I), i === e.INT && (l = e.RGBA32I)), r === e.RGB && (i === e.UNSIGNED_SHORT && c && (l = c.RGB16_EXT), i === e.SHORT && c && (l = c.RGB16_SNORM_EXT), i === e.UNSIGNED_INT_5_9_9_9_REV && (l = e.RGB9_E5), i === e.UNSIGNED_INT_10F_11F_11F_REV && (l = e.R11F_G11F_B10F)), r === e.RGBA) { 9764 let t = s ? St : q.getTransfer(o); 9765 i === e.FLOAT && (l = e.RGBA32F), i === e.HALF_FLOAT && (l = e.RGBA16F), i === e.UNSIGNED_BYTE && (l = t === "srgb" ? e.SRGB8_ALPHA8 : e.RGBA8), i === e.UNSIGNED_SHORT && c && (l = c.RGBA16_EXT), i === e.SHORT && c && (l = c.RGBA16_SNORM_EXT), i === e.UNSIGNED_SHORT_4_4_4_4 && (l = e.RGBA4), i === e.UNSIGNED_SHORT_5_5_5_1 && (l = e.RGB5_A1); 9766 } 9767 return (l === e.R16F || l === e.R32F || l === e.RG16F || l === e.RG32F || l === e.RGBA16F || l === e.RGBA32F) && t.get("EXT_color_buffer_float"), l; 9768 } 9769 function x(t, n) { 9770 let r; 9771 return t ? n === null || n === 1014 || n === 1020 ? r = e.DEPTH24_STENCIL8 : n === 1015 ? r = e.DEPTH32F_STENCIL8 : n === 1012 && (r = e.DEPTH24_STENCIL8, B("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")) : n === null || n === 1014 || n === 1020 ? r = e.DEPTH_COMPONENT24 : n === 1015 ? r = e.DEPTH_COMPONENT32F : n === 1012 && (r = e.DEPTH_COMPONENT16), r; 9772 } 9773 function S(e, t) { 9774 return _(e) === !0 || e.isFramebufferTexture && e.minFilter !== 1003 && e.minFilter !== 1006 ? Math.log2(Math.max(t.width, t.height)) + 1 : e.mipmaps !== void 0 && e.mipmaps.length > 0 ? e.mipmaps.length : e.isCompressedTexture && Array.isArray(e.image) ? t.mipmaps.length : 1; 9775 } 9776 function C(e) { 9777 let t = e.target; 9778 t.removeEventListener("dispose", C), T(t), t.isVideoTexture && u.delete(t), t.isHTMLTexture && d.delete(t); 9779 } 9780 function w(e) { 9781 let t = e.target; 9782 t.removeEventListener("dispose", w), D(t); 9783 } 9784 function T(e) { 9785 let t = r.get(e); 9786 if (t.__webglInit === void 0) return; 9787 let n = e.source, i = p.get(n); 9788 if (i) { 9789 let r = i[t.__cacheKey]; 9790 r.usedTimes--, r.usedTimes === 0 && E(e), Object.keys(i).length === 0 && p.delete(n); 9791 } 9792 r.remove(e); 9793 } 9794 function E(t) { 9795 let n = r.get(t); 9796 e.deleteTexture(n.__webglTexture); 9797 let i = t.source, a = p.get(i); 9798 delete a[n.__cacheKey], o.memory.textures--; 9799 } 9800 function D(t) { 9801 let n = r.get(t); 9802 if (t.depthTexture && (t.depthTexture.dispose(), r.remove(t.depthTexture)), t.isWebGLCubeRen
9802derTarget) for (let t = 0; t < 6; t++) { 9803 if (Array.isArray(n.__webglFramebuffer[t])) for (let r = 0; r < n.__webglFramebuffer[t].length; r++) e.deleteFramebuffer(n.__webglFramebuffer[t][r]); 9804 else e.deleteFramebuffer(n.__webglFramebuffer[t]); 9805 n.__webglDepthbuffer && e.deleteRenderbuffer(n.__webglDepthbuffer[t]); 9806 } 9807 else { 9808 if (Array.isArray(n.__webglFramebuffer)) for (let t = 0; t < n.__webglFramebuffer.length; t++) e.deleteFramebuffer(n.__webglFramebuffer[t]); 9809 else e.deleteFramebuffer(n.__webglFramebuffer); 9810 if (n.__webglDepthbuffer && e.deleteRenderbuffer(n.__webglDepthbuffer), n.__webglMultisampledFramebuffer && e.deleteFramebuffer(n.__webglMultisampledFramebuffer), n.__webglColorRenderbuffer) for (let t = 0; t < n.__webglColorRenderbuffer.length; t++) n.__webglColorRenderbuffer[t] && e.deleteRenderbuffer(n.__webglColorRenderbuffer[t]); 9811 n.__webglDepthRenderbuffer && e.deleteRenderbuffer(n.__webglDepthRenderbuffer); 9812 } 9813 let i = t.textures; 9814 for (let t = 0, n = i.length; t < n; t++) { 9815 let n = r.get(i[t]); 9816 n.__webglTexture && (e.deleteTexture(n.__webglTexture), o.memory.textures--), r.remove(i[t]); 9817 } 9818 r.remove(t); 9819 } 9820 let O = 0; 9821 function k() { 9822 O = 0; 9823 } 9824 function A() { 9825 return O; 9826 } 9827 function ee(e) { 9828 O = e; 9829 } 9830 function te() { 9831 let e = O; 9832 return e >= i.maxTextures && B("WebGLTextures: Trying to use " + e + " texture units while this GPU supports only " + i.maxTextures), O += 1, e; 9833 } 9834 function j(e) { 9835 let t = []; 9836 return t.push(e.wrapS), t.push(e.wrapT), t.push(e.wrapR || 0), t.push(e.magFilter), t.push(e.minFilter), t.push(e.anisotropy), t.push(e.internalFormat), t.push(e.format), t.push(e.type), t.push(e.generateMipmaps), t.push(e.premultiplyAlpha), t.push(e.flipY), t.push(e.unpackAlignment), t.push(e.colorSpace), t.join(); 9837 } 9838 function ne(t, i) { 9839 let a = r.get(t); 9840 if (t.isVideoTexture && Ne(t), t.isRenderTargetTexture === !1 && t.isExternalTexture !== !0 && t.version > 0 && a.__version !== t.version) { 9841 let e = t.image; 9842 if (e === null) B("WebGLRenderer: Texture marked for update but no image data found."); 9843 else if (e.complete === !1) B("WebGLRenderer: Texture marked for update but image is incomplete"); 9844 else { 9845 ye(a, t, i); 9846 return; 9847 } 9848 } else t.isExternalTexture && (a.__webglTexture = t.sourceTexture ? t.sourceTexture : null); 9849 n.bindTexture(e.TEXTURE_2D, a.__webglTexture, e.TEXTURE0 + i); 9850 } 9851 function re(t, i) { 9852 let a = r.get(t); 9853 if (t.isRenderTargetTexture === !1 && t.version > 0 && a.__version !== t.version) { 9854 ye(a, t, i); 9855 return; 9856 } else t.isExternalTexture && (a.__webglTexture = t.sourceTexture ? t.sourceTexture : null); 9857 n.bindTexture(e.TEXTURE_2D_ARRAY, a.__webglTexture, e.TEXTURE0 + i); 9858 } 9859 function M(t, i) { 9860 let a = r.get(t); 9861 if (t.isRenderTargetTexture === !1 && t.version > 0 && a.__version !== t.version) { 9862 ye(a, t, i); 9863 return; 9864 } 9865 n.bindTexture(e.TEXTURE_3D, a.__webglTexture, e.TEXTURE0 + i); 9866 } 9867 function ie(t, i) { 9868 let a = r.get(t); 9869 if (t.isCubeDepthTexture !== !0 && t.version > 0 && a.__version !== t.version) { 9870 be(a, t, i); 9871 return; 9872 } 9873 n.bindTexture(e.TEXTURE_CUBE_MAP, a.__webglTexture, e.TEXTURE0 + i); 9874 } 9875 let fe = { 9876 [ae]: e.REPEAT, 9877 [oe]: e.CLAMP_TO_EDGE, 9878 [se]: e.MIRRORED_REPEAT 9879 }, pe = { 9880 [N]: e.NEAREST, 9881 [ce]: e.NEAREST_MIPMAP_NEAREST, 9882 [le]: e.NEAREST_MIPMAP_LINEAR, 9883 [P]: e.LINEAR, 9884 [ue]: e.LINEAR_MIPMAP_NEAREST, 9885 [de]: e.LINEAR_MIPMAP_LINEAR 9886 }, me = { 9887 512: e.NEVER, 9888 519: e.ALWAYS, 9889 513: e.LESS, 9890 515: e.LEQUAL, 9891 514: e.EQUAL, 9892 518: e.GEQUAL, 9893 516: e.GREATER, 9894 517: e.NOTEQUAL 9895 }; 9896 function he(n, a) { 9897 if (a.type === 1015 && t.has("OES_texture_float_linear") === !1 && (a.magFilter === 1006 || a.magFilter === 1007 || a.magFilter === 1005 || a.magFilter === 1008 || a.minFilter === 1006 || a.minFilter === 1007 || a.minFilter === 1005 || a.minFilter === 1008) && B("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."), e.texParameteri(n, e.TEXTURE_WRAP_S, fe[a.wrapS]), e.texParameteri(n, e.TEXTURE_WRAP_T, fe[a.wrapT]), (n === e.TEXTURE_3D || n === e.TEXTURE_2D_ARRAY) && e.texParameteri(n, e.TEXTURE_WRAP_R, fe[a.wrapR]), e.texParameteri(n, e.TEXTURE_MAG_FILTER, pe[a.magFilter]), e.texParameteri(n, e.TEXTURE_MIN_FILTER, pe[a.minFilter]), a.compareFunction && (e.texParameteri(n, e.TEXTURE_COMPARE_MODE, e.COMPARE_REF_TO_TEXTURE), e.texParameteri(n, e.TEXTURE_COMPARE_FUNC, me[a.compareFunction])), t.has("EXT_texture_filter_anisotropic") === !0) { 9898 if (a.magFilter === 1003 || a.minFilter !== 1005 && a.minFilter !== 1008 || a.type === 1015 && t.has("OES_texture_float_linear") === !1) return; 9899 if (a.anisotropy > 1 || r.get(a).__currentAnisotropy) { 9900 let o = t.get("EXT_texture_filter_anisotropic"); 9901 e.texParameterf(n, o.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(a.anisotropy, i.getMaxAnisotropy())), r.get(a).__currentAnisotropy = a.anisotropy; 9902 } 9903 } 9904 } 9905 function ge(t, n) { 9906 let r = !1; 9907 t.__webglInit === void 0 && (t.__webglInit = !0, n.addEventListener("dispose", C)); 9908 let i = n.source, a = p.get(i); 9909 a === void 0 && (a = {}, p.set(i, a)); 9910 let s = j(n); 9911 if (s !== t.__cacheKey) { 9912 a[s] === void 0 && (a[s] = { 9913 texture: e.createTexture(), 9914 usedTimes: 0 9915 }, o.memory.textures++, r = !0), a[s].usedTimes++; 9916 let i = a[t.__cacheKey]; 9917 i !== void 0 && (a[t.__cacheKey].usedTimes--, i.usedTimes === 0 && E(n)), t.__cacheKey = s, t.__webglTexture = a[s].texture; 9918 } 9919 return r; 9920 } 9921 function _e(e, t, n) { 9922 return Math.floor(Math.floor(e / n) / t); 9923 } 9924 function ve(t, r, i, a) { 9925 let o = t.updateRanges; 9926 if (o.length === 0) n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, r.width, r.height, i, a, r.data); 9927 else { 9928 o.sort((e, t) => e.start - t.start); 9929 let s = 0; 9930 for (let e = 1; e < o.length; e++) { 9931 let t = o[s], n = o[e], i = t.start + t.count, a = _e(n.start, r.width, 4), c = _e(t.start, r.width, 4); 9932 n.start <= i + 1 && a === c && _e(n.start + n.count - 1, r.width, 4) === a ? t.count = Math.max(t.count, n.start + n.count - t.start) : (++s, o[s] = n); 9933 } 9934 o.length = s + 1; 9935 let c = n.getParameter(e.UNPACK_ROW_LENGTH), l = n.getParameter(e.UNPACK_SKIP_PIXELS), u = n.getParameter(e.UNPACK_SKIP_ROWS); 9936 n.pixelStorei(e.UNPACK_ROW_LENGTH, r.width); 9937 for (let t = 0, s = o.length; t < s; t++) {
9938 let s = o[t], c = Math.floor(s.start / 4), l = Math.ceil(s.count / 4), u = c % r.width, d = Math.floor(c / r.width), f = l; 9939 n.pixelStorei(e.UNPACK_SKIP_PIXELS, u), n.pixelStorei(e.UNPACK_SKIP_ROWS, d), n.texSubImage2D(e.TEXTURE_2D, 0, u, d, f, 1, i, a, r.data); 9940 } 9941 t.clearUpdateRanges(), n.pixelStorei(e.UNPACK_ROW_LENGTH, c), n.pixelStorei(e.UNPACK_SKIP_PIXELS, l), n.pixelStorei(e.UNPACK_SKIP_ROWS, u); 9942 } 9943 } 9944 function ye(t, o, s) { 9945 let c = e.TEXTURE_2D; 9946 (o.isDataArrayTexture || o.isCompressedArrayTexture) && (c = e.TEXTURE_2D_ARRAY), o.isData3DTexture && (c = e.TEXTURE_3D); 9947 let l = ge(t, o), u = o.source; 9948 n.bindTexture(c, t.__webglTexture, e.TEXTURE0 + s); 9949 let f = r.get(u); 9950 if (u.version !== f.__version || l === !0) { 9951 if (n.activeTexture(e.TEXTURE0 + s), !(typeof ImageBitmap < "u" && o.image instanceof ImageBitmap)) { 9952 let t = q.getPrimaries(q.workingColorSpace), r = o.colorSpace === "" ? null : q.getPrimaries(o.colorSpace), i = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL; 9953 n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, i); 9954 } 9955 n.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment); 9956 let t = g(o.image, !1, i.maxTextureSize); 9957 t = Pe(o, t); 9958 let r = a.convert(o.format, o.colorSpace), p = a.convert(o.type), m = b(o.internalFormat, r, p, o.normalized, o.colorSpace, o.isVideoTexture); 9959 he(c, o); 9960 let h, y = o.mipmaps, C = o.isVideoTexture !== !0, w = f.__version === void 0 || l === !0, T = u.dataReady, E = S(o, t); 9961 if (o.isDepthTexture) m = x(o.format === ke, o.type), w && (C ? n.texStorage2D(e.TEXTURE_2D, 1, m, t.width, t.height) : n.texImage2D(e.TEXTURE_2D, 0, m, t.width, t.height, 0, r, p, null)); 9962 else if (o.isDataTexture) if (y.length > 0) { 9963 C && w && n.texStorage2D(e.TEXTURE_2D, E, m, y[0].width, y[0].height); 9964 for (let t = 0, i = y.length; t < i; t++) h = y[t], C ? T && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, h.width, h.height, r, p, h.data) : n.texImage2D(e.TEXTURE_2D, t, m, h.width, h.height, 0, r, p, h.data); 9965 o.generateMipmaps = !1; 9966 } else C ? (w && n.texStorage2D(e.TEXTURE_2D, E, m, t.width, t.height), T && ve(o, t, r, p)) : n.texImage2D(e.TEXTURE_2D, 0, m, t.width, t.height, 0, r, p, t.data); 9967 else if (o.isCompressedTexture) if (o.isCompressedArrayTexture) { 9968 C && w && n.texStorage3D(e.TEXTURE_2D_ARRAY, E, m, y[0].width, y[0].height, t.depth); 9969 for (let i = 0, a = y.length; i < a; i++) if (h = y[i], o.format !== 1023) if (r !== null) if (C) { 9970 if (T) if (o.layerUpdates.size > 0) { 9971 let t = Ao(h.width, h.height, o.format, o.type); 9972 for (let a of o.layerUpdates) { 9973 let o = h.data.subarray(a * t / h.data.BYTES_PER_ELEMENT, (a + 1) * t / h.data.BYTES_PER_ELEMENT); 9974 n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, a, h.width, h.height, 1, r, o); 9975 } 9976 o.clearLayerUpdates(); 9977 } else n.compressedTexSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, 0, h.width, h.height, t.depth, r, h.data); 9978 } else n.compressedTexImage3D(e.TEXTURE_2D_ARRAY, i, m, h.width, h.height, t.depth, 0, h.data, 0, 0); 9979 else B("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"); 9980 else C ? T && n.texSubImage3D(e.TEXTURE_2D_ARRAY, i, 0, 0, 0, h.width, h.height, t.depth, r, p, h.data) : n.texImage3D(e.TEXTURE_2D_ARRAY, i, m, h.width, h.height, t.depth, 0, r, p, h.data); 9981 } else { 9982 C && w && n.texStorage2D(e.TEXTURE_2D, E, m, y[0].width, y[0].height); 9983 for (let t = 0, i = y.length; t < i; t++) h = y[t], o.format === 1023 ? C ? T && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, h.width, h.height, r, p, h.data) : n.texImage2D(e.TEXTURE_2D, t, m, h.width, h.height, 0, r, p, h.data) : r === null ? B("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()") : C ? T && n.compressedTexSubImage2D(e.TEXTURE_2D, t, 0, 0, h.width, h.height, r, h.data) : n.compressedTexImage2D(e.TEXTURE_2D, t, m, h.width, h.height, 0, h.data); 9984 } 9985 else if (o.isDataArrayTexture) if (C) { 9986 if (w && n.texStorage3D(e.TEXTURE_2D_ARRAY, E, m, t.width, t.height, t.depth), T) if (o.layerUpdates.size > 0) { 9987 let i = Ao(t.width, t.height, o.format, o.type); 9988 for (let a of o.layerUpdates) { 9989 let o = t.data.subarray(a * i / t.data.BYTES_PER_ELEMENT, (a + 1) * i / t.data.BYTES_PER_ELEMENT); 9990 n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, a, t.width, t.height, 1, r, p, o); 9991 } 9992 o.clearLayerUpdates(); 9993 } else n.texSubImage3D(e.TEXTURE_2D_ARRAY, 0, 0, 0, 0, t.width, t.height, t.depth, r, p, t.data); 9994 } else n.texImage3D(e.TEXTURE_2D_ARRAY, 0, m, t.width, t.height, t.depth, 0, r, p, t.data); 9995 else if (o.isData3DTexture) C ? (w && n.texStorage3D(e.TEXTURE_3D, E, m, t.width, t.height, t.depth), T && n.texSubImage3D(e.TEXTURE_3D, 0, 0, 0, 0, t.width, t.height, t.depth, r, p, t.data)) : n.texImage3D(e.TEXTURE_3D, 0, m, t.width, t.height, t.depth, 0, r, p, t.data); 9996 else if (o.isFramebufferTexture) { 9997 if (w) if (C) n.texStorage2D(e.TEXTURE_2D, E, m, t.width, t.height); 9998 else { 9999 let i = t.width, a = t.height; 10000 for (let t = 0; t < E; t++) n.texImage2D(e.TEXTURE_2D, t, m, i, a, 0, r, p, null), i >>= 1, a >>= 1; 10001 } 10002 } else if (o.isHTMLTexture) { 10003 if ("texElementImage2D" in e) { 10004 let n = e.canvas; 10005 if (n.hasAttribute("layoutsubtree") || n.setAttribute("layoutsubtree", "true"), t.parentNode !== n) { 10006 n.appendChild(t), d.add(o), n.onpaint = (e) => { 10007 let t = e.changedElements; 10008 for (let e of d) t.includes(e.image) && (e.needsUpdate = !0); 10009 }, n.requestPaint(); 10010 return; 10011 } 10012 if (e.texElementImage2D.length === 3) e.texElementImage2D(e.TEXTURE_2D, e.RGBA8, t); 10013 else { 10014 let n = e.RGBA, r = e.RGBA, i = e.UNSIGNED_BYTE; 10015 e.texElementImage2D(e.TEXTURE_2D, 0, n, r, i, t); 10016 } 10017 e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE); 10018 } 10019 } else if (y.length > 0) { 10020 if (C && w) { 10021 let t = I(y[0]); 10022 n.texStorage2D(e.TEXTURE_2D, E, m, t.width, t.height); 10023 } 10024 for (let t = 0, i = y.length; t < i;
10024 t++) h = y[t], C ? T && n.texSubImage2D(e.TEXTURE_2D, t, 0, 0, r, p, h) : n.texImage2D(e.TEXTURE_2D, t, m, r, p, h); 10025 o.generateMipmaps = !1; 10026 } else if (C) { 10027 if (w) { 10028 let r = I(t); 10029 n.texStorage2D(e.TEXTURE_2D, E, m, r.width, r.height); 10030 } 10031 T && n.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, r, p, t); 10032 } else n.texImage2D(e.TEXTURE_2D, 0, m, r, p, t); 10033 _(o) && v(c), f.__version = u.version, o.onUpdate && o.onUpdate(o); 10034 } 10035 t.__version = o.version; 10036 } 10037 function be(t, o, s) { 10038 if (o.image.length !== 6) return; 10039 let c = ge(t, o), l = o.source; 10040 n.bindTexture(e.TEXTURE_CUBE_MAP, t.__webglTexture, e.TEXTURE0 + s); 10041 let u = r.get(l); 10042 if (l.version !== u.__version || c === !0) { 10043 n.activeTexture(e.TEXTURE0 + s); 10044 let t = q.getPrimaries(q.workingColorSpace), r = o.colorSpace === "" ? null : q.getPrimaries(o.colorSpace), d = o.colorSpace === "" || t === r ? e.NONE : e.BROWSER_DEFAULT_WEBGL; 10045 n.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, o.flipY), n.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, o.premultiplyAlpha), n.pixelStorei(e.UNPACK_ALIGNMENT, o.unpackAlignment), n.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL, d); 10046 let f = o.isCompressedTexture || o.image[0].isCompressedTexture, p = o.image[0] && o.image[0].isDataTexture, m = []; 10047 for (let e = 0; e < 6; e++) !f && !p ? m[e] = g(o.image[e], !0, i.maxCubemapSize) : m[e] = p ? o.image[e].image : o.image[e], m[e] = Pe(o, m[e]); 10048 let h = m[0], y = a.convert(o.format, o.colorSpace), x = a.convert(o.type), C = b(o.internalFormat, y, x, o.normalized, o.colorSpace), w = o.isVideoTexture !== !0, T = u.__version === void 0 || c === !0, E = l.dataReady, D = S(o, h); 10049 he(e.TEXTURE_CUBE_MAP, o); 10050 let O; 10051 if (f) { 10052 w && T && n.texStorage2D(e.TEXTURE_CUBE_MAP, D, C, h.width, h.height); 10053 for (let t = 0; t < 6; t++) { 10054 O = m[t].mipmaps; 10055 for (let r = 0; r < O.length; r++) { 10056 let i = O[r]; 10057 o.format === 1023 ? w ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, y, x, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, C, i.width, i.height, 0, y, x, i.data) : y === null ? B("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()") : w ? E && n.compressedTexSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, 0, 0, i.width, i.height, y, i.data) : n.compressedTexImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r, C, i.width, i.height, 0, i.data); 10058 } 10059 } 10060 } else { 10061 if (O = o.mipmaps, w && T) { 10062 O.length > 0 && D++; 10063 let t = I(m[0]); 10064 n.texStorage2D(e.TEXTURE_CUBE_MAP, D, C, t.width, t.height); 10065 } 10066 for (let t = 0; t < 6; t++) if (p) { 10067 w ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, m[t].width, m[t].height, y, x, m[t].data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, C, m[t].width, m[t].height, 0, y, x, m[t].data); 10068 for (let r = 0; r < O.length; r++) { 10069 let i = O[r].image[t].image; 10070 w ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, i.width, i.height, y, x, i.data) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, C, i.width, i.height, 0, y, x, i.data); 10071 } 10072 } else { 10073 w ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, 0, 0, y, x, m[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, 0, C, y, x, m[t]); 10074 for (let r = 0; r < O.length; r++) { 10075 let i = O[r]; 10076 w ? E && n.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, 0, 0, y, x, i.image[t]) : n.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + t, r + 1, C, y, x, i.image[t]); 10077 } 10078 } 10079 } 10080 _(o) && v(e.TEXTURE_CUBE_MAP), u.__version = l.version, o.onUpdate && o.onUpdate(o); 10081 } 10082 t.__version = o.version; 10083 } 10084 function xe(t, i, o, c, l, u) { 10085 let d = a.convert(o.format, o.colorSpace), f = a.convert(o.type), p = b(o.internalFormat, d, f, o.normalized, o.colorSpace), m = r.get(i), h = r.get(o); 10086 if (h.__renderTarget = i, !m.__hasExternalTextures) { 10087 let t = Math.max(1, i.width >> u), r = Math.max(1, i.height >> u); 10088 l === e.TEXTURE_3D || l === e.TEXTURE_2D_ARRAY ? n.texImage3D(l, u, p, t, r, i.depth, 0, d, f, null) : n.texImage2D(l, u, p, t, r, 0, d, f, null); 10089 } 10090 n.bindFramebuffer(e.FRAMEBUFFER, t), Me(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, c, l, h.__webglTexture, 0, F(i)) : (l === e.TEXTURE_2D || l >= e.TEXTURE_CUBE_MAP_POSITIVE_X && l <= e.TEXTURE_CUBE_MAP_NEGATIVE_Z) && e.framebufferTexture2D(e.FRAMEBUFFER, c, l, h.__webglTexture, u), n.bindFramebuffer(e.FRAMEBUFFER, null); 10091 } 10092 function Se(t, n, r) { 10093 if (e.bindRenderbuffer(e.RENDERBUFFER, t), n.depthBuffer) { 10094 let i = n.depthTexture, a = i && i.isDepthTexture ? i.type : null, o = x(n.stencilBuffer, a), c = n.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT; 10095 Me(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, F(n), o, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, F(n), o, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, o, n.width, n.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, c, e.RENDERBUFFER, t); 10096 } else { 10097 let t = n.textures; 10098 for (let i = 0; i < t.length; i++) { 10099 let o = t[i], c = a.convert(o.format, o.colorSpace), l = a.convert(o.type), u = b(o.internalFormat, c, l, o.normalized, o.colorSpace); 10100 Me(n) ? s.renderbufferStorageMultisampleEXT(e.RENDERBUFFER, F(n), u, n.width, n.height) : r ? e.renderbufferStorageMultisample(e.RENDERBUFFER, F(n), u, n.width, n.height) : e.renderbufferStorage(e.RENDERBUFFER, u, n.width, n.height); 10101 } 10102 } 10103 e.bindRenderbuffer(e.RENDERBUFFER, null); 10104 } 10105 function Ce(t, i, o) {
10106 let c = i.isWebGLCubeRenderTarget === !0; 10107 if (n.bindFramebuffer(e.FRAMEBUFFER, t), !(i.depthTexture && i.depthTexture.isDepthTexture)) throw Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture."); 10108 let l = r.get(i.depthTexture); 10109 if (l.__renderTarget = i, (!l.__webglTexture || i.depthTexture.image.width !== i.width || i.depthTexture.image.height !== i.height) && (i.depthTexture.image.width = i.width, i.depthTexture.image.height = i.height, i.depthTexture.needsUpdate = !0), c) { 10110 if (l.__webglInit === void 0 && (l.__webglInit = !0, i.depthTexture.addEventListener("dispose", C)), l.__webglTexture === void 0) { 10111 l.__webglTexture = e.createTexture(), n.bindTexture(e.TEXTURE_CUBE_MAP, l.__webglTexture), he(e.TEXTURE_CUBE_MAP, i.depthTexture); 10112 let t = a.convert(i.depthTexture.format), r = a.convert(i.depthTexture.type), o; 10113 i.depthTexture.format === 1026 ? o = e.DEPTH_COMPONENT24 : i.depthTexture.format === 1027 && (o = e.DEPTH24_STENCIL8); 10114 for (let n = 0; n < 6; n++) e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0, o, i.width, i.height, 0, t, r, null); 10115 } 10116 } else ne(i.depthTexture, 0); 10117 let u = l.__webglTexture, d = F(i), f = c ? e.TEXTURE_CUBE_MAP_POSITIVE_X + o : e.TEXTURE_2D, p = i.depthTexture.format === 1027 ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT; 10118 if (i.depthTexture.format === 1026) Me(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0); 10119 else if (i.depthTexture.format === 1027) Me(i) ? s.framebufferTexture2DMultisampleEXT(e.FRAMEBUFFER, p, f, u, 0, d) : e.framebufferTexture2D(e.FRAMEBUFFER, p, f, u, 0); 10120 else throw Error("THREE.WebGLTextures: Unknown depthTexture format."); 10121 } 10122 function we(t) { 10123 let i = r.get(t), a = t.isWebGLCubeRenderTarget === !0; 10124 if (i.__boundDepthTexture !== t.depthTexture) { 10125 let e = t.depthTexture; 10126 if (i.__depthDisposeCallback && i.__depthDisposeCallback(), e) { 10127 let t = () => { 10128 delete i.__boundDepthTexture, delete i.__depthDisposeCallback, e.removeEventListener("dispose", t); 10129 }; 10130 e.addEventListener("dispose", t), i.__depthDisposeCallback = t; 10131 } 10132 i.__boundDepthTexture = e; 10133 } 10134 if (t.depthTexture && !i.__autoAllocateDepthBuffer) if (a) for (let e = 0; e < 6; e++) Ce(i.__webglFramebuffer[e], t, e); 10135 else { 10136 let e = t.texture.mipmaps; 10137 e && e.length > 0 ? Ce(i.__webglFramebuffer[0], t, 0) : Ce(i.__webglFramebuffer, t, 0); 10138 } 10139 else if (a) { 10140 i.__webglDepthbuffer = []; 10141 for (let r = 0; r < 6; r++) if (n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[r]), i.__webglDepthbuffer[r] === void 0) i.__webglDepthbuffer[r] = e.createRenderbuffer(), Se(i.__webglDepthbuffer[r], t, !1); 10142 else { 10143 let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, a = i.__webglDepthbuffer[r]; 10144 e.bindRenderbuffer(e.RENDERBUFFER, a), e.framebufferRenderbuffer(e.FRAMEBUFFER, n, e.RENDERBUFFER, a); 10145 } 10146 } else { 10147 let r = t.texture.mipmaps; 10148 if (r && r.length > 0 ? n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer[0]) : n.bindFramebuffer(e.FRAMEBUFFER, i.__webglFramebuffer), i.__webglDepthbuffer === void 0) i.__webglDepthbuffer = e.createRenderbuffer(), Se(i.__webglDepthbuffer, t, !1); 10149 else { 10150 let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, r = i.__webglDepthbuffer; 10151 e.bindRenderbuffer(e.RENDERBUFFER, r), e.framebufferRenderbuffer(e.FRAMEBUFFER, n, e.RENDERBUFFER, r); 10152 } 10153 } 10154 n.bindFramebuffer(e.FRAMEBUFFER, null); 10155 } 10156 function Te(t, n, i) { 10157 let a = r.get(t); 10158 n !== void 0 && xe(a.__webglFramebuffer, t, t.texture, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, 0), i !== void 0 && we(t); 10159 } 10160 function Ee(t) { 10161 let i = t.texture, s = r.get(t), c = r.get(i); 10162 t.addEventListener("dispose", w); 10163 let l = t.textures, u = t.isWebGLCubeRenderTarget === !0, d = l.length > 1; 10164 if (d || (c.__webglTexture === void 0 && (c.__webglTexture = e.createTexture()), c.__version = i.version, o.memory.textures++), u) { 10165 s.__webglFramebuffer = []; 10166 for (let t = 0; t < 6; t++) if (i.mipmaps && i.mipmaps.length > 0) { 10167 s.__webglFramebuffer[t] = []; 10168 for (let n = 0; n < i.mipmaps.length; n++) s.__webglFramebuffer[t][n] = e.createFramebuffer(); 10169 } else s.__webglFramebuffer[t] = e.createFramebuffer(); 10170 } else { 10171 if (i.mipmaps && i.mipmaps.length > 0) { 10172 s.__webglFramebuffer = []; 10173 for (let t = 0; t < i.mipmaps.length; t++) s.__webglFramebuffer[t] = e.createFramebuffer(); 10174 } else s.__webglFramebuffer = e.createFramebuffer(); 10175 if (d) for (let t = 0, n = l.length; t < n; t++) { 10176 let n = r.get(l[t]); 10177 n.__webglTexture === void 0 && (n.__webglTexture = e.createTexture(), o.memory.textures++); 10178 } 10179 if (t.samples > 0 && Me(t) === !1) { 10180 s.__webglMultisampledFramebuffer = e.createFramebuffer(), s.__webglColorRen
10180derbuffer = [], n.bindFramebuffer(e.FRAMEBUFFER, s.__webglMultisampledFramebuffer); 10181 for (let n = 0; n < l.length; n++) { 10182 let r = l[n]; 10183 s.__webglColorRenderbuffer[n] = e.createRenderbuffer(), e.bindRenderbuffer(e.RENDERBUFFER, s.__webglColorRenderbuffer[n]); 10184 let i = a.convert(r.format, r.colorSpace), o = a.convert(r.type), c = b(r.internalFormat, i, o, r.normalized, r.colorSpace, t.isXRRenderTarget === !0), u = F(t); 10185 e.renderbufferStorageMultisample(e.RENDERBUFFER, u, c, t.width, t.height), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + n, e.RENDERBUFFER, s.__webglColorRenderbuffer[n]); 10186 } 10187 e.bindRenderbuffer(e.RENDERBUFFER, null), t.depthBuffer && (s.__webglDepthRenderbuffer = e.createRenderbuffer(), Se(s.__webglDepthRenderbuffer, t, !0)), n.bindFramebuffer(e.FRAMEBUFFER, null); 10188 } 10189 } 10190 if (u) { 10191 n.bindTexture(e.TEXTURE_CUBE_MAP, c.__webglTexture), he(e.TEXTURE_CUBE_MAP, i); 10192 for (let n = 0; n < 6; n++) if (i.mipmaps && i.mipmaps.length > 0) for (let r = 0; r < i.mipmaps.length; r++) xe(s.__webglFramebuffer[n][r], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, r); 10193 else xe(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, e.TEXTURE_CUBE_MAP_POSITIVE_X + n, 0); 10194 _(i) && v(e.TEXTURE_CUBE_MAP), n.unbindTexture(); 10195 } else if (d) { 10196 for (let i = 0, a = l.length; i < a; i++) { 10197 let a = l[i], o = r.get(a), c = e.TEXTURE_2D; 10198 (t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (c = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(c, o.__webglTexture), he(c, a), xe(s.__webglFramebuffer, t, a, e.COLOR_ATTACHMENT0 + i, c, 0), _(a) && v(c); 10199 } 10200 n.unbindTexture(); 10201 } else { 10202 let r = e.TEXTURE_2D; 10203 if ((t.isWebGL3DRenderTarget || t.isWebGLArrayRenderTarget) && (r = t.isWebGL3DRenderTarget ? e.TEXTURE_3D : e.TEXTURE_2D_ARRAY), n.bindTexture(r, c.__webglTexture), he(r, i), i.mipmaps && i.mipmaps.length > 0) for (let n = 0; n < i.mipmaps.length; n++) xe(s.__webglFramebuffer[n], t, i, e.COLOR_ATTACHMENT0, r, n); 10204 else xe(s.__webglFramebuffer, t, i, e.COLOR_ATTACHMENT0, r, 0); 10205 _(i) && v(r), n.unbindTexture(); 10206 } 10207 t.depthBuffer && we(t); 10208 } 10209 function De(e) { 10210 let t = e.textures; 10211 for (let i = 0, a = t.length; i < a; i++) { 10212 let a = t[i]; 10213 if (_(a)) { 10214 let t = y(e), i = r.get(a).__webglTexture; 10215 n.bindTexture(t, i), v(t), n.unbindTexture(); 10216 } 10217 } 10218 } 10219 let Oe = [], Ae = []; 10220 function je(t) { 10221 if (t.samples > 0) { 10222 if (Me(t) === !1) { 10223 let i = t.textures, a = t.width, o = t.height, s = e.COLOR_BUFFER_BIT, l = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT, u = r.get(t), d = i.length > 1; 10224 if (d) for (let t = 0; t < i.length; t++) n.bindFramebuffer(e.FRAMEBUFFER, u.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.RENDERBUFFER, null), n.bindFramebuffer(e.FRAMEBUFFER, u.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.TEXTURE_2D, null, 0); 10225 n.bindFramebuffer(e.READ_FRAMEBUFFER, u.__webglMultisampledFramebuffer); 10226 let f = t.texture.mipmaps; 10227 f && f.length > 0 ? n.bindFramebuffer(e.DRAW_FRAMEBUFFER, u.__webglFramebuffer[0]) : n.bindFramebuffer(e.DRAW_FRAMEBUFFER, u.__webglFramebuffer); 10228 for (let n = 0; n < i.length; n++) { 10229 if (t.resolveDepthBuffer && (t.depthBuffer && (s |= e.DEPTH_BUFFER_BIT), t.stencilBuffer && t.resolveStencilBuffer && (s |= e.STENCIL_BUFFER_BIT)), d) { 10230 e.framebufferRenderbuffer(e.READ_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.RENDERBUFFER, u.__webglColorRenderbuffer[n]); 10231 let t = r.get(i[n]).__webglTexture; 10232 e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0); 10233 } 10234 e.blitFramebuffer(0, 0, a, o, 0, 0, a, o, s, e.NEAREST), c === !0 && (Oe.length = 0, Ae.length = 0, Oe.push(e.COLOR_ATTACHMENT0 + n), t.depthBuffer && t.resolveDepthBuffer === !1 && (Oe.push(l), Ae.push(l), e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, Ae)), e.invalidateFramebuffer(e.READ_FRAMEBUFFER, Oe)); 10235 } 10236 if (n.bindFramebuffer(e.READ_FRAMEBUFFER, null), n.bindFramebuffer(e.DRAW_FRAMEBUFFER, null), d) for (let t = 0; t < i.length; t++) { 10237 n.bindFramebuffer(e.FRAMEBUFFER, u.__webglMultisampledFramebuffer), e.framebufferRenderbuffer(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.RENDERBUFFER, u.__webglColorRen
10237derbuffer[t]); 10238 let a = r.get(i[t]).__webglTexture; 10239 n.bindFramebuffer(e.FRAMEBUFFER, u.__webglFramebuffer), e.framebufferTexture2D(e.DRAW_FRAMEBUFFER, e.COLOR_ATTACHMENT0 + t, e.TEXTURE_2D, a, 0); 10240 } 10241 n.bindFramebuffer(e.DRAW_FRAMEBUFFER, u.__webglMultisampledFramebuffer); 10242 } else if (t.depthBuffer && t.resolveDepthBuffer === !1 && c) { 10243 let n = t.stencilBuffer ? e.DEPTH_STENCIL_ATTACHMENT : e.DEPTH_ATTACHMENT; 10244 e.invalidateFramebuffer(e.DRAW_FRAMEBUFFER, [n]); 10245 } 10246 } 10247 } 10248 function F(e) { 10249 return Math.min(i.maxSamples, e.samples); 10250 } 10251 function Me(e) { 10252 let n = r.get(e); 10253 return e.samples > 0 && t.has("WEBGL_multisampled_render_to_texture") === !0 && n.__useRenderToTexture !== !1; 10254 } 10255 function Ne(e) { 10256 let t = o.render.frame; 10257 u.get(e) !== t && (u.set(e, t), e.update()); 10258 } 10259 function Pe(e, t) { 10260 let n = e.colorSpace, r = e.format, i = e.type; 10261 return e.isCompressedTexture === !0 || e.isVideoTexture === !0 || n !== "srgb-linear" && n !== "" && (q.getTransfer(n) === "srgb" ? (r !== 1023 || i !== 1009) && B("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType.") : V("WebGLTextures: Unsupported texture color space:", n)), t; 10262 } 10263 function I(e) { 10264 return typeof HTMLImageElement < "u" && e instanceof HTMLImageElement ? (l.width = e.naturalWidth || e.width, l.height = e.naturalHeight || e.height) : typeof VideoFrame < "u" && e instanceof VideoFrame ? (l.width = e.displayWidth, l.height = e.displayHeight) : (l.width = e.width, l.height = e.height), l; 10265 } 10266 this.allocateTextureUnit = te, this.resetTextureUnits = k, this.getTextureUnits = A, this.setTextureUnits = ee, this.setTexture2D = ne, this.setTexture2DArray = re, this.setTexture3D = M, this.setTextureCube = ie, this.rebindTextures = Te, this.setupRenderTarget = Ee, this.updateRenderTargetMipmap = De, this.updateMultisampleRenderTarget = je, this.setupDepthRenderbuffer = we, this.setupFrameBufferTexture = xe, this.useMultisampledRTT = Me, this.isReversedDepthBuffer = function() { 10267 return n.buffers.depth.getReversed(); 10268 }; 10269} 10270function Fl(e, t) { 10271 function n(n, r = "") { 10272 let i, a = q.getTransfer(r); 10273 if (n === 1009) return e.UNSIGNED_BYTE; 10274 if (n === 1017) return e.UNSIGNED_SHORT_4_4_4_4; 10275 if (n === 1018) return e.UNSIGNED_SHORT_5_5_5_1; 10276 if (n === 35902) return e.UNSIGNED_INT_5_9_9_9_REV; 10277 if (n === 35899) return e.UNSIGNED_INT_10F_11F_11F_REV; 10278 if (n === 1010) return e.BYTE; 10279 if (n === 1011) return e.SHORT; 10280 if (n === 1012) return e.UNSIGNED_SHORT; 10281 if (n === 1013) return e.INT; 10282 if (n === 1014) return e.UNSIGNED_INT; 10283 if (n === 1015) return e.FLOAT; 10284 if (n === 1016) return e.HALF_FLOAT; 10285 if (n === 1021) return e.ALPHA; 10286 if (n === 1022) return e.RGB; 10287 if (n === 1023) return e.RGBA; 10288 if (n === 1026) return e.DEPTH_COMPONENT; 10289 if (n === 1027) return e.DEPTH_STENCIL; 10290 if (n === 1028) return e.RED; 10291 if (n === 1029) return e.RED_INTEGER; 10292 if (n === 1030) return e.RG; 10293 if (n === 1031) return e.RG_INTEGER; 10294 if (n === 1033) return e.RGBA_INTEGER; 10295 if (n === 33776 || n === 33777 || n === 33778 || n === 33779) if (a === "srgb") if (i = t.get("WEBGL_compressed_texture_s3tc_srgb"), i !== null) { 10296 if (n === 33776) return i.COMPRESSED_SRGB_S3TC_DXT1_EXT; 10297 if (n === 33777) return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; 10298 if (n === 33778) return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT; 10299 if (n === 33779) return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; 10300 } else return null; 10301 else if (i = t.get("WEBGL_compressed_texture_s3tc"), i !== null) { 10302 if (n === 33776) return i.COMPRESSED_RGB_S3TC_DXT1_EXT; 10303 if (n === 33777) return i.COMPRESSED_RGBA_S3TC_DXT1_EXT; 10304 if (n === 33778) return i.COMPRESSED_RGBA_S3TC_DXT3_EXT; 10305 if (n === 33779) return i.COMPRESSED_RGBA_S3TC_DXT5_EXT; 10306 } else return null; 10307 if (n === 35840 || n === 35841 || n === 35842 || n === 35843) if (i = t.get("WEBGL_compressed_texture_pvrtc"), i !== null) { 10308 if (n === 35840) return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG; 10309 if (n === 35841) return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG; 10310 if (n === 35842) return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; 10311 if (n === 35843) return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; 10312 } else return null; 10313 if (n === 36196 || n === 37492 || n === 37496 || n === 37488 || n === 37489 || n === 37490 || n === 37491) if (i = t.get("WEBGL_compressed_texture_etc"), i !== null) { 10314 if (n === 36196 || n === 37492) return a === "srgb" ? i.COMPRESSED_SRGB8_ETC2 : i.COMPRESSED_RGB8_ETC2; 10315 if (n === 37496) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : i.COMPRESSED_RGBA8_ETC2_EAC;
10316 if (n === 37488) return i.COMPRESSED_R11_EAC; 10317 if (n === 37489) return i.COMPRESSED_SIGNED_R11_EAC; 10318 if (n === 37490) return i.COMPRESSED_RG11_EAC; 10319 if (n === 37491) return i.COMPRESSED_SIGNED_RG11_EAC; 10320 } else return null; 10321 if (n === 37808 || n === 37809 || n === 37810 || n === 37811 || n === 37812 || n === 37813 || n === 37814 || n === 37815 || n === 37816 || n === 37817 || n === 37818 || n === 37819 || n === 37820 || n === 37821) if (i = t.get("WEBGL_compressed_texture_astc"), i !== null) { 10322 if (n === 37808) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR : i.COMPRESSED_RGBA_ASTC_4x4_KHR; 10323 if (n === 37809) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR : i.COMPRESSED_RGBA_ASTC_5x4_KHR; 10324 if (n === 37810) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR : i.COMPRESSED_RGBA_ASTC_5x5_KHR; 10325 if (n === 37811) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR : i.COMPRESSED_RGBA_ASTC_6x5_KHR; 10326 if (n === 37812) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR : i.COMPRESSED_RGBA_ASTC_6x6_KHR; 10327 if (n === 37813) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR : i.COMPRESSED_RGBA_ASTC_8x5_KHR; 10328 if (n === 37814) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR : i.COMPRESSED_RGBA_ASTC_8x6_KHR; 10329 if (n === 37815) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR : i.COMPRESSED_RGBA_ASTC_8x8_KHR; 10330 if (n === 37816) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR : i.COMPRESSED_RGBA_ASTC_10x5_KHR; 10331 if (n === 37817) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR : i.COMPRESSED_RGBA_ASTC_10x6_KHR; 10332 if (n === 37818) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR : i.COMPRESSED_RGBA_ASTC_10x8_KHR; 10333 if (n === 37819) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR : i.COMPRESSED_RGBA_ASTC_10x10_KHR; 10334 if (n === 37820) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR : i.COMPRESSED_RGBA_ASTC_12x10_KHR; 10335 if (n === 37821) return a === "srgb" ? i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR : i.COMPRESSED_RGBA_ASTC_12x12_KHR; 10336 } else return null; 10337 if (n === 36492 || n === 36494 || n === 36495) if (i = t.get("EXT_texture_compression_bptc"), i !== null) { 10338 if (n === 36492) return a === "srgb" ? i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT : i.COMPRESSED_RGBA_BPTC_UNORM_EXT; 10339 if (n === 36494) return i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT; 10340 if (n === 36495) return i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT; 10341 } else return null; 10342 if (n === 36283 || n === 36284 || n === 36285 || n === 36286) if (i = t.get("EXT_texture_compression_rgtc"), i !== null) { 10343 if (n === 36283) return i.COMPRESSED_RED_RGTC1_EXT; 10344 if (n === 36284) return i.COMPRESSED_SIGNED_RED_RGTC1_EXT; 10345 if (n === 36285) return i.COMPRESSED_RED_GREEN_RGTC2_EXT; 10346 if (n === 36286) return i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT; 10347 } else return null; 10348 return n === 1020 ? e.UNSIGNED_INT_24_8 : e[n] === void 0 ? null : e[n]; 10349 } 10350 return { convert: n }; 10351} 10352var Il = "\nvoid main() {\n\n gl_Position = vec4( position, 1.0 );\n\n}", Ll = "\nuniform sampler2DArray depthColor;\nuniform float depthWidth;\nuniform float depthHeight;\n\nvoid main() {\n\n vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );\n\n if ( coord.x >= 1.0 ) {\n\n gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;\n\n } else {\n\n gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;\n\n }\n\n}", Rl = class { 10353 constructor() { 10354 this.texture = null, this.mesh = null, this.depthNear = 0, this.depthFar = 0; 10355 } 10356 init(e, t) { 10357 if (this.texture === null) { 10358 let n = new pa(e.texture); 10359 (e.depthNear !== t.depthNear || e.depthFar !== t.depthFar) && (this.depthNear = e.depthNear, this.depthFar = e.depthFar), this.texture = n; 10360 } 10361 } 10362 getMesh(e) { 10363 if (this.texture !== null && this.mesh === null) { 10364 let t = e.cameras[0].viewport, n = new Ea({ 10365 vertexShader: Il, 10366 fragmentShader: Ll, 10367 uniforms: { 10368 depthColor: { value: this.texture }, 10369 depthWidth: { value: t.z }, 10370 depthHeight: { value: t.w } 10371 } 10372 }); 10373 this.mesh = new Mi(new ha(20, 20), n); 10374 } 10375 return this.mesh; 10376 } 10377 reset() { 10378 this.texture = null, this.mesh = null; 10379 } 10380 getDepthTexture() { 10381 return this.texture; 10382 } 10383}, zl = class extends Lt { 10384 constructor(e, t) { 10385 super(); 10386 let n = this, r = null, i = 1, a = null, o = "local-floor", s = 1, c = null, l = null, u = null, d = null, f = null, p = null, m = typeof XRWebGLBinding < "u", h = new Rl(), g = {}, _ = t.getContextAttributes(), v = null, y = null, b = [], x = [], S = new W(), C = null, w = new $a(); 10387 w.viewport = new J(); 10388 let T = new $a(); 10389 T.viewport = new J(); 10390 let E = [w, T], D = new ao(), O = null, k = null; 10391 this.cameraAutoUpdate = !0, this.enabled = !1, this.isPresenting = !1, this.getController = function(e) { 10392 let t = b[e]; 10393 return t === void 0 && (t = new sr(), b[e] = t), t.getTargetRaySpace(); 10394 }, this.getControllerGrip = function(e) { 10395 let t = b[e]; 10396 return t === void 0 && (t = new sr(), b[e] = t), t.getGripSpace(); 10397 }, this.getHand = function(e) { 10398 let t = b[e]; 10399 return t === void 0 && (t = new sr(), b[e] = t), t.getHandSpace(); 10400 }; 10401 function A(e) { 10402 let t = x.indexOf(e.inputSource); 10403 if (t === -1) return; 10404 let n = b[t]; 10405 n !== void 0 && (n.update(e.inputSource, e.frame, c || a), n.dispatchEvent({ 10406 type: e.type, 10407 data: e.inputSource 10408 })); 10409 } 10410 function ee() { 10411 r.removeEventListener("select", A), r.removeEventListener("selectstart", A), r.removeEventListener("selectend", A), r.removeEventListener("squeeze", A), r.removeEventListener("squeezestart", A), r.removeEventListener("squeezeend", A), r.removeEventListener("end", ee), r.removeEventListener("inputsourceschange", te); 10412 for (let e = 0; e < b.length; e++) { 10413 let t = x[e]; 10414 t !== null && (x[e] = null, b[e].disconnect(t)); 10415 } 10416 O = null, k = null, h.reset(); 10417 for (let e in g) delete g[e]; 10418 e.setRenderTarget(v), f = null, d = null, u = null, r = null, y = null, se.stop(), n.isPresenting = !1, e.setP
10418ixelRatio(C), e.setSize(S.width, S.height, !1), n.dispatchEvent({ type: "sessionend" }); 10419 } 10420 this.setFramebufferScaleFactor = function(e) { 10421 i = e, n.isPresenting === !0 && B("WebXRManager: Cannot change framebuffer scale while presenting."); 10422 }, this.setReferenceSpaceType = function(e) { 10423 o = e, n.isPresenting === !0 && B("WebXRManager: Cannot change reference space type while presenting."); 10424 }, this.getReferenceSpace = function() { 10425 return c || a; 10426 }, this.setReferenceSpace = function(e) { 10427 c = e; 10428 }, this.getBaseLayer = function() { 10429 return d === null ? f : d; 10430 }, this.getBinding = function() { 10431 return u === null && m && (u = new XRWebGLBinding(r, t)), u; 10432 }, this.getFrame = function() { 10433 return p; 10434 }, this.getSession = function() { 10435 return r; 10436 }, this.setSession = async function(l) { 10437 if (r = l, r !== null) { 10438 if (v = e.getRenderTarget(), r.addEventListener("select", A), r.addEventListener("selectstart", A), r.addEventListener("selectend", A), r.addEventListener("squeeze", A), r.addEventListener("squeezestart", A), r.addEventListener("squeezeend", A), r.addEventListener("end", ee), r.addEventListener("inputsourceschange", te), _.xrCompatible !== !0 && await t.makeXRCompatible(), C = e.getPixelRatio(), e.getSize(S), m && "createProjectionLayer" in XRWebGLBinding.prototype) { 10439 let n = null, a = null, o = null; 10440 _.depth && (o = _.stencil ? t.DEPTH24_STENCIL8 : t.DEPTH_COMPONENT24, n = _.stencil ? ke : Oe, a = _.stencil ? Se : _e); 10441 let s = { 10442 colorFormat: t.RGBA8, 10443 depthFormat: o, 10444 scaleFactor: i 10445 }; 10446 u = this.getBinding(), d = u.createProjectionLayer(s), r.updateRenderState({ layers: [d] }), e.setPixelRatio(1), e.setSize(d.textureWidth, d.textureHeight, !1), y = new On(d.textureWidth, d.textureHeight, { 10447 format: De, 10448 type: fe, 10449 depthTexture: new da(d.textureWidth, d.textureHeight, a, void 0, void 0, void 0, void 0, void 0, void 0, n), 10450 stencilBuffer: _.stencil, 10451 colorSpace: e.outputColorSpace, 10452 samples: _.antialias ? 4 : 0, 10453 resolveDepthBuffer: d.ignoreDepthValues === !1, 10454 resolveStencilBuffer: d.ignoreDepthValues === !1 10455 }); 10456 } else { 10457 let n = { 10458 antialias: _.antialias, 10459 alpha: !0, 10460 depth: _.depth, 10461 stencil: _.stencil, 10462 framebufferScaleFactor: i 10463 }; 10464 f = new XRWebGLLayer(r, t, n), r.updateRenderState({ baseLayer: f }), e.setPixelRatio(1), e.setSize(f.framebufferWidth, f.framebufferHeight, !1), y = new On(f.framebufferWidth, f.framebufferHeight, { 10465 format: De, 10466 type: fe, 10467 colorSpace: e.outputColorSpace, 10468 stencilBuffer: _.stencil, 10469 resolveDepthBuffer: f.ignoreDepthValues === !1, 10470 resolveStencilBuffer: f.ignoreDepthValues === !1 10471 }); 10472 } 10473 y.isXRRenderTarget = !0, this.setFoveation(s), c = null, a = await r.requestReferenceSpace(o), se.setContext(r), se.start(), n.isPresenting = !0, n.dispatchEvent({ type: "sessionstart" }); 10474 } 10475 }, this.getEnvironmentBlendMode = function() { 10476 if (r !== null) return r.environmentBlendMode; 10477 }, this.getDepthTexture = function() { 10478 return h.getDepthTexture(); 10479 }; 10480 function te(e) { 10481 for (let t = 0; t < e.removed.length; t++) { 10482 let n = e.removed[t], r = x.indexOf(n); 10483 r >= 0 && (x[r] = null, b[r].disconnect(n)); 10484 } 10485 for (let t = 0; t < e.added.length; t++) { 10486 let n = e.added[t], r = x.indexOf(n); 10487 if (r === -1) { 10488 for (let e = 0; e < b.length; e++) if (e >= x.length) { 10489 x.push(n), r = e; 10490 break; 10491 } else if (x[e] === null) { 10492 x[e] = n, r = e; 10493 break; 10494 } 10495 if (r === -1) break; 10496 } 10497 let i = b[r]; 10498 i && i.connect(n); 10499 } 10500 } 10501 let j = new G(), ne = new G(); 10502 function re(e, t, n) { 10503 j.setFromMatrixPosition(t.matrixWorld), ne.setFromMatrixPosition(n.matrixWorld); 10504 let r = j.distanceTo(ne), i = t.projectionMatrix.elements, a = n.projectionMatrix.elements, o = i[14] / (i[10] - 1), s = i[14] / (i[10] + 1), c = (i[9] + 1) / i[5], l = (i[9] - 1) / i[5], u = (i[8] - 1) / i[0], d = (a[8] + 1) / a[0], f = o * u, p = o * d, m = r / (-u + d), h = m * -u; 10505 if (t.matrixWorld.decompose(e.position, e.quaternion, e.scale), e.translateX(h), e.translateZ(m), e.matrixWorld.compose(e.position, e.quaternion, e.scale), e.matrixWorldInverse.copy(e.matrixWorld).invert(), i[10] === -1) e.projectionMatrix.copy(t.projectionMatrix), e.projectionMatrixInverse.copy(t.projectionMatrixInverse); 10506 else { 10507 let t = o + m, n = s + m, i = f - h, a = p + (r - h), u = c * s / n * t, d = l * s / n * t; 10508 e.projectionMatrix.makePerspective(i, a, u, d, t, n), e.projectionMatrixInverse.copy(e.projectionMatrix).invert(); 10509 } 10510 } 10511 function M(e, t) { 10512 t === null ? e.matrixWorld.copy(e.matrix) : e.matrixWorld.multiplyMatrices(t.matrixWorld, e.matrix), e.matrixWorldInverse.copy(e.matrixWorld).invert(); 10513 } 10514 this.updateCamera = function(e) { 10515 if (r === null) return; 10516 let t = e.near, n = e.far; 10517 h.texture !== null && (h.depthNear > 0 && (t = h.depthNear), h.depthFar >
10517 0 && (n = h.depthFar)), D.near = T.near = w.near = t, D.far = T.far = w.far = n, (O !== D.near || k !== D.far) && (r.updateRenderState({ 10518 depthNear: D.near, 10519 depthFar: D.far 10520 }), O = D.near, k = D.far), D.layers.mask = e.layers.mask | 6, w.layers.mask = D.layers.mask & -5, T.layers.mask = D.layers.mask & -3; 10521 let i = e.parent, a = D.cameras; 10522 M(D, i); 10523 for (let e = 0; e < a.length; e++) M(a[e], i); 10524 a.length === 2 ? re(D, w, T) : D.projectionMatrix.copy(w.projectionMatrix), ie(e, D, i); 10525 }; 10526 function ie(e, t, n) { 10527 n === null ? e.matrix.copy(t.matrixWorld) : (e.matrix.copy(n.matrixWorld), e.matrix.invert(), e.matrix.multiply(t.matrixWorld)), e.matrix.decompose(e.position, e.quaternion, e.scale), e.updateMatrixWorld(!0), e.projectionMatrix.copy(t.projectionMatrix), e.projectionMatrixInverse.copy(t.projectionMatrixInverse), e.isPerspectiveCamera && (e.fov = Vt * 2 * Math.atan(1 / e.projectionMatrix.elements[5]), e.zoom = 1); 10528 } 10529 this.getCamera = function() { 10530 return D; 10531 }, this.getFoveation = function() { 10532 if (!(d === null && f === null)) return s; 10533 }, this.setFoveation = function(e) { 10534 s = e, d !== null && (d.fixedFoveation = e), f !== null && f.fixedFoveation !== void 0 && (f.fixedFoveation = e); 10535 }, this.hasDepthSensing = function() { 10536 return h.texture !== null; 10537 }, this.getDepthSensingMesh = function() { 10538 return h.getMesh(D); 10539 }, this.getCameraTexture = function(e) { 10540 return g[e]; 10541 }; 10542 let ae = null; 10543 function oe(t, i) { 10544 if (l = i.getViewerPose(c || a), p = i, l !== null) { 10545 let t = l.views; 10546 f !== null && (e.setRenderTargetFramebuffer(y, f.framebuffer), e.setRenderTarget(y)); 10547 let i = !1; 10548 t.length !== D.cameras.length && (D.cameras.length = 0, i = !0); 10549 for (let n = 0; n < t.length; n++) { 10550 let r = t[n], a = null; 10551 if (f !== null) a = f.getViewport(r); 10552 else { 10553 let t = u.getViewSubImage(d, r); 10554 a = t.viewport, n === 0 && (e.setRenderTargetTextures(y, t.colorTexture, t.depthStencilTexture), e.setRenderTarget(y)); 10555 } 10556 let o = E[n]; 10557 o === void 0 && (o = new $a(), o.layers.enable(n), o.viewport = new J(), E[n] = o), o.matrix.fromArray(r.transform.matrix), o.matrix.decompose(o.position, o.quaternion, o.scale), o.projectionMatrix.fromArray(r.projectionMatrix), o.projectionMatrixInverse.copy(o.projectionMatrix).invert(), o.viewport.set(a.x, a.y, a.width, a.height), n === 0 && (D.matrix.copy(o.matrix), D.matrix.decompose(D.position, D.quaternion, D.scale)), i === !0 && D.cameras.push(o); 10558 } 10559 let a = r.enabledFeatures; 10560 if (a && a.includes("depth-sensing") && r.depthUsage == "gpu-optimized" && m) { 10561 u = n.getBinding(); 10562 let e = u.getDepthInformation(t[0]); 10563 e && e.isValid && e.texture && h.init(e, r.renderState); 10564 } 10565 if (a && a.includes("camera-access") && m) { 10566 e.state.unbindTexture(), u = n.getBinding(); 10567 for (let e = 0; e < t.length; e++) { 10568 let n = t[e].camera; 10569 if (n) { 10570 let e = g[n]; 10571 e || (e = new pa(), g[n] = e); 10572 let t = u.getCameraImage(n); 10573 e.sourceTexture = t; 10574 } 10575 } 10576 } 10577 } 10578 for (let e = 0; e < b.length; e++) { 10579 let t = x[e], n = b[e]; 10580 t !== null && n !== void 0 && n.update(t, i, c || a); 10581 } 10582 ae && ae(t, i), i.detectedPlanes && n.dispatchEvent({ 10583 type: "planesdetected", 10584 data: i 10585 }), p = null; 10586 } 10587 let se = new Mo(); 10588 se.setAnimationLoop(oe), this.setAnimationLoop = function(e) { 10589 ae = e; 10590 }, this.dispose = function() {}; 10591 } 10592}, Bl = /*@__PURE__*/ new jn(), Vl = /*@__PURE__*/ new K(); 10593Vl.set(-1, 0, 0, 0, 1, 0, 0, 0, 1); 10594function Hl(e, t) { 10595 function n(e, t) { 10596 e.matrixAutoUpdate === !0 && e.updateMatrix(), t.value.copy(e.matrix); 10597 } 10598 function r(t, n) { 10599 n.color.getRGB(t.fogColor.value, Sa(e)), n.isFog ? (t.fogNear.value = n.near, t.fogFar.value = n.far) : n.isFogExp2 && (t.fogDensity.value = n.density); 10600 } 10601 function i(e, t, n, r, i) { 10602 t.isNodeMaterial ? t.uniformsNeedUpdate = !1 : t.isMeshBasicMaterial ? a(e, t) : t.isMeshLambertMaterial ? (a(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshToonMaterial ? (a(e, t), d(e, t)) : t.isMeshPhongMaterial ? (a(e, t), u(e, t), t.envMap && (e.envMapIntensity.value = t.envMapIntensity)) : t.isMeshStandardMaterial ? (a(e, t), f(e, t), t.isMeshPhysicalMaterial && p(e, t, i)) : t.isMeshMat
10602capMaterial ? (a(e, t), m(e, t)) : t.isMeshDepthMaterial ? a(e, t) : t.isMeshDistanceMaterial ? (a(e, t), h(e, t)) : t.isMeshNormalMaterial ? a(e, t) : t.isLineBasicMaterial ? (o(e, t), t.isLineDashedMaterial && s(e, t)) : t.isPointsMaterial ? c(e, t, n, r) : t.isSpriteMaterial ? l(e, t) : t.isShadowMaterial ? (e.color.value.copy(t.color), e.opacity.value = t.opacity) : t.isShaderMaterial && (t.uniformsNeedUpdate = !1); 10603 } 10604 function a(e, r) { 10605 e.opacity.value = r.opacity, r.color && e.diffuse.value.copy(r.color), r.emissive && e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity), r.map && (e.map.value = r.map, n(r.map, e.mapTransform)), r.alphaMap && (e.alphaMap.value = r.alphaMap, n(r.alphaMap, e.alphaMapTransform)), r.bumpMap && (e.bumpMap.value = r.bumpMap, n(r.bumpMap, e.bumpMapTransform), e.bumpScale.value = r.bumpScale, r.side === 1 && (e.bumpScale.value *= -1)), r.normalMap && (e.normalMap.value = r.normalMap, n(r.normalMap, e.normalMapTransform), e.normalScale.value.copy(r.normalScale), r.side === 1 && e.normalScale.value.negate()), r.displacementMap && (e.displacementMap.value = r.displacementMap, n(r.displacementMap, e.displacementMapTransform), e.displacementScale.value = r.displacementScale, e.displacementBias.value = r.displacementBias), r.emissiveMap && (e.emissiveMap.value = r.emissiveMap, n(r.emissiveMap, e.emissiveMapTransform)), r.specularMap && (e.specularMap.value = r.specularMap, n(r.specularMap, e.specularMapTransform)), r.alphaTest > 0 && (e.alphaTest.value = r.alphaTest); 10606 let i = t.get(r), a = i.envMap, o = i.envMapRotation; 10607 a && (e.envMap.value = a, e.envMapRotation.value.setFromMatrix4(Bl.makeRotationFromEuler(o)).transpose(), a.isCubeTexture && a.isRenderTargetTexture === !1 && e.envMapRotation.value.premultiply(Vl), e.reflectivity.value = r.reflectivity, e.ior.value = r.ior, e.refractionRatio.value = r.refractionRatio), r.lightMap && (e.lightMap.value = r.lightMap, e.lightMapIntensity.value = r.lightMapIntensity, n(r.lightMap, e.lightMapTransform)), r.aoMap && (e.aoMap.value = r.aoMap, e.aoMapIntensity.value = r.aoMapIntensity, n(r.aoMap, e.aoMapTransform)); 10608 } 10609 function o(e, t) { 10610 e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, t.map && (e.map.value = t.map, n(t.map, e.mapTransform)); 10611 } 10612 function s(e, t) { 10613 e.dashSize.value = t.dashSize, e.totalSize.value = t.dashSize + t.gapSize, e.scale.value = t.scale; 10614 } 10615 function c(e, t, r, i) { 10616 e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, e.size.value = t.size * r, e.scale.value = i * .5, t.map && (e.map.value = t.map, n(t.map, e.uvTransform)), t.alphaMap && (e.alphaMap.value = t.alphaMap, n(t.alphaMap, e.alphaMapTransform)), t.alphaTest > 0 && (e.alphaTest.value = t.alphaTest); 10617 } 10618 function l(e, t) { 10619 e.diffuse.value.copy(t.color), e.opacity.value = t.opacity, e.rotation.value = t.rotation, t.map && (e.map.value = t.map, n(t.map, e.mapTransform)), t.alphaMap && (e.alphaMap.value = t.alphaMap, n(t.alphaMap, e.alphaMapTransform)), t.alphaTest > 0 && (e.alphaTest.value = t.alphaTest); 10620 } 10621 function u(e, t) { 10622 e.specular.value.copy(t.specular), e.shininess.value = Math.max(t.shininess, 1e-4); 10623 } 10624 function d(e, t) { 10625 t.gradientMap && (e.gradientMap.value = t.gradientMap); 10626 } 10627 function f(e, t) { 10628 e.metalness.value = t.metalness, t.metalnessMap && (e.metalnessMap.value = t.metalnessMap, n(t.metalnessMap, e.metalnessMapTransform)), e.roughness.value = t.roughness, t.roughnessMap && (e.roughnessMap.value = t.roughnessMap, n(t.roughnessMap, e.roughnessMapTransform)), t.envMap && (e.envMapIntensity.value = t.envMapIntensity); 10629 } 10630 function p(e, t, r) { 10631 e.ior.value = t.ior, t.sheen > 0 && (e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen), e.sheenRoughness.value = t.sheenRoughness, t.sheenColorMap && (e.sheenColorMap.value = t.sheenColorMap, n(t.sheenColorMap, e.sheenColorMapTransform)), t.sheenRoughnessMap && (e.sheenRoughnessMap.value = t.sheenRoughnessMap, n(t.sheenRoughnessMap, e.sheenRoughnessMapTransform))), t.clearcoat > 0 && (e.clearcoat.value = t.clearcoat, e.clearcoatRoughness.value = t.clearcoatRoughness, t.clearcoatMap && (e.clearcoatMap.value = t.clearcoatMap, n(t.clearcoatMap, e.clearcoatMapTransform)), t.clearcoatRoughnessMap && (e.clearcoatRoughnessMap.value = t.clearcoatRoughnessMap, n(t.clearcoatRoughnessMap, e.clearcoatRoughnessMapTransform)), t.clearcoatNormalMap && (e.clearcoatNormalMap.value = t.clearcoatNormalMap, n(t.clearcoatNormalMap, e.clearcoatNormalMapTransform), e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale), t.side === 1 && e.clearcoatNormalScale.value.negate())), t.dispersion >
10631 0 && (e.dispersion.value = t.dispersion), t.iridescence > 0 && (e.iridescence.value = t.iridescence, e.iridescenceIOR.value = t.iridescenceIOR, e.iridescenceThicknessMinimum.value = t.iridescenceThicknessRange[0], e.iridescenceThicknessMaximum.value = t.iridescenceThicknessRange[1], t.iridescenceMap && (e.iridescenceMap.value = t.iridescenceMap, n(t.iridescenceMap, e.iridescenceMapTransform)), t.iridescenceThicknessMap && (e.iridescenceThicknessMap.value = t.iridescenceThicknessMap, n(t.iridescenceThicknessMap, e.iridescenceThicknessMapTransform))), t.transmission > 0 && (e.transmission.value = t.transmission, e.transmissionSamplerMap.value = r.texture, e.transmissionSamplerSize.value.set(r.width, r.height), t.transmissionMap && (e.transmissionMap.value = t.transmissionMap, n(t.transmissionMap, e.transmissionMapTransform)), e.thickness.value = t.thickness, t.thicknessMap && (e.thicknessMap.value = t.thicknessMap, n(t.thicknessMap, e.thicknessMapTransform)), e.attenuationDistance.value = t.attenuationDistance, e.attenuationColor.value.copy(t.attenuationColor)), t.anisotropy > 0 && (e.anisotropyVector.value.set(t.anisotropy * Math.cos(t.anisotropyRotation), t.anisotropy * Math.sin(t.anisotropyRotation)), t.anisotropyMap && (e.anisotropyMap.value = t.anisotropyMap, n(t.anisotropyMap, e.anisotropyMapTransform))), e.specularIntensity.value = t.specularIntensity, e.specularColor.value.copy(t.specularColor), t.specularColorMap && (e.specularColorMap.value = t.specularColorMap, n(t.specularColorMap, e.specularColorMapTransform)), t.specularIntensityMap && (e.specularIntensityMap.value = t.specularIntensityMap, n(t.specularIntensityMap, e.specularIntensityMapTransform)); 10632 } 10633 function m(e, t) { 10634 t.matcap && (e.matcap.value = t.matcap); 10635 } 10636 function h(e, n) { 10637 let r = t.get(n).light; 10638 e.referencePosition.value.setFromMatrixPosition(r.matrixWorld), e.nearDistance.value = r.shadow.camera.near, e.farDistance.value = r.shadow.camera.far; 10639 } 10640 return { 10641 refreshFogUniforms: r, 10642 refreshMaterialUniforms: i 10643 }; 10644} 10645function Ul(e, t, n, r) { 10646 let i = {}, a = {}, o = [], s = e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS); 10647 function c(e, t) { 10648 let n = t.program; 10649 r.uniformBlockBinding(e, n); 10650 } 10651 function l(e, n) { 10652 let o = i[e.id]; 10653 o === void 0 && (g(e), o = u(e), i[e.id] = o, e.addEventListener("dispose", v)); 10654 let s = n.program; 10655 r.updateUBOMapping(e, s); 10656 let c = t.render.frame; 10657 a[e.id] !== c && (f(e), a[e.id] = c); 10658 } 10659 function u(t) { 10660 let n = d(); 10661 t.__bindingPointIndex = n; 10662 let r = e.createBuffer(), i = t.__size, a = t.usage; 10663 return e.bindBuffer(e.UNIFORM_BUFFER, r), e.bufferData(e.UNIFORM_BUFFER, i, a), e.bindBuffer(e.UNIFORM_BUFFER, null), e.bindBufferBase(e.UNIFORM_BUFFER, n, r), r; 10664 } 10665 function d() { 10666 for (let e = 0; e < s; e++) if (o.indexOf(e) === -1) return o.push(e), e; 10667 return V("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."), 0; 10668 } 10669 function f(t) { 10670 let n = i[t.id], r = t.uniforms, a = t.__cache; 10671 e.bindBuffer(e.UNIFORM_BUFFER, n); 10672 for (let e = 0, t = r.length; e < t; e++) { 10673 let t = r[e]; 10674 if (Array.isArray(t)) for (let n = 0, r = t.length; n < r; n++) p(t[n], e, n, a); 10675 else p(t, e, 0, a); 10676 } 10677 e.bindBuffer(e.UNIFORM_BUFFER, null); 10678 } 10679 function p(t, n, r, i) { 10680 if (h(t, n, r, i) === !0) { 10681 let n = t.__offset, r = t.value; 10682 if (Array.isArray(r)) { 10683 let e = 0; 10684 for (let n = 0; n < r.length; n++) { 10685 let i = r[n], a = _(i); 10686 m(i, t.__data, e), typeof i != "number" && typeof i != "boolean" && !i.isMatrix3 && !ArrayBuffer.isView(i) && (e += a.storage / Float32Array.BYTES_PER_ELEMENT); 10687 } 10688 } else m(r, t.__data, 0); 10689 e.bufferSubData(e.UNIFORM_BUFFER, n, t.__data); 10690 } 10691 } 10692 function m(e, t, n) { 10693 typeof e == "number" || typeof e == "boolean" ? t[0] = e : e.isMatrix3 ? (t[0] = e.elements[0], t[1] = e.elements[1], t[2] = e.elements[2], t[3] = 0, t[4] = e.elements[3], t[5] = e.elements[4], t[6] = e.elements[5], t[7] = 0, t[8] = e.elements[6], t[9] = e.elements[7], t[10] = e.elements[8], t[11] = 0) : ArrayBuffer.isView(e) ? t.set(new e.constructor(e.buffer, e.byteOffset, t.length)) : e.toArray(t, n); 10694 } 10695 function h(e, t, n, r) { 10696 let i = e.value, a = t + "_" + n; 10697 if (r[a] === void 0) return typeof i == "number" || typeof i == "boolean" ? r[a] = i : ArrayBuffer.isView(i) ? r[a] = i.slice() : r[a] = i.clone(), !0; 10698 { 10699 let e = r[a]; 10700 if (typeof i == "number" || typeof i == "boolean") { 10701 if (e !== i) return r[a] = i, !0; 10702 } else if (ArrayBuffer.isView(i)) return !0; 10703 else if (e.equals(i) === !1) return e.copy(i), !0; 10704 } 10705 return !1; 10706 } 10707 function g(e) { 10708 let t = e.uniforms, n = 0; 10709 for (let e = 0, r = t.length; e < r; e++) {
10710 let r = Array.isArray(t[e]) ? t[e] : [t[e]]; 10711 for (let e = 0, t = r.length; e < t; e++) { 10712 let t = r[e], i = Array.isArray(t.value) ? t.value : [t.value]; 10713 for (let e = 0, r = i.length; e < r; e++) { 10714 let r = i[e], a = _(r), o = n % 16, s = o % a.boundary, c = o + s; 10715 n += s, c !== 0 && 16 - c < a.storage && (n += 16 - c), t.__data = new Float32Array(a.storage / Float32Array.BYTES_PER_ELEMENT), t.__offset = n, n += a.storage; 10716 } 10717 } 10718 } 10719 let r = n % 16; 10720 return r > 0 && (n += 16 - r), e.__size = n, e.__cache = {}, this; 10721 } 10722 function _(e) { 10723 let t = { 10724 boundary: 0, 10725 storage: 0 10726 }; 10727 return typeof e == "number" || typeof e == "boolean" ? (t.boundary = 4, t.storage = 4) : e.isVector2 ? (t.boundary = 8, t.storage = 8) : e.isVector3 || e.isColor ? (t.boundary = 16, t.storage = 12) : e.isVector4 ? (t.boundary = 16, t.storage = 16) : e.isMatrix3 ? (t.boundary = 48, t.storage = 48) : e.isMatrix4 ? (t.boundary = 64, t.storage = 64) : e.isTexture ? B("WebGLRenderer: Texture samplers can not be part of an uniforms group.") : ArrayBuffer.isView(e) ? (t.boundary = 16, t.storage = e.byteLength) : B("WebGLRenderer: Unsupported uniform value type.", e), t; 10728 } 10729 function v(t) { 10730 let n = t.target; 10731 n.removeEventListener("dispose", v); 10732 let r = o.indexOf(n.__bindingPointIndex); 10733 o.splice(r, 1), e.deleteBuffer(i[n.id]), delete i[n.id], delete a[n.id]; 10734 } 10735 function y() { 10736 for (let t in i) e.deleteBuffer(i[t]); 10737 o = [], i = {}, a = {}; 10738 } 10739 return { 10740 bind: c, 10741 update: l, 10742 dispose: y 10743 }; 10744} 10745var Wl = new Uint16Array([ 10746 12469, 10747 15057, 10748 12620, 10749 14925, 10750 13266, 10751 14620, 10752 13807, 10753 14376, 10754 14323, 10755 13990, 10756 14545, 10757 13625, 10758 14713, 10759 13328, 10760 14840, 10761 12882, 10762 14931, 10763 12528, 10764 14996, 10765 12233, 10766 15039, 10767 11829, 10768 15066, 10769 11525, 10770 15080, 10771 11295, 10772 15085, 10773 10976, 10774 15082, 10775 10705, 10776 15073, 10777 10495, 10778 13880, 10779 14564, 10780 13898, 10781 14542, 10782 13977, 10783 14430, 10784 14158, 10785 14124, 10786 14393, 10787 13732, 10788 14556, 10789 13410, 10790 14702, 10791 12996, 10792 14814, 10793 12596, 10794 14891, 10795 12291, 10796 14937, 10797 11834, 10798 14957, 10799 11489, 10800 14958, 10801 11194, 10802 14943, 10803 10803, 10804 14921, 10805 10506, 10806 14893, 10807 10278, 10808 14858, 10809 9960, 10810 14484, 10811 14039, 10812 14487, 10813 14025, 10814 14499, 10815 13941, 10816 14524, 10817 13740, 10818 14574, 10819 13468, 10820 14654, 10821 13106, 10822 14743, 10823 12678, 10824 14818, 10825 12344, 10826 14867, 10827 11893, 10828 14889, 10829 11509, 10830 14893, 10831 11180, 10832 14881, 10833 10751, 10834 14852, 10835 10428, 10836 14812, 10837 10128, 10838 14765, 10839 9754, 10840 14712, 10841 9466, 10842 14764, 10843 13480, 10844 14764, 10845 13475, 10846 14766, 10847 13440, 10848 14766, 10849 13347, 10850 14769, 10851 13070, 10852 14786, 10853 12713, 10854 14816, 10855 12387, 10856 14844, 10857 11957, 10858 14860, 10859 11549, 10860 14868, 10861 11215, 10862 14855, 10863 10751, 10864 14825, 10865 10403, 10866 14782, 10867 10044, 10868 14729, 10869 9651, 10870 14666, 10871 9352, 10872 14599, 10873 9029, 10874 14967, 10875 12835, 10876 14966, 10877 12831, 10878 14963, 10879 12804, 10880 14954, 10881 12723, 10882 14936, 10883 12564, 10884 14917, 10885 12347, 10886 14900, 10887 11958, 10888 14886, 10889 11569, 10890 14878, 10891 11247, 10892 14859, 10893 10765, 10894 14828, 10895 10401, 10896 14784, 10897 10011, 10898 14727, 10899 9600, 10900 14660, 10901 9289, 10902 14586, 10903 8893, 10904 14508, 10905 8533, 10906 15111, 10907 12234, 10908 15110, 10909 12234, 10910 15104, 10911 12216, 10912 15092, 10913 12156, 10914 15067, 10915 12010, 10916 15028, 10917 11776, 10918 14981, 10919 11500, 10920 14942, 10921 11205, 10922 14902, 10923 10752, 10924 14861, 10925 10393, 10926 14812, 10927 9991, 10928 14752, 10929 9570, 10930 14682, 10931 9252, 10932 14603, 10933 8808, 10934 14519, 10935 8445, 10936 14431, 10937 8145, 10938 15209, 10939 11449, 10940 15208, 10941 11451, 10942 15202, 10943 11451, 10944 15190, 10945 11438, 10946 15163, 10947 11384, 10948 15117, 10949 11274, 10950 15055, 10951 10979, 10952 14994, 10953 10648, 10954 14932, 10955 10343, 10956 14871, 10957 9936, 10958 14803, 10959 9532, 10960 14729, 10961 9218, 10962 14645, 10963 8742, 10964 14556, 10965 8381, 10966 14461, 10967 8020, 10968 14365, 10969 7603, 10970 15273, 10971 10603, 10972 15272, 10973 10607, 10974 15267, 10975 10619, 10976 15256, 10977 10631, 10978 15231, 10979 10614, 10980 15182, 10981 10535, 10982 15118, 10983 10389, 10984 15042, 10985 10167, 10986 14963, 10987 9787, 10988 14883, 10989 9447, 10990 14800, 10991 9115, 10992 14710, 10993 8665, 10994 14615, 10995 8318, 10996 14514, 10997 7911, 10998 14411, 10999 7507, 11000 14279, 11001 7198, 11002 15314, 11003 9675, 11004 15313, 11005 9683, 11006 15309, 11007 9712, 11008 15298, 11009 9759, 11010 15277, 11011 9797, 11012 15229, 11013 9773, 11014 15166, 11015 9668, 11016 15084, 11017 9487, 11018 14995, 11019 9274, 11020 14898, 11021 8910, 11022 14800, 11023 8539, 11024 14697, 11025 8234, 11026 14590, 11027 7790, 11028 14479, 11029 7409, 11030 14367, 11031 7067, 11032 14178, 11033 6621, 11034 15337, 11035 8619, 11036 15337, 11037 8631, 11038 15333, 11039 8677, 11040 15325, 11041 8769, 11042 15305, 11043 8871, 11044 15264, 11045 8940, 11046 15202, 11047 8909, 11048 15119, 11049 8775, 11050 15022, 11051 8565, 11052 14916, 11053 8328, 11054 14804, 11055 8009, 11056 14688, 11057 7614, 11058 14569, 11059 7287, 11060 14448, 11061 6888, 11062 14321, 11063 6483, 11064 14088, 11065 6171, 11066 15350, 11067 7402, 11068 15350, 11069 7419, 11070 15347, 11071 7480, 11072 15340, 11073 7613, 11074 15322, 11075 7804, 11076 15287, 11077 7973, 11078 15229, 11079 8057, 11080 15148, 11081 8012, 11082 15046, 11083 7846, 11084 14933, 11085 7611, 11086 14810, 11087 7357, 11088 14682, 11089 7069, 11090 14552, 11091 6656, 11092 14421, 11093 6316, 11094 14251, 11095 5948,
11096 14007, 11097 5528, 11098 15356, 11099 5942, 11100 15356, 11101 5977, 11102 15353, 11103 6119, 11104 15348, 11105 6294, 11106 15332, 11107 6551, 11108 15302, 11109 6824, 11110 15249, 11111 7044, 11112 15171, 11113 7122, 11114 15070, 11115 7050, 11116 14949, 11117 6861, 11118 14818, 11119 6611, 11120 14679, 11121 6349, 11122 14538, 11123 6067, 11124 14398, 11125 5651, 11126 14189, 11127 5311, 11128 13935, 11129 4958, 11130 15359, 11131 4123, 11132 15359, 11133 4153, 11134 15356, 11135 4296, 11136 15353, 11137 4646, 11138 15338, 11139 5160, 11140 15311, 11141 5508, 11142 15263, 11143 5829, 11144 15188, 11145 6042, 11146 15088, 11147 6094, 11148 14966, 11149 6001, 11150 14826, 11151 5796, 11152 14678, 11153 5543, 11154 14527, 11155 5287, 11156 14377, 11157 4985, 11158 14133, 11159 4586, 11160 13869, 11161 4257, 11162 15360, 11163 1563, 11164 15360, 11165 1642, 11166 15358, 11167 2076, 11168 15354, 11169 2636, 11170 15341, 11171 3350, 11172 15317, 11173 4019, 11174 15273, 11175 4429, 11176 15203, 11177 4732, 11178 15105, 11179 4911, 11180 14981, 11181 4932, 11182 14836, 11183 4818, 11184 14679, 11185 4621, 11186 14517, 11187 4386, 11188 14359, 11189 4156, 11190 14083, 11191 3795, 11192 13808, 11193 3437, 11194 15360, 11195 122, 11196 15360, 11197 137, 11198 15358, 11199 285, 11200 15355, 11201 636, 11202 15344, 11203 1274, 11204 15322, 11205 2177, 11206 15281, 11207 2765, 11208 15215, 11209 3223, 11210 15120, 11211 3451, 11212 14995, 11213 3569, 11214 14846, 11215 3567, 11216 14681, 11217 3466, 11218 14511, 11219 3305, 11220 14344, 11221 3121, 11222 14037, 11223 2800, 11224 13753, 11225 2467, 11226 15360, 11227 0, 11228 15360, 11229 1, 11230 15359, 11231 21, 11232 15355, 11233 89, 11234 15346, 11235 253, 11236 15325, 11237 479, 11238 15287, 11239 796, 11240 15225, 11241 1148, 11242 15133, 11243 1492, 11244 15008, 11245 1749, 11246 14856, 11247 1882, 11248 14685, 11249 1886, 11250 14506, 11251 1783, 11252 14324, 11253 1608, 11254 13996, 11255 1398, 11256 13702, 11257 1183 11258]), Gl = null; 11259function Kl() { 11260 return Gl === null && (Gl = new Fi(Wl, 16, 16, F, ye), Gl.name = "DFG_LUT", Gl.minFilter = P, Gl.magFilter = P, Gl.wrapS = oe, Gl.wrapT = oe, Gl.generateMipmaps = !1, Gl.needsUpdate = !0), Gl; 11261} 11262var ql = class { 11263 constructor(e = {}) { 11264 let { canvas: t = At(), context: n = null, depth: r = !0, stencil: i = !1, alpha: a = !1, antialias: o = !1, premultipliedAlpha: s = !0, preserveDrawingBuffer: c = !1, powerPreference: l = "default", failIfMajorPerformanceCaveat: u = !1, reversedDepthBuffer: d = !1, outputBufferType: f = fe } = e; 11265 this.isWebGLRenderer = !0; 11266 let p; 11267 if (n !== null) { 11268 if (typeof WebGLRenderingContext < "u" && n instanceof WebGLRenderingContext) throw Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163."); 11269 p = n.getContextAttributes().alpha; 11270 } else p = a; 11271 let m = f, h = /* @__PURE__ */ new Set([ 11272 Ne, 11273 Me, 11274 je 11275 ]), g = /* @__PURE__ */ new Set([ 11276 fe, 11277 _e, 11278 he, 11279 Se, 11280 be, 11281 xe 11282 ]), _ = /* @__PURE__ */ new Uint32Array(4), v = /* @__PURE__ */ new Int32Array(4), y = new G(), b = null, x = null, S = [], C = [], w = null; 11283 this.domElement = t, this.debug = { 11284 checkShaderErrors: !0, 11285 onShaderError: null 11286 }, this.autoClear = !0, this.autoClearColor = !0, this.autoClearDepth = !0, this.autoClearStencil = !0, this.sortObjects = !0, this.clippingPlanes = [], this.localClippingEnabled = !1, this.toneMapping = 0, this.toneMappingExposure = 1, this.transmissionResolutionScale = 1; 11287 let T = this, E = !1, D = null, O = null, k = null, A = null; 11288 this._outputColorSpace = bt; 11289 let ee = 0, te = 0, j = null, ne = -1, re = null, M = new J(), ie = new J(), ae = null, oe = new Y(0), se = 0, N = t.width, ce = t.height, le = 1, P = null, ue = null, pe = new J(0, 0, N, ce), me = new J(0, 0, N, ce), ge = !1, ve = new Ui(), Ce = !1, we = !1, Te = new jn(), Ee = new G(), De = new J(), Oe = { 11290 background: null, 11291 fog: null, 11292 environment: null, 11293 overrideMaterial: null, 11294 isScene: !0 11295 }, ke = !1; 11296 function Ae() { 11297 return j === null ? le : 1; 11298 } 11299 let F = n; 11300 function Pe(e, n) { 11301 return t.getContext(e, n); 11302 } 11303 try { 11304 let e = { 11305 alpha: !0, 11306 depth: r, 11307 stencil: i, 11308 antialias: o, 11309 premultipliedAlpha: s, 11310 preserveDrawingBuffer: c, 11311 powerPreference: l, 11312 failIfMajorPerformanceCaveat: u 11313 }; 11314 if ("setAttribute" in t && t.setAttribute("data-engine", "three.js r185"), t.addEventListener("webglcontextlost", nt, !1), t.addEventListener("webglcontextrestored", rt, !1), t.addEventListener("webglcontextcreationerror", it, !1), F === null) { 11315 let t = "webgl2"; 11316 if (F = Pe(t, e), F === null) throw Pe(t) ? Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes.") : Error("THREE.WebGLRenderer: Error creating WebGL context."); 11317 } 11318 } catch (e) { 11319 throw V("WebGLRenderer: " + e.message), e; 11320 } 11321 let I, Fe, L, Ie, R, z, Le, Re, ze, Be, Ve, He, Ue, We, Ge, Ke, qe, Je, Ye, Xe, Ze, Qe, $e; 11322 function et() { 11323 I = new ds(F), I.init(), Ze = new Fl(F, I), Fe = new Vo(F, I, e, Ze), L = new Nl(F, I), Fe.reversedDepthBuffer && d && L.buffers.depth.setReversed(!0), O = F.createFramebuffer(), k = F.createFramebuffer(), A = F.createFramebuffer(), Ie = new ms(F), R = new pl(), z = new Pl(F, I, L, R, Fe, Ze, Ie), Le = new us(T), Re = new No(F), Qe = new zo(F, Re), ze = new fs(F, Re, Ie, Qe), Be = new gs(F, ze, Re, Qe, Ie), Je = new hs(F, Fe, z), Ge = new Ho(R), Ve = new fl(T, Le, I, Fe, Qe, Ge), He = new Hl(T, R), Ue = new _l(), We = new wl(I), qe = new Ro(T, Le, L, Be, p, s), Ke = new Ml(T, Be, Fe), $e = new Ul(F, Ie, Fe, L), Ye = new Bo(F, I, Ie), Xe = new ps(F, I, Ie), Ie.programs = Ve.programs, T.capabilities = Fe, T.extensions = I, T.properties = R, T.renderLists = Ue, T.shadowMap = Ke, T.state = L, T.info = Ie; 11324 } 11325 et(), m !== 1009 && (w = new vs(m, t.width, t.height, o, r, i)); 11326 let tt = new zl(T, F); 11327 this.xr = tt, this.getContext = function() { 11328 return F; 11329 }, this.getContextAttributes = function() { 11330 return F.getContextAttributes(); 11331 }, this.forceContextLoss = function() { 11332 let e = I.get("WEBGL_lose_context"); 11333 e && e.loseContext(); 11334 }, this.forceContextRestore = function() { 11335 let e = I.get("WEBGL_lose_context"); 11336 e && e.restoreContext(); 11337 }, this.getPixelRatio = function() { 11338 return le; 11339 }, this.setPixelRatio = function(e) { 11340 e !== void 0 && (le = e, this.setSize(N, ce, !1)); 11341 }
11341, this.getSize = function(e) { 11342 return e.set(N, ce); 11343 }, this.setSize = function(e, n, r = !0) { 11344 if (tt.isPresenting) { 11345 B("WebGLRenderer: Can't change size while VR device is presenting."); 11346 return; 11347 } 11348 N = e, ce = n, t.width = Math.floor(e * le), t.height = Math.floor(n * le), r === !0 && (t.style.width = e + "px", t.style.height = n + "px"), w !== null && w.setSize(t.width, t.height), this.setViewport(0, 0, e, n); 11349 }, this.getDrawingBufferSize = function(e) { 11350 return e.set(N * le, ce * le).floor(); 11351 }, this.setDrawingBufferSize = function(e, n, r) { 11352 N = e, ce = n, le = r, t.width = Math.floor(e * r), t.height = Math.floor(n * r), this.setViewport(0, 0, e, n); 11353 }, this.setEffects = function(e) { 11354 if (m === 1009) { 11355 V("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType."); 11356 return; 11357 } 11358 if (e) { 11359 for (let t = 0; t < e.length; t++) if (e[t].isOutputPass === !0) { 11360 B("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically."); 11361 break; 11362 } 11363 } 11364 w.setEffects(e || []); 11365 }, this.getCurrentViewport = function(e) { 11366 return e.copy(M); 11367 }, this.getViewport = function(e) { 11368 return e.copy(pe); 11369 }, this.setViewport = function(e, t, n, r) { 11370 e.isVector4 ? pe.set(e.x, e.y, e.z, e.w) : pe.set(e, t, n, r), L.viewport(M.copy(pe).multiplyScalar(le).round()); 11371 }, this.getScissor = function(e) { 11372 return e.copy(me); 11373 }, this.setScissor = function(e, t, n, r) { 11374 e.isVector4 ? me.set(e.x, e.y, e.z, e.w) : me.set(e, t, n, r), L.scissor(ie.copy(me).multiplyScalar(le).round()); 11375 }, this.getScissorTest = function() { 11376 return ge; 11377 }, this.setScissorTest = function(e) { 11378 L.setScissorTest(ge = e); 11379 }, this.setOpaqueSort = function(e) { 11380 P = e; 11381 }, this.setTransparentSort = function(e) { 11382 ue = e; 11383 }, this.getClearColor = function(e) { 11384 return e.copy(qe.getClearColor()); 11385 }, this.setClearColor = function() { 11386 qe.setClearColor(...arguments); 11387 }, this.getClearAlpha = function() { 11388 return qe.getClearAlpha(); 11389 }, this.setClearAlpha = function() { 11390 qe.setClearAlpha(...arguments); 11391 }, this.clear = function(e = !0, t = !0, n = !0) { 11392 let r = 0; 11393 if (e) { 11394 let e = !1; 11395 if (j !== null) { 11396 let t = j.texture.format; 11397 e = h.has(t); 11398 } 11399 if (e) { 11400 let e = j.texture.type, t = g.has(e), n = qe.getClearColor(), r = qe.getClearAlpha(), i = n.r, a = n.g, o = n.b; 11401 t ? (_[0] = i, _[1] = a, _[2] = o, _[3] = r, F.clearBufferuiv(F.COLOR, 0, _)) : (v[0] = i, v[1] = a, v[2] = o, v[3] = r, F.clearBufferiv(F.COLOR, 0, v)); 11402 } else r |= F.COLOR_BUFFER_BIT; 11403 } 11404 t && (r |= F.DEPTH_BUFFER_BIT, this.state.buffers.depth.setMask(!0)), n && (r |= F.STENCIL_BUFFER_BIT, this.state.buffers.stencil.setMask(4294967295)), r !== 0 && F.clear(r); 11405 }, this.clearColor = function() { 11406 this.clear(!0, !1, !1); 11407 }, this.clearDepth = function() { 11408 this.clear(!1, !0, !1); 11409 }, this.clearStencil = function() { 11410 this.clear(!1, !1, !0); 11411 }, this.setNodesHandler = function(e) { 11412 e.setRenderer(this), D = e; 11413 }, this.dispose = function() { 11414 t.removeEventListener("webglcontextlost", nt, !1), t.removeEventListener("webglcontextrestored", rt, !1), t.removeEventListener("webglcontextcreationerror", it, !1), qe.dispose(), Ue.dispose(), We.dispose(), R.dispose(), Le.dispose(), Be.dispose(), Qe.dispose(), $e.dispose(), Ve.dispose(), tt.dispose(), tt.removeEventListener("sessionstart", dt), tt.removeEventListener("sessionend", ft), pt.stop(); 11415 }; 11416 function nt(e) { 11417 e.preventDefault(), Mt("WebGLRenderer: Context Lost."), E = !0; 11418 } 11419 function rt() { 11420 Mt("WebGLRenderer: Context Restored."), E = !1; 11421 let e = Ie.autoReset, t = Ke.enabled, n = Ke.autoUpdate, r = Ke.needsUpdate, i = Ke.type; 11422 et(), Ie.autoReset = e, Ke.enabled = t, Ke.autoUpdate = n, Ke.needsUpdate = r, Ke.type = i; 11423 } 11424 function it(e) { 11425 V("WebGLRenderer: A WebGL context could not be created. Reason: ", e.statusMessage); 11426 } 11427 function at(e) { 11428 let t = e.target; 11429 t.removeEventListener("dispose", at), ot(t); 11430 } 11431 function ot(e) { 11432 st(e), R.remove(e); 11433 } 11434 function st(e) { 11435 let t = R.get(e).programs; 11436 t !== void 0 && (t.forEach(function(e) { 11437 Ve.releaseProgram(e); 11438 }), e.isShaderMaterial && Ve.releaseShaderCache(e)); 11439 } 11440 this.renderBufferDirect = function(e, t, n, r, i, a) { 11441 t === null && (t = Oe); 11442 let o = i.isMesh && i.matrixWorld.determinantAffine() < 0, s = wt(e, t, n, r, i); 11443 L.setMaterial(r, o); 11444 let c = n.index, l = 1; 11445 if (r.wireframe === !0) { 11446 if (c = ze.getWireframeAttribute(n), c === void 0) return; 11447 l = 2; 11448 } 11449 let u = n.drawRange, d = n.attributes.position, f = u.start * l, p = (u.start + u.count) * l;
11450 a !== null && (f = Math.max(f, a.start * l), p = Math.min(p, (a.start + a.count) * l)), c === null ? d != null && (f = Math.max(f, 0), p = Math.min(p, d.count)) : (f = Math.max(f, 0), p = Math.min(p, c.count)); 11451 let m = p - f; 11452 if (m < 0 || m === Infinity) return; 11453 Qe.setup(i, r, s, n, c); 11454 let h, g = Ye; 11455 if (c !== null && (h = Re.get(c), g = Xe, g.setIndex(h)), i.isMesh) r.wireframe === !0 ? (L.setLineWidth(r.wireframeLinewidth * Ae()), g.setMode(F.LINES)) : g.setMode(F.TRIANGLES); 11456 else if (i.isLine) { 11457 let e = r.linewidth; 11458 e === void 0 && (e = 1), L.setLineWidth(e * Ae()), i.isLineSegments ? g.setMode(F.LINES) : i.isLineLoop ? g.setMode(F.LINE_LOOP) : g.setMode(F.LINE_STRIP); 11459 } else i.isPoints ? g.setMode(F.POINTS) : i.isSprite && g.setMode(F.TRIANGLES); 11460 if (i.isBatchedMesh) if (I.get("WEBGL_multi_draw")) g.renderMultiDraw(i._multiDrawStarts, i._multiDrawCounts, i._multiDrawCount); 11461 else { 11462 let e = i._multiDrawStarts, t = i._multiDrawCounts, n = i._multiDrawCount, a = c ? Re.get(c).bytesPerElement : 1, o = R.get(r).currentProgram.getUniforms(); 11463 for (let r = 0; r < n; r++) o.setValue(F, "_gl_DrawID", r), g.render(e[r] / a, t[r]); 11464 } 11465 else if (i.isInstancedMesh) g.renderInstances(f, m, i.count); 11466 else if (n.isInstancedBufferGeometry) { 11467 let e = n._maxInstanceCount === void 0 ? Infinity : n._maxInstanceCount, t = Math.min(n.instanceCount, e); 11468 g.renderInstances(f, m, t); 11469 } else g.render(f, m); 11470 }; 11471 function ct(e, t, n) { 11472 e.transparent === !0 && e.side === 2 && e.forceSinglePass === !1 ? (e.side = 1, e.needsUpdate = !0, yt(e, t, n), e.side = 0, e.needsUpdate = !0, yt(e, t, n), e.side = 2) : yt(e, t, n); 11473 } 11474 this.compile = function(e, t, n = null) { 11475 n === null && (n = e), x = We.get(n), x.init(t), C.push(x), n.traverseVisible(function(e) { 11476 e.isLight && e.layers.test(t.layers) && (x.pushLight(e), e.castShadow && x.pushShadow(e)); 11477 }), e !== n && e.traverseVisible(function(e) { 11478 e.isLight && e.layers.test(t.layers) && (x.pushLight(e), e.castShadow && x.pushShadow(e)); 11479 }), x.setupLights(); 11480 let r = /* @__PURE__ */ new Set(); 11481 return e.traverse(function(e) { 11482 if (!(e.isMesh || e.isPoints || e.isLine || e.isSprite)) return; 11483 let t = e.material; 11484 if (t) if (Array.isArray(t)) for (let i = 0; i < t.length; i++) { 11485 let a = t[i]; 11486 ct(a, n, e), r.add(a); 11487 } 11488 else ct(t, n, e), r.add(t); 11489 }), x = C.pop(), r; 11490 }, this.compileAsync = function(e, t, n = null) { 11491 let r = this.compile(e, t, n); 11492 return new Promise((t) => { 11493 function n() { 11494 if (r.forEach(function(e) { 11495 R.get(e).currentProgram.isReady() && r.delete(e); 11496 }), r.size === 0) { 11497 t(e); 11498 return; 11499 } 11500 setTimeout(n, 10); 11501 } 11502 I.get("KHR_parallel_shader_compile") === null ? setTimeout(n, 10) : n(); 11503 }); 11504 }; 11505 let lt = null; 11506 function ut(e) { 11507 lt && lt(e); 11508 } 11509 function dt() { 11510 pt.stop(); 11511 } 11512 function ft() { 11513 pt.start(); 11514 } 11515 let pt = new Mo(); 11516 pt.setAnimationLoop(ut), typeof self < "u" && pt.setContext(self), this.setAnimationLoop = function(e) { 11517 lt = e, tt.setAnimationLoop(e), e === null ? pt.stop() : pt.start(); 11518 }, tt.addEventListener("sessionstart", dt), tt.addEventListener("sessionend", ft), this.render = function(e, t) { 11519 if (t !== void 0 && t.isCamera !== !0) { 11520 V("WebGLRenderer.render: camera is not an instance of THREE.Camera."); 11521 return; 11522 } 11523 if (E === !0) return; 11524 D !== null && D.renderStart(e, t); 11525 let n = tt.enabled === !0 && tt.isPresenting === !0, r = w !== null && (j === null || n) && w.begin(T, j); 11526 if (e.matrixWorldAutoUpdate === !0 && e.updateMatrixWorld(), t.parent === null && t.matrixWorldAutoUpdate === !0 && t.updateMatrixWorld(), tt.enabled === !0 && tt.isPresenting === !0 && (w === null || w.isCompositing() === !1) && (tt.cameraAutoUpdate === !0 && tt.updateCamera(t), t = tt.getCamera()), e.isScene === !0 && e.onBeforeRender(T, e, t, j), x = We.get(e, C.length), x.init(t), x.state.textureUnits = z.getTextureUnits(), C.push(x), Te.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), ve.setFromProjectionMatrix(Te, Et, t.reversedDepth), we = this.localClippingEnabled, Ce = Ge.init(this.clippingPlanes, we), b = Ue.get(e, S.length), b.init(), S.push(b), tt.enabled === !0 && tt.isPresenting === !0) { 11527 let e = T.xr.getDepthSensingMesh(); 11528 e !== null && mt(e, t, -Infinity, T.sortObjects); 11529 } 11530 mt(e, t, 0, T.sortObjects), b.finish(), T.sortObjects === !0 && b.sort(P, ue, t.reversedDepth), ke = tt.enabled === !1 || tt.isPresenting === !1 || tt.hasDepthSensing() === !1, ke && qe.addToRenderList(b, e), this.info.render.frame++, this.info.autoReset === !0 && this.info.reset(), Ce === !0 && Ge.beginShadows(); 11531 let i = x.state.shadowsArray; 11532 if (Ke.render(i, e, t), Ce === !0 && Ge.endShadows(), (r && w.hasRenderPass()) === !1) { 11533 let n = b.opaque, r = b.transmissive; 11534 if (x.setupLights(), t.isArrayCamera) { 11535 let i = t.cameras; 11536 if (r.length > 0) for (let t = 0, a = i.length; t < a; t++) { 11537 let a = i[t]; 11538 gt(n, r, e, a); 11539 }
11540 ke && qe.render(e); 11541 for (let t = 0, n = i.length; t < n; t++) { 11542 let n = i[t]; 11543 ht(b, e, n, n.viewport); 11544 } 11545 } else r.length > 0 && gt(n, r, e, t), ke && qe.render(e), ht(b, e, t); 11546 } 11547 j !== null && te === 0 && (z.updateMultisampleRenderTarget(j), z.updateRenderTargetMipmap(j)), r && w.end(T), e.isScene === !0 && e.onAfterRender(T, e, t), Qe.resetDefaultState(), ne = -1, re = null, C.pop(), C.length > 0 ? (x = C[C.length - 1], z.setTextureUnits(x.state.textureUnits), Ce === !0 && Ge.setGlobalState(T.clippingPlanes, x.state.camera)) : x = null, S.pop(), b = S.length > 0 ? S[S.length - 1] : null, D !== null && D.renderEnd(); 11548 }; 11549 function mt(e, t, n, r) { 11550 if (e.visible === !1) return; 11551 if (e.layers.test(t.layers)) { 11552 if (e.isGroup) n = e.renderOrder; 11553 else if (e.isLOD) e.autoUpdate === !0 && e.update(t); 11554 else if (e.isLightProbeGrid) x.pushLightProbeGrid(e); 11555 else if (e.isLight) x.pushLight(e), e.castShadow && x.pushShadow(e); 11556 else if (e.isSprite) { 11557 if (!e.frustumCulled || ve.intersectsSprite(e)) { 11558 r && De.setFromMatrixPosition(e.matrixWorld).applyMatrix4(Te); 11559 let t = Be.update(e), i = e.material; 11560 i.visible && b.push(e, t, i, n, De.z, null); 11561 } 11562 } else if ((e.isMesh || e.isLine || e.isPoints) && (!e.frustumCulled || ve.intersectsObject(e))) { 11563 let t = Be.update(e), i = e.material; 11564 if (r && (e.boundingSphere === void 0 ? (t.boundingSphere === null && t.computeBoundingSphere(), De.copy(t.boundingSphere.center)) : (e.boundingSphere === null && e.computeBoundingSphere(), De.copy(e.boundingSphere.center)), De.applyMatrix4(e.matrixWorld).applyMatrix4(Te)), Array.isArray(i)) { 11565 let r = t.groups; 11566 for (let a = 0, o = r.length; a < o; a++) { 11567 let o = r[a], s = i[o.materialIndex]; 11568 s && s.visible && b.push(e, t, s, n, De.z, o); 11569 } 11570 } else i.visible && b.push(e, t, i, n, De.z, null); 11571 } 11572 } 11573 let i = e.children; 11574 for (let e = 0, a = i.length; e < a; e++) mt(i[e], t, n, r); 11575 } 11576 function ht(e, t, n, r) { 11577 let { opaque: i, transmissive: a, transparent: o } = e; 11578 x.setupLightsView(n), Ce === !0 && Ge.setGlobalState(T.clippingPlanes, n), r && L.viewport(M.copy(r)), i.length > 0 && _t(i, t, n), a.length > 0 && _t(a, t, n), o.length > 0 && _t(o, t, n), L.buffers.depth.setTest(!0), L.buffers.depth.setMask(!0), L.buffers.color.setMask(!0), L.setPolygonOffset(!1); 11579 } 11580 function gt(e, t, n, r) { 11581 if ((n.isScene === !0 ? n.overrideMaterial : null) !== null) return; 11582 if (x.state.transmissionRenderTarget[r.id] === void 0) { 11583 let e = I.has("EXT_color_buffer_half_float") || I.has("EXT_color_buffer_float"); 11584 x.state.transmissionRenderTarget[r.id] = new On(1, 1, { 11585 generateMipmaps: !0, 11586 type: e ? ye : fe, 11587 minFilter: de, 11588 samples: Math.max(4, Fe.samples), 11589 stencilBuffer: i, 11590 resolveDepthBuffer: !1, 11591 resolveStencilBuffer: !1, 11592 colorSpace: q.workingColorSpace 11593 }); 11594 } 11595 let a = x.state.transmissionRenderTarget[r.id], o = r.viewport || M; 11596 a.setSize(o.z * T.transmissionResolutionScale, o.w * T.transmissionResolutionScale); 11597 let s = T.getRenderTarget(), c = T.getActiveCubeFace(), l = T.getActiveMipmapLevel(); 11598 T.setRenderTarget(a), T.getClearColor(oe), se = T.getClearAlpha(), se < 1 && T.setClearColor(16777215, .5), T.clear(), ke && qe.render(n); 11599 let u = T.toneMapping; 11600 T.toneMapping = 0; 11601 let d = r.viewport; 11602 if (r.viewport !== void 0 && (r.viewport = void 0), x.setupLightsView(r), Ce === !0 && Ge.setGlobalState(T.clippingPlanes, r), _t(e, n, r), z.updateMultisampleRenderTarget(a), z.updateRenderTargetMipmap(a), I.has("WEBGL_multisampled_render_to_texture") === !1) { 11603 let e = !1; 11604 for (let i = 0, a = t.length; i < a; i++) { 11605 let { object: a, geometry: o, material: s, group: c } = t[i]; 11606 if (s.side === 2 && a.layers.test(r.layers)) { 11607 let t = s.side; 11608 s.side = 1, s.needsUpdate = !0, vt(a, n, r, o, s, c), s.side = t, s.needsUpdate = !0, e = !0; 11609 } 11610 } 11611 e === !0 && (z.updateMultisampleRenderTarget(a), z.updateRenderTargetMipmap(a)); 11612 } 11613 T.setRenderTarget(s, c, l), T.setClearColor(oe, se), d !== void 0 && (r.viewport = d), T.toneMapping = u; 11614 } 11615 function _t(e, t, n) { 11616 let r = t.isScene === !0 ? t.overrideMaterial : null; 11617 for (let i = 0, a = e.length; i < a; i++) { 11618 let a = e[i], { object: o, geometry: s, group: c } = a, l = a.material; 11619 l.allowOverride === !0 && r !== null && (l = r), o.layers.test(n.layers) && vt(o, t, n, s, l, c); 11620 } 11621 } 11622 function vt(e, t, n, r, i, a) { 11623 e.onBeforeRender(T, t, n, r, i, a), e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse, e.matrixWorld), e.normalMatrix.getNormalMatrix(e.modelViewMatrix), i.onBeforeRender(T, t, n, r, e, a), i.transparent === !0 && i.side === 2 && i.forceSinglePass === !1 ? (i.side = 1, i.needsUpdate = !0, T.renderBufferDirect(n, t, r, i, e, a), i.side = 0, i.needsUpdate = !0, T.renderBufferDirect(n, t, r, i, e, a), i.side = 2) : T.renderBufferDirect(n, t, r, i, e, a), e.onAfterRender(T, t, n, r, i, a); 11624 } 11625 function yt(e, t, n) { 11626 t.isScene !== !0 && (t = Oe); 11627 let r = R.get(e), i = x.state.lights, a = x.state.shadowsArray, o = i.state.ver
11627sion, s = Ve.getParameters(e, i.state, a, t, n, x.state.lightProbeGridArray), c = Ve.getProgramCacheKey(s), l = r.programs; 11628 r.environment = e.isMeshStandardMaterial || e.isMeshLambertMaterial || e.isMeshPhongMaterial ? t.environment : null, r.fog = t.fog; 11629 let u = e.isMeshStandardMaterial || e.isMeshLambertMaterial && !e.envMap || e.isMeshPhongMaterial && !e.envMap; 11630 r.envMap = Le.get(e.envMap || r.environment, u), r.envMapRotation = r.environment !== null && e.envMap === null ? t.environmentRotation : e.envMapRotation, l === void 0 && (e.addEventListener("dispose", at), l = /* @__PURE__ */ new Map(), r.programs = l); 11631 let d = l.get(c); 11632 if (d !== void 0) { 11633 if (r.currentProgram === d && r.lightsStateVersion === o) return St(e, s), d; 11634 } else s.uniforms = Ve.getUniforms(e), D !== null && e.isNodeMaterial && D.build(e, n, s), e.onBeforeCompile(s, T), d = Ve.acquireProgram(s, c), l.set(c, d), r.uniforms = s.uniforms; 11635 let f = r.uniforms; 11636 return (!e.isShaderMaterial && !e.isRawShaderMaterial || e.clipping === !0) && (f.clippingPlanes = Ge.uniform), St(e, s), r.needsLights = Dt(e), r.lightsStateVersion = o, r.needsLights && (f.ambientLightColor.value = i.state.ambient, f.lightProbe.value = i.state.probe, f.directionalLights.value = i.state.directional, f.directionalLightShadows.value = i.state.directionalShadow, f.spotLights.value = i.state.spot, f.spotLightShadows.value = i.state.spotShadow, f.rectAreaLights.value = i.state.rectArea, f.ltc_1.value = i.state.rectAreaLTC1, f.ltc_2.value = i.state.rectAreaLTC2, f.pointLights.value = i.state.point, f.pointLightShadows.value = i.state.pointShadow, f.hemisphereLights.value = i.state.hemi, f.directionalShadowMatrix.value = i.state.directionalShadowMatrix, f.spotLightMatrix.value = i.state.spotLightMatrix, f.spotLightMap.value = i.state.spotLightMap, f.pointShadowMatrix.value = i.state.pointShadowMatrix), r.lightProbeGrid = x.state.lightProbeGridArray.length > 0, r.currentProgram = d, r.uniformsList = null, d; 11637 } 11638 function xt(e) { 11639 if (e.uniformsList === null) { 11640 let t = e.currentProgram.getUniforms(); 11641 e.uniformsList = Tc.seqWithValue(t.seq, e.uniforms); 11642 } 11643 return e.uniformsList; 11644 } 11645 function St(e, t) { 11646 let n = R.get(e); 11647 n.outputColorSpace = t.outputColorSpace, n.batching = t.batching, n.batchingColor = t.batchingColor, n.instancing = t.instancing, n.instancingColor = t.instancingColor, n.instancingMorph = t.instancingMorph, n.skinning = t.skinning, n.morphTargets = t.morphTargets, n.morphNormals = t.morphNormals, n.morphColors = t.morphColors, n.morphTargetsCount = t.morphTargetsCount, n.numClippingPlanes = t.numClippingPlanes, n.numIntersection = t.numClipIntersection, n.vertexAlphas = t.vertexAlphas, n.vertexTangents = t.vertexTangents, n.toneMapping = t.toneMapping; 11648 } 11649 function Ct(e, t) { 11650 if (e.length === 0) return null; 11651 if (e.length === 1) return e[0].texture === null ? null : e[0]; 11652 y.setFromMatrixPosition(t.matrixWorld); 11653 for (let t = 0, n = e.length; t < n; t++) { 11654 let n = e[t]; 11655 if (n.texture !== null && n.boundingBox.containsPoint(y)) return n; 11656 } 11657 return null; 11658 } 11659 function wt(e, t, n, r, i) { 11660 t.isScene !== !0 && (t = Oe), z.resetTextureUnits(); 11661 let a = t.fog, o = r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial ? t.environment : null, s = j === null ? T.outputColorSpace : j.isXRRenderTarget === !0 ? j.texture.colorSpace : q.workingColorSpace, c = r.isMeshStandardMaterial || r.isMeshLambertMaterial && !r.envMap || r.isMeshPhongMaterial && !r.envMap, l = Le.get(r.envMap || o, c), u = r.vertexColors === !0 && !!n.attributes.color && n.attributes.color.itemSize === 4, d = !!n.attributes.tangent && (!!r.normalMap || r.anisotropy > 0), f = !!n.morphAttributes.position, p = !!n.morphAttributes.normal, m = !!n.morphAttributes.color, h = 0; 11662 r.toneMapped && (j === null || j.isXRRenderTarget === !0) && (h = T.toneMapping); 11663 let g = n.morphAttributes.position || n.morphAttributes.normal || n.morphAttributes.color, _ = g === void 0 ? 0 : g.length, v = R.get(r), y = x.state.lights; 11664 if (Ce === !0 && (we === !0 || e !== re)) { 11665 let t = e === re && r.id === ne; 11666 Ge.setState(r, e, t); 11667 } 11668 let b = !1; 11669 r.version === v.__version ? v.needsLights && v.lightsStateVersion !== y.state.ver
11669sion ? b = !0 : v.outputColorSpace === s ? i.isBatchedMesh && v.batching === !1 || !i.isBatchedMesh && v.batching === !0 || i.isBatchedMesh && v.batchingColor === !0 && i.colorTexture === null || i.isBatchedMesh && v.batchingColor === !1 && i.colorTexture !== null || i.isInstancedMesh && v.instancing === !1 || !i.isInstancedMesh && v.instancing === !0 || i.isSkinnedMesh && v.skinning === !1 || !i.isSkinnedMesh && v.skinning === !0 || i.isInstancedMesh && v.instancingColor === !0 && i.instanceColor === null || i.isInstancedMesh && v.instancingColor === !1 && i.instanceColor !== null || i.isInstancedMesh && v.instancingMorph === !0 && i.morphTexture === null || i.isInstancedMesh && v.instancingMorph === !1 && i.morphTexture !== null ? b = !0 : v.envMap === l ? r.fog === !0 && v.fog !== a || v.numClippingPlanes !== void 0 && (v.numClippingPlanes !== Ge.numPlanes || v.numIntersection !== Ge.numIntersection) ? b = !0 : v.vertexAlphas === u && v.vertexTangents === d && v.morphTargets === f && v.morphNormals === p && v.morphColors === m && v.toneMapping === h && v.morphTargetsCount === _ ? !!v.lightProbeGrid != x.state.lightProbeGridArray.length > 0 && (b = !0) : b = !0 : b = !0 : b = !0 : (b = !0, v.__version = r.version); 11670 let S = v.currentProgram; 11671 b === !0 && (S = yt(r, t, i), D && r.isNodeMaterial && D.onUpdateProgram(r, S, v)); 11672 let C = !1, w = !1, E = !1, O = S.getUniforms(), k = v.uniforms; 11673 if (L.useProgram(S.program) && (C = !0, w = !0, E = !0), r.id !== ne && (ne = r.id, w = !0), v.needsLights) { 11674 let e = Ct(x.state.lightProbeGridArray, i); 11675 v.lightProbeGrid !== e && (v.lightProbeGrid = e, w = !0); 11676 } 11677 if (C || re !== e) { 11678 L.buffers.depth.getReversed() && e.reversedDepth !== !0 && (e._reversedDepth = !0, e.updateProjectionMatrix()), O.setValue(F, "projectionMatrix", e.projectionMatrix), O.setValue(F, "viewMatrix", e.matrixWorldInverse); 11679 let t = O.map.cameraPosition; 11680 t !== void 0 && t.setValue(F, Ee.setFromMatrixPosition(e.matrixWorld)), Fe.logarithmicDepthBuffer && O.setValue(F, "logDepthBufFC", 2 / (Math.log(e.far + 1) / Math.LN2)), (r.isMeshPhongMaterial || r.isMeshToonMaterial || r.isMeshLambertMaterial || r.isMeshBasicMaterial || r.isMeshStandardMaterial || r.isShaderMaterial) && O.setValue(F, "isOrthographic", e.isOrthographicCamera === !0), re !== e && (re = e, w = !0, E = !0); 11681 } 11682 if (v.needsLights && (y.state.directionalShadowMap.length > 0 && O.setValue(F, "directionalShadowMap", y.state.directionalShadowMap, z), y.state.spotShadowMap.length > 0 && O.setValue(F, "spotShadowMap", y.state.spotShadowMap, z), y.state.pointShadowMap.length > 0 && O.setValue(F, "pointShadowMap", y.state.pointShadowMap, z)), i.isSkinnedMesh) { 11683 O.setOptional(F, i, "bindMatrix"), O.setOptional(F, i, "bindMatrixInverse"); 11684 let e = i.skeleton; 11685 e && (e.boneTexture === null && e.computeBoneTexture(), O.setValue(F, "boneTexture", e.boneTexture, z)); 11686 } 11687 i.isBatchedMesh && (O.setOptional(F, i, "batchingTexture"), O.setValue(F, "batchingTexture", i._matricesTexture, z), O.setOptional(F, i, "batchingIdTexture"), O.setValue(F, "batchingIdTexture", i._indirectTexture, z), O.setOptional(F, i, "batchingColorTexture"), i._colorsTexture !== null && O.setValue(F, "batchingColorTexture", i._colorsTexture, z)); 11688 let A = n.morphAttributes; 11689 if ((A.position !== void 0 || A.normal !== void 0 || A.color !== void 0) && Je.update(i, n, S), (w || v.receiveShadow !== i.receiveShadow) && (v.receiveShadow = i.receiveShadow, O.setValue(F, "receiveShadow", i.receiveShadow)), (r.isMeshStandardMaterial || r.isMeshLambertMaterial || r.isMeshPhongMaterial) && r.envMap === null && t.environment !== null && (k.envMapIntensity.value = t.environmentIntensity), k.dfgLUT !== void 0 && (k.dfgLUT.value = Kl()), w) { 11690 if (O.setValue(F, "toneMappingExposure", T.toneMappingExposure), v.needsLights && Tt(k, E), a && r.fog === !0 && He.refreshFogUniforms(k, a), He.refreshMaterialUniforms(k, r, le, ce, x.state.transmissionRenderTarget[e.id]), v.needsLights && v.lightProbeGrid) { 11691 let e = v.lightProbeGrid; 11692 k.probesSH.value = e.texture, k.probesMin.value.copy(e.boundingBox.min), k.probesMax.value.copy(e.boundingBox.max), k.probesResolution.value.copy(e.resolution); 11693 } 11694 Tc.upload(F, xt(v), k, z); 11695 } 11696 if (r.isShaderMaterial && r.uniformsNeedUpdate === !0 && (Tc.upload(F, xt(v), k, z), r.uniformsNeedUpdate = !1), r.isSpriteMaterial && O.setValue(F, "center", i.center), O.setValue(F, "modelViewMatrix", i.modelViewMatrix), O.setValue(F, "n
11696ormalMatrix", i.normalMatrix), O.setValue(F, "modelMatrix", i.matrixWorld), r.uniformsGroups !== void 0) { 11697 let e = r.uniformsGroups; 11698 for (let t = 0, n = e.length; t < n; t++) { 11699 let n = e[t]; 11700 $e.update(n, S), $e.bind(n, S); 11701 } 11702 } 11703 return S; 11704 } 11705 function Tt(e, t) { 11706 e.ambientLightColor.needsUpdate = t, e.lightProbe.needsUpdate = t, e.directionalLights.needsUpdate = t, e.directionalLightShadows.needsUpdate = t, e.pointLights.needsUpdate = t, e.pointLightShadows.needsUpdate = t, e.spotLights.needsUpdate = t, e.spotLightShadows.needsUpdate = t, e.rectAreaLights.needsUpdate = t, e.hemisphereLights.needsUpdate = t; 11707 } 11708 function Dt(e) { 11709 return e.isMeshLambertMaterial || e.isMeshToonMaterial || e.isMeshPhongMaterial || e.isMeshStandardMaterial || e.isShadowMaterial || e.isShaderMaterial && e.lights === !0; 11710 } 11711 this.getActiveCubeFace = function() { 11712 return ee; 11713 }, this.getActiveMipmapLevel = function() { 11714 return te; 11715 }, this.getRenderTarget = function() { 11716 return j; 11717 }, this.setRenderTargetTextures = function(e, t, n) { 11718 let r = R.get(e); 11719 r.__autoAllocateDepthBuffer = e.resolveDepthBuffer === !1, r.__autoAllocateDepthBuffer === !1 && (r.__useRenderToTexture = !1), R.get(e.texture).__webglTexture = t, R.get(e.depthTexture).__webglTexture = r.__autoAllocateDepthBuffer ? void 0 : n, r.__hasExternalTextures = !0; 11720 }, this.setRenderTargetFramebuffer = function(e, t) { 11721 let n = R.get(e); 11722 n.__webglFramebuffer = t, n.__useDefaultFramebuffer = t === void 0; 11723 }, this.setRenderTarget = function(e, t = 0, n = 0) { 11724 j = e, ee = t, te = n; 11725 let r = null, i = !1, a = !1; 11726 if (e) { 11727 let o = R.get(e); 11728 if (o.__useDefaultFramebuffer !== void 0) { 11729 L.bindFramebuffer(F.FRAMEBUFFER, o.__webglFramebuffer), M.copy(e.viewport), ie.copy(e.scissor), ae = e.scissorTest, L.viewport(M), L.scissor(ie), L.setScissorTest(ae), ne = -1; 11730 return; 11731 } else if (o.__webglFramebuffer === void 0) z.setupRenderTarget(e); 11732 else if (o.__hasExternalTextures) z.rebindTextures(e, R.get(e.texture).__webglTexture, R.get(e.depthTexture).__webglTexture); 11733 else if (e.depthBuffer) { 11734 let t = e.depthTexture; 11735 if (o.__boundDepthTexture !== t) { 11736 if (t !== null && R.has(t) && (e.width !== t.image.width || e.height !== t.image.height)) throw Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size."); 11737 z.setupDepthRenderbuffer(e); 11738 } 11739 } 11740 let s = e.texture; 11741 (s.isData3DTexture || s.isDataArrayTexture || s.isCompressedArrayTexture) && (a = !0); 11742 let c = R.get(e).__webglFramebuffer; 11743 e.isWebGLCubeRenderTarget ? (r = Array.isArray(c[t]) ? c[t][n] : c[t], i = !0) : r = e.samples > 0 && z.useMultisampledRTT(e) === !1 ? R.get(e).__webglMultisampledFramebuffer : Array.isArray(c) ? c[n] : c, M.copy(e.viewport), ie.copy(e.scissor), ae = e.scissorTest; 11744 } else M.copy(pe).multiplyScalar(le).floor(), ie.copy(me).multiplyScalar(le).floor(), ae = ge; 11745 if (n !== 0 && (r = O), L.bindFramebuffer(F.FRAMEBUFFER, r) && L.drawBuffers(e, r), L.viewport(M), L.scissor(ie), L.setScissorTest(ae), i) { 11746 let r = R.get(e.texture); 11747 F.framebufferTexture2D(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_CUBE_MAP_POSITIVE_X + t, r.__webglTexture, n); 11748 } else if (a) { 11749 let r = t; 11750 for (let t = 0; t < e.textures.length; t++) { 11751 let i = R.get(e.textures[t]); 11752 F.framebufferTextureLayer(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0 + t, i.__webglTexture, n, r); 11753 } 11754 } else if (e !== null && n !== 0) { 11755 let t = R.get(e.texture); 11756 F.framebufferTexture2D(F.FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_2D, t.__webglTexture, n); 11757 } 11758 ne = -1; 11759 }, this.readRenderTargetPixels = function(e, t, n, r, i, a, o, s = 0) { 11760 if (!(e && e.isWebGLRenderTarget)) { 11761 V("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); 11762 return; 11763 } 11764 let c = R.get(e).__webglFramebuffer; 11765 if (e.isWebGLCubeRenderTarget && o !== void 0 && (c = c[o]), c) { 11766 L.bindFramebuffer(F.FRAMEBUFFER, c); 11767 try { 11768 let o = e.textures[s], c = o.format, l = o.type; 11769 if (e.textures.length > 1 && F.readBuffer(F.COLOR_ATTACHMENT0 + s), !Fe.textureFormatReadable(c)) { 11770 V("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."); 11771 return; 11772 } 11773 if (!Fe.textureTypeReadable(l)) { 11774 V("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type."); 11775 return; 11776 } 11777 t >= 0 && t <= e.width - r && n >= 0 && n <= e.height - i && F.readPixels(t, n, r, i, Ze.convert(c), Ze.convert(l), a); 11778 } finally { 11779 let e = j === null ? null : R.get(j).__webglFramebuffer; 11780 L.bindFramebuffer(F.FRAMEBUFFER, e); 11781 } 11782 } 11783 }, this.readRenderTargetPixelsAsync = async function(e, t, n, r, i, a, o, s = 0) { 11784 if (!(e && e.isWebGLRenderTarget)) throw Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget."); 11785 let c = R.get(e).__webglFramebuffer;
11786 if (e.isWebGLCubeRenderTarget && o !== void 0 && (c = c[o]), c) if (t >= 0 && t <= e.width - r && n >= 0 && n <= e.height - i) { 11787 L.bindFramebuffer(F.FRAMEBUFFER, c); 11788 let o = e.textures[s], l = o.format, u = o.type; 11789 if (e.textures.length > 1 && F.readBuffer(F.COLOR_ATTACHMENT0 + s), !Fe.textureFormatReadable(l)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format."); 11790 if (!Fe.textureTypeReadable(u)) throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type."); 11791 let d = F.createBuffer(); 11792 F.bindBuffer(F.PIXEL_PACK_BUFFER, d), F.bufferData(F.PIXEL_PACK_BUFFER, a.byteLength, F.STREAM_READ), F.readPixels(t, n, r, i, Ze.convert(l), Ze.convert(u), 0); 11793 let f = j === null ? null : R.get(j).__webglFramebuffer; 11794 L.bindFramebuffer(F.FRAMEBUFFER, f); 11795 let p = F.fenceSync(F.SYNC_GPU_COMMANDS_COMPLETE, 0); 11796 return F.flush(), await Ft(F, p, 4), F.bindBuffer(F.PIXEL_PACK_BUFFER, d), F.getBufferSubData(F.PIXEL_PACK_BUFFER, 0, a), F.deleteBuffer(d), F.deleteSync(p), a; 11797 } else throw Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range."); 11798 }, this.copyFramebufferToTexture = function(e, t = null, n = 0) { 11799 let r = 2 ** -n, i = Math.floor(e.image.width * r), a = Math.floor(e.image.height * r), o = t === null ? 0 : t.x, s = t === null ? 0 : t.y; 11800 z.setTexture2D(e, 0), F.copyTexSubImage2D(F.TEXTURE_2D, n, 0, 0, o, s, i, a), L.unbindTexture(); 11801 }, this.copyTextureToTexture = function(e, t, n = null, r = null, i = 0, a = 0) { 11802 let o, s, c, l, u, d, f, p, m, h = e.isCompressedTexture ? e.mipmaps[a] : e.image; 11803 if (n !== null) o = n.max.x - n.min.x, s = n.max.y - n.min.y, c = n.isBox3 ? n.max.z - n.min.z : 1, l = n.min.x, u = n.min.y, d = n.isBox3 ? n.min.z : 0; 11804 else { 11805 let t = 2 ** -i; 11806 o = Math.floor(h.width * t), s = Math.floor(h.height * t), c = e.isDataArrayTexture ? h.depth : e.isData3DTexture ? Math.floor(h.depth * t) : 1, l = 0, u = 0, d = 0; 11807 } 11808 r === null ? (f = 0, p = 0, m = 0) : (f = r.x, p = r.y, m = r.z); 11809 let g = Ze.convert(t.format), _ = Ze.convert(t.type), v; 11810 t.isData3DTexture ? (z.setTexture3D(t, 0), v = F.TEXTURE_3D) : t.isDataArrayTexture || t.isCompressedArrayTexture ? (z.setTexture2DArray(t, 0), v = F.TEXTURE_2D_ARRAY) : (z.setTexture2D(t, 0), v = F.TEXTURE_2D), L.activeTexture(F.TEXTURE0), L.pixelStorei(F.UNPACK_FLIP_Y_WEBGL, t.flipY), L.pixelStorei(F.UNPACK_PREMULTIPLY_ALPHA_WEBGL, t.premultiplyAlpha), L.pixelStorei(F.UNPACK_ALIGNMENT, t.unpackAlignment); 11811 let y = L.getParameter(F.UNPACK_ROW_LENGTH), b = L.getParameter(F.UNPACK_IMAGE_HEIGHT), x = L.getParameter(F.UNPACK_SKIP_PIXELS), S = L.getParameter(F.UNPACK_SKIP_ROWS), C = L.getParameter(F.UNPACK_SKIP_IMAGES); 11812 L.pixelStorei(F.UNPACK_ROW_LENGTH, h.width), L.pixelStorei(F.UNPACK_IMAGE_HEIGHT, h.height), L.pixelStorei(F.UNPACK_SKIP_PIXELS, l), L.pixelStorei(F.UNPACK_SKIP_ROWS, u), L.pixelStorei(F.UNPACK_SKIP_IMAGES, d); 11813 let w = e.isDataArrayTexture || e.isData3DTexture, T = t.isDataArrayTexture || t.isData3DTexture; 11814 if (e.isDepthTexture) { 11815 let n = R.get(e), r = R.get(t), h = R.get(n.__renderTarget), g = R.get(r.__renderTarget); 11816 L.bindFramebuffer(F.READ_FRAMEBUFFER, h.__webglFramebuffer), L.bindFramebuffer(F.DRAW_FRAMEBUFFER, g.__webglFramebuffer); 11817 for (let n = 0; n < c; n++) w && (F.framebufferTextureLayer(F.READ_FRAMEBUFFER, F.COLOR_ATTACHMENT0, R.get(e).__webglTexture, i, d + n), F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER, F.COLOR_ATTACHMENT0, R.get(t).__webglTexture, a, m + n)), F.blitFramebuffer(l, u, o, s, f, p, o, s, F.DEPTH_BUFFER_BIT, F.NEAREST); 11818 L.bindFramebuffer(F.READ_FRAMEBUFFER, null), L.bindFramebuffer(F.DRAW_FRAMEBUFFER, null); 11819 } else if (i !== 0 || e.isRenderTargetTexture || R.has(e)) { 11820 let n = R.get(e), r = R.get(t); 11821 L.bindFramebuffer(F.READ_FRAMEBUFFER, k), L.bindFramebuffer(F.DRAW_FRAMEBUFFER, A); 11822 for (let e = 0; e < c; e++) w ? F.framebufferTextureLayer(F.READ_FRAMEBUFFER, F.COLOR_ATTACHMENT0, n.__webglTexture, i, d + e) : F.framebufferTexture2D(F.READ_FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_2D, n.__webglTexture, i), T ? F.framebufferTextureLayer(F.DRAW_FRAMEBUFFER, F.COLOR_ATTACHMENT0, r.__webglTexture, a, m + e) : F.framebufferTexture2D(F.DRAW_FRAMEBUFFER, F.COLOR_ATTACHMENT0, F.TEXTURE_2D, r.__webglTexture, a), i === 0 ? T ? F.copyTexSubImage3D(v, a, f, p, m + e, l, u, o, s) : F.copyTexSubImage2D(v, a, f, p, l, u, o, s) : F.blitFramebuffer(l, u, o, s, f, p, o, s, F.COLOR_BUFFER_BIT, F.NEAREST); 11823 L.bindFramebuffer(F.READ_FRAMEBUFFER, null), L.bindFramebuffer(F.DRAW_FRAMEBUFFER, null); 11824 } else T ? e.isDataTexture || e.isData3DTexture ? F.texSubImage3D(v, a, f, p, m, o, s, c, g, _, h.data) : t.isCompressedArrayTexture ? F.compressedTexSubImage3D(v, a, f, p, m, o, s, c, g, h.data) : F.texSubImage3D(v, a, f, p, m, o, s, c, g, _, h) : e.isDataTexture ? F.texSubImage2D(F.TEXTURE_2D, a, f, p, o, s, g, _, h.data) : e.isCompressedTexture ? F.compressedTexSubImage2D(F.TEXTURE_2D, a, f, p, h.width, h.height, g, h.data) : F.texSubImage2D(F.TEXTURE_2D, a, f, p, o, s, g, _, h); 11825 L.pixelStorei(F.UNPACK_ROW_LENGTH, y), L.pixelStorei(F.UNPACK_IMAGE_HEIGHT, b), L.pixelStorei(F.UNPACK_SKIP_PIXELS, x), L.pixelStorei(F.UNPACK_SKIP_ROWS, S), L.pixelStorei(F.UNPACK_SKIP_IMAGES, C), a === 0 && t.generateMipmaps && F.generateMipmap(v), L.unbindTexture(); 11826 }, this.initRenderTarget = function(e) { 11827 R.get(e).__webglFramebuffer === void 0 && z.setupRenderTarget(e); 11828 }, this.initTexture = function(e) { 11829 e.isCubeTexture ? z.setTextureCube(e, 0) : e.isData3DTexture ? z.setTexture3D(e, 0) : e.isDataArrayTexture || e.isCompressedArrayTexture ? z.setTexture2DArray(e, 0) : z.setTexture2D(e, 0), L.unbindTexture(); 11830 }, this.resetState = function() { 11831 ee = 0, te = 0, j = null, L.reset(), Qe.reset(); 11832 }, typeof __THREE_DEVTOOLS__ < "u" && __THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe", { detail: this })); 11833 } 11834 get coordinateSystem() { 11835 return Et; 11836 } 11837 get outputColorSpace() { 11838 return this._outputColorSpace; 11839 } 11840 set outputColorSpace(e) { 11841 this._outputColorSpace = e; 11842 let t = this.getContext(); 11843 t.drawingBufferColorSpace = q._getDrawingBufferColorSpace(e), t.unpackColorSpace = q._getUnpackColorSpace(); 11844 } 11845}, Jl = { type: "change" }, Yl = { type: "start" }, Xl = { type: "end" }
11845, Zl = new yi(), Ql = new zi(), $l = Math.cos(70 * ln.DEG2RAD), eu = new G(), tu = 2 * Math.PI, $ = { 11846 NONE: -1, 11847 ROTATE: 0, 11848 DOLLY: 1, 11849 PAN: 2, 11850 TOUCH_ROTATE: 3, 11851 TOUCH_PAN: 4, 11852 TOUCH_DOLLY_PAN: 5, 11853 TOUCH_DOLLY_ROTATE: 6 11854}, nu = 1e-6, ru = class extends ko { 11855 constructor(e, t = null) { 11856 super(e, t), this.state = $.NONE, this.target = new G(), this.cursor = new G(), this.minDistance = 0, this.maxDistance = Infinity, this.minZoom = 0, this.maxZoom = Infinity, this.minTargetRadius = 0, this.maxTargetRadius = Infinity, this.minPolarAngle = 0, this.maxPolarAngle = Math.PI, this.minAzimuthAngle = -Infinity, this.maxAzimuthAngle = Infinity, this.enableDamping = !1, this.dampingFactor = .05, this.enableZoom = !0, this.zoomSpeed = 1, this.enableRotate = !0, this.rotateSpeed = 1, this.keyRotateSpeed = 1, this.enablePan = !0, this.panSpeed = 1, this.screenSpacePanning = !0, this.keyPanSpeed = 7, this.zoomToCursor = !1, this.autoRotate = !1, this.autoRotateSpeed = 2, this.keys = { 11857 LEFT: "ArrowLeft", 11858 UP: "ArrowUp", 11859 RIGHT: "ArrowRight", 11860 BOTTOM: "ArrowDown" 11861 }, this.mouseButtons = { 11862 LEFT: M.ROTATE, 11863 MIDDLE: M.DOLLY, 11864 RIGHT: M.PAN 11865 }, this.touches = { 11866 ONE: ie.ROTATE, 11867 TWO: ie.DOLLY_PAN 11868 }, this.target0 = this.target.clone(), this.position0 = this.object.position.clone(), this.zoom0 = this.object.zoom, this._cursorStyle = "auto", this._domElementKeyEvents = null, this._lastPosition = new G(), this._lastQuaternion = new un(), this._lastTargetPosition = new G(), this._quat = new un().setFromUnitVectors(e.up, new G(0, 1, 0)), this._quatInverse = this._quat.clone().invert(), this._spherical = new bo(), this._sphericalDelta = new bo(), this._scale = 1, this._panOffset = new G(), this._rotateStart = new W(), this._rotateEnd = new W(), this._rotateDelta = new W(), this._panStart = new W(), this._panEnd = new W(), this._panDelta = new W(), this._dollyStart = new W(), this._dollyEnd = new W(), this._dollyDelta = new W(), this._dollyDirection = new G(), this._mouse = new W(), this._performCursorZoom = !1, this._pointers = [], this._pointerPositions = {}, this._controlActive = !1, this._onPointerMove = au.bind(this), this._onPointerDown = iu.bind(this), this._onPointerUp = ou.bind(this), this._onContextMenu = pu.bind(this), this._onMouseWheel = lu.bind(this), this._onKeyDown = uu.bind(this), this._onTouchStart = du.bind(this), this._onTouchMove = fu.bind(this), this._onMouseDown = su.bind(this), this._onMouseMove = cu.bind(this), this._interceptControlDown = mu.bind(this), this._interceptControlUp = hu.bind(this), this.domElement !== null && this.connect(this.domElement), this.update(); 11869 } 11870 set cursorStyle(e) { 11871 this._cursorStyle = e, e === "grab" ? this.domElement.style.cursor = "grab" : this.domElement.style.cursor = "auto"; 11872 } 11873 get cursorStyle() { 11874 return this._cursorStyle; 11875 } 11876 connect(e) { 11877 super.connect(e), this.domElement.addEventListener("pointerdown", this._onPointerDown), this.domElement.addEventListener("pointercancel", this._onPointerUp), this.domElement.addEventListener("contextmenu", this._onContextMenu), this.domElement.addEventListener("wheel", this._onMouseWheel, { passive: !1 }), this.domElement.getRootNode().addEventListener("keydown", this._interceptControlDown, { 11878 passive: !0, 11879 capture: !0 11880 }), this.domElement.style.touchAction = "none"; 11881 } 11882 disconnect() { 11883 this.domElement.removeEventListener("pointerdown", this._onPointerDown), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.domElement.removeEventListener("pointercancel", this._onPointerUp), this.domElement.removeEventListener("wheel", this._onMouseWheel), this.domElement.removeEventListener("contextmenu", this._onContextMenu), this.stopListenToKeyEvents(), this.domElement.getRootNode().removeEventListener("keydown", this._interceptControlDown, { capture: !0 }), this.domElement.style.touchAction = ""; 11884 } 11885 dispose() { 11886 this.disconnect(); 11887 } 11888 getPolarAngle() { 11889 return this._spherical.phi; 11890 } 11891 getAzimuthalAngle() { 11892 return this._spherical.theta; 11893 } 11894 getDistance() { 11895 return this.object.position.distanceTo(this.target); 11896 } 11897 listenToKeyEvents(e) { 11898 e.addEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = e; 11899 } 11900 stopListenToKeyEvents() { 11901 this._domElementKeyEvents !== null && (this._domElementKeyEvents.removeEventListener("keydown", this._onKeyDown), this._domElementKeyEvents = null); 11902 } 11903 saveState() { 11904 this.target0.copy(this.target), this.position0.copy(this.object.position), this.zoom0 = this.object.zoom; 11905 } 11906 reset() { 11907 this.target.copy(this.target0), this.object.position.copy(this.position0), this.object.zoom = this.zoom0, this.object.updateProjectionMatrix(), this.dispatchEvent(Jl), this.update(), this.state = $.NONE; 11908 } 11909 pan(e, t) { 11910 this._pan(e, t), this.update(); 11911 } 11912 dollyIn(e) { 11913 this._dollyIn(e), this.update(); 11914 } 11915 dollyOut(e) { 11916 this._dollyOut(e), this.update(); 11917 } 11918 rotateLeft(e) { 11919 this._rotateLeft(e), this.update(); 11920 } 11921 rotateUp(e) { 11922 this._rotateUp(e), this.update(); 11923 } 11924 update(e = null) { 11925 let t = this.object.position; 11926 eu.copy(t).sub(this.target), eu.applyQuaternion(this._quat), this._spherical.setFromVector3(eu), this.autoRotate && this.state === $.NONE && this._rotateLeft(this._getAutoRotationAngle(e)), this.enableDamping ? (this._spherical.theta += this._sphericalDelta.theta * this.dampingFactor, this._spherical.phi += this._sphericalDelta.phi * this.dampingFactor) : (this._spherical.theta += this._sphericalDelta.theta, this._spherical.phi += this._sphericalDelta.phi); 11927 let n = this.minAzimuthAngle, r = this.maxAzimuthAngle; 11928 isFinite(n) && isFinite(r) && (n < -Math.PI ? n += tu : n > Math.PI && (n -= tu), r < -Math.PI ? r += tu : r > Math.PI && (r -= tu), n <= r ? this._spherical.theta = Math.max(n, Math.min(r, this._spherical.theta)) : this._spherical.theta = this._spherical.theta > (n + r) / 2 ? Math.max(n, this._spherical.theta) : Math.min(r, this._spherical.theta)), this._spherical.phi = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, this._spherical.phi)), this._spherical.makeSafe(), this.enableDamping === !0 ? this.target.addScaledVector(this._panOffset, this.dampingFactor) : this.target.add(this._panOffset), this.target.sub(this.cursor), this.target.clampLength(this.minTargetRadius, this.maxTargetRadius), this.target.add(this.cursor); 11929 let i = !1; 11930 if (this.zoomToCursor && this._performCursorZoom || this.object.isOrthographicCamera) this._spherical.radiu
11930s = this._clampDistance(this._spherical.radius); 11931 else { 11932 let e = this._spherical.radius; 11933 this._spherical.radius = this._clampDistance(this._spherical.radius * this._scale), i = e != this._spherical.radius; 11934 } 11935 if (eu.setFromSpherical(this._spherical), eu.applyQuaternion(this._quatInverse), t.copy(this.target).add(eu), this.object.lookAt(this.target), this.enableDamping === !0 ? (this._sphericalDelta.theta *= 1 - this.dampingFactor, this._sphericalDelta.phi *= 1 - this.dampingFactor, this._panOffset.multiplyScalar(1 - this.dampingFactor)) : (this._sphericalDelta.set(0, 0, 0), this._panOffset.set(0, 0, 0)), this.zoomToCursor && this._performCursorZoom) { 11936 let e = null; 11937 if (this.object.isPerspectiveCamera) { 11938 let t = eu.length(); 11939 e = this._clampDistance(t * this._scale); 11940 let n = t - e; 11941 this.object.position.addScaledVector(this._dollyDirection, n), this.object.updateMatrixWorld(), i = !!n; 11942 } else if (this.object.isOrthographicCamera) { 11943 let t = new G(this._mouse.x, this._mouse.y, 0); 11944 t.unproject(this.object); 11945 let n = this.object.zoom; 11946 this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), this.object.updateProjectionMatrix(), i = n !== this.object.zoom; 11947 let r = new G(this._mouse.x, this._mouse.y, 0); 11948 r.unproject(this.object), this.object.position.sub(r).add(t), this.object.updateMatrixWorld(), e = eu.length(); 11949 } else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."), this.zoomToCursor = !1; 11950 e !== null && (this.screenSpacePanning ? this.target.set(0, 0, -1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position) : (Zl.origin.copy(this.object.position), Zl.direction.set(0, 0, -1).transformDirection(this.object.matrix), Math.abs(this.object.up.dot(Zl.direction)) < $l ? this.object.lookAt(this.target) : (Ql.setFromNormalAndCoplanarPoint(this.object.up, this.target), Zl.intersectPlane(Ql, this.target)))); 11951 } else if (this.object.isOrthographicCamera) { 11952 let e = this.object.zoom; 11953 this.object.zoom = Math.max(this.minZoom, Math.min(this.maxZoom, this.object.zoom / this._scale)), e !== this.object.zoom && (this.object.updateProjectionMatrix(), i = !0); 11954 } 11955 return this._scale = 1, this._performCursorZoom = !1, i || this._lastPosition.distanceToSquared(this.object.position) > nu || 8 * (1 - this._lastQuaternion.dot(this.object.quaternion)) > nu || this._lastTargetPosition.distanceToSquared(this.target) > nu ? (this.dispatchEvent(Jl), this._lastPosition.copy(this.object.position), this._lastQuaternion.copy(this.object.quaternion), this._lastTargetPosition.copy(this.target), !0) : !1; 11956 } 11957 _getAutoRotationAngle(e) { 11958 return e === null ? tu / 60 / 60 * this.autoRotateSpeed : tu / 60 * this.autoRotateSpeed * e; 11959 } 11960 _getZoomScale(e) { 11961 let t = Math.abs(e * .01); 11962 return .95 ** (this.zoomSpeed * t); 11963 } 11964 _rotateLeft(e) { 11965 this._sphericalDelta.theta -= e; 11966 } 11967 _rotateUp(e) { 11968 this._sphericalDelta.phi -= e; 11969 } 11970 _panLeft(e, t) { 11971 eu.setFromMatrixColumn(t, 0), eu.multiplyScalar(-e), this._panOffset.add(eu); 11972 } 11973 _panUp(e, t) { 11974 this.screenSpacePanning === !0 ? eu.setFromMatrixColumn(t, 1) : (eu.setFromMatrixColumn(t, 0), eu.crossVectors(this.object.up, eu)), eu.multiplyScalar(e), this._panOffset.add(eu); 11975 } 11976 _pan(e, t) { 11977 let n = this.domElement; 11978 if (this.object.isPerspectiveCamera) { 11979 let r = this.object.position; 11980 eu.copy(r).sub(this.target); 11981 let i = eu.length(); 11982 i *= Math.tan(this.object.fov / 2 * Math.PI / 180), this._panLeft(2 * e * i / n.clientHeight, this.object.matrix), this._panUp(2 * t * i / n.clientHeight, this.object.matrix); 11983 } else this.object.isOrthographicCamera ? (this._panLeft(e * (this.object.right - this.object.left) / this.object.zoom / n.clientWidth, this.object.matrix), this._panUp(t * (this.object.top - this.object.bottom) / this.object.zoom / n.clientHeight, this.object.matrix)) : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."), this.enablePan = !1); 11984 } 11985 _dollyOut(e) { 11986 this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale /= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1); 11987 } 11988 _dollyIn(e) { 11989 this.object.isPerspectiveCamera || this.object.isOrthographicCamera ? this._scale *= e : (console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."), this.enableZoom = !1); 11990 } 11991 _updateZoomParameters(e, t) { 11992 if (!this.zoomToCursor) return; 11993 this._performCursorZoom = !0; 11994 let n = this.domElement.getBoundingClientRect(), r = e - n.left, i = t - n.top, a = n.width, o = n.height; 11995 this._mouse.x = r / a * 2 - 1, this._mouse.y = -(i / o) * 2 + 1, this._dollyDirection.set(this._mouse.x, this._mouse.y, 1).unproject(this.object).sub(this.object.position).normalize(); 11996 } 11997 _clampDistance(e) { 11998 return Math.max(this.minDistance, Math.min(this.maxDistance, e)); 11999 } 12000 _handleMouseDownRotate(e) { 12001 this._rotateStart.set(e.clientX, e.clientY); 12002 } 12003 _handleMouseDownDolly(e) { 12004 this._updateZoomParameters(e.clientX, e.clientX), this._dollyStart.set(e.clientX, e.clientY); 12005 } 12006 _handleMouseDownPan(e) { 12007 this._panStart.set(e.clientX, e.clientY); 12008 } 12009 _handleMouseMoveRotate(e) { 12010 this._rotateEnd.set(e.clientX, e.clientY), this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed); 12011 let t = this.domElement; 12012 this._rotateLeft(tu * this._rotateDelta.x / t.clientHeight), this._rotateUp(tu * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd), this.update(); 12013 } 12014 _handleMouseMoveDolly(e) { 12015 this._dollyEnd.set(e.clientX, e.clientY), this._dollyDelta.subVectors(this._dollyEnd, this._dollyStart), this._dollyDelta.y > 0 ? this._dollyOut(this._getZoomScale(this._dollyDelta.y)) : this._dollyDelta.y < 0 && this._dollyIn(this._getZoomScale(this._dollyDelta.y)), this._dollyStart.copy(this._dollyEnd), this.update(); 12016 } 12017 _handleMouseMovePan(e) { 12018 this._panEnd.set(e.clientX, e.clientY), this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd), this.update(); 12019 } 12020 _handleMouseWheel(e) { 12021 this._updateZoomParameters(e.clientX, e.clientY), e.deltaY < 0 ? this._dollyIn(this._getZoomScale(e.deltaY)) : e.deltaY > 0 && this._dollyOut(this._getZoomScale(e.deltaY)), this.update(); 12022 } 12023 _handleKeyDown(e) { 12024 let t = !1; 12025 switch (e.code) { 12026 case this.keys.UP: 12027 e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(tu * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, this.keyPanSpeed), t = !0; 12028 break; 12029 case this.keys.BOTTOM: 12030 e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateUp(-tu * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(0, -this.keyPanSpeed), t = !0; 12031 break; 12032 case this.keys.LEFT: 12033 e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(tu * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(this.keyPanSpeed, 0), t = !0; 12034 break; 12035 case this.keys.RIGHT: 12036 e.ctrlKey || e.metaKey || e.shiftKey ? this.enableRotate && this._rotateLeft(-tu * this.keyRotateSpeed / this.domElement.clientHeight) : this.enablePan && this._pan(-this.keyPanSpeed, 0), t = !0; 12037 break; 12038 } 12039 t && (e.preventDefault(), this.update()); 12040 } 12041 _handleTouchStartRotate(e) { 12042 if (this._pointers.length === 1) this._rotateStart.set(e.pageX, e.pageY); 12043 else { 12044 let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y); 12045 this._rotateStart.set(n, r); 12046 } 12047 } 12048 _handleTouchStartPan(e) { 12049 if (this._pointers.length === 1) this._panStart.set(e.pageX, e.pageY); 12050 else { 12051 let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y); 12052 this._panStart.set(n, r); 12053 } 12054 } 12055 _handleTouchStartDolly(e) { 12056 let t = this._getSecondPointerPosition(e), n = e.pageX - t.x, r = e.pageY - t.y, i = Math.sqrt(n * n + r * r); 12057 this._dollyStart.set(0, i); 12058 } 12059 _handleTouchStartDollyPan(e) { 12060 this.enableZoom && this._handleTouchStartDolly(e), this.enablePan && this._handleTouchStartPan(e); 12061 } 12062 _handleTouchStartDollyRotate(e) { 12063 this.enableZoom && this._handleTouchStartDolly(e), this.enableRotate && this._handleTouchStartRotate(e); 12064 } 12065 _handleTouchMoveRotate(e) { 12066 if (this._pointers.length == 1) this._rotateEnd.set(e.pageX, e.pageY); 12067 else { 12068 let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y); 12069 this._rotateEnd.set(n, r); 12070 } 12071 this._rotateDelta.subVectors(this._rotateEnd, this._rotateStart).multiplyScalar(this.rotateSpeed); 12072 let t = this.domElement; 12073 this._rotateLeft(tu * this._rotateDelta.x / t.clientHeight), this._rotateUp(tu * this._rotateDelta.y / t.clientHeight), this._rotateStart.copy(this._rotateEnd); 12074 } 12075 _handleTouchMovePan(e) { 12076 if (this._pointers.length === 1) this._panEnd.set(e.pageX, e.pageY); 12077 else { 12078 let t = this._getSecondPointerPosition(e), n = .5 * (e.pageX + t.x), r = .5 * (e.pageY + t.y); 12079 this._panEnd.set(n, r); 12080 } 12081 this._panDelta.subVectors(this._panEnd, this._panStart).multiplyScalar(this.panSpeed), this._pan(this._panDelta.x, this._panDelta.y), this._panStart.copy(this._panEnd); 12082 } 12083 _handleTouchMoveDolly(e) { 12084 let t = this._getSecondPointerPosition(e), n = e.pageX - t.x, r = e.pageY - t.y, i = Math.sqrt(n * n + r * r); 12085 this._dollyEnd.set(0, i), this._dollyDelta.set(0, (this._dollyEnd.y / this._dollyStart.y) ** +this.zoomSpeed), this._dollyOut(this._dollyDelta.y), this._dollyStart.copy(this._dollyEnd); 12086 let a = (e.pageX + t.x) * .5, o = (e.pageY + t.y) * .5; 12087 this._updateZoomParameters(a, o); 12088 } 12089 _handleTouchMoveDollyPan(e) { 12090 this.enableZoom && this._handleTouchMoveDolly(e), this.enablePan && this._handleTouchMovePan(e); 12091 } 12092 _handleTouchMoveDollyRotate(e) { 12093 this.enableZoom && this._handleTouchMoveDolly(e), this.enableRotate && this._handleTouchMoveRotate(e); 12094 } 12095 _addPointer(e) { 12096 this._pointers.push(e.pointerId); 12097 } 12098 _removePointer(e) { 12099 delete this._pointerPositions[e.pointerId]; 12100 for (let t = 0; t < this._pointers.length; t++) if (this._pointers[t] == e.pointerId) { 12101 this._pointers.splice(t, 1); 12102 return; 12103 } 12104 } 12105 _isTrackingPointer(e) { 12106 for (let t = 0; t < this._pointers.length; t++) if (this._pointers[t] == e.pointerId) return !0; 12107 return !1; 12108 } 12109 _trackPointer(e) { 12110 let t = this._pointerPositions[e.pointerId]; 12111 t === void 0 && (t = new W(), this._pointerPositions[e.pointerId] = t), t.set(e.pageX, e.pageY); 12112 } 12113 _getSecondPointerPosition(e) { 12114 let t = e.pointerId === this._pointers[0] ? this._pointers[1] : this._pointers[0]; 12115 return this._pointerPositions[t]; 12116 } 12117 _customWheelEvent(e) { 12118 let t = e.deltaMode, n = { 12119 clientX: e.clientX, 12120 clientY: e.clientY, 12121 deltaY: e.deltaY 12122 }; 12123 switch (t) { 12124 case 1: 12125 n.deltaY *= 16; 12126 break; 12127 case 2: 12128 n.deltaY *= 100; 12129 break; 12130 } 12131 return e.ctrlKey && !this._controlActive && (n.deltaY *= 10), n; 12132 } 12133}; 12134function iu(e) { 12135 this.enabled !== !1 && (this._pointers.length === 0 && (this.domElement.setPointerCapture(e.pointerId), this.domElement.ownerDocument.addEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.addEventListener("pointerup", this._onPointerUp)), !this._isTrackingPointer(e) && (this._addPointer(e), e.pointerType === "touch" ? this._onTouchStart(e) : this._onMouseDown(e), this._cursorStyle === "grab" && (this.domElement.style.cursor = "grabbing"))); 12136} 12137function au(e) { 12138 this.enabled !== !1 && (e.pointerType === "touch" ? this._onTouchMove(e) : this._onMouseMove(e)); 12139} 12140function ou(e) { 12141 switch (this._removePointer(e), this._pointers.length) { 12142 case 0: 12143 this.domElement.releasePointerCapture(e.pointerId), this.domElement.ownerDocument.removeEventListener("pointermove", this._onPointerMove), this.domElement.ownerDocument.removeEventListener("pointerup", this._onPointerUp), this.dispatchEvent(Xl), this.state = $.NONE, this._cursorStyle === "grab" && (this.domElement.style.cursor = "grab"); 12144 break; 12145 case 1: 12146 let t = this._pointers[0], n = this._pointerPositions[t]; 12147 this._onTouchStart({ 12148 pointerId: t, 12149 pageX: n.x, 12150 pageY: n.y 12151 }); 12152 break; 12153 } 12154} 12155function su(e) { 12156 let t; 12157 switch (e.button) { 12158 case 0: 12159 t = this.mouseButtons.LEFT; 12160 break; 12161 case 1: 12162 t = this.mouseButtons.MIDDLE; 12163 break; 12164 case 2: 12165 t = this.mouseButtons.RIGHT; 12166 break; 12167 default: t = -1; 12168 } 12169 switch (t) { 12170 case M.DOLLY: 12171 if (this.enableZoom === !1) return; 12172 this._handleMouseDownDolly(e), this.state = $.DOLLY; 12173 break; 12174 case M.ROTATE: 12175 if (e.ctrlKey || e.metaKey || e.shiftKey) { 12176 if (this.enablePan === !1) return; 12177 this._handleMouseDownPan(e), this.state = $.PAN; 12178 } else { 12179 if (this.enableRotate === !1) return; 12180 this._handleMouseDownRotate(e), this.state = $.ROTATE; 12181 } 12182 break; 12183 case M.PAN: 12184 if (e.ctrlKey || e.metaKey || e.shiftKey) { 12185 if (this.enableRotate === !1) return; 12186 this._handleMouseDownRotate(e), this.state = $.ROTATE; 12187 } else { 12188 if (this.enablePan === !1) return; 12189 this._handleMouseDownPan(e), this.state = $.PAN; 12190 } 12191 break; 12192 default: this.state = $.NONE; 12193 } 12194 this.state !== $.NONE && this.dispatchEvent(Yl); 12195} 12196function cu(e) { 12197 switch (this.state) { 12198 case $.ROTATE: 12199 if (this.enableRotate === !1) return; 12200 this._handleMouseMoveRotate(e); 12201 break; 12202 case $.DOLLY: 12203 if (this.enableZoom === !1) return; 12204 this._handleMouseMoveDolly(e); 12205 break; 12206 case $.PAN: 12207 if (this.enablePan === !1) return; 12208 this._handleMouseMovePan(e); 12209 break; 12210 } 12211} 12212function lu(e) { 12213 this.enabled === !1 || this.enableZoom === !1 || this.state !== $.NONE || (e.preventDefault(), this.dispatchEvent(Yl), this._handleMouseWheel(this._customWheelEvent(e)), this.dispatchEvent(Xl)); 12214} 12215function uu(e) { 12216 this.enabled !== !1 && this._handleKeyDown(e); 12217} 12218function du(e) { 12219 switch (this._trackPointer(e), this._pointers.length) { 12220 case 1: 12221 switch (this.touches.ONE) { 12222 case ie.ROTATE: 12223 if (this.enableRotate === !1) return;
12224 this._handleTouchStartRotate(e), this.state = $.TOUCH_ROTATE; 12225 break; 12226 case ie.PAN: 12227 if (this.enablePan === !1) return; 12228 this._handleTouchStartPan(e), this.state = $.TOUCH_PAN; 12229 break; 12230 default: this.state = $.NONE; 12231 } 12232 break; 12233 case 2: 12234 switch (this.touches.TWO) { 12235 case ie.DOLLY_PAN: 12236 if (this.enableZoom === !1 && this.enablePan === !1) return; 12237 this._handleTouchStartDollyPan(e), this.state = $.TOUCH_DOLLY_PAN; 12238 break; 12239 case ie.DOLLY_ROTATE: 12240 if (this.enableZoom === !1 && this.enableRotate === !1) return; 12241 this._handleTouchStartDollyRotate(e), this.state = $.TOUCH_DOLLY_ROTATE; 12242 break; 12243 default: this.state = $.NONE; 12244 } 12245 break; 12246 default: this.state = $.NONE; 12247 } 12248 this.state !== $.NONE && this.dispatchEvent(Yl); 12249} 12250function fu(e) { 12251 switch (this._trackPointer(e), this.state) { 12252 case $.TOUCH_ROTATE: 12253 if (this.enableRotate === !1) return; 12254 this._handleTouchMoveRotate(e), this.update(); 12255 break; 12256 case $.TOUCH_PAN: 12257 if (this.enablePan === !1) return; 12258 this._handleTouchMovePan(e), this.update(); 12259 break; 12260 case $.TOUCH_DOLLY_PAN: 12261 if (this.enableZoom === !1 && this.enablePan === !1) return; 12262 this._handleTouchMoveDollyPan(e), this.update(); 12263 break; 12264 case $.TOUCH_DOLLY_ROTATE: 12265 if (this.enableZoom === !1 && this.enableRotate === !1) return; 12266 this._handleTouchMoveDollyRotate(e), this.update(); 12267 break; 12268 default: this.state = $.NONE; 12269 } 12270} 12271function pu(e) { 12272 this.enabled !== !1 && e.preventDefault(); 12273} 12274function mu(e) { 12275 e.key === "Control" && (this._controlActive = !0, this.domElement.getRootNode().addEventListener("keyup", this._interceptControlUp, { 12276 passive: !0, 12277 capture: !0 12278 })); 12279} 12280function hu(e) { 12281 e.key === "Control" && (this._controlActive = !1, this.domElement.getRootNode().removeEventListener("keyup", this._interceptControlUp, { 12282 passive: !0, 12283 capture: !0 12284 })); 12285} 12286Q.line = { 12287 worldUnits: { value: 1 }, 12288 linewidth: { value: 1 }, 12289 resolution: { value: new W() }, 12290 dashOffset: { value: 0 }, 12291 dashScale: { value: 1 }, 12292 dashSize: { value: 1 }, 12293 gapSize: { value: 1 } 12294}, Po.line = { 12295 uniforms: Ca.merge([ 12296 Q.common, 12297 Q.fog, 12298 Q.line 12299 ]), 12300 vertexShader: "\n #include <common>\n #include <color_pars_vertex>\n #include <fog_pars_vertex>\n #include <logdepthbuf_pars_vertex>\n #include <clipping_planes_pars_vertex>\n\n uniform float linewidth;\n uniform vec2 resolution;\n\n attribute vec3 instanceStart;\n attribute vec3 instanceEnd;\n\n attribute vec3 instanceColorStart;\n attribute vec3 instanceColorEnd;\n\n #ifdef WORLD_UNITS\n\n varying vec4 worldPos;\n varying vec3 worldStart;\n varying vec3 worldEnd;\n\n #ifdef USE_DASH\n\n varying vec2 vUv;\n\n #endif\n\n #else\n\n varying vec2 vUv;\n\n #endif\n\n #ifdef USE_DASH\n\n uniform float dashScale;\n attribute float instanceDistanceStart;\n attribute float instanceDistanceEnd;\n varying float vLineDistance;\n\n #endif\n\n float trimSegmentAlpha( const in vec4 start, const in vec4 end ) {\n\n // compute the interpolation factor needed to trim the segment so it terminates\n // between the camera plane and the near plane\n\n // conservative estimate of the near plane\n float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\n // we need different nearEstimate formula for reversed and default depth buffer\n // a is positive with a reversed depth buffer so it can be used for controlling the code flow\n float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a );\n\n return ( nearEstimate - start.z ) / ( end.z - start.z );\n\n }\n\n void main() {\n\n #ifdef USE_COLOR\n\n vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n #endif\n\n float aspect = resolution.x / resolution.y;\n\n // camera space\n vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n #ifdef USE_DASH\n\n float lineDistanceStart = dashScale * instanceDistanceStart;\n float lineDistanceEnd = dashScale * instanceDistanceEnd;\n\n #endif\n\n #ifdef WORLD_UNITS\n\n worldStart = start.xyz;\n worldEnd = end.xyz;\n\n #else\n\n vUv = uv;\n\n #endif\n\n // special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n // but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n // perhaps there is a more elegant solution -- WestLangley\n\n bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n if ( perspective ) {\n\n if ( start.z < 0.0 && end.z >= 0.0 ) {\n\n float alpha = trimSegmentAlpha( start, end );\n end.xyz = mix( start.xyz, end.xyz, alpha );\n\n #ifdef USE_DASH\n\n lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha );\n\n #endif\n\n } else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n float alpha = trimSegmentAlpha( end, start );\n start.xyz = mix( end.xyz, start.xyz, alpha );\n\n #ifdef USE_DASH\n\n lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha );\n\n #endif\n\n }\n\n }\n\n #ifdef USE_DASH\n\n vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd;\n vUv = uv;\n\n #endif\n\n // clip space\n vec4 clipStart = projectionMatrix * start;\n vec4 clipEnd = projectionMatrix * end;\n\n // ndc space\n vec3 ndcStart = clipStart.xyz / clipStart.w;\n vec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n // direction\n vec2 dir = ndcEnd.xy - ndcStart.xy;\n\n // account for clip-space aspect ratio\n dir.x *= aspect;\n dir = normalize( dir );
12300\n\n #ifdef WORLD_UNITS\n\n vec3 worldDir = normalize( end.xyz - start.xyz );\n vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n vec3 worldFwd = cross( worldDir, worldUp );\n worldPos = position.y < 0.5 ? start: end;\n\n // height offset\n float hw = linewidth * 0.5;\n worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n // don't extend the line if we're rendering dashes because we\n // won't be rendering the endcaps\n #ifndef USE_DASH\n\n // cap extension\n worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n // add width to the box\n worldPos.xyz += worldFwd * hw;\n\n // endcaps\n if ( position.y > 1.0 || position.y < 0.0 ) {\n\n worldPos.xyz -= worldFwd * 2.0 * hw;\n\n }\n\n #endif\n\n // project the worldpos\n vec4 clip = projectionMatrix * worldPos;\n\n // shift the depth of the projected points so the line\n // segments overlap neatly\n vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n clip.z = clipPose.z * clip.w;\n\n #else\n\n vec2 offset = vec2( dir.y, - dir.x );\n // undo aspect ratio adjustment\n dir.x /= aspect;\n offset.x /= aspect;\n\n // sign flip\n if ( position.x < 0.0 ) offset *= - 1.0;\n\n // endcaps\n if ( position.y < 0.0 ) {\n\n offset += - dir;\n\n } else if ( position.y > 1.0 ) {\n\n offset += dir;\n\n }\n\n // adjust for linewidth\n offset *= linewidth;\n\n // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n offset /= resolution.y;\n\n // select end\n vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n // back to clip space\n offset *= clip.w;\n\n clip.xy += offset;\n\n #endif\n\n gl_Position = clip;\n\n vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n\n }\n ", 12301 fragmentShader: "\n uniform vec3 diffuse;\n uniform float opacity;\n uniform float linewidth;\n\n #ifdef USE_DASH\n\n uniform float dashOffset;\n uniform float dashSize;\n uniform float gapSize;\n\n #endif\n\n varying float vLineDistance;\n\n #ifdef WORLD_UNITS\n\n varying vec4 worldPos;\n varying vec3 worldStart;\n varying vec3 worldEnd;\n\n #ifdef USE_DASH\n\n varying vec2 vUv;\n\n #endif\n\n #else\n\n varying vec2 vUv;\n\n #endif\n\n #include <common>\n #include <color_pars_fragment>\n #include <fog_pars_fragment>\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n\n vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n float mua;\n float mub;\n\n vec3 p13 = p1 - p3;\n vec3 p43 = p4 - p3;\n\n vec3 p21 = p2 - p1;\n\n float d1343 = dot( p13, p43 );\n float d4321 = dot( p43, p21 );
12301\n float d1321 = dot( p13, p21 );\n float d4343 = dot( p43, p43 );\n float d2121 = dot( p21, p21 );\n\n float denom = d2121 * d4343 - d4321 * d4321;\n\n float numer = d1343 * d4321 - d1321 * d4343;\n\n mua = numer / denom;\n mua = clamp( mua, 0.0, 1.0 );\n mub = ( d1343 + d4321 * ( mua ) ) / d4343;\n mub = clamp( mub, 0.0, 1.0 );\n\n return vec2( mua, mub );\n\n }\n\n void main() {\n\n float alpha = opacity;\n vec4 diffuseColor = vec4( diffuse, alpha );\n\n #include <clipping_planes_fragment>\n\n #ifdef USE_DASH\n\n if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n #endif\n\n #ifdef WORLD_UNITS\n\n // Find the closest points on the view ray and the line segment\n vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n vec3 lineDir = worldEnd - worldStart;\n vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n vec3 p1 = worldStart + lineDir * params.x;\n vec3 p2 = rayEnd * params.y;\n vec3 delta = p1 - p2;\n float len = length( delta );\n float norm = len / linewidth;\n\n #ifndef USE_DASH\n\n #ifdef USE_ALPHA_TO_COVERAGE\n\n float dnorm = fwidth( norm );\n alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n #else\n\n if ( norm > 0.5 ) {\n\n discard;\n\n }\n\n #endif\n\n #endif\n\n #else\n\n #ifdef USE_ALPHA_TO_COVERAGE\n\n // artifacts appear on some hardware if a derivative is taken within a conditional\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n float dlen = fwidth( len2 );\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n }\n\n #else\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n\n if ( len2 > 1.0 ) discard;\n\n }\n\n #endif\n\n #endif\n\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n\n gl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n\n }\n " 12302}; 12303var gu = class extends Ea { 12304 constructor(e) { 12305 super({ 12306 type: "LineMaterial", 12307 uniforms: Ca.clone(Po.line.uniforms), 12308 vertexShader: Po.line.vertexShader, 12309 fragmentShader: Po.line.fragmentShader, 12310 clipping: !0 12311 }), this.isLineMaterial = !0, this.setValues(e); 12312 } 12313 get color() { 12314 return this.uniforms.diffuse.value; 12315 } 12316 set color(e) { 12317 this.uniforms.diffuse.value = e; 12318 } 12319 get worldUnits() { 12320 return "WORLD_UNITS" in this.defines; 12321 } 12322 set worldUnits(e) { 12323 e === !0 !== this.worldUnits && (this.needsUpdate = !0), e === !0 ? this.defines.WORLD_UNITS = "" : delete this.defines.WORLD_UNITS; 12324 } 12325 get linewidth() { 12326 return this.uniforms.linewidth.value; 12327 } 12328 set linewidth(e) { 12329 this.uniforms.linewidth && (this.uniforms.linewidth.value = e); 12330 } 12331 get dashed() { 12332 return "USE_DASH" in this.defines; 12333 } 12334 set dashed(e) { 12335 e === !0 !== this.dashed && (this.needsUpdate = !0), e === !0 ? this.defines.USE_DASH = "" : delete this.defines.USE_DASH; 12336 } 12337 get dashScale() { 12338 return this.uniforms.dashScale.value; 12339 } 12340 set dashScale(e) { 12341 this.uniforms.dashScale.value = e; 12342 } 12343 get dashSize() { 12344 return this.uniforms.dashSize.value; 12345 } 12346 set dashSize(e) { 12347 this.uniforms.dashSize.value = e; 12348 } 12349 get dashOffset() { 12350 return this.uniforms.dashOffset.value; 12351 } 12352 set dashOffset(e) { 12353 this.uniforms.dashOffset.value = e; 12354 } 12355 get gapSize() { 12356 return this.uniforms.gapSize.value; 12357 } 12358 set gapSize(e) { 12359 this.uniforms.gapSize.value = e; 12360 } 12361 get opacity() { 12362 return this.uniforms.opacity.value; 12363 } 12364 set opacity(e) { 12365 this.uniforms && (this.uniforms.opacity.value = e); 12366 } 12367 get resolution() { 12368 return this.uniforms.resolution.value; 12369 } 12370 set resolution(e) { 12371 this.uniforms.resolution.value.copy(e); 12372 } 12373 get alphaToCoverage() { 12374 return "USE_ALPHA_TO_COVERAGE" in this.defines; 12375 } 12376 set alphaToCoverage(e) { 12377 this.defines && (e === !0 !== this.alphaToCoverage && (this.needsUpdate = !0), e === !0 ? this.defines.USE_ALPHA_TO_COVERAGE = "" : delete this.defines.USE_ALPHA_TO_COVERAGE); 12378 } 12379}, _u = new Or(), vu = new G(), yu = class extends to { 12380 constructor() { 12381 super(), this.isLineSegmentsGeometry = !0, this.type = "LineSegmentsGeometry", this.setIndex([ 12382 0, 12383 2, 12384 1, 12385 2, 12386 3, 12387 1, 12388 2, 12389 4, 12390 3, 12391 4, 12392 5, 12393 3, 12394 4, 12395 6, 12396 5, 12397 6, 12398 7, 12399 5 12400 ]), this.setAttribute("position", new X([ 12401 -1, 12402 2, 12403 0, 12404 1, 12405 2, 12406 0, 12407 -1, 12408 1, 12409 0, 12410 1, 12411 1, 12412 0, 12413 -1, 12414 0, 12415 0, 12416 1, 12417 0, 12418 0, 12419 -1, 12420 -1, 12421 0, 12422 1, 12423 -1, 12424 0 12425 ], 3)), this.setAttribute("uv", new X([ 12426 -1, 12427 2, 12428 1, 12429 2, 12430 -1, 12431 1, 12432 1, 12433 1, 12434 -1, 12435 -1, 12436 1, 12437 -1, 12438 -1, 12439 -2, 12440 1, 12441 -2 12442 ], 2)); 12443 } 12444 applyMatrix4(e) { 12445 let t = this.attributes.instanceStart, n = this.attributes.instanceEnd; 12446 return t !== void 0 && (t.applyMatrix4(e), n.applyMatrix4(e), t.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this; 12447 } 12448 setPositions(e) { 12449 let t; 12450 e instanceof Float32Array ? t = e : Array.isArray(e) && (t = new Float32Array(e)); 12451 let n = new yo(t, 6, 1); 12452 return this.setAttribute("instanceStart", new li(n, 3, 0)), this.setAttribute("instanceEnd", new li(n, 3, 3)), this.instanceCount = this.attributes.instanceStart.count, this.computeBoundingBox(), this.computeBoundingSphere(), this; 12453 } 12454 setColors(e) { 12455 let t; 12456 e instanceof Float32Array ? t = e : Array.isArray(e) && (t = new Float32Array(e)); 12457 let n = new yo(t, 6, 1); 12458 return this.setAttribute("instanceColorStart", new li(n, 3, 0)), this.setAttribute("instanceColorEnd", new li(n, 3, 3)), this; 12459 } 12460 fromWireframeGeometry(e) { 12461 return this.setPositions(e.attributes.position.array), this; 12462 } 12463 fromEdgesGeometry(e) { 12464 return this.setPositions(e.attributes.position.array), this; 12465 } 12466 fromMesh(e) { 12467 return this.fromWireframeGeometry(new ga(e.geometry)), this; 12468 } 12469 fromLineSegments(e) { 12470 let t = e.geometry; 12471 return this.setPositions(t.attributes.position.array), this; 12472 } 12473 computeBoundingBox() { 12474 this.boundingBox === null && (this.boundingBox = new Or()); 12475 let e = this.attributes.instanceStart, t = this.attributes.instanceEnd; 12476 e !== void 0 && t !== void 0 && (this.boundingBox.setFromBufferAttribute(e), _u.setFromBufferAttribute(t), this.boundingBox.union(_u)); 12477 } 12478 computeBoundingSphere() { 12479 this.boundingSphere === null && (this.boundingSphere = new Qr()), this.boundingBox === null && this.computeBoundingBox(); 12480 let e = this.attributes.instanceStart, t = this.attributes.instanceEnd; 12481 if (e !== void 0 && t !== void 0) { 12482 let n = this.boundingSphere.center; 12483 this.boundingBox.getCenter(n); 12484 let r = 0; 12485 for (let i = 0, a = e.count; i < a; i++) vu.fromBufferAttribute(e, i), r = Math.max(r, n.distanceToSquared(vu)), vu.fromBufferAttribute(t, i), r = Math.max(r, n.distanceToSquared(vu)); 12486 this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.", this); 12487 } 12488 } 12489 toJSON() {} 12490}, bu = new J(), xu = new G(), Su = new G(), Cu = new J(), wu = new J(), Tu = new J(), Eu = new G(), Du = new jn(), Ou = new Oo(), ku = new G(), Au = new Or(), ju = new Qr(), Mu = new J(), Nu, Pu; 12491function Fu(e, t, n) { 12492 return Mu.set(0, 0, -t, 1).applyMatrix4(e.projectionMatrix), Mu.multiplyScalar(1 / Mu.w), Mu.x = Pu / n.width, Mu.y = Pu / n.height, Mu.applyM
12492atrix4(e.projectionMatrixInverse), Mu.multiplyScalar(1 / Mu.w), Math.abs(Math.max(Mu.x, Mu.y)); 12493} 12494function Iu(e, t) { 12495 let n = e.matrixWorld, r = e.geometry, i = r.attributes.instanceStart, a = r.attributes.instanceEnd, o = Math.min(r.instanceCount, i.count); 12496 for (let r = 0, s = o; r < s; r++) { 12497 Ou.start.fromBufferAttribute(i, r), Ou.end.fromBufferAttribute(a, r), Ou.applyMatrix4(n); 12498 let o = new G(), s = new G(); 12499 Nu.distanceSqToSegment(Ou.start, Ou.end, s, o), s.distanceTo(o) < Pu * .5 && t.push({ 12500 point: s, 12501 pointOnLine: o, 12502 distance: Nu.origin.distanceTo(s), 12503 object: e, 12504 face: null, 12505 faceIndex: r, 12506 uv: null, 12507 uv1: null 12508 }); 12509 } 12510} 12511function Lu(e, t, n) { 12512 let r = t.projectionMatrix, i = e.material.resolution, a = e.matrixWorld, o = e.geometry, s = o.attributes.instanceStart, c = o.attributes.instanceEnd, l = Math.min(o.instanceCount, s.count), u = -t.near; 12513 Nu.at(1, Tu), Tu.w = 1, Tu.applyMatrix4(t.matrixWorldInverse), Tu.applyMatrix4(r), Tu.multiplyScalar(1 / Tu.w), Tu.x *= i.x / 2, Tu.y *= i.y / 2, Tu.z = 0, Eu.copy(Tu), Du.multiplyMatrices(t.matrixWorldInverse, a); 12514 for (let t = 0, o = l; t < o; t++) { 12515 if (Cu.fromBufferAttribute(s, t), wu.fromBufferAttribute(c, t), Cu.w = 1, wu.w = 1, Cu.applyMatrix4(Du), wu.applyMatrix4(Du), Cu.z > u && wu.z > u) continue; 12516 if (Cu.z > u) { 12517 let e = Cu.z - wu.z, t = (Cu.z - u) / e; 12518 Cu.lerp(wu, t); 12519 } else if (wu.z > u) { 12520 let e = wu.z - Cu.z, t = (wu.z - u) / e; 12521 wu.lerp(Cu, t); 12522 } 12523 Cu.applyMatrix4(r), wu.applyMatrix4(r), Cu.multiplyScalar(1 / Cu.w), wu.multiplyScalar(1 / wu.w), Cu.x *= i.x / 2, Cu.y *= i.y / 2, wu.x *= i.x / 2, wu.y *= i.y / 2, Ou.start.copy(Cu), Ou.start.z = 0, Ou.end.copy(wu), Ou.end.z = 0; 12524 let o = Ou.closestPointToPointParameter(Eu, !0); 12525 Ou.at(o, ku); 12526 let l = ln.lerp(Cu.z, wu.z, o), d = l >= -1 && l <= 1, f = Eu.distanceTo(ku) < Pu * .5; 12527 if (d && f) { 12528 Ou.start.fromBufferAttribute(s, t), Ou.end.fromBufferAttribute(c, t), Ou.start.applyMatrix4(a), Ou.end.applyMatrix4(a); 12529 let r = new G(), i = new G(); 12530 Nu.distanceSqToSegment(Ou.start, Ou.end, i, r), n.push({ 12531 point: i, 12532 pointOnLine: r, 12533 distance: Nu.origin.distanceTo(i), 12534 object: e, 12535 face: null, 12536 faceIndex: t, 12537 uv: null, 12538 uv1: null 12539 }); 12540 } 12541 } 12542} 12543var Ru = class extends Mi { 12544 constructor(e = new yu(), t = new gu({ color: Math.random() * 16777215 })) { 12545 super(e, t), this.isLineSegments2 = !0, this.type = "LineSegments2"; 12546 } 12547 computeLineDistances() { 12548 let e = this.geometry, t = e.attributes.instanceStart, n = e.attributes.instanceEnd, r = new Float32Array(2 * t.count); 12549 for (let e = 0, i = 0, a = t.count; e < a; e++, i += 2) xu.fromBufferAttribute(t, e), Su.fromBufferAttribute(n, e), r[i] = i === 0 ? 0 : r[i - 1], r[i + 1] = r[i] + xu.distanceTo(Su); 12550 let i = new yo(r, 2, 1); 12551 return e.setAttribute("instanceDistanceStart", new li(i, 1, 0)), e.setAttribute("instanceDistanceEnd", new li(i, 1, 1)), this; 12552 } 12553 raycast(e, t) { 12554 let n = this.material.worldUnits, r = e.camera; 12555 if (r === null && !n && console.error("LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false."), n === !1 && (this.material.resolution.x === 0 || this.material.resolution.y === 0)) return; 12556 let i = e.params.Line2 === void 0 ? 0 : e.params.Line2.threshold || 0; 12557 Nu = e.ray; 12558 let a = this.matrixWorld, o = this.geometry, s = this.material; 12559 Pu = s.linewidth + i, o.boundingSphere === null && o.computeBoundingSphere(), ju.copy(o.boundingSphere).applyMatrix4(a); 12560 let c; 12561 if (c = n ? Pu * .5 : Fu(r, Math.max(r.near, ju.distanceToPoint(Nu.origin)), s.resolution), ju.radius += c, Nu.intersectsSphere(ju) === !1) return; 12562 o.boundingBox === null && o.computeBoundingBox(), Au.copy(o.boundingBox).applyMatrix4(a); 12563 let l; 12564 l = n ? Pu * .5 : Fu(r, Math.max(r.near, Au.distanceToPoint(Nu.origin)), s.resolution), Au.expandByScalar(l), Nu.intersectsBox(Au) !== !1 && (n ? Iu(this, t) : Lu(this, r, t)); 12565 } 12566 onBeforeRender(e) { 12567 let t = this.material.uniforms; 12568 t && t.resolution && (e.getViewport(bu), this.material.uniforms.resolution.value.set(bu.z, bu.w)); 12569 } 12570}, zu = { 12571 frame: [ 12572 .8, 12573 .1, 12574 0, 12575 1 12576 ], 12577 plane: [ 12578 1, 12579 .1, 12580 0, 12581 .6 12582 ], 12583 selectedFrame: [ 12584 .8, 12585 0, 12586 .8, 12587 1 12588 ], 12589 selectedPlane: [ 12590 1,
12591 0, 12592 1, 12593 .6 12594 ], 12595 sameFrame: [ 12596 .6, 12597 0, 12598 .6, 12599 179 / 255 12600 ], 12601 sameFramePlane: [ 12602 .8, 12603 0, 12604 .8, 12605 77 / 255 12606 ] 12607}, Bu = { 12608 grid: [ 12609 51 / 255, 12610 51 / 255, 12611 51 / 255, 12612 153 / 255 12613 ], 12614 x: [ 12615 230 / 255, 12616 0, 12617 0, 12618 128 / 255 12619 ], 12620 y: [ 12621 0, 12622 230 / 255, 12623 0, 12624 128 / 255 12625 ], 12626 z: [ 12627 0, 12628 0, 12629 230 / 255, 12630 128 / 255 12631 ] 12632}, Vu = { 12633 selectedPoint: new Y(0, 1, 0), 12634 selectedCameraPlane: new Y(1, 0, 1), 12635 pointConnection: new Y(0, 1, 0), 12636 imageConnection: new Y(.8, 0, .8) 12637}; 12638function Hu(e) { 12639 return new un(e[1], e[2], e[3], e[0]).invert(); 12640} 12641function Uu(e, t, n = 1) { 12642 for (let r = 0; r < n; ++r) e.push(...t); 12643} 12644function Wu(e = 0, t = !0) { 12645 return new Ea({ 12646 vertexShader: "attribute vec4 color; varying vec4 vColor; void main(){vColor=color; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0);}", 12647 fragmentShader: "varying vec4 vColor; void main(){gl_FragColor=vColor;}", 12648 transparent: !0, 12649 depthWrite: t, 12650 side: e, 12651 toneMapped: !1 12652 }); 12653} 12654function Gu(e, t = 0, n = !0) { 12655 return new Ea({ 12656 uniforms: { cameraSize: { value: e } }, 12657 vertexShader: "attribute vec3 cameraCenter; attribute vec4 color; varying vec4 vColor; uniform float cameraSize; void main(){vColor=color; vec3 p=cameraCenter+(position-cameraCenter)*cameraSize; gl_Position=projectionMatrix*modelViewMatrix*vec4(p,1.0);}", 12658 fragmentShader: "varying vec4 vColor; void main(){gl_FragColor=vColor;}", 12659 transparent: !0, 12660 depthWrite: n, 12661 side: t, 12662 toneMapped: !1 12663 }); 12664} 12665function Ku(e) { 12666 return new Ea({ 12667 uniforms: { cameraSize: { value: e } }, 12668 vertexShader: "attribute vec3 cameraCenter; attribute vec3 color; varying vec3 vColor; uniform float cameraSize; void main(){vColor=color; vec3 p=cameraCenter+(position-cameraCenter)*cameraSize; gl_Position=projectionMatrix*modelViewMatrix*vec4(p,1.0);}", 12669 fragmentShader: "varying vec3 vColor; void main(){gl_FragColor=vec4(vColor,1.0);}", 12670 side: 2, 12671 toneMapped: !1 12672 }); 12673} 12674function qu(e, t, n) { 12675 for (let r = 0; r < n; ++r) e.push(t.x, t.y, t.z); 12676} 12677function Ju(e) { 12678 let t = new oi(); 12679 t.setAttribute("position", new X(new Float32Array(e.length * 2 * 3), 3)); 12680 let n = []; 12681 for (let t of e) Uu(n, t, 2); 12682 return t.setAttribute("color", new X(n, 4)), new na(t, Wu()); 12683} 12684function Yu() { 12685 let e = new yu(); 12686 e.setPositions(/* @__PURE__ */ new Float32Array(18)), e.setColors([ 12687 ...Bu.x.slice(0, 3), 12688 ...Bu.x.slice(0, 3), 12689 ...Bu.y.slice(0, 3), 12690 ...Bu.y.slice(0, 3), 12691 ...Bu.z.slice(0, 3), 12692 ...Bu.z.slice(0, 3) 12693 ]); 12694 let t = new gu({ 12695 transparent: !0, 12696 opacity: 128 / 255 12697 }); 12698 t.linewidth = 2, t.vertexColors = !0; 12699 let n = new Ru(e, t); 12700 return n.frustumCulled = !1, n; 12701} 12702function Xu(e, t, n, r, i) { 12703 let a = n === 1 ? 40 : n === 2 ? 100 : 1, o = -t * a, s = Math.max(.01, 1 + o / 100 * .1); 12704 return ln.clamp(e * s, r, i); 12705} 12706function Zu(e) { 12707 e.traverse((e) => { 12708 let t = e; 12709 t.geometry?.dispose(); 12710 let n = t.material; 12711 Array.isArray(n) ? n.forEach((e) => e.dispose()) : n?.dispose(); 12712 }); 12713} 12714var Qu = class { 12715 canvas; 12716 settings = { 12717 pointSize: 2, 12718 cameraSize: .025, 12719 minTrackLength: 3, 12720 maxError: 2, 12721 showConnections: !1, 12722 projection: "perspective" 12723 }; 12724 onSelection = () => void 0; 12725 onError = () => void 0; 12726 onContextChange = () => void 0; 12727 onSettingsChange = () => void 0; 12728 renderer; 12729 scene = new pr(); 12730 pickingScene = new pr(); 12731 perspectiveCamera = new $a(25, 1, 1e-4, 1e6); 12732 orthographicCamera = new eo(-1, 1, 1, -1, 1e-4, 1e6); 12733 activeCamera = this.perspectiveCamera; 12734 controls; 12735 renderTarget = new On(1, 1, { 12736 depthBuffer: !0, 12737 stencilBuffer: !1 12738 }); 12739 content = new ar(); 12740 pickingContent = new ar(); 12741 pointContent = new ar(); 12742 cameraContent = new ar(); 12743 connectionContent = new ar(); 12744 pointPickingContent = new ar(); 12745 cameraPickingContent = new ar(); 12746 coordinateGrid = Ju([ 12747 Bu.grid, 12748 Bu.grid, 12749 Bu.grid 12750 ]); 12751 coordinateAxes = Yu(); 12752 resizeObserver; 12753 reconstruction = null; 12754 pointsObject = null; 12755 pickPointsObject = null; 12756 pointDrawList = /* @__PURE__ */ new Uint32Array(); 12757 imageDrawList = []; 12758 center = [ 12759 0, 12760 0, 12761 0 12762 ]; 12763 scale = 1; 12764 viewCenter = new G(); 12765 viewRadius = 1; 12766 coordinateOrigin = new G(); 12767 selection = null; 12768 animationFrame = 0; 12769 contextLost = !1; 12770 disposed = !1; 12771 constructor(e) { 12772 this.canvas = e, this.renderer = new ql({ 12773 canvas: e, 12774 antialias: !0, 12775 preserveDrawingBuffer: !1 12776 }), this.renderer.setClearColor(16777215, 1), this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2)), this.coordinateGrid.visible = !1, this.coordinateAxes.visible = !1, this.coordinateGrid.renderOrder = -2, this.coordinateAxes.renderOrder = -1, this.content.add(this.pointContent, this.cameraContent, this.connectionContent), this.pickingContent.add(this.pointPickingContent, this.cameraPickingContent), this.scene.add(this.coordinateGrid, this.coordinateAxes, this.content), this.pickingScene.add(this.pickingContent), this.perspectiveCamera.position.set(1.8, -1.8, 1.8), this.perspectiveCamera.up.set(0, -1, 0), this.orthographicCamera.up.copy(this.perspectiveCamera.up), this.controls = this.createControls(this.activeCamera), this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(e.parentElement ?? e), e.addEventListener("dblclick", (e) => this.pick(e)), e.addEventListener("contextmenu", (e) => e.preventDefault()), e.addEventListener("wheel", (e) => this.handleModifiedWheel(e), {
12777 passive: !1, 12778 capture: !0 12779 }), e.addEventListener("webglcontextlost", this.handleContextLost), e.addEventListener("webglcontextrestored", this.handleContextRestored), this.resize(), this.startAnimation(); 12780 } 12781 createControls(e) { 12782 this.controls?.dispose(); 12783 let t = new ru(e, this.canvas); 12784 return t.enableDamping = !0, t.dampingFactor = .08, t.screenSpacePanning = !0, t.mouseButtons.LEFT = M.ROTATE, t.mouseButtons.RIGHT = M.PAN, t; 12785 } 12786 startAnimation() { 12787 this.animationFrame === 0 && !this.contextLost && !this.disposed && (this.animationFrame = requestAnimationFrame(this.animate)); 12788 } 12789 animate = () => { 12790 if (this.animationFrame = 0, !(this.contextLost || this.disposed)) { 12791 this.controls.update(), this.updateCoordinateOverlays(); 12792 try { 12793 this.renderer.render(this.scene, this.activeCamera), this.startAnimation(); 12794 } catch (e) { 12795 this.onError(e instanceof Error ? e : Error(String(e))); 12796 } 12797 } 12798 }; 12799 handleContextLost = (e) => { 12800 e.preventDefault(), this.contextLost = !0, cancelAnimationFrame(this.animationFrame), this.animationFrame = 0, this.disposed || this.onContextChange(!0); 12801 }; 12802 handleContextRestored = () => { 12803 this.disposed || (this.contextLost = !1, this.renderer.resetState(), this.resize(), this.onContextChange(!1), this.startAnimation()); 12804 }; 12805 dispose() { 12806 this.disposed || (this.disposed = !0, cancelAnimationFrame(this.animationFrame), this.animationFrame = 0, this.canvas.removeEventListener("webglcontextlost", this.handleContextLost), this.canvas.removeEventListener("webglcontextrestored", this.handleContextRestored), this.resizeObserver.disconnect(), this.controls.dispose(), this.clearGroups(), Zu(this.coordinateGrid), Zu(this.coordinateAxes), this.renderTarget.dispose(), this.renderer.dispose()); 12807 } 12808 setReconstruction(e) { 12809 this.reconstruction = e, this.selection = null; 12810 let t = [...e.images.values()].map((e) => m(e.camFromWorld)), n = t.map((e) => e[0]), r = t.map((e) => e[1]), i = t.map((e) => e[2]); 12811 this.center = [ 12812 g(n), 12813 g(r), 12814 g(i) 12815 ]; 12816 let a = Math.max(h(n, .95) - h(n, .05), h(r, .95) - h(r, .05), h(i, .95) - h(i, .05), 1e-6); 12817 this.scale = 1 / a, this.coordinateOrigin.copy(this.normalized([ 12818 0, 12819 0, 12820 0 12821 ])), this.coordinateGrid.visible = !0, this.coordinateAxes.visible = !0, this.rebuild(), this.computeViewBounds(), this.resize(), this.resetView(); 12822 } 12823 clearReconstruction() { 12824 this.reconstruction = null, this.selection = null, this.clearGroups(), this.pointDrawList = /* @__PURE__ */ new Uint32Array(), this.imageDrawList = [], this.coordinateGrid.visible = !1, this.coordinateAxes.visible = !1, this.onSelection(null); 12825 } 12826 get visiblePointCount() { 12827 return this.pointDrawList.length; 12828 } 12829 updateSettings(e) { 12830 let t = e.projection !== void 0 && e.projection !== this.settings.projection, n = e.pointSize !== void 0 && e.pointSize !== this.settings.pointSize, r = e.cameraSize !== void 0 && e.cameraSize !== this.settings.cameraSize, i = e.minTrackLength !== void 0 && e.minTrackLength !== this.settings.minTrackLength || e.maxError !== void 0 && e.maxError !== this.settings.maxError, a = e.showConnections !== void 0 && e.showConnections !== this.settings.showConnections; 12831 if (Object.assign(this.settings, e), this.onSettingsChange(this.settings), t && this.switchProjection(), i) { 12832 this.rebuild(); 12833 return; 12834 } 12835 if (n) { 12836 let e = this.pointsObject?.material; 12837 e && (e.size = this.settings.pointSize); 12838 let t = this.pickPointsObject?.material; 12839 t && (t.uniforms.pointSize.value = Math.max(8, this.settings.pointSize * 2)); 12840 } 12841 r && this.updateCameraSize(), a && this.rebuildConnections(); 12842 } 12843 resetView() { 12844 let e = Math.max(.5, this.viewRadius / Math.tan(ln.degToRad(this.perspectiveCamera.fov) / 2) * 1.25), t = new G(1, -1, 1).normalize(); 12845 this.activeCamera.position.copy(this.viewCenter).addScaledVector(t, e), this.controls.target.copy(this.viewCenter), this.activeCamera.lookAt(this.viewCenter), this.controls.update(), this.resize(); 12846 } 12847 clearSelection() { 12848 this.selection = null, this.rebuild(), this.onSelection(null); 12849 } 12850 normalized(e) { 12851 return new G((e[0] - this.center[0]) * this.scale, (e[1] - this.center[1]) * this.scale, (e[2] - this.center[2]) * this.scale); 12852 } 12853 normalizedPoint(e) { 12854 let t = this.reconstruction.points3D.xyz, n = e * 3; 12855 return this.normalized([ 12856 t[n], 12857 t[n + 1], 12858 t[n + 2] 12859 ]); 12860 } 12861 worldUnitsPerPixel() { 12862 let e = Math.max(1, this.canvas.clientHeight); 12863 if (this.activeCamera instanceof eo) return (this.activeCamera.top - this.activeCamera.bottom) / (this.activeCamera.zoom * e); 12864 let t = this.activeCamera.position.distanceTo(this.controls.target); 12865 return 2 * Math.tan(ln.degToRad(this.activeCamera.fov) / 2) * t / e; 12866 } 12867 updateCoordinateOverlays() { 12868 if (!this.reconstruction) return; 12869 let e = this.worldUnitsPerPixel(), t = 20 * e, n = 50 * e, r = this.controls.target, i = this.coordinateGrid.geometry.getAttribute("position"), a = this.coordinateAxes.geometry.getAttribute("instanceStart"), o = this.coordinateAxes.geometry.getAttribute("instanceEnd"); 12870 for (let e = 0; e < 3; ++e) { 12871 let s = r.clone(), c = r.clone(); 12872 s.setComponent(e, s.getComponent(e) - t), c.setComponent(e, c.getComponent(e) + t), i.setXYZ(e * 2, s.x, s.y, s.z), i.setXYZ(e * 2 + 1, c.x, c.y, c.z); 12873 let l = this.coordinateOrigin.clone(); 12874 l.setComponent(e, l.getComponent(e) + n), a.setXYZ(e, this.coordinateOrigin.x, this.coordinateOrigin.y, this.coordinateOrigin.z), o.setXYZ(e, l.x, l.y, l.z); 12875 } 12876 i.needsUpdate = !0, a.data.needsUpdate = !0; 12877 } 12878 clearGroup(e) { 12879 for (let t of [...e.children]) e.remove(t), Zu(t); 12880 } 12881 clearGroups() { 12882 for (let e of [ 12883 this.pointContent, 12884 this.cameraContent, 12885 this.connectionContent, 12886 this.pointPickingContent, 12887 this.cameraPickingContent 12888 ]) this.clearGroup(e); 12889 this.pointsObject = null, this.pickPointsObject = null; 12890 } 12891 rebuild() { 12892 this.reconstruction && (this.clearGroups(), this.buildPoints(), this.buildCameras(), this.buildConnections()); 12893 } 12894 rebuildConnections() { 12895 this.reconstruction && (this.clearGroup(this.connectionContent), this.buildConnections()); 12896 } 12897 updateCameraSize() { 12898 for (let e of [this.cameraContent, this.cameraPickingContent]) e.traverse((e) => { 12899 let t = e.material, n = Array.isArray(t) ? t : [t]; 12900 for (let e of n) e instanceof Ea && e.uniforms.cameraSize && (e.uniforms.cameraSize.value = this.settings.cameraSize); 12901 }); 12902 } 12903 computeViewBounds() { 12904 if (!this.reconstruction) return; 12905 let e = [ 12906 [], 12907 [], 12908 [] 12909 ], t = (t) => { 12910 e[0].push(t.x), e[1].push(t.y), e[2].push(t.z); 12911 }, n = Math.max(1, Math.floor(this.pointDrawList.length / 1e5)); 12912 for (let e = 0; e < this.pointDrawList.length; e += n) { 12913 let n = this.pointDrawList[e] * 3; 12914 t(this.normalized([ 12915 this.reconstruction.points3D.xyz[n], 12916 this.reconstruction.points3D.xyz[n + 1], 12917 this.reconstruction.points3D.xyz[n + 2] 12918 ])); 12919 } 12920 for (let e of this.reconstruction.images.values()) t(this.normalized(m(e.camFromWorld))); 12921 if (e[0].length === 0) { 12922 this.viewCenter.set(0, 0, 0), this.viewRadius = 1; 12923 return; 12924 } 12925 let r = new G(...e.map((e) => h(e, .01))), i = new G(...e.map((e) => h(e, .99))); 12926 this.viewCenter.copy(r).add(i).multiplyScalar(.5), this.viewRadius = Math.max(.05, r.distanceTo(i) * .5); 12927 } 12928 buildPoints() { 12929 let e = this.reconstruction, t = this.selection?.type === "image" ? this.selection.value : null, n = /* @__PURE__ */ new Set(); 12930 if (t) for (let e of t.points2D.point3DIds) e !== 18446744073709551615n && n.add(e); 12931 let r = e.points3D, i = 0; 12932 for (let e = 0; e < te(r); ++e) r.errors[e] <= this.settings.maxError && j(r, e) >= this.settings.minTrackLength && ++i; 12933 this.pointDrawList = new Uint32Array(i); 12934 let a = new Float32Array(i * 3), o = new Float32Array(i * 3), s = new Float32Array(i * 3), c = new Y(), l = 0; 12935 for (let e = 0; e < te(r); ++e) { 12936 if (r.errors[e] > this.settings.maxError || j(r, e) < this.settings.minTrackLength) continue; 12937 this.pointDrawList[l] = e; 12938 let t = e * 3, i = l * 3; 12939 a[i] = (r.xyz[t] - this.center[0]) * this.scale, a[i + 1] = (r.xyz[t + 1] - this.center[1]) * this.scale, a[i + 2] = (r.xyz[t + 2] - this.center[2]) * this.scale, c.setRGB(r.colors[t] / 255, r.colors[t + 1] / 25
129395, r.colors[t + 2] / 255, bt), this.selection?.type === "point" && this.selection.index === e ? c.copy(Vu.selectedPoint) : n.has(r.ids[e]) && c.copy(Vu.selectedCameraPlane), o[i] = c.r, o[i + 1] = c.g, o[i + 2] = c.b; 12940 let u = l + 1; 12941 s[i] = (u & 255) / 255, s[i + 1] = (u >> 8 & 255) / 255, s[i + 2] = (u >> 16 & 255) / 255, ++l; 12942 } 12943 let u = new oi(); 12944 u.setAttribute("position", new X(a, 3)), u.setAttribute("color", new X(o, 3)), this.pointsObject = new ca(u, new ra({ 12945 size: this.settings.pointSize, 12946 sizeAttenuation: !1, 12947 vertexColors: !0 12948 })), this.pointContent.add(this.pointsObject); 12949 let d = new oi(); 12950 d.setAttribute("position", new X(a, 3)), d.setAttribute("pickColor", new X(s, 3)); 12951 let f = new Ea({ 12952 uniforms: { pointSize: { value: Math.max(8, this.settings.pointSize * 2) } }, 12953 vertexShader: "attribute vec3 pickColor; varying vec3 vColor; uniform float pointSize; void main(){vColor=pickColor; gl_Position=projectionMatrix*modelViewMatrix*vec4(position,1.0); gl_PointSize=pointSize;}", 12954 fragmentShader: "varying vec3 vColor; void main(){if(length(gl_PointCoord-vec2(0.5))>0.5) discard; gl_FragColor=vec4(vColor,1.0);}", 12955 toneMapped: !1 12956 }); 12957 this.pickPointsObject = new ca(d, f), this.pointPickingContent.add(this.pickPointsObject); 12958 } 12959 cameraGeometry(e, t) { 12960 let n = this.normalized(m(e.camFromWorld)), r = Hu(e.camFromWorld.rotation), i = t.width / Math.max(t.width, t.height), a = t.height / Math.max(t.width, t.height), o = (t.params[0] ?? Math.max(t.width, t.height)) / Math.max(t.width, t.height), s = i * .5, c = a * .5, l = Math.max(o, .25); 12961 return { 12962 center: n, 12963 corners: [ 12964 new G(-s, -c, l), 12965 new G(s, -c, l), 12966 new G(s, c, l), 12967 new G(-s, c, l) 12968 ].map((e) => e.applyQuaternion(r).add(n)) 12969 }; 12970 } 12971 sphericalCameraGeometry(e) { 12972 let t = this.normalized(m(e.camFromWorld)), n = Hu(e.camFromWorld.rotation), r = .55, i = (e) => e.applyQuaternion(n).add(t), a = []; 12973 for (let e = 0; e < 3; ++e) for (let t = 0; t < 24; ++t) { 12974 let n = [t / 24 * Math.PI * 2, (t + 1) / 24 * Math.PI * 2]; 12975 for (let t of n) { 12976 let n = Math.cos(t) * r, o = Math.sin(t) * r, s = e === 0 ? new G(n, o, 0) : e === 1 ? new G(n, 0, o) : new G(0, n, o); 12977 a.push(i(s)); 12978 } 12979 } 12980 let o = [ 12981 new G(r, 0, 0), 12982 new G(-.55, 0, 0), 12983 new G(0, r, 0), 12984 new G(0, -.55, 0), 12985 new G(0, 0, r), 12986 new G(0, 0, -.55) 12987 ]; 12988 return { 12989 center: t, 12990 lines: a, 12991 triangles: [ 12992 0, 12993 2, 12994 4, 12995 2, 12996 1, 12997 4, 12998 1, 12999 3, 13000 4, 13001 3, 13002 0, 13003 4, 13004 2, 13005 0, 13006 5, 13007 1, 13008 2, 13009 5, 13010 3, 13011 1, 13012 5, 13013 0, 13014 3, 13015 5 13016 ].map((e) => i(o[e].clone())) 13017 }; 13018 } 13019 buildCameras() { 13020 let e = this.reconstruction; 13021 this.imageDrawList = [...e.images.values()]; 13022 let t = [], n = [], r = [], i = [], a = [], o = [], s = [], c = [], l = [], u = this.selection?.type === "image" ? this.selection.value.frameId : -1; 13023 for (let d = 0; d < this.imageDrawList.length; ++d) { 13024 let f = this.imageDrawList[d], p = e.cameras.get(f.cameraId), m = this.selection?.type === "image" && this.selection.value.id === f.id, h = !m && f.frameId === u, g = m ? zu.selectedFrame : h ? zu.sameFrame : zu.frame, _ = m ? zu.selectedPlane : h ? zu.sameFramePlane : zu.plane, v = this.pointDrawList.length + d + 1; 13025 if (p.modelId === 17) { 13026 let e = this.sphericalCameraGeometry(f); 13027 for (let n of e.lines) t.push(...n.toArray()); 13028 Uu(n, g, e.lines.length), qu(r, e.center, e.lines.length); 13029 for (let t of e.triangles) i.push(...t.toArray()), s.push(...t.toArray()); 13030 Uu(a, _, e.triangles.length), qu(o, e.center, e.triangles.length), qu(l, e.center, e.triangles.length); 13031 for (let t = 0; t < e.triangles.length; ++t) c.push((v & 255) / 255, (v >> 8 & 255) / 255, (v >> 16 & 255) / 255); 13032 continue; 13033 } 13034 let { center: y, corners: b } = this.cameraGeometry(f, p); 13035 for (let e = 0; e < 4; ++e) t.push(...y.toArray(), ...b[e].toArray()), t.push(...b[e].toArray(), ...b[(e + 1) % 4].toArray()), Uu(n, g, 4), qu(r, y, 4); 13036 let x = [ 13037 b[0], 13038 b[1], 13039 b[2], 13040 b[0], 13041 b[2], 13042 b[3] 13043 ]; 13044 for (let e of x) i.push(...e.toArray()); 13045 Uu(a, _, 6), qu(o, y, 6); 13046 for (let e of x) s.push(...e.toArray()); 13047 qu(l, y, 6); 13048 for (let e = 0; e < 6; ++e) c.push((v & 255) / 255, (v >> 8 & 255) / 255, (v >> 16 & 255) / 255); 13049 } 13050 let d = new oi(); 13051 d.setAttribute("position", new X(t, 3)), d.setAttribute("color", new X(n, 4)), d.setAttribute("cameraCenter", new X(r, 3)), this.cameraContent.add(new na(d, Gu(this.settings.cameraSize))); 13052 let f = new oi(); 13053 f.setAttribute("position", new X(i, 3)), f.setAttribute("color", new X(a, 4)), f.setAttribute("cameraCenter", new X(o, 3)), this.cameraContent.add(new Mi(f, Gu(this.settings.cameraSize, 2, !1))); 13054 let p = new oi(); 13055 p.setAttribute("position", new X(s, 3)), p.setAttribute("color", new X(c, 3)), p.setAttribute("cameraCenter", new X(l, 3)), this.cameraPickingContent.add(new Mi(p, Ku(this.settings.cameraSize))); 13056 } 13057 buildConnections() { 13058 if (!this.reconstruction || !this.selection && !this.settings.showConnections) return; 13059 let e = this.reconstruction.points3D, t = [], n = Vu.pointConnection; 13060 if (!this.selection) { 13061 n = Vu.imageConnection; 13062 let r = /* @__PURE__ */ new Set(); 13063 for (let n of this.reconstruction.images.values()) { 13064 let i = this.normalized(m(n.camFromWorld)); 13065 for (let a = 0; a < A(n); ++a) { 13066 let o = n.points2D.point3DIds[a]; 13067 if (o === 18446744073709551615n) continue; 13068 let s = re(e, o); 13069 if (!(s < 0)) for (let a = e.trackOffsets[s]; a < e.trackOffsets[s + 1]; ++a) { 13070 let o = e.trackImageIds[a]; 13071 if (o === n.id) continue; 13072 let s = `${Math.min(n.id, o)}:${Math.max(n.id, o)}`; 13073 if (r.has(s)) continue;
13074 let c = this.reconstruction.images.get(o); 13075 c && (r.add(s), t.push(...i.toArray(), ...this.normalized(m(c.camFromWorld)).toArray())); 13076 } 13077 } 13078 } 13079 } else if (this.selection.type === "point") { 13080 let n = this.normalizedPoint(this.selection.index); 13081 for (let r = e.trackOffsets[this.selection.index]; r < e.trackOffsets[this.selection.index + 1]; ++r) { 13082 let i = this.reconstruction.images.get(e.trackImageIds[r]); 13083 i && t.push(...n.toArray(), ...this.normalized(m(i.camFromWorld)).toArray()); 13084 } 13085 } else { 13086 n = Vu.imageConnection; 13087 let r = this.normalized(m(this.selection.value.camFromWorld)), i = /* @__PURE__ */ new Set(); 13088 for (let t of this.selection.value.points2D.point3DIds) { 13089 if (t === 18446744073709551615n) continue; 13090 let n = re(e, t); 13091 if (!(n < 0)) for (let t = e.trackOffsets[n]; t < e.trackOffsets[n + 1]; ++t) i.add(e.trackImageIds[t]); 13092 } 13093 i.delete(this.selection.value.id); 13094 for (let e of i) { 13095 let n = this.reconstruction.images.get(e); 13096 n && t.push(...r.toArray(), ...this.normalized(m(n.camFromWorld)).toArray()); 13097 } 13098 } 13099 if (t.length === 0) return; 13100 let r = new oi(); 13101 r.setAttribute("position", new X(t, 3)), this.connectionContent.add(new na(r, new Wi({ 13102 color: n, 13103 transparent: !0, 13104 opacity: .8 13105 }))); 13106 } 13107 pick(e) { 13108 if (!this.reconstruction || this.pointDrawList.length + this.imageDrawList.length === 0) return; 13109 let t = this.canvas.getBoundingClientRect(), n = Math.floor(e.clientX - t.left), r = Math.floor(e.clientY - t.top), i = Math.max(1, Math.floor(t.width)), a = Math.max(1, Math.floor(t.height)); 13110 this.activeCamera.setViewOffset(i, a, n, r, 1, 1), this.renderer.setRenderTarget(this.renderTarget), this.renderer.setClearColor(0, 1), this.renderer.clear(), this.renderer.render(this.pickingScene, this.activeCamera); 13111 let o = /* @__PURE__ */ new Uint8Array(4); 13112 this.renderer.readRenderTargetPixels(this.renderTarget, 0, 0, 1, 1, o), this.renderer.setRenderTarget(null), this.renderer.setClearColor(16777215, 1), this.activeCamera.clearViewOffset(); 13113 let s = o[0] + (o[1] << 8) + (o[2] << 16); 13114 if (s > 0 && s <= this.pointDrawList.length) this.selection = { 13115 type: "point", 13116 index: this.pointDrawList[s - 1] 13117 }; 13118 else { 13119 let e = this.imageDrawList[s - this.pointDrawList.length - 1]; 13120 this.selection = e ? { 13121 type: "image", 13122 value: e 13123 } : null; 13124 } 13125 this.rebuild(), this.selection?.type === "point" ? this.onSelection({ 13126 type: "point", 13127 value: ne(this.reconstruction.points3D, this.selection.index) 13128 }) : this.onSelection(this.selection); 13129 } 13130 switchProjection() { 13131 let e = this.activeCamera, t = this.controls.target.clone(); 13132 this.activeCamera = this.settings.projection === "perspective" ? this.perspectiveCamera : this.orthographicCamera, this.activeCamera.position.copy(e.position), this.activeCamera.quaternion.copy(e.quaternion), this.activeCamera.up.copy(e.up), this.controls = this.createControls(this.activeCamera), this.controls.target.copy(t), this.controls.update(), this.resize(); 13133 } 13134 resize() { 13135 let e = this.canvas.parentElement; 13136 if (!e) return; 13137 let t = Math.max(1, e.clientWidth), n = Math.max(1, e.clientHeight); 13138 this.renderer.setSize(t, n, !1), this.perspectiveCamera.aspect = t / n, this.perspectiveCamera.updateProjectionMatrix(); 13139 let r = Math.max(.2, this.activeCamera.position.distanceTo(this.controls.target)), i = Math.tan(ln.degToRad(this.perspectiveCamera.fov) / 2) * r; 13140 this.orthographicCamera.left = -i * t / n, this.orthographicCamera.right = i * t / n, this.orthographicCamera.top = i, this.orthographicCamera.bottom = -i, this.orthographicCamera.updateProjectionMatrix(); 13141 } 13142 handleModifiedWheel(e) { 13143 !e.ctrlKey && !e.metaKey && !e.altKey || (e.preventDefault(), e.stopImmediatePropagation(), e.ctrlKey || e.metaKey ? this.updateSettings({ pointSize: Xu(this.settings.pointSize, e.deltaY, e.deltaMode, .5, 100) }) : this.updateSettings({ cameraSize: Xu(this.settings.cameraSize, e.deltaY, e.deltaMode, 1e-6, 1e3) })); 13144 } 13145}, $u = /* @__PURE__ */ new WeakMap(); 13146function ed(e, t = {}) { 13147 $u.get(e)?.dispose(), e.classList.add("colmap-viewer-host"), e.innerHTML = "\n <section class=\"colmap-viewer\" aria-label=\"COLMAP sparse reconstruction viewer\">\n <header class=\"viewer-toolbar\">\n <div class=\"viewer-brand\"><strong data-viewer=\"title\">COLMAP - 3D Web Viewer</strong><span class=\"viewer-stats\" data-viewer=\"stats\" hidden></span></div>\n <div class=\"viewer-actions\">\n <button type=\"button\" data-viewer=\"open\">Open folder</button>
13147\n <select data-viewer=\"model\" aria-label=\"Sparse model\" hidden></select>\n <button type=\"button\" data-viewer=\"reset\" disabled>Reset view</button>\n <button type=\"button\" data-viewer=\"clear\" disabled>Clear selection</button>\n </div>\n </header>\n <div class=\"viewer-controls\" aria-label=\"Render controls\">\n <label>Projection <select data-viewer=\"projection\"><option value=\"perspective\">Perspective</option><option value=\"orthographic\">Orthographic</option></select></label>\n <label>Point size <input data-viewer=\"point-size\" type=\"range\" min=\"0.5\" max=\"100\" step=\"0.5\" value=\"2\"></label>\n <label>Camera size <input data-viewer=\"camera-size\" type=\"range\" min=\"0.000001\" max=\"1\" step=\"0.0005\" value=\"0.025\"></label>\n <label>Min. track <input data-viewer=\"track\" type=\"number\" min=\"0\" max=\"100\" value=\"3\"></label>\n <label>Max. error <input data-viewer=\"error\" type=\"number\" min=\"0\" step=\"0.25\" value=\"2\"></label>\n <label class=\"viewer-check\"><input data-viewer=\"connections\" type=\"checkbox\"> Connections</label>\n </div>\n <div class=\"viewer-workspace\">\n <div class=\"viewer-stage\">\n <canvas class=\"viewer-canvas\" data-viewer=\"canvas\" aria-label=\"Interactive 3D reconstruction\"></canvas>\n <div class=\"viewer-drop\" data-viewer=\"drop\">\n <div class=\"viewer-drop-mark\" aria-hidden=\"true\">3D</div>\n <h2>Open a COLMAP reconstruction</h2>\n <p>Drop a workspace or sparse model folder here.</p>\n <p class=\"viewer-drop-detail\">Requires <code>cameras.bin</code>, <code>images.bin</code>, and <code>points3D.bin</code>. Source images are optional and never leave this browser.</p>\n <button type=\"button\" data-viewer=\"drop-open\">Choose folder</button>\n </div>\n <div class=\"viewer-status\" data-viewer=\"status\" role=\"status\" hidden></div>\n </div>\n <aside class=\"viewer-inspector\" data-viewer=\"inspector\" aria-live=\"polite\">\n <div class=\"viewer-inspector-empty\"><h2>Inspector</h2><p>Double-click a point or camera to inspect it.</p></div>\n </aside>\n </div>\n <input data-viewer=\"folder-input\" type=\"file\" multiple hidden>\n </section>", td(e, "title").textContent = t.title ?? "COLMAP - 3D Web Viewer"; 13148 let n = td(e, "canvas"), r; 13149 try { 13150 r = new Qu(n); 13151 } catch (t) { 13152 let n = `WebGL2 is unavailable: ${t instanceof Error ? t.message : String(t)}`; 13153 throw pd(e, n), Error(n, { cause: t }); 13154 } 13155 let i = td(e, "drop"), a = td(e, "status"), o = td(e, "inspector"), s = td(e, "stats"), c = td(e, "model"), l = td(e, "folder-input"); 13156 l.setAttribute("webkitdirectory", ""); 13157 let u = new AbortController(), d = { observer: null }, f = [], p = [], m = null, h = od([]), g = null, _ = null, v = null, y = !1, b = (e, t = !1) => { 13158 y || (v !== null && (window.clearTimeout(v), v = null), a.hidden = e === null, a.textContent = e ?? "", a.title = e ?? "", a.classList.toggle("is-error", t)); 13159 }, x = () => { 13160 h = od(f), g && m && ld(o, g, m, h, d); 13161 }, S = () => { 13162 d.observer?.disconnect(), d.observer = null, m = null, g = null, r.clearReconstruction(), s.textContent = "", s.hidden = !0; 13163 for (let t of e.querySelectorAll("[data-viewer=\"reset\"], [data-viewer=\"clear\"]")) t.disabled = !0; 13164 o.innerHTML = "<div class=\"viewer-inspector-empty\"><h2>Inspector</h2><p>Double-click a point or camera to inspect it.</p></div>"; 13165 }, C = (t) => { 13166 if (y) throw Error("Cannot load a disposed COLMAP viewer"); 13167 r.setReconstruction(t), m = t, i.hidden = !0, b(null), s.textContent = `${t.images.size.toLocaleString()} images / ${r.visiblePointCount.toLocaleString()} visible points`, s.hidden = !1; 13168 for (let t of e.querySelectorAll("[data-viewer=\"reset\"], [data-viewer=\"clear\"]")) t.disabled = !1; 13169 g = null, o.innerHTML = `<div class="viewer-inspector-empty"><h2>Model loaded</h2><p>Double-click a point or camera to inspect it.</p><dl><dt>
13169Format</dt><dd>${t.modernRigFormat ? "Binary with rigs" : "Legacy binary"}</dd><dt>Images</dt><dd>${t.images.size.toLocaleString()}</dd><dt>Points</dt><dd>${te(t.points3D).toLocaleString()}</dd></dl></div>`, x(); 13170 }, w = (e, n) => { 13171 let r = n instanceof Error ? n : Error(String(n)); 13172 return S(), i.hidden = !1, console.error(`[COLMAP viewer] Failed to ${e}`, r), b(`Failed to ${e}: ${r.name}: ${r.message || "Unknown error"}`, !0), t.onError?.(r), r; 13173 }, T = async (e) => { 13174 _?.abort(); 13175 let t = new AbortController(); 13176 _ = t, S(), b("Parsing reconstruction..."); 13177 let n = "parse model"; 13178 try { 13179 let r = await rd(e.files, t.signal); 13180 if (t.signal.aborted || _ !== t) return; 13181 n = "build Three.js scene", C(r); 13182 } catch (e) { 13183 if (t.signal.aborted || _ !== t || e instanceof DOMException && e.name === "AbortError") return; 13184 throw w(n, e); 13185 } finally { 13186 _ === t && (_ = null); 13187 } 13188 }, E = async (e) => { 13189 if (e.length === 0) return; 13190 let n = O(e); 13191 if (n.length === 0 && m) { 13192 f.push(...e), x(), b(`Added ${e.length.toLocaleString()} image files`), v = window.setTimeout(() => b(null), 1800); 13193 return; 13194 } 13195 if (n.length === 0) { 13196 let e = /* @__PURE__ */ Error("No binary sparse model was found in that folder"); 13197 throw b(e.message, !0), t.onError?.(e), e; 13198 } 13199 f = e, p = n, x(), c.replaceChildren(...p.map((e, t) => { 13200 let n = document.createElement("option"); 13201 return n.value = String(t), n.textContent = e.path === "." ? "Sparse model" : e.path, n; 13202 })), c.hidden = p.length < 2, await T(p[0]); 13203 }, D = () => l.click(), k = { signal: u.signal }; 13204 td(e, "open").addEventListener("click", D, k), td(e, "drop-open").addEventListener("click", D, k), l.addEventListener("change", () => { 13205 let e = [...l.files ?? []].map((e) => ({ 13206 path: e.webkitRelativePath || e.name, 13207 file: e 13208 })); 13209 l.value = "", E(e).catch(() => void 0); 13210 }, k), c.addEventListener("change", () => { 13211 let e = p[Number(c.value)]; 13212 e && T(e).catch(() => void 0); 13213 }, k); 13214 for (let t of ["dragenter", "dragover"]) e.addEventListener(t, (e) => { 13215 e.preventDefault(), i.hidden = !1, i.classList.add("is-dragging"); 13216 }, k); 13217 e.addEventListener("dragleave", (t) => { 13218 e.contains(t.relatedTarget) || (i.classList.remove("is-dragging"), m && (i.hidden = !0)); 13219 }, k), e.addEventListener("drop", (e) => { 13220 e.preventDefault(), i.classList.remove("is-dragging"), id(e.dataTransfer).then(E).then(() => { 13221 m && (i.hidden = !0); 13222 }).catch(() => void 0); 13223 }, k), r.onSelection = (e) => { 13224 g = e, e && m ? ld(o, e, m, h, d) : o.innerHTML = "<div class=\"viewer-inspector-empty\"><h2>Inspector</h2><p>Double-click a point or camera to inspect it.</p></div>"; 13225 }, r.onError = (e) => { 13226 console.error("[COLMAP viewer] WebGL render failed", e), b(`WebGL render failed: ${e.name}: ${e.message || "Unknown error"}`, !0), t.onError?.(e); 13227 }, r.onContextChange = (e) => { 13228 b(e ? "WebGL context lost. Waiting for the browser to restore it..." : null, e); 13229 }, r.onSettingsChange = (t) => { 13230 td(e, "point-size").value = String(t.pointSize), td(e, "camera-size").value = String(t.cameraSize); 13231 }, td(e, "reset").addEventListener("click", () => r.resetView(), k), td(e, "clear").addEventListener("click", () => r.clearSelection(), k), nd(e, r, u.signal); 13232 let A = { 13233 viewer: r, 13234 async load(e, t = []) { 13235 if (y) throw Error("Cannot load a disposed COLMAP viewer"); 13236 if (Array.isArray(e)) { 13237 await E([...e]); 13238 return; 13239 } 13240 _?.abort(); 13241 let n = new AbortController(); 13242 _ = n, S(), f = [...t], p = [], c.replaceChildren(), c.hidden = !0, x(), b("Building Three.js scene..."); 13243 try { 13244 C(e); 13245 } catch (e) { 13246 throw w("build Three.js scene", e); 13247 } finally { 13248 _ === n && (_ = null); 13249 } 13250 }, 13251 clear() { 13252 y || (_?.abort(), _ = null, f = [], p = [], h = od([]), c.replaceChildren(), c.hidden = !0, S(), i.hidden = !1, b(null)); 13253 }, 13254 dispose() { 13255 y || (y = !0, _?.abort(), v !== null && window.clearTimeout(v), d.observer?.disconnect(), u.abort(), r.dispose(), e.replaceChildren(), e.classList.remove("colmap-viewer-host"), $u.get(e) === A && $u.delete(e)); 13256 } 13257 }; 13258 return $u.set(e, A), A; 13259} 13260function td(e, t) { 13261 let n = `[data-viewer="${t}"]`, r = e.querySelector(n); 13262 if (!r) throw Error(`Missing viewer element ${n}`); 13263 return r; 13264}
13265function nd(e, t, n) { 13266 let r = { signal: n }; 13267 td(e, "projection").addEventListener("change", (e) => t.updateSettings({ projection: e.currentTarget.value }), r), td(e, "point-size").addEventListener("input", (e) => t.updateSettings({ pointSize: Number(e.currentTarget.value) }), r), td(e, "camera-size").addEventListener("input", (e) => t.updateSettings({ cameraSize: Number(e.currentTarget.value) }), r), td(e, "track").addEventListener("change", (e) => t.updateSettings({ minTrackLength: Math.max(0, Number(e.currentTarget.value)) }), r), td(e, "error").addEventListener("change", (e) => t.updateSettings({ maxError: Math.max(0, Number(e.currentTarget.value)) }), r), td(e, "connections").addEventListener("change", (e) => t.updateSettings({ showConnections: e.currentTarget.checked }), r); 13268} 13269async function rd(e, t) { 13270 let n = new Worker(new URL( 13271 /* @vite-ignore */ 13272 "" + new URL("assets/parser.worker-sW_eqDEb.js", import.meta.url).href, 13273 "" + import.meta.url 13274 ), { type: "module" }); 13275 return await new Promise((r, i) => { 13276 let a = !1, o = (e) => { 13277 a || (a = !0, t.removeEventListener("abort", s), n.terminate(), e()); 13278 }, s = () => o(() => i(new DOMException("Model load superseded", "AbortError"))); 13279 if (t.aborted) { 13280 s(); 13281 return; 13282 } 13283 t.addEventListener("abort", s, { once: !0 }), n.onmessage = (e) => { 13284 e.data.ok && e.data.reconstruction ? o(() => r(e.data.reconstruction)) : o(() => i(Error(e.data.error ?? "Could not parse reconstruction"))); 13285 }, n.onerror = (e) => o(() => i(Error(e.message || "Parser worker failed"))), n.onmessageerror = () => o(() => i(/* @__PURE__ */ Error("Parser worker returned an unreadable result"))); 13286 try { 13287 n.postMessage(e); 13288 } catch (e) { 13289 o(() => i(e instanceof Error ? e : Error(String(e)))); 13290 } 13291 }); 13292} 13293async function id(e) { 13294 if (!e) return []; 13295 let t = [...e.items].map((e) => e.webkitGetAsEntry()).filter((e) => e !== null); 13296 return t.length > 0 ? (await Promise.all(t.map((e) => ad(e, e.name)))).flat() : [...e.files].map((e) => ({ 13297 path: e.name, 13298 file: e 13299 })); 13300} 13301async function ad(e, t) { 13302 if (e.isFile) return [{ 13303 path: t, 13304 file: await new Promise((t, n) => e.file(t, n)) 13305 }]; 13306 if (!e.isDirectory) return []; 13307 let n = e.createReader(), r = []; 13308 for (;;) { 13309 let e = await new Promise((e, t) => n.readEntries(e, t)); 13310 if (e.length === 0) break; 13311 r.push(...e); 13312 } 13313 return (await Promise.all(r.map((e) => ad(e, `${t}/${e.name}`)))).flat(); 13314} 13315function od(e) { 13316 let t = new Map(e.map((e) => [D(e.path), e.file])), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(); 13317 for (let [e, i] of t) for (let t = 0; t < e.length;) { 13318 let a = e.slice(t); 13319 (!r.has(a) || e.length < r.get(a)) && (n.set(a, i), r.set(a, e.length)); 13320 let o = e.indexOf("/", t); 13321 if (o < 0) break; 13322 t = o + 1; 13323 } 13324 return { 13325 exact: t, 13326 suffix: n 13327 }; 13328} 13329function sd(e, t) { 13330 let n = D(t); 13331 return e.exact.get(n) ?? e.suffix.get(n) ?? null; 13332} 13333function cd(e, t) { 13334 let n = document.createElement("section"), r = document.createElement("h2"); 13335 r.textContent = e; 13336 let i = document.createElement("dl"); 13337 for (let [e, n] of t) { 13338 let t = document.createElement("dt"); 13339 t.textContent = e; 13340 let r = document.createElement("dd"); 13341 r.textContent = n, i.append(t, r); 13342 } 13343 return n.append(r, i), n; 13344} 13345function ld(t, n, r, i, a) { 13346 if (a.observer?.disconnect(), a.observer = null, t.replaceChildren(), n.type === "image") { 13347 let a = n.value, o = r.cameras.get(a.cameraId), s = 0; 13348 for (let e of a.points2D.point3DIds) e !== 18446744073709551615n && ++s; 13349 let c = m(a.camFromWorld); 13350 t.append(cd(`Image ${a.id}`, [ 13351 ["Image", a.name], 13352 ["Camera model", e[o.modelId] ?? `Unknown (${o.modelId})`], 13353 ["Dimensions", `${o.width} x ${o.height}`], 13354 ["Frame / rig", `${a.frameId} / ${a.rigId}`], 13355 ["Observations", `${s.toLocaleString()} / ${A(a).toLocaleString()} triangulated`], 13356 ["Center", c.map((e) => e.toFixed(6)).join(", ")], 13357 ["Pose (qw,qx,qy,qz | tx,ty,tz)", `${a.camFromWorld.rotation.map((e) => e.toFixed(6)).join(", ")} | ${a.camFromWorld.translation.map((e) => e.toFixed(6)).join(", ")}`] 13358 ])); 13359 let l = sd(i, a.name), u = document.createElement("figure"); 13360 if (u.className = "viewer-image", l) { 13361 let e = document.createElement("canvas");
13362 u.append(e), ud(e, l, a, o.width, o.height).catch(() => fd(u, "The browser could not decode this image.")); 13363 } else fd(u, "Source image unavailable. Drop the images folder to display keypoints."); 13364 t.append(u); 13365 } else { 13366 let e = n.value; 13367 t.append(cd(`Point ${e.id}`, [ 13368 ["Position", e.xyz.map((e) => e.toFixed(8)).join(", ")], 13369 ["Color", e.color.join(", ")], 13370 ["Error", `${e.error.toFixed(4)} px`], 13371 ["Track length", e.track.length.toLocaleString()] 13372 ])); 13373 let o = document.createElement("h3"); 13374 o.textContent = "Observations"; 13375 let s = document.createElement("div"); 13376 s.className = "viewer-observations"; 13377 let c = [...e.track].sort((e, t) => (r.images.get(e.imageId)?.name ?? "").localeCompare(r.images.get(t.imageId)?.name ?? "")); 13378 for (let n of c) { 13379 let o = r.images.get(n.imageId); 13380 if (!o) continue; 13381 let c = ee(o, n.point2DIdx), u = r.cameras.get(o.cameraId); 13382 if (!c || !u) continue; 13383 let d = l(u, p(o.camFromWorld, e.xyz)), f = document.createElement("article"); 13384 f.className = "viewer-observation"; 13385 let m = document.createElement("div"); 13386 m.className = "viewer-observation-label", m.textContent = o.name; 13387 let h = document.createElement("small"); 13388 h.textContent = `Image ${o.id}`, m.append(h), f.append(m); 13389 let g = sd(i, o.name); 13390 if (g) { 13391 let e = document.createElement("canvas"); 13392 if (e.width = 280, e.height = 180, f.prepend(e), d) { 13393 let e = Math.hypot(c.xy[0] - d[0], c.xy[1] - d[1]); 13394 h.textContent = `Image ${o.id} / ${e.toFixed(3)} px`; 13395 } 13396 let n = () => { 13397 dd(e, g, c.xy, d).catch(() => { 13398 e.replaceWith(document.createTextNode("Image unavailable")); 13399 }); 13400 }; 13401 "IntersectionObserver" in window ? (a.observer ??= new IntersectionObserver((e, t) => { 13402 for (let n of e) n.isIntersecting && (t.unobserve(n.target), n.target.dispatchEvent(new Event("viewer-load-image"))); 13403 }, { 13404 root: t, 13405 rootMargin: "180px" 13406 }), e.addEventListener("viewer-load-image", n, { once: !0 }), a.observer.observe(e)) : n(); 13407 } else { 13408 let e = document.createElement("div"); 13409 e.className = "viewer-observation-missing", e.textContent = "Image unavailable", f.prepend(e); 13410 } 13411 s.append(f); 13412 } 13413 t.append(o, s); 13414 } 13415} 13416async function ud(e, t, n, r, i) { 13417 let a = await createImageBitmap(t), o = Math.min(1, 1e3 / Math.max(a.width, a.height)); 13418 e.width = Math.max(1, Math.round(a.width * o)), e.height = Math.max(1, Math.round(a.height * o)); 13419 let s = e.getContext("2d"); 13420 s.drawImage(a, 0, 0, e.width, e.height), a.close(); 13421 let c = e.width / r, l = e.height / i; 13422 for (let e = 0; e < A(n); ++e) { 13423 let t = ee(n, e); 13424 s.fillStyle = t.point3DId === null ? "#ef3028" : "#ff00ff", s.beginPath(), s.arc(t.xy[0] * c, t.xy[1] * l, 1.6, 0, Math.PI * 2), s.fill(); 13425 } 13426} 13427async function dd(e, t, n, r) { 13428 let i = await createImageBitmap(t), a = r ? (n[0] + r[0]) / 2 : n[0], o = r ? (n[1] + r[1]) / 2 : n[1], s = r ? Math.hypot(n[0] - r[0], n[1] - r[1]) : 0, c = Math.min(Math.max(120, s * 2 + 50), Math.min(i.width, i.height)), l = Math.max(0, Math.min(i.width - c, a - c / 2)), u = Math.max(0, Math.min(i.height - c, o - c / 2)), d = e.getContext("2d"); 13429 d.drawImage(i, l, u, c, c, 0, 0, e.width, e.height), i.close(); 13430 let f = (t) => [(t[0] - l) / c * e.width, (t[1] - u) / c * e.height], [p, m] = f(n); 13431 if (d.strokeStyle = "#00e13a", d.lineWidth = 3, d.beginPath(), d.moveTo(p - 9, m - 9), d.lineTo(p + 9, m + 9), d.moveTo(p - 9, m + 9), d.lineTo(p + 9, m - 9), d.stroke(), r) { 13432 let [e, t] = f(r); 13433 d.strokeStyle = "#ef3028", d.lineWidth = 2; 13434 for (let n of [ 13435 4, 13436 12, 13437 30 13438 ]) d.beginPath(), d.arc(e, t, n, 0, Math.PI * 2), d.stroke(); 13439 } 13440} 13441function fd(e, t) { 13442 e.replaceChildren(); 13443 let n = document.createElement("p"); 13444 n.className = "viewer-image-missing", n.textContent = t, e.append(n); 13445} 13446function pd(e, t) { 13447 e.replaceChildren(); 13448 let n = document.createElement("div"); 13449 n.className = "viewer-fatal", n.setAttribute("role", "alert"), n.textContent = t, e.append(n); 13450} 13451//#endregion 13452export { k as i, Qu as n, O as r, ed as t };
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.