@ridp/threejs 1.3.3 → 1.4.0

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.
@@ -1,15 +0,0 @@
1
- "use strict";const b=require("./ImageLoader-DwvBWW6h.cjs"),D=require("three");function g(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const l=g(D);function w(e,n=[.3,.3,.3]){const t=document.querySelector(`#${e}`);if(!t){console.log(" 获取 infoPlane 元素失败 (id) =====> :",e);return}const a=t.cloneNode(!0);a.style.display="block";const i=new b.CSS3DSprite(a);return i.visible=!1,i.scale.set(...n),i}function A(e,n){const t=v(e);t.style.display="block";const a=new b.CSS3DSprite(t);return a.visible=!1,a.scale.set(n,n,n),a}const v=e=>{const n=document.createElement("div");n.style.cssText=`
2
- border-radius: 50px;
3
- border: 2px solid rgba(255, 255, 255, 0.5);
4
- background-color: rgba(15, 20, 22, 0.562);
5
- justify-content: flex-start;
6
- align-items: center;
7
- padding: 20px 30px;
8
- display: flex;
9
- transform-origin: center 0;`;const t=document.createElement("span");return t.style.cssText=`
10
- font-size: 40px;
11
- line-height: 1;
12
- white-space: nowrap;
13
- color: #fff;
14
- font-weight: 700;
15
- `,t.innerText=e,n.appendChild(t),n},O=(e,n)=>{const t={};e.forEach(r=>{let o=r.parent;for(;o;)t[o.uuid]?t[o.uuid]++:t[o.uuid]=1,o=o.parent});let a=null,i=0;for(const r in t)t[r]>i&&(i=t[r],a=n.getObjectByProperty("uuid",r));return a},h={};async function j(e,n=50){const t={type:e.type,name:e.name,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,children:[],geometry:null,material:null,userData:e.userData};e.isMesh&&(t.geometry=u(e.geometry),t.material=m(e.material));const a=[{object:e,parentData:t}];let i=0;for(;a.length>0;){const{object:r,parentData:o}=a.pop();for(const s of r.children){const c={type:s.type,name:s.name,position:s.position.toArray(),rotation:s.rotation.toArray(),scale:s.scale.toArray(),visible:s.visible,children:[],geometry:null,material:null,userData:s.userData};s.isMesh&&(c.geometry=u(s.geometry),c.material=m(s.material)),o.children.push(c),a.push({object:s,parentData:c}),i++,i%n===0&&await new Promise(p=>requestAnimationFrame(p))}}return t}function k(e){const n={type:e.type,name:e.name,position:e.position.toArray(),rotation:e.rotation.toArray(),scale:e.scale.toArray(),visible:e.visible,children:[],geometry:null,material:null,userData:e.userData};e.isMesh&&(n.geometry=u(e.geometry),n.material=m(e.material));const t=[{object:e,parentData:n}];for(;t.length>0;){const{object:a,parentData:i}=t.pop();for(const r of a.children){const o={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&&(o.geometry=u(r.geometry),o.material=m(r.material)),i.children.push(o),t.push({object:r,parentData:o})}}return n}async function S(e,n=50){const t=[];let a;switch(e.type){case"Mesh":const r=y(e.geometry),o=f(e.material);a=new l.Mesh(r,o);break;case"Group":a=new l.Group;break;case"Object3D":a=new l.Object3D;break;default:return console.warn(`Unsupported object type: ${e.type}`),null}a.name=e.name,a.position.fromArray(e.position),a.rotation.fromArray(e.rotation),a.scale.fromArray(e.scale),a.visible=e.visible,a.userData=e.userData,t.push({data:e,object:a});let i=0;for(;t.length>0;){const{data:r,object:o}=t.pop();for(const s of[...r.children].reverse()){let c;switch(s.type){case"Mesh":const p=y(s.geometry),d=f(s.material);c=new l.Mesh(p,d);break;case"Group":c=new l.Group;break;case"Object3D":c=new l.Object3D;break;default:console.warn(`Unsupported object type: ${s.type}`);continue}c&&(c.name=s.name,c.position.fromArray(s.position),c.rotation.fromArray(s.rotation),c.scale.fromArray(s.scale),c.visible=s.visible,c.userData=s.userData,o.add(c),t.push({data:s,object:c}),i++,i%n===0&&await new Promise(p=>requestAnimationFrame(p)))}}return a}function x(e){const n=[];let t;switch(e.type){case"Mesh":const a=y(e.geometry),i=f(e.material);t=new l.Mesh(a,i);break;case"Group":t=new l.Group;break;case"Object3D":t=new l.Object3D;break;default:return console.warn(`Unsupported object type: ${e.type}`),null}for(t.name=e.name,t.position.fromArray(e.position),t.rotation.fromArray(e.rotation),t.scale.fromArray(e.scale),t.visible=e.visible,t.userData=e.userData,n.push({data:e,object:t});n.length>0;){const{data:a,object:i}=n.pop();for(const r of[...a.children].reverse()){let o;switch(r.type){case"Mesh":const s=y(r.geometry),c=f(r.material);o=new l.Mesh(s,c);break;case"Group":o=new l.Group;break;case"Object3D":o=new l.Object3D;break;default:console.warn(`Unsupported object type: ${r.type}`);continue}o&&(o.name=r.name,o.position.fromArray(r.position),o.rotation.fromArray(r.rotation),o.scale.fromArray(r.scale),o.visible=r.visible,o.userData=r.userData,i.add(o),n.push({data:r,object:o}))}}return t}function u(e){const n={},{attributes:t,index:a,type:i}=e;t.position&&(n.position={type:"Float32Array",array:Array.from(t.position.array),itemSize:3}),t.normal&&(n.normal={type:"Float32Array",array:Array.from(t.normal.array),itemSize:3}),t.uv&&(n.uv={type:"Float32Array",array:Array.from(t.uv.array),itemSize:2});const r={type:i,attributes:n};return a&&a.array&&(r.index={type:"Uint32Array",array:Array.from(a.array),itemSize:1}),r}function y(e){const{type:n,attributes:t,index:a}=e,i=new l.BufferGeometry;for(const r in t)if(t.hasOwnProperty(r)){const{type:o,array:s,itemSize:c}=t[r];i.setAttribute(r,new l.BufferAttribute(new Float32Array(s),c))}return a&&i.setIndex(a.array),i}function m(e){return{type:e.type,color:e.color.getHex(),map:e.map?e.map.image.src:null,opacity:e.opacity,name:e.name,depthTest:e.depthTest,depthWrite:e.depthWrite,transparent:e.transparent,side:e.side,roughness:e.roughness,metalness:e.metalness,emissive:e.emissive.getHex()}}function f(e){if(h[e.name])return h[e.name];const{type:n,...t}=e,a=n||"MeshStandardMaterial",i=new l[a]({...t});if(e.map){const r=new l.TextureLoader().load(e.map);i.map=r}return i.needsUpdate=!0,h[e.name]=i,i}exports.createInfoPlane=w;exports.createTagPlane=A;exports.dataToObject3D=S;exports.dataToObject3DSync=x;exports.getCommonParent=O;exports.object3DToData=j;exports.object3DToDataSync=k;
@@ -1,276 +0,0 @@
1
- import { l as b } from "./ImageLoader-xzOH4Owt.js";
2
- import * as l from "three";
3
- function w(e, o = [0.3, 0.3, 0.3]) {
4
- const t = document.querySelector(`#${e}`);
5
- if (!t) {
6
- console.log(" 获取 infoPlane 元素失败 (id) =====> :", e);
7
- return;
8
- }
9
- const a = t.cloneNode(!0);
10
- a.style.display = "block";
11
- const s = new b(a);
12
- return s.visible = !1, s.scale.set(...o), s;
13
- }
14
- function A(e, o) {
15
- const t = D(e);
16
- t.style.display = "block";
17
- const a = new b(t);
18
- return a.visible = !1, a.scale.set(o, o, o), a;
19
- }
20
- const D = (e) => {
21
- const o = document.createElement("div");
22
- o.style.cssText = `
23
- border-radius: 50px;
24
- border: 2px solid rgba(255, 255, 255, 0.5);
25
- background-color: rgba(15, 20, 22, 0.562);
26
- justify-content: flex-start;
27
- align-items: center;
28
- padding: 20px 30px;
29
- display: flex;
30
- transform-origin: center 0;`;
31
- const t = document.createElement("span");
32
- return t.style.cssText = `
33
- font-size: 40px;
34
- line-height: 1;
35
- white-space: nowrap;
36
- color: #fff;
37
- font-weight: 700;
38
- `, t.innerText = e, o.appendChild(t), o;
39
- }, v = (e, o) => {
40
- const t = {};
41
- e.forEach((r) => {
42
- let n = r.parent;
43
- for (; n; )
44
- t[n.uuid] ? t[n.uuid]++ : t[n.uuid] = 1, n = n.parent;
45
- });
46
- let a = null, s = 0;
47
- for (const r in t)
48
- t[r] > s && (s = t[r], a = o.getObjectByProperty("uuid", r));
49
- return a;
50
- }, h = {};
51
- async function k(e, o = 50) {
52
- const t = {
53
- type: e.type,
54
- name: e.name,
55
- position: e.position.toArray(),
56
- rotation: e.rotation.toArray(),
57
- scale: e.scale.toArray(),
58
- visible: e.visible,
59
- children: [],
60
- geometry: null,
61
- material: null,
62
- userData: e.userData
63
- };
64
- e.isMesh && (t.geometry = u(e.geometry), t.material = m(e.material));
65
- const a = [{ object: e, parentData: t }];
66
- let s = 0;
67
- for (; a.length > 0; ) {
68
- const { object: r, parentData: n } = a.pop();
69
- for (const i of r.children) {
70
- const c = {
71
- type: i.type,
72
- name: i.name,
73
- position: i.position.toArray(),
74
- rotation: i.rotation.toArray(),
75
- scale: i.scale.toArray(),
76
- visible: i.visible,
77
- children: [],
78
- geometry: null,
79
- material: null,
80
- userData: i.userData
81
- };
82
- i.isMesh && (c.geometry = u(i.geometry), c.material = m(i.material)), n.children.push(c), a.push({ object: i, parentData: c }), s++, s % o === 0 && await new Promise((p) => requestAnimationFrame(p));
83
- }
84
- }
85
- return t;
86
- }
87
- function x(e) {
88
- const o = {
89
- type: e.type,
90
- name: e.name,
91
- position: e.position.toArray(),
92
- rotation: e.rotation.toArray(),
93
- scale: e.scale.toArray(),
94
- visible: e.visible,
95
- children: [],
96
- geometry: null,
97
- material: null,
98
- userData: e.userData
99
- };
100
- e.isMesh && (o.geometry = u(e.geometry), o.material = m(e.material));
101
- const t = [{ object: e, parentData: o }];
102
- for (; t.length > 0; ) {
103
- const { object: a, parentData: s } = t.pop();
104
- for (const r of a.children) {
105
- const n = {
106
- type: r.type,
107
- name: r.name,
108
- position: r.position.toArray(),
109
- rotation: r.rotation.toArray(),
110
- scale: r.scale.toArray(),
111
- visible: r.visible,
112
- children: [],
113
- geometry: null,
114
- material: null,
115
- userData: r.userData
116
- };
117
- r.isMesh && (n.geometry = u(r.geometry), n.material = m(r.material)), s.children.push(n), t.push({ object: r, parentData: n });
118
- }
119
- }
120
- return o;
121
- }
122
- async function O(e, o = 50) {
123
- const t = [];
124
- let a;
125
- switch (e.type) {
126
- case "Mesh":
127
- const r = y(e.geometry), n = f(e.material);
128
- a = new l.Mesh(r, n);
129
- break;
130
- case "Group":
131
- a = new l.Group();
132
- break;
133
- case "Object3D":
134
- a = new l.Object3D();
135
- break;
136
- default:
137
- return console.warn(`Unsupported object type: ${e.type}`), null;
138
- }
139
- a.name = e.name, a.position.fromArray(e.position), a.rotation.fromArray(e.rotation), a.scale.fromArray(e.scale), a.visible = e.visible, a.userData = e.userData, t.push({ data: e, object: a });
140
- let s = 0;
141
- for (; t.length > 0; ) {
142
- const { data: r, object: n } = t.pop();
143
- for (const i of [...r.children].reverse()) {
144
- let c;
145
- switch (i.type) {
146
- case "Mesh":
147
- const p = y(i.geometry), d = f(i.material);
148
- c = new l.Mesh(p, d);
149
- break;
150
- case "Group":
151
- c = new l.Group();
152
- break;
153
- case "Object3D":
154
- c = new l.Object3D();
155
- break;
156
- default:
157
- console.warn(`Unsupported object type: ${i.type}`);
158
- continue;
159
- }
160
- c && (c.name = i.name, c.position.fromArray(i.position), c.rotation.fromArray(i.rotation), c.scale.fromArray(i.scale), c.visible = i.visible, c.userData = i.userData, n.add(c), t.push({ data: i, object: c }), s++, s % o === 0 && await new Promise((p) => requestAnimationFrame(p)));
161
- }
162
- }
163
- return a;
164
- }
165
- function M(e) {
166
- const o = [];
167
- let t;
168
- switch (e.type) {
169
- case "Mesh":
170
- const a = y(e.geometry), s = f(e.material);
171
- t = new l.Mesh(a, s);
172
- break;
173
- case "Group":
174
- t = new l.Group();
175
- break;
176
- case "Object3D":
177
- t = new l.Object3D();
178
- break;
179
- default:
180
- return console.warn(`Unsupported object type: ${e.type}`), null;
181
- }
182
- for (t.name = e.name, t.position.fromArray(e.position), t.rotation.fromArray(e.rotation), t.scale.fromArray(e.scale), t.visible = e.visible, t.userData = e.userData, o.push({ data: e, object: t }); o.length > 0; ) {
183
- const { data: a, object: s } = o.pop();
184
- for (const r of [...a.children].reverse()) {
185
- let n;
186
- switch (r.type) {
187
- case "Mesh":
188
- const i = y(r.geometry), c = f(r.material);
189
- n = new l.Mesh(i, c);
190
- break;
191
- case "Group":
192
- n = new l.Group();
193
- break;
194
- case "Object3D":
195
- n = new l.Object3D();
196
- break;
197
- default:
198
- console.warn(`Unsupported object type: ${r.type}`);
199
- continue;
200
- }
201
- n && (n.name = r.name, n.position.fromArray(r.position), n.rotation.fromArray(r.rotation), n.scale.fromArray(r.scale), n.visible = r.visible, n.userData = r.userData, s.add(n), o.push({ data: r, object: n }));
202
- }
203
- }
204
- return t;
205
- }
206
- function u(e) {
207
- const o = {}, { attributes: t, index: a, type: s } = e;
208
- t.position && (o.position = {
209
- type: "Float32Array",
210
- array: Array.from(t.position.array),
211
- itemSize: 3
212
- }), t.normal && (o.normal = {
213
- type: "Float32Array",
214
- array: Array.from(t.normal.array),
215
- itemSize: 3
216
- }), t.uv && (o.uv = {
217
- type: "Float32Array",
218
- array: Array.from(t.uv.array),
219
- itemSize: 2
220
- });
221
- const r = {
222
- type: s,
223
- attributes: o
224
- };
225
- return a && a.array && (r.index = {
226
- type: "Uint32Array",
227
- array: Array.from(a.array),
228
- itemSize: 1
229
- }), r;
230
- }
231
- function y(e) {
232
- const { type: o, attributes: t, index: a } = e, s = new l.BufferGeometry();
233
- for (const r in t)
234
- if (t.hasOwnProperty(r)) {
235
- const { type: n, array: i, itemSize: c } = t[r];
236
- s.setAttribute(
237
- r,
238
- new l.BufferAttribute(new Float32Array(i), c)
239
- );
240
- }
241
- return a && s.setIndex(a.array), s;
242
- }
243
- function m(e) {
244
- return {
245
- type: e.type,
246
- color: e.color.getHex(),
247
- map: e.map ? e.map.image.src : null,
248
- opacity: e.opacity,
249
- name: e.name,
250
- depthTest: e.depthTest,
251
- depthWrite: e.depthWrite,
252
- transparent: e.transparent,
253
- side: e.side,
254
- roughness: e.roughness,
255
- metalness: e.metalness,
256
- emissive: e.emissive.getHex()
257
- };
258
- }
259
- function f(e) {
260
- if (h[e.name]) return h[e.name];
261
- const { type: o, ...t } = e, a = o || "MeshStandardMaterial", s = new l[a]({ ...t });
262
- if (e.map) {
263
- const r = new l.TextureLoader().load(e.map);
264
- s.map = r;
265
- }
266
- return s.needsUpdate = !0, h[e.name] = s, s;
267
- }
268
- export {
269
- A as a,
270
- x as b,
271
- w as c,
272
- O as d,
273
- M as e,
274
- v as g,
275
- k as o
276
- };
@@ -1,2 +0,0 @@
1
- "use strict";const d=require("three"),H=require("vue"),Z=require("./ImageLoader-DwvBWW6h.cjs"),Oe=require("dexie");function fe(f,e){if(e===d.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),f;if(e===d.TriangleFanDrawMode||e===d.TriangleStripDrawMode){let t=f.getIndex();if(t===null){const o=[],a=f.getAttribute("position");if(a!==void 0){for(let i=0;i<a.count;i++)o.push(i);f.setIndex(o),t=f.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),f}const s=t.count-2,n=[];if(e===d.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 r=f.clone();return r.setIndex(n),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),f}const se=new WeakMap;class Pe extends d.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 r=new d.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{this.parse(o,t,n)},s,n)}parse(e,t,s=()=>{}){this.decodeDracoFile(e,t,null,null,d.SRGBColorSpace,s).catch(s)}decodeDracoFile(e,t,s,n,r=d.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:s||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!s,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const s=JSON.stringify(t);if(se.has(e)){const i=se.get(e);if(i.key===s)return i.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 r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(i=>(n=i,new Promise((c,l)=>{n._callbacks[r]={resolve:c,reject:l},n.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(i=>this._createGeometry(i.geometry));return a.catch(()=>!0).then(()=>{n&&r&&this._releaseTask(n,r)}),se.set(e,{key:s,promise:a}),a}_createGeometry(e){const t=new d.BufferGeometry;e.index&&t.setIndex(new d.BufferAttribute(e.index.array,1));for(let s=0;s<e.attributes.length;s++){const n=e.attributes[s],r=n.name,o=n.array,a=n.itemSize,i=new d.BufferAttribute(o,a);r==="color"&&(this._assignVertexColorSpace(i,n.vertexColorSpace),i.normalized=!(o instanceof Float32Array)),t.setAttribute(r,i)}return t}_assignVertexColorSpace(e,t){if(t!==d.SRGBColorSpace)return;const s=new d.Color;for(let n=0,r=e.count;n<r;n++)s.fromBufferAttribute(e,n),d.ColorManagement.colorSpaceToWorking(s,d.SRGBColorSpace),e.setXYZ(n,s.r,s.g,s.b)}_loadLibrary(e,t){const s=new d.FileLoader(this.manager);return s.setPath(this.decoderPath),s.setResponseType(t),s.setWithCredentials(this.withCredentials),new Promise((n,r)=>{s.load(e,n,void 0,r)})}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 r=De.toString(),o=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.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(r){const o=r.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,r){return n._taskLoad>r._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 De(){let f,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":f=a.decoderConfig,e=new Promise(function(l){f.onModuleLoaded=function(u){l({draco:u})},DracoDecoderModule(f)});break;case"decode":const i=a.buffer,c=a.taskConfig;e.then(l=>{const u=l.draco,h=new u.Decoder;try{const p=t(u,h,new Int8Array(i),c),m=p.attributes.map(y=>y.array.buffer);p.index&&m.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},m)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(h)}});break}};function t(o,a,i,c){const l=c.attributeIDs,u=c.attributeTypes;let h,p;const m=a.GetEncodedGeometryType(i);if(m===o.TRIANGULAR_MESH)h=new o.Mesh,p=a.DecodeArrayToMesh(i,i.byteLength,h);else if(m===o.POINT_CLOUD)h=new o.PointCloud,p=a.DecodeArrayToPointCloud(i,i.byteLength,h);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||h.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const y={index:null,attributes:[]};for(const g in l){const T=self[u[g]];let S,E;if(c.useUniqueIDs)E=l[g],S=a.GetAttributeByUniqueId(h,E);else{if(E=a.GetAttributeId(h,o[l[g]]),E===-1)continue;S=a.GetAttribute(h,E)}const R=n(o,a,h,g,T,S);g==="color"&&(R.vertexColorSpace=c.vertexColorSpace),y.attributes.push(R)}return m===o.TRIANGULAR_MESH&&(y.index=s(o,a,h)),o.destroy(h),y}function s(o,a,i){const l=i.num_faces()*3,u=l*4,h=o._malloc(u);a.GetTrianglesUInt32Array(i,u,h);const p=new Uint32Array(o.HEAPF32.buffer,h,l).slice();return o._free(h),{array:p,itemSize:1}}function n(o,a,i,c,l,u){const h=u.num_components(),m=i.num_points()*h,y=m*l.BYTES_PER_ELEMENT,g=r(o,l),T=o._malloc(y);a.GetAttributeDataArrayForAllPoints(i,u,g,y,T);const S=new l(o.HEAPF32.buffer,T,m).slice();return o._free(T),{name:c,array:S,itemSize:h}}function r(o,a){switch(a){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 ke extends d.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ge(t)}),this.register(function(t){return new He(t)}),this.register(function(t){return new Je(t)}),this.register(function(t){return new Qe(t)}),this.register(function(t){return new $e(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Ve(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new Ue(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new ve(t)}),this.register(function(t){return new Ze(t)}),this.register(function(t){return new et(t)})}load(e,t,s,n){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=d.LoaderUtils.extractUrlBase(e);o=d.LoaderUtils.resolveURL(c,this.path)}else o=d.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){n?n(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},i=new d.FileLoader(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(c){try{r.parse(c,o,function(l){t(l),r.manager.itemEnd(e)},a)}catch(l){a(l)}},s,a)}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 r;const o={},a={},i=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(i.decode(new Uint8Array(e,0,4))===Me){try{o[b.KHR_BINARY_GLTF]=new tt(e)}catch(u){n&&n(u);return}r=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else r=JSON.parse(i.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new pt(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let l=0;l<this.pluginCallbacks.length;l++){const u=this.pluginCallbacks[l](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let l=0;l<r.extensionsUsed.length;++l){const u=r.extensionsUsed[l],h=r.extensionsRequired||[];switch(u){case b.KHR_MATERIALS_UNLIT:o[u]=new Be;break;case b.KHR_DRACO_MESH_COMPRESSION:o[u]=new nt(r,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[u]=new st;break;case b.KHR_MESH_QUANTIZATION:o[u]=new rt;break;default:h.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function Fe(){let f={};return{get:function(e){return f[e]},add:function(e,t){f[e]=t},remove:function(e){delete f[e]},removeAll:function(){f={}}}}const b={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 ve{constructor(e){this.parser=e,this.name=b.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 r=t[s];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,s="light:"+e;let n=t.cache.get(s);if(n)return n;const r=t.json,i=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const l=new d.Color(16777215);i.color!==void 0&&l.setRGB(i.color[0],i.color[1],i.color[2],d.LinearSRGBColorSpace);const u=i.range!==void 0?i.range:0;switch(i.type){case"directional":c=new d.DirectionalLight(l),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new d.PointLight(l),c.distance=u;break;case"spot":c=new d.SpotLight(l),c.distance=u,i.spot=i.spot||{},i.spot.innerConeAngle=i.spot.innerConeAngle!==void 0?i.spot.innerConeAngle:0,i.spot.outerConeAngle=i.spot.outerConeAngle!==void 0?i.spot.outerConeAngle:Math.PI/4,c.angle=i.spot.outerConeAngle,c.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return c.position.set(0,0,0),v(c,i),i.intensity!==void 0&&(c.intensity=i.intensity),c.name=t.createUniqueName(i.name||"light_"+e),n=Promise.resolve(c),t.cache.add(s,n),n}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,s=this.parser,r=s.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(i){return s._getNodeRef(t.cache,a,i)})}}class Be{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return d.MeshBasicMaterial}extendParams(e,t,s){const n=[];e.color=new d.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],d.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&n.push(s.assignTexture(e,"map",r.baseColorTexture,d.SRGBColorSpace))}return Promise.all(n)}}class Ue{constructor(e){this.parser=e,this.name=b.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 r=n.extensions[this.name].emissiveStrength;return r!==void 0&&(t.emissiveIntensity=r),Promise.resolve()}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&r.push(s.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&r.push(s.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(r.push(s.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new d.Vector2(a,a)}return Promise.all(r)}}class He{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=r.dispersion!==void 0?r.dispersion:0,Promise.resolve()}}class je{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&r.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&&r.push(s.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(r)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[];t.sheenColor=new d.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=n.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&r.push(s.assignTexture(t,"sheenColorMap",o.sheenColorTexture,d.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&r.push(s.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(r)}}class Ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&r.push(s.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(r)}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&r.push(s.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),Promise.all(r)}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=r.ior!==void 0?r.ior:1.5,Promise.resolve()}}class qe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&r.push(s.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new d.Color().setRGB(a[0],a[1],a[2],d.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&r.push(s.assignTexture(t,"specularColorMap",o.specularColorTexture,d.SRGBColorSpace)),Promise.all(r)}}class We{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],o=n.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&r.push(s.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(r)}}class Ye{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const s=this.parser.json.materials[e];return!s.extensions||!s.extensions[this.name]?null:d.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser,n=s.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=[],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&&r.push(s.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(r)}}class Je{constructor(e){this.parser=e,this.name=b.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 r=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,r.source,o)}}class Qe{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=n.images[o.source];let i=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(i=c)}return s.loadTextureImage(e,o.source,i)}}class $e{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=n.images[o.source];let i=s.textureLoader;if(a.uri){const c=s.options.manager.getHandler(a.uri);c!==null&&(i=c)}return s.loadTextureImage(e,o.source,i)}}class Ze{constructor(e){this.name=b.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],r=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 r.then(function(a){const i=n.byteOffset||0,c=n.byteLength||0,l=n.count,u=n.byteStride,h=new Uint8Array(a,i,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(l,u,h,n.mode,n.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(l*u);return o.decodeGltfBuffer(new Uint8Array(p),l,u,h,n.mode,n.filter),p})})}else return null}}class et{constructor(e){this.name=b.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 c of n.primitives)if(c.mode!==O.TRIANGLES&&c.mode!==O.TRIANGLE_STRIP&&c.mode!==O.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=s.extensions[this.name].attributes,a=[],i={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(l=>(i[c]=l,i[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const l=c.pop(),u=l.isGroup?l.children:[l],h=c[0].count,p=[];for(const m of u){const y=new d.Matrix4,g=new d.Vector3,T=new d.Quaternion,S=new d.Vector3(1,1,1),E=new d.InstancedMesh(m.geometry,m.material,h);for(let R=0;R<h;R++)i.TRANSLATION&&g.fromBufferAttribute(i.TRANSLATION,R),i.ROTATION&&T.fromBufferAttribute(i.ROTATION,R),i.SCALE&&S.fromBufferAttribute(i.SCALE,R),E.setMatrixAt(R,y.compose(g,T,S));for(const R in i)if(R==="_COLOR_0"){const C=i[R];E.instanceColor=new d.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else R!=="TRANSLATION"&&R!=="ROTATION"&&R!=="SCALE"&&m.geometry.setAttribute(R,i[R]);d.Object3D.prototype.copy.call(E,m),this.parser.assignFinalMaterial(E),p.push(E)}return l.isGroup?(l.clear(),l.add(...p),l):p[0]}))}}const Me="glTF",$=12,pe={JSON:1313821514,BIN:5130562};class tt{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,$),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!==Me)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-$,r=new DataView(e,$);let o=0;for(;o<n;){const a=r.getUint32(o,!0);o+=4;const i=r.getUint32(o,!0);if(o+=4,i===pe.JSON){const c=new Uint8Array(e,$+o,a);this.content=s.decode(c)}else if(i===pe.BIN){const c=$+o;this.body=e.slice(c,c+a)}o+=a}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=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const s=this.json,n=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},i={},c={};for(const l in o){const u=ae[l]||l.toLowerCase();a[u]=o[l]}for(const l in e.attributes){const u=ae[l]||l.toLowerCase();if(o[l]!==void 0){const h=s.accessors[e.attributes[l]],p=Y[h.componentType];c[u]=p.name,i[u]=h.normalized===!0}}return t.getDependency("bufferView",r).then(function(l){return new Promise(function(u,h){n.decodeDracoFile(l,function(p){for(const m in p.attributes){const y=p.attributes[m],g=i[m];g!==void 0&&(y.normalized=g)}u(p)},a,c,d.LinearSRGBColorSpace,h)})})}}class st{constructor(){this.name=b.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 rt{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class we extends d.Interpolant{constructor(e,t,s,n){super(e,t,s,n)}copySampleValue_(e){const t=this.resultBuffer,s=this.sampleValues,n=this.valueSize,r=e*n*3+n;for(let o=0;o!==n;o++)t[o]=s[r+o];return t}interpolate_(e,t,s,n){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,i=a*2,c=a*3,l=n-t,u=(s-t)/l,h=u*u,p=h*u,m=e*c,y=m-c,g=-2*p+3*h,T=p-h,S=1-g,E=T-h+u;for(let R=0;R!==a;R++){const C=o[y+R+a],D=o[y+R+i]*l,I=o[m+R+a],B=o[m+R]*l;r[R]=S*C+E*D+g*I+T*B}return r}}const ot=new d.Quaternion;class it extends we{interpolate_(e,t,s,n){const r=super.interpolate_(e,t,s,n);return ot.fromArray(r).normalize().toArray(r),r}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Y={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},me={9728:d.NearestFilter,9729:d.LinearFilter,9984:d.NearestMipmapNearestFilter,9985:d.LinearMipmapNearestFilter,9986:d.NearestMipmapLinearFilter,9987:d.LinearMipmapLinearFilter},ge={33071:d.ClampToEdgeWrapping,33648:d.MirroredRepeatWrapping,10497:d.RepeatWrapping},re={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ae={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"},j={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},at={CUBICSPLINE:void 0,LINEAR:d.InterpolateLinear,STEP:d.InterpolateDiscrete},oe={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function ct(f){return f.DefaultMaterial===void 0&&(f.DefaultMaterial=new d.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:d.FrontSide})),f.DefaultMaterial}function V(f,e,t){for(const s in t.extensions)f[s]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[s]=t.extensions[s])}function v(f,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(f.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function lt(f,e,t){let s=!1,n=!1,r=!1;for(let c=0,l=e.length;c<l;c++){const u=e[c];if(u.POSITION!==void 0&&(s=!0),u.NORMAL!==void 0&&(n=!0),u.COLOR_0!==void 0&&(r=!0),s&&n&&r)break}if(!s&&!n&&!r)return Promise.resolve(f);const o=[],a=[],i=[];for(let c=0,l=e.length;c<l;c++){const u=e[c];if(s){const h=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):f.attributes.position;o.push(h)}if(n){const h=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):f.attributes.normal;a.push(h)}if(r){const h=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):f.attributes.color;i.push(h)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(i)]).then(function(c){const l=c[0],u=c[1],h=c[2];return s&&(f.morphAttributes.position=l),n&&(f.morphAttributes.normal=u),r&&(f.morphAttributes.color=h),f.morphTargetsRelative=!0,f})}function ut(f,e){if(f.updateMorphTargets(),e.weights!==void 0)for(let t=0,s=e.weights.length;t<s;t++)f.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(f.morphTargetInfluences.length===t.length){f.morphTargetDictionary={};for(let s=0,n=t.length;s<n;s++)f.morphTargetDictionary[t[s]]=s}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function dt(f){let e;const t=f.extensions&&f.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+ie(t.attributes):e=f.indices+":"+ie(f.attributes)+":"+f.mode,f.targets!==void 0)for(let s=0,n=f.targets.length;s<n;s++)e+=":"+ie(f.targets[s]);return e}function ie(f){let e="";const t=Object.keys(f).sort();for(let s=0,n=t.length;s<n;s++)e+=t[s]+":"+f[t[s]]+";";return e}function ce(f){switch(f){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 ht(f){return f.search(/\.jpe?g($|\?)/i)>0||f.search(/^data\:image\/jpeg/)===0?"image/jpeg":f.search(/\.webp($|\?)/i)>0||f.search(/^data\:image\/webp/)===0?"image/webp":f.search(/\.ktx2($|\?)/i)>0||f.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ft=new d.Matrix4;class pt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Fe,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,r=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;s=/^((?!chrome|android).)*safari/i.test(a)===!0;const i=a.match(/Version\/(\d+)/);n=s&&i?parseInt(i[1],10):-1,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||s&&n<17||r&&o<98?this.textureLoader=new d.TextureLoader(this.options.manager):this.textureLoader=new d.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new d.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,r=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 a={scene:o[0][n.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:n.asset,parser:s,userData:{}};return V(r,a,n),v(a,n),Promise.all(s._invokeAll(function(i){return i.afterRoot&&i.afterRoot(a)})).then(function(){for(const i of a.scenes)i.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const o=t[n].joints;for(let a=0,i=o.length;a<i;a++)e[o[a]].isBone=!0}for(let n=0,r=e.length;n<r;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(),r=(o,a)=>{const i=this.associations.get(o);i!=null&&this.associations.set(a,i);for(const[c,l]of o.children.entries())r(l,a.children[c])};return r(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 r=e(t[n]);r&&s.push(r)}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(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":n=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.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(r,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[b.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(r,o){s.load(d.LoaderUtils.resolveURL(t.uri,n.path),r,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,r=t.byteOffset||0;return s.slice(r,r+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=re[n.type],a=Y[n.componentType],i=n.normalized===!0,c=new a(n.count*o);return Promise.resolve(new d.BufferAttribute(c,o,i))}const r=[];return n.bufferView!==void 0?r.push(this.getDependency("bufferView",n.bufferView)):r.push(null),n.sparse!==void 0&&(r.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],i=re[n.type],c=Y[n.componentType],l=c.BYTES_PER_ELEMENT,u=l*i,h=n.byteOffset||0,p=n.bufferView!==void 0?s.bufferViews[n.bufferView].byteStride:void 0,m=n.normalized===!0;let y,g;if(p&&p!==u){const T=Math.floor(h/p),S="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+T+":"+n.count;let E=t.cache.get(S);E||(y=new c(a,T*p,n.count*p/l),E=new d.InterleavedBuffer(y,p/l),t.cache.add(S,E)),g=new d.InterleavedBufferAttribute(E,i,h%p/l,m)}else a===null?y=new c(n.count*i):y=new c(a,h,n.count*i),g=new d.BufferAttribute(y,i,m);if(n.sparse!==void 0){const T=re.SCALAR,S=Y[n.sparse.indices.componentType],E=n.sparse.indices.byteOffset||0,R=n.sparse.values.byteOffset||0,C=new S(o[1],E,n.sparse.count*T),D=new c(o[2],R,n.sparse.count*i);a!==null&&(g=new d.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let I=0,B=C.length;I<B;I++){const k=C[I];if(g.setX(k,D[I*i]),i>=2&&g.setY(k,D[I*i+1]),i>=3&&g.setZ(k,D[I*i+2]),i>=4&&g.setW(k,D[I*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=m}return g})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const i=s.manager.getHandler(o.uri);i!==null&&(a=i)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,s){const n=this,r=this.json,o=r.textures[e],a=r.images[t],i=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[i])return this.textureCache[i];const c=this.loadImageSource(t,s).then(function(l){l.flipY=!1,l.name=o.name||a.name||"",l.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(l.name=a.uri);const h=(r.samplers||{})[o.sampler]||{};return l.magFilter=me[h.magFilter]||d.LinearFilter,l.minFilter=me[h.minFilter]||d.LinearMipmapLinearFilter,l.wrapS=ge[h.wrapS]||d.RepeatWrapping,l.wrapT=ge[h.wrapT]||d.RepeatWrapping,l.generateMipmaps=!l.isCompressedTexture&&l.minFilter!==d.NearestFilter&&l.minFilter!==d.LinearFilter,n.associations.set(l,{textures:e}),l}).catch(function(){return null});return this.textureCache[i]=c,c}loadImageSource(e,t){const s=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=n.images[e],a=self.URL||self.webkitURL;let i=o.uri||"",c=!1;if(o.bufferView!==void 0)i=s.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const h=new Blob([u],{type:o.mimeType});return i=a.createObjectURL(h),i});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(i).then(function(u){return new Promise(function(h,p){let m=h;t.isImageBitmapLoader===!0&&(m=function(y){const g=new d.Texture(y);g.needsUpdate=!0,h(g)}),t.load(d.LoaderUtils.resolveURL(u,r.path),m,void 0,p)})}).then(function(u){return c===!0&&a.revokeObjectURL(i),v(u,o),u.userData.mimeType=o.mimeType||ht(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",i),u});return this.sourceCache[e]=l,l}assignTexture(e,t,s,n){const r=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),r.extensions[b.KHR_TEXTURE_TRANSFORM]){const a=s.extensions!==void 0?s.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const i=r.associations.get(o);o=r.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,i)}}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,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+s.uuid;let i=this.cache.get(a);i||(i=new d.PointsMaterial,d.Material.prototype.copy.call(i,s),i.color.copy(s.color),i.map=s.map,i.sizeAttenuation=!1,this.cache.add(a,i)),s=i}else if(e.isLine){const a="LineBasicMaterial:"+s.uuid;let i=this.cache.get(a);i||(i=new d.LineBasicMaterial,d.Material.prototype.copy.call(i,s),i.color.copy(s.color),i.map=s.map,this.cache.add(a,i)),s=i}if(n||r||o){let a="ClonedMaterial:"+s.uuid+":";n&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let i=this.cache.get(a);i||(i=s.clone(),r&&(i.vertexColors=!0),o&&(i.flatShading=!0),n&&(i.normalScale&&(i.normalScale.y*=-1),i.clearcoatNormalScale&&(i.clearcoatNormalScale.y*=-1)),this.cache.add(a,i),this.associations.set(i,this.associations.get(s))),s=i}e.material=s}getMaterialType(){return d.MeshStandardMaterial}loadMaterial(e){const t=this,s=this.json,n=this.extensions,r=s.materials[e];let o;const a={},i=r.extensions||{},c=[];if(i[b.KHR_MATERIALS_UNLIT]){const u=n[b.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new d.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const h=u.baseColorFactor;a.color.setRGB(h[0],h[1],h[2],d.LinearSRGBColorSpace),a.opacity=h[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,d.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(h){return h.getMaterialType&&h.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(h){return h.extendMaterialParams&&h.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=d.DoubleSide);const l=r.alphaMode||oe.OPAQUE;if(l===oe.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,l===oe.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==d.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new d.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==d.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==d.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new d.Color().setRGB(u[0],u[1],u[2],d.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==d.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,d.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return r.name&&(u.name=r.name),v(u,r),t.associations.set(u,{materials:e}),r.extensions&&V(n,u,r),u})}createUniqueName(e){const t=d.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 r(a){return s[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(i){return Te(i,a,t)})}const o=[];for(let a=0,i=e.length;a<i;a++){const c=e[a],l=dt(c),u=n[l];if(u)o.push(u.promise);else{let h;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?h=r(c):h=Te(new d.BufferGeometry,c,t),n[l]={primitive:c,promise:h},o.push(h)}}return Promise.all(o)}loadMesh(e){const t=this,s=this.json,n=this.extensions,r=s.meshes[e],o=r.primitives,a=[];for(let i=0,c=o.length;i<c;i++){const l=o[i].material===void 0?ct(this.cache):this.getDependency("material",o[i].material);a.push(l)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(i){const c=i.slice(0,i.length-1),l=i[i.length-1],u=[];for(let p=0,m=l.length;p<m;p++){const y=l[p],g=o[p];let T;const S=c[p];if(g.mode===O.TRIANGLES||g.mode===O.TRIANGLE_STRIP||g.mode===O.TRIANGLE_FAN||g.mode===void 0)T=r.isSkinnedMesh===!0?new d.SkinnedMesh(y,S):new d.Mesh(y,S),T.isSkinnedMesh===!0&&T.normalizeSkinWeights(),g.mode===O.TRIANGLE_STRIP?T.geometry=fe(T.geometry,d.TriangleStripDrawMode):g.mode===O.TRIANGLE_FAN&&(T.geometry=fe(T.geometry,d.TriangleFanDrawMode));else if(g.mode===O.LINES)T=new d.LineSegments(y,S);else if(g.mode===O.LINE_STRIP)T=new d.Line(y,S);else if(g.mode===O.LINE_LOOP)T=new d.LineLoop(y,S);else if(g.mode===O.POINTS)T=new d.Points(y,S);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(T.geometry.morphAttributes).length>0&&ut(T,r),T.name=t.createUniqueName(r.name||"mesh_"+e),v(T,r),g.extensions&&V(n,T,g),t.assignFinalMaterial(T),u.push(T)}for(let p=0,m=u.length;p<m;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return r.extensions&&V(n,u[0],r),u[0];const h=new d.Group;r.extensions&&V(n,h,r),t.associations.set(h,{meshes:e});for(let p=0,m=u.length;p<m;p++)h.add(u[p]);return h})}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 d.PerspectiveCamera(d.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):s.type==="orthographic"&&(t=new d.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),s.name&&(t.name=this.createUniqueName(s.name)),v(t,s),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],s=[];for(let n=0,r=t.joints.length;n<r;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 r=n.pop(),o=n,a=[],i=[];for(let c=0,l=o.length;c<l;c++){const u=o[c];if(u){a.push(u);const h=new d.Matrix4;r!==null&&h.fromArray(r.array,c*16),i.push(h)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new d.Skeleton(a,i)})}loadAnimation(e){const t=this.json,s=this,n=t.animations[e],r=n.name?n.name:"animation_"+e,o=[],a=[],i=[],c=[],l=[];for(let u=0,h=n.channels.length;u<h;u++){const p=n.channels[u],m=n.samplers[p.sampler],y=p.target,g=y.node,T=n.parameters!==void 0?n.parameters[m.input]:m.input,S=n.parameters!==void 0?n.parameters[m.output]:m.output;y.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",T)),i.push(this.getDependency("accessor",S)),c.push(m),l.push(y))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(i),Promise.all(c),Promise.all(l)]).then(function(u){const h=u[0],p=u[1],m=u[2],y=u[3],g=u[4],T=[];for(let S=0,E=h.length;S<E;S++){const R=h[S],C=p[S],D=m[S],I=y[S],B=g[S];if(R===void 0)continue;R.updateMatrix&&R.updateMatrix();const k=s._createAnimationTracks(R,C,D,I,B);if(k)for(let J=0;J<k.length;J++)T.push(k[J])}return new d.AnimationClip(r,void 0,T)})}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(r){const o=s._getNodeRef(s.meshCache,n.mesh,r);return n.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let i=0,c=n.weights.length;i<c;i++)a.morphTargetInfluences[i]=n.weights[i]}),o})}loadNode(e){const t=this.json,s=this,n=t.nodes[e],r=s._loadNodeShallow(e),o=[],a=n.children||[];for(let c=0,l=a.length;c<l;c++)o.push(s.getDependency("node",a[c]));const i=n.skin===void 0?Promise.resolve(null):s.getDependency("skin",n.skin);return Promise.all([r,Promise.all(o),i]).then(function(c){const l=c[0],u=c[1],h=c[2];h!==null&&l.traverse(function(p){p.isSkinnedMesh&&p.bind(h,ft)});for(let p=0,m=u.length;p<m;p++)l.add(u[p]);return l})}_loadNodeShallow(e){const t=this.json,s=this.extensions,n=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?n.createUniqueName(r.name):"",a=[],i=n._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return i&&a.push(i),r.camera!==void 0&&a.push(n.getDependency("camera",r.camera).then(function(c){return n._getNodeRef(n.cameraCache,r.camera,c)})),n._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let l;if(r.isBone===!0?l=new d.Bone:c.length>1?l=new d.Group:c.length===1?l=c[0]:l=new d.Object3D,l!==c[0])for(let u=0,h=c.length;u<h;u++)l.add(c[u]);if(r.name&&(l.userData.name=r.name,l.name=o),v(l,r),r.extensions&&V(s,l,r),r.matrix!==void 0){const u=new d.Matrix4;u.fromArray(r.matrix),l.applyMatrix4(u)}else r.translation!==void 0&&l.position.fromArray(r.translation),r.rotation!==void 0&&l.quaternion.fromArray(r.rotation),r.scale!==void 0&&l.scale.fromArray(r.scale);if(!n.associations.has(l))n.associations.set(l,{});else if(r.mesh!==void 0&&n.meshCache.refs[r.mesh]>1){const u=n.associations.get(l);n.associations.set(l,{...u})}return n.associations.get(l).nodes=e,l}),this.nodeCache[e]}loadScene(e){const t=this.extensions,s=this.json.scenes[e],n=this,r=new d.Group;s.name&&(r.name=n.createUniqueName(s.name)),v(r,s),s.extensions&&V(t,r,s);const o=s.nodes||[],a=[];for(let i=0,c=o.length;i<c;i++)a.push(n.getDependency("node",o[i]));return Promise.all(a).then(function(i){for(let l=0,u=i.length;l<u;l++)r.add(i[l]);const c=l=>{const u=new Map;for(const[h,p]of n.associations)(h instanceof d.Material||h instanceof d.Texture)&&u.set(h,p);return l.traverse(h=>{const p=n.associations.get(h);p!=null&&u.set(h,p)}),u};return n.associations=c(r),r})}_createAnimationTracks(e,t,s,n,r){const o=[],a=e.name?e.name:e.uuid,i=[];j[r.path]===j.weights?e.traverse(function(h){h.morphTargetInfluences&&i.push(h.name?h.name:h.uuid)}):i.push(a);let c;switch(j[r.path]){case j.weights:c=d.NumberKeyframeTrack;break;case j.rotation:c=d.QuaternionKeyframeTrack;break;case j.translation:case j.scale:c=d.VectorKeyframeTrack;break;default:switch(s.itemSize){case 1:c=d.NumberKeyframeTrack;break;case 2:case 3:default:c=d.VectorKeyframeTrack;break}break}const l=n.interpolation!==void 0?at[n.interpolation]:d.InterpolateLinear,u=this._getArrayFromAccessor(s);for(let h=0,p=i.length;h<p;h++){const m=new c(i[h]+"."+j[r.path],t.array,u,l);n.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const s=ce(t.constructor),n=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)n[r]=t[r]*s;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(s){const n=this instanceof d.QuaternionKeyframeTrack?it:we;return new n(this.times,this.values,this.getValueSize()/3,s)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function mt(f,e,t){const s=e.attributes,n=new d.Box3;if(s.POSITION!==void 0){const a=t.json.accessors[s.POSITION],i=a.min,c=a.max;if(i!==void 0&&c!==void 0){if(n.set(new d.Vector3(i[0],i[1],i[2]),new d.Vector3(c[0],c[1],c[2])),a.normalized){const l=ce(Y[a.componentType]);n.min.multiplyScalar(l),n.max.multiplyScalar(l)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new d.Vector3,i=new d.Vector3;for(let c=0,l=r.length;c<l;c++){const u=r[c];if(u.POSITION!==void 0){const h=t.json.accessors[u.POSITION],p=h.min,m=h.max;if(p!==void 0&&m!==void 0){if(i.setX(Math.max(Math.abs(p[0]),Math.abs(m[0]))),i.setY(Math.max(Math.abs(p[1]),Math.abs(m[1]))),i.setZ(Math.max(Math.abs(p[2]),Math.abs(m[2]))),h.normalized){const y=ce(Y[h.componentType]);i.multiplyScalar(y)}a.max(i)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}n.expandByVector(a)}f.boundingBox=n;const o=new d.Sphere;n.getCenter(o.center),o.radius=n.min.distanceTo(n.max)/2,f.boundingSphere=o}function Te(f,e,t){const s=e.attributes,n=[];function r(o,a){return t.getDependency("accessor",o).then(function(i){f.setAttribute(a,i)})}for(const o in s){const a=ae[o]||o.toLowerCase();a in f.attributes||n.push(r(s[o],a))}if(e.indices!==void 0&&!f.index){const o=t.getDependency("accessor",e.indices).then(function(a){f.setIndex(a)});n.push(o)}return d.ColorManagement.workingColorSpace!==d.LinearSRGBColorSpace&&"COLOR_0"in s&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${d.ColorManagement.workingColorSpace}" not supported.`),v(f,e),mt(f,e,t),Promise.all(n).then(function(){return e.targets!==void 0?lt(f,e.targets,t):f})}const A={c:null,u:[new d.Vector3,new d.Vector3,new d.Vector3],e:[]},M={c:null,u:[new d.Vector3,new d.Vector3,new d.Vector3],e:[]},L=[[],[],[]],x=[[],[],[]],w=[],K=new d.Vector3,X=new d.Vector3,q=new d.Vector3,_=new d.Vector3,ye=new d.Vector3,xe=new d.Vector3,P=new d.Matrix3,Re=new d.Box3,ee=new d.Matrix4,be=new d.Matrix4,Se=new d.Ray;class le{constructor(e=new d.Vector3,t=new d.Vector3,s=new d.Matrix3){this.center=e,this.halfSize=t,this.rotation=s}set(e,t,s){return this.center=e,this.halfSize=t,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,t){const s=this.halfSize;_.subVectors(e,this.center),this.rotation.extractBasis(K,X,q),t.copy(this.center);const n=d.MathUtils.clamp(_.dot(K),-s.x,s.x);t.add(K.multiplyScalar(n));const r=d.MathUtils.clamp(_.dot(X),-s.y,s.y);t.add(X.multiplyScalar(r));const o=d.MathUtils.clamp(_.dot(q),-s.z,s.z);return t.add(q.multiplyScalar(o)),t}containsPoint(e){return _.subVectors(e,this.center),this.rotation.extractBasis(K,X,q),Math.abs(_.dot(K))<=this.halfSize.x&&Math.abs(_.dot(X))<=this.halfSize.y&&Math.abs(_.dot(q))<=this.halfSize.z}intersectsBox3(e){return this.intersectsOBB(gt.fromBox3(e))}intersectsSphere(e){return this.clampPoint(e.center,xe),xe.distanceToSquared(e.center)<=e.radius*e.radius}intersectsOBB(e,t=Number.EPSILON){A.c=this.center,A.e[0]=this.halfSize.x,A.e[1]=this.halfSize.y,A.e[2]=this.halfSize.z,this.rotation.extractBasis(A.u[0],A.u[1],A.u[2]),M.c=e.center,M.e[0]=e.halfSize.x,M.e[1]=e.halfSize.y,M.e[2]=e.halfSize.z,e.rotation.extractBasis(M.u[0],M.u[1],M.u[2]);for(let r=0;r<3;r++)for(let o=0;o<3;o++)L[r][o]=A.u[r].dot(M.u[o]);_.subVectors(M.c,A.c),w[0]=_.dot(A.u[0]),w[1]=_.dot(A.u[1]),w[2]=_.dot(A.u[2]);for(let r=0;r<3;r++)for(let o=0;o<3;o++)x[r][o]=Math.abs(L[r][o])+t;let s,n;for(let r=0;r<3;r++)if(s=A.e[r],n=M.e[0]*x[r][0]+M.e[1]*x[r][1]+M.e[2]*x[r][2],Math.abs(w[r])>s+n)return!1;for(let r=0;r<3;r++)if(s=A.e[0]*x[0][r]+A.e[1]*x[1][r]+A.e[2]*x[2][r],n=M.e[r],Math.abs(w[0]*L[0][r]+w[1]*L[1][r]+w[2]*L[2][r])>s+n)return!1;return s=A.e[1]*x[2][0]+A.e[2]*x[1][0],n=M.e[1]*x[0][2]+M.e[2]*x[0][1],!(Math.abs(w[2]*L[1][0]-w[1]*L[2][0])>s+n||(s=A.e[1]*x[2][1]+A.e[2]*x[1][1],n=M.e[0]*x[0][2]+M.e[2]*x[0][0],Math.abs(w[2]*L[1][1]-w[1]*L[2][1])>s+n)||(s=A.e[1]*x[2][2]+A.e[2]*x[1][2],n=M.e[0]*x[0][1]+M.e[1]*x[0][0],Math.abs(w[2]*L[1][2]-w[1]*L[2][2])>s+n)||(s=A.e[0]*x[2][0]+A.e[2]*x[0][0],n=M.e[1]*x[1][2]+M.e[2]*x[1][1],Math.abs(w[0]*L[2][0]-w[2]*L[0][0])>s+n)||(s=A.e[0]*x[2][1]+A.e[2]*x[0][1],n=M.e[0]*x[1][2]+M.e[2]*x[1][0],Math.abs(w[0]*L[2][1]-w[2]*L[0][1])>s+n)||(s=A.e[0]*x[2][2]+A.e[2]*x[0][2],n=M.e[0]*x[1][1]+M.e[1]*x[1][0],Math.abs(w[0]*L[2][2]-w[2]*L[0][2])>s+n)||(s=A.e[0]*x[1][0]+A.e[1]*x[0][0],n=M.e[1]*x[2][2]+M.e[2]*x[2][1],Math.abs(w[1]*L[0][0]-w[0]*L[1][0])>s+n)||(s=A.e[0]*x[1][1]+A.e[1]*x[0][1],n=M.e[0]*x[2][2]+M.e[2]*x[2][0],Math.abs(w[1]*L[0][1]-w[0]*L[1][1])>s+n)||(s=A.e[0]*x[1][2]+A.e[1]*x[0][2],n=M.e[0]*x[2][1]+M.e[1]*x[2][0],Math.abs(w[1]*L[0][2]-w[0]*L[1][2])>s+n))}intersectsPlane(e){this.rotation.extractBasis(K,X,q);const t=this.halfSize.x*Math.abs(e.normal.dot(K))+this.halfSize.y*Math.abs(e.normal.dot(X))+this.halfSize.z*Math.abs(e.normal.dot(q)),s=e.normal.dot(this.center)-e.constant;return Math.abs(s)<=t}intersectRay(e,t){return this.getSize(ye),Re.setFromCenterAndSize(_.set(0,0,0),ye),ee.setFromMatrix3(this.rotation),ee.setPosition(this.center),be.copy(ee).invert(),Se.copy(e).applyMatrix4(be),Se.intersectBox(Re,t)?t.applyMatrix4(ee):null}intersectsRay(e){return this.intersectRay(e,_)!==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 t=e.elements;let s=_.set(t[0],t[1],t[2]).length();const n=_.set(t[4],t[5],t[6]).length(),r=_.set(t[8],t[9],t[10]).length();e.determinant()<0&&(s=-s),P.setFromMatrix4(e);const a=1/s,i=1/n,c=1/r;return P.elements[0]*=a,P.elements[1]*=a,P.elements[2]*=a,P.elements[3]*=i,P.elements[4]*=i,P.elements[5]*=i,P.elements[6]*=c,P.elements[7]*=c,P.elements[8]*=c,this.rotation.multiply(P),this.halfSize.x*=s,this.halfSize.y*=n,this.halfSize.z*=r,_.setFromMatrixPosition(e),this.center.add(_),this}}const gt=new le,Tt={enableDamping:!0,dampingFactor:.25,screenSpacePanning:!1,minDistance:.1,maxDistance:1e3,maxPolarAngle:d.MathUtils.degToRad(60)};function yt(f,e){const t=Object.assign({css3d:!1,stats:!1,renderType:"change",control:{init:!0,options:{}}},e||{});let s,n,r,o=[];const a=H.ref(!1),i=H.shallowRef(),c=H.ref(0),l=H.ref(0),u=new d.WebGLRenderer({antialias:!0,alpha:!0,precision:"mediump",logarithmicDepthBuffer:!0}),h=new d.Scene({}),p=new d.PerspectiveCamera(50,1,.1,2e3),m=Math.tan(Math.PI/180*p.fov/2);let y=!1;u.setPixelRatio(window.devicePixelRatio);function g(){a.value=!1;const N=B();c.value=N[0],l.value=N[1],p.aspect=c.value/l.value,p.position.set(47,39,100),p.fov=360/Math.PI*Math.atan(m*(l.value/c.value)),p.lookAt(0,0,0),p.updateProjectionMatrix(),u.setSize(c.value,l.value),s.appendChild(u.domElement),t.stats&&k(),t.css3d&&Le();let U;if(t.control&&t.control.init){U=Z.createOrbitControl(p,u.domElement);const G=Object.assign(Tt,t.control.options||{});Object.keys(G).forEach(Q=>{U[Q]=G[Q]})}return H.nextTick(()=>a.value=!0),U}function T(N){N.preventDefault(),cancelAnimationFrame(R)}function S(N){N.preventDefault(),g(),R()}function E(N){o.push(N)}function R(N){o&&o.length&&o.forEach(U=>{typeof U=="function"&&U()}),t.renderType==="loop"&&C(),requestAnimationFrame(R)}function C(){y=!1,n&&n.update(),i.value&&i.value.update(),u.render(h,p),r&&r.render(h,p)}function D(){y||(y=!0,requestAnimationFrame(C))}function I(){H.nextTick(()=>{const N=B();c.value=N[0],l.value=N[1],p.aspect=c.value/l.value,p.fov=360/Math.PI*Math.atan(m*(l.value/c.value)),p.updateProjectionMatrix(),p.lookAt(h.position),u.setSize(c.value,l.value),r&&r.setSize(c.value,l.value),C()})}function B(){return s=document.querySelector(f),s?[s.clientWidth,s.clientHeight]:[0,0]}function k(){n=new Z.Stats,n.dom.style.cssText="position:absolute;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.appendChild(n.dom)}function J(N,U,G,Q,ue){const de=new d.Box3().setFromObject(N),he=de.getSize(new d.Vector3).length(),z=de.getCenter(new d.Vector3);ue&&z.add(ue);const Ce=he*U*.5,Ie=d.MathUtils.degToRad(G.fov*.5),Ne=Ce/Math.tan(Ie),ne=new d.Vector3().subVectors(G.position,z).multiply(new d.Vector3(1,1,1)).normalize().multiplyScalar(Ne).add(z),W={x:ne.x,y:ne.y,z:ne.z,lookAt_x:z.x,lookAt_y:z.y,lookAt_z:z.z};return G.position.set(W.x,W.y,W.z),G.lookAt(W.lookAt_x,W.lookAt_y,W.lookAt_z),G.updateProjectionMatrix(),Q.target.copy(z),Q.update(),he}function Le(){r=new Z.CSS3DRenderer,r.setSize(c.value,l.value),r.domElement.style.position="absolute",r.domElement.style.top=0,r.domElement.style.left=0,r.domElement.style.pointerEvents="none",s.appendChild(r.domElement)}function _e(){Z.disposeThreeObject(h)}return H.onMounted(()=>{i.value=g(),window.addEventListener("resize",I,!1),u.domElement.addEventListener("webglcontextlost",T,!1),u.domElement.addEventListener("webglcontextrestored",S,!1),t.renderType==="loop"?requestAnimationFrame(R):t.renderType==="change"&&i.value&&i.value.addEventListener("change",D)}),H.onUnmounted(()=>{cancelAnimationFrame(R),u.domElement.removeEventListener("resize",I,!1),u.domElement.removeEventListener("webglcontextlost",T,!1),u.domElement.removeEventListener("webglcontextrestored",S,!1),_e()}),{addAnimate:E,frameArea:J,onRender:C,css3dRenderer:r,scene:h,camera:p,control:i,renderer:u,domWidth:c,domHeight:l,isReady:a}}const xt=(f="app")=>{const e=new d.Raycaster;e.params.Line.threshold=8;const t=new d.Vector2,s=document.getElementById(f);function n(a,i){const{scaleX:c,scaleY:l}=o(s),{clientWidth:u,clientHeight:h}=i,p=i.getBoundingClientRect(),m=u*c,y=h*l,g=a.clientX-p.left,T=a.clientY-p.top;return t.x=(a.clientX-p.left)/m*2-1,t.y=-((a.clientY-p.top)/y)*2+1,{pointer:t,x:g,y:T}}function r(a,i,c,l){const{pointer:u,x:h,y:p}=n(a,i);return e.setFromCamera(u,c),{intersects:e.intersectObjects(l),pointer:u,x:h,y:p}}function o(a){const i=window.getComputedStyle(a),c=i.transform||i.webkitTransform||i.mozTransform;if(c&&c!=="none"){const l=c.match(/^matrix\((.+)\)$/);if(l){const u=l[1].split(", "),h=parseFloat(u[0]),p=parseFloat(u[3]);return{scaleX:h,scaleY:p}}}return{scaleX:1,scaleY:1}}return{raycaster:e,pointer:t,getPointer:n,getScale:o,getIntersects:r}},F=[],Rt=new d.Color(16711680),bt=()=>{const f=()=>{F.splice(0)},e=(a,i)=>{i.traverse(c=>{c&&t(a,c)})},t=(a,i)=>{if(i.userData.needCheck&&(i.autoUpdateMatrix=!1,i.updateMatrix(),i.updateMatrixWorld(),i.isMesh)){const c=new d.Box3(new d.Vector3).setFromObject(i);i.geometry.userData.obb=new le,i.geometry.userData.obb.halfSize.copy(c.getSize(new d.Vector3)).multiplyScalar(.5).multiplyScalar(.88),i.userData.obb=new le,i.userData.originColor=i.material.color.clone(),i.userData.parentUid=a,F.push({object:i,parentUid:a})}};return{resetObbs:f,initObb:e,getObbObjectByParentUid:a=>F.filter(i=>i.parentUid===a),addObbFromArray:(a,i)=>{for(let c=0,l=i.length;c<l;c++)t(a,i[c])},removeObbFromArray:a=>{const i=F.filter(c=>!a.includes(c.object));F.splice(0,F.length,...i)},removeUidObb:a=>{for(let i=F.length-1;i>=0;i--)F[i].parentUid===a&&F.splice(i,1)}}},Ae=4;class Ee{constructor(e="threeJsIDBCache"){this.version=Ae,this.dbName=e,this.dbInit()}dbInit(){this.db=new Oe(this.dbName),this.db.version(this.version).stores({models:"&path, version"}).upgrade(async e=>{console.log("[ IDBCache 版本更新 ] ====> version",Ae);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.db.table("models").put({path:e,version:t,data:s})}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):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}}let te;const St=()=>{const f=new ke,e=new Pe;e.setDecoderPath("/draco/"),f.setDRACOLoader(e);function t(i,c,l,u){return f.load(i,c,l,u)}function s(i,c){return new Promise((l,u)=>{f.load(i,l,c,u)})}async function n(i,c){try{console.log("[ 读取缓存 ] ====> "),console.time("[ 读取缓存耗时 ] ");let l=await o(i,c);console.timeEnd("[ 读取缓存耗时 ] "),l||(console.log("[ 读取缓存 ] ====> 缓存未命中,开始加载模型"),console.time("[ fetchArrayBuffer ] ====> 加载模型耗时"),l=await r(i),console.log("[ asyncFetch ] ====> arrayBuffer",l),console.timeEnd("[ fetchArrayBuffer ] ====> 加载模型耗时"),te.saveModel(i,c,l)),console.log("[ 开始解析模型 ] ====> "),console.time("[ 解析模型耗时 ]");const u=await a(l);return console.timeEnd("[ 解析模型耗时 ]"),u.scene}catch(l){return console.error(`加载模型 ${i} 失败:`,l),null}}async function r(i){return new Promise((c,l)=>{fetch(i).then(u=>u.arrayBuffer()).then(u=>{c(u)}).catch(u=>{l(u)})})}async function o(i,c){return te||(te=new Ee),te.getModel(i,c)}async function a(i){return new Promise((c,l)=>{f.parse(i,"",c,l)})}return{load:t,asyncLoad:s,asyncCacheLoad:n,asyncFetch:n}};exports.IDBCache=Ee;exports.intersectColor=Rt;exports.obbObjects=F;exports.useGLTFLoader=St;exports.useObb=bt;exports.useRaycaster=xt;exports.useThreeJs=yt;