@ridp/threejs 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ImageLoader-DXx88iwh.js → ImageLoader-Br_nvMOg.js} +1 -1
- package/dist/{ImageLoader-DzG6sgbB.cjs → ImageLoader-DL32KyTh.cjs} +1 -1
- package/dist/{PredictiveLoader--_3bEnce.js → PredictiveLoader-CZfMSjv-.js} +40 -47
- package/dist/PredictiveLoader-DDxh7dDg.cjs +2 -0
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +2 -2
- package/dist/threejs.cjs +1 -1
- package/dist/threejs.js +5 -5
- package/dist/{useBatchGLTFLoader-Dg-xau9i.js → useBatchGLTFLoader-B5EUagWI.js} +1 -1
- package/dist/{useBatchGLTFLoader-CDNvTMtt.cjs → useBatchGLTFLoader-BjAvIpyB.cjs} +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +2 -2
- package/package.json +1 -1
- package/dist/PredictiveLoader-CpRi-ULa.cjs +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as pn } from "./PredictiveLoader
|
|
1
|
+
import { t as pn } from "./PredictiveLoader-CZfMSjv-.js";
|
|
2
2
|
import { DataTextureLoader as fn, HalfFloatType as Ue, FloatType as Be, RGBAFormat as jn, LinearSRGBColorSpace as tn, RedFormat as et, NoColorSpace as nt, LinearFilter as qe, DataUtils as Fe, EquirectangularReflectionMapping as tt } from "three";
|
|
3
3
|
/*!
|
|
4
4
|
fflate - fast JavaScript compression/decompression
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const sn=require("./PredictiveLoader-
|
|
1
|
+
"use strict";const sn=require("./PredictiveLoader-DDxh7dDg.cjs"),F=require("three");/*!
|
|
2
2
|
fflate - fast JavaScript compression/decompression
|
|
3
3
|
<https://101arrowz.github.io/fflate>
|
|
4
4
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
@@ -71,7 +71,7 @@ class ss extends De {
|
|
|
71
71
|
return super.copy(e, t), this.element = e.element.cloneNode(!0), this;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
class
|
|
74
|
+
class fn extends ss {
|
|
75
75
|
/**
|
|
76
76
|
* Constructs a new CSS3D sprite object.
|
|
77
77
|
*
|
|
@@ -85,7 +85,7 @@ class un extends ss {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
const k = new J(), ns = new J();
|
|
88
|
-
class
|
|
88
|
+
class pn {
|
|
89
89
|
/**
|
|
90
90
|
* Constructs a new CSS3D renderer.
|
|
91
91
|
*
|
|
@@ -617,35 +617,35 @@ class ys extends rt {
|
|
|
617
617
|
super(e, t), this.screenSpacePanning = !1, this.mouseButtons = { LEFT: U.PAN, MIDDLE: U.DOLLY, RIGHT: U.ROTATE }, this.touches = { ONE: z.PAN, TWO: z.DOLLY_ROTATE };
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
-
function
|
|
620
|
+
function mn(r) {
|
|
621
621
|
return new ft(r);
|
|
622
622
|
}
|
|
623
|
-
function
|
|
623
|
+
function gn(r = 150, ...e) {
|
|
624
624
|
return new pt(r, r / 10, ...e);
|
|
625
625
|
}
|
|
626
|
-
function
|
|
626
|
+
function yn(r) {
|
|
627
627
|
return new mt(r, 16776960);
|
|
628
628
|
}
|
|
629
|
-
function
|
|
629
|
+
function _n(r, e) {
|
|
630
630
|
return new rt(r, e);
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function Tn(r, e) {
|
|
633
633
|
return new ys(r, e);
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function wn() {
|
|
636
636
|
const r = new gt(), e = new C(0, 0);
|
|
637
637
|
return {
|
|
638
638
|
raycaster: r,
|
|
639
639
|
pointer: e
|
|
640
640
|
};
|
|
641
641
|
}
|
|
642
|
-
function
|
|
642
|
+
function bn(r = 10) {
|
|
643
643
|
return new yt(r);
|
|
644
644
|
}
|
|
645
|
-
function
|
|
645
|
+
function En(r = new L(1, 1, 1), e = new L(10, 10, 10), t = 5, s = 16776960) {
|
|
646
646
|
return r.normalize(), new _t(r, e, t, s);
|
|
647
647
|
}
|
|
648
|
-
function
|
|
648
|
+
function xn() {
|
|
649
649
|
const r = new ie();
|
|
650
650
|
return r.dom.style.cssText = "position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000", r;
|
|
651
651
|
}
|
|
@@ -2644,7 +2644,7 @@ function Ve(r) {
|
|
|
2644
2644
|
r.dispose();
|
|
2645
2645
|
}
|
|
2646
2646
|
const be = {};
|
|
2647
|
-
async function
|
|
2647
|
+
async function An(r, e = 50) {
|
|
2648
2648
|
const t = {
|
|
2649
2649
|
type: r.type,
|
|
2650
2650
|
name: r.name,
|
|
@@ -2680,7 +2680,7 @@ async function En(r, e = 50) {
|
|
|
2680
2680
|
}
|
|
2681
2681
|
return t;
|
|
2682
2682
|
}
|
|
2683
|
-
function
|
|
2683
|
+
function Rn(r) {
|
|
2684
2684
|
const e = {
|
|
2685
2685
|
type: r.type,
|
|
2686
2686
|
name: r.name,
|
|
@@ -2758,7 +2758,7 @@ async function sn(r, e = 50) {
|
|
|
2758
2758
|
}
|
|
2759
2759
|
return s;
|
|
2760
2760
|
}
|
|
2761
|
-
function
|
|
2761
|
+
function Sn(r) {
|
|
2762
2762
|
const e = [];
|
|
2763
2763
|
let t;
|
|
2764
2764
|
switch (r.type) {
|
|
@@ -3321,7 +3321,7 @@ function rn(r) {
|
|
|
3321
3321
|
}
|
|
3322
3322
|
return e.uuid = r.uuid, e;
|
|
3323
3323
|
}
|
|
3324
|
-
class
|
|
3324
|
+
class Mn {
|
|
3325
3325
|
constructor() {
|
|
3326
3326
|
this.geometries = [], this.materials = [], this.hierarchy = [], this.geometryMap = /* @__PURE__ */ new Map(), this.materialMap = /* @__PURE__ */ new Map();
|
|
3327
3327
|
}
|
|
@@ -3355,10 +3355,11 @@ class Rn {
|
|
|
3355
3355
|
return this.buildCurrent();
|
|
3356
3356
|
}
|
|
3357
3357
|
}
|
|
3358
|
+
const an = "/assets/gltfParser.worker-Bqz8BBJx.js", cn = "/assets/gltfParserOptimized.worker-DfipxPjm.js";
|
|
3358
3359
|
let q;
|
|
3359
3360
|
const xe = "/draco/";
|
|
3360
3361
|
let Z, $, Ze = 0;
|
|
3361
|
-
const B = /* @__PURE__ */ new Map(),
|
|
3362
|
+
const B = /* @__PURE__ */ new Map(), ln = () => {
|
|
3362
3363
|
const r = new ws(), e = new _s();
|
|
3363
3364
|
e.setDecoderPath(xe), r.setDRACOLoader(e);
|
|
3364
3365
|
function t(f, g, y, p) {
|
|
@@ -3478,11 +3479,7 @@ const B = /* @__PURE__ */ new Map(), an = () => {
|
|
|
3478
3479
|
}
|
|
3479
3480
|
return (await m(f)).scene;
|
|
3480
3481
|
}
|
|
3481
|
-
const a = () => typeof window > "u" || typeof Worker > "u" ? null : (Z || (Z = new Worker(
|
|
3482
|
-
/* @vite-ignore */
|
|
3483
|
-
"/assets/gltfParser.worker-Bqz8BBJx.js",
|
|
3484
|
-
import.meta.url
|
|
3485
|
-
), { type: "module" }), Z.onmessage = (f) => {
|
|
3482
|
+
const a = () => typeof window > "u" || typeof Worker > "u" ? null : (Z || (Z = new Worker(an, { type: "module" }), Z.onmessage = (f) => {
|
|
3486
3483
|
const { id: g, data: y, error: p } = f.data || {};
|
|
3487
3484
|
if (!g || !B.has(g)) return;
|
|
3488
3485
|
const { resolve: d, reject: _ } = B.get(g);
|
|
@@ -3496,11 +3493,7 @@ const B = /* @__PURE__ */ new Map(), an = () => {
|
|
|
3496
3493
|
return null;
|
|
3497
3494
|
if (!$)
|
|
3498
3495
|
try {
|
|
3499
|
-
$ = new Worker(
|
|
3500
|
-
/* @vite-ignore */
|
|
3501
|
-
"/assets/gltfParserOptimized.worker-DfipxPjm.js",
|
|
3502
|
-
import.meta.url
|
|
3503
|
-
), { type: "module" }), $.onmessage = (f) => {
|
|
3496
|
+
$ = new Worker(cn, { type: "module" }), $.onmessage = (f) => {
|
|
3504
3497
|
const { id: g, data: y, error: p, type: d } = f.data || {};
|
|
3505
3498
|
if (!g || !B.has(g) || d === "progress")
|
|
3506
3499
|
return;
|
|
@@ -3556,13 +3549,13 @@ const B = /* @__PURE__ */ new Map(), an = () => {
|
|
|
3556
3549
|
resetCacheStats: () => V.reset()
|
|
3557
3550
|
};
|
|
3558
3551
|
};
|
|
3559
|
-
class
|
|
3552
|
+
class hn {
|
|
3560
3553
|
constructor(e = {}) {
|
|
3561
3554
|
this.options = {
|
|
3562
3555
|
maxPreloadCount: e.maxPreloadCount || 5,
|
|
3563
3556
|
preloadDelay: e.preloadDelay || 1e3,
|
|
3564
3557
|
enableLearning: e.enableLearning !== !1
|
|
3565
|
-
}, this.loadHistory = /* @__PURE__ */ new Map(), this.loadSequence = [], this.associations = /* @__PURE__ */ new Map(), this.preloadQueue = /* @__PURE__ */ new Set(), this.isPreloading = !1, this.loader = null, this.getLoader = () => (this.loader || (this.loader =
|
|
3558
|
+
}, this.loadHistory = /* @__PURE__ */ new Map(), this.loadSequence = [], this.associations = /* @__PURE__ */ new Map(), this.preloadQueue = /* @__PURE__ */ new Set(), this.isPreloading = !1, this.loader = null, this.getLoader = () => (this.loader || (this.loader = ln()), this.loader);
|
|
3566
3559
|
}
|
|
3567
3560
|
/**
|
|
3568
3561
|
* 记录模型加载
|
|
@@ -3705,34 +3698,34 @@ class cn {
|
|
|
3705
3698
|
});
|
|
3706
3699
|
}
|
|
3707
3700
|
}
|
|
3708
|
-
const
|
|
3701
|
+
const Ln = new hn();
|
|
3709
3702
|
export {
|
|
3710
3703
|
nn as C,
|
|
3711
3704
|
Ee as E,
|
|
3712
3705
|
qe as I,
|
|
3713
3706
|
oe as M,
|
|
3714
|
-
|
|
3707
|
+
hn as P,
|
|
3715
3708
|
fe as R,
|
|
3716
3709
|
ie as S,
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3710
|
+
gn as a,
|
|
3711
|
+
yn as b,
|
|
3712
|
+
mn as c,
|
|
3713
|
+
_n as d,
|
|
3714
|
+
Tn as e,
|
|
3715
|
+
wn as f,
|
|
3716
|
+
bn as g,
|
|
3717
|
+
En as h,
|
|
3718
|
+
xn as i,
|
|
3726
3719
|
tn as j,
|
|
3727
|
-
|
|
3720
|
+
Rn as k,
|
|
3728
3721
|
sn as l,
|
|
3729
|
-
|
|
3722
|
+
Sn as m,
|
|
3730
3723
|
V as n,
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3724
|
+
An as o,
|
|
3725
|
+
Ln as p,
|
|
3726
|
+
Mn as q,
|
|
3734
3727
|
lt as r,
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3728
|
+
pn as s,
|
|
3729
|
+
fn as t,
|
|
3730
|
+
ln as u
|
|
3738
3731
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const u=require("three"),ve=require("dexie");function He(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const S=He(u);var V=function(){var r=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(d){d.preventDefault(),s(++r%e.children.length)},!1);function t(d){return e.appendChild(d.dom),d}function s(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===d?"block":"none";r=d}var n=(performance||Date).now(),i=n,o=0,c=t(new V.Panel("FPS","#0ff","#002")),a=t(new V.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var l=t(new V.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:e,addPanel:t,showPanel:s,begin:function(){n=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(a.update(d-n,200),d>=i+1e3&&(c.update(o*1e3/(d-i),100),i=d,o=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){n=this.end()},domElement:e,setMode:s}};V.Panel=function(r,e,t){var s=1/0,n=0,i=Math.round,o=i(window.devicePixelRatio||1),c=80*o,a=48*o,l=3*o,d=2*o,h=3*o,g=15*o,p=74*o,y=30*o,_=document.createElement("canvas");_.width=c,_.height=a,_.style.cssText="width:80px;height:48px";var m=_.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,c,a),m.fillStyle=e,m.fillText(r,l,d),m.fillRect(h,g,p,y),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(h,g,p,y),{dom:_,update:function(f,T){s=Math.min(s,f),n=Math.max(n,f),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,c,g),m.fillStyle=e,m.fillText(i(f)+" "+r+" ("+i(s)+"-"+i(n)+")",l,d),m.drawImage(_,h+o,g,p-o,y,h,g,p-o,y),m.fillRect(h+p-o,g,o,y),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(h+p-o,g,o,i((1-f/T)*y))}}};const me=new u.Vector3,Fe=new u.Quaternion,ge=new u.Vector3;class Ue extends u.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}}class je extends Ue{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}}const I=new u.Matrix4,Ge=new u.Matrix4;class Be{constructor(e={}){const t=this;let s,n,i,o;const c={camera:{style:""},objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",a.appendChild(l);const d=document.createElement("div");d.style.transformStyle="preserve-3d",l.appendChild(d),this.getSize=function(){return{width:s,height:n}},this.render=function(m,f){const T=f.projectionMatrix.elements[5]*o;f.view&&f.view.enabled?(l.style.transform=`translate( ${-f.view.offsetX*(s/f.view.width)}px, ${-f.view.offsetY*(n/f.view.height)}px )`,l.style.transform+=`scale( ${f.view.fullWidth/f.view.width}, ${f.view.fullHeight/f.view.height} )`):l.style.transform="",m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),f.parent===null&&f.matrixWorldAutoUpdate===!0&&f.updateMatrixWorld();let w,b;f.isOrthographicCamera&&(w=-(f.right+f.left)/2,b=(f.top+f.bottom)/2);const M=f.view&&f.view.enabled?f.view.height/f.view.fullHeight:1,A=f.isOrthographicCamera?`scale( ${M} )scale(`+T+")translate("+h(w)+"px,"+h(b)+"px)"+g(f.matrixWorldInverse):`scale( ${M} )translateZ(`+T+"px)"+g(f.matrixWorldInverse),R=(f.isPerspectiveCamera?"perspective("+T+"px) ":"")+A+"translate("+i+"px,"+o+"px)";c.camera.style!==R&&(d.style.transform=R,c.camera.style=R),_(m,m,f)},this.setSize=function(m,f){s=m,n=f,i=s/2,o=n/2,a.style.width=m+"px",a.style.height=f+"px",l.style.width=m+"px",l.style.height=f+"px",d.style.width=m+"px",d.style.height=f+"px"};function h(m){return Math.abs(m)<1e-10?0:m}function g(m){const f=m.elements;return"matrix3d("+h(f[0])+","+h(-f[1])+","+h(f[2])+","+h(f[3])+","+h(f[4])+","+h(-f[5])+","+h(f[6])+","+h(f[7])+","+h(f[8])+","+h(-f[9])+","+h(f[10])+","+h(f[11])+","+h(f[12])+","+h(-f[13])+","+h(f[14])+","+h(f[15])+")"}function p(m){const f=m.elements;return"translate(-50%,-50%)"+("matrix3d("+h(f[0])+","+h(f[1])+","+h(f[2])+","+h(f[3])+","+h(-f[4])+","+h(-f[5])+","+h(-f[6])+","+h(-f[7])+","+h(f[8])+","+h(f[9])+","+h(f[10])+","+h(f[11])+","+h(f[12])+","+h(f[13])+","+h(f[14])+","+h(f[15])+")")}function y(m){m.isCSS3DObject&&(m.element.style.display="none");for(let f=0,T=m.children.length;f<T;f++)y(m.children[f])}function _(m,f,T,w){if(m.visible===!1){y(m);return}if(m.isCSS3DObject){const b=m.layers.test(T.layers)===!0,M=m.element;if(M.style.display=b===!0?"":"none",b===!0){m.onBeforeRender(t,f,T);let A;m.isCSS3DSprite?(I.copy(T.matrixWorldInverse),I.transpose(),m.rotation2D!==0&&I.multiply(Ge.makeRotationZ(m.rotation2D)),m.matrixWorld.decompose(me,Fe,ge),I.setPosition(me),I.scale(ge),I.elements[3]=0,I.elements[7]=0,I.elements[11]=0,I.elements[15]=1,A=p(I)):A=p(m.matrixWorld);const L=c.objects.get(m);if(L===void 0||L.style!==A){M.style.transform=A;const R={style:A};c.objects.set(m,R)}M.parentNode!==d&&d.appendChild(M),m.onAfterRender(t,f,T)}}for(let b=0,M=m.children.length;b<M;b++)_(m.children[b],f,T)}}}const ye={type:"change"},de={type:"start"},Ae={type:"end"},Z=new u.Ray,_e=new u.Plane,ze=Math.cos(70*u.MathUtils.DEG2RAD),P=new u.Vector3,D=2*Math.PI,x={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},se=1e-6;class Le extends u.Controls{constructor(e,t=null){super(e,t),this.state=x.NONE,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,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={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new u.Vector3,this._lastQuaternion=new u.Quaternion,this._lastTargetPosition=new u.Vector3,this._quat=new u.Quaternion().setFromUnitVectors(e.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new u.Spherical,this._sphericalDelta=new u.Spherical,this._scale=1,this._panOffset=new u.Vector3,this._rotateStart=new u.Vector2,this._rotateEnd=new u.Vector2,this._rotateDelta=new u.Vector2,this._panStart=new u.Vector2,this._panEnd=new u.Vector2,this._panDelta=new u.Vector2,this._dollyStart=new u.Vector2,this._dollyEnd=new u.Vector2,this._dollyDelta=new u.Vector2,this._dollyDirection=new u.Vector3,this._mouse=new u.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ve.bind(this),this._onPointerDown=Ke.bind(this),this._onPointerUp=We.bind(this),this._onContextMenu=Je.bind(this),this._onMouseWheel=qe.bind(this),this._onKeyDown=Ze.bind(this),this._onTouchStart=$e.bind(this),this._onTouchMove=Qe.bind(this),this._onMouseDown=Xe.bind(this),this._onMouseMove=Ye.bind(this),this._interceptControlDown=et.bind(this),this._interceptControlUp=tt.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){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,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.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="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ye),this.update(),this.state=x.NONE}update(e=null){const t=this.object.position;P.copy(t).sub(this.target),P.applyQuaternion(this._quat),this._spherical.setFromVector3(P),this.autoRotate&&this.state===x.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);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=D:s>Math.PI&&(s-=D),n<-Math.PI?n+=D:n>Math.PI&&(n-=D),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,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);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(P.setFromSpherical(this._spherical),P.applyQuaternion(this._quatInverse),t.copy(this.target).add(P),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){let o=null;if(this.object.isPerspectiveCamera){const c=P.length();o=this._clampDistance(c*this._scale);const a=c-o;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),i=!!a}else if(this.object.isOrthographicCamera){const c=new u.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object);const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=a!==this.object.zoom;const l=new u.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(c),this.object.updateMatrixWorld(),o=P.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Z.origin.copy(this.object.position),Z.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Z.direction))<ze?this.object.lookAt(this.target):(_e.setFromNormalAndCoplanarPoint(this.object.up,this.target),Z.intersectPlane(_e,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>se||8*(1-this._lastQuaternion.dot(this.object.quaternion))>se||this._lastTargetPosition.distanceToSquared(this.target)>se?(this.dispatchEvent(ye),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?D/60*this.autoRotateSpeed*e:D/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){P.setFromMatrixColumn(t,0),P.multiplyScalar(-e),this._panOffset.add(P)}_panUp(e,t){this.screenSpacePanning===!0?P.setFromMatrixColumn(t,1):(P.setFromMatrixColumn(t,0),P.crossVectors(this.object.up,P)),P.multiplyScalar(e),this._panOffset.add(P)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;P.copy(n).sub(this.target);let i=P.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){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)}_dollyIn(e){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)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,c=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/c)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(D*this._rotateDelta.x/t.clientHeight),this._rotateUp(D*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){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()}_handleMouseMovePan(e){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()}_handleMouseWheel(e){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()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(D*this._rotateDelta.x/t.clientHeight),this._rotateUp(D*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,c=(e.pageY+t.y)*.5;this._updateZoomParameters(o,c)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new u.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Ke(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function Ve(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function We(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Ae),this.state=x.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Xe(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case u.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=x.DOLLY;break;case u.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=x.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=x.ROTATE}break;case u.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=x.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=x.PAN}break;default:this.state=x.NONE}this.state!==x.NONE&&this.dispatchEvent(de)}function Ye(r){switch(this.state){case x.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case x.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case x.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function qe(r){this.enabled===!1||this.enableZoom===!1||this.state!==x.NONE||(r.preventDefault(),this.dispatchEvent(de),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(Ae))}function Ze(r){this.enabled!==!1&&this._handleKeyDown(r)}function $e(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case u.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=x.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=x.TOUCH_PAN;break;default:this.state=x.NONE}break;case 2:switch(this.touches.TWO){case u.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=x.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=x.TOUCH_DOLLY_ROTATE;break;default:this.state=x.NONE}break;default:this.state=x.NONE}this.state!==x.NONE&&this.dispatchEvent(de)}function Qe(r){switch(this._trackPointer(r),this.state){case x.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case x.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case x.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case x.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=x.NONE}}function Je(r){this.enabled!==!1&&r.preventDefault()}function et(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function tt(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class st extends Le{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons={LEFT:u.MOUSE.PAN,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.ROTATE},this.touches={ONE:u.TOUCH.PAN,TWO:u.TOUCH.DOLLY_ROTATE}}}function nt(r){return new u.CameraHelper(r)}function it(r=150,...e){return new u.GridHelper(r,r/10,...e)}function ot(r){return new u.BoxHelper(r,16776960)}function rt(r,e){return new Le(r,e)}function at(r,e){return new st(r,e)}function ct(){const r=new u.Raycaster,e=new u.Vector2(0,0);return{raycaster:r,pointer:e}}function lt(r=10){return new u.AxesHelper(r)}function ht(r=new u.Vector3(1,1,1),e=new u.Vector3(10,10,10),t=5,s=16776960){return r.normalize(),new u.ArrowHelper(r,e,t,s)}function ut(){const r=new V;return r.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r}function Te(r,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],c=r.getAttribute("position");if(c!==void 0){for(let a=0;a<c.count;a++)o.push(a);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const s=t.count-2,n=[];if(e===u.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=r.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}const ne=new WeakMap;class dt extends u.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,n){const i=new u.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{this.parse(o,t,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,u.SRGBColorSpace,s).catch(s)}decodeDracoFile(e,t,s,n,i=u.LinearSRGBColorSpace,o=()=>{}){const c={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:i};return this.decodeGeometry(e,c).then(t).catch(o)}decodeGeometry(e,t){const s=JSON.stringify(t);if(ne.has(e)){const a=ne.get(e);if(a.key===s)return a.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,o=e.byteLength,c=this._getWorker(i,o).then(a=>(n=a,new Promise((l,d)=>{n._callbacks[i]={resolve:l,reject:d},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return c.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),ne.set(e,{key:s,promise:c}),c}_createGeometry(e){const t=new u.BufferGeometry;e.index&&t.setIndex(new u.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s],i=n.name,o=n.array,c=n.itemSize,a=new u.BufferAttribute(o,c);i==="color"&&(this._assignVertexColorSpace(a,n.vertexColorSpace),a.normalized=!(o instanceof Float32Array)),t.setAttribute(i,a)}return t}_assignVertexColorSpace(e,t){if(t!==u.SRGBColorSpace)return;const s=new u.Color;for(let n=0,i=e.count;n<i;n++)s.fromBufferAttribute(e,n),u.ColorManagement.colorSpaceToWorking(s,u.SRGBColorSpace),e.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new u.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((n,i)=>{s.load(e,n,void 0,i)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const n=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const i=ft.toString(),o=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
2
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const o=i.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function ft(){let r,e;onmessage=function(o){const c=o.data;switch(c.type){case"init":r=c.decoderConfig,e=new Promise(function(d){r.onModuleLoaded=function(h){d({draco:h})},DracoDecoderModule(r)});break;case"decode":const a=c.buffer,l=c.taskConfig;e.then(d=>{const h=d.draco,g=new h.Decoder;try{const p=t(h,g,new Int8Array(a),l),y=p.attributes.map(_=>_.array.buffer);p.index&&y.push(p.index.array.buffer),self.postMessage({type:"decode",id:c.id,geometry:p},y)}catch(p){console.error(p),self.postMessage({type:"error",id:c.id,error:p.message})}finally{h.destroy(g)}});break}};function t(o,c,a,l){const d=l.attributeIDs,h=l.attributeTypes;let g,p;const y=c.GetEncodedGeometryType(a);if(y===o.TRIANGULAR_MESH)g=new o.Mesh,p=c.DecodeArrayToMesh(a,a.byteLength,g);else if(y===o.POINT_CLOUD)g=new o.PointCloud,p=c.DecodeArrayToPointCloud(a,a.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const _={index:null,attributes:[]};for(const m in d){const f=self[h[m]];let T,w;if(l.useUniqueIDs)w=d[m],T=c.GetAttributeByUniqueId(g,w);else{if(w=c.GetAttributeId(g,o[d[m]]),w===-1)continue;T=c.GetAttribute(g,w)}const b=n(o,c,g,m,f,T);m==="color"&&(b.vertexColorSpace=l.vertexColorSpace),_.attributes.push(b)}return y===o.TRIANGULAR_MESH&&(_.index=s(o,c,g)),o.destroy(g),_}function s(o,c,a){const d=a.num_faces()*3,h=d*4,g=o._malloc(h);c.GetTrianglesUInt32Array(a,h,g);const p=new Uint32Array(o.HEAPF32.buffer,g,d).slice();return o._free(g),{array:p,itemSize:1}}function n(o,c,a,l,d,h){const g=h.num_components(),y=a.num_points()*g,_=y*d.BYTES_PER_ELEMENT,m=i(o,d),f=o._malloc(_);c.GetAttributeDataArrayForAllPoints(a,h,m,_,f);const T=new d(o.HEAPF32.buffer,f,y).slice();return o._free(f),{name:l,array:T,itemSize:g}}function i(o,c){switch(c){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}class pt extends u.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Tt(t)}),this.register(function(t){return new bt(t)}),this.register(function(t){return new Pt(t)}),this.register(function(t){return new Ct(t)}),this.register(function(t){return new Dt(t)}),this.register(function(t){return new Et(t)}),this.register(function(t){return new St(t)}),this.register(function(t){return new xt(t)}),this.register(function(t){return new Mt(t)}),this.register(function(t){return new _t(t)}),this.register(function(t){return new Rt(t)}),this.register(function(t){return new wt(t)}),this.register(function(t){return new Lt(t)}),this.register(function(t){return new At(t)}),this.register(function(t){return new gt(t)}),this.register(function(t){return new Ot(t)}),this.register(function(t){return new It(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=u.LoaderUtils.extractUrlBase(e);o=u.LoaderUtils.resolveURL(l,this.path)}else o=u.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const c=function(l){n?n(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},a=new u.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{i.parse(l,o,function(d){t(d),i.manager.itemEnd(e)},c)}catch(d){c(d)}},s,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const o={},c={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Pe){try{o[E.KHR_BINARY_GLTF]=new kt(e)}catch(h){n&&n(h);return}i=JSON.parse(o[E.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Xt(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const h=this.pluginCallbacks[d](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[h.name]=h,o[h.name]=!0}if(i.extensionsUsed)for(let d=0;d<i.extensionsUsed.length;++d){const h=i.extensionsUsed[d],g=i.extensionsRequired||[];switch(h){case E.KHR_MATERIALS_UNLIT:o[h]=new yt;break;case E.KHR_DRACO_MESH_COMPRESSION:o[h]=new Nt(i,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:o[h]=new vt;break;case E.KHR_MESH_QUANTIZATION:o[h]=new Ht;break;default:g.indexOf(h)>=0&&c[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(c),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function mt(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const E={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class gt{constructor(e){this.parser=e,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const d=new u.Color(16777215);a.color!==void 0&&d.setRGB(a.color[0],a.color[1],a.color[2],u.LinearSRGBColorSpace);const h=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new u.DirectionalLight(d),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new u.PointLight(d),l.distance=h;break;case"spot":l=new u.SpotLight(d),l.distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,l.angle=a.spot.outerConeAngle,l.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return l.position.set(0,0,0),N(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(l),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],c=(i.extensions&&i.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(a){return s._getNodeRef(t.cache,c,a)})}}class yt{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new u.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,u.SRGBColorSpace))}return Promise.all(n)}}class _t{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class Tt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const c=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new u.Vector2(c,c)}return Promise.all(i)}}class bt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class wt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Et{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new u.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const c=o.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],u.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,u.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class St{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class xt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const c=o.attenuationColor||[1,1,1];return t.attenuationColor=new u.Color().setRGB(c[0],c[1],c[2],u.LinearSRGBColorSpace),Promise.all(i)}}class Mt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Rt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const c=o.specularColorFactor||[1,1,1];return t.specularColor=new u.Color().setRGB(c[0],c[1],c[2],u.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,u.SRGBColorSpace)),Promise.all(i)}}class At{constructor(e){this.parser=e,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class Lt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Pt{constructor(e){this.parser=e,this.name=E.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Ct{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],c=n.images[o.source];let a=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(a=l)}return s.loadTextureImage(e,o.source,a)}}class Dt{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],c=n.images[o.source];let a=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(a=l)}return s.loadTextureImage(e,o.source,a)}}class Ot{constructor(e){this.name=E.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(c){const a=n.byteOffset||0,l=n.byteLength||0,d=n.count,h=n.byteStride,g=new Uint8Array(c,a,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,h,g,n.mode,n.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(d*h);return o.decodeGltfBuffer(new Uint8Array(p),d,h,g,n.mode,n.filter),p})})}else return null}}class It{constructor(e){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const l of n.primitives)if(l.mode!==O.TRIANGLES&&l.mode!==O.TRIANGLE_STRIP&&l.mode!==O.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=s.extensions[this.name].attributes,c=[],a={};for(const l in o)c.push(this.parser.getDependency("accessor",o[l]).then(d=>(a[l]=d,a[l])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(l=>{const d=l.pop(),h=d.isGroup?d.children:[d],g=l[0].count,p=[];for(const y of h){const _=new u.Matrix4,m=new u.Vector3,f=new u.Quaternion,T=new u.Vector3(1,1,1),w=new u.InstancedMesh(y.geometry,y.material,g);for(let b=0;b<g;b++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,b),a.ROTATION&&f.fromBufferAttribute(a.ROTATION,b),a.SCALE&&T.fromBufferAttribute(a.SCALE,b),w.setMatrixAt(b,_.compose(m,f,T));for(const b in a)if(b==="_COLOR_0"){const M=a[b];w.instanceColor=new u.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&y.geometry.setAttribute(b,a[b]);u.Object3D.prototype.copy.call(w,y),this.parser.assignFinalMaterial(w),p.push(w)}return d.isGroup?(d.clear(),d.add(...p),d):p[0]}))}}const Pe="glTF",Y=12,be={JSON:1313821514,BIN:5130562};class kt{constructor(e){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,Y),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Pe)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-Y,i=new DataView(e,Y);let o=0;for(;o<n;){const c=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,a===be.JSON){const l=new Uint8Array(e,Y+o,c);this.content=s.decode(l)}else if(a===be.BIN){const l=Y+o;this.body=e.slice(l,l+c)}o+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Nt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,c={},a={},l={};for(const d in o){const h=le[d]||d.toLowerCase();c[h]=o[d]}for(const d in e.attributes){const h=le[d]||d.toLowerCase();if(o[d]!==void 0){const g=s.accessors[e.attributes[d]],p=W[g.componentType];l[h]=p.name,a[h]=g.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(h,g){n.decodeDracoFile(d,function(p){for(const y in p.attributes){const _=p.attributes[y],m=a[y];m!==void 0&&(_.normalized=m)}h(p)},c,l,u.LinearSRGBColorSpace,g)})})}}class vt{constructor(){this.name=E.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ht{constructor(){this.name=E.KHR_MESH_QUANTIZATION}}class Ce extends u.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,c=this.valueSize,a=c*2,l=c*3,d=n-t,h=(s-t)/d,g=h*h,p=g*h,y=e*l,_=y-l,m=-2*p+3*g,f=p-g,T=1-m,w=f-g+h;for(let b=0;b!==c;b++){const M=o[_+b+c],A=o[_+b+a]*d,L=o[y+b+c],R=o[y+b]*d;i[b]=T*M+w*A+m*L+f*R}return i}}const Ft=new u.Quaternion;class Ut extends Ce{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ft.fromArray(i).normalize().toArray(i),i}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},W={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},we={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},Ee={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},ie={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},le={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jt={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},oe={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Gt(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),r.DefaultMaterial}function j(r,e,t){for(const s in t.extensions)r[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function N(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Bt(r,e,t){let s=!1,n=!1,i=!1;for(let l=0,d=e.length;l<d;l++){const h=e[l];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(n=!0),h.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(r);const o=[],c=[],a=[];for(let l=0,d=e.length;l<d;l++){const h=e[l];if(s){const g=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):r.attributes.position;o.push(g)}if(n){const g=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):r.attributes.normal;c.push(g)}if(i){const g=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):r.attributes.color;a.push(g)}}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(a)]).then(function(l){const d=l[0],h=l[1],g=l[2];return s&&(r.morphAttributes.position=d),n&&(r.morphAttributes.normal=h),i&&(r.morphAttributes.color=g),r.morphTargetsRelative=!0,r})}function zt(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)r.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Kt(r){let e;const t=r.extensions&&r.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+re(t.attributes):e=r.indices+":"+re(r.attributes)+":"+r.mode,r.targets!==void 0)for(let s=0,n=r.targets.length;s<n;s++)e+=":"+re(r.targets[s]);return e}function re(r){let e="";const t=Object.keys(r).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+r[t[s]]+";";return e}function he(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Vt(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Wt=new u.Matrix4;class Xt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new mt,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const c=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(c)===!0;const a=c.match(/Version\/(\d+)/);n=s&&a?parseInt(a[1],10):-1,i=c.indexOf("Firefox")>-1,o=i?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const c={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return j(i,c,n),N(c,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(c)})).then(function(){for(const a of c.scenes)a.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let c=0,a=o.length;c<a;c++)e[o[c]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,c)=>{const a=this.associations.get(o);a!=null&&this.associations.set(c,a);for(const[l,d]of o.children.entries())i(d,c.children[l])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(u.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=ie[n.type],c=W[n.componentType],a=n.normalized===!0,l=new c(n.count*o);return Promise.resolve(new u.BufferAttribute(l,o,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const c=o[0],a=ie[n.type],l=W[n.componentType],d=l.BYTES_PER_ELEMENT,h=d*a,g=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,y=n.normalized===!0;let _,m;if(p&&p!==h){const f=Math.floor(g/p),T="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count;let w=t.cache.get(T);w||(_=new l(c,f*p,n.count*p/d),w=new u.InterleavedBuffer(_,p/d),t.cache.add(T,w)),m=new u.InterleavedBufferAttribute(w,a,g%p/d,y)}else c===null?_=new l(n.count*a):_=new l(c,g,n.count*a),m=new u.BufferAttribute(_,a,y);if(n.sparse!==void 0){const f=ie.SCALAR,T=W[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,b=n.sparse.values.byteOffset||0,M=new T(o[1],w,n.sparse.count*f),A=new l(o[2],b,n.sparse.count*a);c!==null&&(m=new u.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let L=0,R=M.length;L<R;L++){const C=M[L];if(m.setX(C,A[L*a]),a>=2&&m.setY(C,A[L*a+1]),a>=3&&m.setZ(C,A[L*a+2]),a>=4&&m.setW(C,A[L*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=y}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let c=this.textureLoader;if(o.uri){const a=s.manager.getHandler(o.uri);a!==null&&(c=a)}return this.loadTextureImage(e,i,c)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],c=i.images[t],a=(c.uri||c.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,s).then(function(d){d.flipY=!1,d.name=o.name||c.name||"",d.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(d.name=c.uri);const g=(i.samplers||{})[o.sampler]||{};return d.magFilter=we[g.magFilter]||u.LinearFilter,d.minFilter=we[g.minFilter]||u.LinearMipmapLinearFilter,d.wrapS=Ee[g.wrapS]||u.RepeatWrapping,d.wrapT=Ee[g.wrapT]||u.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==u.NearestFilter&&d.minFilter!==u.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=n.images[e],c=self.URL||self.webkitURL;let a=o.uri||"",l=!1;if(o.bufferView!==void 0)a=s.getDependency("bufferView",o.bufferView).then(function(h){l=!0;const g=new Blob([h],{type:o.mimeType});return a=c.createObjectURL(g),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(h){return new Promise(function(g,p){let y=g;t.isImageBitmapLoader===!0&&(y=function(_){const m=new u.Texture(_);m.needsUpdate=!0,g(m)}),t.load(u.LoaderUtils.resolveURL(h,i.path),y,void 0,p)})}).then(function(h){return l===!0&&c.revokeObjectURL(a),N(h,o),h.userData.mimeType=o.mimeType||Vt(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),h});return this.sourceCache[e]=d,d}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[E.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const a=i.associations.get(o);o=i.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(o,c),i.associations.set(o,a)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let a=this.cache.get(c);a||(a=new u.PointsMaterial,u.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(c,a)),s=a}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let a=this.cache.get(c);a||(a=new u.LineBasicMaterial,u.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(c,a)),s=a}if(n||i||o){let c="ClonedMaterial:"+s.uuid+":";n&&(c+="derivative-tangents:"),i&&(c+="vertex-colors:"),o&&(c+="flat-shading:");let a=this.cache.get(c);a||(a=s.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(c,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const c={},a=i.extensions||{},l=[];if(a[E.KHR_MATERIALS_UNLIT]){const h=n[E.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(c,i,t))}else{const h=i.pbrMetallicRoughness||{};if(c.color=new u.Color(1,1,1),c.opacity=1,Array.isArray(h.baseColorFactor)){const g=h.baseColorFactor;c.color.setRGB(g[0],g[1],g[2],u.LinearSRGBColorSpace),c.opacity=g[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(c,"map",h.baseColorTexture,u.SRGBColorSpace)),c.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,c.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(c,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(c,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,c)})))}i.doubleSided===!0&&(c.side=u.DoubleSide);const d=i.alphaMode||oe.OPAQUE;if(d===oe.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,d===oe.MASK&&(c.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==u.MeshBasicMaterial&&(l.push(t.assignTexture(c,"normalMap",i.normalTexture)),c.normalScale=new u.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;c.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&o!==u.MeshBasicMaterial&&(l.push(t.assignTexture(c,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==u.MeshBasicMaterial){const h=i.emissiveFactor;c.emissive=new u.Color().setRGB(h[0],h[1],h[2],u.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==u.MeshBasicMaterial&&l.push(t.assignTexture(c,"emissiveMap",i.emissiveTexture,u.SRGBColorSpace)),Promise.all(l).then(function(){const h=new o(c);return i.name&&(h.name=i.name),N(h,i),t.associations.set(h,{materials:e}),i.extensions&&j(n,h,i),h})}createUniqueName(e){const t=u.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(c){return s[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(a){return Se(a,c,t)})}const o=[];for(let c=0,a=e.length;c<a;c++){const l=e[c],d=Kt(l),h=n[d];if(h)o.push(h.promise);else{let g;l.extensions&&l.extensions[E.KHR_DRACO_MESH_COMPRESSION]?g=i(l):g=Se(new u.BufferGeometry,l,t),n[d]={primitive:l,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,c=[];for(let a=0,l=o.length;a<l;a++){const d=o[a].material===void 0?Gt(this.cache):this.getDependency("material",o[a].material);c.push(d)}return c.push(t.loadGeometries(o)),Promise.all(c).then(function(a){const l=a.slice(0,a.length-1),d=a[a.length-1],h=[];for(let p=0,y=d.length;p<y;p++){const _=d[p],m=o[p];let f;const T=l[p];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)f=i.isSkinnedMesh===!0?new u.SkinnedMesh(_,T):new u.Mesh(_,T),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?f.geometry=Te(f.geometry,u.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(f.geometry=Te(f.geometry,u.TriangleFanDrawMode));else if(m.mode===O.LINES)f=new u.LineSegments(_,T);else if(m.mode===O.LINE_STRIP)f=new u.Line(_,T);else if(m.mode===O.LINE_LOOP)f=new u.LineLoop(_,T);else if(m.mode===O.POINTS)f=new u.Points(_,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(f.geometry.morphAttributes).length>0&&zt(f,i),f.name=t.createUniqueName(i.name||"mesh_"+e),N(f,i),m.extensions&&j(n,f,m),t.assignFinalMaterial(f),h.push(f)}for(let p=0,y=h.length;p<y;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return i.extensions&&j(n,h[0],i),h[0];const g=new u.Group;i.extensions&&j(n,g,i),t.associations.set(g,{meshes:e});for(let p=0,y=h.length;p<y;p++)g.add(h[p]);return g})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new u.PerspectiveCamera(u.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new u.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),N(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,c=[],a=[];for(let l=0,d=o.length;l<d;l++){const h=o[l];if(h){c.push(h);const g=new u.Matrix4;i!==null&&g.fromArray(i.array,l*16),a.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new u.Skeleton(c,a)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],c=[],a=[],l=[],d=[];for(let h=0,g=n.channels.length;h<g;h++){const p=n.channels[h],y=n.samplers[p.sampler],_=p.target,m=_.node,f=n.parameters!==void 0?n.parameters[y.input]:y.input,T=n.parameters!==void 0?n.parameters[y.output]:y.output;_.node!==void 0&&(o.push(this.getDependency("node",m)),c.push(this.getDependency("accessor",f)),a.push(this.getDependency("accessor",T)),l.push(y),d.push(_))}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(a),Promise.all(l),Promise.all(d)]).then(function(h){const g=h[0],p=h[1],y=h[2],_=h[3],m=h[4],f=[];for(let T=0,w=g.length;T<w;T++){const b=g[T],M=p[T],A=y[T],L=_[T],R=m[T];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const C=s._createAnimationTracks(b,M,A,L,R);if(C)for(let k=0;k<C.length;k++)f.push(C[k])}return new u.AnimationClip(i,void 0,f)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(c){if(c.isMesh)for(let a=0,l=n.weights.length;a<l;a++)c.morphTargetInfluences[a]=n.weights[a]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],c=n.children||[];for(let l=0,d=c.length;l<d;l++)o.push(s.getDependency("node",c[l]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),a]).then(function(l){const d=l[0],h=l[1],g=l[2];g!==null&&d.traverse(function(p){p.isSkinnedMesh&&p.bind(g,Wt)});for(let p=0,y=h.length;p<y;p++)d.add(h[p]);return d})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",c=[],a=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return a&&c.push(a),i.camera!==void 0&&c.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){c.push(l)}),this.nodeCache[e]=Promise.all(c).then(function(l){let d;if(i.isBone===!0?d=new u.Bone:l.length>1?d=new u.Group:l.length===1?d=l[0]:d=new u.Object3D,d!==l[0])for(let h=0,g=l.length;h<g;h++)d.add(l[h]);if(i.name&&(d.userData.name=i.name,d.name=o),N(d,i),i.extensions&&j(s,d,i),i.matrix!==void 0){const h=new u.Matrix4;h.fromArray(i.matrix),d.applyMatrix4(h)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const h=n.associations.get(d);n.associations.set(d,{...h})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new u.Group;s.name&&(i.name=n.createUniqueName(s.name)),N(i,s),s.extensions&&j(t,i,s);const o=s.nodes||[],c=[];for(let a=0,l=o.length;a<l;a++)c.push(n.getDependency("node",o[a]));return Promise.all(c).then(function(a){for(let d=0,h=a.length;d<h;d++)i.add(a[d]);const l=d=>{const h=new Map;for(const[g,p]of n.associations)(g instanceof u.Material||g instanceof u.Texture)&&h.set(g,p);return d.traverse(g=>{const p=n.associations.get(g);p!=null&&h.set(g,p)}),h};return n.associations=l(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],c=e.name?e.name:e.uuid,a=[];H[i.path]===H.weights?e.traverse(function(g){g.morphTargetInfluences&&a.push(g.name?g.name:g.uuid)}):a.push(c);let l;switch(H[i.path]){case H.weights:l=u.NumberKeyframeTrack;break;case H.rotation:l=u.QuaternionKeyframeTrack;break;case H.translation:case H.scale:l=u.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:l=u.NumberKeyframeTrack;break;case 2:case 3:default:l=u.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?jt[n.interpolation]:u.InterpolateLinear,h=this._getArrayFromAccessor(s);for(let g=0,p=a.length;g<p;g++){const y=new l(a[g]+"."+H[i.path],t.array,h,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),o.push(y)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=he(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof u.QuaternionKeyframeTrack?Ut:Ce;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Yt(r,e,t){const s=e.attributes,n=new u.Box3;if(s.POSITION!==void 0){const c=t.json.accessors[s.POSITION],a=c.min,l=c.max;if(a!==void 0&&l!==void 0){if(n.set(new u.Vector3(a[0],a[1],a[2]),new u.Vector3(l[0],l[1],l[2])),c.normalized){const d=he(W[c.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const c=new u.Vector3,a=new u.Vector3;for(let l=0,d=i.length;l<d;l++){const h=i[l];if(h.POSITION!==void 0){const g=t.json.accessors[h.POSITION],p=g.min,y=g.max;if(p!==void 0&&y!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(y[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(y[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(y[2]))),g.normalized){const _=he(W[g.componentType]);a.multiplyScalar(_)}c.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(c)}r.boundingBox=n;const o=new u.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,r.boundingSphere=o}function Se(r,e,t){const s=e.attributes,n=[];function i(o,c){return t.getDependency("accessor",o).then(function(a){r.setAttribute(c,a)})}for(const o in s){const c=le[o]||o.toLowerCase();c in r.attributes||n.push(i(s[o],c))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(c){r.setIndex(c)});n.push(o)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),N(r,e),Yt(r,e,t),Promise.all(n).then(function(){return e.targets!==void 0?Bt(r,e.targets,t):r})}const De=r=>{r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(e=>{xe(e)}):xe(r.material)),r.children&&r.children.forEach(e=>De(e))};function xe(r){for(const e in r)r[e]&&r[e].isTexture&&r[e].dispose();r.dispose()}const ae={};async function qt(r,e=50){const t={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(t.geometry=Q(r.geometry),t.material=ee(r.material));const s=[{object:r,parentData:t}];let n=0;for(;s.length>0;){const{object:i,parentData:o}=s.pop();for(const c of i.children){const a={type:c.type,name:c.name,position:c.position.toArray(),rotation:c.rotation.toArray(),scale:c.scale.toArray(),visible:c.visible,children:[],geometry:null,material:null,userData:c.userData};c.isMesh&&(a.geometry=Q(c.geometry),a.material=ee(c.material)),o.children.push(a),s.push({object:c,parentData:a}),n++,n%e===0&&await new Promise(l=>requestAnimationFrame(l))}}return t}function Zt(r){const e={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(e.geometry=Q(r.geometry),e.material=ee(r.material));const t=[{object:r,parentData:e}];for(;t.length>0;){const{object:s,parentData:n}=t.pop();for(const i of s.children){const o={type:i.type,name:i.name,position:i.position.toArray(),rotation:i.rotation.toArray(),scale:i.scale.toArray(),visible:i.visible,children:[],geometry:null,material:null,userData:i.userData};i.isMesh&&(o.geometry=Q(i.geometry),o.material=ee(i.material)),n.children.push(o),t.push({object:i,parentData:o})}}return e}async function Oe(r,e=50){const t=[];let s;switch(r.type){case"Mesh":const i=J(r.geometry),o=te(r.material);s=new S.Mesh(i,o);break;case"Group":s=new S.Group;break;case"Object3D":s=new S.Object3D;break;default:return console.warn(`Unsupported object type: ${r.type}`),null}s.name=r.name,s.position.fromArray(r.position),s.rotation.fromArray(r.rotation),s.scale.fromArray(r.scale),s.visible=r.visible,s.userData=r.userData,t.push({data:r,object:s});let n=0;for(;t.length>0;){const{data:i,object:o}=t.pop();for(const c of[...i.children].reverse()){let a;switch(c.type){case"Mesh":const l=J(c.geometry),d=te(c.material);a=new S.Mesh(l,d);break;case"Group":a=new S.Group;break;case"Object3D":a=new S.Object3D;break;default:console.warn(`Unsupported object type: ${c.type}`);continue}a&&(a.name=c.name,a.position.fromArray(c.position),a.rotation.fromArray(c.rotation),a.scale.fromArray(c.scale),a.visible=c.visible,a.userData=c.userData,o.add(a),t.push({data:c,object:a}),n++,n%e===0&&await new Promise(l=>requestAnimationFrame(l)))}}return s}function $t(r){const e=[];let t;switch(r.type){case"Mesh":const s=J(r.geometry),n=te(r.material);t=new S.Mesh(s,n);break;case"Group":t=new S.Group;break;case"Object3D":t=new S.Object3D;break;default:return console.warn(`Unsupported object type: ${r.type}`),null}for(t.name=r.name,t.position.fromArray(r.position),t.rotation.fromArray(r.rotation),t.scale.fromArray(r.scale),t.visible=r.visible,t.userData=r.userData,e.push({data:r,object:t});e.length>0;){const{data:s,object:n}=e.pop();for(const i of[...s.children].reverse()){let o;switch(i.type){case"Mesh":const c=J(i.geometry),a=te(i.material);o=new S.Mesh(c,a);break;case"Group":o=new S.Group;break;case"Object3D":o=new S.Object3D;break;default:console.warn(`Unsupported object type: ${i.type}`);continue}o&&(o.name=i.name,o.position.fromArray(i.position),o.rotation.fromArray(i.rotation),o.scale.fromArray(i.scale),o.visible=i.visible,o.userData=i.userData,n.add(o),e.push({data:i,object:o}))}}return t}function Q(r){const e={},{attributes:t,index:s,type:n}=r;t.position&&(e.position={type:"Float32Array",array:Array.from(t.position.array),itemSize:3}),t.normal&&(e.normal={type:"Float32Array",array:Array.from(t.normal.array),itemSize:3}),t.uv&&(e.uv={type:"Float32Array",array:Array.from(t.uv.array),itemSize:2});const i={type:n,attributes:e};return s&&s.array&&(i.index={type:"Uint32Array",array:Array.from(s.array),itemSize:1}),i}function J(r){const{type:e,attributes:t,index:s}=r,n=new S.BufferGeometry;for(const i in t)if(t.hasOwnProperty(i)){const{type:o,array:c,itemSize:a}=t[i];n.setAttribute(i,new S.BufferAttribute(new Float32Array(c),a))}return s&&n.setIndex(s.array),n}function ee(r){return{type:r.type,color:r.color.getHex(),map:r.map?r.map.image.src:null,opacity:r.opacity,name:r.name,depthTest:r.depthTest,depthWrite:r.depthWrite,transparent:r.transparent,side:r.side,roughness:r.roughness,metalness:r.metalness,emissive:r.emissive.getHex()}}function te(r){if(ae[r.name])return ae[r.name];const{type:e,...t}=r,s=e||"MeshStandardMaterial",n=new S[s]({...t});if(r.map){const i=new S.TextureLoader().load(r.map);n.map=i}return n.needsUpdate=!0,ae[r.name]=n,n}class Ie{constructor(){this.stats={hits:0,misses:0,totalLoadTime:0,cacheSaveTime:0,errors:0},this.loadHistory=[]}recordHit(e){this.stats.hits++,this.stats.totalLoadTime+=e,this._recordHistory("hit",e)}recordMiss(e){this.stats.misses++,this.stats.totalLoadTime+=e,this._recordHistory("miss",e)}recordCacheSave(e){this.stats.cacheSaveTime+=e}recordError(e,t){this.stats.errors++,this._recordHistory("error",0,{path:e,error:t.message})}getHitRate(){const e=this.stats.hits+this.stats.misses;return e>0?(this.stats.hits/e*100).toFixed(2)+"%":"0%"}getAvgLoadTime(){const e=this.stats.hits+this.stats.misses;return e>0?(this.stats.totalLoadTime/e).toFixed(2)+"ms":"0ms"}getStats(){const e=this.stats.hits+this.stats.misses;return{命中率:this.getHitRate(),平均加载时间:this.getAvgLoadTime(),缓存命中数:this.stats.hits,缓存未命中数:this.stats.misses,总加载次数:e,总加载时间:this.stats.totalLoadTime.toFixed(2)+"ms",缓存保存时间:this.stats.cacheSaveTime.toFixed(2)+"ms",错误次数:this.stats.errors}}getHistory(e=10){return this.loadHistory.slice(-e)}reset(){this.stats={hits:0,misses:0,totalLoadTime:0,cacheSaveTime:0,errors:0},this.loadHistory=[]}_recordHistory(e,t,s={}){this.loadHistory.push({type:e,duration:t,timestamp:Date.now(),...s}),this.loadHistory.length>100&&this.loadHistory.shift()}logReport(){console.group("📊 缓存性能报告");const e=this.getStats();Object.entries(e).forEach(([t,s])=>{console.log(`${t}: ${s}`)}),console.groupEnd()}}const U=new Ie;class q{static async retry(e,t={}){const{maxRetries:s=3,initialDelay:n=1e3,maxDelay:i=1e4,backoffFactor:o=2,shouldRetry:c=q.defaultShouldRetry}=t;let a,l=n;for(let d=0;d<=s;d++)try{return await e()}catch(h){if(a=h,d===s||!c(h,d))throw h;console.warn(`[ RetryHelper ] 操作失败,第 ${d+1} 次尝试失败,${l}ms 后进行第 ${d+2} 次尝试...`,h),await q.delay(l),l=Math.min(l*o,i)}throw a}static defaultShouldRetry(e,t){if(e.name==="TypeError"&&e.message.includes("fetch"))return!0;if(e.message.includes("HTTP error")){const s=e.message.match(/status:\s*(\d+)/);if(s){const n=parseInt(s[1],10);return n>=500||n===429||n===408}}return!1}static delay(e){return new Promise(t=>setTimeout(t,e))}}const $={NETWORK:"NETWORK",PARSE:"PARSE",VERSION_MISMATCH:"VERSION",UNKNOWN:"UNKNOWN"};class X extends Error{constructor(e,t,s,n){super(e),this.name="ModelLoadError",this.type=t,this.path=s,this.originalError=n,this.timestamp=Date.now()}static networkError(e,t){return new X(`网络加载失败: ${e}`,$.NETWORK,e,t)}static parseError(e,t){return new X(`模型解析失败: ${e}`,$.PARSE,e,t)}static versionMismatchError(e,t,s){return new X(`版本不匹配: ${e} (期望: ${t}, 实际: ${s})`,$.VERSION_MISMATCH,e)}}const Me=4;class ue{constructor(e="threeJsIDBCache",t={}){this.version=Me,this.dbName=e,this.options={maxSize:t.maxSize||500*1024*1024,maxEntries:t.maxEntries||50,evictRatio:t.evictRatio||.2},this.dbInit()}dbInit(){this.db=new ve(this.dbName),this.db.version(this.version).stores({models:"&path, version, timestamp, accessCount, size"}).upgrade(async e=>{console.log("[ IDBCache 版本更新 ] ====> version",Me);const t=e.table("models"),s=await t.toArray();for(const n of s)n.data instanceof ArrayBuffer||await t.delete(n.path)})}getDatabase(){return this.db}async saveModel(e,t,s){await this.ensureCapacity(s.byteLength),await this.db.table("models").put({path:e,version:t,data:s,size:s.byteLength,timestamp:Date.now(),accessCount:0})}async ensureCapacity(e){const t=await this.db.table("models").toArray(),s=t.reduce((c,a)=>c+(a.size||0),0),n=t.length,i=s+e>this.options.maxSize,o=n>=this.options.maxEntries;(i||o)&&(console.log(`[ IDBCache ] ====> 容量不足,开始 LRU 淘汰. 总大小: ${(s/1024/1024).toFixed(2)}MB, 条目数: ${n}`),await this.evictLRU(t))}async evictLRU(e){const t=e.sort((c,a)=>(c.accessCount||0)!==(a.accessCount||0)?(c.accessCount||0)-(a.accessCount||0):(c.timestamp||0)-(a.timestamp||0)),s=Math.max(1,Math.floor(t.length*this.options.evictRatio)),n=t.slice(0,s),i=n.map(c=>c.path);await this.db.table("models").bulkDelete(i);const o=n.reduce((c,a)=>c+(a.size||0),0);console.log(`[ IDBCache ] ====> LRU 淘汰完成. 删除 ${s} 个条目,释放 ${(o/1024/1024).toFixed(2)}MB`)}async getModel(e,t){const s=await this.db.table("models").get(e);return s?s.version!==t?(console.log("模型版本不一致, 清除当前记录"),await this.db.table("models").delete(e),null):(await this.db.table("models").update(e,{accessCount:(s.accessCount||0)+1,timestamp:Date.now()}),s.data):(console.warn(`Model "${e}" not found in table models`),null)}async cacheModel(e,t,s){console.log("[ ] ====> path, modelData, version",e,t,s);try{this.db.table("models").put({version:s,path:e,data:t}).then(()=>{console.log(`Model "${e}" cached successfully in table models`)})}catch{console.log(" 缓存模型失败 =====> ")}return t}async loadCachedModel(e,t){let s=null;try{if(s=await this.db.table("models").get(e),!s)return console.warn(`Model "${t}" not found in table models`),null;if(s.version!==t)return console.log(" =====> 模型版本不一致, 清除当前记录"),await this.db.table("models").delete(e),null}catch{return console.log(" =====> 查询表中模型失败"),this.db.delete().then(()=>{this.init()}),null}return s.data}async getStats(){const e=await this.db.table("models").toArray(),t=e.reduce((n,i)=>n+(i.size||0),0),s=e.reduce((n,i)=>n+(i.accessCount||0),0);return{count:e.length,totalSize:t,totalSizeMB:(t/1024/1024).toFixed(2),maxEntries:this.options.maxEntries,maxSizeMB:(this.options.maxSize/1024/1024).toFixed(2),usagePercentage:(t/this.options.maxSize*100).toFixed(2),totalAccessCount:s,avgAccessCount:e.length>0?(s/e.length).toFixed(2):0}}async clear(){await this.db.table("models").clear(),console.log("[ IDBCache ] ====> 缓存已清空")}async deleteModel(e){await this.db.table("models").delete(e)}}function fe(r){const{geometries:e,materials:t,hierarchy:s}=r,n=new Map;e.forEach((a,l)=>{const d=Qt(a);n.set(l,d)});const i=new Map;t.forEach((a,l)=>{const d=Jt(a);i.set(l,d)});const o=new S.Group;o.name="Scene";const c=new Map;return s.forEach(a=>{let l;if(a.type==="Mesh"){const d=a.geometryIndex>=0?n.get(a.geometryIndex):null,h=a.materialIndex>=0?i.get(a.materialIndex):null;l=new S.Mesh(d,h)}else a.type==="Group"?l=new S.Group:a.type==="Object3D"?l=new S.Object3D:l=new S.Object3D;l.name=a.name,l.position.fromArray(a.position),l.rotation.fromArray(a.rotation),l.scale.fromArray(a.scale),l.visible=a.visible,c.set(a.id,l)}),s.forEach(a=>{const l=c.get(a.id);if(a.parentId!==null){const d=c.get(a.parentId);d&&d.add(l)}else o.add(l)}),o}function Qt(r){const e=new S.BufferGeometry;for(const t in r.attributes){const s=r.attributes[t],n=s.array;let i;if(n.byteLength===0){console.warn(`[ sceneRebuilder ] 属性 ${t} 的数组为空`);continue}if(n.buffer&&n.buffer.byteLength===0){console.warn(`[ sceneRebuilder ] 属性 ${t} 的 buffer 已被转移,尝试重建`);continue}i=n;const o=new S.BufferAttribute(i,s.itemSize);o.normalized=s.normalized,e.setAttribute(t,o)}if(r.index){const t=r.index,s=t.array;if(s&&s.byteLength>0){const n=new S.BufferAttribute(s,t.itemSize);e.setIndex(n)}}return e}function Jt(r){let e;const t={color:r.color!==void 0?r.color:16777215,opacity:r.opacity!==void 0?r.opacity:1,transparent:r.transparent!==void 0?r.transparent:!1,alphaTest:r.alphaTest!==void 0?r.alphaTest:0,side:r.side!==void 0?r.side:S.FrontSide,depthTest:r.depthTest!==void 0?r.depthTest:!0,depthWrite:r.depthWrite!==void 0?r.depthWrite:!0,wireframe:r.wireframe!==void 0?r.wireframe:!1,vertexColors:r.vertexColors!==void 0?r.vertexColors:!1};switch(r.type){case"MeshStandardMaterial":e=new S.MeshStandardMaterial({...t,roughness:r.roughness!==void 0?r.roughness:.5,metalness:r.metalness!==void 0?r.metalness:.5,emissive:r.emissive!==void 0?r.emissive:0,emissiveIntensity:r.emissiveIntensity!==void 0?r.emissiveIntensity:1});break;case"MeshBasicMaterial":e=new S.MeshBasicMaterial({...t});break;case"MeshPhongMaterial":e=new S.MeshPhongMaterial({...t,shininess:r.shininess!==void 0?r.shininess:30,specular:r.specular!==void 0?r.specular:1118481,emissive:r.emissive!==void 0?r.emissive:0,emissiveIntensity:r.emissiveIntensity!==void 0?r.emissiveIntensity:1});break;default:e=new S.MeshStandardMaterial(t)}return e.uuid=r.uuid,e}class es{constructor(){this.geometries=[],this.materials=[],this.hierarchy=[],this.geometryMap=new Map,this.materialMap=new Map}addChunk(e){e.geometries&&e.geometries.forEach(t=>{const s=this.geometries.length;this.geometries.push(t),this.geometryMap.set(t.uuid,s)}),e.materials&&e.materials.forEach(t=>{const s=this.materials.length;this.materials.push(t),this.materialMap.set(t.uuid,s)}),e.hierarchy&&this.hierarchy.push(...e.hierarchy)}buildCurrent(){const e={geometries:this.geometries,materials:this.materials,hierarchy:this.hierarchy};return fe(e)}finalize(){return this.buildCurrent()}}const ts="/assets/gltfParser.worker-Bqz8BBJx.js",ss="/assets/gltfParserOptimized.worker-DfipxPjm.js";let B;const ce="/draco/";let z,K,Re=0;const F=new Map,ke=()=>{const r=new pt,e=new dt;e.setDecoderPath(ce),r.setDRACOLoader(e);function t(p,y,_,m){return r.load(p,y,_,m)}function s(p,y){return new Promise((_,m)=>{r.load(p,_,y,m)})}async function n(p,y,_,m={}){const f=performance.now();let T=!1;const{maxRetries:w=3,optimizeMaterials:b=!1,simplifyGeometry:M=!1,simplifyRatio:A=.5,simplifyOptions:L={}}=m;try{let R=await o(p,y);if(R)console.log(`[ asyncFetch ] ====> 缓存命中: ${p}`),T=!0;else{console.log(`[ asyncFetch ] ====> 缓存未命中: ${p}`),console.time("[ fetchArrayBuffer ] 加载模型耗时"),R=await q.retry(()=>i(p,_),{maxRetries:w,shouldRetry:pe=>!!(pe.name==="TypeError"||pe.message.includes("HTTP error! status: 5"))}),console.timeEnd("[ fetchArrayBuffer ] 加载模型耗时");const v=performance.now();await B.saveModel(p,y,R);const G=performance.now()-v;U.recordCacheSave(G),T=!1}console.time("[ 解析模型耗时 ]");let C=await c(R);if(console.timeEnd("[ 解析模型耗时 ]"),console.time("[ 模型优化耗时 ]"),b){console.log("🔧 [ 材质优化 ] 开始合并相同材质...");const{modelOptimizer:v}=await Promise.resolve().then(()=>require("./modelOptimizer-A0Cs6f9e.cjs"));C=v.optimizeMaterials(C)}if(M){console.log(`🔧 [ 几何体简化 ] 开始简化模型 (比例: ${A})...`);const{modelOptimizer:v}=await Promise.resolve().then(()=>require("./modelOptimizer-A0Cs6f9e.cjs")),G={minFaceCount:100,preserveUVs:!0,...L};C=v.simplifyModel(C,A,G)}console.timeEnd("[ 模型优化耗时 ]");const k=performance.now()-f;return T?U.recordHit(k):U.recordMiss(k),C}catch(R){throw console.error(`加载模型 ${p} 失败:`,R),U.recordError(p,R),R.name==="TypeError"&&R.message.includes("fetch")?X.networkError(p,R):R}}async function i(p,y){return new Promise((_,m)=>{fetch(p).then(f=>{if(!f.ok)throw new Error(`HTTP error! status: ${f.status}`);return f}).then(f=>{const T=f.headers.get("content-length"),w=T?parseInt(T,10):0;if(y&&w>0){const b=f.body.getReader();let M=0;const A=[],L=()=>{b.read().then(({done:R,value:C})=>{if(R){const k=new Uint8Array(M);let v=0;for(const G of A)k.set(G,v),v+=G.length;_(k.buffer);return}A.push(C),M+=C.length,y(Math.round(M/w*100)),L()}).catch(m)};L()}else return f.arrayBuffer()}).then(f=>_(f)).catch(f=>{m(f)})})}async function o(p,y){return B||(B=new ue),B.getModel(p,y)}async function c(p,y={}){if(!p)return null;const{useOptimizedParser:_=!0,useProgressive:m=!1}=y;if(_){const w=l();if(w)try{console.time("[ 优化解析 ] 使用 Transferable Objects 解析");const b=await d(w,p,m);return console.timeEnd("[ 优化解析 ] 使用 Transferable Objects 解析"),fe(b)}catch(b){console.warn("[ 优化解析 ] 失败,回退到标准解析",b)}}const f=a();if(f)try{const w=await h(f,p);return Oe(w)}catch(w){console.warn("[ GLTF Worker ] ====> 解析失败,回退到主线程解析",w)}return(await g(p)).scene}const a=()=>typeof window>"u"||typeof Worker>"u"?null:(z||(z=new Worker(ts,{type:"module"}),z.onmessage=p=>{const{id:y,data:_,error:m}=p.data||{};if(!y||!F.has(y))return;const{resolve:f,reject:T}=F.get(y);F.delete(y),m?T(new Error(m)):f(_)},z.onmessageerror=p=>{console.error("[ GLTF Worker ] ====> 消息解析失败",p)},z.onerror=p=>{console.error("[ GLTF Worker ] ====> 运行错误",p)}),z),l=()=>{if(typeof window>"u"||typeof Worker>"u")return null;if(!K)try{K=new Worker(ss,{type:"module"}),K.onmessage=p=>{const{id:y,data:_,error:m,type:f}=p.data||{};if(!y||!F.has(y)||f==="progress")return;const{resolve:T,reject:w}=F.get(y);F.delete(y),m?w(new Error(m)):T(_)},K.onmessageerror=p=>{console.error("[ 优化 Worker ] ====> 消息解析失败",p)},K.onerror=p=>{console.error("[ 优化 Worker ] ====> 运行错误",p)}}catch(p){return console.warn("[ 优化 Worker ] ====> 创建失败,可能不支持模块化 Worker",p),null}return K},d=(p,y,_=!1)=>new Promise((m,f)=>{const T=++Re;F.set(T,{resolve:m,reject:f});const w={id:T,arrayBuffer:y,dracoPath:ce,mode:_?"progressive":"standard"};p.postMessage(w,[y])}),h=(p,y)=>new Promise((_,m)=>{const f=++Re;F.set(f,{resolve:_,reject:m}),p.postMessage({id:f,arrayBuffer:y,dracoPath:ce})}),g=p=>new Promise((y,_)=>{r.parse(p,"",y,_)});return{load:t,asyncLoad:s,asyncCacheLoad:n,asyncFetch:n,getCacheStats:()=>U.getStats(),getCache:()=>B||(B=new ue),logCacheReport:()=>U.logReport(),resetCacheStats:()=>U.reset()}};class Ne{constructor(e={}){this.options={maxPreloadCount:e.maxPreloadCount||5,preloadDelay:e.preloadDelay||1e3,enableLearning:e.enableLearning!==!1},this.loadHistory=new Map,this.loadSequence=[],this.associations=new Map,this.preloadQueue=new Set,this.isPreloading=!1,this.loader=null,this.getLoader=()=>(this.loader||(this.loader=ke()),this.loader)}recordLoad(e,t){const s=Date.now(),n=this.loadHistory.get(e)||{count:0,lastLoadTime:0,versions:new Set};n.count++,n.lastLoadTime=s,n.versions.add(t),this.loadHistory.set(e,n),this.loadSequence.push({path:e,timestamp:s}),this.loadSequence.length>100&&this.loadSequence.shift(),this.options.enableLearning&&this.loadSequence.length>=2&&this._learnAssociations(e),this._triggerPredictivePreload(e,t)}_learnAssociations(e){const s=this.loadSequence.length-1;for(let n=Math.max(0,s-10);n<s;n++){const{path:i}=this.loadSequence[n];if(this.loadSequence[s].timestamp-this.loadSequence[n].timestamp<5*60*1e3&&i!==e){this.associations.has(i)||this.associations.set(i,new Map);const c=this.associations.get(i),a=c.get(e)||0;c.set(e,a+1)}}}_triggerPredictivePreload(e,t){setTimeout(()=>{const s=this.predictNext(e);this.preload(s,t)},this.options.preloadDelay)}predictNext(e){const t=new Map,s=this.associations.get(e);s&&s.forEach((c,a)=>{t.set(a,(t.get(a)||0)+c*2)});const n=Array.from(this.loadHistory.values()).reduce((c,a)=>c+a.count,0)/(this.loadHistory.size||1);this.loadHistory.forEach((c,a)=>{if(a!==e){const l=c.count/n;t.set(a,(t.get(a)||0)+l)}});const i=this.loadSequence.slice(-10);return new Set(i.map(c=>c.path)).forEach(c=>{c!==e&&t.set(c,(t.get(c)||0)+.5)}),Array.from(t.entries()).sort((c,a)=>a[1]-c[1]).slice(0,this.options.maxPreloadCount).map(([c])=>c)}async preload(e,t="latest"){if(this.isPreloading)return;this.isPreloading=!0;const{asyncFetch:s}=this.getLoader(),n=e.filter(i=>!this.preloadQueue.has(i)).slice(0,this.options.maxPreloadCount).map(async i=>{this.preloadQueue.add(i);try{console.log(`[ 智能预加载 ] 开始预加载: ${i}`),await s(i,t),console.log(`[ 智能预加载 ] 完成: ${i}`)}catch(o){console.warn(`[ 智能预加载 ] 失败: ${i}`,o)}finally{this.preloadQueue.delete(i)}});await Promise.all(n),this.isPreloading=!1}addAssociation(e,t){this.associations.has(e)||this.associations.set(e,new Map);const s=this.associations.get(e);t.forEach(n=>{const i=s.get(n)||0;s.set(n,i+10)})}getStats(){const e=Array.from(this.loadHistory.entries()).sort((t,s)=>s[1].count-t[1].count).slice(0,10).map(([t,s])=>({path:t,loadCount:s.count,lastLoadTime:new Date(s.lastLoadTime).toLocaleString()}));return{totalModelsLoaded:this.loadHistory.size,totalAssociations:this.associations.size,topModels:e,preloadQueueSize:this.preloadQueue.size}}clearHistory(){this.loadHistory.clear(),this.loadSequence=[],this.associations.clear()}exportAssociations(){const e={};return this.associations.forEach((t,s)=>{e[s]=Array.from(t.entries())}),e}importAssociations(e){Object.entries(e).forEach(([t,s])=>{const n=new Map(s);this.associations.set(t,n)})}}const ns=new Ne;exports.CSS3DRenderer=Be;exports.CSS3DSprite=je;exports.CacheMonitor=Ie;exports.ErrorType=$;exports.IDBCache=ue;exports.ModelLoadError=X;exports.PredictiveLoader=Ne;exports.ProgressiveSceneBuilder=es;exports.RetryHelper=q;exports.Stats=V;exports.cacheMonitor=U;exports.createArrowHelper=ht;exports.createAxesHelper=lt;exports.createBox3Helper=ot;exports.createCameraHelper=nt;exports.createGridHelper=it;exports.createMapControls=at;exports.createOrbitControl=rt;exports.createRaycaster=ct;exports.createStats=ut;exports.dataToObject3D=Oe;exports.dataToObject3DSync=$t;exports.disposeThreeObject=De;exports.object3DToData=qt;exports.object3DToDataSync=Zt;exports.predictiveLoader=ns;exports.rebuildScene=fe;exports.useGLTFLoader=ke;
|
package/dist/hooks.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useBatchGLTFLoader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useBatchGLTFLoader-BjAvIpyB.cjs"),r=require("./PredictiveLoader-DDxh7dDg.cjs");exports.intersectColor=e.intersectColor;exports.obbObjects=e.obbObjects;exports.useBatchGLTFLoader=e.useBatchGLTFLoader;exports.useObb=e.useObb;exports.useRaycaster=e.useRaycaster;exports.useThreeJs=e.useThreeJs;exports.useGLTFLoader=r.useGLTFLoader;
|
package/dist/hooks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as a, o, c as r, b as t, a as u, u as b } from "./useBatchGLTFLoader-
|
|
2
|
-
import { u as L } from "./PredictiveLoader
|
|
1
|
+
import { i as a, o, c as r, b as t, a as u, u as b } from "./useBatchGLTFLoader-B5EUagWI.js";
|
|
2
|
+
import { u as L } from "./PredictiveLoader-CZfMSjv-.js";
|
|
3
3
|
export {
|
|
4
4
|
a as intersectColor,
|
|
5
5
|
o as obbObjects,
|
package/dist/threejs.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var j=Object.defineProperty;var q=(x,e,t)=>e in x?j(x,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):x[e]=t;var o=(x,e,t)=>q(x,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./useBatchGLTFLoader-
|
|
1
|
+
"use strict";var j=Object.defineProperty;var q=(x,e,t)=>e in x?j(x,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):x[e]=t;var o=(x,e,t)=>q(x,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("./useBatchGLTFLoader-BjAvIpyB.cjs"),i=require("./PredictiveLoader-DDxh7dDg.cjs"),R=require("./ImageLoader-DL32KyTh.cjs"),S=require("./modelOptimizer-A0Cs6f9e.cjs"),r=require("three"),B="1.4.1",X=50,Y=20,Z=20,E={TOP:"top",RIGHT:"right",LEFT:"left",ISO:"iso"},G={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:r.MathUtils.degToRad(60)};class I{constructor(e,t){o(this,"isReady",!1);o(this,"scene",null);o(this,"camera",null);o(this,"renderer",null);o(this,"control",null);o(this,"css3dRenderer",null);o(this,"el",null);o(this,"renderRequested",!1);o(this,"selector",null);o(this,"eventsListener",{});o(this,"stats",null);o(this,"isDispose",!1);o(this,"version","0.0.0");o(this,"boxHelper",null);o(this,"initOpt",{css3d:!1,stats:!1,renderType:"change",initListener:!0,initialFov:50,control:{init:!0,options:{}}});o(this,"setup",e=>{if(this.isDispose=!1,this.selector=e,this.el=document.querySelector(e),!this.el){console.error(`ThreeIns: 找不到元素 ${e}`);return}const[t,h]=this.getTargetSize();if(this.updateCameraFOV(t,h),this.camera.position.set(0,0,0),this.camera.lookAt(0,0,0),this.camera.updateProjectionMatrix(),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(t,h),this.el.appendChild(this.renderer.domElement),this.initOpt.control&&this.initOpt.control.init){this.control=i.createOrbitControl(this.camera,this.renderer.domElement);const s=Object.assign(G,this.initOpt.control.options||{});Object.keys(s).forEach(F=>{this.control[F]=s[F]})}setTimeout(()=>{this.isReady=!0},Y),this.initOpt.stats&&this.initStats(),this.initOpt.css3d&&this.initCss3dRenderer(),this.initOpt.renderType==="loop"?this.animate():this.initOpt.renderType==="change"&&this.control&&this.control.addEventListener("change",this.requestRenderIfNotRequested),this.initListener()});o(this,"onContextLost",e=>{e.preventDefault(),this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)});o(this,"onContextRestored",e=>{e.preventDefault(),this.dispose(),setTimeout(()=>{this.setup(this.selector)},Z)});o(this,"initListener",()=>{this.initOpt.initListener&&window&&window.addEventListener("resize",this.onResize,!1),this.renderer.domElement.addEventListener("webglcontextlost",this.onContextLost,!1),this.renderer.domElement.addEventListener("webglcontextrestored",this.onContextRestored,!1)});o(this,"removeListener",()=>{window&&window.removeEventListener("resize",this.onResize,!1),this.renderer&&this.renderer.domElement&&(this.renderer.domElement.removeEventListener("webglcontextlost",this.onContextLost,!1),this.renderer.domElement.removeEventListener("webglcontextrestored",this.onContextRestored,!1))});o(this,"animate",()=>{this.isDispose||(this.initOpt.renderType==="loop"&&this.onRender(),this.animationFrameId=requestAnimationFrame(this.animate))});o(this,"onRender",()=>{this.isDispose||(this.renderRequested=!1,this.stats&&this.stats.update(),this.control&&this.control.update(),this.renderer.render(this.scene,this.camera),this.css3dRenderer&&this.css3dRenderer.render(this.scene,this.camera),this.eventsListener.onRender&&this.eventsListener.onRender.length&&this.eventsListener.onRender.forEach(e=>e()))});o(this,"requestRenderIfNotRequested",()=>{this.renderRequested||(this.renderRequested=!0,requestAnimationFrame(()=>{this.onRender()}))});o(this,"onResize",()=>{this.resizeTimer&&clearTimeout(this.resizeTimer),this.resizeTimer=setTimeout(()=>{const[e,t]=this.getTargetSize();this.updateCameraFOV(e,t),this.camera.lookAt(this.scene.position),this.renderer.setSize(e,t),this.css3dRenderer&&this.css3dRenderer.setSize(e,t),this.onRender()},X)});o(this,"frameArea",(e,t)=>(console.warn(`[ThreeIns] frameArea() 已弃用,建议使用 setView() 方法。
|
|
2
2
|
旧用法: threeIns.frameArea(model, scale)
|
|
3
3
|
新用法: threeIns.setView(model, ViewType.ISO, { scale })`),this.setView(e,E.ISO,{scale:t,animate:!1,showBox:!1})));o(this,"setView",(e,t,h={})=>{let s=h.scale||.8,F=h.offset||null,b=h.showBox||!1,H=h.boxColor||16776960,O=h.animate!==void 0?h.animate:!0,z=h.duration||1e3;const T=new r.Box3().setFromObject(e);let d=T.getCenter(new r.Vector3);F&&d.add(F);const w={top:new r.Vector3(0,1,0),right:new r.Vector3(2,1,1).normalize(),left:new r.Vector3(-2,1,1).normalize(),iso:new r.Vector3(0,1,1).normalize()},M=w[t]||w.iso,n=T.getSize(new r.Vector3),v=this.camera.aspect,a=r.MathUtils.degToRad(this.camera.fov*.5),P=r.MathUtils.degToRad(80),m=Math.min(Math.atan(Math.tan(a)*v),P);let u;if(t==="top"){const l=n.x*.5/(Math.tan(m)*s),c=n.z*.5/(Math.tan(a)*s);u=Math.max(l,c)}else if(t==="right"||t==="left"){const l=n.y*.5/(Math.tan(a)*s),c=n.z*.5/(Math.tan(a)*s);u=Math.max(l,c)}else{const l=n.x*.5/(Math.tan(m)*s),c=n.y*.5/(Math.tan(a)*s),f=n.z*.5/(Math.tan(a)*s);u=Math.max(l,c,f)}const p=M.clone().multiplyScalar(u).add(d);if(b&&(console.log("📍 相机位置验证:"),console.log(" - 方向向量:",M),console.log(" - 距离:",u.toFixed(2)),console.log(" - 包围盒中心:",d),console.log(" - 计算公式: direction * distance + boxCenter"),console.log(" - 目标位置:",p),console.log(" - 实际相机与中心的距离:",p.clone().sub(d).length().toFixed(2))),b?(this.boxHelper&&(this.scene.remove(this.boxHelper),this.boxHelper=null),this.boxHelper=new r.Box3Helper(T,H),this.scene.add(this.boxHelper)):this.boxHelper&&(this.scene.remove(this.boxHelper),this.boxHelper=null),O){const l=this.camera.position.clone(),c=this.control?this.control.target.clone():new r.Vector3(0,0,0),f=d,V=Date.now(),C=()=>{const A=Date.now()-V,y=Math.min(A/z,1),D=1-Math.pow(1-y,3);if(this.camera.position.lerpVectors(l,p,D),this.control){const L=new r.Vector3;L.lerpVectors(c,f,D),this.control.target.copy(L),this.camera.lookAt(L)}else this.camera.lookAt(d);this.camera.updateProjectionMatrix(),y<1?requestAnimationFrame(C):(this.camera.position.copy(p),this.camera.lookAt(d),this.camera.updateProjectionMatrix(),this.control&&(this.control.target.copy(d),this.control.update()),this.onRender())};C()}else this.camera.position.copy(p),this.camera.lookAt(d),this.camera.updateProjectionMatrix(),this.control&&(this.control.target.copy(d),this.control.update()),this.onRender();if(b){if(console.log("🎥 视角切换信息:"),console.log(" - 视角类型:",t),console.log(" - 相机位置:",p),console.log(" - 观察目标:",d),console.log(" - 方向向量:",M),console.log(" - 包围盒尺寸:",n),console.log(" - 包围盒中心:",T.getCenter(new r.Vector3)),console.log(" - 水平 FOV:",r.MathUtils.radToDeg(m*2).toFixed(2)+"°"),console.log(" - 垂直 FOV:",r.MathUtils.radToDeg(a*2).toFixed(2)+"°"),console.log(" - 宽高比:",v.toFixed(4)),console.log(" - 模型宽度:",n.x.toFixed(2)),console.log(" - 模型高度:",n.y.toFixed(2)),console.log(" - 模型深度:",n.z.toFixed(2)),console.log(" - 传入的 scale 参数:",s),t==="top"){const l=n.x*.5/(Math.tan(m)*s),c=n.z*.5/(Math.tan(a)*s);console.log(" - 模型 X 尺寸 (宽度):",n.x.toFixed(2)),console.log(" - 模型 Z 尺寸 (深度):",n.z.toFixed(2)),console.log(" - tan(halfFovX):",Math.tan(m).toFixed(4)),console.log(" - tan(halfFovY):",Math.tan(a).toFixed(4)),console.log(" - X方向距离计算: (",(n.x*.5).toFixed(2),") / (",Math.tan(m).toFixed(4)," *",s,") =",l.toFixed(2)),console.log(" - Z方向距离计算: (",(n.z*.5).toFixed(2),") / (",Math.tan(a).toFixed(4)," *",s,") =",c.toFixed(2)),console.log(" - X方向距离 (scale="+s+"):",l.toFixed(2)),console.log(" - Z方向距离 (scale="+s+"):",c.toFixed(2))}else if(t==="right"||t==="left"){const l=n.y*.5/(Math.tan(a)*s),c=n.z*.5/(Math.tan(a)*s);console.log(" - Y方向距离 (scale="+s+"):",l.toFixed(2)),console.log(" - Z方向距离 (scale="+s+"):",c.toFixed(2))}else{const l=n.x*.5/(Math.tan(m)*s),c=n.y*.5/(Math.tan(a)*s),f=n.z*.5/(Math.tan(a)*s);console.log(" - 模型 X 尺寸 (宽度):",n.x.toFixed(2)),console.log(" - 模型 Y 尺寸 (高度):",n.y.toFixed(2)),console.log(" - 模型 Z 尺寸 (深度):",n.z.toFixed(2)),console.log(" - tan(halfFovX):",Math.tan(m).toFixed(4)),console.log(" - tan(halfFovY):",Math.tan(a).toFixed(4)),console.log(" - X方向距离计算: (",(n.x*.5).toFixed(2),") / (",Math.tan(m).toFixed(4)," *",s,") =",l.toFixed(2)),console.log(" - Y方向距离计算: (",(n.y*.5).toFixed(2),") / (",Math.tan(a).toFixed(4)," *",s,") =",c.toFixed(2)),console.log(" - Z方向距离计算: (",(n.z*.5).toFixed(2),") / (",Math.tan(a).toFixed(4)," *",s,") =",f.toFixed(2)),console.log(" - X方向距离 (scale="+s+"):",l.toFixed(2)),console.log(" - Y方向距离 (scale="+s+"):",c.toFixed(2)),console.log(" - Z方向距离 (scale="+s+"):",f.toFixed(2)),console.log(" - 最大距离 (Max):",Math.max(l,c,f).toFixed(2))}console.log(" - 最终距离:",u.toFixed(2)),console.log(" - 缩放比例:",s),console.log(" - 动画:",O?"是 ("+z+"ms)":"否")}return{position:p,target:d,distance:u,viewType:t}});o(this,"on",(e,t)=>!e||!t||typeof t!="function"?(console.warn("ThreeIns.on: 无效的参数"),()=>{}):(this.eventsListener[e]||(this.eventsListener[e]=[]),this.eventsListener[e].push(t),()=>this.off(e,t)));this.isReady=!1,this.scene=new r.Scene({}),this.camera=new r.PerspectiveCamera(50,1,.1,2e3),this.renderer=new r.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),this.version=B,this.onContextLost=this.onContextLost.bind(this),this.onContextRestored=this.onContextRestored.bind(this),this.onResize=this.onResize.bind(this),this.animate=this.animate.bind(this),this.resizeTimer=null,this.animationFrameId=null,t&&(this.initOpt=Object.assign(this.initOpt,t)),e&&this.setup(e)}updateCameraFOV(e,t){const h=this.initOpt.initialFov||50,s=Math.tan(Math.PI/180*h/2);this.camera.aspect=e/t,this.camera.fov=360/Math.PI*Math.atan(s*(t/e)),this.camera.updateProjectionMatrix()}initStats(){this.stats=new i.Stats,this.stats.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",this.el.appendChild(this.stats.dom)}initCss3dRenderer(){this.css3dRenderer=new i.CSS3DRenderer;const[e,t]=this.getTargetSize();this.css3dRenderer.setSize(e,t),this.css3dRenderer.domElement.style.position="absolute",this.css3dRenderer.domElement.style.pointerEvents="none",this.css3dRenderer.domElement.style.top=0,this.css3dRenderer.domElement.style.left=0,this.el.appendChild(this.css3dRenderer.domElement)}getTargetSize(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement?[window.innerWidth,window.innerHeight]:this.el?!document.body.contains(this.el)&&(console.warn(`ThreeIns: 缓存的元素已失效,重新查询 ${this.selector}`),this.el=document.querySelector(this.selector),!this.el)?[0,0]:[this.el.clientWidth,this.el.clientHeight]:[0,0]}off(e,t){if(!e){this.eventsListener={};return}this.eventsListener[e]&&(t?this.eventsListener[e]=this.eventsListener[e].filter(h=>h!==t):this.eventsListener[e]=[])}dispose(){this.isDispose||(this.isDispose=!0,this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.resizeTimer&&(clearTimeout(this.resizeTimer),this.resizeTimer=null),this.removeListener(),this.eventsListener={},this.stats&&this.stats.dom&&(this.stats.dom.remove(),this.stats=null),this.css3dRenderer&&(this.css3dRenderer.domElement.remove(),this.css3dRenderer=null),this.boxHelper&&(this.scene.remove(this.boxHelper),this.boxHelper=null),this.scene&&(i.disposeThreeObject(this.scene),this.scene=null),this.renderer&&(this.renderer.dispose(),this.renderer.domElement&&this.renderer.domElement.remove(),this.renderer=null),this.control&&(this.control.dispose(),this.control=null),this.camera=null,this.el=null,this.selector=null,console.log("ThreeIns: 资源已清理完成"))}}o(I,"ViewType",E);exports.intersectColor=g.intersectColor;exports.obbObjects=g.obbObjects;exports.useBatchGLTFLoader=g.useBatchGLTFLoader;exports.useObb=g.useObb;exports.useRaycaster=g.useRaycaster;exports.useThreeJs=g.useThreeJs;exports.CacheMonitor=i.CacheMonitor;exports.ErrorType=i.ErrorType;exports.IDBCache=i.IDBCache;exports.ModelLoadError=i.ModelLoadError;exports.PredictiveLoader=i.PredictiveLoader;exports.ProgressiveSceneBuilder=i.ProgressiveSceneBuilder;exports.RetryHelper=i.RetryHelper;exports.cacheMonitor=i.cacheMonitor;exports.createArrowHelper=i.createArrowHelper;exports.createAxesHelper=i.createAxesHelper;exports.createBox3Helper=i.createBox3Helper;exports.createCameraHelper=i.createCameraHelper;exports.createGridHelper=i.createGridHelper;exports.createMapControls=i.createMapControls;exports.createOrbitControl=i.createOrbitControl;exports.createRaycaster=i.createRaycaster;exports.createStats=i.createStats;exports.dataToObject3D=i.dataToObject3D;exports.dataToObject3DSync=i.dataToObject3DSync;exports.disposeThreeObject=i.disposeThreeObject;exports.object3DToData=i.object3DToData;exports.object3DToDataSync=i.object3DToDataSync;exports.predictiveLoader=i.predictiveLoader;exports.rebuildScene=i.rebuildScene;exports.useGLTFLoader=i.useGLTFLoader;exports.ImageLoader=R.ImageLoader;exports.createInfoPlane=R.createInfoPlane;exports.createTagPlane=R.createTagPlane;exports.getCommonParent=R.getCommonParent;exports.initEnvImage=R.initEnvImage;exports.ModelOptimizer=S.ModelOptimizer;exports.modelOptimizer=S.modelOptimizer;exports.ThreeIns=I;exports.ViewType=E;
|
package/dist/threejs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var H = Object.defineProperty;
|
|
2
2
|
var A = (p, e, t) => e in p ? H(p, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : p[e] = t;
|
|
3
3
|
var o = (p, e, t) => A(p, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { i as se, o as oe, c as ie, b as ne, a as re, u as ae } from "./useBatchGLTFLoader-
|
|
5
|
-
import { d as P, S as j, s as V, j as q } from "./PredictiveLoader
|
|
6
|
-
import { C as ce, E as he, I as de, M as me, P as ue, q as fe, R as pe, n as xe, h as ge, g as Fe, b as Re, c as Me, a as Ee, e as Te, f as be, i as ze, l as we, m as Le, o as ve, k as Oe, p as Ce, r as ye, u as Se } from "./PredictiveLoader
|
|
7
|
-
import { I as Ie, c as He, a as Ae, g as Pe, i as je } from "./ImageLoader-
|
|
4
|
+
import { i as se, o as oe, c as ie, b as ne, a as re, u as ae } from "./useBatchGLTFLoader-B5EUagWI.js";
|
|
5
|
+
import { d as P, S as j, s as V, j as q } from "./PredictiveLoader-CZfMSjv-.js";
|
|
6
|
+
import { C as ce, E as he, I as de, M as me, P as ue, q as fe, R as pe, n as xe, h as ge, g as Fe, b as Re, c as Me, a as Ee, e as Te, f as be, i as ze, l as we, m as Le, o as ve, k as Oe, p as Ce, r as ye, u as Se } from "./PredictiveLoader-CZfMSjv-.js";
|
|
7
|
+
import { I as Ie, c as He, a as Ae, g as Pe, i as je } from "./ImageLoader-Br_nvMOg.js";
|
|
8
8
|
import { ModelOptimizer as qe, modelOptimizer as Xe } from "./modelOptimizer-BRPnM2RH.js";
|
|
9
9
|
import { MathUtils as g, Scene as X, PerspectiveCamera as Y, WebGLRenderer as B, Box3 as Z, Vector3 as d, Box3Helper as _ } from "three";
|
|
10
|
-
const G = "1.4.
|
|
10
|
+
const G = "1.4.1", N = 50, W = 20, k = 20, C = {
|
|
11
11
|
TOP: "top",
|
|
12
12
|
// 俯视(从上往下)
|
|
13
13
|
RIGHT: "right",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Vector3 as b, Matrix3 as re, MathUtils as q, Box3 as J, Matrix4 as ae, Ray as de, WebGLRenderer as me, Scene as pe, PerspectiveCamera as ye, Raycaster as be, Vector2 as ze, Color as xe } from "three";
|
|
2
2
|
import { ref as H, shallowRef as Se, onMounted as we, onUnmounted as ge, nextTick as K } from "vue";
|
|
3
|
-
import { d as ve, j as Me, S as Oe, s as Re, u as Ae } from "./PredictiveLoader
|
|
3
|
+
import { d as ve, j as Me, S as Oe, s as Re, u as Ae } from "./PredictiveLoader-CZfMSjv-.js";
|
|
4
4
|
const l = {
|
|
5
5
|
c: null,
|
|
6
6
|
// center
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const c=require("three"),C=require("vue"),I=require("./PredictiveLoader-
|
|
1
|
+
"use strict";const c=require("three"),C=require("vue"),I=require("./PredictiveLoader-DDxh7dDg.cjs"),u={c:null,u:[new c.Vector3,new c.Vector3,new c.Vector3],e:[]},h={c:null,u:[new c.Vector3,new c.Vector3,new c.Vector3],e:[]},b=[[],[],[]],a=[[],[],[]],y=[],V=new c.Vector3,B=new c.Vector3,j=new c.Vector3,x=new c.Vector3,Z=new c.Vector3,K=new c.Vector3,v=new c.Matrix3,ee=new c.Box3,_=new c.Matrix4,te=new c.Matrix4,ne=new c.Ray;class G{constructor(e=new c.Vector3,r=new c.Vector3,s=new c.Matrix3){this.center=e,this.halfSize=r,this.rotation=s}set(e,r,s){return this.center=e,this.halfSize=r,this.rotation=s,this}copy(e){return this.center.copy(e.center),this.halfSize.copy(e.halfSize),this.rotation.copy(e.rotation),this}clone(){return new this.constructor().copy(this)}getSize(e){return e.copy(this.halfSize).multiplyScalar(2)}clampPoint(e,r){const s=this.halfSize;x.subVectors(e,this.center),this.rotation.extractBasis(V,B,j),r.copy(this.center);const o=c.MathUtils.clamp(x.dot(V),-s.x,s.x);r.add(V.multiplyScalar(o));const t=c.MathUtils.clamp(x.dot(B),-s.y,s.y);r.add(B.multiplyScalar(t));const f=c.MathUtils.clamp(x.dot(j),-s.z,s.z);return r.add(j.multiplyScalar(f)),r}containsPoint(e){return x.subVectors(e,this.center),this.rotation.extractBasis(V,B,j),Math.abs(x.dot(V))<=this.halfSize.x&&Math.abs(x.dot(B))<=this.halfSize.y&&Math.abs(x.dot(j))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(le.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,K),K.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,r=Number.EPSILON){u.c=this.center,u.e[0]=this.halfSize.x,u.e[1]=this.halfSize.y,u.e[2]=this.halfSize.z,this.rotation.extractBasis(u.u[0],u.u[1],u.u[2]),h.c=e.center,h.e[0]=e.halfSize.x,h.e[1]=e.halfSize.y,h.e[2]=e.halfSize.z,e.rotation.extractBasis(h.u[0],h.u[1],h.u[2]);for(let t=0;t<3;t++)for(let f=0;f<3;f++)b[t][f]=u.u[t].dot(h.u[f]);x.subVectors(h.c,u.c),y[0]=x.dot(u.u[0]),y[1]=x.dot(u.u[1]),y[2]=x.dot(u.u[2]);for(let t=0;t<3;t++)for(let f=0;f<3;f++)a[t][f]=Math.abs(b[t][f])+r;let s,o;for(let t=0;t<3;t++)if(s=u.e[t],o=h.e[0]*a[t][0]+h.e[1]*a[t][1]+h.e[2]*a[t][2],Math.abs(y[t])>s+o)return!1;for(let t=0;t<3;t++)if(s=u.e[0]*a[0][t]+u.e[1]*a[1][t]+u.e[2]*a[2][t],o=h.e[t],Math.abs(y[0]*b[0][t]+y[1]*b[1][t]+y[2]*b[2][t])>s+o)return!1;return s=u.e[1]*a[2][0]+u.e[2]*a[1][0],o=h.e[1]*a[0][2]+h.e[2]*a[0][1],!(Math.abs(y[2]*b[1][0]-y[1]*b[2][0])>s+o||(s=u.e[1]*a[2][1]+u.e[2]*a[1][1],o=h.e[0]*a[0][2]+h.e[2]*a[0][0],Math.abs(y[2]*b[1][1]-y[1]*b[2][1])>s+o)||(s=u.e[1]*a[2][2]+u.e[2]*a[1][2],o=h.e[0]*a[0][1]+h.e[1]*a[0][0],Math.abs(y[2]*b[1][2]-y[1]*b[2][2])>s+o)||(s=u.e[0]*a[2][0]+u.e[2]*a[0][0],o=h.e[1]*a[1][2]+h.e[2]*a[1][1],Math.abs(y[0]*b[2][0]-y[2]*b[0][0])>s+o)||(s=u.e[0]*a[2][1]+u.e[2]*a[0][1],o=h.e[0]*a[1][2]+h.e[2]*a[1][0],Math.abs(y[0]*b[2][1]-y[2]*b[0][1])>s+o)||(s=u.e[0]*a[2][2]+u.e[2]*a[0][2],o=h.e[0]*a[1][1]+h.e[1]*a[1][0],Math.abs(y[0]*b[2][2]-y[2]*b[0][2])>s+o)||(s=u.e[0]*a[1][0]+u.e[1]*a[0][0],o=h.e[1]*a[2][2]+h.e[2]*a[2][1],Math.abs(y[1]*b[0][0]-y[0]*b[1][0])>s+o)||(s=u.e[0]*a[1][1]+u.e[1]*a[0][1],o=h.e[0]*a[2][2]+h.e[2]*a[2][0],Math.abs(y[1]*b[0][1]-y[0]*b[1][1])>s+o)||(s=u.e[0]*a[1][2]+u.e[1]*a[0][2],o=h.e[0]*a[2][1]+h.e[1]*a[2][0],Math.abs(y[1]*b[0][2]-y[0]*b[1][2])>s+o))}intersectsPlane(e){this.rotation.extractBasis(V,B,j);const r=this.halfSize.x*Math.abs(e.normal.dot(V))+this.halfSize.y*Math.abs(e.normal.dot(B))+this.halfSize.z*Math.abs(e.normal.dot(j)),s=e.normal.dot(this.center)-e.constant;return Math.abs(s)<=r}intersectRay(e,r){return this.getSize(Z),ee.setFromCenterAndSize(x.set(0,0,0),Z),_.setFromMatrix3(this.rotation),_.setPosition(this.center),te.copy(_).invert(),ne.copy(e).applyMatrix4(te),ne.intersectBox(ee,r)?r.applyMatrix4(_):null}intersectsRay(e){return this.intersectRay(e,x)!==null}fromBox3(e){return e.getCenter(this.center),e.getSize(this.halfSize).multiplyScalar(.5),this.rotation.identity(),this}equals(e){return e.center.equals(this.center)&&e.halfSize.equals(this.halfSize)&&e.rotation.equals(this.rotation)}applyMatrix4(e){const r=e.elements;let s=x.set(r[0],r[1],r[2]).length();const o=x.set(r[4],r[5],r[6]).length(),t=x.set(r[8],r[9],r[10]).length();e.determinant()<0&&(s=-s),v.setFromMatrix4(e);const l=1/s,n=1/o,i=1/t;return v.elements[0]*=l,v.elements[1]*=l,v.elements[2]*=l,v.elements[3]*=n,v.elements[4]*=n,v.elements[5]*=n,v.elements[6]*=i,v.elements[7]*=i,v.elements[8]*=i,this.rotation.multiply(v),this.halfSize.x*=s,this.halfSize.y*=o,this.halfSize.z*=t,x.setFromMatrixPosition(e),this.center.add(x),this}}const le=new G,ue={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:c.MathUtils.degToRad(60)};function he(F,e){typeof console<"u"&&console.warn&&console.warn(`[ThreeIns] useThreeJs() Hook 已弃用,建议使用 ThreeIns 类代替。
|
|
2
2
|
旧用法: const { scene, camera } = useThreeJs(selector, options)
|
|
3
3
|
新用法: const threeIns = new ThreeIns(selector, options)
|
|
4
4
|
|
package/dist/utils.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PredictiveLoader-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PredictiveLoader-DDxh7dDg.cjs"),r=require("./ImageLoader-DL32KyTh.cjs"),t=require("./modelOptimizer-A0Cs6f9e.cjs");exports.CacheMonitor=e.CacheMonitor;exports.ErrorType=e.ErrorType;exports.ModelLoadError=e.ModelLoadError;exports.PredictiveLoader=e.PredictiveLoader;exports.ProgressiveSceneBuilder=e.ProgressiveSceneBuilder;exports.RetryHelper=e.RetryHelper;exports.cacheMonitor=e.cacheMonitor;exports.createArrowHelper=e.createArrowHelper;exports.createAxesHelper=e.createAxesHelper;exports.createBox3Helper=e.createBox3Helper;exports.createCameraHelper=e.createCameraHelper;exports.createGridHelper=e.createGridHelper;exports.createMapControls=e.createMapControls;exports.createOrbitControl=e.createOrbitControl;exports.createRaycaster=e.createRaycaster;exports.createStats=e.createStats;exports.dataToObject3D=e.dataToObject3D;exports.dataToObject3DSync=e.dataToObject3DSync;exports.disposeThreeObject=e.disposeThreeObject;exports.object3DToData=e.object3DToData;exports.object3DToDataSync=e.object3DToDataSync;exports.predictiveLoader=e.predictiveLoader;exports.rebuildScene=e.rebuildScene;exports.ImageLoader=r.ImageLoader;exports.createInfoPlane=r.createInfoPlane;exports.createTagPlane=r.createTagPlane;exports.getCommonParent=r.getCommonParent;exports.initEnvImage=r.initEnvImage;exports.ModelOptimizer=t.ModelOptimizer;exports.modelOptimizer=t.modelOptimizer;
|
package/dist/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as r, E as t, M as o, P as s, q as c, R as i, n as d, h as l, g as n, b as p, c as m, a as b, e as g, d as T, f as j, i as C, l as D, m as H, j as M, o as O, k as P, p as f, r as x } from "./PredictiveLoader
|
|
2
|
-
import { I as S, c as h, a as v, g as E, i as I } from "./ImageLoader-
|
|
1
|
+
import { C as r, E as t, M as o, P as s, q as c, R as i, n as d, h as l, g as n, b as p, c as m, a as b, e as g, d as T, f as j, i as C, l as D, m as H, j as M, o as O, k as P, p as f, r as x } from "./PredictiveLoader-CZfMSjv-.js";
|
|
2
|
+
import { I as S, c as h, a as v, g as E, i as I } from "./ImageLoader-Br_nvMOg.js";
|
|
3
3
|
import { ModelOptimizer as R, modelOptimizer as u } from "./modelOptimizer-BRPnM2RH.js";
|
|
4
4
|
export {
|
|
5
5
|
r as CacheMonitor,
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const u=require("three"),He=require("dexie");var B=typeof document<"u"?document.currentScript:null;function Fe(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const S=Fe(u);var W=function(){var r=0,e=document.createElement("div");e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",function(d){d.preventDefault(),s(++r%e.children.length)},!1);function t(d){return e.appendChild(d.dom),d}function s(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===d?"block":"none";r=d}var n=(performance||Date).now(),i=n,o=0,c=t(new W.Panel("FPS","#0ff","#002")),a=t(new W.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var l=t(new W.Panel("MB","#f08","#201"));return s(0),{REVISION:16,dom:e,addPanel:t,showPanel:s,begin:function(){n=(performance||Date).now()},end:function(){o++;var d=(performance||Date).now();if(a.update(d-n,200),d>=i+1e3&&(c.update(o*1e3/(d-i),100),i=d,o=0,l)){var h=performance.memory;l.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){n=this.end()},domElement:e,setMode:s}};W.Panel=function(r,e,t){var s=1/0,n=0,i=Math.round,o=i(window.devicePixelRatio||1),c=80*o,a=48*o,l=3*o,d=2*o,h=3*o,g=15*o,p=74*o,y=30*o,_=document.createElement("canvas");_.width=c,_.height=a,_.style.cssText="width:80px;height:48px";var m=_.getContext("2d");return m.font="bold "+9*o+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=t,m.fillRect(0,0,c,a),m.fillStyle=e,m.fillText(r,l,d),m.fillRect(h,g,p,y),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(h,g,p,y),{dom:_,update:function(f,T){s=Math.min(s,f),n=Math.max(n,f),m.fillStyle=t,m.globalAlpha=1,m.fillRect(0,0,c,g),m.fillStyle=e,m.fillText(i(f)+" "+r+" ("+i(s)+"-"+i(n)+")",l,d),m.drawImage(_,h+o,g,p-o,y,h,g,p-o,y),m.fillRect(h+p-o,g,o,y),m.fillStyle=t,m.globalAlpha=.9,m.fillRect(h+p-o,g,o,i((1-f/T)*y))}}};const ge=new u.Vector3,Ue=new u.Quaternion,ye=new u.Vector3;class je extends u.Object3D{constructor(e=document.createElement("div")){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position="absolute",this.element.style.pointerEvents="auto",this.element.style.userSelect="none",this.element.setAttribute("draggable",!1),this.addEventListener("removed",function(){this.traverse(function(t){t.element instanceof t.element.ownerDocument.defaultView.Element&&t.element.parentNode!==null&&t.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}}class Ge extends je{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}}const I=new u.Matrix4,Be=new u.Matrix4;class ze{constructor(e={}){const t=this;let s,n,i,o;const c={camera:{style:""},objects:new WeakMap},a=e.element!==void 0?e.element:document.createElement("div");a.style.overflow="hidden",this.domElement=a;const l=document.createElement("div");l.style.transformOrigin="0 0",l.style.pointerEvents="none",a.appendChild(l);const d=document.createElement("div");d.style.transformStyle="preserve-3d",l.appendChild(d),this.getSize=function(){return{width:s,height:n}},this.render=function(m,f){const T=f.projectionMatrix.elements[5]*o;f.view&&f.view.enabled?(l.style.transform=`translate( ${-f.view.offsetX*(s/f.view.width)}px, ${-f.view.offsetY*(n/f.view.height)}px )`,l.style.transform+=`scale( ${f.view.fullWidth/f.view.width}, ${f.view.fullHeight/f.view.height} )`):l.style.transform="",m.matrixWorldAutoUpdate===!0&&m.updateMatrixWorld(),f.parent===null&&f.matrixWorldAutoUpdate===!0&&f.updateMatrixWorld();let w,b;f.isOrthographicCamera&&(w=-(f.right+f.left)/2,b=(f.top+f.bottom)/2);const M=f.view&&f.view.enabled?f.view.height/f.view.fullHeight:1,A=f.isOrthographicCamera?`scale( ${M} )scale(`+T+")translate("+h(w)+"px,"+h(b)+"px)"+g(f.matrixWorldInverse):`scale( ${M} )translateZ(`+T+"px)"+g(f.matrixWorldInverse),R=(f.isPerspectiveCamera?"perspective("+T+"px) ":"")+A+"translate("+i+"px,"+o+"px)";c.camera.style!==R&&(d.style.transform=R,c.camera.style=R),_(m,m,f)},this.setSize=function(m,f){s=m,n=f,i=s/2,o=n/2,a.style.width=m+"px",a.style.height=f+"px",l.style.width=m+"px",l.style.height=f+"px",d.style.width=m+"px",d.style.height=f+"px"};function h(m){return Math.abs(m)<1e-10?0:m}function g(m){const f=m.elements;return"matrix3d("+h(f[0])+","+h(-f[1])+","+h(f[2])+","+h(f[3])+","+h(f[4])+","+h(-f[5])+","+h(f[6])+","+h(f[7])+","+h(f[8])+","+h(-f[9])+","+h(f[10])+","+h(f[11])+","+h(f[12])+","+h(-f[13])+","+h(f[14])+","+h(f[15])+")"}function p(m){const f=m.elements;return"translate(-50%,-50%)"+("matrix3d("+h(f[0])+","+h(f[1])+","+h(f[2])+","+h(f[3])+","+h(-f[4])+","+h(-f[5])+","+h(-f[6])+","+h(-f[7])+","+h(f[8])+","+h(f[9])+","+h(f[10])+","+h(f[11])+","+h(f[12])+","+h(f[13])+","+h(f[14])+","+h(f[15])+")")}function y(m){m.isCSS3DObject&&(m.element.style.display="none");for(let f=0,T=m.children.length;f<T;f++)y(m.children[f])}function _(m,f,T,w){if(m.visible===!1){y(m);return}if(m.isCSS3DObject){const b=m.layers.test(T.layers)===!0,M=m.element;if(M.style.display=b===!0?"":"none",b===!0){m.onBeforeRender(t,f,T);let A;m.isCSS3DSprite?(I.copy(T.matrixWorldInverse),I.transpose(),m.rotation2D!==0&&I.multiply(Be.makeRotationZ(m.rotation2D)),m.matrixWorld.decompose(ge,Ue,ye),I.setPosition(ge),I.scale(ye),I.elements[3]=0,I.elements[7]=0,I.elements[11]=0,I.elements[15]=1,A=p(I)):A=p(m.matrixWorld);const L=c.objects.get(m);if(L===void 0||L.style!==A){M.style.transform=A;const R={style:A};c.objects.set(m,R)}M.parentNode!==d&&d.appendChild(M),m.onAfterRender(t,f,T)}}for(let b=0,M=m.children.length;b<M;b++)_(m.children[b],f,T)}}}const _e={type:"change"},fe={type:"start"},Le={type:"end"},$=new u.Ray,Te=new u.Plane,Ke=Math.cos(70*u.MathUtils.DEG2RAD),P=new u.Vector3,D=2*Math.PI,x={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},ne=1e-6;class Pe extends u.Controls{constructor(e,t=null){super(e,t),this.state=x.NONE,this.target=new u.Vector3,this.cursor=new u.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,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={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:u.MOUSE.ROTATE,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.PAN},this.touches={ONE:u.TOUCH.ROTATE,TWO:u.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new u.Vector3,this._lastQuaternion=new u.Quaternion,this._lastTargetPosition=new u.Vector3,this._quat=new u.Quaternion().setFromUnitVectors(e.up,new u.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new u.Spherical,this._sphericalDelta=new u.Spherical,this._scale=1,this._panOffset=new u.Vector3,this._rotateStart=new u.Vector2,this._rotateEnd=new u.Vector2,this._rotateDelta=new u.Vector2,this._panStart=new u.Vector2,this._panEnd=new u.Vector2,this._panDelta=new u.Vector2,this._dollyStart=new u.Vector2,this._dollyEnd=new u.Vector2,this._dollyDelta=new u.Vector2,this._dollyDirection=new u.Vector3,this._mouse=new u.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=We.bind(this),this._onPointerDown=Ve.bind(this),this._onPointerUp=Xe.bind(this),this._onContextMenu=et.bind(this),this._onMouseWheel=Ze.bind(this),this._onKeyDown=$e.bind(this),this._onTouchStart=Qe.bind(this),this._onTouchMove=Je.bind(this),this._onMouseDown=Ye.bind(this),this._onMouseMove=qe.bind(this),this._interceptControlDown=tt.bind(this),this._interceptControlUp=st.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){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,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.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="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(_e),this.update(),this.state=x.NONE}update(e=null){const t=this.object.position;P.copy(t).sub(this.target),P.applyQuaternion(this._quat),this._spherical.setFromVector3(P),this.autoRotate&&this.state===x.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);let s=this.minAzimuthAngle,n=this.maxAzimuthAngle;isFinite(s)&&isFinite(n)&&(s<-Math.PI?s+=D:s>Math.PI&&(s-=D),n<-Math.PI?n+=D:n>Math.PI&&(n-=D),s<=n?this._spherical.theta=Math.max(s,Math.min(n,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(s+n)/2?Math.max(s,this._spherical.theta):Math.min(n,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);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(P.setFromSpherical(this._spherical),P.applyQuaternion(this._quatInverse),t.copy(this.target).add(P),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){let o=null;if(this.object.isPerspectiveCamera){const c=P.length();o=this._clampDistance(c*this._scale);const a=c-o;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),i=!!a}else if(this.object.isOrthographicCamera){const c=new u.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object);const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=a!==this.object.zoom;const l=new u.Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object),this.object.position.sub(l).add(c),this.object.updateMatrixWorld(),o=P.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):($.origin.copy(this.object.position),$.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot($.direction))<Ke?this.object.lookAt(this.target):(Te.setFromNormalAndCoplanarPoint(this.object.up,this.target),$.intersectPlane(Te,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>ne||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ne||this._lastTargetPosition.distanceToSquared(this.target)>ne?(this.dispatchEvent(_e),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?D/60*this.autoRotateSpeed*e:D/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){P.setFromMatrixColumn(t,0),P.multiplyScalar(-e),this._panOffset.add(P)}_panUp(e,t){this.screenSpacePanning===!0?P.setFromMatrixColumn(t,1):(P.setFromMatrixColumn(t,0),P.crossVectors(this.object.up,P)),P.multiplyScalar(e),this._panOffset.add(P)}_pan(e,t){const s=this.domElement;if(this.object.isPerspectiveCamera){const n=this.object.position;P.copy(n).sub(this.target);let i=P.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/s.clientHeight,this.object.matrix),this._panUp(2*t*i/s.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/s.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/s.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){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)}_dollyIn(e){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)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const s=this.domElement.getBoundingClientRect(),n=e-s.left,i=t-s.top,o=s.width,c=s.height;this._mouse.x=n/o*2-1,this._mouse.y=-(i/c)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(D*this._rotateDelta.x/t.clientHeight),this._rotateUp(D*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){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()}_handleMouseMovePan(e){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()}_handleMouseWheel(e){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()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-D*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._rotateStart.set(s,n)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panStart.set(s,n)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const s=this._getSecondPointerPosition(e),n=.5*(e.pageX+s.x),i=.5*(e.pageY+s.y);this._rotateEnd.set(n,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(D*this._rotateDelta.x/t.clientHeight),this._rotateUp(D*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),s=.5*(e.pageX+t.x),n=.5*(e.pageY+t.y);this._panEnd.set(s,n)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),s=e.pageX-t.x,n=e.pageY-t.y,i=Math.sqrt(s*s+n*n);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,c=(e.pageY+t.y)*.5;this._updateZoomParameters(o,c)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new u.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,s={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:s.deltaY*=16;break;case 2:s.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(s.deltaY*=10),s}}function Ve(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function We(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function Xe(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Le),this.state=x.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Ye(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case u.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=x.DOLLY;break;case u.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=x.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=x.ROTATE}break;case u.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=x.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=x.PAN}break;default:this.state=x.NONE}this.state!==x.NONE&&this.dispatchEvent(fe)}function qe(r){switch(this.state){case x.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case x.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case x.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function Ze(r){this.enabled===!1||this.enableZoom===!1||this.state!==x.NONE||(r.preventDefault(),this.dispatchEvent(fe),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(Le))}function $e(r){this.enabled!==!1&&this._handleKeyDown(r)}function Qe(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case u.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=x.TOUCH_ROTATE;break;case u.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=x.TOUCH_PAN;break;default:this.state=x.NONE}break;case 2:switch(this.touches.TWO){case u.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=x.TOUCH_DOLLY_PAN;break;case u.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=x.TOUCH_DOLLY_ROTATE;break;default:this.state=x.NONE}break;default:this.state=x.NONE}this.state!==x.NONE&&this.dispatchEvent(fe)}function Je(r){switch(this._trackPointer(r),this.state){case x.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case x.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case x.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case x.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=x.NONE}}function et(r){this.enabled!==!1&&r.preventDefault()}function tt(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function st(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class nt extends Pe{constructor(e,t){super(e,t),this.screenSpacePanning=!1,this.mouseButtons={LEFT:u.MOUSE.PAN,MIDDLE:u.MOUSE.DOLLY,RIGHT:u.MOUSE.ROTATE},this.touches={ONE:u.TOUCH.PAN,TWO:u.TOUCH.DOLLY_ROTATE}}}function it(r){return new u.CameraHelper(r)}function ot(r=150,...e){return new u.GridHelper(r,r/10,...e)}function rt(r){return new u.BoxHelper(r,16776960)}function at(r,e){return new Pe(r,e)}function ct(r,e){return new nt(r,e)}function lt(){const r=new u.Raycaster,e=new u.Vector2(0,0);return{raycaster:r,pointer:e}}function ht(r=10){return new u.AxesHelper(r)}function ut(r=new u.Vector3(1,1,1),e=new u.Vector3(10,10,10),t=5,s=16776960){return r.normalize(),new u.ArrowHelper(r,e,t,s)}function dt(){const r=new W;return r.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r}function be(r,e){if(e===u.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===u.TriangleFanDrawMode||e===u.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],c=r.getAttribute("position");if(c!==void 0){for(let a=0;a<c.count;a++)o.push(a);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const s=t.count-2,n=[];if(e===u.TriangleFanDrawMode)for(let o=1;o<=s;o++)n.push(t.getX(0)),n.push(t.getX(o)),n.push(t.getX(o+1));else for(let o=0;o<s;o++)o%2===0?(n.push(t.getX(o)),n.push(t.getX(o+1)),n.push(t.getX(o+2))):(n.push(t.getX(o+2)),n.push(t.getX(o+1)),n.push(t.getX(o)));n.length/3!==s&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=r.clone();return i.setIndex(n),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}const ie=new WeakMap;class ft extends u.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,s,n){const i=new u.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,o=>{this.parse(o,t,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,u.SRGBColorSpace,s).catch(s)}decodeDracoFile(e,t,s,n,i=u.LinearSRGBColorSpace,o=()=>{}){const c={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:i};return this.decodeGeometry(e,c).then(t).catch(o)}decodeGeometry(e,t){const s=JSON.stringify(t);if(ie.has(e)){const a=ie.get(e);if(a.key===s)return a.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let n;const i=this.workerNextTaskID++,o=e.byteLength,c=this._getWorker(i,o).then(a=>(n=a,new Promise((l,d)=>{n._callbacks[i]={resolve:l,reject:d},n.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))).then(a=>this._createGeometry(a.geometry));return c.catch(()=>!0).then(()=>{n&&i&&this._releaseTask(n,i)}),ie.set(e,{key:s,promise:c}),c}_createGeometry(e){const t=new u.BufferGeometry;e.index&&t.setIndex(new u.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s],i=n.name,o=n.array,c=n.itemSize,a=new u.BufferAttribute(o,c);i==="color"&&(this._assignVertexColorSpace(a,n.vertexColorSpace),a.normalized=!(o instanceof Float32Array)),t.setAttribute(i,a)}return t}_assignVertexColorSpace(e,t){if(t!==u.SRGBColorSpace)return;const s=new u.Color;for(let n=0,i=e.count;n<i;n++)s.fromBufferAttribute(e,n),u.ColorManagement.colorSpaceToWorking(s,u.SRGBColorSpace),e.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new u.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((n,i)=>{s.load(e,n,void 0,i)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(s=>{const n=s[0];e||(this.decoderConfig.wasmBinary=s[1]);const i=pt.toString(),o=["/* draco decoder */",n,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join(`
|
|
2
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const n=new Worker(this.workerSourceURL);n._callbacks={},n._taskCosts={},n._taskLoad=0,n.postMessage({type:"init",decoderConfig:this.decoderConfig}),n.onmessage=function(i){const o=i.data;switch(o.type){case"decode":n._callbacks[o.id].resolve(o);break;case"error":n._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(n)}else this.workerPool.sort(function(n,i){return n._taskLoad>i._taskLoad?-1:1});const s=this.workerPool[this.workerPool.length-1];return s._taskCosts[e]=t,s._taskLoad+=t,s})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function pt(){let r,e;onmessage=function(o){const c=o.data;switch(c.type){case"init":r=c.decoderConfig,e=new Promise(function(d){r.onModuleLoaded=function(h){d({draco:h})},DracoDecoderModule(r)});break;case"decode":const a=c.buffer,l=c.taskConfig;e.then(d=>{const h=d.draco,g=new h.Decoder;try{const p=t(h,g,new Int8Array(a),l),y=p.attributes.map(_=>_.array.buffer);p.index&&y.push(p.index.array.buffer),self.postMessage({type:"decode",id:c.id,geometry:p},y)}catch(p){console.error(p),self.postMessage({type:"error",id:c.id,error:p.message})}finally{h.destroy(g)}});break}};function t(o,c,a,l){const d=l.attributeIDs,h=l.attributeTypes;let g,p;const y=c.GetEncodedGeometryType(a);if(y===o.TRIANGULAR_MESH)g=new o.Mesh,p=c.DecodeArrayToMesh(a,a.byteLength,g);else if(y===o.POINT_CLOUD)g=new o.PointCloud,p=c.DecodeArrayToPointCloud(a,a.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const _={index:null,attributes:[]};for(const m in d){const f=self[h[m]];let T,w;if(l.useUniqueIDs)w=d[m],T=c.GetAttributeByUniqueId(g,w);else{if(w=c.GetAttributeId(g,o[d[m]]),w===-1)continue;T=c.GetAttribute(g,w)}const b=n(o,c,g,m,f,T);m==="color"&&(b.vertexColorSpace=l.vertexColorSpace),_.attributes.push(b)}return y===o.TRIANGULAR_MESH&&(_.index=s(o,c,g)),o.destroy(g),_}function s(o,c,a){const d=a.num_faces()*3,h=d*4,g=o._malloc(h);c.GetTrianglesUInt32Array(a,h,g);const p=new Uint32Array(o.HEAPF32.buffer,g,d).slice();return o._free(g),{array:p,itemSize:1}}function n(o,c,a,l,d,h){const g=h.num_components(),y=a.num_points()*g,_=y*d.BYTES_PER_ELEMENT,m=i(o,d),f=o._malloc(_);c.GetAttributeDataArrayForAllPoints(a,h,m,_,f);const T=new d(o.HEAPF32.buffer,f,y).slice();return o._free(f),{name:l,array:T,itemSize:g}}function i(o,c){switch(c){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}class mt extends u.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new bt(t)}),this.register(function(t){return new wt(t)}),this.register(function(t){return new Ct(t)}),this.register(function(t){return new Dt(t)}),this.register(function(t){return new Ot(t)}),this.register(function(t){return new St(t)}),this.register(function(t){return new xt(t)}),this.register(function(t){return new Mt(t)}),this.register(function(t){return new Rt(t)}),this.register(function(t){return new Tt(t)}),this.register(function(t){return new At(t)}),this.register(function(t){return new Et(t)}),this.register(function(t){return new Pt(t)}),this.register(function(t){return new Lt(t)}),this.register(function(t){return new yt(t)}),this.register(function(t){return new It(t)}),this.register(function(t){return new kt(t)})}load(e,t,s,n){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const l=u.LoaderUtils.extractUrlBase(e);o=u.LoaderUtils.resolveURL(l,this.path)}else o=u.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const c=function(l){n?n(l):console.error(l),i.manager.itemError(e),i.manager.itemEnd(e)},a=new u.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(l){try{i.parse(l,o,function(d){t(d),i.manager.itemEnd(e)},c)}catch(d){c(d)}},s,c)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s,n){let i;const o={},c={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===Ce){try{o[E.KHR_BINARY_GLTF]=new Nt(e)}catch(h){n&&n(h);return}i=JSON.parse(o[E.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const l=new Yt(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let d=0;d<this.pluginCallbacks.length;d++){const h=this.pluginCallbacks[d](l);h.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),c[h.name]=h,o[h.name]=!0}if(i.extensionsUsed)for(let d=0;d<i.extensionsUsed.length;++d){const h=i.extensionsUsed[d],g=i.extensionsRequired||[];switch(h){case E.KHR_MATERIALS_UNLIT:o[h]=new _t;break;case E.KHR_DRACO_MESH_COMPRESSION:o[h]=new vt(i,this.dracoLoader);break;case E.KHR_TEXTURE_TRANSFORM:o[h]=new Ht;break;case E.KHR_MESH_QUANTIZATION:o[h]=new Ft;break;default:g.indexOf(h)>=0&&c[h]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+h+'".')}}l.setExtensions(o),l.setPlugins(c),l.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,i){s.parse(e,t,n,i)})}}function gt(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const E={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class yt{constructor(e){this.parser=e,this.name=E.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s<n;s++){const i=t[s];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let l;const d=new u.Color(16777215);a.color!==void 0&&d.setRGB(a.color[0],a.color[1],a.color[2],u.LinearSRGBColorSpace);const h=a.range!==void 0?a.range:0;switch(a.type){case"directional":l=new u.DirectionalLight(d),l.target.position.set(0,0,-1),l.add(l.target);break;case"point":l=new u.PointLight(d),l.distance=h;break;case"spot":l=new u.SpotLight(d),l.distance=h,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,l.angle=a.spot.outerConeAngle,l.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,l.target.position.set(0,0,-1),l.add(l.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return l.position.set(0,0,0),N(l,a),a.intensity!==void 0&&(l.intensity=a.intensity),l.name=t.createUniqueName(a.name||"light_"+e),n=Promise.resolve(l),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,i=s.json.nodes[e],c=(i.extensions&&i.extensions[this.name]||{}).light;return c===void 0?null:this._loadLight(c).then(function(a){return s._getNodeRef(t.cache,c,a)})}}class _t{constructor(){this.name=E.KHR_MATERIALS_UNLIT}getMaterialType(){return u.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new u.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],u.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",i.baseColorTexture,u.SRGBColorSpace))}return Promise.all(n)}}class Tt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class bt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const c=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new u.Vector2(c,c)}return Promise.all(i)}}class wt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Et{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class St{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new u.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const c=o.sheenColorFactor;t.sheenColor.setRGB(c[0],c[1],c[2],u.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,u.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class xt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Mt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const c=o.attenuationColor||[1,1,1];return t.attenuationColor=new u.Color().setRGB(c[0],c[1],c[2],u.LinearSRGBColorSpace),Promise.all(i)}}class Rt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class At{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const c=o.specularColorFactor||[1,1,1];return t.specularColor=new u.Color().setRGB(c[0],c[1],c[2],u.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,u.SRGBColorSpace)),Promise.all(i)}}class Lt{constructor(e){this.parser=e,this.name=E.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class Pt{constructor(e){this.parser=e,this.name=E.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:u.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=[],o=n.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Ct{constructor(e){this.parser=e,this.name=E.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,s=t.json,n=s.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const i=n.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(s.extensionsRequired&&s.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class Dt{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],c=n.images[o.source];let a=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(a=l)}return s.loadTextureImage(e,o.source,a)}}class Ot{constructor(e){this.parser=e,this.name=E.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,i=n.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],c=n.images[o.source];let a=s.textureLoader;if(c.uri){const l=s.options.manager.getHandler(c.uri);l!==null&&(a=l)}return s.loadTextureImage(e,o.source,a)}}class It{constructor(e){this.name=E.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],i=this.parser.getDependency("buffer",n.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(c){const a=n.byteOffset||0,l=n.byteLength||0,d=n.count,h=n.byteStride,g=new Uint8Array(c,a,l);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(d,h,g,n.mode,n.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(d*h);return o.decodeGltfBuffer(new Uint8Array(p),d,h,g,n.mode,n.filter),p})})}else return null}}class kt{constructor(e){this.name=E.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const l of n.primitives)if(l.mode!==O.TRIANGLES&&l.mode!==O.TRIANGLE_STRIP&&l.mode!==O.TRIANGLE_FAN&&l.mode!==void 0)return null;const o=s.extensions[this.name].attributes,c=[],a={};for(const l in o)c.push(this.parser.getDependency("accessor",o[l]).then(d=>(a[l]=d,a[l])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(l=>{const d=l.pop(),h=d.isGroup?d.children:[d],g=l[0].count,p=[];for(const y of h){const _=new u.Matrix4,m=new u.Vector3,f=new u.Quaternion,T=new u.Vector3(1,1,1),w=new u.InstancedMesh(y.geometry,y.material,g);for(let b=0;b<g;b++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,b),a.ROTATION&&f.fromBufferAttribute(a.ROTATION,b),a.SCALE&&T.fromBufferAttribute(a.SCALE,b),w.setMatrixAt(b,_.compose(m,f,T));for(const b in a)if(b==="_COLOR_0"){const M=a[b];w.instanceColor=new u.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&y.geometry.setAttribute(b,a[b]);u.Object3D.prototype.copy.call(w,y),this.parser.assignFinalMaterial(w),p.push(w)}return d.isGroup?(d.clear(),d.add(...p),d):p[0]}))}}const Ce="glTF",q=12,we={JSON:1313821514,BIN:5130562};class Nt{constructor(e){this.name=E.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,q),s=new TextDecoder;if(this.header={magic:s.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Ce)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-q,i=new DataView(e,q);let o=0;for(;o<n;){const c=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,a===we.JSON){const l=new Uint8Array(e,q+o,c);this.content=s.decode(l)}else if(a===we.BIN){const l=q+o;this.body=e.slice(l,l+c)}o+=c}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class vt{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=E.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,c={},a={},l={};for(const d in o){const h=he[d]||d.toLowerCase();c[h]=o[d]}for(const d in e.attributes){const h=he[d]||d.toLowerCase();if(o[d]!==void 0){const g=s.accessors[e.attributes[d]],p=X[g.componentType];l[h]=p.name,a[h]=g.normalized===!0}}return t.getDependency("bufferView",i).then(function(d){return new Promise(function(h,g){n.decodeDracoFile(d,function(p){for(const y in p.attributes){const _=p.attributes[y],m=a[y];m!==void 0&&(_.normalized=m)}h(p)},c,l,u.LinearSRGBColorSpace,g)})})}}class Ht{constructor(){this.name=E.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ft{constructor(){this.name=E.KHR_MESH_QUANTIZATION}}class De extends u.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,i=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[i+o];return t}interpolate_(e,t,s,n){const i=this.resultBuffer,o=this.sampleValues,c=this.valueSize,a=c*2,l=c*3,d=n-t,h=(s-t)/d,g=h*h,p=g*h,y=e*l,_=y-l,m=-2*p+3*g,f=p-g,T=1-m,w=f-g+h;for(let b=0;b!==c;b++){const M=o[_+b+c],A=o[_+b+a]*d,L=o[y+b+c],R=o[y+b]*d;i[b]=T*M+w*A+m*L+f*R}return i}}const Ut=new u.Quaternion;class jt extends De{interpolate_(e,t,s,n){const i=super.interpolate_(e,t,s,n);return Ut.fromArray(i).normalize().toArray(i),i}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},X={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Ee={9728:u.NearestFilter,9729:u.LinearFilter,9984:u.NearestMipmapNearestFilter,9985:u.LinearMipmapNearestFilter,9986:u.NearestMipmapLinearFilter,9987:u.LinearMipmapLinearFilter},Se={33071:u.ClampToEdgeWrapping,33648:u.MirroredRepeatWrapping,10497:u.RepeatWrapping},oe={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},he={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},H={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Gt={CUBICSPLINE:void 0,LINEAR:u.InterpolateLinear,STEP:u.InterpolateDiscrete},re={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Bt(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new u.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:u.FrontSide})),r.DefaultMaterial}function j(r,e,t){for(const s in t.extensions)r[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function N(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function zt(r,e,t){let s=!1,n=!1,i=!1;for(let l=0,d=e.length;l<d;l++){const h=e[l];if(h.POSITION!==void 0&&(s=!0),h.NORMAL!==void 0&&(n=!0),h.COLOR_0!==void 0&&(i=!0),s&&n&&i)break}if(!s&&!n&&!i)return Promise.resolve(r);const o=[],c=[],a=[];for(let l=0,d=e.length;l<d;l++){const h=e[l];if(s){const g=h.POSITION!==void 0?t.getDependency("accessor",h.POSITION):r.attributes.position;o.push(g)}if(n){const g=h.NORMAL!==void 0?t.getDependency("accessor",h.NORMAL):r.attributes.normal;c.push(g)}if(i){const g=h.COLOR_0!==void 0?t.getDependency("accessor",h.COLOR_0):r.attributes.color;a.push(g)}}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(a)]).then(function(l){const d=l[0],h=l[1],g=l[2];return s&&(r.morphAttributes.position=d),n&&(r.morphAttributes.normal=h),i&&(r.morphAttributes.color=g),r.morphTargetsRelative=!0,r})}function Kt(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)r.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Vt(r){let e;const t=r.extensions&&r.extensions[E.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ae(t.attributes):e=r.indices+":"+ae(r.attributes)+":"+r.mode,r.targets!==void 0)for(let s=0,n=r.targets.length;s<n;s++)e+=":"+ae(r.targets[s]);return e}function ae(r){let e="";const t=Object.keys(r).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+r[t[s]]+";";return e}function ue(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Wt(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Xt=new u.Matrix4;class Yt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new gt,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=-1,i=!1,o=-1;if(typeof navigator<"u"){const c=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(c)===!0;const a=c.match(/Version\/(\d+)/);n=s&&a?parseInt(a[1],10):-1,i=c.indexOf("Firefox")>-1,o=i?c.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||i&&o<98?this.textureLoader=new u.TextureLoader(this.options.manager):this.textureLoader=new u.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new u.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(o){const c={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return j(i,c,n),N(c,n),Promise.all(s._invokeAll(function(a){return a.afterRoot&&a.afterRoot(c)})).then(function(){for(const a of c.scenes)a.updateMatrixWorld();e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const o=t[n].joints;for(let c=0,a=o.length;c<a;c++)e[o[c]].isBone=!0}for(let n=0,i=e.length;n<i;n++){const o=e[n];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(s[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,s){if(e.refs[t]<=1)return s;const n=s.clone(),i=(o,c)=>{const a=this.associations.get(o);a!=null&&this.associations.set(c,a);for(const[l,d]of o.children.entries())i(d,c.children[l])};return i(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s<t.length;s++){const n=e(t[s]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const s=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i&&s.push(i)}return s}getDependency(e,t){const s=e+":"+t;let n=this.cache.get(s);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":n=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e);break}this.cache.add(s,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const s=this,n=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(n.map(function(i,o){return s.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],s=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[E.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(i,o){s.load(u.LoaderUtils.resolveURL(t.uri,n.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(s){const n=t.byteLength||0,i=t.byteOffset||0;return s.slice(i,i+n)})}loadAccessor(e){const t=this,s=this.json,n=this.json.accessors[e];if(n.bufferView===void 0&&n.sparse===void 0){const o=oe[n.type],c=X[n.componentType],a=n.normalized===!0,l=new c(n.count*o);return Promise.resolve(new u.BufferAttribute(l,o,a))}const i=[];return n.bufferView!==void 0?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),n.sparse!==void 0&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(o){const c=o[0],a=oe[n.type],l=X[n.componentType],d=l.BYTES_PER_ELEMENT,h=d*a,g=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,y=n.normalized===!0;let _,m;if(p&&p!==h){const f=Math.floor(g/p),T="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+f+":"+n.count;let w=t.cache.get(T);w||(_=new l(c,f*p,n.count*p/d),w=new u.InterleavedBuffer(_,p/d),t.cache.add(T,w)),m=new u.InterleavedBufferAttribute(w,a,g%p/d,y)}else c===null?_=new l(n.count*a):_=new l(c,g,n.count*a),m=new u.BufferAttribute(_,a,y);if(n.sparse!==void 0){const f=oe.SCALAR,T=X[n.sparse.indices.componentType],w=n.sparse.indices.byteOffset||0,b=n.sparse.values.byteOffset||0,M=new T(o[1],w,n.sparse.count*f),A=new l(o[2],b,n.sparse.count*a);c!==null&&(m=new u.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let L=0,R=M.length;L<R;L++){const C=M[L];if(m.setX(C,A[L*a]),a>=2&&m.setY(C,A[L*a+1]),a>=3&&m.setZ(C,A[L*a+2]),a>=4&&m.setW(C,A[L*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=y}return m})}loadTexture(e){const t=this.json,s=this.options,i=t.textures[e].source,o=t.images[i];let c=this.textureLoader;if(o.uri){const a=s.manager.getHandler(o.uri);a!==null&&(c=a)}return this.loadTextureImage(e,i,c)}loadTextureImage(e,t,s){const n=this,i=this.json,o=i.textures[e],c=i.images[t],a=(c.uri||c.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,s).then(function(d){d.flipY=!1,d.name=o.name||c.name||"",d.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(d.name=c.uri);const g=(i.samplers||{})[o.sampler]||{};return d.magFilter=Ee[g.magFilter]||u.LinearFilter,d.minFilter=Ee[g.minFilter]||u.LinearMipmapLinearFilter,d.wrapS=Se[g.wrapS]||u.RepeatWrapping,d.wrapT=Se[g.wrapT]||u.RepeatWrapping,d.generateMipmaps=!d.isCompressedTexture&&d.minFilter!==u.NearestFilter&&d.minFilter!==u.LinearFilter,n.associations.set(d,{textures:e}),d}).catch(function(){return null});return this.textureCache[a]=l,l}loadImageSource(e,t){const s=this,n=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(h=>h.clone());const o=n.images[e],c=self.URL||self.webkitURL;let a=o.uri||"",l=!1;if(o.bufferView!==void 0)a=s.getDependency("bufferView",o.bufferView).then(function(h){l=!0;const g=new Blob([h],{type:o.mimeType});return a=c.createObjectURL(g),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(a).then(function(h){return new Promise(function(g,p){let y=g;t.isImageBitmapLoader===!0&&(y=function(_){const m=new u.Texture(_);m.needsUpdate=!0,g(m)}),t.load(u.LoaderUtils.resolveURL(h,i.path),y,void 0,p)})}).then(function(h){return l===!0&&c.revokeObjectURL(a),N(h,o),h.userData.mimeType=o.mimeType||Wt(o.uri),h}).catch(function(h){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),h});return this.sourceCache[e]=d,d}assignTexture(e,t,s,n){const i=this;return this.getDependency("texture",s.index).then(function(o){if(!o)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(o=o.clone(),o.channel=s.texCoord),i.extensions[E.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[E.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const a=i.associations.get(o);o=i.extensions[E.KHR_TEXTURE_TRANSFORM].extendTexture(o,c),i.associations.set(o,a)}}return n!==void 0&&(o.colorSpace=n),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let a=this.cache.get(c);a||(a=new u.PointsMaterial,u.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,a.sizeAttenuation=!1,this.cache.add(c,a)),s=a}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let a=this.cache.get(c);a||(a=new u.LineBasicMaterial,u.Material.prototype.copy.call(a,s),a.color.copy(s.color),a.map=s.map,this.cache.add(c,a)),s=a}if(n||i||o){let c="ClonedMaterial:"+s.uuid+":";n&&(c+="derivative-tangents:"),i&&(c+="vertex-colors:"),o&&(c+="flat-shading:");let a=this.cache.get(c);a||(a=s.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),n&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(c,a),this.associations.set(a,this.associations.get(s))),s=a}e.material=s}getMaterialType(){return u.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,i=s.materials[e];let o;const c={},a=i.extensions||{},l=[];if(a[E.KHR_MATERIALS_UNLIT]){const h=n[E.KHR_MATERIALS_UNLIT];o=h.getMaterialType(),l.push(h.extendParams(c,i,t))}else{const h=i.pbrMetallicRoughness||{};if(c.color=new u.Color(1,1,1),c.opacity=1,Array.isArray(h.baseColorFactor)){const g=h.baseColorFactor;c.color.setRGB(g[0],g[1],g[2],u.LinearSRGBColorSpace),c.opacity=g[3]}h.baseColorTexture!==void 0&&l.push(t.assignTexture(c,"map",h.baseColorTexture,u.SRGBColorSpace)),c.metalness=h.metallicFactor!==void 0?h.metallicFactor:1,c.roughness=h.roughnessFactor!==void 0?h.roughnessFactor:1,h.metallicRoughnessTexture!==void 0&&(l.push(t.assignTexture(c,"metalnessMap",h.metallicRoughnessTexture)),l.push(t.assignTexture(c,"roughnessMap",h.metallicRoughnessTexture))),o=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),l.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,c)})))}i.doubleSided===!0&&(c.side=u.DoubleSide);const d=i.alphaMode||re.OPAQUE;if(d===re.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,d===re.MASK&&(c.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==u.MeshBasicMaterial&&(l.push(t.assignTexture(c,"normalMap",i.normalTexture)),c.normalScale=new u.Vector2(1,1),i.normalTexture.scale!==void 0)){const h=i.normalTexture.scale;c.normalScale.set(h,h)}if(i.occlusionTexture!==void 0&&o!==u.MeshBasicMaterial&&(l.push(t.assignTexture(c,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==u.MeshBasicMaterial){const h=i.emissiveFactor;c.emissive=new u.Color().setRGB(h[0],h[1],h[2],u.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==u.MeshBasicMaterial&&l.push(t.assignTexture(c,"emissiveMap",i.emissiveTexture,u.SRGBColorSpace)),Promise.all(l).then(function(){const h=new o(c);return i.name&&(h.name=i.name),N(h,i),t.associations.set(h,{materials:e}),i.extensions&&j(n,h,i),h})}createUniqueName(e){const t=u.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function i(c){return s[E.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(a){return xe(a,c,t)})}const o=[];for(let c=0,a=e.length;c<a;c++){const l=e[c],d=Vt(l),h=n[d];if(h)o.push(h.promise);else{let g;l.extensions&&l.extensions[E.KHR_DRACO_MESH_COMPRESSION]?g=i(l):g=xe(new u.BufferGeometry,l,t),n[d]={primitive:l,promise:g},o.push(g)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,i=s.meshes[e],o=i.primitives,c=[];for(let a=0,l=o.length;a<l;a++){const d=o[a].material===void 0?Bt(this.cache):this.getDependency("material",o[a].material);c.push(d)}return c.push(t.loadGeometries(o)),Promise.all(c).then(function(a){const l=a.slice(0,a.length-1),d=a[a.length-1],h=[];for(let p=0,y=d.length;p<y;p++){const _=d[p],m=o[p];let f;const T=l[p];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)f=i.isSkinnedMesh===!0?new u.SkinnedMesh(_,T):new u.Mesh(_,T),f.isSkinnedMesh===!0&&f.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?f.geometry=be(f.geometry,u.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(f.geometry=be(f.geometry,u.TriangleFanDrawMode));else if(m.mode===O.LINES)f=new u.LineSegments(_,T);else if(m.mode===O.LINE_STRIP)f=new u.Line(_,T);else if(m.mode===O.LINE_LOOP)f=new u.LineLoop(_,T);else if(m.mode===O.POINTS)f=new u.Points(_,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(f.geometry.morphAttributes).length>0&&Kt(f,i),f.name=t.createUniqueName(i.name||"mesh_"+e),N(f,i),m.extensions&&j(n,f,m),t.assignFinalMaterial(f),h.push(f)}for(let p=0,y=h.length;p<y;p++)t.associations.set(h[p],{meshes:e,primitives:p});if(h.length===1)return i.extensions&&j(n,h[0],i),h[0];const g=new u.Group;i.extensions&&j(n,g,i),t.associations.set(g,{meshes:e});for(let p=0,y=h.length;p<y;p++)g.add(h[p]);return g})}loadCamera(e){let t;const s=this.json.cameras[e],n=s[s.type];if(!n){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return s.type==="perspective"?t=new u.PerspectiveCamera(u.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new u.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),N(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,i=t.joints.length;n<i;n++)s.push(this._loadNodeShallow(t.joints[n]));return t.inverseBindMatrices!==void 0?s.push(this.getDependency("accessor",t.inverseBindMatrices)):s.push(null),Promise.all(s).then(function(n){const i=n.pop(),o=n,c=[],a=[];for(let l=0,d=o.length;l<d;l++){const h=o[l];if(h){c.push(h);const g=new u.Matrix4;i!==null&&g.fromArray(i.array,l*16),a.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[l])}return new u.Skeleton(c,a)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,o=[],c=[],a=[],l=[],d=[];for(let h=0,g=n.channels.length;h<g;h++){const p=n.channels[h],y=n.samplers[p.sampler],_=p.target,m=_.node,f=n.parameters!==void 0?n.parameters[y.input]:y.input,T=n.parameters!==void 0?n.parameters[y.output]:y.output;_.node!==void 0&&(o.push(this.getDependency("node",m)),c.push(this.getDependency("accessor",f)),a.push(this.getDependency("accessor",T)),l.push(y),d.push(_))}return Promise.all([Promise.all(o),Promise.all(c),Promise.all(a),Promise.all(l),Promise.all(d)]).then(function(h){const g=h[0],p=h[1],y=h[2],_=h[3],m=h[4],f=[];for(let T=0,w=g.length;T<w;T++){const b=g[T],M=p[T],A=y[T],L=_[T],R=m[T];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const C=s._createAnimationTracks(b,M,A,L,R);if(C)for(let k=0;k<C.length;k++)f.push(C[k])}return new u.AnimationClip(i,void 0,f)})}createNodeMesh(e){const t=this.json,s=this,n=t.nodes[e];return n.mesh===void 0?null:s.getDependency("mesh",n.mesh).then(function(i){const o=s._getNodeRef(s.meshCache,n.mesh,i);return n.weights!==void 0&&o.traverse(function(c){if(c.isMesh)for(let a=0,l=n.weights.length;a<l;a++)c.morphTargetInfluences[a]=n.weights[a]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],i=s._loadNodeShallow(e),o=[],c=n.children||[];for(let l=0,d=c.length;l<d;l++)o.push(s.getDependency("node",c[l]));const a=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([i,Promise.all(o),a]).then(function(l){const d=l[0],h=l[1],g=l[2];g!==null&&d.traverse(function(p){p.isSkinnedMesh&&p.bind(g,Xt)});for(let p=0,y=h.length;p<y;p++)d.add(h[p]);return d})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?n.createUniqueName(i.name):"",c=[],a=n._invokeOne(function(l){return l.createNodeMesh&&l.createNodeMesh(e)});return a&&c.push(a),i.camera!==void 0&&c.push(n.getDependency("camera",i.camera).then(function(l){return n._getNodeRef(n.cameraCache,i.camera,l)})),n._invokeAll(function(l){return l.createNodeAttachment&&l.createNodeAttachment(e)}).forEach(function(l){c.push(l)}),this.nodeCache[e]=Promise.all(c).then(function(l){let d;if(i.isBone===!0?d=new u.Bone:l.length>1?d=new u.Group:l.length===1?d=l[0]:d=new u.Object3D,d!==l[0])for(let h=0,g=l.length;h<g;h++)d.add(l[h]);if(i.name&&(d.userData.name=i.name,d.name=o),N(d,i),i.extensions&&j(s,d,i),i.matrix!==void 0){const h=new u.Matrix4;h.fromArray(i.matrix),d.applyMatrix4(h)}else i.translation!==void 0&&d.position.fromArray(i.translation),i.rotation!==void 0&&d.quaternion.fromArray(i.rotation),i.scale!==void 0&&d.scale.fromArray(i.scale);if(!n.associations.has(d))n.associations.set(d,{});else if(i.mesh!==void 0&&n.meshCache.refs[i.mesh]>1){const h=n.associations.get(d);n.associations.set(d,{...h})}return n.associations.get(d).nodes=e,d}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,i=new u.Group;s.name&&(i.name=n.createUniqueName(s.name)),N(i,s),s.extensions&&j(t,i,s);const o=s.nodes||[],c=[];for(let a=0,l=o.length;a<l;a++)c.push(n.getDependency("node",o[a]));return Promise.all(c).then(function(a){for(let d=0,h=a.length;d<h;d++)i.add(a[d]);const l=d=>{const h=new Map;for(const[g,p]of n.associations)(g instanceof u.Material||g instanceof u.Texture)&&h.set(g,p);return d.traverse(g=>{const p=n.associations.get(g);p!=null&&h.set(g,p)}),h};return n.associations=l(i),i})}_createAnimationTracks(e,t,s,n,i){const o=[],c=e.name?e.name:e.uuid,a=[];H[i.path]===H.weights?e.traverse(function(g){g.morphTargetInfluences&&a.push(g.name?g.name:g.uuid)}):a.push(c);let l;switch(H[i.path]){case H.weights:l=u.NumberKeyframeTrack;break;case H.rotation:l=u.QuaternionKeyframeTrack;break;case H.translation:case H.scale:l=u.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:l=u.NumberKeyframeTrack;break;case 2:case 3:default:l=u.VectorKeyframeTrack;break}break}const d=n.interpolation!==void 0?Gt[n.interpolation]:u.InterpolateLinear,h=this._getArrayFromAccessor(s);for(let g=0,p=a.length;g<p;g++){const y=new l(a[g]+"."+H[i.path],t.array,h,d);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(y),o.push(y)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=ue(t.constructor),n=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)n[i]=t[i]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof u.QuaternionKeyframeTrack?jt:De;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function qt(r,e,t){const s=e.attributes,n=new u.Box3;if(s.POSITION!==void 0){const c=t.json.accessors[s.POSITION],a=c.min,l=c.max;if(a!==void 0&&l!==void 0){if(n.set(new u.Vector3(a[0],a[1],a[2]),new u.Vector3(l[0],l[1],l[2])),c.normalized){const d=ue(X[c.componentType]);n.min.multiplyScalar(d),n.max.multiplyScalar(d)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const c=new u.Vector3,a=new u.Vector3;for(let l=0,d=i.length;l<d;l++){const h=i[l];if(h.POSITION!==void 0){const g=t.json.accessors[h.POSITION],p=g.min,y=g.max;if(p!==void 0&&y!==void 0){if(a.setX(Math.max(Math.abs(p[0]),Math.abs(y[0]))),a.setY(Math.max(Math.abs(p[1]),Math.abs(y[1]))),a.setZ(Math.max(Math.abs(p[2]),Math.abs(y[2]))),g.normalized){const _=ue(X[g.componentType]);a.multiplyScalar(_)}c.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(c)}r.boundingBox=n;const o=new u.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,r.boundingSphere=o}function xe(r,e,t){const s=e.attributes,n=[];function i(o,c){return t.getDependency("accessor",o).then(function(a){r.setAttribute(c,a)})}for(const o in s){const c=he[o]||o.toLowerCase();c in r.attributes||n.push(i(s[o],c))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(c){r.setIndex(c)});n.push(o)}return u.ColorManagement.workingColorSpace!==u.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${u.ColorManagement.workingColorSpace}" not supported.`),N(r,e),qt(r,e,t),Promise.all(n).then(function(){return e.targets!==void 0?zt(r,e.targets,t):r})}const Oe=r=>{r.geometry&&r.geometry.dispose(),r.material&&(Array.isArray(r.material)?r.material.forEach(e=>{Me(e)}):Me(r.material)),r.children&&r.children.forEach(e=>Oe(e))};function Me(r){for(const e in r)r[e]&&r[e].isTexture&&r[e].dispose();r.dispose()}const ce={};async function Zt(r,e=50){const t={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(t.geometry=J(r.geometry),t.material=te(r.material));const s=[{object:r,parentData:t}];let n=0;for(;s.length>0;){const{object:i,parentData:o}=s.pop();for(const c of i.children){const a={type:c.type,name:c.name,position:c.position.toArray(),rotation:c.rotation.toArray(),scale:c.scale.toArray(),visible:c.visible,children:[],geometry:null,material:null,userData:c.userData};c.isMesh&&(a.geometry=J(c.geometry),a.material=te(c.material)),o.children.push(a),s.push({object:c,parentData:a}),n++,n%e===0&&await new Promise(l=>requestAnimationFrame(l))}}return t}function $t(r){const e={type:r.type,name:r.name,position:r.position.toArray(),rotation:r.rotation.toArray(),scale:r.scale.toArray(),visible:r.visible,children:[],geometry:null,material:null,userData:r.userData};r.isMesh&&(e.geometry=J(r.geometry),e.material=te(r.material));const t=[{object:r,parentData:e}];for(;t.length>0;){const{object:s,parentData:n}=t.pop();for(const i of s.children){const o={type:i.type,name:i.name,position:i.position.toArray(),rotation:i.rotation.toArray(),scale:i.scale.toArray(),visible:i.visible,children:[],geometry:null,material:null,userData:i.userData};i.isMesh&&(o.geometry=J(i.geometry),o.material=te(i.material)),n.children.push(o),t.push({object:i,parentData:o})}}return e}async function Ie(r,e=50){const t=[];let s;switch(r.type){case"Mesh":const i=ee(r.geometry),o=se(r.material);s=new S.Mesh(i,o);break;case"Group":s=new S.Group;break;case"Object3D":s=new S.Object3D;break;default:return console.warn(`Unsupported object type: ${r.type}`),null}s.name=r.name,s.position.fromArray(r.position),s.rotation.fromArray(r.rotation),s.scale.fromArray(r.scale),s.visible=r.visible,s.userData=r.userData,t.push({data:r,object:s});let n=0;for(;t.length>0;){const{data:i,object:o}=t.pop();for(const c of[...i.children].reverse()){let a;switch(c.type){case"Mesh":const l=ee(c.geometry),d=se(c.material);a=new S.Mesh(l,d);break;case"Group":a=new S.Group;break;case"Object3D":a=new S.Object3D;break;default:console.warn(`Unsupported object type: ${c.type}`);continue}a&&(a.name=c.name,a.position.fromArray(c.position),a.rotation.fromArray(c.rotation),a.scale.fromArray(c.scale),a.visible=c.visible,a.userData=c.userData,o.add(a),t.push({data:c,object:a}),n++,n%e===0&&await new Promise(l=>requestAnimationFrame(l)))}}return s}function Qt(r){const e=[];let t;switch(r.type){case"Mesh":const s=ee(r.geometry),n=se(r.material);t=new S.Mesh(s,n);break;case"Group":t=new S.Group;break;case"Object3D":t=new S.Object3D;break;default:return console.warn(`Unsupported object type: ${r.type}`),null}for(t.name=r.name,t.position.fromArray(r.position),t.rotation.fromArray(r.rotation),t.scale.fromArray(r.scale),t.visible=r.visible,t.userData=r.userData,e.push({data:r,object:t});e.length>0;){const{data:s,object:n}=e.pop();for(const i of[...s.children].reverse()){let o;switch(i.type){case"Mesh":const c=ee(i.geometry),a=se(i.material);o=new S.Mesh(c,a);break;case"Group":o=new S.Group;break;case"Object3D":o=new S.Object3D;break;default:console.warn(`Unsupported object type: ${i.type}`);continue}o&&(o.name=i.name,o.position.fromArray(i.position),o.rotation.fromArray(i.rotation),o.scale.fromArray(i.scale),o.visible=i.visible,o.userData=i.userData,n.add(o),e.push({data:i,object:o}))}}return t}function J(r){const e={},{attributes:t,index:s,type:n}=r;t.position&&(e.position={type:"Float32Array",array:Array.from(t.position.array),itemSize:3}),t.normal&&(e.normal={type:"Float32Array",array:Array.from(t.normal.array),itemSize:3}),t.uv&&(e.uv={type:"Float32Array",array:Array.from(t.uv.array),itemSize:2});const i={type:n,attributes:e};return s&&s.array&&(i.index={type:"Uint32Array",array:Array.from(s.array),itemSize:1}),i}function ee(r){const{type:e,attributes:t,index:s}=r,n=new S.BufferGeometry;for(const i in t)if(t.hasOwnProperty(i)){const{type:o,array:c,itemSize:a}=t[i];n.setAttribute(i,new S.BufferAttribute(new Float32Array(c),a))}return s&&n.setIndex(s.array),n}function te(r){return{type:r.type,color:r.color.getHex(),map:r.map?r.map.image.src:null,opacity:r.opacity,name:r.name,depthTest:r.depthTest,depthWrite:r.depthWrite,transparent:r.transparent,side:r.side,roughness:r.roughness,metalness:r.metalness,emissive:r.emissive.getHex()}}function se(r){if(ce[r.name])return ce[r.name];const{type:e,...t}=r,s=e||"MeshStandardMaterial",n=new S[s]({...t});if(r.map){const i=new S.TextureLoader().load(r.map);n.map=i}return n.needsUpdate=!0,ce[r.name]=n,n}class ke{constructor(){this.stats={hits:0,misses:0,totalLoadTime:0,cacheSaveTime:0,errors:0},this.loadHistory=[]}recordHit(e){this.stats.hits++,this.stats.totalLoadTime+=e,this._recordHistory("hit",e)}recordMiss(e){this.stats.misses++,this.stats.totalLoadTime+=e,this._recordHistory("miss",e)}recordCacheSave(e){this.stats.cacheSaveTime+=e}recordError(e,t){this.stats.errors++,this._recordHistory("error",0,{path:e,error:t.message})}getHitRate(){const e=this.stats.hits+this.stats.misses;return e>0?(this.stats.hits/e*100).toFixed(2)+"%":"0%"}getAvgLoadTime(){const e=this.stats.hits+this.stats.misses;return e>0?(this.stats.totalLoadTime/e).toFixed(2)+"ms":"0ms"}getStats(){const e=this.stats.hits+this.stats.misses;return{命中率:this.getHitRate(),平均加载时间:this.getAvgLoadTime(),缓存命中数:this.stats.hits,缓存未命中数:this.stats.misses,总加载次数:e,总加载时间:this.stats.totalLoadTime.toFixed(2)+"ms",缓存保存时间:this.stats.cacheSaveTime.toFixed(2)+"ms",错误次数:this.stats.errors}}getHistory(e=10){return this.loadHistory.slice(-e)}reset(){this.stats={hits:0,misses:0,totalLoadTime:0,cacheSaveTime:0,errors:0},this.loadHistory=[]}_recordHistory(e,t,s={}){this.loadHistory.push({type:e,duration:t,timestamp:Date.now(),...s}),this.loadHistory.length>100&&this.loadHistory.shift()}logReport(){console.group("📊 缓存性能报告");const e=this.getStats();Object.entries(e).forEach(([t,s])=>{console.log(`${t}: ${s}`)}),console.groupEnd()}}const U=new ke;class Z{static async retry(e,t={}){const{maxRetries:s=3,initialDelay:n=1e3,maxDelay:i=1e4,backoffFactor:o=2,shouldRetry:c=Z.defaultShouldRetry}=t;let a,l=n;for(let d=0;d<=s;d++)try{return await e()}catch(h){if(a=h,d===s||!c(h,d))throw h;console.warn(`[ RetryHelper ] 操作失败,第 ${d+1} 次尝试失败,${l}ms 后进行第 ${d+2} 次尝试...`,h),await Z.delay(l),l=Math.min(l*o,i)}throw a}static defaultShouldRetry(e,t){if(e.name==="TypeError"&&e.message.includes("fetch"))return!0;if(e.message.includes("HTTP error")){const s=e.message.match(/status:\s*(\d+)/);if(s){const n=parseInt(s[1],10);return n>=500||n===429||n===408}}return!1}static delay(e){return new Promise(t=>setTimeout(t,e))}}const Q={NETWORK:"NETWORK",PARSE:"PARSE",VERSION_MISMATCH:"VERSION",UNKNOWN:"UNKNOWN"};class Y extends Error{constructor(e,t,s,n){super(e),this.name="ModelLoadError",this.type=t,this.path=s,this.originalError=n,this.timestamp=Date.now()}static networkError(e,t){return new Y(`网络加载失败: ${e}`,Q.NETWORK,e,t)}static parseError(e,t){return new Y(`模型解析失败: ${e}`,Q.PARSE,e,t)}static versionMismatchError(e,t,s){return new Y(`版本不匹配: ${e} (期望: ${t}, 实际: ${s})`,Q.VERSION_MISMATCH,e)}}const Re=4;class de{constructor(e="threeJsIDBCache",t={}){this.version=Re,this.dbName=e,this.options={maxSize:t.maxSize||500*1024*1024,maxEntries:t.maxEntries||50,evictRatio:t.evictRatio||.2},this.dbInit()}dbInit(){this.db=new He(this.dbName),this.db.version(this.version).stores({models:"&path, version, timestamp, accessCount, size"}).upgrade(async e=>{console.log("[ IDBCache 版本更新 ] ====> version",Re);const t=e.table("models"),s=await t.toArray();for(const n of s)n.data instanceof ArrayBuffer||await t.delete(n.path)})}getDatabase(){return this.db}async saveModel(e,t,s){await this.ensureCapacity(s.byteLength),await this.db.table("models").put({path:e,version:t,data:s,size:s.byteLength,timestamp:Date.now(),accessCount:0})}async ensureCapacity(e){const t=await this.db.table("models").toArray(),s=t.reduce((c,a)=>c+(a.size||0),0),n=t.length,i=s+e>this.options.maxSize,o=n>=this.options.maxEntries;(i||o)&&(console.log(`[ IDBCache ] ====> 容量不足,开始 LRU 淘汰. 总大小: ${(s/1024/1024).toFixed(2)}MB, 条目数: ${n}`),await this.evictLRU(t))}async evictLRU(e){const t=e.sort((c,a)=>(c.accessCount||0)!==(a.accessCount||0)?(c.accessCount||0)-(a.accessCount||0):(c.timestamp||0)-(a.timestamp||0)),s=Math.max(1,Math.floor(t.length*this.options.evictRatio)),n=t.slice(0,s),i=n.map(c=>c.path);await this.db.table("models").bulkDelete(i);const o=n.reduce((c,a)=>c+(a.size||0),0);console.log(`[ IDBCache ] ====> LRU 淘汰完成. 删除 ${s} 个条目,释放 ${(o/1024/1024).toFixed(2)}MB`)}async getModel(e,t){const s=await this.db.table("models").get(e);return s?s.version!==t?(console.log("模型版本不一致, 清除当前记录"),await this.db.table("models").delete(e),null):(await this.db.table("models").update(e,{accessCount:(s.accessCount||0)+1,timestamp:Date.now()}),s.data):(console.warn(`Model "${e}" not found in table models`),null)}async cacheModel(e,t,s){console.log("[ ] ====> path, modelData, version",e,t,s);try{this.db.table("models").put({version:s,path:e,data:t}).then(()=>{console.log(`Model "${e}" cached successfully in table models`)})}catch{console.log(" 缓存模型失败 =====> ")}return t}async loadCachedModel(e,t){let s=null;try{if(s=await this.db.table("models").get(e),!s)return console.warn(`Model "${t}" not found in table models`),null;if(s.version!==t)return console.log(" =====> 模型版本不一致, 清除当前记录"),await this.db.table("models").delete(e),null}catch{return console.log(" =====> 查询表中模型失败"),this.db.delete().then(()=>{this.init()}),null}return s.data}async getStats(){const e=await this.db.table("models").toArray(),t=e.reduce((n,i)=>n+(i.size||0),0),s=e.reduce((n,i)=>n+(i.accessCount||0),0);return{count:e.length,totalSize:t,totalSizeMB:(t/1024/1024).toFixed(2),maxEntries:this.options.maxEntries,maxSizeMB:(this.options.maxSize/1024/1024).toFixed(2),usagePercentage:(t/this.options.maxSize*100).toFixed(2),totalAccessCount:s,avgAccessCount:e.length>0?(s/e.length).toFixed(2):0}}async clear(){await this.db.table("models").clear(),console.log("[ IDBCache ] ====> 缓存已清空")}async deleteModel(e){await this.db.table("models").delete(e)}}function pe(r){const{geometries:e,materials:t,hierarchy:s}=r,n=new Map;e.forEach((a,l)=>{const d=Jt(a);n.set(l,d)});const i=new Map;t.forEach((a,l)=>{const d=es(a);i.set(l,d)});const o=new S.Group;o.name="Scene";const c=new Map;return s.forEach(a=>{let l;if(a.type==="Mesh"){const d=a.geometryIndex>=0?n.get(a.geometryIndex):null,h=a.materialIndex>=0?i.get(a.materialIndex):null;l=new S.Mesh(d,h)}else a.type==="Group"?l=new S.Group:a.type==="Object3D"?l=new S.Object3D:l=new S.Object3D;l.name=a.name,l.position.fromArray(a.position),l.rotation.fromArray(a.rotation),l.scale.fromArray(a.scale),l.visible=a.visible,c.set(a.id,l)}),s.forEach(a=>{const l=c.get(a.id);if(a.parentId!==null){const d=c.get(a.parentId);d&&d.add(l)}else o.add(l)}),o}function Jt(r){const e=new S.BufferGeometry;for(const t in r.attributes){const s=r.attributes[t],n=s.array;let i;if(n.byteLength===0){console.warn(`[ sceneRebuilder ] 属性 ${t} 的数组为空`);continue}if(n.buffer&&n.buffer.byteLength===0){console.warn(`[ sceneRebuilder ] 属性 ${t} 的 buffer 已被转移,尝试重建`);continue}i=n;const o=new S.BufferAttribute(i,s.itemSize);o.normalized=s.normalized,e.setAttribute(t,o)}if(r.index){const t=r.index,s=t.array;if(s&&s.byteLength>0){const n=new S.BufferAttribute(s,t.itemSize);e.setIndex(n)}}return e}function es(r){let e;const t={color:r.color!==void 0?r.color:16777215,opacity:r.opacity!==void 0?r.opacity:1,transparent:r.transparent!==void 0?r.transparent:!1,alphaTest:r.alphaTest!==void 0?r.alphaTest:0,side:r.side!==void 0?r.side:S.FrontSide,depthTest:r.depthTest!==void 0?r.depthTest:!0,depthWrite:r.depthWrite!==void 0?r.depthWrite:!0,wireframe:r.wireframe!==void 0?r.wireframe:!1,vertexColors:r.vertexColors!==void 0?r.vertexColors:!1};switch(r.type){case"MeshStandardMaterial":e=new S.MeshStandardMaterial({...t,roughness:r.roughness!==void 0?r.roughness:.5,metalness:r.metalness!==void 0?r.metalness:.5,emissive:r.emissive!==void 0?r.emissive:0,emissiveIntensity:r.emissiveIntensity!==void 0?r.emissiveIntensity:1});break;case"MeshBasicMaterial":e=new S.MeshBasicMaterial({...t});break;case"MeshPhongMaterial":e=new S.MeshPhongMaterial({...t,shininess:r.shininess!==void 0?r.shininess:30,specular:r.specular!==void 0?r.specular:1118481,emissive:r.emissive!==void 0?r.emissive:0,emissiveIntensity:r.emissiveIntensity!==void 0?r.emissiveIntensity:1});break;default:e=new S.MeshStandardMaterial(t)}return e.uuid=r.uuid,e}class ts{constructor(){this.geometries=[],this.materials=[],this.hierarchy=[],this.geometryMap=new Map,this.materialMap=new Map}addChunk(e){e.geometries&&e.geometries.forEach(t=>{const s=this.geometries.length;this.geometries.push(t),this.geometryMap.set(t.uuid,s)}),e.materials&&e.materials.forEach(t=>{const s=this.materials.length;this.materials.push(t),this.materialMap.set(t.uuid,s)}),e.hierarchy&&this.hierarchy.push(...e.hierarchy)}buildCurrent(){const e={geometries:this.geometries,materials:this.materials,hierarchy:this.hierarchy};return pe(e)}finalize(){return this.buildCurrent()}}let z;const le="/draco/";let K,V,Ae=0;const F=new Map,Ne=()=>{const r=new mt,e=new ft;e.setDecoderPath(le),r.setDRACOLoader(e);function t(p,y,_,m){return r.load(p,y,_,m)}function s(p,y){return new Promise((_,m)=>{r.load(p,_,y,m)})}async function n(p,y,_,m={}){const f=performance.now();let T=!1;const{maxRetries:w=3,optimizeMaterials:b=!1,simplifyGeometry:M=!1,simplifyRatio:A=.5,simplifyOptions:L={}}=m;try{let R=await o(p,y);if(R)console.log(`[ asyncFetch ] ====> 缓存命中: ${p}`),T=!0;else{console.log(`[ asyncFetch ] ====> 缓存未命中: ${p}`),console.time("[ fetchArrayBuffer ] 加载模型耗时"),R=await Z.retry(()=>i(p,_),{maxRetries:w,shouldRetry:me=>!!(me.name==="TypeError"||me.message.includes("HTTP error! status: 5"))}),console.timeEnd("[ fetchArrayBuffer ] 加载模型耗时");const v=performance.now();await z.saveModel(p,y,R);const G=performance.now()-v;U.recordCacheSave(G),T=!1}console.time("[ 解析模型耗时 ]");let C=await c(R);if(console.timeEnd("[ 解析模型耗时 ]"),console.time("[ 模型优化耗时 ]"),b){console.log("🔧 [ 材质优化 ] 开始合并相同材质...");const{modelOptimizer:v}=await Promise.resolve().then(()=>require("./modelOptimizer-A0Cs6f9e.cjs"));C=v.optimizeMaterials(C)}if(M){console.log(`🔧 [ 几何体简化 ] 开始简化模型 (比例: ${A})...`);const{modelOptimizer:v}=await Promise.resolve().then(()=>require("./modelOptimizer-A0Cs6f9e.cjs")),G={minFaceCount:100,preserveUVs:!0,...L};C=v.simplifyModel(C,A,G)}console.timeEnd("[ 模型优化耗时 ]");const k=performance.now()-f;return T?U.recordHit(k):U.recordMiss(k),C}catch(R){throw console.error(`加载模型 ${p} 失败:`,R),U.recordError(p,R),R.name==="TypeError"&&R.message.includes("fetch")?Y.networkError(p,R):R}}async function i(p,y){return new Promise((_,m)=>{fetch(p).then(f=>{if(!f.ok)throw new Error(`HTTP error! status: ${f.status}`);return f}).then(f=>{const T=f.headers.get("content-length"),w=T?parseInt(T,10):0;if(y&&w>0){const b=f.body.getReader();let M=0;const A=[],L=()=>{b.read().then(({done:R,value:C})=>{if(R){const k=new Uint8Array(M);let v=0;for(const G of A)k.set(G,v),v+=G.length;_(k.buffer);return}A.push(C),M+=C.length,y(Math.round(M/w*100)),L()}).catch(m)};L()}else return f.arrayBuffer()}).then(f=>_(f)).catch(f=>{m(f)})})}async function o(p,y){return z||(z=new de),z.getModel(p,y)}async function c(p,y={}){if(!p)return null;const{useOptimizedParser:_=!0,useProgressive:m=!1}=y;if(_){const w=l();if(w)try{console.time("[ 优化解析 ] 使用 Transferable Objects 解析");const b=await d(w,p,m);return console.timeEnd("[ 优化解析 ] 使用 Transferable Objects 解析"),pe(b)}catch(b){console.warn("[ 优化解析 ] 失败,回退到标准解析",b)}}const f=a();if(f)try{const w=await h(f,p);return Ie(w)}catch(w){console.warn("[ GLTF Worker ] ====> 解析失败,回退到主线程解析",w)}return(await g(p)).scene}const a=()=>typeof window>"u"||typeof Worker>"u"?null:(K||(K=new Worker(new URL("/assets/gltfParser.worker-Bqz8BBJx.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:B&&B.tagName.toUpperCase()==="SCRIPT"&&B.src||new URL("PredictiveLoader-CpRi-ULa.cjs",document.baseURI).href),{type:"module"}),K.onmessage=p=>{const{id:y,data:_,error:m}=p.data||{};if(!y||!F.has(y))return;const{resolve:f,reject:T}=F.get(y);F.delete(y),m?T(new Error(m)):f(_)},K.onmessageerror=p=>{console.error("[ GLTF Worker ] ====> 消息解析失败",p)},K.onerror=p=>{console.error("[ GLTF Worker ] ====> 运行错误",p)}),K),l=()=>{if(typeof window>"u"||typeof Worker>"u")return null;if(!V)try{V=new Worker(new URL("/assets/gltfParserOptimized.worker-DfipxPjm.js",typeof document>"u"?require("url").pathToFileURL(__filename).href:B&&B.tagName.toUpperCase()==="SCRIPT"&&B.src||new URL("PredictiveLoader-CpRi-ULa.cjs",document.baseURI).href),{type:"module"}),V.onmessage=p=>{const{id:y,data:_,error:m,type:f}=p.data||{};if(!y||!F.has(y)||f==="progress")return;const{resolve:T,reject:w}=F.get(y);F.delete(y),m?w(new Error(m)):T(_)},V.onmessageerror=p=>{console.error("[ 优化 Worker ] ====> 消息解析失败",p)},V.onerror=p=>{console.error("[ 优化 Worker ] ====> 运行错误",p)}}catch(p){return console.warn("[ 优化 Worker ] ====> 创建失败,可能不支持模块化 Worker",p),null}return V},d=(p,y,_=!1)=>new Promise((m,f)=>{const T=++Ae;F.set(T,{resolve:m,reject:f});const w={id:T,arrayBuffer:y,dracoPath:le,mode:_?"progressive":"standard"};p.postMessage(w,[y])}),h=(p,y)=>new Promise((_,m)=>{const f=++Ae;F.set(f,{resolve:_,reject:m}),p.postMessage({id:f,arrayBuffer:y,dracoPath:le})}),g=p=>new Promise((y,_)=>{r.parse(p,"",y,_)});return{load:t,asyncLoad:s,asyncCacheLoad:n,asyncFetch:n,getCacheStats:()=>U.getStats(),getCache:()=>z||(z=new de),logCacheReport:()=>U.logReport(),resetCacheStats:()=>U.reset()}};class ve{constructor(e={}){this.options={maxPreloadCount:e.maxPreloadCount||5,preloadDelay:e.preloadDelay||1e3,enableLearning:e.enableLearning!==!1},this.loadHistory=new Map,this.loadSequence=[],this.associations=new Map,this.preloadQueue=new Set,this.isPreloading=!1,this.loader=null,this.getLoader=()=>(this.loader||(this.loader=Ne()),this.loader)}recordLoad(e,t){const s=Date.now(),n=this.loadHistory.get(e)||{count:0,lastLoadTime:0,versions:new Set};n.count++,n.lastLoadTime=s,n.versions.add(t),this.loadHistory.set(e,n),this.loadSequence.push({path:e,timestamp:s}),this.loadSequence.length>100&&this.loadSequence.shift(),this.options.enableLearning&&this.loadSequence.length>=2&&this._learnAssociations(e),this._triggerPredictivePreload(e,t)}_learnAssociations(e){const s=this.loadSequence.length-1;for(let n=Math.max(0,s-10);n<s;n++){const{path:i}=this.loadSequence[n];if(this.loadSequence[s].timestamp-this.loadSequence[n].timestamp<5*60*1e3&&i!==e){this.associations.has(i)||this.associations.set(i,new Map);const c=this.associations.get(i),a=c.get(e)||0;c.set(e,a+1)}}}_triggerPredictivePreload(e,t){setTimeout(()=>{const s=this.predictNext(e);this.preload(s,t)},this.options.preloadDelay)}predictNext(e){const t=new Map,s=this.associations.get(e);s&&s.forEach((c,a)=>{t.set(a,(t.get(a)||0)+c*2)});const n=Array.from(this.loadHistory.values()).reduce((c,a)=>c+a.count,0)/(this.loadHistory.size||1);this.loadHistory.forEach((c,a)=>{if(a!==e){const l=c.count/n;t.set(a,(t.get(a)||0)+l)}});const i=this.loadSequence.slice(-10);return new Set(i.map(c=>c.path)).forEach(c=>{c!==e&&t.set(c,(t.get(c)||0)+.5)}),Array.from(t.entries()).sort((c,a)=>a[1]-c[1]).slice(0,this.options.maxPreloadCount).map(([c])=>c)}async preload(e,t="latest"){if(this.isPreloading)return;this.isPreloading=!0;const{asyncFetch:s}=this.getLoader(),n=e.filter(i=>!this.preloadQueue.has(i)).slice(0,this.options.maxPreloadCount).map(async i=>{this.preloadQueue.add(i);try{console.log(`[ 智能预加载 ] 开始预加载: ${i}`),await s(i,t),console.log(`[ 智能预加载 ] 完成: ${i}`)}catch(o){console.warn(`[ 智能预加载 ] 失败: ${i}`,o)}finally{this.preloadQueue.delete(i)}});await Promise.all(n),this.isPreloading=!1}addAssociation(e,t){this.associations.has(e)||this.associations.set(e,new Map);const s=this.associations.get(e);t.forEach(n=>{const i=s.get(n)||0;s.set(n,i+10)})}getStats(){const e=Array.from(this.loadHistory.entries()).sort((t,s)=>s[1].count-t[1].count).slice(0,10).map(([t,s])=>({path:t,loadCount:s.count,lastLoadTime:new Date(s.lastLoadTime).toLocaleString()}));return{totalModelsLoaded:this.loadHistory.size,totalAssociations:this.associations.size,topModels:e,preloadQueueSize:this.preloadQueue.size}}clearHistory(){this.loadHistory.clear(),this.loadSequence=[],this.associations.clear()}exportAssociations(){const e={};return this.associations.forEach((t,s)=>{e[s]=Array.from(t.entries())}),e}importAssociations(e){Object.entries(e).forEach(([t,s])=>{const n=new Map(s);this.associations.set(t,n)})}}const ss=new ve;exports.CSS3DRenderer=ze;exports.CSS3DSprite=Ge;exports.CacheMonitor=ke;exports.ErrorType=Q;exports.IDBCache=de;exports.ModelLoadError=Y;exports.PredictiveLoader=ve;exports.ProgressiveSceneBuilder=ts;exports.RetryHelper=Z;exports.Stats=W;exports.cacheMonitor=U;exports.createArrowHelper=ut;exports.createAxesHelper=ht;exports.createBox3Helper=rt;exports.createCameraHelper=it;exports.createGridHelper=ot;exports.createMapControls=ct;exports.createOrbitControl=at;exports.createRaycaster=lt;exports.createStats=dt;exports.dataToObject3D=Ie;exports.dataToObject3DSync=Qt;exports.disposeThreeObject=Oe;exports.object3DToData=Zt;exports.object3DToDataSync=$t;exports.predictiveLoader=ss;exports.rebuildScene=pe;exports.useGLTFLoader=Ne;
|