iflow-engine-base 2.1.3 → 2.1.5
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/bim-engine-sdk.es.js +412 -389
- package/dist/bim-engine-sdk.es.js.map +1 -1
- package/dist/bim-engine-sdk.umd.js +2 -2
- package/dist/bim-engine-sdk.umd.js.map +1 -1
- package/dist/iflow-engine-base.css +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/model1/info~/info.json +1 -0
- package/dist/model1/lod0~/instances.json +1 -0
- package/dist/model1/lod0~/nodes.json +1 -0
- package/dist/model1/lod0~/primitives/0.glb +0 -0
- package/dist/model1/lod0~/primitives/1.glb +0 -0
- package/dist/model1/lod0~/primitives/10.glb +0 -0
- package/dist/model1/lod0~/primitives/11.glb +0 -0
- package/dist/model1/lod0~/primitives/12.glb +0 -0
- package/dist/model1/lod0~/primitives/13.glb +0 -0
- package/dist/model1/lod0~/primitives/14.glb +0 -0
- package/dist/model1/lod0~/primitives/15.glb +0 -0
- package/dist/model1/lod0~/primitives/16.glb +0 -0
- package/dist/model1/lod0~/primitives/17.glb +0 -0
- package/dist/model1/lod0~/primitives/18.glb +0 -0
- package/dist/model1/lod0~/primitives/19.glb +0 -0
- package/dist/model1/lod0~/primitives/2.glb +0 -0
- package/dist/model1/lod0~/primitives/20.glb +0 -0
- package/dist/model1/lod0~/primitives/21.glb +0 -0
- package/dist/model1/lod0~/primitives/22.glb +0 -0
- package/dist/model1/lod0~/primitives/23.glb +0 -0
- package/dist/model1/lod0~/primitives/24.glb +0 -0
- package/dist/model1/lod0~/primitives/25.glb +0 -0
- package/dist/model1/lod0~/primitives/26.glb +0 -0
- package/dist/model1/lod0~/primitives/27.glb +0 -0
- package/dist/model1/lod0~/primitives/28.glb +0 -0
- package/dist/model1/lod0~/primitives/29.glb +0 -0
- package/dist/model1/lod0~/primitives/3.glb +0 -0
- package/dist/model1/lod0~/primitives/30.glb +0 -0
- package/dist/model1/lod0~/primitives/31.glb +0 -0
- package/dist/model1/lod0~/primitives/4.glb +0 -0
- package/dist/model1/lod0~/primitives/5.glb +0 -0
- package/dist/model1/lod0~/primitives/6.glb +0 -0
- package/dist/model1/lod0~/primitives/7.glb +0 -0
- package/dist/model1/lod0~/primitives/8.glb +0 -0
- package/dist/model1/lod0~/primitives/9.glb +0 -0
- package/dist/model4/info +0 -0
- package/dist/model4/lod0 +0 -0
- package/dist/model4/property +0 -0
- package/package.json +1 -1
|
@@ -964,7 +964,7 @@
|
|
|
964
964
|
`+r.map(_r).join(`
|
|
965
965
|
`):" "+_r(r[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const Mr={getAdapter:Fl,adapters:Ni};function Ri(o){if(o.cancelToken&&o.cancelToken.throwIfRequested(),o.signal&&o.signal.aborted)throw new Wt(null,o)}function Sr(o){return Ri(o),o.headers=Fe.from(o.headers),o.data=zi.call(o,o.transformRequest),["post","put","patch"].indexOf(o.method)!==-1&&o.headers.setContentType("application/x-www-form-urlencoded",!1),Mr.getAdapter(o.adapter||on.adapter,o)(o).then(function(n){return Ri(o),n.data=zi.call(o,o.transformResponse,n),n.headers=Fe.from(n.headers),n},function(n){return cr(n)||(Ri(o),n&&n.response&&(n.response.data=zi.call(o,o.transformResponse,n.response),n.response.headers=Fe.from(n.response.headers))),Promise.reject(n)})}const Ar="1.13.2",Gn={};["object","boolean","number","function","string","symbol"].forEach((o,e)=>{Gn[o]=function(n){return typeof n===o||"a"+(e<1?"n ":" ")+o}});const Cr={};Gn.transitional=function(e,t,n){function i(s,r){return"[Axios v"+Ar+"] Transitional option '"+s+"'"+r+(n?". "+n:"")}return(s,r,a)=>{if(e===!1)throw new re(i(r," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!Cr[r]&&(Cr[r]=!0,console.warn(i(r," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,r,a):!0}},Gn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function Ul(o,e,t){if(typeof o!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const n=Object.keys(o);let i=n.length;for(;i-- >0;){const s=n[i],r=e[s];if(r){const a=o[s],l=a===void 0||r(a,s,o);if(l!==!0)throw new re("option "+s+" must be "+l,re.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new re("Unknown option "+s,re.ERR_BAD_OPTION)}}const Wn={assertOptions:Ul,validators:Gn},Je=Wn.validators;let Tt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new rr,response:new rr}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
966
966
|
`+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ct(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Wn.assertOptions(n,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},!1),i!=null&&(W.isFunction(i)?t.paramsSerializer={serialize:i}:Wn.assertOptions(i,{encode:Je.function,serialize:Je.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Wn.assertOptions(t,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=s&&W.merge(s.common,s[t.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),t.headers=Fe.concat(r,s);const a=[];let l=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(t)===!1||(l=l&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const h=[];this.interceptors.response.forEach(function(u){h.push(u.fulfilled,u.rejected)});let c,d=0,m;if(!l){const f=[Sr.bind(this),void 0];for(f.unshift(...a),f.push(...h),m=f.length,c=Promise.resolve(t);d<m;)c=c.then(f[d++],f[d++]);return c}m=a.length;let p=t;for(;d<m;){const f=a[d++],u=a[d++];try{p=f(p)}catch(g){u.call(this,g);break}}try{c=Sr.call(this,p)}catch(f){return Promise.reject(f)}for(d=0,m=h.length;d<m;)c=c.then(h[d++],h[d++]);return c}getUri(e){e=Ct(this.defaults,e);const t=fr(e.baseURL,e.url,e.allowAbsoluteUrls);return sr(t,e.params,e.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(e){Tt.prototype[e]=function(t,n){return this.request(Ct(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(n){return function(s,r,a){return this.request(Ct(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}Tt.prototype[e]=t(),Tt.prototype[e+"Form"]=t(!0)});let Vl=class Fo{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const r=new Promise(a=>{n.subscribe(a),s=a}).then(i);return r.cancel=function(){n.unsubscribe(s)},r},e(function(s,r,a){n.reason||(n.reason=new Wt(s,r,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Fo(function(i){e=i}),cancel:e}}};function jl(o){return function(t){return o.apply(null,t)}}function Gl(o){return W.isObject(o)&&o.isAxiosError===!0}const Fi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Fi).forEach(([o,e])=>{Fi[e]=o});function Tr(o){const e=new Tt(o),t=Gs(Tt.prototype.request,e);return W.extend(t,Tt.prototype,e,{allOwnKeys:!0}),W.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Tr(Ct(o,i))},t}const ye=Tr(on);ye.Axios=Tt,ye.CanceledError=Wt,ye.CancelToken=Vl,ye.isCancel=cr,ye.VERSION=Ar,ye.toFormData=Fn,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=jl,ye.isAxiosError=Gl,ye.mergeConfig=Ct,ye.AxiosHeaders=Fe,ye.formToJSON=o=>ar(W.isHTMLForm(o)?new FormData(o):o),ye.getAdapter=Mr.getAdapter,ye.HttpStatusCode=Fi,ye.default=ye;const{Axios:Nd,AxiosError:Rd,CanceledError:Fd,isCancel:Ud,CancelToken:Vd,VERSION:jd,all:Gd,Cancel:Wd,isAxiosError:Xd,spread:Zd,toFormData:qd,AxiosHeaders:Kd,HttpStatusCode:Yd,formToJSON:$d,getAdapter:Hd,mergeConfig:Jd}=ye;function Pr(o,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=o;t.open("GET",n,!0),t.send(null),t.onreadystatechange=function(){t.readyState==4&&t.status==200&&(t.responseText.includes("</html>",0)&&t.responseText.includes("</body>",0)&&t.responseText.includes("</head>",0)?e(null):e(t.responseText))},t.onloadend=function(){t.readyState==4&&t.status==404&&t.status==502&&e(null)}}}function Wl(o,e){ye({method:"get",responseType:"blob",url:o}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});js.loadAsync(n).then(i=>{const s=new Map,r=[];for(let a in i.files){if(i.files[a].dir)continue;const l=i.file(i.files[a].name);if(l){const h=l.async("blob").then(c=>{const d=URL.createObjectURL(c);s.set("/"+i.files[a].name.replace("\\","/"),d)});r.push(h)}}Promise.all(r).then(()=>{e(s)}).catch(a=>{console.error("解压zip文件失败:",a),e(new Map)})}).catch(i=>{console.error("加载zip文件失败:",i),e(new Map)})}).catch(t=>{console.error("下载zip文件失败:",t),e(new Map)})}function Dr(o,e){ye({method:"get",responseType:"blob",url:o}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});js.loadAsync(i).then(s=>{for(let r in s.files)s.file(s.files[r].name).async("blob").then(l=>{t(l,"utf-8",function(h,c){e(c)})})})});function t(n,i,s){var r=new FileReader,a=new Blob([n]);r.onload=function(l){s(null,l.target.result)},r.onerror=function(l){s(l.error,null)},r.readAsText(a,i)}}const Ui=new WeakMap;class Xl extends _.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,n,i){const s=new _.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,_.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=_.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Ui.has(e)){const l=Ui.get(e);if(l.key===n)return l.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 i;const s=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(s,r).then(l=>(i=l,new Promise((h,c)=>{i._callbacks[s]={resolve:h,reject:c},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Ui.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new _.BufferGeometry;e.index&&t.setIndex(new _.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:r,stride:a,vertexColorSpace:l}=e.attributes[n];let h;if(r===a)h=new _.BufferAttribute(s,r);else{const c=new _.InterleavedBuffer(s,a);h=new _.InterleavedBufferAttribute(c,r,0)}i==="color"&&(this._assignVertexColorSpace(h,l),h.normalized=!(s instanceof Float32Array)),t.setAttribute(i,h)}return t}_assignVertexColorSpace(e,t){if(t!==_.SRGBColorSpace)return;const n=new _.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),_.ColorManagement.colorSpaceToWorking(n,_.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new _.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}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(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=Zl.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
967
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const r=s.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 Zl(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(c){o.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const d=c.draco,m=new d.Decoder;try{const p=t(d,m,new Int8Array(l),h),f=p.attributes.map(u=>u.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{d.destroy(m)}});break}};function t(r,a,l,h){const c=h.attributeIDs,d=h.attributeTypes;let m,p;const f=a.GetEncodedGeometryType(l);if(f===r.TRIANGULAR_MESH)m=new r.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,m);else if(f===r.POINT_CLOUD)m=new r.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const u={index:null,attributes:[]};for(const g in c){const y=self[d[g]];let w,x;if(h.useUniqueIDs)x=c[g],w=a.GetAttributeByUniqueId(m,x);else{if(x=a.GetAttributeId(m,r[c[g]]),x===-1)continue;w=a.GetAttribute(m,x)}const v=i(r,a,m,g,y,w);g==="color"&&(v.vertexColorSpace=h.vertexColorSpace),u.attributes.push(v)}return f===r.TRIANGULAR_MESH&&(u.index=n(r,a,m)),r.destroy(m),u}function n(r,a,l){const c=l.num_faces()*3,d=c*4,m=r._malloc(d);a.GetTrianglesUInt32Array(l,d,m);const p=new Uint32Array(r.HEAPF32.buffer,m,c).slice();return r._free(m),{array:p,itemSize:1}}function i(r,a,l,h,c,d){const m=l.num_points(),p=d.num_components(),f=s(r,c),u=p*c.BYTES_PER_ELEMENT,g=Math.ceil(u/4)*4,y=g/c.BYTES_PER_ELEMENT,w=m*u,x=m*g,v=r._malloc(w);a.GetAttributeDataArrayForAllPoints(l,d,f,w,v);const b=new c(r.HEAPF32.buffer,v,w/c.BYTES_PER_ELEMENT);let D;if(u===g)D=b.slice();else{D=new c(x/c.BYTES_PER_ELEMENT);let T=0;for(let k=0,P=b.length;k<P;k++){for(let I=0;I<p;I++)D[T+I]=b[k*p+I];T+=y}}return r._free(v),{name:h,count:m,itemSize:p,array:D,stride:y}}function s(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var ut=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.ViewportResize="viewport-resize",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.SectionMove="section-move",o))(ut||{});function ql(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(p=>p.url==t),l=e.circularMeps,h=e.rectMeps.filter(p=>p.type==="风管"),c=e.rectMeps.filter(p=>p.type==="桥架"),d=e.ellipseMeps,m=o.scene;if(new S.MeshBasicMaterial,new S.BufferGeometry,l&&l.length){let p=[],f=0;for(let u of l)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Circle",m,p,t)}if(h&&h.length){let p=[],f=0;for(let u of h)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Rect",m,p,t)}if(d&&d.length){let p=[],f=0;for(let u of d)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Ellipse",m,p,t)}if(c&&c.length){let p=[],f=0;for(let u of c)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Bridge",m,p,t)}}function Xn(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new S.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=Zn("Rect",a);break;case"Bridge":r=Zn("Bridge",a);break;case"Circle":r=Zn("Circle",a);break;case"Ellipse":r=Zn("Ellipse",a);break}r&&(s=new S.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[],h=[];for(var c=0;c<t.length;c++){let p=t[c],f=new S.Vector3(p.startPoint.X,0,-p.startPoint.Y),u=new S.Vector3(p.endPoint.X,0,-p.endPoint.Y),g=new S.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),y=new S.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),w=0,x=0,v=0;if(Math.abs(u.clone().sub(f.clone()).z)<.01&&Math.abs(u.clone().sub(f.clone()).x)<.01){if(w=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var d=new S.Vector3(p.base_x.X,0,-p.base_x.Y);x=(d.clone().cross(new S.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new S.Vector3(0,0,1))+Math.PI*.5}}else x=(u.clone().sub(f.clone()).cross(new S.Vector3(0,0,1)).y>0?-1:1)*u.clone().sub(f.clone()).angleTo(new S.Vector3(0,0,1)),w=(p.startPoint.Z>p.endPoint.Z?1:-1)*u.clone().sub(f.clone()).angleTo(y.clone().sub(g.clone()));let b=new S.Matrix4;const D=new S.Euler(w,x,v,"YXZ");let T=b.clone().makeRotationFromEuler(D),k,P;o==="Circle"?(k=p.diameter,P=p.diameter):(k=p.width,P=p.height);let I=b.clone().makeScale(k,P,p.length);b.multiplyMatrices(T,I),b.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(c,b.clone()),s.setColorAt(c,p.color),s.geometry.computeBoundingBox();let z=s.geometry.boundingBox.min.clone().applyMatrix4(b.clone()),C=s.geometry.boundingBox.max.clone().applyMatrix4(b.clone()),E=new S.Vector3(Math.min(z.x,C.x),Math.min(z.y,C.y),Math.min(z.z,C.z)),M=new S.Vector3(Math.max(z.x,C.x),Math.max(z.y,C.y),Math.max(z.z,C.z)),B=E.clone().add(M.clone()).multiplyScalar(.5),V={name:p.name,min:E,max:M,center:B,dbid:c,materialName:r.material.name},U=null,H=null;o==="Circle"&&(U={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},H={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},V.minC=U,V.maxC=H),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(b.clone()),h.push(b.clone()),s.ids.push(Number(p.id)),l.push(V)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=h;let m=[];m={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=m,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Zn(o,e,t){let n=new S.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,o){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return s(n,i,e.color,e.position,e.rotation);function s(r,a,l,h,c){let d=new S.ExtrudeGeometry(r,a),m=new S.MeshStandardMaterial({color:l,side:S.DoubleSide}),p=new S.Mesh(d,m);return p.position.set(h.x,h.y,h.z),p.rotation._order="YXZ",p.rotation.set(c.x,c.y,c.z),p}}function kr(o,e=!1){const t=o[0].index!==null,n=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),s={},r={},a=o[0].morphTargetsRelative,l=new _.BufferGeometry;let h=0;for(let c=0;c<o.length;++c){const d=o[c];let m=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),m++}if(m!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(t){let c=0;const d=[];for(let m=0;m<o.length;++m){const p=o[m].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+c);c+=o[m].attributes.position.count}l.setIndex(d)}for(const c in s){const d=Ir(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(const c in r){const d=r[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let m=0;m<d;++m){const p=[];for(let u=0;u<r[c].length;++u)p.push(r[c][u][m]);const f=Ir(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function Ir(o){let e,t,n,i=-1,s=0;for(let h=0;h<o.length;++h){const c=o[h];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=c.gpuType),i!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*t}const r=new e(s),a=new _.BufferAttribute(r,t,n);let l=0;for(let h=0;h<o.length;++h){const c=o[h];if(c.isInterleavedBufferAttribute){const d=l/t;for(let m=0,p=c.count;m<p;m++)for(let f=0;f<t;f++){const u=c.getComponent(m,f);a.setComponent(m+d,f,u)}}else r.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Lr(o,e){if(e===_.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===_.TriangleFanDrawMode||e===_.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)r.push(l);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,i=[];if(e===_.TriangleFanDrawMode)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Kl extends _.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ql(t)}),this.register(function(t){return new ec(t)}),this.register(function(t){return new cc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new nc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new Jl(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new $l(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new fc(t)})}load(e,t,n,i){const s=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=_.LoaderUtils.extractUrlBase(e);r=_.LoaderUtils.resolveURL(h,this.path)}else r=_.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){i?i(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},l=new _.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{s.parse(h,r,function(c){t(c),s.manager.itemEnd(e)},a)}catch(c){a(c)}},n,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,n,i){let s;const r={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Er){try{r[le.KHR_BINARY_GLTF]=new pc(e)}catch(d){i&&i(d);return}s=JSON.parse(r[le.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new Tc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const d=this.pluginCallbacks[c](h);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,r[d.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const d=s.extensionsUsed[c],m=s.extensionsRequired||[];switch(d){case le.KHR_MATERIALS_UNLIT:r[d]=new Hl;break;case le.KHR_DRACO_MESH_COMPRESSION:r[d]=new mc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[d]=new gc;break;case le.KHR_MESH_QUANTIZATION:r[d]=new yc;break;default:m.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}h.setExtensions(r),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function Yl(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const le={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 $l{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const c=new _.Color(16777215);l.color!==void 0&&c.setRGB(l.color[0],l.color[1],l.color[2],_.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new _.DirectionalLight(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new _.PointLight(c),h.distance=d;break;case"spot":h=new _.SpotLight(c),h.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Qe(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Hl{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return _.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new _.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const r=s.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],_.LinearSRGBColorSpace),e.opacity=r[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,_.SRGBColorSpace))}return Promise.all(i)}}class Jl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Ql{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new _.Vector2(a,a)}return Promise.all(s)}}class ec{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class tc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class nc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new _.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,_.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class ic{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class sc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),Promise.all(s)}}class rc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class oc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,_.SRGBColorSpace)),Promise.all(s)}}class ac{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(s)}}class lc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(s)}}class cc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class hc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,r.source,l)}}class uc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,r.source,l)}}class dc{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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 s.then(function(a){const l=i.byteOffset||0,h=i.byteLength||0,c=i.count,d=i.byteStride,m=new Uint8Array(a,l,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,d,m,i.mode,i.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(c*d);return r.decodeGltfBuffer(new Uint8Array(p),c,d,m,i.mode,i.filter),p})})}else return null}}class fc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Ve.TRIANGLES&&h.mode!==Ve.TRIANGLE_STRIP&&h.mode!==Ve.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],l={};for(const h in r)a.push(this.parser.getDependency("accessor",r[h]).then(c=>(l[h]=c,l[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const c=h.pop(),d=c.isGroup?c.children:[c],m=h[0].count,p=[];for(const f of d){const u=new _.Matrix4,g=new _.Vector3,y=new _.Quaternion,w=new _.Vector3(1,1,1),x=new _.InstancedMesh(f.geometry,f.material,m);for(let v=0;v<m;v++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,v),l.SCALE&&w.fromBufferAttribute(l.SCALE,v),x.setMatrixAt(v,u.compose(g,y,w));for(const v in l)if(v==="_COLOR_0"){const b=l[v];x.instanceColor=new _.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&f.geometry.setAttribute(v,l[v]);_.Object3D.prototype.copy.call(x,f),this.parser.assignFinalMaterial(x),p.push(x)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Er="glTF",ln=12,Br={JSON:1313821514,BIN:5130562};class pc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ln),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Er)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ln,s=new DataView(e,ln);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Br.JSON){const h=new Uint8Array(e,ln+r,a);this.content=n.decode(h)}else if(l===Br.BIN){const h=ln+r;this.body=e.slice(h,h+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class mc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},l={},h={};for(const c in r){const d=ji[c]||c.toLowerCase();a[d]=r[c]}for(const c in e.attributes){const d=ji[c]||c.toLowerCase();if(r[c]!==void 0){const m=n.accessors[e.attributes[c]],p=Xt[m.componentType];h[d]=p.name,l[d]=m.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(d,m){i.decodeDracoFile(c,function(p){for(const f in p.attributes){const u=p.attributes[f],g=l[f];g!==void 0&&(u.normalized=g)}d(p)},a,h,_.LinearSRGBColorSpace,m)})})}}class gc{constructor(){this.name=le.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 yc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Or extends _.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=a*2,h=a*3,c=i-t,d=(n-t)/c,m=d*d,p=m*d,f=e*h,u=f-h,g=-2*p+3*m,y=p-m,w=1-g,x=y-m+d;for(let v=0;v!==a;v++){const b=r[u+v+a],D=r[u+v+l]*c,T=r[f+v+a],k=r[f+v]*c;s[v]=w*b+x*D+g*T+y*k}return s}}const wc=new _.Quaternion;class xc extends Or{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return wc.fromArray(s).normalize().toArray(s),s}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Xt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},zr={9728:_.NearestFilter,9729:_.LinearFilter,9984:_.NearestMipmapNearestFilter,9985:_.LinearMipmapNearestFilter,9986:_.NearestMipmapLinearFilter,9987:_.LinearMipmapLinearFilter},Nr={33071:_.ClampToEdgeWrapping,33648:_.MirroredRepeatWrapping,10497:_.RepeatWrapping},Vi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ji={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"},dt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},vc={CUBICSPLINE:void 0,LINEAR:_.InterpolateLinear,STEP:_.InterpolateDiscrete},Gi={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function bc(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new _.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_.FrontSide})),o.DefaultMaterial}function Pt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function _c(o,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const d=e[h];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const d=e[h];if(n){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;r.push(m)}if(i){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(m)}if(s){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(m)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],d=h[1],m=h[2];return n&&(o.morphAttributes.position=c),i&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=m),o.morphTargetsRelative=!0,o})}function Mc(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Sc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Wi(t.attributes):e=o.indices+":"+Wi(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+Wi(o.targets[n]);return e}function Wi(o){let e="";const t=Object.keys(o).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+o[t[n]]+";";return e}function Xi(o){switch(o){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 Ac(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Cc=new _.Matrix4;class Tc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Yl,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 n=!1,i=-1,s=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,r=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&r<98?this.textureLoader=new _.TextureLoader(this.options.manager):this.textureLoader=new _.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _.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 n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Pt(s,a,i),Qe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const r=t[i].joints;for(let a=0,l=r.length;a<l;a++)e[r[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.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,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(r,a)=>{const l=this.associations.get(r);l!=null&&this.associations.set(a,l);for(const[h,c]of r.children.entries())s(c,a.children[h])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[le.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,r){n.load(_.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){r(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(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=Vi[i.type],a=Xt[i.componentType],l=i.normalized===!0,h=new a(i.count*r);return Promise.resolve(new _.BufferAttribute(h,r,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(r){const a=r[0],l=Vi[i.type],h=Xt[i.componentType],c=h.BYTES_PER_ELEMENT,d=c*l,m=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let u,g;if(p&&p!==d){const y=Math.floor(m/p),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let x=t.cache.get(w);x||(u=new h(a,y*p,i.count*p/c),x=new _.InterleavedBuffer(u,p/c),t.cache.add(w,x)),g=new _.InterleavedBufferAttribute(x,l,m%p/c,f)}else a===null?u=new h(i.count*l):u=new h(a,m,i.count*l),g=new _.BufferAttribute(u,l,f);if(i.sparse!==void 0){const y=Vi.SCALAR,w=Xt[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,v=i.sparse.values.byteOffset||0,b=new w(r[1],x,i.sparse.count*y),D=new h(r[2],v,i.sparse.count*l);a!==null&&(g=new _.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let T=0,k=b.length;T<k;T++){const P=b[T];if(g.setX(P,D[T*l]),l>=2&&g.setY(P,D[T*l+1]),l>=3&&g.setZ(P,D[T*l+2]),l>=4&&g.setW(P,D[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=f}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const l=n.manager.getHandler(r.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,n).then(function(c){c.flipY=!1,c.name=r.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const m=(s.samplers||{})[r.sampler]||{};return c.magFilter=zr[m.magFilter]||_.LinearFilter,c.minFilter=zr[m.minFilter]||_.LinearMipmapLinearFilter,c.wrapS=Nr[m.wrapS]||_.RepeatWrapping,c.wrapT=Nr[m.wrapT]||_.RepeatWrapping,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==_.NearestFilter&&c.minFilter!==_.LinearFilter,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const r=i.images[e],a=self.URL||self.webkitURL;let l=r.uri||"",h=!1;if(r.bufferView!==void 0)l=n.getDependency("bufferView",r.bufferView).then(function(d){h=!0;const m=new Blob([d],{type:r.mimeType});return l=a.createObjectURL(m),l});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(l).then(function(d){return new Promise(function(m,p){let f=m;t.isImageBitmapLoader===!0&&(f=function(u){const g=new _.Texture(u);g.needsUpdate=!0,m(g)}),t.load(_.LoaderUtils.resolveURL(d,s.path),f,void 0,p)})}).then(function(d){return h===!0&&a.revokeObjectURL(l),Qe(d,r),d.userData.mimeType=r.mimeType||Ac(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),s.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(r);r=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),s.associations.set(r,l)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.PointsMaterial,_.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.LineBasicMaterial,_.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||r){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),r&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return _.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},l=s.extensions||{},h=[];if(l[le.KHR_MATERIALS_UNLIT]){const d=i[le.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),h.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new _.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;a.color.setRGB(m[0],m[1],m[2],_.LinearSRGBColorSpace),a.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",d.baseColorTexture,_.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=_.DoubleSide);const c=s.alphaMode||Gi.OPAQUE;if(c===Gi.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Gi.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==_.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new _.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&r!==_.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==_.MeshBasicMaterial){const d=s.emissiveFactor;a.emissive=new _.Color().setRGB(d[0],d[1],d[2],_.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==_.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,_.SRGBColorSpace)),Promise.all(h).then(function(){const d=new r(a);return s.name&&(d.name=s.name),Qe(d,s),t.associations.set(d,{materials:e}),s.extensions&&Pt(i,d,s),d})}createUniqueName(e){const t=_.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Rr(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=Sc(h),d=i[c];if(d)r.push(d.promise);else{let m;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?m=s(h):m=Rr(new _.BufferGeometry,h,t),i[c]={primitive:h,promise:m},r.push(m)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l].material===void 0?bc(this.cache):this.getDependency("material",r[l].material);a.push(c)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(l){const h=l.slice(0,l.length-1),c=l[l.length-1],d=[];for(let p=0,f=c.length;p<f;p++){const u=c[p],g=r[p];let y;const w=h[p];if(g.mode===Ve.TRIANGLES||g.mode===Ve.TRIANGLE_STRIP||g.mode===Ve.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new _.SkinnedMesh(u,w):new _.Mesh(u,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Lr(y.geometry,_.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Lr(y.geometry,_.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new _.LineSegments(u,w);else if(g.mode===Ve.LINE_STRIP)y=new _.Line(u,w);else if(g.mode===Ve.LINE_LOOP)y=new _.LineLoop(u,w);else if(g.mode===Ve.POINTS)y=new _.Points(u,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Mc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&Pt(i,y,g),t.assignFinalMaterial(y),d.push(y)}for(let p=0,f=d.length;p<f;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return s.extensions&&Pt(i,d[0],s),d[0];const m=new _.Group;s.extensions&&Pt(i,m,s),t.associations.set(m,{meshes:e});for(let p=0,f=d.length;p<f;p++)m.add(d[p]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new _.PerspectiveCamera(_.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new _.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Qe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),r=i,a=[],l=[];for(let h=0,c=r.length;h<c;h++){const d=r[h];if(d){a.push(d);const m=new _.Matrix4;s!==null&&m.fromArray(s.array,h*16),l.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new _.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,r=[],a=[],l=[],h=[],c=[];for(let d=0,m=i.channels.length;d<m;d++){const p=i.channels[d],f=i.samplers[p.sampler],u=p.target,g=u.node,y=i.parameters!==void 0?i.parameters[f.input]:f.input,w=i.parameters!==void 0?i.parameters[f.output]:f.output;u.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(f),c.push(u))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(d){const m=d[0],p=d[1],f=d[2],u=d[3],g=d[4],y=[];for(let x=0,v=m.length;x<v;x++){const b=m[x],D=p[x],T=f[x],k=u[x],P=g[x];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const I=n._createAnimationTracks(b,D,T,k,P);if(I)for(let z=0;z<I.length;z++)y.push(I[z])}const w=new _.AnimationClip(s,void 0,y);return Qe(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const r=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let l=0,h=i.weights.length;l<h;l++)a.morphTargetInfluences[l]=i.weights[l]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),r=[],a=i.children||[];for(let h=0,c=a.length;h<c;h++)r.push(n.getDependency("node",a[h]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(r),l]).then(function(h){const c=h[0],d=h[1],m=h[2];m!==null&&c.traverse(function(p){p.isSkinnedMesh&&p.bind(m,Cc)});for(let p=0,f=d.length;p<f;p++)c.add(d[p]);return c})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],r=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(h){return i._getNodeRef(i.cameraCache,s.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let c;if(s.isBone===!0?c=new _.Bone:h.length>1?c=new _.Group:h.length===1?c=h[0]:c=new _.Object3D,c!==h[0])for(let d=0,m=h.length;d<m;d++)c.add(h[d]);if(s.name&&(c.userData.name=s.name,c.name=r),Qe(c,s),s.extensions&&Pt(n,c,s),s.matrix!==void 0){const d=new _.Matrix4;d.fromArray(s.matrix),c.applyMatrix4(d)}else s.translation!==void 0&&c.position.fromArray(s.translation),s.rotation!==void 0&&c.quaternion.fromArray(s.rotation),s.scale!==void 0&&c.scale.fromArray(s.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const d=i.associations.get(c);i.associations.set(c,{...d})}return i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new _.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&Pt(t,s,n);const r=n.nodes||[],a=[];for(let l=0,h=r.length;l<h;l++)a.push(i.getDependency("node",r[l]));return Promise.all(a).then(function(l){for(let c=0,d=l.length;c<d;c++)s.add(l[c]);const h=c=>{const d=new Map;for(const[m,p]of i.associations)(m instanceof _.Material||m instanceof _.Texture)&&d.set(m,p);return c.traverse(m=>{const p=i.associations.get(m);p!=null&&d.set(m,p)}),d};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];dt[s.path]===dt.weights?e.traverse(function(m){m.morphTargetInfluences&&l.push(m.name?m.name:m.uuid)}):l.push(a);let h;switch(dt[s.path]){case dt.weights:h=_.NumberKeyframeTrack;break;case dt.rotation:h=_.QuaternionKeyframeTrack;break;case dt.translation:case dt.scale:h=_.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=_.NumberKeyframeTrack;break;case 2:case 3:default:h=_.VectorKeyframeTrack;break}break}const c=i.interpolation!==void 0?vc[i.interpolation]:_.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let m=0,p=l.length;m<p;m++){const f=new h(l[m]+"."+dt[s.path],t.array,d,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),r.push(f)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Xi(t.constructor),i=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof _.QuaternionKeyframeTrack?xc:Or;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Pc(o,e,t){const n=e.attributes,i=new _.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(i.set(new _.Vector3(l[0],l[1],l[2]),new _.Vector3(h[0],h[1],h[2])),a.normalized){const c=Xi(Xt[a.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new _.Vector3,l=new _.Vector3;for(let h=0,c=s.length;h<c;h++){const d=s[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],p=m.min,f=m.max;if(p!==void 0&&f!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),m.normalized){const u=Xi(Xt[m.componentType]);l.multiplyScalar(u)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new _.Sphere;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Rr(o,e,t){const n=e.attributes,i=[];function s(r,a){return t.getDependency("accessor",r).then(function(l){o.setAttribute(a,l)})}for(const r in n){const a=ji[r]||r.toLowerCase();a in o.attributes||i.push(s(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return _.ColorManagement.workingColorSpace!==_.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${_.ColorManagement.workingColorSpace}" not supported.`),Qe(o,e),Pc(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?_c(o,e.targets,t):o})}function Dc(o,e,t){let n=new S.Group;n.name=e,o.scene.add(n),Dr(e+"/info",i=>{let s=JSON.parse(i);o.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),o.models==null&&(o.models=[]),o.models.push({url:e,nodesMap:new Map,boundingBox:{min:new S.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new S.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ut.EngineFree,e)})}function kc(o,e){o.engineStatus.models.filter(t=>e==null||t.url==e).forEach(t=>{t.loadStatus==null&&(t.loadStatus={mep:!1,instance:!1,normal:!1}),t.status==="loading"&&t.type==="light"&&(t.loadStatus.modelMep!=!0&&(t.loadStatus.modelMep=!0,ql(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Ic(o,t))})}function Ic(o,e){if(o.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(i=>{if(i.status!=!0)if(i.glbs==null)console.log("加载GLB............."),i.glbs={},Wl(e.url+i.path,s=>{Pr(s.get("/nodes.json"),r=>{let a=JSON.parse(r);o.models.find(c=>c.url==e.url).nodesMap==null&&(o.models.find(c=>c.url==e.url).nodesMap=new Map);let l=o.models.find(c=>c.url==e.url).nodesMap,h=0;for(let c in a){a[c].forEach(p=>{p.glb=c,l.has(p.id)==!1?l.set(p.id,{infos:[p]}):l.get(p.id).infos.push(p)});let d=new Kl;const m=new Xl;m.setDecoderPath("/draco/"),m.preload(),d.setDRACOLoader(m),d.load(s.get(c+".glb"),p=>{i.glbs[c]=p.scene.children,i.glbs[c].forEach(f=>{f.geometry.computeVertexNormals()}),h++,h==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ut.EngineFree,e.url),o.viewCube.CameraGoHome())})}Pr(s.get("/instances.json"),c=>{let d=JSON.parse(c);o.models.find(m=>m.url==e.url).instanceNodes=d})})});else{let s=n(e,i,i.octreeBox),r=[],a=o.models.find(h=>h.url==e.url);s.forEach(h=>{a.nodesMap.has(h)&&a.nodesMap.get(h).infos.forEach(c=>{let d=i.glbs[c.glb][c.mesh];if(d!=null&&d.geometry!=null&&d.material!=null){let m=new S.Matrix4;m.elements=c.matrix;let p=new S.Mesh(d.geometry.clone().applyMatrix4(m),d.material),f=new S.Box3().setFromObject(p);c.box=f,c.mesh=p,p.name=h,p.glb=c.glb,p.url=e.url,d.geometry.attributes.position!=null&&r.push(p)}})}),Lc(e.url,o,r);let l=a.instanceNodes;if(l!=null)for(let h in l)(l[h].isLoaded==null||l[h].isLoaded==!1)&&(l[h].isLoaded=!0,l[h].forEach(c=>{if(i.glbs[h]!=null){let d=i.glbs[h][c.mesh];Ec(e.url,c.mesh,o,d,c.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new S.Vector3(r.min.X,r.min.Z,-r.min.Y),h=new S.Vector3(r.max.X,r.max.Z,-r.max.Y);h.distanceTo(l);let c=o.camera.position,d=new S.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(d),r.elements.forEach(m=>{a.push(m)}),r.children.forEach(m=>{a.push(...n(i,s,m))}),r.children.findIndex(m=>m.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Lc(o,e,t){let n=[];t.forEach(i=>{n.findIndex(r=>r.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(r=>r.glb==i.glb).meshes.push(i),n.find(r=>r.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(r=>r.glb==i.glb);s.indexes.has(Number(i.name))?s.indexes.get(Number(i.name)).push([s.currentIndex-i.geometry.index.count,s.currentIndex]):s.indexes.set(Number(i.name),[[s.currentIndex-i.geometry.index.count,s.currentIndex]])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof S.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new S.BufferGeometry,a=Bc(i.meshes[0].material);r=kr(i.meshes.map(c=>c.geometry),!1);let l=new S.Mesh(r,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=o,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(c=>c.geometry);let h=e.models.find(c=>c.url==o);if(h!=null){let c=0;i.indexes.forEach(d=>{d.forEach(m=>{h.nodesMap.get(Number(i.meshes[c].name)).indexes==null&&(h.nodesMap.get(Number(i.meshes[c].name)).indexes=[]),h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index,c++,m[0],m[1]])})})}}})}function Ec(o,e,t,n,i){if(n==null)return;let s=new S.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)r[l*3]=1,r[l*3+1]=1,r[l*3+2]=1;s.instanceColor=new S.InstancedBufferAttribute(r,3);let a=[];for(let l=0;l<i.length;l++){let h=i[l],c=new S.Matrix4;c.elements=h.matrix,s.setMatrixAt(l,c),s.matrixs||(s.matrixs=[]),s.matrixs.push(c.clone()),a.push(c.clone()),t.models.find(d=>d.url==o).nodesMap.has(h.id)?(t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes==null&&(t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes=[]),t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(d=>d.url==o).nodesMap.set(h.id,{instance:!0,info:h,indexes:[[t.scene.children.length-1,l,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(l=>l.id),s.matrixsClone=a}function Bc(o){return o.map!=null&&(o.map.colorSpace=S.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=S.FrontSide,o.side=o.side,o}class Oc{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&Dc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class zc{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ut.EngineFree,e=>{this.updateFree(!0),kc(this.engine,e)}),this.engine.events.on(ut.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Nc{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,r)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${r}:`,a)}})}}class Rc{engine;constructor(e){this.engine=e}init(){const e=new S.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new S.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new S.AmbientLight(16777215,1);this.engine.scene.add(i)}}var _e=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.MeasureClick="measure-click",o.SectionMove="section-move",o))(_e||{});class Fc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new S.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;handleMouseMove(e){if(!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let t=e.catch.object,n=e.catch.object.id,i=this.engine.models.find(a=>a.url==t.url).nodesMap.get(n),s=new Map;i?.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof S.InstancedMesh&&(s.has(a[0])?s.get(a[0])?.push(a[1]):s.set(a[0],[a[1]]))});let r=[];return s.forEach((a,l)=>{let h=this.engine.scene.children[l];a.forEach(c=>{let d=h.geometry.clone();d.applyMatrix4(h.matrixs[c]),r.push(new S.Mesh(d,h.material))})}),this.hoverOldId==n?[]:(this.hoverOldId=n,this.engine.hoverHighLight.clearHighlight(),r)}else{const t=e.catch;t.object;let n=t.object,i=n.name,a=this.engine.models.find(l=>l.url===n.url).nodesMap.get(i).infos.map(l=>l.mesh);return this.hoverOldId==i?[]:(this.hoverOldId=i,this.engine.hoverHighLight.clearHighlight(),a)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(_e.Click,[{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object;let i=n.object,r=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix,l=[];r.indexes.forEach(c=>{let d=c[0],m=this.engine.scene.children[d].geometry.boundingSphere;const p=new S.Box3,f=m.center.clone().applyMatrix4(a),u=m.radius,g=new S.Vector3;g.setFromMatrixScale(a);const y=Math.max(g.x,g.y,g.z),w=u*y;p.min.set(f.x-w,f.y-w,f.z-w),p.max.set(f.x+w,f.y+w,f.z+w),l.push(p)});let h=t(l);this.engine.viewCube.zoomToModel(h)}else{let a=r.infos.map(h=>h.box),l=t(a);this.engine.viewCube.zoomToModel(l)}}function t(n){let i=new S.Vector3(1e8,1e9,1e10),s=new S.Vector3(-1e8,-1e9,-1e10);return n.forEach(r=>{r.min.x<i.x&&(i.x=r.min.x),r.min.y<i.y&&(i.y=r.min.y),r.min.z<i.z&&(i.z=r.min.z),r.max.x>s.x&&(s.x=r.max.x),r.max.y>s.y&&(s.y=r.max.y),r.max.z>s.z&&(s.z=r.max.z)}),new S.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof S.InstancedMesh),!0)}}class Uc{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new S.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:S.DoubleSide}),this.hideMaterial=new S.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:S.DoubleSide}),this.translucentMaterial=new S.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:S.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof S.InstancedMesh)return;let t=e.materialClone.clone(),n=kr(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.engine.scene.children[a[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[a[0]]),this.engine.scene.children[a[0]].geometry.groups[a[1]].materialIndex=1)})}),Vc(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof S.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=0})}),Fr(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Gc(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Ur(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const r=i.ids.indexOf(s);r!==-1&&i.ids.splice(r,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=2)})}),jc(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof S.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(this.split_merge_model(this.engine.scene.children[r[0]]),a.geometry.groups[r[1]].materialIndex=0)})}),n.size>0&&Ur(n,this.engine),Fr(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Vc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof S.InstancedMesh))return;const s=i.geometry,r=new S.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:S.DoubleSide}),a=new S.InstancedMesh(s,r,t.length);a.name="highlightModel",a.key=n;const l=new Map,h=new S.Matrix4,c=new S.Matrix4;c.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,h),l.set(d,h.clone()),i.setMatrixAt(d,c),a.setMatrixAt(m,h)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Fr(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof S.InstancedMesh))return;n.forEach(a=>{const l=s.matrixsClone[a];l&&s.setMatrixAt(a,l)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function jc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof S.InstancedMesh))return;const s=i.geometry,r=new S.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:S.DoubleSide}),a=new S.InstancedMesh(s,r,t.length);a.name="translucentModel",a.key=n;const l=new Map,h=new S.Matrix4,c=new S.Matrix4;c.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,h),l.set(d,h.clone()),i.setMatrixAt(d,c),a.setMatrixAt(m,h)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Gc(o,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof S.InstancedMesh))return;const s=new Map,r=new S.Matrix4,a=new S.Matrix4;a.makeScale(0,0,0),t.forEach((l,h)=>{i.getMatrixAt(l,r),s.set(l,r.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Ur(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof S.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class Wc{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof S.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof S.DirectionalLight),i={low:1024,medium:2048,high:2048}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class qn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;constructor(e){this.engine=e,this.init()}init(){this.overlayMaterial=new S.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:S.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const s of i){const r=new S.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),r.matrix.copy(s.matrixWorld),r.matrixAutoUpdate=!1,this.engine.scene.add(r),this.overlayMeshes.push(r)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/qn.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/qn.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Kn={exports:{}},Xc=Kn.exports,Vr;function Zc(){return Vr||(Vr=1,(function(o,e){(function(t,n){o.exports=n()})(Xc,function(){var t=function(){function n(p){return r.appendChild(p.dom),p}function i(p){for(var f=0;f<r.children.length;f++)r.children[f].style.display=f===p?"block":"none";s=p}var s=0,r=document.createElement("div");r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(p){p.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var p=(performance||Date).now();if(d.update(p-a,200),p>l+1e3&&(c.update(1e3*h/(p-l),100),l=p,h=0,m)){var f=performance.memory;m.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:r,setMode:i}};return t.Panel=function(n,i,s){var r=1/0,a=0,l=Math.round,h=l(window.devicePixelRatio||1),c=80*h,d=48*h,m=3*h,p=2*h,f=3*h,u=15*h,g=74*h,y=30*h,w=document.createElement("canvas");w.width=c,w.height=d,w.style.cssText="width:80px;height:48px";var x=w.getContext("2d");return x.font="bold "+9*h+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,c,d),x.fillStyle=i,x.fillText(n,m,p),x.fillRect(f,u,g,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(f,u,g,y),{dom:w,update:function(v,b){r=Math.min(r,v),a=Math.max(a,v),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,c,u),x.fillStyle=i,x.fillText(l(v)+" "+n+" ("+l(r)+"-"+l(a)+")",m,p),x.drawImage(w,f+h,u,g-h,y,f,u,g-h,y),x.fillRect(f+g-h,u,h,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(f+g-h,u,h,l((1-v/b)*y))}}},t})})(Kn)),Kn.exports}var qc=Zc();const Kc=Us(qc);var Zt=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-Zt.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?Zt.Bounce.In(o*2)*.5:Zt.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),cn=function(){return performance.now()},Yc=(function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=cn()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],r=!t;s&&s.update(e,r)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o})(),Zi={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=Zi.Utils.Linear;return e<0?s(o[0],o[1],n):e>1?s(o[t],o[t-1],t-n):s(o[i],o[i+1>t?t:i+1],n-i)},Utils:{Linear:function(o,e,t){return(e-o)*t+o}}},jr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),qi=new Yc,$c=(function(){function o(e,t){t===void 0&&(t=qi),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Zt.Linear.None,this._interpolationFunction=Zi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=jr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=cn()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,n,i,s){for(var r in n){var a=e[r],l=Array.isArray(a),h=l?"array":typeof a,c=!l&&Array.isArray(n[r]);if(!(h==="undefined"||h==="function")){if(c){var d=n[r];if(d.length===0)continue;for(var m=[a],p=0,f=d.length;p<f;p+=1){var u=this._handleRelativeValue(a,d[p]);if(isNaN(u)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(u)}c&&(n[r]=m)}if((h==="object"||l)&&a&&!c){t[r]=l?[]:{};var g=a;for(var y in g)t[r][y]=g[y];i[r]=l?[]:{};var d=n[r];if(!this._isDynamic){var w={};for(var y in d)w[y]=d[y];n[r]=d=w}this._setupProperties(g,t[r],d,i[r],s)}else(typeof t[r]>"u"||s)&&(t[r]=a),l||(t[r]*=1),c?i[r]=n[r].slice().reverse():i[r]=t[r]||0}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=cn()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=cn()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=qi),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=Zt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Zi.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=cn()),t===void 0&&(t=!0),this._isPaused)return!0;var s,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),h=this._duration+this._repeat*l,c=function(){if(n._duration===0||a>h)return 1;var g=Math.trunc(a/l),y=a-g*l,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},d=c(),m=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var f=0,u=this._chainedTweens.length;f<u;f++)this._chainedTweens[f].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var r=t[s]||0,a=n[s],l=Array.isArray(e[s]),h=Array.isArray(a),c=!l&&h;c?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],r,a,i):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(e[s]=r+(a-r)*i))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},o})();jr.nextId;var et=qi;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var hn={Easing:Zt,Tween:$c};class Hc extends _.DataTextureLoader{constructor(e){super(e),this.type=_.HalfFloatType}parse(e){const r=function(k,P){switch(k){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(P||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(P||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(P||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(P||""))}},d=function(k,P,I){P=P||1024;let C=k.pos,E=-1,M=0,B="",V=String.fromCharCode.apply(null,new Uint16Array(k.subarray(C,C+128)));for(;0>(E=V.indexOf(`
|
|
967
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const r=s.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_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 Zl(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(c){o.onModuleLoaded=function(d){c({draco:d})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(c=>{const d=c.draco,m=new d.Decoder;try{const p=t(d,m,new Int8Array(l),h),f=p.attributes.map(u=>u.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{d.destroy(m)}});break}};function t(r,a,l,h){const c=h.attributeIDs,d=h.attributeTypes;let m,p;const f=a.GetEncodedGeometryType(l);if(f===r.TRIANGULAR_MESH)m=new r.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,m);else if(f===r.POINT_CLOUD)m=new r.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const u={index:null,attributes:[]};for(const g in c){const y=self[d[g]];let w,x;if(h.useUniqueIDs)x=c[g],w=a.GetAttributeByUniqueId(m,x);else{if(x=a.GetAttributeId(m,r[c[g]]),x===-1)continue;w=a.GetAttribute(m,x)}const v=i(r,a,m,g,y,w);g==="color"&&(v.vertexColorSpace=h.vertexColorSpace),u.attributes.push(v)}return f===r.TRIANGULAR_MESH&&(u.index=n(r,a,m)),r.destroy(m),u}function n(r,a,l){const c=l.num_faces()*3,d=c*4,m=r._malloc(d);a.GetTrianglesUInt32Array(l,d,m);const p=new Uint32Array(r.HEAPF32.buffer,m,c).slice();return r._free(m),{array:p,itemSize:1}}function i(r,a,l,h,c,d){const m=l.num_points(),p=d.num_components(),f=s(r,c),u=p*c.BYTES_PER_ELEMENT,g=Math.ceil(u/4)*4,y=g/c.BYTES_PER_ELEMENT,w=m*u,x=m*g,v=r._malloc(w);a.GetAttributeDataArrayForAllPoints(l,d,f,w,v);const b=new c(r.HEAPF32.buffer,v,w/c.BYTES_PER_ELEMENT);let D;if(u===g)D=b.slice();else{D=new c(x/c.BYTES_PER_ELEMENT);let T=0;for(let k=0,P=b.length;k<P;k++){for(let I=0;I<p;I++)D[T+I]=b[k*p+I];T+=y}}return r._free(v),{name:h,count:m,itemSize:p,array:D,stride:y}}function s(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var ut=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.ViewportResize="viewport-resize",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.SectionMove="section-move",o))(ut||{});function ql(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(p=>p.url==t),l=e.circularMeps,h=e.rectMeps?.filter(p=>p.type==="风管"),c=e.rectMeps?.filter(p=>p.type==="桥架"),d=e.ellipseMeps,m=o.scene;if(new S.MeshBasicMaterial,new S.BufferGeometry,l&&l.length){let p=[],f=0;for(let u of l)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Circle",m,p,t)}if(h&&h.length){let p=[],f=0;for(let u of h)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Rect",m,p,t)}if(d&&d.length){let p=[],f=0;for(let u of d)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Ellipse",m,p,t)}if(c&&c.length){let p=[],f=0;for(let u of c)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new S.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);Xn("Bridge",m,p,t)}}function Xn(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new S.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=Zn("Rect",a);break;case"Bridge":r=Zn("Bridge",a);break;case"Circle":r=Zn("Circle",a);break;case"Ellipse":r=Zn("Ellipse",a);break}r&&(s=new S.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[],h=[];for(var c=0;c<t.length;c++){let p=t[c],f=new S.Vector3(p.startPoint.X,0,-p.startPoint.Y),u=new S.Vector3(p.endPoint.X,0,-p.endPoint.Y),g=new S.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),y=new S.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),w=0,x=0,v=0;if(Math.abs(u.clone().sub(f.clone()).z)<.01&&Math.abs(u.clone().sub(f.clone()).x)<.01){if(w=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var d=new S.Vector3(p.base_x.X,0,-p.base_x.Y);x=(d.clone().cross(new S.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new S.Vector3(0,0,1))+Math.PI*.5}}else x=(u.clone().sub(f.clone()).cross(new S.Vector3(0,0,1)).y>0?-1:1)*u.clone().sub(f.clone()).angleTo(new S.Vector3(0,0,1)),w=(p.startPoint.Z>p.endPoint.Z?1:-1)*u.clone().sub(f.clone()).angleTo(y.clone().sub(g.clone()));let b=new S.Matrix4;const D=new S.Euler(w,x,v,"YXZ");let T=b.clone().makeRotationFromEuler(D),k,P;o==="Circle"?(k=p.diameter,P=p.diameter):(k=p.width,P=p.height);let I=b.clone().makeScale(k,P,p.length);b.multiplyMatrices(T,I),b.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(c,b.clone()),s.setColorAt(c,p.color),s.geometry.computeBoundingBox();let z=s.geometry.boundingBox.min.clone().applyMatrix4(b.clone()),C=s.geometry.boundingBox.max.clone().applyMatrix4(b.clone()),E=new S.Vector3(Math.min(z.x,C.x),Math.min(z.y,C.y),Math.min(z.z,C.z)),M=new S.Vector3(Math.max(z.x,C.x),Math.max(z.y,C.y),Math.max(z.z,C.z)),B=E.clone().add(M.clone()).multiplyScalar(.5),V={name:p.name,min:E,max:M,center:B,dbid:c,materialName:r.material.name},U=null,H=null;o==="Circle"&&(U={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},H={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},V.minC=U,V.maxC=H),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(b.clone()),h.push(b.clone()),s.ids.push(Number(p.id)),l.push(V)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=h;let m=[];m={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=m,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function Zn(o,e,t){let n=new S.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,o){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return s(n,i,e.color,e.position,e.rotation);function s(r,a,l,h,c){let d=new S.ExtrudeGeometry(r,a),m=new S.MeshStandardMaterial({color:l,side:S.DoubleSide}),p=new S.Mesh(d,m);return p.position.set(h.x,h.y,h.z),p.rotation._order="YXZ",p.rotation.set(c.x,c.y,c.z),p}}function kr(o,e=!1){const t=o[0].index!==null,n=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),s={},r={},a=o[0].morphTargetsRelative,l=new _.BufferGeometry;let h=0;for(let c=0;c<o.length;++c){const d=o[c];let m=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),m++}if(m!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,c),h+=p}}if(t){let c=0;const d=[];for(let m=0;m<o.length;++m){const p=o[m].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+c);c+=o[m].attributes.position.count}l.setIndex(d)}for(const c in s){const d=Ir(s[c]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;l.setAttribute(c,d)}for(const c in r){const d=r[c][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[c]=[];for(let m=0;m<d;++m){const p=[];for(let u=0;u<r[c].length;++u)p.push(r[c][u][m]);const f=Ir(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;l.morphAttributes[c].push(f)}}return l}function Ir(o){let e,t,n,i=-1,s=0;for(let h=0;h<o.length;++h){const c=o[h];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=c.normalized),n!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=c.gpuType),i!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=c.count*t}const r=new e(s),a=new _.BufferAttribute(r,t,n);let l=0;for(let h=0;h<o.length;++h){const c=o[h];if(c.isInterleavedBufferAttribute){const d=l/t;for(let m=0,p=c.count;m<p;m++)for(let f=0;f<t;f++){const u=c.getComponent(m,f);a.setComponent(m+d,f,u)}}else r.set(c.array,l);l+=c.count*t}return i!==void 0&&(a.gpuType=i),a}function Lr(o,e){if(e===_.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===_.TriangleFanDrawMode||e===_.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)r.push(l);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,i=[];if(e===_.TriangleFanDrawMode)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Kl extends _.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Ql(t)}),this.register(function(t){return new ec(t)}),this.register(function(t){return new cc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new nc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new Jl(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new $l(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new fc(t)})}load(e,t,n,i){const s=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const h=_.LoaderUtils.extractUrlBase(e);r=_.LoaderUtils.resolveURL(h,this.path)}else r=_.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){i?i(h):console.error(h),s.manager.itemError(e),s.manager.itemEnd(e)},l=new _.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{s.parse(h,r,function(c){t(c),s.manager.itemEnd(e)},a)}catch(c){a(c)}},n,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,n,i){let s;const r={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Er){try{r[le.KHR_BINARY_GLTF]=new pc(e)}catch(d){i&&i(d);return}s=JSON.parse(r[le.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new Tc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let c=0;c<this.pluginCallbacks.length;c++){const d=this.pluginCallbacks[c](h);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,r[d.name]=!0}if(s.extensionsUsed)for(let c=0;c<s.extensionsUsed.length;++c){const d=s.extensionsUsed[c],m=s.extensionsRequired||[];switch(d){case le.KHR_MATERIALS_UNLIT:r[d]=new Hl;break;case le.KHR_DRACO_MESH_COMPRESSION:r[d]=new mc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[d]=new gc;break;case le.KHR_MESH_QUANTIZATION:r[d]=new yc;break;default:m.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}h.setExtensions(r),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function Yl(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const le={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 $l{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let h;const c=new _.Color(16777215);l.color!==void 0&&c.setRGB(l.color[0],l.color[1],l.color[2],_.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new _.DirectionalLight(c),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new _.PointLight(c),h.distance=d;break;case"spot":h=new _.SpotLight(c),h.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Qe(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Hl{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return _.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new _.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const r=s.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],_.LinearSRGBColorSpace),e.opacity=r[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,_.SRGBColorSpace))}return Promise.all(i)}}class Jl{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class Ql{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new _.Vector2(a,a)}return Promise.all(s)}}class ec{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class tc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class nc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new _.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,_.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class ic{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class sc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),Promise.all(s)}}class rc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class oc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,_.SRGBColorSpace)),Promise.all(s)}}class ac{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(s)}}class lc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(s)}}class cc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class hc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,r.source,l)}}class uc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,r.source,l)}}class dc{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.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 s.then(function(a){const l=i.byteOffset||0,h=i.byteLength||0,c=i.count,d=i.byteStride,m=new Uint8Array(a,l,h);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(c,d,m,i.mode,i.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(c*d);return r.decodeGltfBuffer(new Uint8Array(p),c,d,m,i.mode,i.filter),p})})}else return null}}class fc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Ve.TRIANGLES&&h.mode!==Ve.TRIANGLE_STRIP&&h.mode!==Ve.TRIANGLE_FAN&&h.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],l={};for(const h in r)a.push(this.parser.getDependency("accessor",r[h]).then(c=>(l[h]=c,l[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const c=h.pop(),d=c.isGroup?c.children:[c],m=h[0].count,p=[];for(const f of d){const u=new _.Matrix4,g=new _.Vector3,y=new _.Quaternion,w=new _.Vector3(1,1,1),x=new _.InstancedMesh(f.geometry,f.material,m);for(let v=0;v<m;v++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,v),l.SCALE&&w.fromBufferAttribute(l.SCALE,v),x.setMatrixAt(v,u.compose(g,y,w));for(const v in l)if(v==="_COLOR_0"){const b=l[v];x.instanceColor=new _.InstancedBufferAttribute(b.array,b.itemSize,b.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&f.geometry.setAttribute(v,l[v]);_.Object3D.prototype.copy.call(x,f),this.parser.assignFinalMaterial(x),p.push(x)}return c.isGroup?(c.clear(),c.add(...p),c):p[0]}))}}const Er="glTF",ln=12,Br={JSON:1313821514,BIN:5130562};class pc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ln),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Er)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-ln,s=new DataView(e,ln);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Br.JSON){const h=new Uint8Array(e,ln+r,a);this.content=n.decode(h)}else if(l===Br.BIN){const h=ln+r;this.body=e.slice(h,h+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class mc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},l={},h={};for(const c in r){const d=ji[c]||c.toLowerCase();a[d]=r[c]}for(const c in e.attributes){const d=ji[c]||c.toLowerCase();if(r[c]!==void 0){const m=n.accessors[e.attributes[c]],p=Xt[m.componentType];h[d]=p.name,l[d]=m.normalized===!0}}return t.getDependency("bufferView",s).then(function(c){return new Promise(function(d,m){i.decodeDracoFile(c,function(p){for(const f in p.attributes){const u=p.attributes[f],g=l[f];g!==void 0&&(u.normalized=g)}d(p)},a,h,_.LinearSRGBColorSpace,m)})})}}class gc{constructor(){this.name=le.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 yc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Or extends _.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=a*2,h=a*3,c=i-t,d=(n-t)/c,m=d*d,p=m*d,f=e*h,u=f-h,g=-2*p+3*m,y=p-m,w=1-g,x=y-m+d;for(let v=0;v!==a;v++){const b=r[u+v+a],D=r[u+v+l]*c,T=r[f+v+a],k=r[f+v]*c;s[v]=w*b+x*D+g*T+y*k}return s}}const wc=new _.Quaternion;class xc extends Or{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return wc.fromArray(s).normalize().toArray(s),s}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Xt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},zr={9728:_.NearestFilter,9729:_.LinearFilter,9984:_.NearestMipmapNearestFilter,9985:_.LinearMipmapNearestFilter,9986:_.NearestMipmapLinearFilter,9987:_.LinearMipmapLinearFilter},Nr={33071:_.ClampToEdgeWrapping,33648:_.MirroredRepeatWrapping,10497:_.RepeatWrapping},Vi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ji={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"},dt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},vc={CUBICSPLINE:void 0,LINEAR:_.InterpolateLinear,STEP:_.InterpolateDiscrete},Gi={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function bc(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new _.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_.FrontSide})),o.DefaultMaterial}function Pt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function _c(o,e,t){let n=!1,i=!1,s=!1;for(let h=0,c=e.length;h<c;h++){const d=e[h];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let h=0,c=e.length;h<c;h++){const d=e[h];if(n){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;r.push(m)}if(i){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(m)}if(s){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(m)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(h){const c=h[0],d=h[1],m=h[2];return n&&(o.morphAttributes.position=c),i&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=m),o.morphTargetsRelative=!0,o})}function Mc(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Sc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Wi(t.attributes):e=o.indices+":"+Wi(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+Wi(o.targets[n]);return e}function Wi(o){let e="";const t=Object.keys(o).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+o[t[n]]+";";return e}function Xi(o){switch(o){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 Ac(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Cc=new _.Matrix4;class Tc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Yl,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 n=!1,i=-1,s=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,r=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&r<98?this.textureLoader=new _.TextureLoader(this.options.manager):this.textureLoader=new _.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _.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 n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Pt(s,a,i),Qe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const r=t[i].joints;for(let a=0,l=r.length;a<l;a++)e[r[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.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,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(r,a)=>{const l=this.associations.get(r);l!=null&&this.associations.set(a,l);for(const[h,c]of r.children.entries())s(c,a.children[h])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=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[le.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,r){n.load(_.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){r(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(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=Vi[i.type],a=Xt[i.componentType],l=i.normalized===!0,h=new a(i.count*r);return Promise.resolve(new _.BufferAttribute(h,r,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(r){const a=r[0],l=Vi[i.type],h=Xt[i.componentType],c=h.BYTES_PER_ELEMENT,d=c*l,m=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let u,g;if(p&&p!==d){const y=Math.floor(m/p),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let x=t.cache.get(w);x||(u=new h(a,y*p,i.count*p/c),x=new _.InterleavedBuffer(u,p/c),t.cache.add(w,x)),g=new _.InterleavedBufferAttribute(x,l,m%p/c,f)}else a===null?u=new h(i.count*l):u=new h(a,m,i.count*l),g=new _.BufferAttribute(u,l,f);if(i.sparse!==void 0){const y=Vi.SCALAR,w=Xt[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,v=i.sparse.values.byteOffset||0,b=new w(r[1],x,i.sparse.count*y),D=new h(r[2],v,i.sparse.count*l);a!==null&&(g=new _.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let T=0,k=b.length;T<k;T++){const P=b[T];if(g.setX(P,D[T*l]),l>=2&&g.setY(P,D[T*l+1]),l>=3&&g.setZ(P,D[T*l+2]),l>=4&&g.setW(P,D[T*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=f}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const l=n.manager.getHandler(r.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,n).then(function(c){c.flipY=!1,c.name=r.name||a.name||"",c.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(c.name=a.uri);const m=(s.samplers||{})[r.sampler]||{};return c.magFilter=zr[m.magFilter]||_.LinearFilter,c.minFilter=zr[m.minFilter]||_.LinearMipmapLinearFilter,c.wrapS=Nr[m.wrapS]||_.RepeatWrapping,c.wrapT=Nr[m.wrapT]||_.RepeatWrapping,c.generateMipmaps=!c.isCompressedTexture&&c.minFilter!==_.NearestFilter&&c.minFilter!==_.LinearFilter,i.associations.set(c,{textures:e}),c}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const r=i.images[e],a=self.URL||self.webkitURL;let l=r.uri||"",h=!1;if(r.bufferView!==void 0)l=n.getDependency("bufferView",r.bufferView).then(function(d){h=!0;const m=new Blob([d],{type:r.mimeType});return l=a.createObjectURL(m),l});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(l).then(function(d){return new Promise(function(m,p){let f=m;t.isImageBitmapLoader===!0&&(f=function(u){const g=new _.Texture(u);g.needsUpdate=!0,m(g)}),t.load(_.LoaderUtils.resolveURL(d,s.path),f,void 0,p)})}).then(function(d){return h===!0&&a.revokeObjectURL(l),Qe(d,r),d.userData.mimeType=r.mimeType||Ac(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),s.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(r);r=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),s.associations.set(r,l)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.PointsMaterial,_.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.LineBasicMaterial,_.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||r){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),r&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return _.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},l=s.extensions||{},h=[];if(l[le.KHR_MATERIALS_UNLIT]){const d=i[le.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),h.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new _.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;a.color.setRGB(m[0],m[1],m[2],_.LinearSRGBColorSpace),a.opacity=m[3]}d.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",d.baseColorTexture,_.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=_.DoubleSide);const c=s.alphaMode||Gi.OPAQUE;if(c===Gi.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,c===Gi.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==_.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new _.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&r!==_.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==_.MeshBasicMaterial){const d=s.emissiveFactor;a.emissive=new _.Color().setRGB(d[0],d[1],d[2],_.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==_.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,_.SRGBColorSpace)),Promise.all(h).then(function(){const d=new r(a);return s.name&&(d.name=s.name),Qe(d,s),t.associations.set(d,{materials:e}),s.extensions&&Pt(i,d,s),d})}createUniqueName(e){const t=_.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Rr(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],c=Sc(h),d=i[c];if(d)r.push(d.promise);else{let m;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?m=s(h):m=Rr(new _.BufferGeometry,h,t),i[c]={primitive:h,promise:m},r.push(m)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let l=0,h=r.length;l<h;l++){const c=r[l].material===void 0?bc(this.cache):this.getDependency("material",r[l].material);a.push(c)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(l){const h=l.slice(0,l.length-1),c=l[l.length-1],d=[];for(let p=0,f=c.length;p<f;p++){const u=c[p],g=r[p];let y;const w=h[p];if(g.mode===Ve.TRIANGLES||g.mode===Ve.TRIANGLE_STRIP||g.mode===Ve.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new _.SkinnedMesh(u,w):new _.Mesh(u,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Lr(y.geometry,_.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Lr(y.geometry,_.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new _.LineSegments(u,w);else if(g.mode===Ve.LINE_STRIP)y=new _.Line(u,w);else if(g.mode===Ve.LINE_LOOP)y=new _.LineLoop(u,w);else if(g.mode===Ve.POINTS)y=new _.Points(u,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Mc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&Pt(i,y,g),t.assignFinalMaterial(y),d.push(y)}for(let p=0,f=d.length;p<f;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return s.extensions&&Pt(i,d[0],s),d[0];const m=new _.Group;s.extensions&&Pt(i,m,s),t.associations.set(m,{meshes:e});for(let p=0,f=d.length;p<f;p++)m.add(d[p]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new _.PerspectiveCamera(_.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new _.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Qe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),r=i,a=[],l=[];for(let h=0,c=r.length;h<c;h++){const d=r[h];if(d){a.push(d);const m=new _.Matrix4;s!==null&&m.fromArray(s.array,h*16),l.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new _.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,r=[],a=[],l=[],h=[],c=[];for(let d=0,m=i.channels.length;d<m;d++){const p=i.channels[d],f=i.samplers[p.sampler],u=p.target,g=u.node,y=i.parameters!==void 0?i.parameters[f.input]:f.input,w=i.parameters!==void 0?i.parameters[f.output]:f.output;u.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(f),c.push(u))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(c)]).then(function(d){const m=d[0],p=d[1],f=d[2],u=d[3],g=d[4],y=[];for(let x=0,v=m.length;x<v;x++){const b=m[x],D=p[x],T=f[x],k=u[x],P=g[x];if(b===void 0)continue;b.updateMatrix&&b.updateMatrix();const I=n._createAnimationTracks(b,D,T,k,P);if(I)for(let z=0;z<I.length;z++)y.push(I[z])}const w=new _.AnimationClip(s,void 0,y);return Qe(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const r=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let l=0,h=i.weights.length;l<h;l++)a.morphTargetInfluences[l]=i.weights[l]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),r=[],a=i.children||[];for(let h=0,c=a.length;h<c;h++)r.push(n.getDependency("node",a[h]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(r),l]).then(function(h){const c=h[0],d=h[1],m=h[2];m!==null&&c.traverse(function(p){p.isSkinnedMesh&&p.bind(m,Cc)});for(let p=0,f=d.length;p<f;p++)c.add(d[p]);return c})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],r=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(h){return i._getNodeRef(i.cameraCache,s.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let c;if(s.isBone===!0?c=new _.Bone:h.length>1?c=new _.Group:h.length===1?c=h[0]:c=new _.Object3D,c!==h[0])for(let d=0,m=h.length;d<m;d++)c.add(h[d]);if(s.name&&(c.userData.name=s.name,c.name=r),Qe(c,s),s.extensions&&Pt(n,c,s),s.matrix!==void 0){const d=new _.Matrix4;d.fromArray(s.matrix),c.applyMatrix4(d)}else s.translation!==void 0&&c.position.fromArray(s.translation),s.rotation!==void 0&&c.quaternion.fromArray(s.rotation),s.scale!==void 0&&c.scale.fromArray(s.scale);if(!i.associations.has(c))i.associations.set(c,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const d=i.associations.get(c);i.associations.set(c,{...d})}return i.associations.get(c).nodes=e,c}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new _.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&Pt(t,s,n);const r=n.nodes||[],a=[];for(let l=0,h=r.length;l<h;l++)a.push(i.getDependency("node",r[l]));return Promise.all(a).then(function(l){for(let c=0,d=l.length;c<d;c++)s.add(l[c]);const h=c=>{const d=new Map;for(const[m,p]of i.associations)(m instanceof _.Material||m instanceof _.Texture)&&d.set(m,p);return c.traverse(m=>{const p=i.associations.get(m);p!=null&&d.set(m,p)}),d};return i.associations=h(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];dt[s.path]===dt.weights?e.traverse(function(m){m.morphTargetInfluences&&l.push(m.name?m.name:m.uuid)}):l.push(a);let h;switch(dt[s.path]){case dt.weights:h=_.NumberKeyframeTrack;break;case dt.rotation:h=_.QuaternionKeyframeTrack;break;case dt.translation:case dt.scale:h=_.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=_.NumberKeyframeTrack;break;case 2:case 3:default:h=_.VectorKeyframeTrack;break}break}const c=i.interpolation!==void 0?vc[i.interpolation]:_.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let m=0,p=l.length;m<p;m++){const f=new h(l[m]+"."+dt[s.path],t.array,d,c);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),r.push(f)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Xi(t.constructor),i=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof _.QuaternionKeyframeTrack?xc:Or;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Pc(o,e,t){const n=e.attributes,i=new _.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(i.set(new _.Vector3(l[0],l[1],l[2]),new _.Vector3(h[0],h[1],h[2])),a.normalized){const c=Xi(Xt[a.componentType]);i.min.multiplyScalar(c),i.max.multiplyScalar(c)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new _.Vector3,l=new _.Vector3;for(let h=0,c=s.length;h<c;h++){const d=s[h];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],p=m.min,f=m.max;if(p!==void 0&&f!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),m.normalized){const u=Xi(Xt[m.componentType]);l.multiplyScalar(u)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new _.Sphere;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Rr(o,e,t){const n=e.attributes,i=[];function s(r,a){return t.getDependency("accessor",r).then(function(l){o.setAttribute(a,l)})}for(const r in n){const a=ji[r]||r.toLowerCase();a in o.attributes||i.push(s(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return _.ColorManagement.workingColorSpace!==_.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${_.ColorManagement.workingColorSpace}" not supported.`),Qe(o,e),Pc(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?_c(o,e.targets,t):o})}function Dc(o,e,t){let n=new S.Group;n.name=e,o.scene.add(n),Dr(e+"/info",i=>{let s=JSON.parse(i);o.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),o.models==null&&(o.models=[]),o.models.push({url:e,nodesMap:new Map,boundingBox:{min:new S.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new S.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ut.EngineFree,e)})}function kc(o,e){o.engineStatus.models.filter(t=>e==null||t.url==e).forEach(t=>{t.loadStatus==null&&(t.loadStatus={mep:!1,instance:!1,normal:!1}),t.status==="loading"&&t.type==="light"&&(t.loadStatus.modelMep!=!0&&(t.loadStatus.modelMep=!0,ql(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Ic(o,t))})}function Ic(o,e){if(o.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(i=>{if(i.status!=!0)if(i.glbs==null)console.log("加载GLB............."),i.glbs={},Wl(e.url+i.path,s=>{Pr(s.get("/nodes.json"),r=>{let a=JSON.parse(r);o.models.find(c=>c.url==e.url).nodesMap==null&&(o.models.find(c=>c.url==e.url).nodesMap=new Map);let l=o.models.find(c=>c.url==e.url).nodesMap,h=0;for(let c in a){a[c].forEach(p=>{p.glb=c,l.has(p.id)==!1?l.set(p.id,{infos:[p]}):l.get(p.id).infos.push(p)});let d=new Kl;const m=new Xl;m.setDecoderPath("/draco/"),m.preload(),d.setDRACOLoader(m),d.load(s.get(c+".glb"),p=>{i.glbs[c]=p.scene.children,i.glbs[c].forEach(f=>{f.geometry.computeVertexNormals()}),h++,h==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ut.EngineFree,e.url),o.viewCube.CameraGoHome())})}Pr(s.get("/instances.json"),c=>{let d=JSON.parse(c);o.models.find(m=>m.url==e.url).instanceNodes=d})})});else{let s=n(e,i,i.octreeBox),r=[],a=o.models.find(h=>h.url==e.url);s.forEach(h=>{a.nodesMap.has(h)&&a.nodesMap.get(h).infos.forEach(c=>{let d=i.glbs[c.glb][c.mesh];if(d!=null&&d.geometry!=null&&d.material!=null){let m=new S.Matrix4;m.elements=c.matrix;let p=new S.Mesh(d.geometry.clone().applyMatrix4(m),d.material),f=new S.Box3().setFromObject(p);c.box=f,c.mesh=p,p.name=h,p.glb=c.glb,p.url=e.url,d.geometry.attributes.position!=null&&r.push(p)}})}),Lc(e.url,o,r);let l=a.instanceNodes;if(l!=null)for(let h in l)(l[h].isLoaded==null||l[h].isLoaded==!1)&&(l[h].isLoaded=!0,l[h].forEach(c=>{if(i.glbs[h]!=null){let d=i.glbs[h][c.mesh];Ec(e.url,c.mesh,o,d,c.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new S.Vector3(r.min.X,r.min.Z,-r.min.Y),h=new S.Vector3(r.max.X,r.max.Z,-r.max.Y);h.distanceTo(l);let c=o.camera.position,d=new S.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);c.distanceTo(d),r.elements.forEach(m=>{a.push(m)}),r.children.forEach(m=>{a.push(...n(i,s,m))}),r.children.findIndex(m=>m.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Lc(o,e,t){let n=[];t.forEach(i=>{n.findIndex(r=>r.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(r=>r.glb==i.glb).meshes.push(i),n.find(r=>r.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(r=>r.glb==i.glb);s.indexes.has(Number(i.name))?s.indexes.get(Number(i.name)).push([s.currentIndex-i.geometry.index.count,s.currentIndex]):s.indexes.set(Number(i.name),[[s.currentIndex-i.geometry.index.count,s.currentIndex]])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof S.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new S.BufferGeometry,a=Bc(i.meshes[0].material);r=kr(i.meshes.map(c=>c.geometry),!1);let l=new S.Mesh(r,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=o,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(c=>c.geometry);let h=e.models.find(c=>c.url==o);if(h!=null){let c=0;i.indexes.forEach(d=>{d.forEach(m=>{h.nodesMap.get(Number(i.meshes[c].name)).indexes==null&&(h.nodesMap.get(Number(i.meshes[c].name)).indexes=[]),h.nodesMap.get(Number(i.meshes[c].name)).indexes.push([l.index,c++,m[0],m[1]])})})}}})}function Ec(o,e,t,n,i){if(n==null)return;let s=new S.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)r[l*3]=1,r[l*3+1]=1,r[l*3+2]=1;s.instanceColor=new S.InstancedBufferAttribute(r,3);let a=[];for(let l=0;l<i.length;l++){let h=i[l],c=new S.Matrix4;c.elements=h.matrix,s.setMatrixAt(l,c),s.matrixs||(s.matrixs=[]),s.matrixs.push(c.clone()),a.push(c.clone()),t.models.find(d=>d.url==o).nodesMap.has(h.id)?(t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes==null&&(t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes=[]),t.models.find(d=>d.url==o).nodesMap.get(h.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(d=>d.url==o).nodesMap.set(h.id,{instance:!0,info:h,indexes:[[t.scene.children.length-1,l,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(l=>l.id),s.matrixsClone=a}function Bc(o){return o.map!=null&&(o.map.colorSpace=S.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=S.FrontSide,o.side=o.side,o}class Oc{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&Dc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class zc{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ut.EngineFree,e=>{this.updateFree(!0),kc(this.engine,e)}),this.engine.events.on(ut.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class Nc{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,r)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${r}:`,a)}})}}class Rc{engine;constructor(e){this.engine=e}init(){const e=new S.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new S.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new S.AmbientLight(16777215,1);this.engine.scene.add(i)}}var _e=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.MeasureClick="measure-click",o.SectionMove="section-move",o))(_e||{});class Fc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new S.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;timeOutEvent;handleMouseMove(e){if(this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null),e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;let n=this.getCatchMeshs(e,!0);n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let n=e.catch.object,i=e.catch.object.id,s=this.engine.models.find(l=>l.url==n.url).nodesMap.get(i),r=new Map;s?.indexes.forEach(l=>{this.engine.scene.children[l[0]]instanceof S.InstancedMesh&&(r.has(l[0])?r.get(l[0])?.push(l[1]):r.set(l[0],[l[1]]))});let a=[];return r.forEach((l,h)=>{let c=this.engine.scene.children[h];l.forEach(d=>{let m=c.geometry.clone();m.applyMatrix4(c.matrixs[d]),a.push(new S.Mesh(m,c.material))})}),this.hoverOldId==i?[]:(this.hoverOldId=i,t||this.engine.hoverHighLight.clearHighlight(),a)}else{let i=e.catch.object,s=i.name,l=this.engine.models.find(h=>h.url===i.url).nodesMap.get(s).infos.map(h=>h.mesh);return this.hoverOldId==s?[]:(this.hoverOldId=s,t||this.engine.hoverHighLight.clearHighlight(),l)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(_e.Click,[{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;let i=n.object,r=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix;const l=[];r.indexes.forEach(c=>{let d=c[0],m=this.engine.scene.children[d].geometry.boundingSphere;const p=new S.Box3,f=m.center.clone().applyMatrix4(a),u=m.radius,g=new S.Vector3;g.setFromMatrixScale(a);const y=Math.max(g.x,g.y,g.z),w=u*y;p.min.set(f.x-w,f.y-w,f.z-w),p.max.set(f.x+w,f.y+w,f.z+w),l.push(p)});let h=t(l);this.engine.viewCube.zoomToModel(h)}else{const a=r.infos.map(h=>h.box);let l=t(a);this.engine.viewCube.zoomToModel(l)}}function t(n){let i=new S.Vector3(1e8,1e9,1e10),s=new S.Vector3(-1e8,-1e9,-1e10);return n.forEach(r=>{r.min.x<i.x&&(i.x=r.min.x),r.min.y<i.y&&(i.y=r.min.y),r.min.z<i.z&&(i.z=r.min.z),r.max.x>s.x&&(s.x=r.max.x),r.max.y>s.y&&(s.y=r.max.y),r.max.z>s.z&&(s.z=r.max.z)}),new S.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof S.InstancedMesh),!0)}}class Uc{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new S.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:S.DoubleSide}),this.hideMaterial=new S.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:S.DoubleSide}),this.translucentMaterial=new S.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:S.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof S.InstancedMesh)return;let t=e.materialClone.clone(),n=kr(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.engine.scene.children[a[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[a[0]]),this.engine.scene.children[a[0]].geometry.groups[a[1]].materialIndex=1)})}),Vc(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof S.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=0})}),Fr(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Gc(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Ur(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const r=i.ids.indexOf(s);r!==-1&&i.ids.splice(r,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof S.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=2)})}),jc(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof S.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(this.split_merge_model(this.engine.scene.children[r[0]]),a.geometry.groups[r[1]].materialIndex=0)})}),n.size>0&&Ur(n,this.engine),Fr(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Vc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof S.InstancedMesh))return;const s=i.geometry,r=new S.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:S.DoubleSide}),a=new S.InstancedMesh(s,r,t.length);a.name="highlightModel",a.key=n;const l=new Map,h=new S.Matrix4,c=new S.Matrix4;c.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,h),l.set(d,h.clone()),i.setMatrixAt(d,c),a.setMatrixAt(m,h)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Fr(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof S.InstancedMesh))return;n.forEach(a=>{const l=s.matrixsClone[a];l&&s.setMatrixAt(a,l)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function jc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof S.InstancedMesh))return;const s=i.geometry,r=new S.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:S.DoubleSide}),a=new S.InstancedMesh(s,r,t.length);a.name="translucentModel",a.key=n;const l=new Map,h=new S.Matrix4,c=new S.Matrix4;c.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,h),l.set(d,h.clone()),i.setMatrixAt(d,c),a.setMatrixAt(m,h)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Gc(o,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof S.InstancedMesh))return;const s=new Map,r=new S.Matrix4,a=new S.Matrix4;a.makeScale(0,0,0),t.forEach((l,h)=>{i.getMatrixAt(l,r),s.set(l,r.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Ur(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof S.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class Wc{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof S.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof S.DirectionalLight),i={low:1024,medium:2048,high:2048}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class qn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);i.infos&&i.infos.length>0&&(this.tagDiv.innerHTML=i.infos[0].name);const r=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=r.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=r.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new S.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:S.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const s of i){const r=new S.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),r.matrix.copy(s.matrixWorld),r.matrixAutoUpdate=!1,this.engine.scene.add(r),this.overlayMeshes.push(r)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/qn.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/qn.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Kn={exports:{}},Xc=Kn.exports,Vr;function Zc(){return Vr||(Vr=1,(function(o,e){(function(t,n){o.exports=n()})(Xc,function(){var t=function(){function n(p){return r.appendChild(p.dom),p}function i(p){for(var f=0;f<r.children.length;f++)r.children[f].style.display=f===p?"block":"none";s=p}var s=0,r=document.createElement("div");r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(p){p.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,c=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var p=(performance||Date).now();if(d.update(p-a,200),p>l+1e3&&(c.update(1e3*h/(p-l),100),l=p,h=0,m)){var f=performance.memory;m.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:r,setMode:i}};return t.Panel=function(n,i,s){var r=1/0,a=0,l=Math.round,h=l(window.devicePixelRatio||1),c=80*h,d=48*h,m=3*h,p=2*h,f=3*h,u=15*h,g=74*h,y=30*h,w=document.createElement("canvas");w.width=c,w.height=d,w.style.cssText="width:80px;height:48px";var x=w.getContext("2d");return x.font="bold "+9*h+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,c,d),x.fillStyle=i,x.fillText(n,m,p),x.fillRect(f,u,g,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(f,u,g,y),{dom:w,update:function(v,b){r=Math.min(r,v),a=Math.max(a,v),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,c,u),x.fillStyle=i,x.fillText(l(v)+" "+n+" ("+l(r)+"-"+l(a)+")",m,p),x.drawImage(w,f+h,u,g-h,y,f,u,g-h,y),x.fillRect(f+g-h,u,h,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(f+g-h,u,h,l((1-v/b)*y))}}},t})})(Kn)),Kn.exports}var qc=Zc();const Kc=Us(qc);var Zt=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-Zt.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?Zt.Bounce.In(o*2)*.5:Zt.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),cn=function(){return performance.now()},Yc=(function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=cn()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],r=!t;s&&s.update(e,r)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o})(),Zi={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=Zi.Utils.Linear;return e<0?s(o[0],o[1],n):e>1?s(o[t],o[t-1],t-n):s(o[i],o[i+1>t?t:i+1],n-i)},Utils:{Linear:function(o,e,t){return(e-o)*t+o}}},jr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),qi=new Yc,$c=(function(){function o(e,t){t===void 0&&(t=qi),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Zt.Linear.None,this._interpolationFunction=Zi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=jr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=cn()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,n,i,s){for(var r in n){var a=e[r],l=Array.isArray(a),h=l?"array":typeof a,c=!l&&Array.isArray(n[r]);if(!(h==="undefined"||h==="function")){if(c){var d=n[r];if(d.length===0)continue;for(var m=[a],p=0,f=d.length;p<f;p+=1){var u=this._handleRelativeValue(a,d[p]);if(isNaN(u)){c=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(u)}c&&(n[r]=m)}if((h==="object"||l)&&a&&!c){t[r]=l?[]:{};var g=a;for(var y in g)t[r][y]=g[y];i[r]=l?[]:{};var d=n[r];if(!this._isDynamic){var w={};for(var y in d)w[y]=d[y];n[r]=d=w}this._setupProperties(g,t[r],d,i[r],s)}else(typeof t[r]>"u"||s)&&(t[r]=a),l||(t[r]*=1),c?i[r]=n[r].slice().reverse():i[r]=t[r]||0}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=cn()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=cn()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=qi),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=Zt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Zi.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=cn()),t===void 0&&(t=!0),this._isPaused)return!0;var s,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),h=this._duration+this._repeat*l,c=function(){if(n._duration===0||a>h)return 1;var g=Math.trunc(a/l),y=a-g*l,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},d=c(),m=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var f=0,u=this._chainedTweens.length;f<u;f++)this._chainedTweens[f].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var r=t[s]||0,a=n[s],l=Array.isArray(e[s]),h=Array.isArray(a),c=!l&&h;c?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],r,a,i):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(e[s]=r+(a-r)*i))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},o})();jr.nextId;var et=qi;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var hn={Easing:Zt,Tween:$c};class Hc extends _.DataTextureLoader{constructor(e){super(e),this.type=_.HalfFloatType}parse(e){const r=function(k,P){switch(k){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(P||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(P||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(P||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(P||""))}},d=function(k,P,I){P=P||1024;let C=k.pos,E=-1,M=0,B="",V=String.fromCharCode.apply(null,new Uint16Array(k.subarray(C,C+128)));for(;0>(E=V.indexOf(`
|
|
968
968
|
`))&&M<P&&C<k.byteLength;)B+=V,M+=V.length,C+=128,V+=String.fromCharCode.apply(null,new Uint16Array(k.subarray(C,C+128)));return-1<E?(k.pos+=M+E+1,B+V.slice(0,E)):!1},m=function(k){const P=/^#\?(\S+)/,I=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,z=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,C=/^\s*FORMAT=(\S+)\s*$/,E=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,M={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let B,V;for((k.pos>=k.byteLength||!(B=d(k)))&&r(1,"no header found"),(V=B.match(P))||r(3,"bad initial token"),M.valid|=1,M.programtype=V[1],M.string+=B+`
|
|
969
969
|
`;B=d(k),B!==!1;){if(M.string+=B+`
|
|
970
970
|
`,B.charAt(0)==="#"){M.comments+=B+`
|
|
@@ -1096,7 +1096,7 @@ void main() {
|
|
|
1096
1096
|
|
|
1097
1097
|
gl_FragColor = vec4(color, uOpacity);
|
|
1098
1098
|
}
|
|
1099
|
-
`;class Cd{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=3;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;text;hdr;ground;models=[];reactBoundingClientRect={left:0,top:0};version="2.1.3";versionEl=null;container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.engineModelModule=new Wc(this),this.engineModelModule.init(),this.ai=new pd(this),this.deviceModule=new Go(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new jo(this),this.sceneModule=new Vo(this),this.scene=this.sceneModule.scene,this.renderModule=new Wo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ra(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new wa(this),this.composerModule.init(),this.events=new Nc,this.engineStatus=new zc(this),this.engineStatus.init(),this.loaderModule=new Oc(this),this.lightModule=new Rc(this),this.lightModule.init(),this.viewCube=new th(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=nh(this),this.rangeScale=new ih(this),this.rangeScale.init(),this.clipping=new ad(this),this.clipping.init(),this.setting=new sh(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=Ci(this),this.modelMapperBatch=new ud(this),this.measure=new fh(this),this.modelToolModule=new Uc(this),this.modelProperties=new hd(this),this.interactionModule=new Fc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new qn(this),this.modelEdge=new dd(this),this.modelTree=new ld(this),this.engineInfo=new cd(this),this.pathRoaming=new md(this),this.pathRoaming.init(),this.minMap=new gd(this),this.grid=new wd(this),this.level=new vd(this),this.text=new bd(this),this.hdr=new _d(this),this.ground=new Md(this),this.ground.init(),this.worldToScreen=new ze(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Kc,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(ut.EngineBusy)}),this.controls.addEventListener("end",()=>{i.events.trigger(ut.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const r=s-this._fpsLastCheck,a=this._fpsFrameCount/r*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let r=this.scene?.dirLight;r&&this.camera&&this.updateLightPosition(this.camera,r)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new S.Vector3;e.getWorldDirection(n);const i=100,s=new S.Vector3().copy(n).multiplyScalar(-i),r=new S.Vector3(0,1,0),a=new S.Vector3().crossVectors(n,r).normalize();s.addScaledVector(r,i*.5),s.addScaledVector(a,i*.3),t.position.copy(e.position).add(s);const l=new S.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,r=this.container.clientWidth/this.container.clientHeight;i.left=s*r/-2,i.right=s*r/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ut.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof S.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof S.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof S.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof S.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof S.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof S.Texture&&i.dispose()}),e.dispose()}}function Td(o){return new Cd(o)}const Pd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
|
1099
|
+
`;class Cd{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=3;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;text;hdr;ground;models=[];reactBoundingClientRect={left:0,top:0};version="2.1.5";versionEl=null;container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.engineModelModule=new Wc(this),this.engineModelModule.init(),this.ai=new pd(this),this.deviceModule=new Go(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new jo(this),this.sceneModule=new Vo(this),this.scene=this.sceneModule.scene,this.renderModule=new Wo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ra(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new wa(this),this.composerModule.init(),this.events=new Nc,this.engineStatus=new zc(this),this.engineStatus.init(),this.loaderModule=new Oc(this),this.lightModule=new Rc(this),this.lightModule.init(),this.viewCube=new th(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=nh(this),this.rangeScale=new ih(this),this.rangeScale.init(),this.clipping=new ad(this),this.clipping.init(),this.setting=new sh(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=Ci(this),this.modelMapperBatch=new ud(this),this.measure=new fh(this),this.modelToolModule=new Uc(this),this.modelProperties=new hd(this),this.interactionModule=new Fc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new qn(this),this.modelEdge=new dd(this),this.modelTree=new ld(this),this.engineInfo=new cd(this),this.pathRoaming=new md(this),this.pathRoaming.init(),this.minMap=new gd(this),this.grid=new wd(this),this.level=new vd(this),this.text=new bd(this),this.hdr=new _d(this),this.ground=new Md(this),this.ground.init(),this.worldToScreen=new ze(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Kc,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(ut.EngineBusy)}),this.controls.addEventListener("end",()=>{i.events.trigger(ut.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const r=s-this._fpsLastCheck,a=this._fpsFrameCount/r*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let r=this.scene?.dirLight;r&&this.camera&&this.updateLightPosition(this.camera,r)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new S.Vector3;e.getWorldDirection(n);const i=100,s=new S.Vector3().copy(n).multiplyScalar(-i),r=new S.Vector3(0,1,0),a=new S.Vector3().crossVectors(n,r).normalize();s.addScaledVector(r,i*.5),s.addScaledVector(a,i*.3),t.position.copy(e.position).add(s);const l=new S.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,r=this.container.clientWidth/this.container.clientHeight;i.left=s*r/-2,i.right=s*r/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ut.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof S.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof S.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof S.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof S.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof S.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof S.Texture&&i.dispose()}),e.dispose()}}function Td(o){return new Cd(o)}const Pd=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家\r
|
|
1100
1100
|
\r
|
|
1101
1101
|
## 角色定位\r
|
|
1102
1102
|
\r
|