iflow-engine-base 3.8.3 → 3.8.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 +3 -8
- package/dist/bim-engine-sdk.es.js.map +1 -1
- package/dist/bim-engine-sdk.umd.js +3 -3
- package/dist/bim-engine-sdk.umd.js.map +1 -1
- package/dist2d/dwg-preview.es.js +77 -82
- package/dist2d/dwg-preview.es.js.map +1 -1
- package/dist2d/dwg-preview.umd.js +1 -1
- package/dist2d/dwg-preview.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -4938,7 +4938,7 @@ void main() {
|
|
|
4938
4938
|
`):" "+WA(o[0]):"as no adapter specified";throw new Je("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const HA={getAdapter:HI,adapters:Yd};function Kd(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Ao(null,s)}function qA(s){return Kd(s),s.headers=_n.from(s.headers),s.data=Xd.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),HA.getAdapter(s.adapter||ga.adapter,s)(s).then(function(n){return Kd(s),n.data=Xd.call(s,s.transformResponse,n),n.headers=_n.from(n.headers),n},function(n){return PA(n)||(Kd(s),n&&n.response&&(n.response.data=Xd.call(s,s.transformResponse,n.response),n.response.headers=_n.from(n.response.headers))),Promise.reject(n)})}const XA="1.13.2",Mc={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{Mc[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});const YA={};Mc.transitional=function(e,t,n){function i(r,o){return"[Axios v"+XA+"] Transitional option '"+r+"'"+o+(n?". "+n:"")}return(r,o,a)=>{if(e===!1)throw new Je(i(o," has been removed"+(t?" in "+t:"")),Je.ERR_DEPRECATED);return t&&!YA[o]&&(YA[o]=!0,console.warn(i(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(r,o,a):!0}},Mc.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function qI(s,e,t){if(typeof s!="object")throw new Je("options must be an object",Je.ERR_BAD_OPTION_VALUE);const n=Object.keys(s);let i=n.length;for(;i-- >0;){const r=n[i],o=e[r];if(o){const a=s[r],l=a===void 0||o(a,r,s);if(l!==!0)throw new Je("option "+r+" must be "+l,Je.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Je("Unknown option "+r,Je.ERR_BAD_OPTION)}}const Sc={assertOptions:qI,validators:Mc},vi=Sc.validators;let dr=class{constructor(e){this.defaults=e||{},this.interceptors={request:new IA,response:new IA}}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 r=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?r&&!String(n.stack).endsWith(r.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
4939
4939
|
`+r):n.stack=r}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=ur(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:r}=t;n!==void 0&&Sc.assertOptions(n,{silentJSONParsing:vi.transitional(vi.boolean),forcedJSONParsing:vi.transitional(vi.boolean),clarifyTimeoutError:vi.transitional(vi.boolean)},!1),i!=null&&(ce.isFunction(i)?t.paramsSerializer={serialize:i}:Sc.assertOptions(i,{encode:vi.function,serialize:vi.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Sc.assertOptions(t,{baseUrl:vi.spelling("baseURL"),withXsrfToken:vi.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&ce.merge(r.common,r[t.method]);r&&ce.forEach(["delete","get","head","post","put","patch","common"],m=>{delete r[m]}),t.headers=_n.concat(o,r);const a=[];let l=!0;this.interceptors.request.forEach(function(g){typeof g.runWhen=="function"&&g.runWhen(t)===!1||(l=l&&g.synchronous,a.unshift(g.fulfilled,g.rejected))});const c=[];this.interceptors.response.forEach(function(g){c.push(g.fulfilled,g.rejected)});let h,u=0,d;if(!l){const m=[qA.bind(this),void 0];for(m.unshift(...a),m.push(...c),d=m.length,h=Promise.resolve(t);u<d;)h=h.then(m[u++],m[u++]);return h}d=a.length;let f=t;for(;u<d;){const m=a[u++],g=a[u++];try{f=m(f)}catch(A){g.call(this,A);break}}try{h=qA.call(this,f)}catch(m){return Promise.reject(m)}for(u=0,d=c.length;u<d;)h=h.then(c[u++],c[u++]);return h}getUri(e){e=ur(this.defaults,e);const t=FA(e.baseURL,e.url,e.allowAbsoluteUrls);return EA(t,e.params,e.paramsSerializer)}};ce.forEach(["delete","get","head","options"],function(e){dr.prototype[e]=function(t,n){return this.request(ur(n||{},{method:e,url:t,data:(n||{}).data}))}}),ce.forEach(["post","put","patch"],function(e){function t(n){return function(r,o,a){return this.request(ur(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}dr.prototype[e]=t(),dr.prototype[e+"Form"]=t(!0)});let XI=class y_{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const n=this;this.promise.then(i=>{if(!n._listeners)return;let r=n._listeners.length;for(;r-- >0;)n._listeners[r](i);n._listeners=null}),this.promise.then=i=>{let r;const o=new Promise(a=>{n.subscribe(a),r=a}).then(i);return o.cancel=function(){n.unsubscribe(r)},o},e(function(r,o,a){n.reason||(n.reason=new Ao(r,o,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 y_(function(i){e=i}),cancel:e}}};function YI(s){return function(t){return s.apply(null,t)}}function KI(s){return ce.isObject(s)&&s.isAxiosError===!0}const $d={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($d).forEach(([s,e])=>{$d[e]=s});function KA(s){const e=new dr(s),t=dA(dr.prototype.request,e);return ce.extend(t,dr.prototype,e,{allOwnKeys:!0}),ce.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return KA(ur(s,i))},t}const Et=KA(ga);Et.Axios=dr,Et.CanceledError=Ao,Et.CancelToken=XI,Et.isCancel=PA,Et.VERSION=XA,Et.toFormData=vc,Et.AxiosError=Je,Et.Cancel=Et.CanceledError,Et.all=function(e){return Promise.all(e)},Et.spread=YI,Et.isAxiosError=KI,Et.mergeConfig=ur,Et.AxiosHeaders=_n,Et.formToJSON=s=>BA(ce.isHTMLForm(s)?new FormData(s):s),Et.getAdapter=HA.getAdapter,Et.HttpStatusCode=$d,Et.default=Et;const{Axios:zF,AxiosError:GF,CanceledError:VF,isCancel:QF,CancelToken:jF,VERSION:WF,all:HF,Cancel:qF,isAxiosError:XF,spread:YF,toFormData:KF,AxiosHeaders:$F,HttpStatusCode:JF,formToJSON:ZF,getAdapter:eO,mergeConfig:tO}=Et;class xo{static MAGIC=new TextEncoder().encode("BIMGCM01");static isEncrypted(e){if(e.byteLength<8)return!1;const t=new Uint8Array(e);for(let n=0;n<8;n++)if(t[n]!==xo.MAGIC[n])return!1;return!0}static async decryptPzEnc(e,t){const n=new Uint8Array(e),i=new TextEncoder().encode("BIMGCM01");for(let A=0;A<i.length;A++)if(n[A]!==i[A])throw new Error("magic 不匹配: 不是有效的 pzenc 文件");const r=n[8];if(r!==1)throw new Error(`不支持的 pzenc 版本: ${r}`);const o=n[9],a=n[10],l=11,c=n.slice(l,l+o),h=n.slice(l+o,l+o+a),u=n.slice(l+o+a),d=JI(u,h),f=$I(t);if(f.length!==32)throw new Error("AES-256 密钥必须是 32 字节");const m=await crypto.subtle.importKey("raw",f.buffer,{name:"AES-GCM"},!1,["decrypt"]),g=await crypto.subtle.decrypt({name:"AES-GCM",iv:c.buffer,additionalData:n.slice(0,l).buffer,tagLength:a*8},m,d.buffer);return new Uint8Array(g)}}function $I(s){const e=atob(s),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.codePointAt(n);return t}function JI(s,e){const t=new Uint8Array(s.length+e.length);return t.set(s,0),t.set(e,s.length),t}function Ec(s,e,t,n){Et({method:"get",responseType:"arraybuffer",url:s}).then(async r=>{let o=r.data;n&&xo.isEncrypted(r.data)&&(o=await xo.decryptPzEnc(r.data,n)),zd.loadAsync(o).then(a=>{for(let l in a.files){const c=a.file(a.files[l].name);c&&c.async("blob").then(h=>{i(h,"utf-8",function(u,d){e(d)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(()=>{t()});function i(r,o,a){var l=new FileReader,c=new Blob([r]);l.onload=function(h){a(null,h.target.result)},l.onerror=function(){a(null,null)},l.readAsText(c,o)}}const Jd=new WeakMap;class ZI extends w.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 r=new w.FileLoader(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,w.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,r=w.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:r};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Jd.has(e)){const l=Jd.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 r=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(r,o).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[r]={resolve:c,reject:h},i.postMessage({type:"decode",id:r,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&r&&this._releaseTask(i,r)}),Jd.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new w.BufferGeometry;e.index&&t.setIndex(new w.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:r,itemSize:o,stride:a,vertexColorSpace:l}=e.attributes[n];let c;if(o===a)c=new w.BufferAttribute(r,o);else{const h=new w.InterleavedBuffer(r,a);c=new w.InterleavedBufferAttribute(h,o,0)}i==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(r instanceof Float32Array)),t.setAttribute(i,c)}return t}_assignVertexColorSpace(e,t){if(t!==w.SRGBColorSpace)return;const n=new w.Color;for(let i=0,r=e.count;i<r;i++)n.fromBufferAttribute(e,i),w.ColorManagement.colorSpaceToWorking(n,w.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new w.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,r)=>{n.load(e,i,void 0,r)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const r=eT.toString(),o=["/* draco decoder */",i,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join(`
|
|
4940
4940
|
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),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(r){const o=r.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,r){return i._taskLoad>r._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 eT(){let s,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":s=a.decoderConfig,e=new Promise(function(h){s.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(s)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const u=h.draco,d=new u.Decoder;try{const f=t(u,d,new Int8Array(l),c),m=f.attributes.map(g=>g.array.buffer);f.index&&m.push(f.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:f},m)}catch(f){console.error(f),self.postMessage({type:"error",id:a.id,error:f.message})}finally{u.destroy(d)}});break}};function t(o,a,l,c){const h=c.attributeIDs,u=c.attributeTypes;let d,f;const m=a.GetEncodedGeometryType(l);if(m===o.TRIANGULAR_MESH)d=new o.Mesh,f=a.DecodeArrayToMesh(l,l.byteLength,d);else if(m===o.POINT_CLOUD)d=new o.PointCloud,f=a.DecodeArrayToPointCloud(l,l.byteLength,d);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!f.ok()||d.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+f.error_msg());const g={index:null,attributes:[]};for(const A in h){const p=self[u[A]];let x,y;if(c.useUniqueIDs)y=h[A],x=a.GetAttributeByUniqueId(d,y);else{if(y=a.GetAttributeId(d,o[h[A]]),y===-1)continue;x=a.GetAttribute(d,y)}const v=i(o,a,d,A,p,x);A==="color"&&(v.vertexColorSpace=c.vertexColorSpace),g.attributes.push(v)}return m===o.TRIANGULAR_MESH&&(g.index=n(o,a,d)),o.destroy(d),g}function n(o,a,l){const h=l.num_faces()*3,u=h*4,d=o._malloc(u);a.GetTrianglesUInt32Array(l,u,d);const f=new Uint32Array(o.HEAPF32.buffer,d,h).slice();return o._free(d),{array:f,itemSize:1}}function i(o,a,l,c,h,u){const d=l.num_points(),f=u.num_components(),m=r(o,h),g=f*h.BYTES_PER_ELEMENT,A=Math.ceil(g/4)*4,p=A/h.BYTES_PER_ELEMENT,x=d*g,y=d*A,v=o._malloc(x);a.GetAttributeDataArrayForAllPoints(l,u,m,x,v);const _=new h(o.HEAPF32.buffer,v,x/h.BYTES_PER_ELEMENT);let E;if(g===A)E=_.slice();else{E=new h(y/h.BYTES_PER_ELEMENT);let I=0;for(let B=0,M=_.length;B<M;B++){for(let C=0;C<f;C++)E[I+C]=_[B*f+C];I+=p}}return o._free(v),{name:c,count:d,itemSize:f,array:E,stride:p}}function r(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}var tT=(function(){var s="b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuec:W:Odkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq;lZkdbk;jYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbhodnawTmbaxa8Acd4fRbbhokaocFeGh5cbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q1jjbfcj1jjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bbarcwf9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfag9c8F1:NghcKtc8F91aicdfa8J9c8N1:Nfg8KRbbG86bbarcVfcba8KahcjeGcr4fghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fag9c8F1:NgicKtc8F91aha8J9c8N1:NfghRbbG86bbarc96fcbahaicjeGcr4fgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbb83bbarcwfaicwf8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbcbaocl49Rh8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E93aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:XseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8AavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk::ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxabaiarcefciGfcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGfgkcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkabaiarcufciGfcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkabakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K1jjbgeabcifc98GfgbBd:K1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;teeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiaeydlBdlaiaeydwBdwaiaeydxBdxaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk:3eedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdxaialBdwaialBdlaialBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk81dbcjwk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:Kwkl8WNbb",e="b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuec:q:6dkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:Ctklbzik9:evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaec:q:yjjbfai86bbaecitc:q1jjbfab8Piw83ibaecefgecjd9hmbkk:183lYud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxavaialfgmar9Rgoad;8qbbcj;abad9Uc;WFbGcjdadca0EhPdndndnadTmbaoadfhscbhzinaeaz9nmdamax9RaD6miabazad2fhHaxaDfhOaPaeaz9RazaPfae6EgAcsfgocl4cifcd4hCavcj;cbfaoc9WGgXcetfhQavcj;cbfaXci2fhLavcj;cbfaXfhKcbhYaoc;ab6h8AincbhodnawTmbaxaYcd4fRbbhokaocFeGhEcbh3avcj;cbfh5indndndndnaEa3cet4ciGgoc9:fPdebdkamaO9RaX6mwavcj;cbfa3aX2faOaX;8qbbaOaAfhOxdkavcj;cbfa3aX2fcbaX;8kbxekamaO9RaC6moaoclVcbawEhraOaCfhocbhidna8Ambamao9Rc;Gb6mbcbhlina5alfhidndndndndndnaOalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaiczfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaoclffahc:q:yjjbfRbbfhoxikaicafaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaaaocwffahc:q:yjjbfRbbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaaaocdffahc:q:yjjbfRbbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaoclffaqc:q:yjjbfRbbfhoxikaic8Wfaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngicitc:q1jjbfpbibaic:q:yjjbfRbbgipsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spklbaiaocwffaqc:q:yjjbfRbbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitc:q1jjbfpbibaic:q:yjjbfRbbgipsaoRbegqcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqc:q:yjjbfRbbfhokalc;abfhialcjefaX0meaihlamao9Rc;Fb0mbkkdnaiaX9pmbaici4hlinamao9RcK6mwa5aifhqdndndndndndnaOaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLg8Ecdp:mea8EpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9og8Fpxiiiiiiiiiiiiiiiip8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaoclffahc:q:yjjbfRbbfhoxikaqaopbbwaopbbbg8Eclp:mea8EpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9og8Fpxssssssssssssssssp8Jg8Ep5b9cjF;8;4;W;G;ab9:9cU1:Ngacitc:q1jjbfpbibaac:q:yjjbfRbbgapsa8Ep5e9cjF;8;4;W;G;ab9:9cU1:Nghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPa8Fa8Ep9spkbbaaaocwffahc:q:yjjbfRbbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbgacitc:q1jjbfpbibaac:q:yjjbfRbbgapsaoRbeghcitc:q1jjbfpbibp9UpmbedilvorzHOACXQLpPpkbbaaaocdffahc:q:yjjbfRbbfhokalcdfhlaiczfgiaX6mbkkaohOaoTmoka5aXfh5a3cefg3cl9hmbkdndndndnawTmbasaYcd4fRbbglciGPlbedwbkaXTmdavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep9Ta8Epxeeeeeeeeeeeeeeeeg8Fp9op9Hp9rg8Eagp9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Uggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp9Uggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp9Uggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep9Ta8Ea8Fp9op9Hp9rg8Ep9Ug8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9Ug8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9Uggp9AbbbaladfhlaoczfgoaX6mbxikkaXTmeavcjdfaYfhlavaYfpbdbhgcbhoinalavcj;cbfaofpblbg8JaKaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaQaofpblbg8MaLaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Ecep:nea8Epxebebebebebebebebg8Fp9op:bep9rg8Eagp:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8LaypmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeggp9Abbbaladfglaga8Ea8Epmlvorlvorlvorlvorp:oeggp9Abbbaladfglaga8Ea8EpmwDqkwDqkwDqkwDqkp:oeggp9Abbbaladfglaga8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9Abbbaladfglaga8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Ecep:nea8Ea8Fp9op:bep9rg8Ep:oeg8Fp9Abbbaladfgla8Fa8Ea8Epmlvorlvorlvorlvorp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmwDqkwDqkwDqkwDqkp:oeg8Fp9Abbbaladfgla8Fa8Ea8EpmxmPsxmPsxmPsxmPsp:oeggp9AbbbaladfhlaoczfgoaX6mbxdkkaXTmbcbhocbalcl4gl9Rc8FGhiavcjdfaYfhravaYfpbdbh8Finaravcj;cbfaofpblbggaKaofpblbg8JpmbzeHdOiAlCvXoQrLg8KaQaofpblbg8LaLaofpblbg8MpmbzeHdOiAlCvXoQrLg8NpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ea8Fp9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Fa8Ka8NpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwKDYq8AkEx3m5P8Es8Fgga8La8MpmwKDYq8AkEx3m5P8Es8Fg8JpmbezHdiOAlvCXorQLg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9Abbbaradfgra8Faga8JpmwDKYqk8AExm35Ps8E8Fg8Eaip:Rea8Ealp:Sep9qg8Ep9rg8Fp9Abbbaradfgra8Fa8Ea8Epmlvorlvorlvorlvorp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmwDqkwDqkwDqkwDqkp9rg8Fp9Abbbaradfgra8Fa8Ea8EpmxmPsxmPsxmPsxmPsp9rg8Fp9AbbbaradfhraoczfgoaX6mbkkaYclfgYad6mbkaHavcjdfaAad2;8qbbavavcjdfaAcufad2fad;8qbbaAazfhzc9:hoaOhxaOmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdaPaeao9RaoaPfae6Eaofgoae6mbkaial9Rhxkcbc99amax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbk:TseHu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnaeci9UgrcHfal0mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbavcUf9cu83ibavc8Wf9cu83ibavcyf9cu83ibavcaf9cu83ibavcKf9cu83ibavczf9cu83ibav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbaxcefgOavaiaqaDcsGfRbbgscl49RcsGcdtfydbascz6gPEhDavaias9RcsGcdtfydbaOaPfgzascsGgOEhsaOThOdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiaPfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaOfhiazaOfhxxekaxcbalRbbgHEgAaDc;:eSgDfhzaHcsGhCaHcl4hXdndnaHcs0mbazcefhOxekazhOavaiaX9RcsGcdtfydbhzkdndnaCmbaOcefhxxekaOhxavaiaH9RcsGcdtfydbhOkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhAascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaAhDxekaDcefhDkasce4cbasceG9R7amfgmhAkdndnaXcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhzaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkazhsxekascefhskaPce4cbaPceG9R7amfgmhzkdndnaCcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhOaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkaOhlxekalcefhlkaPce4cbaPceG9R7amfgmhOkdndnadcd9hmbabarcetfgDaA87ebaDclfaO87ebaDcdfaz87ebxekabarcdtfgDaABdbaDcwfaOBdbaDclfazBdbkavc;abfaocitfgDazBdbaDaABdlavaicdtfaABdbavc;abfaocefcsGcitfgDaOBdbaDazBdlavaicefgicsGcdtfazBdbavc;abfaocdfcsGcitfgDaABdbaDaOBdlavaiaHcz6aXcsSVfgicsGcdtfaOBdbaiaCTaCcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnaecvfal9nmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:2Pliur97eue978Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbdnalTmbcbhvabhdinadadpbbbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDpxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbadczfhdavclfgval6mbkkalaeSmeaipxbbbbbbbbbbbbbbbbgqpklbaiabalcdtfgdaeciGglcdtgv;8qbbdnalTmbaiaipblbgocKp:RecKp:Sep;6egraocwp:RecKp:Sep;6earp;Geaoczp:RecKp:Sep;6egwp;Gep;Kep;LegDaqp:2egqarpxbbbjbbbjbbbjbbbjgkp9op9rp;Kegrpxbb;:9cbb;:9cbb;:9cbb;:9cararp;MeaDaDp;Meawaqawakp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFbbbFbbbFbbbFbbbp9oaopxbbbFbbbFbbbFbbbFp9op9qarawp;Meaqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaDawp;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpklbkadaiav;8qbbskaipxFubbFubbFubbFubbgxpklbdnalTmbcbhvabhdinadczfgmampbbbgopxbbbbbbFFbbbbbbFFgkp9oadpbbbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblbaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpkbbadaDakp9oaoarpmbezHdiOAlvCXorQLp9qpkbbadcafhdavclfgval6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgopklbaiaopklbaiabalcitfgdaeciGglcitgv;8qbbaiaxpkladnalTmbaiaipblzgopxbbbbbbFFbbbbbbFFgkp9oaipblbgDaopmbediwDqkzHOAKY8AEgwczp:Reczp:Sep;6egraipblaaDaopmlvorxmPsCXQL358E8Fp9op;6eawczp:Sep;6egwp;Gearp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egqarpxbbbjbbbjbbbjbbbjgPp9op9rp;Kegrpxb;:FSb;:FSb;:FSb;:FSararp;Meaoaop;MeawaqawaPp9op9rp;Kegrarp;Mep;Kep;Kep;Jep;Negwp;Mepxbbn0bbn0bbn0bbn0gqp;KepxFFbbFFbbFFbbFFbbp9oaoawp;Meaqp;Keczp:Rep9qgoarawp;Meaqp;KepxFFbbFFbbFFbbFFbbp9ogrpmwDKYqk8AExm35Ps8E8Fp9qpklzaiaDakp9oaoarpmbezHdiOAlvCXorQLp9qpklbkadaiav;8qbbkk:Iwllue97euo978Jjjjjbca9Rhidnaec98GglTmbcbhvabhoinaocKfpx:ji:1S:ji:1S:ji:1S:ji:1SaopbbbgraoczfgwpbbbgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83ibawarp5bampEd:T:j83ibaocwfaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83ibaoaxp5bampEb:T:j83ibaocafhoavclfgval6mbkkdnalaeSmbaiczfpxbbbbbbbbbbbbbbbbgmpklbaiampklbaiabalcitfgoaeciGgvcitgw;8qbbdnavTmbaipx:ji:1S:ji:1S:ji:1S:ji:1SaipblbgraipblzgDpmlvorxmPsCXQL358E8Fgqczp:Segkpxibbbibbbibbbibbbp9qgxp;6ep;Negmaxaxp:1ep;7egxaxp;KearaDpmbediwDqkzHOAKY8AEgxczp:Reczp:Sep;6egrarp;Meaxczp:Sep;6egDaDp;Meaqczp:Reczp:Sep;6egqaqp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gxp;KepxFFbbFFbbFFbbFFbbgPp9oamaDp;Meaxp;Keczp:Rep9qgDamarp;Meaxp;KeaPp9oamaqp;Meaxp;Keczp:Rep9qgxpmwDKYqk8AExm35Ps8E8Fgrp5eakclp:RegmpEi:T:j83iKaiarp5bampEd:T:j83izaiaDaxpmbezHdiOAlvCXorQLgxp5eampEe:T:j83iwaiaxp5bampEb:T:j83ibkaoaiaw;8qbbkk;uddiue978Jjjjjbc;ab9Rhidnadcd4ae2glc98GgvTmbcbheabhdinadadpbbbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbadczfhdaeclfgeav6mbkkdnavalSmbaic8WfpxbbbbbbbbbbbbbbbbgopklbaicafaopklbaiczfaopklbaiaopklbaiabavcdtfgdalciGgecdtgv;8qbbdnaeTmbaiaipblbgocwp:Recwp:Sep;6eaocep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepklbkadaiav;8qbbkk:CPvdue97euw97eu8Jjjjjbc8W9Rhiaec98Ghldndnadcl9hmbaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadpbbbhradpxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpkbbadczfhdaoclfgoal6mbkkalaeSmeaiavpklaaicafabalcdtfgdaeciGglcdtgo;8qbbaiavpklbdnalTmbaipblahraipxbbuJbbuJbbuJbbuJaipblbarcKp:Tep9qgwcep:Seawp9qgDcdp:SeaDp9qgDclp:SeaDp9qgqp;6ep;NegDarcwp:RecKp:SegkarpxFbbbFbbbFbbbFbbbgxp9ogmp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gPp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oaDamakp:Xearczp:RecKp:Segrp:Uep;6ep;MeaPp;Keaxp9op9qaDamakarp:Uep:Xep;6ep;MeaPp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qaDaqawcep:Rep9oawpxebbbebbbebbbebbbp9op9qp;6ep;MeaPp;KecKp:Rep9qpklakadaicafao;8qbbskaipxbbbbbbbbbbbbbbbbgvpklbdnalTmbcbhoabhdinadczfgspxbFu9hbFu9hbFu9hbFu9hadpbbbgDaspbbbgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblbp9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpkbbadaxarpmbezHdiOAlvCXorQLpkbbadcafhdaoclfgoal6mbkkalaeSmbaiczfpxbbbbbbbbbbbbbbbbgrpklbaiarpklbaiabalcitfgdaeciGglcitgo;8qbbaiavpkladnalTmbaipxbFu9hbFu9hbFu9hbFu9haipblbgDaipblzgPpmlvorxmPsCXQL358E8Fgmczp:Teaipblap9qgrcep:Searp9qgwcdp:Seawp9qgwclp:Seawp9qgwcwp:Seawp9qgqp;6ep;NegwaDaPpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbgPp9ogkaDczp:Segxp:Ueamczp:Reczp:Segmp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gDp;KeaPp9oawakaxamp:Uep:Xep;6ep;MeaDp;Keczp:Rep9qgxawaqarcep:Rep9oarpxebbbebbbebbbebbbp9op9qp;6ep;MeaDp;Keczp:Reawamakp:Uep;6ep;MeaDp;KeaPp9op9qgrpmwDKYqk8AExm35Ps8E8FpklzaiaxarpmbezHdiOAlvCXorQLpklbkadaiao;8qbbkk9teiucbcbydj1jjbgeabcifc98GfgbBdj1jjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkkebcjwklz:Dbb",t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if(typeof WebAssembly!="object")return{supported:!1};var i=WebAssembly.validate(t)?a(e):a(s),r,o=WebAssembly.instantiate(i,{}).then(function(p){r=p.instance,r.exports.__wasm_call_ctors()});function a(p){for(var x=new Uint8Array(p.length),y=0;y<p.length;++y){var v=p.charCodeAt(y);x[y]=v>96?v-97:v>64?v-39:v+4}for(var _=0,y=0;y<p.length;++y)x[_++]=x[y]<60?n[x[y]]:(x[y]-60)*64+x[++y];return x.buffer.slice(0,_)}function l(p,x,y,v,_,E,I){var B=p.exports.sbrk,M=v+3&-4,C=B(M*_),P=B(E.length),T=new Uint8Array(p.exports.memory.buffer);T.set(E,P);var R=x(C,v,_,P,E.length);if(R==0&&I&&I(C,M,_),y.set(T.subarray(C,C+v*_)),B(C-B(0)),R!=0)throw new Error("Malformed buffer data: "+R)}var c={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp",COLOR:"meshopt_decodeFilterColor"},h={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"},u=[],d=0;function f(p){var x={object:new Worker(p),pending:0,requests:{}};return x.object.onmessage=function(y){var v=y.data;x.pending-=v.count,x.requests[v.id][v.action](v.value),delete x.requests[v.id]},x}function m(p){for(var x="self.ready = WebAssembly.instantiate(new Uint8Array(["+new Uint8Array(i)+"]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = "+A.name+";"+l.toString()+A.toString(),y=new Blob([x],{type:"text/javascript"}),v=URL.createObjectURL(y),_=u.length;_<p;++_)u[_]=f(v);for(var _=p;_<u.length;++_)u[_].object.postMessage({});u.length=p,URL.revokeObjectURL(v)}function g(p,x,y,v,_){for(var E=u[0],I=1;I<u.length;++I)u[I].pending<E.pending&&(E=u[I]);return new Promise(function(B,M){var C=new Uint8Array(y),P=++d;E.pending+=p,E.requests[P]={resolve:B,reject:M},E.object.postMessage({id:P,count:p,size:x,source:C,mode:v,filter:_},[C.buffer])})}function A(p){var x=p.data;if(!x.id)return self.close();self.ready.then(function(y){try{var v=new Uint8Array(x.count*x.size);l(y,y.exports[x.mode],v,x.count,x.size,x.source,y.exports[x.filter]),self.postMessage({id:x.id,count:x.count,action:"resolve",value:v},[v.buffer])}catch(_){self.postMessage({id:x.id,count:x.count,action:"reject",value:_})}})}return{ready:o,supported:!0,useWorkers:function(p){m(p)},decodeVertexBuffer:function(p,x,y,v,_){l(r,r.exports.meshopt_decodeVertexBuffer,p,x,y,v,r.exports[c[_]])},decodeIndexBuffer:function(p,x,y,v){l(r,r.exports.meshopt_decodeIndexBuffer,p,x,y,v)},decodeIndexSequence:function(p,x,y,v){l(r,r.exports.meshopt_decodeIndexSequence,p,x,y,v)},decodeGltfBuffer:function(p,x,y,v,_,E){l(r,r.exports[h[_]],p,x,y,v,r.exports[c[E]])},decodeGltfBufferAsync:function(p,x,y,v,_){return u.length>0?g(p,x,y,h[v],c[_]):o.then(function(){var E=new Uint8Array(p*x);return l(r,r.exports[h[v]],E,p,x,y,r.exports[c[_]]),E})}}})();class nT{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0,this.workerCreator=null}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:i,msg:r,transfer:o}=this.queue.shift();this.workersResolve[e]=i,this.workers[e].postMessage(r,o)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise(n=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})})}dispose(){this.workers.forEach(e=>e.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const iT=0,$A=2,sT=1,JA=2,rT=0,oT=1,aT=10,lT=0,ZA=9,e0=15,t0=16,n0=22,i0=37,s0=43,r0=76,o0=83,a0=97,l0=100,c0=103,h0=109,u0=122,d0=123,f0=131,p0=132,g0=133,m0=134,A0=137,x0=138,y0=139,b0=140,v0=141,_0=142,w0=145,C0=146,M0=148,S0=152,E0=153,I0=154,T0=155,B0=156,D0=157,P0=158,L0=165,R0=166,k0=1000054e3,F0=1000054001,O0=1000054004,U0=1000054005,Zd=1000066e3,N0=1000066004;let Aa=class{constructor(e,t,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,n),this._littleEndian=i,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+4294967296*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==t&&i<e;)i++,this._offset++;return i<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}};const hn=[171,75,84,88,32,50,48,187,13,10,26,10];function z0(s){return new TextDecoder().decode(s)}function cT(s){const e=new Uint8Array(s.buffer,s.byteOffset,hn.length);if(e[0]!==hn[0]||e[1]!==hn[1]||e[2]!==hn[2]||e[3]!==hn[3]||e[4]!==hn[4]||e[5]!==hn[5]||e[6]!==hn[6]||e[7]!==hn[7]||e[8]!==hn[8]||e[9]!==hn[9]||e[10]!==hn[10]||e[11]!==hn[11])throw new Error("Missing KTX 2.0 identifier.");const t={vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null},n=17*Uint32Array.BYTES_PER_ELEMENT,i=new Aa(s,hn.length,n,!0);t.vkFormat=i._nextUint32(),t.typeSize=i._nextUint32(),t.pixelWidth=i._nextUint32(),t.pixelHeight=i._nextUint32(),t.pixelDepth=i._nextUint32(),t.layerCount=i._nextUint32(),t.faceCount=i._nextUint32(),t.levelCount=i._nextUint32(),t.supercompressionScheme=i._nextUint32();const r=i._nextUint32(),o=i._nextUint32(),a=i._nextUint32(),l=i._nextUint32(),c=i._nextUint64(),h=i._nextUint64(),u=3*Math.max(t.levelCount,1)*8,d=new Aa(s,hn.length+n,u,!0);for(let z=0,G=Math.max(t.levelCount,1);z<G;z++)t.levels.push({levelData:new Uint8Array(s.buffer,s.byteOffset+d._nextUint64(),d._nextUint64()),uncompressedByteLength:d._nextUint64()});const f=new Aa(s,r,o,!0);f._skip(4);const m=f._nextUint16(),g=f._nextUint16(),A=f._nextUint16(),p=f._nextUint16(),x={vendorId:m,descriptorType:g,versionNumber:A,colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},y=(p/4-6)/4;for(let z=0;z<y;z++){const G={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelType:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};64&G.channelType?(G.sampleLower=f._nextInt32(),G.sampleUpper=f._nextInt32()):(G.sampleLower=f._nextUint32(),G.sampleUpper=f._nextUint32()),x.samples[z]=G}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(x);const v=new Aa(s,a,l,!0);for(;v._offset<l;){const z=v._nextUint32(),G=v._scan(z),re=z0(G);if(t.keyValue[re]=v._nextUint8Array(z-G.byteLength-1),re.match(/^ktx/i)){const le=z0(t.keyValue[re]);t.keyValue[re]=le.substring(0,le.lastIndexOf("\0"))}v._skip(z%4?4-z%4:0)}if(h<=0)return t;const _=new Aa(s,c,h,!0),E=_._nextUint16(),I=_._nextUint16(),B=_._nextUint32(),M=_._nextUint32(),C=_._nextUint32(),P=_._nextUint32(),T=[];for(let z=0,G=Math.max(t.levelCount,1);z<G;z++)T.push({imageFlags:_._nextUint32(),rgbSliceByteOffset:_._nextUint32(),rgbSliceByteLength:_._nextUint32(),alphaSliceByteOffset:_._nextUint32(),alphaSliceByteLength:_._nextUint32()});const R=c+_._offset,S=R+B,F=S+M,N=F+C,j=new Uint8Array(s.buffer,s.byteOffset+R,B),q=new Uint8Array(s.buffer,s.byteOffset+S,M),U=new Uint8Array(s.buffer,s.byteOffset+F,C),H=new Uint8Array(s.buffer,s.byteOffset+N,P);return t.globalData={endpointCount:E,selectorCount:I,imageDescs:T,endpointsData:j,selectorsData:q,tablesData:U,extendedData:H},t}let ef,Ki,tf;const nf={env:{emscripten_notify_memory_growth:function(s){tf=new Uint8Array(Ki.exports.memory.buffer)}}};let hT=class{init(){return ef||(ef=typeof fetch<"u"?fetch("data:application/wasm;base64,"+G0).then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,nf)).then(this._init):WebAssembly.instantiate(Buffer.from(G0,"base64"),nf).then(this._init),ef)}_init(e){Ki=e.instance,nf.env.emscripten_notify_memory_growth(0)}decode(e,t=0){if(!Ki)throw new Error("ZSTDDecoder: Await .init() before decoding.");const n=e.byteLength,i=Ki.exports.malloc(n);tf.set(e,i),t=t||Number(Ki.exports.ZSTD_findDecompressedSize(i,n));const r=Ki.exports.malloc(t),o=Ki.exports.ZSTD_decompress(r,t,i,n),a=tf.slice(r,r+o);return Ki.exports.free(i),Ki.exports.free(r),a}};const G0="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IAMNACAEQQNxBEADQCACRQ0FIAAgAkF/aiICaiIDIAEgAmotAAA6AAAgA0EDcQ0ACwsgAkEDTQ0AA0AgACACQXxqIgJqIAEgAmooAgA2AgAgAkEDSw0ACwsgAkUNAgNAIAAgAkF/aiICaiABIAJqLQAAOgAAIAINAAsMAgsgAkEDTQ0AIAIhBANAIAMgASgCADYCACABQQRqIQEgA0EEaiEDIARBfGoiBEEDSw0ACyACQQNxIQILIAJFDQADQCADIAEtAAA6AAAgA0EBaiEDIAFBAWohASACQX9qIgINAAsLIAAL8wICAn8BfgJAIAJFDQAgACACaiIDQX9qIAE6AAAgACABOgAAIAJBA0kNACADQX5qIAE6AAAgACABOgABIANBfWogAToAACAAIAE6AAIgAkEHSQ0AIANBfGogAToAACAAIAE6AAMgAkEJSQ0AIABBACAAa0EDcSIEaiIDIAFB/wFxQYGChAhsIgE2AgAgAyACIARrQXxxIgRqIgJBfGogATYCACAEQQlJDQAgAyABNgIIIAMgATYCBCACQXhqIAE2AgAgAkF0aiABNgIAIARBGUkNACADIAE2AhggAyABNgIUIAMgATYCECADIAE2AgwgAkFwaiABNgIAIAJBbGogATYCACACQWhqIAE2AgAgAkFkaiABNgIAIAQgA0EEcUEYciIEayICQSBJDQAgAa0iBUIghiAFhCEFIAMgBGohAQNAIAEgBTcDGCABIAU3AxAgASAFNwMIIAEgBTcDACABQSBqIQEgAkFgaiICQR9LDQALCyAACy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAIajYCACADCy8BAn8gACgCBCAAKAIAQQJ0aiICLQACIQMgACACLwEAIAEgAi0AAxAFajYCACADCx8AIAAgASACKAIEEAg2AgAgARAEGiAAIAJBCGo2AgQLCAAgAGdBH3MLugUBDX8jAEEQayIKJAACfyAEQQNNBEAgCkEANgIMIApBDGogAyAEEAsaIAAgASACIApBDGpBBBAVIgBBbCAAEAMbIAAgACAESxsMAQsgAEEAIAEoAgBBAXRBAmoQECENQVQgAygAACIGQQ9xIgBBCksNABogAiAAQQVqNgIAIAMgBGoiAkF8aiEMIAJBeWohDiACQXtqIRAgAEEGaiELQQQh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ASIDNgLE4AEgACgCvOABIQQgACABNgK84AEgACABIAJqNgK44AEgACABIAQgA2tqNgLA4AELpgEBAX8gACAAKALs4QEQFjYCyOABIABCADcD+OABIABCADcDuOABIABBwOABakIANwMAIABBqNAAaiIBQYyAgOAANgIAIABBADYCmOIBIABCADcDiOEBIABCAzcDgOEBIABBrNABakHgEikCADcCACAAQbTQAWpB6BIoAgA2AgAgACABNgIMIAAgAEGYIGo2AgggACAAQaAwajYCBCAAIABBEGo2AgALYQEBf0G4fyEDAkAgAUEDSQ0AIAIgABAhIgFBA3YiADYCCCACIAFBAXE2AgQgAiABQQF2QQNxIgM2AgACQCADQX9qIgFBAksNAAJAIAFBAWsOAgEAAgtBbA8LIAAhAwsgAwsMACAAIAEgAkEAEC4LiAQCA38CfiADEBYhBCAAQQBBKBAQIQAgBCACSwRAIAQPCyABRQRAQX8PCwJAAkAgA0EBRg0AIAEoAAAiBkGo6r5pRg0AQXYhAyAGQXBxQdDUtMIBRw0BQQghAyACQQhJDQEgAEEAQSgQECEAIAEoAAQhASAAQQE2AhQgACABrTcDAEEADwsgASACIAMQLyIDIAJLDQAgACADNgIYQXIhAyABIARqIgVBf2otAAAiAkEIcQ0AIAJBIHEiBkUEQEFwIQMgBS0AACIFQacBSw0BIAVBB3GtQgEgBUEDdkEKaq2GIgdCA4h+IAd8IQggBEEBaiEECyACQQZ2IQMgAkECdiEFAkAgAkEDcUF/aiICQQJLBEBBACECDAELAkACQAJAIAJBAWsOAgECAAsgASAEai0AACECIARBAWohBAwCCyABIARqLwAAIQIgBEECaiEEDAELIAEgBGooAAAhAiAEQQRqIQQLIAVBAXEhBQJ+AkACQAJAIANBf2oiA0ECTQRAIANBAWsOAgIDAQtCfyAGRQ0DGiABIARqMQAADAMLIAEgBGovAACtQoACfAwCCyABIARqKAAArQwBCyABIARqKQAACyEHIAAgBTYCICAAIAI2AhwgACAHNwMAQQAhAyAAQQA2AhQgACAHIAggBhsiBzcDCCAAIAdCgIAIIAdCgIAIVBs+AhALIAMLWwEBf0G4fyEDIAIQFiICIAFNBH8gACACakF/ai0AACIAQQNxQQJ0QaAeaigC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C0Egak8NAQsgByAHKQNoNwMQIAcgBykDYDcDCCAEIA0gB0EIaiAHQdwAaiAPIA4gESAQEB4hCwwBCyACIARqIQggBCAKEAcgAkERTwRAIARBEGohAgNAIAIgCkEQaiIKEAcgAkEQaiICIAhJDQALCyAIIAlrIQIgByATNgJcIAkgCCAOa0sEQCAJIAggEWtLBEBBbCELDAILIBAgAiAOayICaiIKIANqIBBNBEAgCCAKIAMQDxoMAgsgCCAKQQAgAmsQDyEIIAcgAiADaiIDNgJkIAggAmshCCAOIQILIAlBEE8EQCADIAhqIQMDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALDAELAkAgCUEHTQRAIAggAi0AADoAACAIIAItAAE6AAEgCCACLQACOgACIAggAi0AAzoAAyAIQQRqIAIgCUECdCIDQcAeaigCAGoiAhAXIAIgA0HgHmooAgBrIQIgBygCZCEDDAELIAggAhAMCyADQQlJDQAgAyAIaiEDIAhBCGoiCCACQQhqIgJrQQ9MBEADQCAIIAIQDCACQQhqIQIgCEEIaiIIIANJDQAMAgALAAsDQCAIIAIQByACQRBqIQIgCEEQaiIIIANJDQALCyAHQRhqEAQaIAsgDCALEAMiAhshDCAEIAQgC2ogAhshBCAFQX9qIgUNAAsgDBADDQFBbCEMIAdBGGoQBEECSQ0BQQAhCANAIAhBA0cEQCAAIAhBAnQiAmpBrNABaiACIAdqKAJENgIAIAhBAWohCAwBCwsgBygCXCEIC0G6fyEMIA8gCGsiACANIARrSw0AIAQEfyAEIAggABALIABqBUEACyABayEMCyAHQfAAaiQAIAwLkRcCFn8FfiMAQdABayIHJAAgByAAKALw4QEiCDYCvAEgASACaiESIAggACgCgOIBaiETAkACQCAFRQRAIAEhAwwBCyAAKALE4AEhESAAKALA4AEhFSAAKAK84AEhDyAAQQE2AozhAUEAIQgDQCAIQQNHBEAgByAIQQJ0IgJqIAAgAmpBrNABaigCADYCVCAIQQFqIQgMAQsLIAcgETYCZCAHIA82AmAgByABIA9rNgJoQWwhECAHQShqIAMgBBAGEAMNASAFQQQgBUEESBshFyAHQTxqIAdBKGogACgCABATIAdBxABqIAdBKGogACgCCBATIAdBzABqIAdB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IAdB0AFqJAAgEAslACAAQgA3AgAgAEEAOwEIIABBADoACyAAIAE2AgwgACACOgAKC7QFAQN/IwBBMGsiBCQAIABB/wFqIgVBfWohBgJAIAMvAQIEQCAEQRhqIAEgAhAGIgIQAw0BIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahASOgAAIAMgBEEIaiAEQRhqEBI6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0FIAEgBEEQaiAEQRhqEBI6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBSABIARBCGogBEEYahASOgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEjoAACABIAJqIABrIQIMAwsgAyAEQRBqIARBGGoQEjoAAiADIARBCGogBEEYahASOgADIANBBGohAwwAAAsACyAEQRhqIAEgAhAGIgIQAw0AIARBEGogBEEYaiADEBwgBEEIaiAEQRhqIAMQHCAAIQMDQAJAIARBGGoQBCADIAZPckUEQCADIARBEGogBEEYahAROgAAIAMgBEEIaiAEQRhqEBE6AAEgBEEYahAERQ0BIANBAmohAwsgBUF+aiEFAn8DQEG6fyECIAMiASAFSw0EIAEgBEEQaiAEQRhqEBE6AAAgAUEBaiEDIARBGGoQBEEDRgRAQQIhAiAEQQhqDAILIAMgBUsNBCABIARBCGogBEEYahAROgABIAFBAmohA0EDIQIgBEEYahAEQQNHDQALIARBEGoLIQUgAyAFIARBGGoQEToAACABIAJqIABrIQIMAgsgAyAEQRBqIARBGGoQEToAAiADIARBCGogBEEYahAROgADIANBBGohAwwAAAsACyAEQTBqJAAgAgtpAQF/An8CQAJAIAJBB00NACABKAAAQbfIwuF+Rw0AIAAgASgABDYCmOIBQWIgAEEQaiABIAIQPiIDEAMNAhogAEKBgICAEDcDiOEBIAAgASADaiACIANrECoMAQsgACABIAIQKgtBAAsLrQMBBn8jAEGAAWsiAyQAQWIhCAJAIAJBCUkNACAAQZjQAGogAUEIaiIEIAJBeGogAEGY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wOABCwutAgIEfwF+IwBBQGoiBCQAAkACQCACQQhJDQAgASgAAEFwcUHQ1LTCAUcNACABIAIQIiEBIABCADcDCCAAQQA2AgQgACABNgIADAELIARBGGogASACEC0iAxADBEAgACADEBoMAQsgAwRAIABBuH8QGgwBCyACIAQoAjAiA2shAiABIANqIQMDQAJAIAAgAyACIARBCGoQLCIFEAMEfyAFBSACIAVBA2oiBU8NAUG4fwsQGgwCCyAGQQFqIQYgAiAFayECIAMgBWohAyAEKAIMRQ0ACyAEKAI4BEAgAkEDTQRAIABBuH8QGgwCCyADQQRqIQMLIAQoAighAiAEKQMYIQcgAEEANgIEIAAgAyABazYCACAAIAIgBmytIAcgB0J/URs3AwgLIARBQGskAAslAQF/IwBBEGsiAiQAIAIgACABEFEgAigCACEAIAJBEGokACAAC30BBH8jAEGQBGsiBCQAIARB/wE2AggCQCAEQRBqIARBCGogBEEMaiABIAIQFSIGEAMEQCAGIQUMAQtBVCEFIAQoAgwiB0EGSw0AIAMgBEEQaiAEKAIIIAcQQSIFEAMNACAAIAEgBmogAiAGayADEDwhBQsgBEGQBGokACAFC4cBAgJ/An5BABAWIQMCQANAIAEgA08EQAJAIAAoAABBcHFB0NS0wgFGBEAgACABECIiAhADRQ0BQn4PCyAAIAEQVSIEQn1WDQMgBCAFfCIFIARUIQJCfiEEIAINAyAAIAEQUiICEAMNAwsgASACayEBIAAgAmohAAwBCwtCfiAFIAEbIQQLIAQLPwIBfwF+IwBBMGsiAiQAAn5CfiACQQhqIAAgARAtDQAaQgAgAigCHEEBRg0AGiACKQMICyEDIAJBMGokACADC40BAQJ/IwBBMGsiASQAAkAgAEUNACAAKAKI4gENACABIABB/OEBaigCADYCKCABIAApAvThATcDICAAEDAgACgCqOIBIQIgASABKAIoNgIYIAEgASkDIDcDECACIAFBEGoQGyAAQQA2AqjiASABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALKgECfyMAQRBrIgAkACAAQQA2AgggAEIANwMAIAAQWCEBIABBEGokACABC4cBAQN/IwBBEGsiAiQAAkAgACgCAEUgACgCBEVzDQAgAiAAKAIINgIIIAIgACkCADcDAAJ/IAIoAgAiAQRAIAIoAghBqOMJIAERBQAMAQtBqOMJECgLIgFFDQAgASAAKQIANwL04QEgAUH84QFqIAAoAgg2AgAgARBZIAEhAwsgAkEQaiQAIAMLywEBAn8jAEEgayIBJAAgAEGBgIDAADYCtOIBIABBADYCiOIBIABBADYC7OEBIABCADcDkOIBIABBADYCpOMJIABBADYC3OIBIABCADcCzOIBIABBADYCvOIBIABBADYCxOABIABCADcCnOIBIABBpOIBakIANwIAIABBrOIBakEANgIAIAFCADcCECABQgA3AhggASABKQMYNwMIIAEgASkDEDcDACABKAIIQQh2QQFxIQIgAEEANgLg4gEgACACNgKM4gEgAUEgaiQAC3YBA38jAEEwayIBJAAgAARAIAEgAEHE0AFqIgIoAgA2AiggASAAKQK80AE3AyAgACgCACEDIAEgAigCADYCGCABIAApArzQATcDECADIAFBEGoQGyABIAEoAig2AgggASABKQMgNwMAIAAgARAbCyABQTBqJAALzAEBAX8gACABKAK00AE2ApjiASAAIAEoAgQiAjYCwOABIAAgAjYCvOABIAAgAiABKAIIaiICNgK44AEgACACNgLE4AEgASgCuNABBEAgAEKBgICAEDcDiOEBIAAgAUGk0ABqNgIMIAAgAUGUIGo2AgggACABQZwwajYCBCAAIAFBDGo2AgAgAEGs0AFqIAFBqNABaigCADYCACAAQbDQAWogAUGs0AFqKAIANgIAIABBtNABaiABQbDQAWooAgA2AgAPCyAAQgA3A4jhAQs7ACACRQRAQbp/DwsgBEUEQEFsDwsgAiAEEGAEQCAAIAEgAiADIAQgBRBhDwsgACABIAIgAyAEIAUQZQtGAQF/IwBBEGsiBSQAIAVBCGogBBAOAn8gBS0ACQRAIAAgASACIAMgBBAyDAELIAAgASACIAMgBBA0CyEAIAVBEGokACAACzQAIAAgAyAEIAUQNiIFEAMEQCAFDwsgBSAESQR/IAEgAiADIAVqIAQgBWsgABA1BUG4fwsLRgEBfyMAQRBrIgUkACAFQQhqIAQQDgJ/IAUtAAkEQCAAIAEgAiADIAQQYgwBCyAAIAEgAiADIAQQNQshACAFQRBqJAAgAAtZAQF/QQ8hAiABIABJBEAgAUEE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",uT="display-p3",dT="display-p3-linear";({...w.ColorManagement.spaces[w.SRGBColorSpace]});const sf=new WeakMap;let rf=0,of;class Gn extends w.Loader{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new nT,this.workerSourceURL="",this.workerConfig=null,typeof MSC_TRANSCODER<"u"&&console.warn('THREE.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}async detectSupportAsync(e){return console.warn('KTX2Loader: "detectSupportAsync()" has been deprecated. Use "detectSupport()" and "await renderer.init();" when creating the renderer.'),await e.init(),this.detectSupport(e)}detectSupport(e){return e.isWebGPURenderer===!0?this.workerConfig={astcSupported:e.hasFeature("texture-compression-astc"),astcHDRSupported:!1,etc1Supported:e.hasFeature("texture-compression-etc1"),etc2Supported:e.hasFeature("texture-compression-etc2"),dxtSupported:e.hasFeature("texture-compression-s3tc"),bptcSupported:e.hasFeature("texture-compression-bc"),pvrtcSupported:e.hasFeature("texture-compression-pvrtc")}:(this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),astcHDRSupported:e.extensions.has("WEBGL_compressed_texture_astc")&&e.extensions.get("WEBGL_compressed_texture_astc").getSupportedProfiles().includes("hdr"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},typeof navigator<"u"&&typeof navigator.platform<"u"&&typeof navigator.userAgent<"u"&&navigator.platform.indexOf("Linux")>=0&&navigator.userAgent.indexOf("Firefox")>=0&&this.workerConfig.astcSupported&&this.workerConfig.etc2Supported&&this.workerConfig.bptcSupported&&this.workerConfig.dxtSupported&&(this.workerConfig.astcSupported=!1,this.workerConfig.etc2Supported=!1)),this}init(){if(!this.transcoderPending){const e=new w.FileLoader(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new w.FileLoader(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then(([r,o])=>{const a=Gn.BasisWorker.toString(),l=["/* constants */","let _EngineFormat = "+JSON.stringify(Gn.EngineFormat),"let _EngineType = "+JSON.stringify(Gn.EngineType),"let _TranscoderFormat = "+JSON.stringify(Gn.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(Gn.BasisFormat),"/* basis_transcoder.js */",r,"/* worker */",a.substring(a.indexOf("{")+1,a.lastIndexOf("}"))].join(`
|
|
4941
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),rf>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),rf++}return this.transcoderPending}load(e,t,n,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new w.FileLoader(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(sf.has(e))return sf.get(e).promise.then(t).catch(n);this._createTexture(e).then(i=>t?t(i):null).catch(n)}_createTextureFrom(e,t){const{type:n,error:i,data:{faces:r,width:o,height:a,format:l,type:c,dfdFlags:h}}=e;if(n==="error")return Promise.reject(i);let u;if(t.faceCount===6)u=new w.CompressedCubeTexture(r,l,c);else{const d=r[0].mipmaps;u=t.layerCount>1?new w.CompressedArrayTexture(d,o,a,t.layerCount,l,c):new w.CompressedTexture(d,o,a,l,c)}return u.minFilter=r[0].mipmaps.length===1?w.LinearFilter:w.LinearMipmapLinearFilter,u.magFilter=w.LinearFilter,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=V0(t),u.premultiplyAlpha=!!(h&sT),u}async _createTexture(e,t={}){const n=cT(new Uint8Array(e)),i=n.vkFormat===Zd&&n.dataFormatDescriptor[0].colorModel===167;if(!(n.vkFormat===lT||i&&!this.workerConfig.astcHDRSupported))return pT(n);const o=t,a=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:o},[e])).then(l=>this._createTextureFrom(l.data,n));return sf.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),rf--}}Gn.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Gn.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},Gn.EngineFormat={RGBAFormat:w.RGBAFormat,RGBA_ASTC_4x4_Format:w.RGBA_ASTC_4x4_Format,RGB_BPTC_UNSIGNED_Format:w.RGB_BPTC_UNSIGNED_Format,RGBA_BPTC_Format:w.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:w.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:w.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:w.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:w.RGB_ETC1_Format,RGB_ETC2_Format:w.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:w.RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:w.RGBA_S3TC_DXT1_Format},Gn.EngineType={UnsignedByteType:w.UnsignedByteType,HalfFloatType:w.HalfFloatType,FloatType:w.FloatType},Gn.BasisWorker=function(){let s,e,t;const n=_EngineFormat,i=_EngineType,r=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",function(m){const g=m.data;switch(g.type){case"init":s=g.config,a(g.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:A,buffers:p,width:x,height:y,hasAlpha:v,format:_,type:E,dfdFlags:I}=l(g.buffer);self.postMessage({type:"transcode",id:g.id,data:{faces:A,width:x,height:y,hasAlpha:v,format:_,type:E,dfdFlags:I}},p)}catch(A){console.error(A),self.postMessage({type:"error",id:g.id,error:A.message})}});break}});function a(m){e=new Promise(g=>{t={wasmBinary:m,onRuntimeInitialized:g},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function l(m){const g=new t.KTX2File(new Uint8Array(m));function A(){g.close(),g.delete()}if(!g.isValid())throw A(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let p;if(g.isUASTC())p=o.UASTC;else if(g.isETC1S())p=o.ETC1S;else if(g.isHDR())p=o.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const x=g.getWidth(),y=g.getHeight(),v=g.getLayers()||1,_=g.getLevels(),E=g.getFaces(),I=g.getHasAlpha(),B=g.getDFDFlags(),{transcoderFormat:M,engineFormat:C,engineType:P}=u(p,x,y,I);if(!x||!y||!_)throw A(),new Error("THREE.KTX2Loader: Invalid texture");if(!g.startTranscoding())throw A(),new Error("THREE.KTX2Loader: .startTranscoding failed");const T=[],R=[];for(let S=0;S<E;S++){const F=[];for(let N=0;N<_;N++){const j=[];let q,U;for(let z=0;z<v;z++){const G=g.getImageLevelInfo(N,z,S);S===0&&N===0&&z===0&&(G.origWidth%4!==0||G.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),_>1?(q=G.origWidth,U=G.origHeight):(q=G.width,U=G.height);let re=new Uint8Array(g.getImageTranscodedSizeInBytes(N,z,0,M));const le=g.transcodeImage(re,N,z,S,M,0,-1,-1);if(P===i.HalfFloatType&&(re=new Uint16Array(re.buffer,re.byteOffset,re.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!le)throw A(),new Error("THREE.KTX2Loader: .transcodeImage failed.");j.push(re)}const H=f(j);F.push({data:H,width:q,height:U}),R.push(H.buffer)}T.push({mipmaps:F,width:x,height:y,format:C,type:P})}return A(),{faces:T,buffers:R,width:x,height:y,hasAlpha:I,dfdFlags:B,format:C,type:P}}const c=[{if:"astcSupported",basisFormat:[o.UASTC],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],engineType:[i.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],engineType:[i.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGBA_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],engineType:[i.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],engineType:[i.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],engineType:[i.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],engineType:[i.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[o.UASTC_HDR],transcoderFormat:[r.BC6H],engineFormat:[n.RGB_BPTC_UNSIGNED_Format],engineType:[i.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[n.RGBAFormat,n.RGBAFormat],engineType:[i.UnsignedByteType,i.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[n.RGBAFormat],engineType:[i.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[o.ETC1S]:c.filter(m=>m.basisFormat.includes(o.ETC1S)).sort((m,g)=>m.priorityETC1S-g.priorityETC1S),[o.UASTC]:c.filter(m=>m.basisFormat.includes(o.UASTC)).sort((m,g)=>m.priorityUASTC-g.priorityUASTC),[o.UASTC_HDR]:c.filter(m=>m.basisFormat.includes(o.UASTC_HDR)).sort((m,g)=>m.priorityHDR-g.priorityHDR)};function u(m,g,A,p){const x=h[m];for(let y=0;y<x.length;y++){const v=x[y];if(v.if&&!s[v.if]||!v.basisFormat.includes(m)||p&&v.transcoderFormat.length<2||v.needsPowerOfTwo&&!(d(g)&&d(A)))continue;const _=v.transcoderFormat[p?1:0],E=v.engineFormat[p?1:0],I=v.engineType[0];return{transcoderFormat:_,engineFormat:E,engineType:I}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function d(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let g=0;for(let x=0;x<m.length;x++){const y=m[x];g+=y.byteLength}const A=new Uint8Array(g);let p=0;for(let x=0;x<m.length;x++){const y=m[x];A.set(y,p),p+=y.byteLength}return A}};const fT=new Set([w.RGBAFormat,w.RGBFormat,w.RGFormat,w.RedFormat]),af={[h0]:w.RGBAFormat,[c0]:w.RGFormat,[l0]:w.RedFormat,[a0]:w.RGBAFormat,[o0]:w.RGFormat,[r0]:w.RedFormat,[s0]:w.RGBAFormat,[i0]:w.RGBAFormat,[n0]:w.RGFormat,[t0]:w.RGFormat,[e0]:w.RedFormat,[ZA]:w.RedFormat,[d0]:w.RGBFormat,[u0]:w.RGBFormat,[S0]:w.RGBA_ETC2_EAC_Format,[M0]:w.RGB_ETC2_Format,[E0]:w.R11_EAC_Format,[I0]:w.SIGNED_R11_EAC_Format,[T0]:w.RG11_EAC_Format,[B0]:w.SIGNED_RG11_EAC_Format,[Zd]:w.RGBA_ASTC_4x4_Format,[P0]:w.RGBA_ASTC_4x4_Format,[D0]:w.RGBA_ASTC_4x4_Format,[N0]:w.RGBA_ASTC_6x6_Format,[R0]:w.RGBA_ASTC_6x6_Format,[L0]:w.RGBA_ASTC_6x6_Format,[m0]:w.RGBA_S3TC_DXT1_Format,[g0]:w.RGBA_S3TC_DXT1_Format,[p0]:w.RGB_S3TC_DXT1_Format,[f0]:w.RGB_S3TC_DXT1_Format,[x0]:w.RGBA_S3TC_DXT5_Format,[A0]:w.RGBA_S3TC_DXT5_Format,[b0]:w.SIGNED_RED_RGTC1_Format,[y0]:w.RED_RGTC1_Format,[_0]:w.SIGNED_RED_GREEN_RGTC2_Format,[v0]:w.RED_GREEN_RGTC2_Format,[C0]:w.RGBA_BPTC_Format,[w0]:w.RGBA_BPTC_Format,[U0]:w.RGBA_PVRTC_4BPPV1_Format,[F0]:w.RGBA_PVRTC_4BPPV1_Format,[O0]:w.RGBA_PVRTC_2BPPV1_Format,[k0]:w.RGBA_PVRTC_2BPPV1_Format},yo={[h0]:w.FloatType,[c0]:w.FloatType,[l0]:w.FloatType,[a0]:w.HalfFloatType,[o0]:w.HalfFloatType,[r0]:w.HalfFloatType,[s0]:w.UnsignedByteType,[i0]:w.UnsignedByteType,[n0]:w.UnsignedByteType,[t0]:w.UnsignedByteType,[e0]:w.UnsignedByteType,[ZA]:w.UnsignedByteType,[d0]:w.UnsignedInt5999Type,[u0]:w.UnsignedInt101111Type,[S0]:w.UnsignedByteType,[M0]:w.UnsignedByteType,[E0]:w.UnsignedByteType,[I0]:w.UnsignedByteType,[T0]:w.UnsignedByteType,[B0]:w.UnsignedByteType,[Zd]:w.HalfFloatType,[P0]:w.UnsignedByteType,[D0]:w.UnsignedByteType,[N0]:w.HalfFloatType,[R0]:w.UnsignedByteType,[L0]:w.UnsignedByteType,[m0]:w.UnsignedByteType,[g0]:w.UnsignedByteType,[p0]:w.UnsignedByteType,[f0]:w.UnsignedByteType,[x0]:w.UnsignedByteType,[A0]:w.UnsignedByteType,[b0]:w.UnsignedByteType,[y0]:w.UnsignedByteType,[_0]:w.UnsignedByteType,[v0]:w.UnsignedByteType,[C0]:w.UnsignedByteType,[w0]:w.UnsignedByteType,[U0]:w.UnsignedByteType,[F0]:w.UnsignedByteType,[O0]:w.UnsignedByteType,[k0]:w.UnsignedByteType};async function pT(s){const{vkFormat:e}=s;if(af[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+e);yo[e]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+e);let t;s.supercompressionScheme===$A&&(of||(of=new Promise(async o=>{const a=new hT;await a.init(),o(a)})),t=await of);const n=[];for(let o=0;o<s.levels.length;o++){const a=Math.max(1,s.pixelWidth>>o),l=Math.max(1,s.pixelHeight>>o),c=s.pixelDepth?Math.max(1,s.pixelDepth>>o):0,h=s.levels[o];let u;if(s.supercompressionScheme===iT)u=h.levelData;else if(s.supercompressionScheme===$A)u=t.decode(h.levelData,h.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let d;yo[e]===w.FloatType?d=new Float32Array(u.buffer,u.byteOffset,u.byteLength/Float32Array.BYTES_PER_ELEMENT):yo[e]===w.HalfFloatType?d=new Uint16Array(u.buffer,u.byteOffset,u.byteLength/Uint16Array.BYTES_PER_ELEMENT):yo[e]===w.UnsignedInt5999Type||yo[e]===w.UnsignedInt101111Type?d=new Uint32Array(u.buffer,u.byteOffset,u.byteLength/Uint32Array.BYTES_PER_ELEMENT):d=u,n.push({data:d,width:a,height:l,depth:c})}const i=s.levelCount===0||n.length>1;let r;if(fT.has(af[e]))r=s.pixelDepth===0?new w.DataTexture(n[0].data,s.pixelWidth,s.pixelHeight):new w.Data3DTexture(n[0].data,s.pixelWidth,s.pixelHeight,s.pixelDepth),r.minFilter=i?w.NearestMipmapNearestFilter:w.NearestFilter,r.magFilter=w.NearestFilter,r.generateMipmaps=s.levelCount===0;else{if(s.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new w.CompressedTexture(n,s.pixelWidth,s.pixelHeight),r.minFilter=i?w.LinearMipmapLinearFilter:w.LinearFilter,r.magFilter=w.LinearFilter}return r.mipmaps=n,r.type=yo[e],r.format=af[e],r.colorSpace=V0(s),r.needsUpdate=!0,Promise.resolve(r)}function V0(s){const e=s.dataFormatDescriptor[0];return e.colorPrimaries===oT?e.transferFunction===JA?w.SRGBColorSpace:w.LinearSRGBColorSpace:e.colorPrimaries===aT?e.transferFunction===JA?uT:dT:(e.colorPrimaries===rT||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),w.NoColorSpace)}function gT(s,e,t,n){const a=s.models.find(g=>g.url==t);if(a==null)return;const l=ua(s,t),c=e.circularMeps,h=e.rectMeps?.filter(g=>g.type==="风管"),u=e.rectMeps?.filter(g=>g.type==="桥架"),d=e.ellipseMeps,f=g=>(g.color=g.color.split(",").map(A=>parseInt(A)/255),g.color=new b.Color(g.color[0],g.color[1],g.color[2]),g.position={x:g.startPoint.X*.3048+0,y:g.startPoint.Z*.3048+0,z:-g.startPoint.Y*.3048+0},g.rotation={x:0,y:0,z:0},g),m=(g,A)=>{if(!Array.isArray(A)||A.length===0)return;const p=A.map(y=>f(y)),x=mT(g,l,p,t,s);x!=null&&p.forEach((y,v)=>{y.indexes=[[x,v,0,0]],a.nodesMap.set(Number(y.id),y)})};m("Circle",c),m("Rect",h),m("Ellipse",d),m("Bridge",u)}function mT(s,e,t,n,i){let r;const o={width:1,height:1,length:1,diameter:1,color:new b.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(s){case"Rect":r=Ic("Rect",o);break;case"Bridge":r=Ic("Bridge",o);break;case"Circle":r=Ic("Circle",o);break;case"Ellipse":r=Ic("Ellipse",o);break}if(!r)return null;const a=new b.InstancedMesh(r.geometry,r.material,t.length);a.url=n,e.add(a);const l=kd(i,a),c=[],h=[];for(let d=0;d<t.length;d++){const f=t[d],m=new b.Vector3(f.startPoint.X,0,-f.startPoint.Y),g=new b.Vector3(f.endPoint.X,0,-f.endPoint.Y),A=new b.Vector3(f.startPoint.X,f.startPoint.Z,-f.startPoint.Y),p=new b.Vector3(f.endPoint.X,f.endPoint.Z,-f.endPoint.Y);let x=0,y=0,v=0;if(Math.abs(g.clone().sub(m.clone()).z)<.01&&Math.abs(g.clone().sub(m.clone()).x)<.01){if(x=(f.startPoint.Z>f.endPoint.Z?1:-1)*Math.PI*.5,f.base_x!=null){const q=new b.Vector3(f.base_x.X,0,-f.base_x.Y);y=(q.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*q.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else y=(g.clone().sub(m.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*g.clone().sub(m.clone()).angleTo(new b.Vector3(0,0,1)),x=(f.startPoint.Z>f.endPoint.Z?1:-1)*g.clone().sub(m.clone()).angleTo(p.clone().sub(A.clone()));const _=new b.Matrix4,E=new b.Euler(x,y,v,"YXZ"),I=_.clone().makeRotationFromEuler(E);let B,M;s==="Circle"?(B=f.diameter,M=f.diameter):(B=f.width,M=f.height);const C=_.clone().makeScale(B,M,f.length);_.multiplyMatrices(I,C),_.setPosition(f.position.x,f.position.y,f.position.z),a.setMatrixAt(d,_.clone()),a.setColorAt(d,f.color),a.geometry.computeBoundingBox();const P=a.geometry.boundingBox.min.clone().applyMatrix4(_.clone()),T=a.geometry.boundingBox.max.clone().applyMatrix4(_.clone()),R=new b.Vector3(Math.min(P.x,T.x),Math.min(P.y,T.y),Math.min(P.z,T.z)),S=new b.Vector3(Math.max(P.x,T.x),Math.max(P.y,T.y),Math.max(P.z,T.z)),F=R.clone().add(S.clone()).multiplyScalar(.5),N={name:f.name,min:R,max:S,center:F,dbid:d,materialName:r.material.name};s==="Circle"&&(N.minC={x:f.startPoint.X*.3048,y:f.startPoint.Z*.3048,z:-f.startPoint.Y*.3048},N.maxC={x:f.endPoint.X*.3048,y:f.endPoint.Z*.3048,z:-f.endPoint.Y*.3048}),a.ids||(a.ids=[]),a.matrixs||(a.matrixs=[]),a.matrixs.push(_.clone()),h.push(_.clone()),a.ids.push(Number(f.id)),c.push(N)}a.castShadow=!0,a.ElementInfos=c,a.name="rootModel",a.TypeName="InstancedMesh-Pipe",a.PipeType=s,a.MeshId=null,a.realMaterial=a.material.clone(),a.originalMaterial=a.material.clone(),a.matrixsClone=h,i?.sectionPlane&&(a.material.clippingPlanes=i.sectionPlane,a.originalMaterial.clippingPlanes=i.sectionPlane,a.realMaterial.clippingPlanes=i.sectionPlane);const u={geometry:a.geometry,matrix:a.matrix,position:a.position,rotation:a.rotation};return a.meshs=u,a.instanceMatrix&&a.instanceMatrix.array&&(a.cloneInstanceMatrix=Array.from(a.instanceMatrix.array)),a.instanceMatrix.needsUpdate=!0,l}function Ic(s,e){const t=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Bridge":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(-e.width/2+.01,e.height/2),t.lineTo(-e.width/2+.01,-e.height/2+.01),t.lineTo(e.width/2-.01,-e.height/2+.01),t.lineTo(e.width/2-.01,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Circle":t.moveTo(0,0),t.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const n={depth:e.length*.3048,bevelEnabled:!1};return i(t,n,e.color,e.position,e.rotation);function i(r,o,a,l,c){const h=new b.ExtrudeGeometry(r,o),u=new b.MeshStandardMaterial({color:a,side:b.DoubleSide}),d=new b.Mesh(h,u);return d.position.set(l.x,l.y,l.z),d.rotation._order="YXZ",d.rotation.set(c.x,c.y,c.z),d}}function _i(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,l=new w.BufferGeometry;let c=0;for(let h=0;h<s.length;++h){const u=s[h];let d=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(u.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(u.morphAttributes[f])}if(e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,h),c+=f}}if(t){let h=0;const u=[];for(let d=0;d<s.length;++d){const f=s[d].index;for(let m=0;m<f.count;++m)u.push(f.getX(m)+h);h+=s[d].attributes.position.count}l.setIndex(u)}for(const h in r){const u=Q0(r[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(const h in o){const u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){const f=[];for(let g=0;g<o[h].length;++g)f.push(o[h][g][d]);const m=Q0(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function Q0(s){let e,t,n,i=-1,r=0;for(let c=0;c<s.length;++c){const h=s[c];if(e===void 0&&(e=h.array.constructor),e!==h.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=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.count*t}const o=new e(r),a=new w.BufferAttribute(o,t,n);let l=0;for(let c=0;c<s.length;++c){const h=s[c];if(h.isInterleavedBufferAttribute){const u=l/t;for(let d=0,f=h.count;d<f;d++)for(let m=0;m<t;m++){const g=h.getComponent(d,m);a.setComponent(d+u,m,g)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function j0(s,e){if(e===w.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===w.TriangleFanDrawMode||e===w.TriangleStripDrawMode){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===w.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function AT(s){const e=new Map,t=new Map,n=s.clone();return W0(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,o=e.get(i),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),n}function W0(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)W0(s.children[n],e.children[n],t)}class xT extends w.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new wT(t)}),this.register(function(t){return new CT(t)}),this.register(function(t){return new LT(t)}),this.register(function(t){return new RT(t)}),this.register(function(t){return new kT(t)}),this.register(function(t){return new ST(t)}),this.register(function(t){return new ET(t)}),this.register(function(t){return new IT(t)}),this.register(function(t){return new TT(t)}),this.register(function(t){return new _T(t)}),this.register(function(t){return new BT(t)}),this.register(function(t){return new MT(t)}),this.register(function(t){return new PT(t)}),this.register(function(t){return new DT(t)}),this.register(function(t){return new bT(t)}),this.register(function(t){return new H0(t,tt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new H0(t,tt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new FT(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=w.LoaderUtils.extractUrlBase(e);o=w.LoaderUtils.resolveURL(c,this.path)}else o=w.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new w.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},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 r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===q0){try{o[tt.KHR_BINARY_GLTF]=new OT(e)}catch(u){i&&i(u);return}r=JSON.parse(o[tt.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new KT(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const u=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(u){case tt.KHR_MATERIALS_UNLIT:o[u]=new vT;break;case tt.KHR_DRACO_MESH_COMPRESSION:o[u]=new UT(r,this.dracoLoader);break;case tt.KHR_TEXTURE_TRANSFORM:o[u]=new NT;break;case tt.KHR_MESH_QUANTIZATION:o[u]=new zT;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function yT(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function Ft(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const tt={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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class bT{constructor(e){this.parser=e,this.name=tt.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 r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new w.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],w.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new w.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new w.PointLight(h),c.distance=u;break;case"spot":c=new w.SpotLight(h),c.distance=u,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,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),wi(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class vT{constructor(){this.name=tt.KHR_MATERIALS_UNLIT}getMaterialType(){return w.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new w.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],w.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,w.SRGBColorSpace))}return Promise.all(i)}}class _T{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class wT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new w.Vector2(r,r)}return Promise.all(i)}}class CT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class MT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class ST{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new w.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],w.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,w.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class ET{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class IT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new w.Color().setRGB(r[0],r[1],r[2],w.LinearSRGBColorSpace),Promise.all(i)}}class TT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IOR}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class BT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new w.Color().setRGB(r[0],r[1],r[2],w.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,w.SRGBColorSpace)),Promise.all(i)}}class DT{constructor(e){this.parser=e,this.name=tt.EXT_MATERIALS_BUMP}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class PT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class LT{constructor(e){this.parser=e,this.name=tt.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 r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){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,r.source,o)}}class RT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class kT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class H0{constructor(e,t){this.name=t,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],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,u=i.byteStride,d=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,d,i.mode,i.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(f),h,u,d,i.mode,i.filter),f})})}else return null}}class FT{constructor(e){this.name=tt.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 c of i.primitives)if(c.mode!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],d=c[0].count,f=[];for(const m of u){const g=new w.Matrix4,A=new w.Vector3,p=new w.Quaternion,x=new w.Vector3(1,1,1),y=new w.InstancedMesh(m.geometry,m.material,d);for(let v=0;v<d;v++)l.TRANSLATION&&A.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,v),l.SCALE&&x.fromBufferAttribute(l.SCALE,v),y.setMatrixAt(v,g.compose(A,p,x));for(const v in l)if(v==="_COLOR_0"){const _=l[v];y.instanceColor=new w.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&m.geometry.setAttribute(v,l[v]);w.Object3D.prototype.copy.call(y,m),this.parser.assignFinalMaterial(y),f.push(y)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const q0="glTF",xa=12,X0={JSON:1313821514,BIN:5130562};class OT{constructor(e){this.name=tt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,xa),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!==q0)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-xa,r=new DataView(e,xa);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===X0.JSON){const c=new Uint8Array(e,xa+o,a);this.content=n.decode(c)}else if(l===X0.BIN){const c=xa+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class UT{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=tt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const u=cf[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=cf[h]||h.toLowerCase();if(o[h]!==void 0){const d=n.accessors[e.attributes[h]],f=bo[d.componentType];c[u]=f.name,l[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,d){i.decodeDracoFile(h,function(f){for(const m in f.attributes){const g=f.attributes[m],A=l[m];A!==void 0&&(g.normalized=A)}u(f)},a,c,w.LinearSRGBColorSpace,d)})})}}class NT{constructor(){this.name=tt.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 zT{constructor(){this.name=tt.KHR_MESH_QUANTIZATION}}class Y0 extends w.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,u=(n-t)/h,d=u*u,f=d*u,m=e*c,g=m-c,A=-2*f+3*d,p=f-d,x=1-A,y=p-d+u;for(let v=0;v!==a;v++){const _=o[g+v+a],E=o[g+v+l]*h,I=o[m+v+a],B=o[m+v]*h;r[v]=x*_+y*E+A*I+p*B}return r}}const GT=new w.Quaternion;class VT extends Y0{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return GT.fromArray(r).normalize().toArray(r),r}}const Vn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},bo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},K0={9728:w.NearestFilter,9729:w.LinearFilter,9984:w.NearestMipmapNearestFilter,9985:w.LinearMipmapNearestFilter,9986:w.NearestMipmapLinearFilter,9987:w.LinearMipmapLinearFilter},$0={33071:w.ClampToEdgeWrapping,33648:w.MirroredRepeatWrapping,10497:w.RepeatWrapping},lf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},cf={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"},Ms={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},QT={CUBICSPLINE:void 0,LINEAR:w.InterpolateLinear,STEP:w.InterpolateDiscrete},hf={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function jT(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new w.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:w.FrontSide})),s.DefaultMaterial}function fr(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function wi(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function WT(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const u=e[c];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const u=e[c];if(n){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(d)}if(i){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(d)}if(r){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],d=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function HT(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function qT(s){let e;const t=s.extensions&&s.extensions[tt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+uf(t.attributes):e=s.indices+":"+uf(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+uf(s.targets[n]);return e}function uf(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function df(s){switch(s){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 XT(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const YT=new w.Matrix4;class KT{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new yT,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,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"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,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new w.TextureLoader(this.options.manager):this.textureLoader=new w.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new w.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,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return fr(r,a,i),wi(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,r=t.length;i<r;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())r(h,a.children[c])};return r(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 r=e(t[i]);r&&n.push(r)}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(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.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(r,o){return n.getDependency(e,o)})),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[tt.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(w.LoaderUtils.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=lf[i.type],a=bo[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new w.BufferAttribute(c,o,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],l=lf[i.type],c=bo[i.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let g,A;if(f&&f!==u){const p=Math.floor(d/f),x="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let y=t.cache.get(x);y||(g=new c(a,p*f,i.count*f/h),y=new w.InterleavedBuffer(g,f/h),t.cache.add(x,y)),A=new w.InterleavedBufferAttribute(y,l,d%f/h,m)}else a===null?g=new c(i.count*l):g=new c(a,d,i.count*l),A=new w.BufferAttribute(g,l,m);if(i.sparse!==void 0){const p=lf.SCALAR,x=bo[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,v=i.sparse.values.byteOffset||0,_=new x(o[1],y,i.sparse.count*p),E=new c(o[2],v,i.sparse.count*l);a!==null&&(A=new w.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let I=0,B=_.length;I<B;I++){const M=_[I];if(A.setX(M,E[I*l]),l>=2&&A.setY(M,E[I*l+1]),l>=3&&A.setZ(M,E[I*l+2]),l>=4&&A.setW(M,E[I*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=m}return A})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const d=(r.samplers||{})[o.sampler]||{};return h.magFilter=K0[d.magFilter]||w.LinearFilter,h.minFilter=K0[d.minFilter]||w.LinearMipmapLinearFilter,h.wrapS=$0[d.wrapS]||w.RepeatWrapping,h.wrapT=$0[d.wrapT]||w.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==w.NearestFilter&&h.minFilter!==w.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(d,f){let m=d;t.isImageBitmapLoader===!0&&(m=function(g){const A=new w.Texture(g);A.needsUpdate=!0,d(A)}),t.load(w.LoaderUtils.resolveURL(u,r.path),m,void 0,f)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),wi(u,o),u.userData.mimeType=o.mimeType||XT(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[tt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[tt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[tt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new w.PointsMaterial,w.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 w.LineBasicMaterial,w.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(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 w.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[tt.KHR_MATERIALS_UNLIT]){const u=i[tt.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new w.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],w.LinearSRGBColorSpace),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,w.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=w.DoubleSide);const h=r.alphaMode||hf.OPAQUE;if(h===hf.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===hf.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==w.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new w.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==w.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==w.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new w.Color().setRGB(u[0],u[1],u[2],w.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==w.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,w.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return r.name&&(u.name=r.name),wi(u,r),t.associations.set(u,{materials:e}),r.extensions&&fr(i,u,r),u})}createUniqueName(e){const t=w.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 r(a){return n[tt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return J0(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=qT(c),u=i[h];if(u)o.push(u.promise);else{let d;c.extensions&&c.extensions[tt.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=J0(new w.BufferGeometry,c,t),i[h]={primitive:c,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?jT(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],u=[];for(let f=0,m=h.length;f<m;f++){const g=h[f],A=o[f];let p;const x=c[f];if(A.mode===Vn.TRIANGLES||A.mode===Vn.TRIANGLE_STRIP||A.mode===Vn.TRIANGLE_FAN||A.mode===void 0)p=r.isSkinnedMesh===!0?new w.SkinnedMesh(g,x):new w.Mesh(g,x),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),A.mode===Vn.TRIANGLE_STRIP?p.geometry=j0(p.geometry,w.TriangleStripDrawMode):A.mode===Vn.TRIANGLE_FAN&&(p.geometry=j0(p.geometry,w.TriangleFanDrawMode));else if(A.mode===Vn.LINES)p=new w.LineSegments(g,x);else if(A.mode===Vn.LINE_STRIP)p=new w.Line(g,x);else if(A.mode===Vn.LINE_LOOP)p=new w.LineLoop(g,x);else if(A.mode===Vn.POINTS)p=new w.Points(g,x);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(p.geometry.morphAttributes).length>0&&HT(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),wi(p,r),A.extensions&&fr(i,p,A),t.assignFinalMaterial(p),u.push(p)}for(let f=0,m=u.length;f<m;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return r.extensions&&fr(i,u[0],r),u[0];const d=new w.Group;r.extensions&&fr(i,d,r),t.associations.set(d,{meshes:e});for(let f=0,m=u.length;f<m;f++)d.add(u[f]);return d})}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 w.PerspectiveCamera(w.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new w.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),wi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;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 r=i.pop(),o=i,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const u=o[c];if(u){a.push(u);const d=new w.Matrix4;r!==null&&d.fromArray(r.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new w.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let u=0,d=i.channels.length;u<d;u++){const f=i.channels[u],m=i.samplers[f.sampler],g=f.target,A=g.node,p=i.parameters!==void 0?i.parameters[m.input]:m.input,x=i.parameters!==void 0?i.parameters[m.output]:m.output;g.node!==void 0&&(o.push(this.getDependency("node",A)),a.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",x)),c.push(m),h.push(g))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){const d=u[0],f=u[1],m=u[2],g=u[3],A=u[4],p=[];for(let y=0,v=d.length;y<v;y++){const _=d[y],E=f[y],I=m[y],B=g[y],M=A[y];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const C=n._createAnimationTracks(_,E,I,B,M);if(C)for(let P=0;P<C.length;P++)p.push(C[P])}const x=new w.AnimationClip(r,void 0,p);return wi(x,i),x})}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(r){const o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){const h=c[0],u=c[1],d=c[2];d!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(d,YT)});for(let f=0,m=u.length;f<m;f++)h.add(u[f]);if(h.userData.pivot!==void 0&&u.length>0){const f=h.userData.pivot,m=u[0];h.pivot=new w.Vector3().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],m.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new w.Bone:c.length>1?h=new w.Group:c.length===1?h=c[0]:h=new w.Object3D,h!==c[0])for(let u=0,d=c.length;u<d;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=o),wi(h,r),r.extensions&&fr(n,h,r),r.matrix!==void 0){const u=new w.Matrix4;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const u=i.associations.get(h);i.associations.set(h,{...u})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new w.Group;n.name&&(r.name=i.createUniqueName(n.name)),wi(r,n),n.extensions&&fr(t,r,n);const o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,u=l.length;h<u;h++){const d=l[h];d.parent!==null?r.add(AT(d)):r.add(d)}const c=h=>{const u=new Map;for(const[d,f]of i.associations)(d instanceof w.Material||d instanceof w.Texture)&&u.set(d,f);return h.traverse(d=>{const f=i.associations.get(d);f!=null&&u.set(d,f)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];Ms[r.path]===Ms.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(a);let c;switch(Ms[r.path]){case Ms.weights:c=w.NumberKeyframeTrack;break;case Ms.rotation:c=w.QuaternionKeyframeTrack;break;case Ms.translation:case Ms.scale:c=w.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=w.NumberKeyframeTrack;break;case 2:case 3:default:c=w.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?QT[i.interpolation]:w.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let d=0,f=l.length;d<f;d++){const m=new c(l[d]+"."+Ms[r.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=df(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof w.QuaternionKeyframeTrack?VT:Y0;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $T(s,e,t){const n=e.attributes,i=new w.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new w.Vector3(l[0],l[1],l[2]),new w.Vector3(c[0],c[1],c[2])),a.normalized){const h=df(bo[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new w.Vector3,l=new w.Vector3;for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,m=d.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){const g=df(bo[d.componentType]);l.multiplyScalar(g)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new w.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function J0(s,e,t){const n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){s.setAttribute(a,l)})}for(const o in n){const a=cf[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return w.ColorManagement.workingColorSpace!==w.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${w.ColorManagement.workingColorSpace}" not supported.`),wi(s,e),$T(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?WT(s,e.targets,t):s})}var Ct=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.MeasureClick="measure-click",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(Ct||{});let ya=null,ba=null,Z0=null;const JT=8,ex=24,ZT=24,e2=64,t2=200,n2=10;function tx(){return new URL("draco/",document.baseURI).toString()}function nx(){return new URL("basis/",document.baseURI).toString()}function i2(){return ya==null&&(ya=new ZI,ya.setDecoderPath(tx()),ya.preload()),ya}function s2(s){return ba==null&&(ba=new Gn,ba.setTranscoderPath(nx())),Z0!==s&&(ba.detectSupport(s),Z0=s),ba}function r2(s){const e=new xT;return e.setDRACOLoader(i2()),e.setMeshoptDecoder(tT),s?.renderer?.capabilities!=null&&typeof s.renderer.getContext=="function"&&e.setKTX2Loader(s2(s.renderer)),e}function ix(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function o2(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function a2(s){return s?.engineStatus?.isFree===!1||o2()}async function $i(s,e,t){if(e)return t;const n=performance.now();return a2(s)||n-t>=JT?(await ix(),performance.now()):t}function l2(s,e){return new Promise((t,n)=>{Ec(s,i=>{if(i==null){n(new Error(`[loadLightModel] empty zip json: ${s}`));return}t(i)},()=>{n(new Error(`[loadLightModel] failed to load zip json: ${s}`))},e)})}function c2(s,e){return Et({method:"get",responseType:"arraybuffer",url:s}).then(async t=>{let n=t.data;return xo.isEncrypted(t.data)&&(n=await xo.decryptPzEnc(t.data,e)),zd.loadAsync(n)})}function sx(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function rx(s,e){const t=new Set(e.map(n=>sx(n)));for(const n of Object.keys(s.files))if(t.has(sx(n)))return s.files[n];return null}function ox(s,e){const t=rx(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function h2(s){return s.charCodeAt(0)===65279?s.slice(1):s}function ff(s){return JSON.parse(h2(s))}function u2(s,e){const t=rx(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function d2(s,e){return new Promise((t,n)=>{r2(s).parse(e,document.baseURI,t,n)})}function Tc(s,e){const t=s.models.find(n=>n.url==e);return t!=null&&t.group==null&&(t.group=sc(s,e)??ua(s,e)),t}function ax(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function f2(s){return ax(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function lx(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(n=>f2(n))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(Ct.LoadingCompleted,{}))}function cx(s){return s===!0||s==="loading"}function hx(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function p2(s,e,t){let n=performance.now();for(let i=0;i<e.length;i++){const r=e[i];r?.geometry!=null&&r.geometry.computeVertexNormals,(i+1)%ZT===0&&(n=await $i(s,t,n))}}async function g2(s,e,t){const n=[],i=[{node:e.octreeBox,visited:!1}];let r=performance.now();for(;i.length>0;){const o=i.pop();if(o==null||o.node==null||o.node.status===!0)continue;const a=o.node;if(o.visited){const c=Array.isArray(a.children)?a.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(a.status=!0),r=await $i(s,t,r);continue}i.push({node:a,visited:!0}),Array.isArray(a.elements)&&n.push(...a.elements);const l=Array.isArray(a.children)?a.children:[];for(let c=l.length-1;c>=0;c--)i.push({node:l[c],visited:!1});r=await $i(s,t,r)}return n}async function m2(s,e,t,n){const i=Tc(s,e.url);if(i?.nodesMap==null)return[];const r=await g2(s,t,n);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const o=[];let a=performance.now(),l=0;for(const c of r){if(!i.nodesMap.has(c))continue;const h=i.nodesMap.get(c),u=Array.isArray(h?.infos)?h.infos:[];for(const d of u){const f=t.glbs?.[d.glb]?.[d.mesh];if(f?.geometry==null||f.material==null)continue;const m=new b.Matrix4;m.elements=d.matrix;const g=f.geometry.clone();g.applyMatrix4(m),g.computeBoundingBox();const A=new b.Mesh(g,f.material);d.box=g.boundingBox?.clone(),d.mesh=A,A.name=Number(c),A.glb=d.glb,A.url=e.url,g.attributes.position!=null&&o.push(A),l++,l%ex===0&&(a=await $i(s,n,a))}}return o}function A2(s,e,t,n,i){const r=_i(n.map(l=>l.geometry),!1),o=new b.Mesh(r,i);return o.castShadow=!0,o.receiveShadow=!0,ua(e,s).add(o),kd(e,o),o.url=s,o.glb=t,o.materialClone=i,o.geometrys=n.map(l=>l.geometry),o.geometry.computeVertexNormals(),o}function x2(s,e,t,n){return(sc(s,e)?.children??s.scene.children).find(o=>{const a=o;return o instanceof b.Mesh&&a.url==e&&a.glb==t&&a.materialClone===n})}function y2(s,e){const t=Array.isArray(s.geometrys)?s.geometrys:[],n=e.map(o=>o.geometry),i=[...t,...n],r=_i(i,!1);s.geometry!=null&&s.geometry.dispose(),s.geometry=r,s.geometrys=i,s.castShadow=!0,s.receiveShadow=!0}async function b2(s,e,t,n){const i=new Map;for(const a of t){const l=i.get(a.glb)??[];l.push(a),i.set(a.glb,l)}const r=Tc(e,s);let o=performance.now();for(const[a,l]of i.entries()){const c=n?l.length:t2;for(let h=0;h<l.length;h+=c){const u=l.slice(h,h+c);if(u.length===0)continue;const d=B2(u[0].material,e);let f=x2(e,s,a,d),m=0,g=0;f=null,f!=null?(m=Array.isArray(f.geometrys)?f.geometrys.length:0,g=hx(f.geometry),y2(f,u)):f=A2(s,e,a,u,d);const A=new Map;let p=g;u.forEach((x,y)=>{const v=Number(x.name),_=hx(x.geometry),E=A.get(v)??[];if(E.push([p,p+_]),A.set(v,E),r?.nodesMap?.has(v)){const I=r.nodesMap.get(v);I.indexes==null&&(I.indexes=[]),I.indexes.push([f.index,m+y,p,p+_])}p+=_}),f.indexes==null&&(f.indexes=new Map),A.forEach((x,y)=>{const v=f.indexes.get(y)??[];v.push(...x),f.indexes.set(y,v)}),o=await $i(e,n,o)}}}async function v2(s,e,t,n,i,r){if(n==null||i==null||i.length===0)return;const o=Tc(t,s);if(o==null)return;const a=new b.InstancedMesh(n.geometry,n.material,i.length);ua(t,s).add(a);const c=kd(t,a),h=new Float32Array(i.length*3);for(let f=0;f<i.length;f++)h[f*3]=1,h[f*3+1]=1,h[f*3+2]=1;a.instanceColor=new b.InstancedBufferAttribute(h,3);let u=performance.now();const d=[];for(let f=0;f<i.length;f++){const m=i[f],g=new b.Matrix4;if(g.elements=m.matrix,a.setMatrixAt(f,g),a.matrixs||(a.matrixs=[]),a.matrixs.push(g.clone()),d.push(g.clone()),o.nodesMap.has(m.id)){const A=o.nodesMap.get(m.id);A.indexes==null&&(A.indexes=[]),A.indexes.push([c,f,0,0])}else o.nodesMap.set(m.id,{instance:!0,info:m,indexes:[[c,f,0,0]]});(f+1)%e2===0&&(u=await $i(t,r,u))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.materialClone=n.material,a.url=s,a.glb=n.glb,a.ids=i.map(f=>f.id),a.matrixsClone=d,a.meshIndex=e}async function _2(s,e,t,n){const i=e.instanceNodes;if(i==null)return;let r=performance.now();for(const o in i)if(i[o].isLoaded!==!0){i[o].isLoaded=!0;for(const a of i[o]){const l=e.glbs?.[o]?.[a.mesh];l!=null&&await v2(s.url,a.mesh,t,l,a.children,n)}r=await $i(t,n,r)}}async function w2(s,e,t,n){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const i=await m2(s,e,t,n);await b2(e.url,s,i,n),await _2(e,t,s,n),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function C2(s,e,t,n){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const i=await c2(e.url+t.path,e.key),r=await ox(i,["/nodes.json","nodes.json"]);if(r==null)return;const o=ff(r),a=Tc(s,e.url);if(a==null)return;a.nodesMap==null&&(a.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(o)){const u=o[h];for(let f=0;f<u.length;f++){const m=u[f];if(m.glb=h,a.nodesMap.has(m.id)===!1)a.nodesMap.set(m.id,{infos:[m]});else{if(!a.nodesMap.get(m.id).infos)continue;a.nodesMap.get(m.id).infos.push(m)}(f+1)%ex===0&&(l=await $i(s,n,l))}const d=await u2(i,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(d==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(i.files)});continue}try{const f=await d2(s,d);t.glbs[h]=f.scene.children,t.glbs[h].forEach(m=>{m.matrixWorld}),await p2(s,t.glbs[h],n)}catch(f){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:tx(),basisTranscoderPath:nx(),error:f})}l=await $i(s,n,l)}const c=await ox(i,["/instances.json","instances.json"]);t.instanceNodes=c!=null?ff(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function M2(s,e,t){if(t.boundingBox||(t.boundingBox=new b.Box3,t.boundingBox.min=new b.Vector3(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new b.Vector3(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const n=t.boundingBox,i=n.min,r=n.max,o=i.clone().add(r.clone()).multiplyScalar(.5),a=i.distanceTo(r),l=new b.Vector3,c=new b.Vector3,h=new b.Vector3,u=new b.Vector3;if(e.getWorldDirection(h),e.getWorldPosition(u),e.matrixWorld.extractBasis(l,c,new b.Vector3),e instanceof b.OrthographicCamera){const p=Math.max((e.top-e.bottom)/e.zoom,1e-6),x=s?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,y=b.MathUtils.degToRad(x*.5),v=y>0?p/(2*Math.tan(y)):p;u.copy(o).add(h.clone().multiplyScalar(-v))}if(u.distanceTo(o)<=a*.5)return 1e3;const d=o.clone().sub(u).dot(h);if(d<=0)return 0;const f=u.clone().add(h.multiplyScalar(Math.max(d,a))),m=f.clone().add(l.setLength(t.maxSize)),g=new vt(e,s.renderer,s.scene).worldToScreen(f),A=new vt(e,s.renderer,s.scene).worldToScreen(m);return g.distanceTo(A)}async function S2(s,e,t,n){t.maxSize<1e6&&t.path!="/lod0"&&(!(M2(s,s.camera,t)>=n2)||t.status===!0)||(await C2(s,e,t,n),t.loadSuccess===!0&&await w2(s,e,t,n))}function E2(s,e,t){if(cx(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await ix(),gT(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,lx(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)})}function I2(s,e,t,n){const i=ua(s,e);s.models||(s.models=[]),window.startTime=Date.now();let r="WDDsBNtzVz6aSh/bCFh3CmjjANEDRryoXF1XCJvJjeE=";l2(e+"/info",r).then(o=>{const a=ff(o);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1},key:r}),s.models.push({url:e,group:i,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,name:a.baseInfo.name,boundingBox:{min:new b.Vector3(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new b.Vector3(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),s.models.length==n&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{ux(s,null,!1)},100))}).catch(o=>{console.error("[loadLightModel] failed to load model info",{url:e,error:o})})}async function ux(s,e,t=!1){const n=s.engineStatus.models.filter(i=>e==null||i.url==e);for(const i of n)if(ax(i),!(i.status!=="loading"||i.type!=="light")&&(E2(s,i,t),!cx(i.loadStatus.normal))){i.loadStatus.normal="loading";try{await T2(s,i,t)}finally{const r=Array.isArray(i.info?.lods)&&i.info.lods.every(o=>o.status===!0);i.loadStatus.normal=r,r&&(i.status="loaded"),lx(s)}}}async function T2(s,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const n of e.info.lods)await S2(s,e,n,t)}function B2(s,e){return s.map!=null&&(s.map.colorSpace=b.SRGBColorSpace,s.map.needsUpdate=!0),s.side=b.DoubleSide,s.shadowSide=b.DoubleSide,s.clipShadows=!0,e?.sectionPlane&&(s.clippingPlanes=e.sectionPlane),s}class D2{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&I2(this.engine,i,t,e.length);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var Ss=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.ViewportResize="viewport-resize",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(Ss||{});class P2{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(Ss.EngineFree,e=>{this.updateFree(!0),ux(this.engine,e,!1),this.engine?.octreeBox?.requestBvhBuild?.()}),this.engine.events.on(Ss.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let L2=class{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),r=i.indexOf(t);r!==-1?(i.splice(r,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((r,o)=>{try{r(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}};const Bc=1,pf=20,R2=5e3,k2=1.25,dx=500,F2=5e4;class O2{engine;lastShadowHalfSize=0;lastShadowFar=0;constructor(e){this.engine=e}init(){const e=new b.DirectionalLight(16777215,1);e.position.set(1,2,1),e.castShadow=!0,e.shadow.mapSize.width=1024,e.shadow.mapSize.height=1024,e.shadow.camera.near=.1,e.shadow.camera.far=100,e.shadow.bias=-5e-5,e.shadow.normalBias=.05;const t=pf;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,e.shadow.intensity=Bc;const n=new b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n,this.engine.scene.dirLightShodow=e;const i=new b.AmbientLight(16777215,2);this.engine.scene.add(i)}updateShadowCameraRange(e){const t=this.getShadowDirectionalLight();if(!t||!(t.shadow.camera instanceof b.OrthographicCamera))return;const n=t.shadow.camera,i=this.getSceneBoundingBox();let r=0,o=0,a=null;if(i){const f=i.getSize(new b.Vector3);r=Math.max(f.x,f.y,f.z)*.5,o=Math.max(f.length(),1),a=i.getCenter(new b.Vector3)}const l=this.getCameraHalfExtent(e,a),c=b.MathUtils.clamp(Math.max(l*k2,r*.6,pf),pf,R2),h=b.MathUtils.clamp(Math.max(c*8,o*2,dx),dx,F2),u=Math.abs(c-this.lastShadowHalfSize)>.5,d=Math.abs(h-this.lastShadowFar)>1;!u&&!d||(n.left=-c,n.right=c,n.top=c,n.bottom=-c,n.near=.1,n.far=h,n.updateProjectionMatrix(),t.shadow.needsUpdate=!0,this.lastShadowHalfSize=c,this.lastShadowFar=h)}getShadowDirectionalLight(){const e=this.engine.scene;if(!e)return null;const t=e.dirLight;return t instanceof b.DirectionalLight&&t.castShadow?t:e.children.find(n=>n instanceof b.DirectionalLight&&n.castShadow)??null}getSceneBoundingBox(){const e=this.engine.octreeBox?.getBoundingBox?.();if(!e?.min||!e?.max)return null;const t=e.min,n=e.max;if(![t.x,t.y,t.z,n.x,n.y,n.z].every(Number.isFinite))return null;const r=new b.Box3(new b.Vector3(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z)),new b.Vector3(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))),o=r.getSize(new b.Vector3);return o.lengthSq()<=1e-8||o.length()>1e7?null:r}getCameraHalfExtent(e,t){if(!e)return 0;if(e instanceof b.OrthographicCamera){const n=Math.max(e.zoom,1e-6),i=Math.max((e.top-e.bottom)/(2*n),1),r=Math.max((e.right-e.left)/(2*n),1);return Math.max(r,i)}if(e instanceof b.PerspectiveCamera){const n=this.resolveCameraTarget(e,t),i=Math.max(e.position.distanceTo(n),1),r=b.MathUtils.degToRad(e.getEffectiveFOV()*.5),o=Math.max(Math.tan(r)*i,1),a=o*Math.max(e.aspect,1e-6);return Math.max(a,o)}return 0}resolveCameraTarget(e,t){const n=this.engine.controls?.target;if(n instanceof b.Vector3)return n.clone();if(t)return t.clone();const i=new b.Vector3;return e.getWorldDirection(i),e.position.clone().add(i.multiplyScalar(10))}}class U2{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new b.Vector2;selectionEnd=new b.Vector2;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new b.Matrix4;tempScale=new b.Vector3;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}dispose(){this.clearHoverTimeout(),this.cancelBoxSelection(),this.clearHoverFeedback(),this.behavior?.disActive?.(),this.selectionBox?.remove(),this.selectionBox=null,this.isBoxSelecting=!1,this.suppressClickOnce=!1,this.behavior=null}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handelKeyEscDown(){this.engine.modelToolModule.unhighlightAllModels()}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const n=this.getCatchMeshs(e,!0);n!=null&&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}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}e.catch==null&&this.engine.hoverHighLight.clearHighlight()}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),n=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(n):this.applyBoxSelection(n),this.suppressClickForCurrentTick())}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const c=e.catch.object,h=e.catch.object.id,d=this.engine.models.find(g=>g.url==c.url)?.nodesMap?.get(h),f=new Map;d?.indexes.forEach(g=>{this.getSceneModel(g[0])instanceof b.InstancedMesh&&(f.has(g[0])||f.set(g[0],[]),f.get(g[0])?.push(g[1]))});const m=[];return f.forEach((g,A)=>{const p=this.getSceneModel(A);g.forEach(x=>{const y=p.geometry.clone();y.applyMatrix4(p.matrixs[x]),m.push(new b.Mesh(y,p.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),m)}const i=e.catch.object,r=i.name,l=this.engine.models.find(c=>c.url===i.url)?.nodesMap?.get(r)?.infos?.map(c=>c.mesh)??[];return this.hoverOldId==r?[]:(this.hoverOldId=r,t||this.engine.hoverHighLight.clearHighlight(),l)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown){if(e.catch!=null){const i=e.catch.object;this.applyBoxDeselection([{url:i.url,ids:[i.name]}])}return}if(e.catch!=null){const n=e.catch,i=n.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const o=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(o)}this.engine.controlModule.orbitControls.origin.set(n.point.x,n.point.y,n.point.z),this.engine.modelToolModule.highlightModel([{url:i.url,ids:[i.name]}]),this.engine.events.trigger(Ct.Click,[{url:i.url,ids:[i.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:i.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.controlModule?.orbitControls.enabled&&this.engine.viewCube.CameraGoHome(500);return}const t=e.catch;if(this.engine.controlModule?.firstPersonControls?.enabled===!0&&t.point instanceof b.Vector3){const l=this.engine.camera,c=l.position.clone();let h=t.point.clone();const u=500,d=performance.now();let f=h.clone().sub(c).normalize();h=h.clone().sub(f.clone().setLength(.5));const m=()=>{const g=performance.now()-d,A=Math.min(g/u,1),p=A<.5?2*A*A:1-Math.pow(-2*A+2,2)/2;l.position.lerpVectors(c,h,p),A<1?requestAnimationFrame(m):this.engine.controlModule.firstPersonControls.setCameraHeight(l.position.y)};requestAnimationFrame(m);return}const n=t.object,r=this.engine.models.find(l=>l.url===n.url)?.nodesMap?.get(n.name);if(!r)return;if(t.object.isInstance){const l=t.matrix,c=[];r.indexes.forEach(u=>{const d=this.getSceneModel(u[0]);d?.geometry?.boundingSphere||d?.geometry?.computeBoundingSphere?.();const f=d?.geometry?.boundingSphere;if(!f)return;const m=new b.Box3,g=f.center.clone().applyMatrix4(l),A=f.radius,p=new b.Vector3().setFromMatrixScale(l),x=A*Math.max(p.x,p.y,p.z)*.15;m.min.set(g.x-x,g.y-x,g.z-x),m.max.set(g.x+x,g.y+x,g.z+x),c.push(m)});const h=this.getMergedBox(c);h!=null&&this.engine.viewCube.zoomToModel(h);return}const o=r.infos.map(l=>l.box).filter(l=>l instanceof b.Box3),a=this.getMergedBox(o);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(iA(this.engine),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}suppressClickForCurrentTick(){this.suppressClickOnce=!0,setTimeout(()=>{this.suppressClickOnce=!1},0)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),n=new Map,i=this.getIgnoredSelectionIdsByUrl();return this.engine.models?.forEach(r=>{if(!r?.url||!r?.nodesMap)return;const o=i.get(r.url);r.nodesMap.forEach((a,l)=>{if(o?.has(l))return;const c=this.getNodeWorldBox(a);if(!this.isBoxVisibleUnderClipping(c))return;const h=this.projectBoxToScreenRect(c);h==null||!(t?this.containsRect(e,h):this.intersectsRect(e,h))||(n.has(r.url)||n.set(r.url,new Set),n.get(r.url)?.add(l))})}),Array.from(n.entries()).map(([r,o])=>({url:r,ids:Array.from(o)}))}getIgnoredSelectionIdsByUrl(){const e=new Map,t=n=>{n?.forEach(i=>{e.has(i.url)||e.set(i.url,new Set),i.ids.forEach(r=>e.get(i.url)?.add(r))})};return t(this.engine.engineStatus.hideModels),t(this.engine.engineStatus.translucentModels),e}isBoxVisibleUnderClipping(e){if(e==null||e.isEmpty())return!1;const t=this.getActiveClippingPlanes();if(t.length===0)return!0;const n=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)];return t.every(i=>n.some(r=>i.distanceToPoint(r)>=-1e-4))}getActiveClippingPlanes(){const e=this.engine.clipping,t=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[],n=e?.currentClippingMode;if(n==="box")return t.slice(0,6).filter(i=>i instanceof b.Plane);if(n==="x"||n==="y"||n==="z"||n==="face"){const i=t[6];return i instanceof b.Plane?[i]:[]}return[]}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(Ct.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(Ct.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(n=>n?.box).filter(n=>n instanceof b.Box3);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(n=>{const i=this.getSceneModel(n[0]),r=this.getInstanceWorldBox(i,n[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof b.InstancedMesh))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const n=e.geometry.boundingBox;if(!n)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:n.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)];let n=1/0,i=1/0,r=-1/0,o=-1/0;return t.forEach(a=>{const l=new vt(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(a);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(n=Math.min(n,l.x),i=Math.min(i,l.y),r=Math.max(r,l.x),o=Math.max(o,l.y))}),!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(o)?null:{left:n,top:i,right:r,bottom:o}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new b.Box3().makeEmpty();return e.forEach(n=>t.union(n)),t.isEmpty()?null:t}getSceneModel(e){return Fd(this.engine,e)}}class N2{engine;highlightMaterial;translucentMaterial;customModelColorRecords;constructor(e){this.engine=e,this.customModelColorRecords=new Map,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!0,transparent:!0,opacity:.3,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane,this.engine.events?.on?.(Ss.EngineFree,()=>{this.restoreSplitModelsOnIdle()})}split_merge_model(e){if(e.isSplit||e instanceof b.InstancedMesh)return;e.geometry!=null&&(e.__mergedGeometryBackup=e.geometry);let t=e.material,n=_i(e.geometrys,!0);n.computeVertexNormals(),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){if(e==null||e instanceof b.InstancedMesh||e.isSplit!==!0||this.shouldKeepSplitState(e))return;const t=e.__mergedGeometryBackup;if(t!=null){const r=e.geometry;e.geometry=t,e.material=e.material[0],e.needsUpdate=!0,e.isSplit=!1,r&&r!==t&&typeof r.dispose=="function"&&r.dispose(),console.log("merge");return}if(!Array.isArray(e.geometrys)||e.geometrys.length===0)return;const n=e.geometry,i=_i(e.geometrys,!1);i!=null&&(i.computeVertexNormals(),e.geometry=i,e.material=e.material[0],e.needsUpdate=!0,e.isSplit=!1,n&&n!==i&&typeof n.dispose=="function"&&n.dispose(),console.log("merge"))}shouldKeepSplitState(e){const t=e?.geometry?.groups;return!Array.isArray(t)||t.length===0?!1:t.some(n=>(typeof n.materialIndex=="number"?n.materialIndex:0)!==0||n.visible===!1)}areAllGroupsHidden(e){const t=e?.geometry?.groups;return!Array.isArray(t)||t.length===0?!1:t.every(n=>{const i=typeof n.materialIndex=="number"?n.materialIndex:0;return n.visible===!1||i===-1})}getEngineModelByUrl(e){return this.engine.models.find(t=>t.url==e)}appendUniqueIds(e,t){if(!Array.isArray(e)||!Array.isArray(t)||t.length===0)return e;const n=new Set(e);return t.forEach(i=>{n.has(i)||(e.push(i),n.add(i))}),e}restoreSplitModelsOnIdle(){if(!this.engine?.scene)return;rc(this.engine,t=>t instanceof b.Mesh&&!(t instanceof b.InstancedMesh)).forEach(t=>{t instanceof b.Mesh&&(t.isSplit===!0&&(t.visible=!this.areAllGroupsHidden(t)),t.isSplit===!0&&this.un_split_merge_model(t))})}getSceneModel(e){return Fd(this.engine,e)}updateMaterial(){let e=0;this.engine.engineStatus.highlightModels?.forEach(t=>{e=e+t.ids.length}),e>20?(this.highlightMaterial.depthTest=!0,this.highlightMaterial.transparent=!1):(this.highlightMaterial.depthTest=!1,this.highlightMaterial.transparent=!0)}highlightModel(e){e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(o=>{let a=n.nodesMap.get(o);a!=null&&a.indexes!=null&&a.indexes.forEach(l=>{const c=this.getSceneModel(l[0]);c instanceof b.InstancedMesh?i.has(l[0])?i.get(l[0])?.push(l[1]):i.set(l[0],[l[1]]):(this.split_merge_model(c),c.geometry.groups[l[1]].materialIndex=1)})}),z2(i,this.engine);let r=this.engine.engineStatus.highlightModels.find(o=>o.url==t.url);r!=null?r.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)}),this.updateMaterial()}unhighlightModel(e){e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(r=>{let o=n.nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):l.geometry.groups.length!=0&&(l.geometry.groups[a[1]].materialIndex=0)})}),fx(i,this.engine,"highlightModel")}),this.updateMaterial()}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[]),this.updateMaterial()}hideModel(e){e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(o=>{let a=n.nodesMap.get(o);this.engine.modelEdge.hideModelEdge(t.url,o),a!=null&&a.indexes!=null&&a.indexes.forEach(l=>{const c=this.getSceneModel(l[0]);c instanceof b.InstancedMesh?i.has(l[0])?i.get(l[0])?.push(l[1]):i.set(l[0],[l[1]]):(this.split_merge_model(c),c.geometry.groups[l[1]].materialIndex=-1,c.geometry.groups[l[1]].visible=!1)})}),i.size>0&&V2(i,this.engine);let r=this.engine.engineStatus.hideModels.find(o=>o.url==t.url);r!=null?this.appendUniqueIds(r.ids,t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:[...new Set(t.ids)]}),this.engine.engineStatus.highlightModels=[]})}showModel(e,t=!1){e.forEach(n=>{const i=this.getEngineModelByUrl(n.url);if(i==null)return;let r=new Map;if(n.ids.forEach(a=>{let l=i.nodesMap.get(a);this.engine.modelEdge.showModelEdge(n.url,a),l!=null&&l.indexes!=null&&l.indexes.forEach(c=>{const h=this.getSceneModel(c[0]);h instanceof b.InstancedMesh?r.has(c[0])?r.get(c[0])?.push(c[1]):r.set(c[0],[c[1]]):(h.visible=!0,h.geometry.groups[c[1]].materialIndex=0,h.geometry.groups[c[1]].visible=!0)})}),r.size>0&&px(r,this.engine),t)return;let o=this.engine.engineStatus.hideModels.find(a=>a.url==n.url);o&&(n.ids.forEach(a=>{const l=o.ids.indexOf(a);l!==-1&&o.ids.splice(l,1)}),o.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(a=>a!==o)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t=16777215,n=1){const i=this.normalizeOpacity(n);if(e instanceof b.Mesh&&!(e instanceof b.InstancedMesh)){e.material?.color!=null&&(e.material.color.set(t),this.clearMaterialTextures(e.material),e.material.transparent=i<1,e.material.opacity=i,e.material.needsUpdate=!0);return}if(!Array.isArray(e))return;const r=new b.Color(t);e.forEach(o=>{const a=this.getEngineModelByUrl(o.url);a==null||!Array.isArray(o.ids)||o.ids.forEach(l=>{let c=a.nodesMap.get(l);c==null||c.indexes==null||c.indexes.forEach(h=>{const u=this.getSceneModel(h[0]);u instanceof b.InstancedMesh?this.setInstanceModelColor(o.url,l,u,h[0],h[1],r,i):u instanceof b.Mesh&&this.setSimpleModelColor(o.url,l,u,h[1],r,i)})})})}restoreModelColor(e){Array.isArray(e)&&e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);n==null||!Array.isArray(t.ids)||t.ids.forEach(i=>{let r=n.nodesMap.get(i);r==null||r.indexes==null||r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof b.InstancedMesh?this.restoreInstanceModelColor(t.url,i,a,o[0],o[1]):a instanceof b.Mesh&&this.restoreSimpleModelColor(t.url,i,a,o[0],o[1])})})})}setAllModelsColor(e,t=1){const n=[];this.engine.models.forEach(i=>{let r={url:i.url,ids:[]};for(let o of i.nodesMap)r.ids.push(o[0]);n.push(r)}),this.setModelColor(n,e,t)}restoreAllModelsColor(){Array.from(this.customModelColorRecords.keys()).forEach(e=>{const t=this.customModelColorRecords.get(e);if(t==null)return;const n=this.getSceneModel(t.meshIndex);t.type==="instance"&&n instanceof b.InstancedMesh?this.restoreInstanceColorRecord(n,t):t.type==="mesh"&&n instanceof b.Mesh&&this.restoreSimpleColorRecord(n,t),this.customModelColorRecords.delete(e)})}setSimpleModelColor(e,t,n,i,r,o){this.split_merge_model(n);const a=n.geometry?.groups?.[i];if(a==null)return;const l=this.getCustomColorRecordKey(e,t,n.index,i);this.customModelColorRecords.has(l)||this.customModelColorRecords.set(l,{type:"mesh",meshIndex:n.index,groupIndex:i,materialIndex:a.materialIndex??0}),a.materialIndex=this.getCustomColorMaterialIndex(n,r,o)}restoreSimpleModelColor(e,t,n,i,r){const o=this.getCustomColorRecordKey(e,t,i,r),a=this.customModelColorRecords.get(o);a!=null&&(this.restoreSimpleColorRecord(n,a),this.customModelColorRecords.delete(o))}restoreSimpleColorRecord(e,t){const n=e.geometry?.groups?.[t.groupIndex];n!=null&&(n.materialIndex=t.materialIndex??0,this.un_split_merge_model(e))}setInstanceModelColor(e,t,n,i,r,o,a){const l=this.getCustomColorRecordKey(e,t,i,r);if(this.customModelColorRecords.has(l))this.removeCustomInstanceClone(this.customModelColorRecords.get(l));else{const h=new b.Matrix4;n.getMatrixAt(r,h),this.customModelColorRecords.set(l,{type:"instance",meshIndex:i,instanceIndex:r,matrix:h.clone(),cloneModel:null})}const c=this.customModelColorRecords.get(l);this.hideOriginalInstance(n,r),c.cloneModel=this.createCustomInstanceClone(n,i,r,c.matrix,o,a),this.engine.scene.add(c.cloneModel)}restoreInstanceModelColor(e,t,n,i,r){const o=this.getCustomColorRecordKey(e,t,i,r),a=this.customModelColorRecords.get(o);a!=null&&(this.restoreInstanceColorRecord(n,a),this.customModelColorRecords.delete(o))}restoreInstanceColorRecord(e,t){this.removeCustomInstanceClone(t),t.matrix!=null&&(e.setMatrixAt(t.instanceIndex,t.matrix),e.instanceMatrix.needsUpdate=!0)}getCustomColorRecordKey(e,t,n,i){return`${e}|${t}|${n}|${i}`}getCustomColorMaterialIndex(e,t,n){const i=`${t.getHexString()}|${n}`;e.__customColorMaterialIndexes instanceof Map||(e.__customColorMaterialIndexes=new Map);const r=e.__customColorMaterialIndexes.get(i);if(typeof r=="number"&&Array.isArray(e.material)&&e.material[r]!=null)return r;typeof r=="number"&&e.__customColorMaterialIndexes.delete(i),Array.isArray(e.material)||(e.material=[e.material]);const o=Array.isArray(e.material)?e.material[0]:e.material,a=typeof o?.clone=="function"?o.clone():new b.MeshBasicMaterial;a.color!=null&&a.color.copy(t),this.clearMaterialTextures(a),a.transparent=n<1,a.opacity=n,a.depthWrite=n>=1,a.clippingPlanes=this.engine.sectionPlane,a.needsUpdate=!0,e.material.push(a);const l=e.material.length-1;return e.__customColorMaterialIndexes.set(i,l),l}hideOriginalInstance(e,t){const n=new b.Matrix4;n.makeScale(0,0,0),e.setMatrixAt(t,n),e.instanceMatrix.needsUpdate=!0}createCustomInstanceClone(e,t,n,i,r,o){const a=new b.MeshBasicMaterial({color:r,transparent:o<1,opacity:o,depthWrite:o>=1,side:b.DoubleSide});this.clearMaterialTextures(a),a.clippingPlanes=this.engine.sectionPlane,a.needsUpdate=!0;const l=new b.InstancedMesh(e.geometry,a,1);return l.name="customColorModel",l.key=t,l.url=e.url,l.ids=Array.isArray(e.ids)?[e.ids[n]]:[],l.matrixs=[i.clone()],l.setMatrixAt(0,i),l.instanceMatrix.needsUpdate=!0,l}removeCustomInstanceClone(e){const t=e?.cloneModel;t!=null&&(t.parent!=null&&t.parent.remove(t),t.material?.dispose!=null&&t.material.dispose(),e.cloneModel=null)}normalizeOpacity(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):1}clearMaterialTextures(e){["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap"].forEach(t=>{t in e&&(e[t]=null)})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(o=>{let a=n.nodesMap.get(o);a!=null&&a.indexes!=null&&a.indexes.forEach(l=>{const c=this.getSceneModel(l[0]);c instanceof b.InstancedMesh?i.has(l[0])?i.get(l[0])?.push(l[1]):i.set(l[0],[l[1]]):(this.split_merge_model(c),c.geometry.groups[l[1]].materialIndex=2)})}),G2(i,this.engine);let r=this.engine.engineStatus.translucentModels.find(o=>o.url==t.url);r!=null?r.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=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(r=>{let o=n.nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(l),l.geometry.groups[a[1]].materialIndex=0)})}),i.size>0&&px(i,this.engine),fx(i,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}hideAllModels(){let e=[];this.engine.models.forEach(t=>{let n={url:t.url,ids:[]};for(let i of t.nodesMap)n.ids.push(i[0]);e.push(n)}),this.unhighlightAllModels(),this.hideModel(e)}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels,!0),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 z2(s,e){s.forEach((t,n)=>{const i=va(e,n);if(!(i instanceof b.InstancedMesh))return;const r=i.geometry,o=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide});o.clippingPlanes=e.sectionPlane;const a=new b.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=n,a.ids=[],a.matrixs=[],a.url=i.url,t.forEach(u=>{a.ids.push(i.ids[u]),a.matrixs.push(i.matrixs[u])});const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((u,d)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(d,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function fx(s,e,t){s.forEach((n,i)=>{const r=va(e,i);if(!(r instanceof b.InstancedMesh))return;n.forEach(a=>{const l=r.matrixsClone[a];l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0;const o=[];e.scene.traverse(a=>{a.key==i&&a.name==t&&o.push(a)}),o.forEach(a=>{e.scene.remove(a)})})}function G2(s,e){s.forEach((t,n)=>{const i=va(e,n);if(!(i instanceof b.InstancedMesh))return;const r=i.geometry,o=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide});o.clippingPlanes=e.sectionPlane;const a=new b.InstancedMesh(r,o,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((u,d)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(d,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function V2(s,e){const t=[];e.scene.traverse(n=>{n.name=="highlightModel"&&t.push(n)}),t.forEach(n=>{e.scene.remove(n)}),s.forEach((n,i)=>{const r=va(e,i);if(!(r instanceof b.InstancedMesh))return;const o=new Map,a=new b.Matrix4,l=new b.Matrix4;l.makeScale(0,0,0),n.forEach((c,h)=>{r.getMatrixAt(c,a),o.set(c,a.clone()),r.setMatrixAt(c,l)}),r.instanceMatrix.needsUpdate=!0})}function px(s,e){s.forEach((t,n)=>{const i=va(e,n);i instanceof b.InstancedMesh&&(t.forEach(r=>{const o=i.matrixs[r];o&&i.setMatrixAt(r,o)}),i.instanceMatrix.needsUpdate=!0)})}function va(s,e){return Fd(s,e)}const gx="advanced";class Q2{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch(gx)}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(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"advanced":this.setShadows(!0),this.setGTAO(!0),this.setSSAO(!1),this.setSaturation(!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 b.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(r=>r instanceof b.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 Dc{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]);if(i.infos&&i.infos.length>0){let a=i.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:b.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(r=>r?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const r of i){let o=r.geometry.clone();o.computeVertexNormals();const a=new b.Mesh(o,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}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/Dc.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/Dc.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),e.geometry?.dispose?.();this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.tagDiv?.remove?.(),this.tagDiv=null,this.animState="idle"}}var Pc={exports:{}},j2=Pc.exports,mx;function W2(){return mx||(mx=1,(function(s,e){(function(t,n){s.exports=n()})(j2,function(){var t=function(){function n(f){return o.appendChild(f.dom),f}function i(f){for(var m=0;m<o.children.length;m++)o.children[m].style.display=m===f?"block":"none";r=f}var r=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(f){f.preventDefault(),i(++r%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var f=(performance||Date).now();if(u.update(f-a,200),f>l+1e3&&(h.update(1e3*c/(f-l),100),l=f,c=0,d)){var m=performance.memory;d.update(m.usedJSHeapSize/1048576,m.jsHeapSizeLimit/1048576)}return f},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,r){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,d=3*c,f=2*c,m=3*c,g=15*c,A=74*c,p=30*c,x=document.createElement("canvas");x.width=h,x.height=u,x.style.cssText="width:80px;height:48px";var y=x.getContext("2d");return y.font="bold "+9*c+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=r,y.fillRect(0,0,h,u),y.fillStyle=i,y.fillText(n,d,f),y.fillRect(m,g,A,p),y.fillStyle=r,y.globalAlpha=.9,y.fillRect(m,g,A,p),{dom:x,update:function(v,_){o=Math.min(o,v),a=Math.max(a,v),y.fillStyle=r,y.globalAlpha=1,y.fillRect(0,0,h,g),y.fillStyle=i,y.fillText(l(v)+" "+n+" ("+l(o)+"-"+l(a)+")",d,f),y.drawImage(x,m+c,g,A-c,p,m,g,A-c,p),y.fillRect(m+A-c,g,c,p),y.fillStyle=r,y.globalAlpha=.9,y.fillRect(m+A-c,g,c,l((1-v/_)*p))}}},t})})(Pc)),Pc.exports}var H2=W2();const Ax=hA(H2);var vo=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var e=1.70158;return s===1?1:s*s*((e+1)*s-e)},Out:function(s){var e=1.70158;return s===0?0:--s*s*((e+1)*s+e)+1},InOut:function(s){var e=2.5949095;return(s*=2)<1?.5*(s*s*((e+1)*s-e)):.5*((s-=2)*s*((e+1)*s+e)+2)}}),Bounce:Object.freeze({In:function(s){return 1-vo.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?vo.Bounce.In(s*2)*.5:vo.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(e){return Math.pow(e,s)},Out:function(e){return 1-Math.pow(1-e,s)},InOut:function(e){return e<.5?Math.pow(e*2,s)/2:(1-Math.pow(2-e*2,s))/2+.5}}}}),_a=function(){return performance.now()},q2=(function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},s.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},s.prototype.update=function(e,t){e===void 0&&(e=_a()),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 r=this._tweens[n[i]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),gf={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=gf.Utils.Linear;return e<0?r(s[0],s[1],n):e>1?r(s[t],s[t-1],t-n):r(s[i],s[i+1>t?t:i+1],n-i)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},xx=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),mf=new q2,X2=(function(){function s(e,t){t===void 0&&(t=mf),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=vo.Linear.None,this._interpolationFunction=gf.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=xx.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.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},s.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},s.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},s.prototype.start=function(e,t){if(e===void 0&&(e=_a()),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 r in this._valuesEnd)i[r]=this._valuesEnd[r];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},s.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},s.prototype._setupProperties=function(e,t,n,i,r){for(var o in n){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[o]);if(!(c==="undefined"||c==="function")){if(h){var u=n[o];if(u.length===0)continue;for(var d=[a],f=0,m=u.length;f<m;f+=1){var g=this._handleRelativeValue(a,u[f]);if(isNaN(g)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(g)}h&&(n[o]=d)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var A=a;for(var p in A)t[o][p]=A[p];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var x={};for(var p in u)x[p]=u[p];n[o]=u=x}this._setupProperties(A,t[o],u,i[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=a),l||(t[o]*=1),h?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},s.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},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(e){return e===void 0&&(e=_a()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},s.prototype.resume=function(e){return e===void 0&&(e=_a()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},s.prototype.group=function(e){return e===void 0&&(e=mf),this._group=e,this},s.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},s.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},s.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},s.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},s.prototype.easing=function(e){return e===void 0&&(e=vo.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=gf.Linear),this._interpolationFunction=e,this},s.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},s.prototype.onStart=function(e){return this._onStartCallback=e,this},s.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},s.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},s.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},s.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},s.prototype.onStop=function(e){return this._onStopCallback=e,this},s.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=_a()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)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),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var A=Math.trunc(a/l),p=a-A*l,x=Math.min(p/n._duration,1);return x===0&&a===n._duration?1:x},u=h(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var m=0,g=this._chainedTweens.length;m<g;m++)this._chainedTweens[m].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(t[r]!==void 0){var o=t[r]||0,a=n[r],l=Array.isArray(e[r]),c=Array.isArray(a),h=!l&&c;h?e[r]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[r],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[r]=o+(a-o)*i))}},s.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},s.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},s})();xx.nextId;var Ci=mf;Ci.getAll.bind(Ci),Ci.removeAll.bind(Ci),Ci.add.bind(Ci),Ci.remove.bind(Ci),Ci.update.bind(Ci);var wa={Easing:vo,Tween:X2};const pr=new w.Raycaster,sn=new w.Vector3,Es=new w.Vector3,wt=new w.Quaternion,yx={X:new w.Vector3(1,0,0),Y:new w.Vector3(0,1,0),Z:new w.Vector3(0,0,1)},Af={type:"change"},bx={type:"mouseDown",mode:null},vx={type:"mouseUp",mode:null},_x={type:"objectChange"};class wx extends w.Controls{constructor(e,t=null){super(void 0,t);const n=new eB(this);this._root=n;const i=new tB;this._gizmo=i,n.add(i);const r=new nB;this._plane=r,n.add(r);const o=this;function a(y,v){let _=v;Object.defineProperty(o,y,{get:function(){return _!==void 0?_:v},set:function(E){_!==E&&(_=E,r[y]=E,i[y]=E,o.dispatchEvent({type:y+"-changed",value:E}),o.dispatchEvent(Af))}}),o[y]=v,r[y]=v,i[y]=v}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new w.Vector3,c=new w.Vector3,h=new w.Quaternion,u=new w.Quaternion,d=new w.Vector3,f=new w.Quaternion,m=new w.Vector3,g=new w.Vector3,A=new w.Vector3,p=0,x=new w.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",u),a("cameraPosition",d),a("cameraQuaternion",f),a("pointStart",m),a("pointEnd",g),a("rotationAxis",A),a("rotationAngle",p),a("eye",x),this._offset=new w.Vector3,this._startNorm=new w.Vector3,this._endNorm=new w.Vector3,this._cameraScale=new w.Vector3,this._parentPosition=new w.Vector3,this._parentQuaternion=new w.Quaternion,this._parentQuaternionInv=new w.Quaternion,this._parentScale=new w.Vector3,this._worldScaleStart=new w.Vector3,this._worldQuaternionInv=new w.Quaternion,this._worldScale=new w.Vector3,this._positionStart=new w.Vector3,this._quaternionStart=new w.Quaternion,this._scaleStart=new w.Vector3,this._getPointer=Y2.bind(this),this._onPointerDown=$2.bind(this),this._onPointerHover=K2.bind(this),this._onPointerMove=J2.bind(this),this._onPointerUp=Z2.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&pr.setFromCamera(e,this.camera);const t=xf(this._gizmo.picker[this.mode],pr);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&pr.setFromCamera(e,this.camera);const t=xf(this._plane,pr,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,bx.mode=this.mode,this.dispatchEvent(bx)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if(n==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&pr.setFromCamera(e,this.camera);const o=xf(this._plane,pr,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(i.position.applyQuaternion(wt.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),r==="world"&&(i.parent&&i.position.add(sn.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(sn.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Es.set(a,a,a)}else sn.copy(this.pointStart),Es.copy(this.pointEnd),sn.applyQuaternion(this._worldQuaternionInv),Es.applyQuaternion(this._worldQuaternionInv),Es.divide(sn),t.search("X")===-1&&(Es.x=1),t.search("Y")===-1&&(Es.y=1),t.search("Z")===-1&&(Es.z=1);i.scale.copy(this._scaleStart).multiply(Es),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(sn.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(sn.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(yx[t]),sn.copy(yx[t]),r==="local"&&sn.applyQuaternion(this.worldQuaternion),sn.cross(this.eye),sn.length()===0?l=!0:this.rotationAngle=this._offset.dot(sn.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(wt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(wt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Af),this.dispatchEvent(_x)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(vx.mode=this.mode,this.dispatchEvent(vx)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Af),this.dispatchEvent(_x),this.pointStart.copy(this.pointEnd))}getRaycaster(){return pr}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,i){const r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(n),r.active.color.set(i),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(n),r.activeTransparent.color.set(i),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(n),r.active._color&&r.active._color.set(i),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(n),r.activeTransparent._color&&r.activeTransparent._color.set(i)}}function Y2(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function K2(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function $2(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function J2(s){this.enabled&&this.pointerMove(this._getPointer(s))}function Z2(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function xf(s,e,t){const n=e.intersectObject(s,!0);for(let i=0;i<n.length;i++)if(n[i].object.visible||t)return n[i];return!1}const Lc=new w.Euler,mt=new w.Vector3(0,1,0),Cx=new w.Vector3(0,0,0),Mx=new w.Matrix4,Rc=new w.Quaternion,kc=new w.Quaternion,Mi=new w.Vector3,Sx=new w.Matrix4,Ca=new w.Vector3(1,0,0),gr=new w.Vector3(0,1,0),Ma=new w.Vector3(0,0,1),Fc=new w.Vector3,Sa=new w.Vector3,Ea=new w.Vector3;class eB extends w.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class tB extends w.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new w.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new w.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25;const f=e.clone();f.color.setHex(16776960);const m=e.clone();m.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:o,zAxis:a,active:f,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:d};const g=new w.CylinderGeometry(0,.04,.1,12);g.translate(0,.05,0);const A=new w.BoxGeometry(.08,.08,.08);A.translate(0,.04,0);const p=new w.BufferGeometry;p.setAttribute("position",new w.Float32BufferAttribute([0,0,0,1,0,0],3));const x=new w.CylinderGeometry(.0075,.0075,.5,3);x.translate(0,.25,0);function y(F,N){const j=new w.TorusGeometry(F,.0075,3,64,N*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}function v(){const F=new w.BufferGeometry;return F.setAttribute("position",new w.Float32BufferAttribute([0,0,0,1,1,1],3)),F}const _={X:[[new w.Mesh(g,r),[.5,0,0],[0,0,-Math.PI/2]],[new w.Mesh(g,r),[-.5,0,0],[0,0,Math.PI/2]],[new w.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new w.Mesh(g,o),[0,.5,0]],[new w.Mesh(g,o),[0,-.5,0],[Math.PI,0,0]],[new w.Mesh(x,o)]],Z:[[new w.Mesh(g,a),[0,0,.5],[Math.PI/2,0,0]],[new w.Mesh(g,a),[0,0,-.5],[-Math.PI/2,0,0]],[new w.Mesh(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.OctahedronGeometry(.1,0),u),[0,0,0]]],XY:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},E={X:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.OctahedronGeometry(.2,0),n)]],XY:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new w.Mesh(new w.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new w.Mesh(new w.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new w.Line(v(),i),null,null,null,"helper"]],X:[[new w.Line(p,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new w.Line(p,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new w.Line(p,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},B={XYZE:[[new w.Mesh(y(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new w.Mesh(y(.5,.5),r)]],Y:[[new w.Mesh(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new w.Mesh(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new w.Mesh(y(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new w.Line(p,i),[-1e3,0,0],null,[1e6,1,1],"helper"]]},C={XYZE:[[new w.Mesh(new w.SphereGeometry(.25,10,8),n)]],X:[[new w.Mesh(new w.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new w.Mesh(new w.TorusGeometry(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new w.Mesh(new w.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new w.Mesh(new w.TorusGeometry(.75,.1,2,24),n)]]},P={X:[[new w.Mesh(A,r),[.5,0,0],[0,0,-Math.PI/2]],[new w.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]],[new w.Mesh(A,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new w.Mesh(A,o),[0,.5,0]],[new w.Mesh(x,o)],[new w.Mesh(A,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new w.Mesh(A,a),[0,0,.5],[Math.PI/2,0,0]],[new w.Mesh(x,a),[0,0,0],[Math.PI/2,0,0]],[new w.Mesh(A,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.BoxGeometry(.1,.1,.1),u)]]},T={X:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.2),n),[0,0,0]]]},R={X:[[new w.Line(p,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new w.Line(p,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new w.Line(p,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function S(F){const N=new w.Object3D;for(const j in F)for(let q=F[j].length;q--;){const U=F[j][q][0].clone(),H=F[j][q][1],z=F[j][q][2],G=F[j][q][3],re=F[j][q][4];U.name=j,U.tag=re,H&&U.position.set(H[0],H[1],H[2]),z&&U.rotation.set(z[0],z[1],z[2]),G&&U.scale.set(G[0],G[1],G[2]),U.updateMatrix();const le=U.geometry.clone();le.applyMatrix4(U.matrix),U.geometry=le,U.renderOrder=1/0,U.position.set(0,0,0),U.rotation.set(0,0,0),U.scale.set(1,1,1),N.add(U)}return N}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=S(_)),this.add(this.gizmo.rotate=S(B)),this.add(this.gizmo.scale=S(P)),this.add(this.picker.translate=S(E)),this.add(this.picker.rotate=S(C)),this.add(this.picker.scale=S(T)),this.add(this.helper.translate=S(I)),this.add(this.helper.rotate=S(M)),this.add(this.helper.scale=S(R)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:kc;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let r=0;r<i.length;r++){const o=i[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(wt.setFromEuler(Lc.set(0,0,0)),o.quaternion.copy(n).multiply(wt),Math.abs(mt.copy(Ca).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(wt.setFromEuler(Lc.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(wt),Math.abs(mt.copy(gr).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(wt.setFromEuler(Lc.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(wt),Math.abs(mt.copy(Ma).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(wt.setFromEuler(Lc.set(0,Math.PI/2,0)),mt.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(Mx.lookAt(Cx,mt,gr)),o.quaternion.multiply(wt),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),sn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),sn.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(sn),o.visible=this.dragging):(o.quaternion.copy(n),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(mt.copy(Ca).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(mt.copy(gr).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(mt.copy(Ma).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(mt.copy(Ma).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(mt.copy(Ca).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(mt.copy(gr).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Rc.copy(n),mt.copy(this.eye).applyQuaternion(wt.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(Mx.lookAt(this.eye,Cx,gr)),o.name==="X"&&(wt.setFromAxisAngle(Ca,Math.atan2(-mt.y,mt.z)),wt.multiplyQuaternions(Rc,wt),o.quaternion.copy(wt)),o.name==="Y"&&(wt.setFromAxisAngle(gr,Math.atan2(mt.x,mt.z)),wt.multiplyQuaternions(Rc,wt),o.quaternion.copy(wt)),o.name==="Z"&&(wt.setFromAxisAngle(Ma,Math.atan2(mt.y,mt.x)),wt.multiplyQuaternions(Rc,wt),o.quaternion.copy(wt))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class nB extends w.Mesh{constructor(){super(new w.PlaneGeometry(1e5,1e5,2,2),new w.MeshBasicMaterial({visible:!1,wireframe:!0,side:w.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Fc.copy(Ca).applyQuaternion(t==="local"?this.worldQuaternion:kc),Sa.copy(gr).applyQuaternion(t==="local"?this.worldQuaternion:kc),Ea.copy(Ma).applyQuaternion(t==="local"?this.worldQuaternion:kc),mt.copy(Sa),this.mode){case"translate":case"scale":switch(this.axis){case"X":mt.copy(this.eye).cross(Fc),Mi.copy(Fc).cross(mt);break;case"Y":mt.copy(this.eye).cross(Sa),Mi.copy(Sa).cross(mt);break;case"Z":mt.copy(this.eye).cross(Ea),Mi.copy(Ea).cross(mt);break;case"XY":Mi.copy(Ea);break;case"YZ":Mi.copy(Fc);break;case"XZ":mt.copy(Ea),Mi.copy(Sa);break;case"XYZ":case"E":Mi.set(0,0,0);break}break;case"rotate":default:Mi.set(0,0,0)}Mi.length()===0?this.quaternion.copy(this.cameraQuaternion):(Sx.lookAt(sn.set(0,0,0),Mi,mt),this.quaternion.setFromRotationMatrix(Sx)),super.updateMatrixWorld(e)}}class iB extends w.DataTextureLoader{constructor(e){super(e),this.type=w.HalfFloatType}parse(e){const o=function(B,M){switch(B){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(M||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(M||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(M||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(M||""))}},u=function(B,M,C){M=M||1024;let T=B.pos,R=-1,S=0,F="",N=String.fromCharCode.apply(null,new Uint16Array(B.subarray(T,T+128)));for(;0>(R=N.indexOf(`
|
|
4941
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([l])),this.transcoderBinary=o,this.workerPool.setWorkerCreator(()=>{const c=new Worker(this.workerSourceURL),h=this.transcoderBinary.slice(0);return c.postMessage({type:"init",config:this.workerConfig,transcoderBinary:h},[h]),c})}),rf>0&&console.warn("THREE.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),rf++}return this.transcoderPending}load(e,t,n,i){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");const r=new w.FileLoader(this.manager);r.setPath(this.path),r.setCrossOrigin(this.crossOrigin),r.setWithCredentials(this.withCredentials),r.setRequestHeader(this.requestHeader),r.setResponseType("arraybuffer"),r.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n){if(this.workerConfig===null)throw new Error("THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.");if(sf.has(e))return sf.get(e).promise.then(t).catch(n);this._createTexture(e).then(i=>t?t(i):null).catch(n)}_createTextureFrom(e,t){const{type:n,error:i,data:{faces:r,width:o,height:a,format:l,type:c,dfdFlags:h}}=e;if(n==="error")return Promise.reject(i);let u;if(t.faceCount===6)u=new w.CompressedCubeTexture(r,l,c);else{const d=r[0].mipmaps;u=t.layerCount>1?new w.CompressedArrayTexture(d,o,a,t.layerCount,l,c):new w.CompressedTexture(d,o,a,l,c)}return u.minFilter=r[0].mipmaps.length===1?w.LinearFilter:w.LinearMipmapLinearFilter,u.magFilter=w.LinearFilter,u.generateMipmaps=!1,u.needsUpdate=!0,u.colorSpace=V0(t),u.premultiplyAlpha=!!(h&sT),u}async _createTexture(e,t={}){const n=cT(new Uint8Array(e)),i=n.vkFormat===Zd&&n.dataFormatDescriptor[0].colorModel===167;if(!(n.vkFormat===lT||i&&!this.workerConfig.astcHDRSupported))return pT(n);const o=t,a=this.init().then(()=>this.workerPool.postMessage({type:"transcode",buffer:e,taskConfig:o},[e])).then(l=>this._createTextureFrom(l.data,n));return sf.set(e,{promise:a}),a}dispose(){this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),rf--}}Gn.BasisFormat={ETC1S:0,UASTC:1,UASTC_HDR:2},Gn.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16,BC6H:22,RGB_HALF:24,RGBA_HALF:25},Gn.EngineFormat={RGBAFormat:w.RGBAFormat,RGBA_ASTC_4x4_Format:w.RGBA_ASTC_4x4_Format,RGB_BPTC_UNSIGNED_Format:w.RGB_BPTC_UNSIGNED_Format,RGBA_BPTC_Format:w.RGBA_BPTC_Format,RGBA_ETC2_EAC_Format:w.RGBA_ETC2_EAC_Format,RGBA_PVRTC_4BPPV1_Format:w.RGBA_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT5_Format:w.RGBA_S3TC_DXT5_Format,RGB_ETC1_Format:w.RGB_ETC1_Format,RGB_ETC2_Format:w.RGB_ETC2_Format,RGB_PVRTC_4BPPV1_Format:w.RGB_PVRTC_4BPPV1_Format,RGBA_S3TC_DXT1_Format:w.RGBA_S3TC_DXT1_Format},Gn.EngineType={UnsignedByteType:w.UnsignedByteType,HalfFloatType:w.HalfFloatType,FloatType:w.FloatType},Gn.BasisWorker=function(){let s,e,t;const n=_EngineFormat,i=_EngineType,r=_TranscoderFormat,o=_BasisFormat;self.addEventListener("message",function(m){const g=m.data;switch(g.type){case"init":s=g.config,a(g.transcoderBinary);break;case"transcode":e.then(()=>{try{const{faces:A,buffers:p,width:x,height:y,hasAlpha:v,format:_,type:E,dfdFlags:I}=l(g.buffer);self.postMessage({type:"transcode",id:g.id,data:{faces:A,width:x,height:y,hasAlpha:v,format:_,type:E,dfdFlags:I}},p)}catch(A){console.error(A),self.postMessage({type:"error",id:g.id,error:A.message})}});break}});function a(m){e=new Promise(g=>{t={wasmBinary:m,onRuntimeInitialized:g},BASIS(t)}).then(()=>{t.initializeBasis(),t.KTX2File===void 0&&console.warn("THREE.KTX2Loader: Please update Basis Universal transcoder.")})}function l(m){const g=new t.KTX2File(new Uint8Array(m));function A(){g.close(),g.delete()}if(!g.isValid())throw A(),new Error("THREE.KTX2Loader: Invalid or unsupported .ktx2 file");let p;if(g.isUASTC())p=o.UASTC;else if(g.isETC1S())p=o.ETC1S;else if(g.isHDR())p=o.UASTC_HDR;else throw new Error("THREE.KTX2Loader: Unknown Basis encoding");const x=g.getWidth(),y=g.getHeight(),v=g.getLayers()||1,_=g.getLevels(),E=g.getFaces(),I=g.getHasAlpha(),B=g.getDFDFlags(),{transcoderFormat:M,engineFormat:C,engineType:P}=u(p,x,y,I);if(!x||!y||!_)throw A(),new Error("THREE.KTX2Loader: Invalid texture");if(!g.startTranscoding())throw A(),new Error("THREE.KTX2Loader: .startTranscoding failed");const T=[],R=[];for(let S=0;S<E;S++){const F=[];for(let N=0;N<_;N++){const j=[];let q,U;for(let z=0;z<v;z++){const G=g.getImageLevelInfo(N,z,S);S===0&&N===0&&z===0&&(G.origWidth%4!==0||G.origHeight%4!==0)&&console.warn("THREE.KTX2Loader: ETC1S and UASTC textures should use multiple-of-four dimensions."),_>1?(q=G.origWidth,U=G.origHeight):(q=G.width,U=G.height);let re=new Uint8Array(g.getImageTranscodedSizeInBytes(N,z,0,M));const le=g.transcodeImage(re,N,z,S,M,0,-1,-1);if(P===i.HalfFloatType&&(re=new Uint16Array(re.buffer,re.byteOffset,re.byteLength/Uint16Array.BYTES_PER_ELEMENT)),!le)throw A(),new Error("THREE.KTX2Loader: .transcodeImage failed.");j.push(re)}const H=f(j);F.push({data:H,width:q,height:U}),R.push(H.buffer)}T.push({mipmaps:F,width:x,height:y,format:C,type:P})}return A(),{faces:T,buffers:R,width:x,height:y,hasAlpha:I,dfdFlags:B,format:C,type:P}}const c=[{if:"astcSupported",basisFormat:[o.UASTC],transcoderFormat:[r.ASTC_4x4,r.ASTC_4x4],engineFormat:[n.RGBA_ASTC_4x4_Format,n.RGBA_ASTC_4x4_Format],engineType:[i.UnsignedByteType],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC7_M5,r.BC7_M5],engineFormat:[n.RGBA_BPTC_Format,n.RGBA_BPTC_Format],engineType:[i.UnsignedByteType],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.BC1,r.BC3],engineFormat:[n.RGBA_S3TC_DXT1_Format,n.RGBA_S3TC_DXT5_Format],engineType:[i.UnsignedByteType],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1,r.ETC2],engineFormat:[n.RGB_ETC2_Format,n.RGBA_ETC2_EAC_Format],engineType:[i.UnsignedByteType],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.ETC1],engineFormat:[n.RGB_ETC1_Format],engineType:[i.UnsignedByteType],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.PVRTC1_4_RGB,r.PVRTC1_4_RGBA],engineFormat:[n.RGB_PVRTC_4BPPV1_Format,n.RGBA_PVRTC_4BPPV1_Format],engineType:[i.UnsignedByteType],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0},{if:"bptcSupported",basisFormat:[o.UASTC_HDR],transcoderFormat:[r.BC6H],engineFormat:[n.RGB_BPTC_UNSIGNED_Format],engineType:[i.HalfFloatType],priorityHDR:1,needsPowerOfTwo:!1},{basisFormat:[o.ETC1S,o.UASTC],transcoderFormat:[r.RGBA32,r.RGBA32],engineFormat:[n.RGBAFormat,n.RGBAFormat],engineType:[i.UnsignedByteType,i.UnsignedByteType],priorityETC1S:100,priorityUASTC:100,needsPowerOfTwo:!1},{basisFormat:[o.UASTC_HDR],transcoderFormat:[r.RGBA_HALF],engineFormat:[n.RGBAFormat],engineType:[i.HalfFloatType],priorityHDR:100,needsPowerOfTwo:!1}],h={[o.ETC1S]:c.filter(m=>m.basisFormat.includes(o.ETC1S)).sort((m,g)=>m.priorityETC1S-g.priorityETC1S),[o.UASTC]:c.filter(m=>m.basisFormat.includes(o.UASTC)).sort((m,g)=>m.priorityUASTC-g.priorityUASTC),[o.UASTC_HDR]:c.filter(m=>m.basisFormat.includes(o.UASTC_HDR)).sort((m,g)=>m.priorityHDR-g.priorityHDR)};function u(m,g,A,p){const x=h[m];for(let y=0;y<x.length;y++){const v=x[y];if(v.if&&!s[v.if]||!v.basisFormat.includes(m)||p&&v.transcoderFormat.length<2||v.needsPowerOfTwo&&!(d(g)&&d(A)))continue;const _=v.transcoderFormat[p?1:0],E=v.engineFormat[p?1:0],I=v.engineType[0];return{transcoderFormat:_,engineFormat:E,engineType:I}}throw new Error("THREE.KTX2Loader: Failed to identify transcoding target.")}function d(m){return m<=2?!0:(m&m-1)===0&&m!==0}function f(m){if(m.length===1)return m[0];let g=0;for(let x=0;x<m.length;x++){const y=m[x];g+=y.byteLength}const A=new Uint8Array(g);let p=0;for(let x=0;x<m.length;x++){const y=m[x];A.set(y,p),p+=y.byteLength}return A}};const fT=new Set([w.RGBAFormat,w.RGBFormat,w.RGFormat,w.RedFormat]),af={[h0]:w.RGBAFormat,[c0]:w.RGFormat,[l0]:w.RedFormat,[a0]:w.RGBAFormat,[o0]:w.RGFormat,[r0]:w.RedFormat,[s0]:w.RGBAFormat,[i0]:w.RGBAFormat,[n0]:w.RGFormat,[t0]:w.RGFormat,[e0]:w.RedFormat,[ZA]:w.RedFormat,[d0]:w.RGBFormat,[u0]:w.RGBFormat,[S0]:w.RGBA_ETC2_EAC_Format,[M0]:w.RGB_ETC2_Format,[E0]:w.R11_EAC_Format,[I0]:w.SIGNED_R11_EAC_Format,[T0]:w.RG11_EAC_Format,[B0]:w.SIGNED_RG11_EAC_Format,[Zd]:w.RGBA_ASTC_4x4_Format,[P0]:w.RGBA_ASTC_4x4_Format,[D0]:w.RGBA_ASTC_4x4_Format,[N0]:w.RGBA_ASTC_6x6_Format,[R0]:w.RGBA_ASTC_6x6_Format,[L0]:w.RGBA_ASTC_6x6_Format,[m0]:w.RGBA_S3TC_DXT1_Format,[g0]:w.RGBA_S3TC_DXT1_Format,[p0]:w.RGB_S3TC_DXT1_Format,[f0]:w.RGB_S3TC_DXT1_Format,[x0]:w.RGBA_S3TC_DXT5_Format,[A0]:w.RGBA_S3TC_DXT5_Format,[b0]:w.SIGNED_RED_RGTC1_Format,[y0]:w.RED_RGTC1_Format,[_0]:w.SIGNED_RED_GREEN_RGTC2_Format,[v0]:w.RED_GREEN_RGTC2_Format,[C0]:w.RGBA_BPTC_Format,[w0]:w.RGBA_BPTC_Format,[U0]:w.RGBA_PVRTC_4BPPV1_Format,[F0]:w.RGBA_PVRTC_4BPPV1_Format,[O0]:w.RGBA_PVRTC_2BPPV1_Format,[k0]:w.RGBA_PVRTC_2BPPV1_Format},yo={[h0]:w.FloatType,[c0]:w.FloatType,[l0]:w.FloatType,[a0]:w.HalfFloatType,[o0]:w.HalfFloatType,[r0]:w.HalfFloatType,[s0]:w.UnsignedByteType,[i0]:w.UnsignedByteType,[n0]:w.UnsignedByteType,[t0]:w.UnsignedByteType,[e0]:w.UnsignedByteType,[ZA]:w.UnsignedByteType,[d0]:w.UnsignedInt5999Type,[u0]:w.UnsignedInt101111Type,[S0]:w.UnsignedByteType,[M0]:w.UnsignedByteType,[E0]:w.UnsignedByteType,[I0]:w.UnsignedByteType,[T0]:w.UnsignedByteType,[B0]:w.UnsignedByteType,[Zd]:w.HalfFloatType,[P0]:w.UnsignedByteType,[D0]:w.UnsignedByteType,[N0]:w.HalfFloatType,[R0]:w.UnsignedByteType,[L0]:w.UnsignedByteType,[m0]:w.UnsignedByteType,[g0]:w.UnsignedByteType,[p0]:w.UnsignedByteType,[f0]:w.UnsignedByteType,[x0]:w.UnsignedByteType,[A0]:w.UnsignedByteType,[b0]:w.UnsignedByteType,[y0]:w.UnsignedByteType,[_0]:w.UnsignedByteType,[v0]:w.UnsignedByteType,[C0]:w.UnsignedByteType,[w0]:w.UnsignedByteType,[U0]:w.UnsignedByteType,[F0]:w.UnsignedByteType,[O0]:w.UnsignedByteType,[k0]:w.UnsignedByteType};async function pT(s){const{vkFormat:e}=s;if(af[e]===void 0)throw new Error("THREE.KTX2Loader: Unsupported vkFormat: "+e);yo[e]===void 0&&console.warn('THREE.KTX2Loader: Missing ".type" for vkFormat: '+e);let t;s.supercompressionScheme===$A&&(of||(of=new Promise(async o=>{const a=new hT;await a.init(),o(a)})),t=await of);const n=[];for(let o=0;o<s.levels.length;o++){const a=Math.max(1,s.pixelWidth>>o),l=Math.max(1,s.pixelHeight>>o),c=s.pixelDepth?Math.max(1,s.pixelDepth>>o):0,h=s.levels[o];let u;if(s.supercompressionScheme===iT)u=h.levelData;else if(s.supercompressionScheme===$A)u=t.decode(h.levelData,h.uncompressedByteLength);else throw new Error("THREE.KTX2Loader: Unsupported supercompressionScheme.");let d;yo[e]===w.FloatType?d=new Float32Array(u.buffer,u.byteOffset,u.byteLength/Float32Array.BYTES_PER_ELEMENT):yo[e]===w.HalfFloatType?d=new Uint16Array(u.buffer,u.byteOffset,u.byteLength/Uint16Array.BYTES_PER_ELEMENT):yo[e]===w.UnsignedInt5999Type||yo[e]===w.UnsignedInt101111Type?d=new Uint32Array(u.buffer,u.byteOffset,u.byteLength/Uint32Array.BYTES_PER_ELEMENT):d=u,n.push({data:d,width:a,height:l,depth:c})}const i=s.levelCount===0||n.length>1;let r;if(fT.has(af[e]))r=s.pixelDepth===0?new w.DataTexture(n[0].data,s.pixelWidth,s.pixelHeight):new w.Data3DTexture(n[0].data,s.pixelWidth,s.pixelHeight,s.pixelDepth),r.minFilter=i?w.NearestMipmapNearestFilter:w.NearestFilter,r.magFilter=w.NearestFilter,r.generateMipmaps=s.levelCount===0;else{if(s.pixelDepth>0)throw new Error("THREE.KTX2Loader: Unsupported pixelDepth.");r=new w.CompressedTexture(n,s.pixelWidth,s.pixelHeight),r.minFilter=i?w.LinearMipmapLinearFilter:w.LinearFilter,r.magFilter=w.LinearFilter}return r.mipmaps=n,r.type=yo[e],r.format=af[e],r.colorSpace=V0(s),r.needsUpdate=!0,Promise.resolve(r)}function V0(s){const e=s.dataFormatDescriptor[0];return e.colorPrimaries===oT?e.transferFunction===JA?w.SRGBColorSpace:w.LinearSRGBColorSpace:e.colorPrimaries===aT?e.transferFunction===JA?uT:dT:(e.colorPrimaries===rT||console.warn(`THREE.KTX2Loader: Unsupported color primaries, "${e.colorPrimaries}"`),w.NoColorSpace)}function gT(s,e,t,n){const a=s.models.find(g=>g.url==t);if(a==null)return;const l=ua(s,t),c=e.circularMeps,h=e.rectMeps?.filter(g=>g.type==="风管"),u=e.rectMeps?.filter(g=>g.type==="桥架"),d=e.ellipseMeps,f=g=>(g.color=g.color.split(",").map(A=>parseInt(A)/255),g.color=new b.Color(g.color[0],g.color[1],g.color[2]),g.position={x:g.startPoint.X*.3048+0,y:g.startPoint.Z*.3048+0,z:-g.startPoint.Y*.3048+0},g.rotation={x:0,y:0,z:0},g),m=(g,A)=>{if(!Array.isArray(A)||A.length===0)return;const p=A.map(y=>f(y)),x=mT(g,l,p,t,s);x!=null&&p.forEach((y,v)=>{y.indexes=[[x,v,0,0]],a.nodesMap.set(Number(y.id),y)})};m("Circle",c),m("Rect",h),m("Ellipse",d),m("Bridge",u)}function mT(s,e,t,n,i){let r;const o={width:1,height:1,length:1,diameter:1,color:new b.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(s){case"Rect":r=Ic("Rect",o);break;case"Bridge":r=Ic("Bridge",o);break;case"Circle":r=Ic("Circle",o);break;case"Ellipse":r=Ic("Ellipse",o);break}if(!r)return null;const a=new b.InstancedMesh(r.geometry,r.material,t.length);a.url=n,e.add(a);const l=kd(i,a),c=[],h=[];for(let d=0;d<t.length;d++){const f=t[d],m=new b.Vector3(f.startPoint.X,0,-f.startPoint.Y),g=new b.Vector3(f.endPoint.X,0,-f.endPoint.Y),A=new b.Vector3(f.startPoint.X,f.startPoint.Z,-f.startPoint.Y),p=new b.Vector3(f.endPoint.X,f.endPoint.Z,-f.endPoint.Y);let x=0,y=0,v=0;if(Math.abs(g.clone().sub(m.clone()).z)<.01&&Math.abs(g.clone().sub(m.clone()).x)<.01){if(x=(f.startPoint.Z>f.endPoint.Z?1:-1)*Math.PI*.5,f.base_x!=null){const q=new b.Vector3(f.base_x.X,0,-f.base_x.Y);y=(q.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*q.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else y=(g.clone().sub(m.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*g.clone().sub(m.clone()).angleTo(new b.Vector3(0,0,1)),x=(f.startPoint.Z>f.endPoint.Z?1:-1)*g.clone().sub(m.clone()).angleTo(p.clone().sub(A.clone()));const _=new b.Matrix4,E=new b.Euler(x,y,v,"YXZ"),I=_.clone().makeRotationFromEuler(E);let B,M;s==="Circle"?(B=f.diameter,M=f.diameter):(B=f.width,M=f.height);const C=_.clone().makeScale(B,M,f.length);_.multiplyMatrices(I,C),_.setPosition(f.position.x,f.position.y,f.position.z),a.setMatrixAt(d,_.clone()),a.setColorAt(d,f.color),a.geometry.computeBoundingBox();const P=a.geometry.boundingBox.min.clone().applyMatrix4(_.clone()),T=a.geometry.boundingBox.max.clone().applyMatrix4(_.clone()),R=new b.Vector3(Math.min(P.x,T.x),Math.min(P.y,T.y),Math.min(P.z,T.z)),S=new b.Vector3(Math.max(P.x,T.x),Math.max(P.y,T.y),Math.max(P.z,T.z)),F=R.clone().add(S.clone()).multiplyScalar(.5),N={name:f.name,min:R,max:S,center:F,dbid:d,materialName:r.material.name};s==="Circle"&&(N.minC={x:f.startPoint.X*.3048,y:f.startPoint.Z*.3048,z:-f.startPoint.Y*.3048},N.maxC={x:f.endPoint.X*.3048,y:f.endPoint.Z*.3048,z:-f.endPoint.Y*.3048}),a.ids||(a.ids=[]),a.matrixs||(a.matrixs=[]),a.matrixs.push(_.clone()),h.push(_.clone()),a.ids.push(Number(f.id)),c.push(N)}a.castShadow=!0,a.ElementInfos=c,a.name="rootModel",a.TypeName="InstancedMesh-Pipe",a.PipeType=s,a.MeshId=null,a.realMaterial=a.material.clone(),a.originalMaterial=a.material.clone(),a.matrixsClone=h,i?.sectionPlane&&(a.material.clippingPlanes=i.sectionPlane,a.originalMaterial.clippingPlanes=i.sectionPlane,a.realMaterial.clippingPlanes=i.sectionPlane);const u={geometry:a.geometry,matrix:a.matrix,position:a.position,rotation:a.rotation};return a.meshs=u,a.instanceMatrix&&a.instanceMatrix.array&&(a.cloneInstanceMatrix=Array.from(a.instanceMatrix.array)),a.instanceMatrix.needsUpdate=!0,l}function Ic(s,e){const t=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Bridge":t.moveTo(-e.width/2,-e.height/2),t.lineTo(-e.width/2,e.height/2),t.lineTo(-e.width/2+.01,e.height/2),t.lineTo(-e.width/2+.01,-e.height/2+.01),t.lineTo(e.width/2-.01,-e.height/2+.01),t.lineTo(e.width/2-.01,e.height/2),t.lineTo(e.width/2,e.height/2),t.lineTo(e.width/2,-e.height/2),t.lineTo(-e.width/2,-e.height/2);break;case"Circle":t.moveTo(0,0),t.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const n={depth:e.length*.3048,bevelEnabled:!1};return i(t,n,e.color,e.position,e.rotation);function i(r,o,a,l,c){const h=new b.ExtrudeGeometry(r,o),u=new b.MeshStandardMaterial({color:a,side:b.DoubleSide}),d=new b.Mesh(h,u);return d.position.set(l.x,l.y,l.z),d.rotation._order="YXZ",d.rotation.set(c.x,c.y,c.z),d}}function _i(s,e=!1){const t=s[0].index!==null,n=new Set(Object.keys(s[0].attributes)),i=new Set(Object.keys(s[0].morphAttributes)),r={},o={},a=s[0].morphTargetsRelative,l=new w.BufferGeometry;let c=0;for(let h=0;h<s.length;++h){const u=s[h];let d=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const f in u.attributes){if(!n.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+f+'" attribute exists among all geometries, or in none of them.'),null;r[f]===void 0&&(r[f]=[]),r[f].push(u.attributes[f]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const f in u.morphAttributes){if(!i.has(f))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[f]===void 0&&(o[f]=[]),o[f].push(u.morphAttributes[f])}if(e){let f;if(t)f=u.index.count;else if(u.attributes.position!==void 0)f=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,f,h),c+=f}}if(t){let h=0;const u=[];for(let d=0;d<s.length;++d){const f=s[d].index;for(let m=0;m<f.count;++m)u.push(f.getX(m)+h);h+=s[d].attributes.position.count}l.setIndex(u)}for(const h in r){const u=Q0(r[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(const h in o){const u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let d=0;d<u;++d){const f=[];for(let g=0;g<o[h].length;++g)f.push(o[h][g][d]);const m=Q0(f);if(!m)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(m)}}return l}function Q0(s){let e,t,n,i=-1,r=0;for(let c=0;c<s.length;++c){const h=s[c];if(e===void 0&&(e=h.array.constructor),e!==h.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=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=h.count*t}const o=new e(r),a=new w.BufferAttribute(o,t,n);let l=0;for(let c=0;c<s.length;++c){const h=s[c];if(h.isInterleavedBufferAttribute){const u=l/t;for(let d=0,f=h.count;d<f;d++)for(let m=0;m<t;m++){const g=h.getComponent(d,m);a.setComponent(d+u,m,g)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function j0(s,e){if(e===w.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===w.TriangleFanDrawMode||e===w.TriangleStripDrawMode){let t=s.getIndex();if(t===null){const o=[],a=s.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);s.setIndex(o),t=s.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),s}const n=t.count-2,i=[];if(e===w.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=s.clone();return r.setIndex(i),r.clearGroups(),r}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),s}function AT(s){const e=new Map,t=new Map,n=s.clone();return W0(s,n,function(i,r){e.set(r,i),t.set(i,r)}),n.traverse(function(i){if(!i.isSkinnedMesh)return;const r=i,o=e.get(i),a=o.skeleton.bones;r.skeleton=o.skeleton.clone(),r.bindMatrix.copy(o.bindMatrix),r.skeleton.bones=a.map(function(l){return t.get(l)}),r.bind(r.skeleton,r.bindMatrix)}),n}function W0(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)W0(s.children[n],e.children[n],t)}class xT extends w.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new wT(t)}),this.register(function(t){return new CT(t)}),this.register(function(t){return new LT(t)}),this.register(function(t){return new RT(t)}),this.register(function(t){return new kT(t)}),this.register(function(t){return new ST(t)}),this.register(function(t){return new ET(t)}),this.register(function(t){return new IT(t)}),this.register(function(t){return new TT(t)}),this.register(function(t){return new _T(t)}),this.register(function(t){return new BT(t)}),this.register(function(t){return new MT(t)}),this.register(function(t){return new PT(t)}),this.register(function(t){return new DT(t)}),this.register(function(t){return new bT(t)}),this.register(function(t){return new H0(t,tt.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new H0(t,tt.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new FT(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=w.LoaderUtils.extractUrlBase(e);o=w.LoaderUtils.resolveURL(c,this.path)}else o=w.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),r.manager.itemError(e),r.manager.itemEnd(e)},l=new w.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{r.parse(c,o,function(h){t(h),r.manager.itemEnd(e)},a)}catch(h){a(h)}},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 r;const o={},a={},l=new TextDecoder;if(typeof e=="string")r=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===q0){try{o[tt.KHR_BINARY_GLTF]=new OT(e)}catch(u){i&&i(u);return}r=JSON.parse(o[tt.KHR_BINARY_GLTF].content)}else r=JSON.parse(l.decode(e));else r=e;if(r.asset===void 0||r.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new KT(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(r.extensionsUsed)for(let h=0;h<r.extensionsUsed.length;++h){const u=r.extensionsUsed[h],d=r.extensionsRequired||[];switch(u){case tt.KHR_MATERIALS_UNLIT:o[u]=new vT;break;case tt.KHR_DRACO_MESH_COMPRESSION:o[u]=new UT(r,this.dracoLoader);break;case tt.KHR_TEXTURE_TRANSFORM:o[u]=new NT;break;case tt.KHR_MESH_QUANTIZATION:o[u]=new zT;break;default:d.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,r){n.parse(e,t,i,r)})}}function yT(){let s={};return{get:function(e){return s[e]},add:function(e,t){s[e]=t},remove:function(e){delete s[e]},removeAll:function(){s={}}}}function Ft(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const tt={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",KHR_MESHOPT_COMPRESSION:"KHR_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class bT{constructor(e){this.parser=e,this.name=tt.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 r=t[n];r.extensions&&r.extensions[this.name]&&r.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const r=t.json,l=((r.extensions&&r.extensions[this.name]||{}).lights||[])[e];let c;const h=new w.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],w.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new w.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new w.PointLight(h),c.distance=u;break;case"spot":c=new w.SpotLight(h),c.distance=u,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,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),wi(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],a=(r.extensions&&r.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class vT{constructor(){this.name=tt.KHR_MATERIALS_UNLIT}getMaterialType(){return w.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new w.Color(1,1,1),e.opacity=1;const r=t.pbrMetallicRoughness;if(r){if(Array.isArray(r.baseColorFactor)){const o=r.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],w.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,w.SRGBColorSpace))}return Promise.all(i)}}class _T{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class wT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(n.clearcoatFactor!==void 0&&(t.clearcoat=n.clearcoatFactor),n.clearcoatTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatMap",n.clearcoatTexture)),n.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=n.clearcoatRoughnessFactor),n.clearcoatRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"clearcoatRoughnessMap",n.clearcoatRoughnessTexture)),n.clearcoatNormalTexture!==void 0&&(i.push(this.parser.assignTexture(t,"clearcoatNormalMap",n.clearcoatNormalTexture)),n.clearcoatNormalTexture.scale!==void 0)){const r=n.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new w.Vector2(r,r)}return Promise.all(i)}}class CT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_DISPERSION}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class MT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.iridescenceFactor!==void 0&&(t.iridescence=n.iridescenceFactor),n.iridescenceTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceMap",n.iridescenceTexture)),n.iridescenceIor!==void 0&&(t.iridescenceIOR=n.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),n.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=n.iridescenceThicknessMinimum),n.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=n.iridescenceThicknessMaximum),n.iridescenceThicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"iridescenceThicknessMap",n.iridescenceThicknessTexture)),Promise.all(i)}}class ST{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SHEEN}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new w.Color(0,0,0),t.sheenRoughness=0,t.sheen=1,n.sheenColorFactor!==void 0){const r=n.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],w.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,w.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class ET{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.transmissionFactor!==void 0&&(t.transmission=n.transmissionFactor),n.transmissionTexture!==void 0&&i.push(this.parser.assignTexture(t,"transmissionMap",n.transmissionTexture)),Promise.all(i)}}class IT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_VOLUME}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.thickness=n.thicknessFactor!==void 0?n.thicknessFactor:0,n.thicknessTexture!==void 0&&i.push(this.parser.assignTexture(t,"thicknessMap",n.thicknessTexture)),t.attenuationDistance=n.attenuationDistance||1/0;const r=n.attenuationColor||[1,1,1];return t.attenuationColor=new w.Color().setRGB(r[0],r[1],r[2],w.LinearSRGBColorSpace),Promise.all(i)}}class TT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_IOR}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class BT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_SPECULAR}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];t.specularIntensity=n.specularFactor!==void 0?n.specularFactor:1,n.specularTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularIntensityMap",n.specularTexture));const r=n.specularColorFactor||[1,1,1];return t.specularColor=new w.Color().setRGB(r[0],r[1],r[2],w.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,w.SRGBColorSpace)),Promise.all(i)}}class DT{constructor(e){this.parser=e,this.name=tt.EXT_MATERIALS_BUMP}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return t.bumpScale=n.bumpFactor!==void 0?n.bumpFactor:1,n.bumpTexture!==void 0&&i.push(this.parser.assignTexture(t,"bumpMap",n.bumpTexture)),Promise.all(i)}}class PT{constructor(e){this.parser=e,this.name=tt.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return Ft(this.parser,e,this.name)!==null?w.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=Ft(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];return n.anisotropyStrength!==void 0&&(t.anisotropy=n.anisotropyStrength),n.anisotropyRotation!==void 0&&(t.anisotropyRotation=n.anisotropyRotation),n.anisotropyTexture!==void 0&&i.push(this.parser.assignTexture(t,"anisotropyMap",n.anisotropyTexture)),Promise.all(i)}}class LT{constructor(e){this.parser=e,this.name=tt.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 r=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){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,r.source,o)}}class RT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class kT{constructor(e){this.parser=e,this.name=tt.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,r=i.textures[e];if(!r.extensions||!r.extensions[t])return null;const o=r.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class H0{constructor(e,t){this.name=t,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],r=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,u=i.byteStride,d=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,d,i.mode,i.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(f),h,u,d,i.mode,i.filter),f})})}else return null}}class FT{constructor(e){this.name=tt.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 c of i.primitives)if(c.mode!==Vn.TRIANGLES&&c.mode!==Vn.TRIANGLE_STRIP&&c.mode!==Vn.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],d=c[0].count,f=[];for(const m of u){const g=new w.Matrix4,A=new w.Vector3,p=new w.Quaternion,x=new w.Vector3(1,1,1),y=new w.InstancedMesh(m.geometry,m.material,d);for(let v=0;v<d;v++)l.TRANSLATION&&A.fromBufferAttribute(l.TRANSLATION,v),l.ROTATION&&p.fromBufferAttribute(l.ROTATION,v),l.SCALE&&x.fromBufferAttribute(l.SCALE,v),y.setMatrixAt(v,g.compose(A,p,x));for(const v in l)if(v==="_COLOR_0"){const _=l[v];y.instanceColor=new w.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else v!=="TRANSLATION"&&v!=="ROTATION"&&v!=="SCALE"&&m.geometry.setAttribute(v,l[v]);w.Object3D.prototype.copy.call(y,m),this.parser.assignFinalMaterial(y),f.push(y)}return h.isGroup?(h.clear(),h.add(...f),h):f[0]}))}}const q0="glTF",xa=12,X0={JSON:1313821514,BIN:5130562};class OT{constructor(e){this.name=tt.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,xa),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!==q0)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-xa,r=new DataView(e,xa);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===X0.JSON){const c=new Uint8Array(e,xa+o,a);this.content=n.decode(c)}else if(l===X0.BIN){const c=xa+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class UT{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=tt.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,r=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const u=cf[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=cf[h]||h.toLowerCase();if(o[h]!==void 0){const d=n.accessors[e.attributes[h]],f=bo[d.componentType];c[u]=f.name,l[u]=d.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,d){i.decodeDracoFile(h,function(f){for(const m in f.attributes){const g=f.attributes[m],A=l[m];A!==void 0&&(g.normalized=A)}u(f)},a,c,w.LinearSRGBColorSpace,d)})})}}class NT{constructor(){this.name=tt.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 zT{constructor(){this.name=tt.KHR_MESH_QUANTIZATION}}class Y0 extends w.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[r+o];return t}interpolate_(e,t,n,i){const r=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,u=(n-t)/h,d=u*u,f=d*u,m=e*c,g=m-c,A=-2*f+3*d,p=f-d,x=1-A,y=p-d+u;for(let v=0;v!==a;v++){const _=o[g+v+a],E=o[g+v+l]*h,I=o[m+v+a],B=o[m+v]*h;r[v]=x*_+y*E+A*I+p*B}return r}}const GT=new w.Quaternion;class VT extends Y0{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return GT.fromArray(r).normalize().toArray(r),r}}const Vn={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},bo={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},K0={9728:w.NearestFilter,9729:w.LinearFilter,9984:w.NearestMipmapNearestFilter,9985:w.LinearMipmapNearestFilter,9986:w.NearestMipmapLinearFilter,9987:w.LinearMipmapLinearFilter},$0={33071:w.ClampToEdgeWrapping,33648:w.MirroredRepeatWrapping,10497:w.RepeatWrapping},lf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},cf={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"},Ms={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},QT={CUBICSPLINE:void 0,LINEAR:w.InterpolateLinear,STEP:w.InterpolateDiscrete},hf={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function jT(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new w.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:w.FrontSide})),s.DefaultMaterial}function fr(s,e,t){for(const n in t.extensions)s[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function wi(s,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(s.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function WT(s,e,t){let n=!1,i=!1,r=!1;for(let c=0,h=e.length;c<h;c++){const u=e[c];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(r=!0),n&&i&&r)break}if(!n&&!i&&!r)return Promise.resolve(s);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const u=e[c];if(n){const d=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(d)}if(i){const d=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(d)}if(r){const d=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;l.push(d)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],d=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=d),s.morphTargetsRelative=!0,s})}function HT(s,e){if(s.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)s.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(s.morphTargetInfluences.length===t.length){s.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)s.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function qT(s){let e;const t=s.extensions&&s.extensions[tt.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+uf(t.attributes):e=s.indices+":"+uf(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+uf(s.targets[n]);return e}function uf(s){let e="";const t=Object.keys(s).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+s[t[n]]+";";return e}function df(s){switch(s){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 XT(s){return s.search(/\.jpe?g($|\?)/i)>0||s.search(/^data\:image\/jpeg/)===0?"image/jpeg":s.search(/\.webp($|\?)/i)>0||s.search(/^data\:image\/webp/)===0?"image/webp":s.search(/\.ktx2($|\?)/i)>0||s.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const YT=new w.Matrix4;class KT{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new yT,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,r=!1,o=-1;if(typeof navigator<"u"&&typeof navigator.userAgent<"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,r=a.indexOf("Firefox")>-1,o=r?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||r&&o<98?this.textureLoader=new w.TextureLoader(this.options.manager):this.textureLoader=new w.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new w.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,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return fr(r,a,i),wi(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,r=t.length;i<r;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,r=e.length;i<r;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),r=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())r(h,a.children[c])};return r(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 r=e(t[i]);r&&n.push(r)}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(r){return r.loadNode&&r.loadNode(t)});break;case"mesh":i=this._invokeOne(function(r){return r.loadMesh&&r.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(r){return r.loadBufferView&&r.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(r){return r.loadMaterial&&r.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(r){return r.loadTexture&&r.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(r){return r.loadAnimation&&r.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.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(r,o){return n.getDependency(e,o)})),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[tt.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(w.LoaderUtils.resolveURL(t.uri,i.path),r,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,r=t.byteOffset||0;return n.slice(r,r+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=lf[i.type],a=bo[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new w.BufferAttribute(c,o,l))}const r=[];return i.bufferView!==void 0?r.push(this.getDependency("bufferView",i.bufferView)):r.push(null),i.sparse!==void 0&&(r.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),r.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(r).then(function(o){const a=o[0],l=lf[i.type],c=bo[i.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,d=i.byteOffset||0,f=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,m=i.normalized===!0;let g,A;if(f&&f!==u){const p=Math.floor(d/f),x="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+p+":"+i.count;let y=t.cache.get(x);y||(g=new c(a,p*f,i.count*f/h),y=new w.InterleavedBuffer(g,f/h),t.cache.add(x,y)),A=new w.InterleavedBufferAttribute(y,l,d%f/h,m)}else a===null?g=new c(i.count*l):g=new c(a,d,i.count*l),A=new w.BufferAttribute(g,l,m);if(i.sparse!==void 0){const p=lf.SCALAR,x=bo[i.sparse.indices.componentType],y=i.sparse.indices.byteOffset||0,v=i.sparse.values.byteOffset||0,_=new x(o[1],y,i.sparse.count*p),E=new c(o[2],v,i.sparse.count*l);a!==null&&(A=new w.BufferAttribute(A.array.slice(),A.itemSize,A.normalized)),A.normalized=!1;for(let I=0,B=_.length;I<B;I++){const M=_[I];if(A.setX(M,E[I*l]),l>=2&&A.setY(M,E[I*l+1]),l>=3&&A.setZ(M,E[I*l+2]),l>=4&&A.setW(M,E[I*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}A.normalized=m}return A})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,o=t.images[r];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,r,a)}loadTextureImage(e,t,n){const i=this,r=this.json,o=r.textures[e],a=r.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const d=(r.samplers||{})[o.sampler]||{};return h.magFilter=K0[d.magFilter]||w.LinearFilter,h.minFilter=K0[d.minFilter]||w.LinearMipmapLinearFilter,h.wrapS=$0[d.wrapS]||w.RepeatWrapping,h.wrapT=$0[d.wrapT]||w.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==w.NearestFilter&&h.minFilter!==w.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const d=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(d),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(d,f){let m=d;t.isImageBitmapLoader===!0&&(m=function(g){const A=new w.Texture(g);A.needsUpdate=!0,d(A)}),t.load(w.LoaderUtils.resolveURL(u,r.path),m,void 0,f)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),wi(u,o),u.userData.mimeType=o.mimeType||XT(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const r=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),r.extensions[tt.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[tt.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[tt.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),r.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new w.PointsMaterial,w.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 w.LineBasicMaterial,w.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||r||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),r&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),r&&(l.vertexColors=!0),o&&(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 w.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,r=n.materials[e];let o;const a={},l=r.extensions||{},c=[];if(l[tt.KHR_MATERIALS_UNLIT]){const u=i[tt.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new w.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const d=u.baseColorFactor;a.color.setRGB(d[0],d[1],d[2],w.LinearSRGBColorSpace),a.opacity=d[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,w.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(d){return d.getMaterialType&&d.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(d){return d.extendMaterialParams&&d.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=w.DoubleSide);const h=r.alphaMode||hf.OPAQUE;if(h===hf.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===hf.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==w.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new w.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==w.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==w.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new w.Color().setRGB(u[0],u[1],u[2],w.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==w.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,w.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return r.name&&(u.name=r.name),wi(u,r),t.associations.set(u,{materials:e}),r.extensions&&fr(i,u,r),u})}createUniqueName(e){const t=w.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 r(a){return n[tt.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return J0(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=qT(c),u=i[h];if(u)o.push(u.promise);else{let d;c.extensions&&c.extensions[tt.KHR_DRACO_MESH_COMPRESSION]?d=r(c):d=J0(new w.BufferGeometry,c,t),i[h]={primitive:c,promise:d},o.push(d)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,r=n.meshes[e],o=r.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?jT(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],u=[];for(let f=0,m=h.length;f<m;f++){const g=h[f],A=o[f];let p;const x=c[f];if(A.mode===Vn.TRIANGLES||A.mode===Vn.TRIANGLE_STRIP||A.mode===Vn.TRIANGLE_FAN||A.mode===void 0)p=r.isSkinnedMesh===!0?new w.SkinnedMesh(g,x):new w.Mesh(g,x),p.isSkinnedMesh===!0&&p.normalizeSkinWeights(),A.mode===Vn.TRIANGLE_STRIP?p.geometry=j0(p.geometry,w.TriangleStripDrawMode):A.mode===Vn.TRIANGLE_FAN&&(p.geometry=j0(p.geometry,w.TriangleFanDrawMode));else if(A.mode===Vn.LINES)p=new w.LineSegments(g,x);else if(A.mode===Vn.LINE_STRIP)p=new w.Line(g,x);else if(A.mode===Vn.LINE_LOOP)p=new w.LineLoop(g,x);else if(A.mode===Vn.POINTS)p=new w.Points(g,x);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+A.mode);Object.keys(p.geometry.morphAttributes).length>0&&HT(p,r),p.name=t.createUniqueName(r.name||"mesh_"+e),wi(p,r),A.extensions&&fr(i,p,A),t.assignFinalMaterial(p),u.push(p)}for(let f=0,m=u.length;f<m;f++)t.associations.set(u[f],{meshes:e,primitives:f});if(u.length===1)return r.extensions&&fr(i,u[0],r),u[0];const d=new w.Group;r.extensions&&fr(i,d,r),t.associations.set(d,{meshes:e});for(let f=0,m=u.length;f<m;f++)d.add(u[f]);return d})}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 w.PerspectiveCamera(w.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new w.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),wi(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,r=t.joints.length;i<r;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 r=i.pop(),o=i,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const u=o[c];if(u){a.push(u);const d=new w.Matrix4;r!==null&&d.fromArray(r.array,c*16),l.push(d)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new w.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],r=i.name?i.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let u=0,d=i.channels.length;u<d;u++){const f=i.channels[u],m=i.samplers[f.sampler],g=f.target,A=g.node,p=i.parameters!==void 0?i.parameters[m.input]:m.input,x=i.parameters!==void 0?i.parameters[m.output]:m.output;g.node!==void 0&&(o.push(this.getDependency("node",A)),a.push(this.getDependency("accessor",p)),l.push(this.getDependency("accessor",x)),c.push(m),h.push(g))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){const d=u[0],f=u[1],m=u[2],g=u[3],A=u[4],p=[];for(let y=0,v=d.length;y<v;y++){const _=d[y],E=f[y],I=m[y],B=g[y],M=A[y];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const C=n._createAnimationTracks(_,E,I,B,M);if(C)for(let P=0;P<C.length;P++)p.push(C[P])}const x=new w.AnimationClip(r,void 0,p);return wi(x,i),x})}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(r){const o=n._getNodeRef(n.meshCache,i.mesh,r);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],r=n._loadNodeShallow(e),o=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([r,Promise.all(o),l]).then(function(c){const h=c[0],u=c[1],d=c[2];d!==null&&h.traverse(function(f){f.isSkinnedMesh&&f.bind(d,YT)});for(let f=0,m=u.length;f<m;f++)h.add(u[f]);if(h.userData.pivot!==void 0&&u.length>0){const f=h.userData.pivot,m=u[0];h.pivot=new w.Vector3().fromArray(f),h.position.x-=f[0],h.position.y-=f[1],h.position.z-=f[2],m.position.set(0,0,0),delete h.userData.pivot}return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const r=t.nodes[e],o=r.name?i.createUniqueName(r.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),r.camera!==void 0&&a.push(i.getDependency("camera",r.camera).then(function(c){return i._getNodeRef(i.cameraCache,r.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(r.isBone===!0?h=new w.Bone:c.length>1?h=new w.Group:c.length===1?h=c[0]:h=new w.Object3D,h!==c[0])for(let u=0,d=c.length;u<d;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=o),wi(h,r),r.extensions&&fr(n,h,r),r.matrix!==void 0){const u=new w.Matrix4;u.fromArray(r.matrix),h.applyMatrix4(u)}else r.translation!==void 0&&h.position.fromArray(r.translation),r.rotation!==void 0&&h.quaternion.fromArray(r.rotation),r.scale!==void 0&&h.scale.fromArray(r.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(r.mesh!==void 0&&i.meshCache.refs[r.mesh]>1){const u=i.associations.get(h);i.associations.set(h,{...u})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,r=new w.Group;n.name&&(r.name=i.createUniqueName(n.name)),wi(r,n),n.extensions&&fr(t,r,n);const o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,u=l.length;h<u;h++){const d=l[h];d.parent!==null?r.add(AT(d)):r.add(d)}const c=h=>{const u=new Map;for(const[d,f]of i.associations)(d instanceof w.Material||d instanceof w.Texture)&&u.set(d,f);return h.traverse(d=>{const f=i.associations.get(d);f!=null&&u.set(d,f)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];Ms[r.path]===Ms.weights?e.traverse(function(d){d.morphTargetInfluences&&l.push(d.name?d.name:d.uuid)}):l.push(a);let c;switch(Ms[r.path]){case Ms.weights:c=w.NumberKeyframeTrack;break;case Ms.rotation:c=w.QuaternionKeyframeTrack;break;case Ms.translation:case Ms.scale:c=w.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=w.NumberKeyframeTrack;break;case 2:case 3:default:c=w.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?QT[i.interpolation]:w.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let d=0,f=l.length;d<f;d++){const m=new c(l[d]+"."+Ms[r.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(m),o.push(m)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=df(t.constructor),i=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r++)i[r]=t[r]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof w.QuaternionKeyframeTrack?VT:Y0;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $T(s,e,t){const n=e.attributes,i=new w.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new w.Vector3(l[0],l[1],l[2]),new w.Vector3(c[0],c[1],c[2])),a.normalized){const h=df(bo[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const r=e.targets;if(r!==void 0){const a=new w.Vector3,l=new w.Vector3;for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u.POSITION!==void 0){const d=t.json.accessors[u.POSITION],f=d.min,m=d.max;if(f!==void 0&&m!==void 0){if(l.setX(Math.max(Math.abs(f[0]),Math.abs(m[0]))),l.setY(Math.max(Math.abs(f[1]),Math.abs(m[1]))),l.setZ(Math.max(Math.abs(f[2]),Math.abs(m[2]))),d.normalized){const g=df(bo[d.componentType]);l.multiplyScalar(g)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new w.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function J0(s,e,t){const n=e.attributes,i=[];function r(o,a){return t.getDependency("accessor",o).then(function(l){s.setAttribute(a,l)})}for(const o in n){const a=cf[o]||o.toLowerCase();a in s.attributes||i.push(r(n[o],a))}if(e.indices!==void 0&&!s.index){const o=t.getDependency("accessor",e.indices).then(function(a){s.setIndex(a)});i.push(o)}return w.ColorManagement.workingColorSpace!==w.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${w.ColorManagement.workingColorSpace}" not supported.`),wi(s,e),$T(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?WT(s,e.targets,t):s})}var Ct=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.MeasureClick="measure-click",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(Ct||{});let ya=null,ba=null,Z0=null;const JT=8,ex=24,ZT=24,e2=64,t2=200,n2=10;function tx(){return new URL("draco/",document.baseURI).toString()}function nx(){return new URL("basis/",document.baseURI).toString()}function i2(){return ya==null&&(ya=new ZI,ya.setDecoderPath(tx()),ya.preload()),ya}function s2(s){return ba==null&&(ba=new Gn,ba.setTranscoderPath(nx())),Z0!==s&&(ba.detectSupport(s),Z0=s),ba}function r2(s){const e=new xT;return e.setDRACOLoader(i2()),e.setMeshoptDecoder(tT),s?.renderer?.capabilities!=null&&typeof s.renderer.getContext=="function"&&e.setKTX2Loader(s2(s.renderer)),e}function ix(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function o2(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function a2(s){return s?.engineStatus?.isFree===!1||o2()}async function $i(s,e,t){if(e)return t;const n=performance.now();return a2(s)||n-t>=JT?(await ix(),performance.now()):t}function l2(s,e){return new Promise((t,n)=>{Ec(s,i=>{if(i==null){n(new Error(`[loadLightModel] empty zip json: ${s}`));return}t(i)},()=>{n(new Error(`[loadLightModel] failed to load zip json: ${s}`))},e)})}function c2(s,e){return Et({method:"get",responseType:"arraybuffer",url:s}).then(async t=>{let n=t.data;return xo.isEncrypted(t.data)&&(n=await xo.decryptPzEnc(t.data,e)),zd.loadAsync(n)})}function sx(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function rx(s,e){const t=new Set(e.map(n=>sx(n)));for(const n of Object.keys(s.files))if(t.has(sx(n)))return s.files[n];return null}function ox(s,e){const t=rx(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function h2(s){return s.charCodeAt(0)===65279?s.slice(1):s}function ff(s){return JSON.parse(h2(s))}function u2(s,e){const t=rx(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function d2(s,e){return new Promise((t,n)=>{r2(s).parse(e,document.baseURI,t,n)})}function Tc(s,e){const t=s.models.find(n=>n.url==e);return t!=null&&t.group==null&&(t.group=sc(s,e)??ua(s,e)),t}function ax(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function f2(s){return ax(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function lx(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(n=>f2(n))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(Ct.LoadingCompleted,{}))}function cx(s){return s===!0||s==="loading"}function hx(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function p2(s,e,t){let n=performance.now();for(let i=0;i<e.length;i++){const r=e[i];r?.geometry!=null&&r.geometry.computeVertexNormals,(i+1)%ZT===0&&(n=await $i(s,t,n))}}async function g2(s,e,t){const n=[],i=[{node:e.octreeBox,visited:!1}];let r=performance.now();for(;i.length>0;){const o=i.pop();if(o==null||o.node==null||o.node.status===!0)continue;const a=o.node;if(o.visited){const c=Array.isArray(a.children)?a.children:[];(c.length===0||c.findIndex(h=>h.status!=!0)===-1)&&(a.status=!0),r=await $i(s,t,r);continue}i.push({node:a,visited:!0}),Array.isArray(a.elements)&&n.push(...a.elements);const l=Array.isArray(a.children)?a.children:[];for(let c=l.length-1;c>=0;c--)i.push({node:l[c],visited:!1});r=await $i(s,t,r)}return n}async function m2(s,e,t,n){const i=Tc(s,e.url);if(i?.nodesMap==null)return[];const r=await g2(s,t,n);console.log("[loadLightModel] pending mesh ids",t.path,r.length);const o=[];let a=performance.now(),l=0;for(const c of r){if(!i.nodesMap.has(c))continue;const h=i.nodesMap.get(c),u=Array.isArray(h?.infos)?h.infos:[];for(const d of u){const f=t.glbs?.[d.glb]?.[d.mesh];if(f?.geometry==null||f.material==null)continue;const m=new b.Matrix4;m.elements=d.matrix;const g=f.geometry.clone();g.applyMatrix4(m),g.computeBoundingBox();const A=new b.Mesh(g,f.material);d.box=g.boundingBox?.clone(),d.mesh=A,A.name=Number(c),A.glb=d.glb,A.url=e.url,g.attributes.position!=null&&o.push(A),l++,l%ex===0&&(a=await $i(s,n,a))}}return o}function A2(s,e,t,n,i){const r=_i(n.map(l=>l.geometry),!1),o=new b.Mesh(r,i);return o.castShadow=!0,o.receiveShadow=!0,ua(e,s).add(o),kd(e,o),o.url=s,o.glb=t,o.materialClone=i,o.geometrys=n.map(l=>l.geometry),o.geometry.computeVertexNormals(),o}function x2(s,e,t,n){return(sc(s,e)?.children??s.scene.children).find(o=>{const a=o;return o instanceof b.Mesh&&a.url==e&&a.glb==t&&a.materialClone===n})}function y2(s,e){const t=Array.isArray(s.geometrys)?s.geometrys:[],n=e.map(o=>o.geometry),i=[...t,...n],r=_i(i,!1);s.geometry!=null&&s.geometry.dispose(),s.geometry=r,s.geometrys=i,s.castShadow=!0,s.receiveShadow=!0}async function b2(s,e,t,n){const i=new Map;for(const a of t){const l=i.get(a.glb)??[];l.push(a),i.set(a.glb,l)}const r=Tc(e,s);let o=performance.now();for(const[a,l]of i.entries()){const c=n?l.length:t2;for(let h=0;h<l.length;h+=c){const u=l.slice(h,h+c);if(u.length===0)continue;const d=B2(u[0].material,e);let f=x2(e,s,a,d),m=0,g=0;f=null,f!=null?(m=Array.isArray(f.geometrys)?f.geometrys.length:0,g=hx(f.geometry),y2(f,u)):f=A2(s,e,a,u,d);const A=new Map;let p=g;u.forEach((x,y)=>{const v=Number(x.name),_=hx(x.geometry),E=A.get(v)??[];if(E.push([p,p+_]),A.set(v,E),r?.nodesMap?.has(v)){const I=r.nodesMap.get(v);I.indexes==null&&(I.indexes=[]),I.indexes.push([f.index,m+y,p,p+_])}p+=_}),f.indexes==null&&(f.indexes=new Map),A.forEach((x,y)=>{const v=f.indexes.get(y)??[];v.push(...x),f.indexes.set(y,v)}),o=await $i(e,n,o)}}}async function v2(s,e,t,n,i,r){if(n==null||i==null||i.length===0)return;const o=Tc(t,s);if(o==null)return;const a=new b.InstancedMesh(n.geometry,n.material,i.length);ua(t,s).add(a);const c=kd(t,a),h=new Float32Array(i.length*3);for(let f=0;f<i.length;f++)h[f*3]=1,h[f*3+1]=1,h[f*3+2]=1;a.instanceColor=new b.InstancedBufferAttribute(h,3);let u=performance.now();const d=[];for(let f=0;f<i.length;f++){const m=i[f],g=new b.Matrix4;if(g.elements=m.matrix,a.setMatrixAt(f,g),a.matrixs||(a.matrixs=[]),a.matrixs.push(g.clone()),d.push(g.clone()),o.nodesMap.has(m.id)){const A=o.nodesMap.get(m.id);A.indexes==null&&(A.indexes=[]),A.indexes.push([c,f,0,0])}else o.nodesMap.set(m.id,{instance:!0,info:m,indexes:[[c,f,0,0]]});(f+1)%e2===0&&(u=await $i(t,r,u))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.materialClone=n.material,a.url=s,a.glb=n.glb,a.ids=i.map(f=>f.id),a.matrixsClone=d,a.meshIndex=e}async function _2(s,e,t,n){const i=e.instanceNodes;if(i==null)return;let r=performance.now();for(const o in i)if(i[o].isLoaded!==!0){i[o].isLoaded=!0;for(const a of i[o]){const l=e.glbs?.[o]?.[a.mesh];l!=null&&await v2(s.url,a.mesh,t,l,a.children,n)}r=await $i(t,n,r)}}async function w2(s,e,t,n){if(t.status===!0||t.meshPromise!=null){await t.meshPromise;return}t.meshPromise=(async()=>{console.log(`[loadLightModel] start build lod meshes ${Date.now()-window.startTime}ms`);const i=await m2(s,e,t,n);await b2(e.url,s,i,n),await _2(e,t,s,n),t.status=!0,console.log(`[loadLightModel] *****************************************************finish build lod meshes ${Date.now()-window.startTime}ms`)})().finally(()=>{t.meshPromise=null}),await t.meshPromise}async function C2(s,e,t,n){if(t.loadSuccess!==!0){if(t.preparePromise!=null){await t.preparePromise;return}t.preparePromise=(async()=>{console.log("[loadLightModel] loading GLB bundle",t.path),t.glbs=t.glbs??{};const i=await c2(e.url+t.path,e.key),r=await ox(i,["/nodes.json","nodes.json"]);if(r==null)return;const o=ff(r),a=Tc(s,e.url);if(a==null)return;a.nodesMap==null&&(a.nodesMap=new Map);let l=performance.now();for(const h of Object.keys(o)){const u=o[h];for(let f=0;f<u.length;f++){const m=u[f];if(m.glb=h,a.nodesMap.has(m.id)===!1)a.nodesMap.set(m.id,{infos:[m]});else{if(!a.nodesMap.get(m.id).infos)continue;a.nodesMap.get(m.id).infos.push(m)}(f+1)%ex===0&&(l=await $i(s,n,l))}const d=await u2(i,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(d==null){console.error("[loadLightModel] glb not found in zip",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,availableFiles:Object.keys(i.files)});continue}try{const f=await d2(s,d);t.glbs[h]=f.scene.children,t.glbs[h].forEach(m=>{m.matrixWorld}),await p2(s,t.glbs[h],n)}catch(f){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:tx(),basisTranscoderPath:nx(),error:f})}l=await $i(s,n,l)}const c=await ox(i,["/instances.json","instances.json"]);t.instanceNodes=c!=null?ff(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function M2(s,e,t){if(t.boundingBox||(t.boundingBox=new b.Box3,t.boundingBox.min=new b.Vector3(t.octreeBox.min.X,t.octreeBox.min.Z,-t.octreeBox.min.Y),t.boundingBox.max=new b.Vector3(t.octreeBox.max.X,t.octreeBox.max.Z,-t.octreeBox.max.Y)),!t.maxSize)return 1e3;const n=t.boundingBox,i=n.min,r=n.max,o=i.clone().add(r.clone()).multiplyScalar(.5),a=i.distanceTo(r),l=new b.Vector3,c=new b.Vector3,h=new b.Vector3,u=new b.Vector3;if(e.getWorldDirection(h),e.getWorldPosition(u),e.matrixWorld.extractBasis(l,c,new b.Vector3),e instanceof b.OrthographicCamera){const p=Math.max((e.top-e.bottom)/e.zoom,1e-6),x=s?.cameraModule?.perspectiveCamera?.getEffectiveFOV?.()??20,y=b.MathUtils.degToRad(x*.5),v=y>0?p/(2*Math.tan(y)):p;u.copy(o).add(h.clone().multiplyScalar(-v))}if(u.distanceTo(o)<=a*.5)return 1e3;const d=o.clone().sub(u).dot(h);if(d<=0)return 0;const f=u.clone().add(h.multiplyScalar(Math.max(d,a))),m=f.clone().add(l.setLength(t.maxSize)),g=new vt(e,s.renderer,s.scene).worldToScreen(f),A=new vt(e,s.renderer,s.scene).worldToScreen(m);return g.distanceTo(A)}async function S2(s,e,t,n){t.maxSize<1e6&&t.path!="/lod0"&&(!(M2(s,s.camera,t)>=n2)||t.status===!0)||(await C2(s,e,t,n),t.loadSuccess===!0&&await w2(s,e,t,n))}function E2(s,e,t){if(cx(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await ix(),gT(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,lx(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)})}function I2(s,e,t,n){const i=ua(s,e);s.models||(s.models=[]),window.startTime=Date.now();let r="WDDsBNtzVz6aSh/bCFh3CmjjANEDRryoXF1XCJvJjeE=";l2(e+"/info",r).then(o=>{const a=ff(o);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:a,name:a.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1},key:r}),s.models.push({url:e,group:i,nodesMap:new Map,grids:a.modelGrid,levels:a.modelLevel,rooms:a.modelRoom,views:a.modelView,name:a.baseInfo.name,boundingBox:{min:new b.Vector3(a.baseInfo.min.X*.3048,a.baseInfo.min.Z*.3048,-a.baseInfo.min.Y*.3048),max:new b.Vector3(a.baseInfo.max.X*.3048,a.baseInfo.max.Z*.3048,-a.baseInfo.max.Y*.3048)}}),s.models.length==n&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{ux(s,null,!1)},100))}).catch(o=>{console.error("[loadLightModel] failed to load model info",{url:e,error:o})})}async function ux(s,e,t=!1){const n=s.engineStatus.models.filter(i=>e==null||i.url==e);for(const i of n)if(i.key="WDDsBNtzVz6aSh/bCFh3CmjjANEDRryoXF1XCJvJjeE=",ax(i),!(i.status!=="loading"||i.type!=="light")&&(E2(s,i,t),!cx(i.loadStatus.normal))){i.loadStatus.normal="loading";try{await T2(s,i,t)}finally{const r=Array.isArray(i.info?.lods)&&i.info.lods.every(o=>o.status===!0);i.loadStatus.normal=r,r&&(i.status="loaded"),lx(s)}}}async function T2(s,e,t=!1){if(console.log(`[loadLightModel] start loadNode ${Date.now()-window.startTime}ms`),!(e.info==null||e.info.lods==null))for(const n of e.info.lods)await S2(s,e,n,t)}function B2(s,e){return s.map!=null&&(s.map.colorSpace=b.SRGBColorSpace,s.map.needsUpdate=!0),s.side=b.DoubleSide,s.shadowSide=b.DoubleSide,s.clipShadows=!0,e?.sectionPlane&&(s.clippingPlanes=e.sectionPlane),s}class D2{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&I2(this.engine,i,t,e.length);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var Ss=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelError="model-error",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.Click="click",s.MouseMove="mouse-move",s.CameraChanged="camera-changed",s.CameraIdle="camera-idle",s.ViewportResize="viewport-resize",s.EngineFree="engine-free",s.EngineBusy="engine-busy",s.MeasureChanged="measure-changed",s.SectionMove="section-move",s.LoadingCompleted="loading_completed",s))(Ss||{});class P2{engine;isFree;isForceFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.isForceFree=!1,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(Ss.EngineFree,e=>{this.updateFree(!0),ux(this.engine,e,!1),this.engine?.octreeBox?.requestBvhBuild?.()}),this.engine.events.on(Ss.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let L2=class{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),r=i.indexOf(t);r!==-1?(i.splice(r,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((r,o)=>{try{r(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}};const Bc=1,pf=20,R2=5e3,k2=1.25,dx=500,F2=5e4;class O2{engine;lastShadowHalfSize=0;lastShadowFar=0;constructor(e){this.engine=e}init(){const e=new b.DirectionalLight(16777215,1);e.position.set(1,2,1),e.castShadow=!0,e.shadow.mapSize.width=1024,e.shadow.mapSize.height=1024,e.shadow.camera.near=.1,e.shadow.camera.far=100,e.shadow.bias=-5e-5,e.shadow.normalBias=.05;const t=pf;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2,e.shadow.intensity=Bc;const n=new b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n,this.engine.scene.dirLightShodow=e;const i=new b.AmbientLight(16777215,2);this.engine.scene.add(i)}updateShadowCameraRange(e){const t=this.getShadowDirectionalLight();if(!t||!(t.shadow.camera instanceof b.OrthographicCamera))return;const n=t.shadow.camera,i=this.getSceneBoundingBox();let r=0,o=0,a=null;if(i){const f=i.getSize(new b.Vector3);r=Math.max(f.x,f.y,f.z)*.5,o=Math.max(f.length(),1),a=i.getCenter(new b.Vector3)}const l=this.getCameraHalfExtent(e,a),c=b.MathUtils.clamp(Math.max(l*k2,r*.6,pf),pf,R2),h=b.MathUtils.clamp(Math.max(c*8,o*2,dx),dx,F2),u=Math.abs(c-this.lastShadowHalfSize)>.5,d=Math.abs(h-this.lastShadowFar)>1;!u&&!d||(n.left=-c,n.right=c,n.top=c,n.bottom=-c,n.near=.1,n.far=h,n.updateProjectionMatrix(),t.shadow.needsUpdate=!0,this.lastShadowHalfSize=c,this.lastShadowFar=h)}getShadowDirectionalLight(){const e=this.engine.scene;if(!e)return null;const t=e.dirLight;return t instanceof b.DirectionalLight&&t.castShadow?t:e.children.find(n=>n instanceof b.DirectionalLight&&n.castShadow)??null}getSceneBoundingBox(){const e=this.engine.octreeBox?.getBoundingBox?.();if(!e?.min||!e?.max)return null;const t=e.min,n=e.max;if(![t.x,t.y,t.z,n.x,n.y,n.z].every(Number.isFinite))return null;const r=new b.Box3(new b.Vector3(Math.min(t.x,n.x),Math.min(t.y,n.y),Math.min(t.z,n.z)),new b.Vector3(Math.max(t.x,n.x),Math.max(t.y,n.y),Math.max(t.z,n.z))),o=r.getSize(new b.Vector3);return o.lengthSq()<=1e-8||o.length()>1e7?null:r}getCameraHalfExtent(e,t){if(!e)return 0;if(e instanceof b.OrthographicCamera){const n=Math.max(e.zoom,1e-6),i=Math.max((e.top-e.bottom)/(2*n),1),r=Math.max((e.right-e.left)/(2*n),1);return Math.max(r,i)}if(e instanceof b.PerspectiveCamera){const n=this.resolveCameraTarget(e,t),i=Math.max(e.position.distanceTo(n),1),r=b.MathUtils.degToRad(e.getEffectiveFOV()*.5),o=Math.max(Math.tan(r)*i,1),a=o*Math.max(e.aspect,1e-6);return Math.max(a,o)}return 0}resolveCameraTarget(e,t){const n=this.engine.controls?.target;if(n instanceof b.Vector3)return n.clone();if(t)return t.clone();const i=new b.Vector3;return e.getWorldDirection(i),e.position.clone().add(i.multiplyScalar(10))}}class U2{engine;behavior;isCtrlDown=!1;isShiftDown=!1;hoverOldId=null;timeOutEvent;selectionBox=null;isBoxSelecting=!1;selectionStart=new b.Vector2;selectionEnd=new b.Vector2;suppressClickOnce=!1;selectionThreshold=5;tempInstanceMatrix=new b.Matrix4;tempScale=new b.Vector3;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.ensureSelectionBox(),this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.cancelBoxSelection(),this.behavior.disActive()}dispose(){this.clearHoverTimeout(),this.cancelBoxSelection(),this.clearHoverFeedback(),this.behavior?.disActive?.(),this.selectionBox?.remove(),this.selectionBox=null,this.isBoxSelecting=!1,this.suppressClickOnce=!1,this.behavior=null}handelKeyCtrlUp(){this.isCtrlDown=!1,this.isBoxSelecting&&this.cancelBoxSelection()}handelKeyCtrlDown(){this.isCtrlDown=!0}handelKeyShiftUp(){this.isShiftDown=!1}handelKeyShiftDown(){this.isShiftDown=!0}handleMouseDown(e){e.button!==0||!this.isBoxSelectionModifierDown()||(this.isBoxSelecting=!0,this.selectionStart.set(e.offsetX,e.offsetY),this.selectionEnd.copy(this.selectionStart),this.suppressClickOnce=!1,this.clearHoverFeedback(),this.updateSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!1))}handelKeyEscDown(){this.engine.modelToolModule.unhighlightAllModels()}handleMouseMove(e){if(this.clearHoverTimeout(),this.isBoxSelecting){this.selectionEnd.set(e.offsetX,e.offsetY),this.clearHoverFeedback(),this.updateSelectionBox();return}if(e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;const n=this.getCatchMeshs(e,!0);n!=null&&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}const t=this.getCatchMeshs(e);if(t!=null&&t.length>0){this.engine.hoverHighLight.hightMesh(t);return}e.catch==null&&this.engine.hoverHighLight.clearHighlight()}handleMouseUp(e){if(!this.isBoxSelecting)return;this.selectionEnd.set(e.offsetX,e.offsetY);const t=this.hasSelectionBox(),n=t?this.collectModelsInSelection():[];this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0),t&&(this.isBoxDeselectMode()?this.applyBoxDeselection(n):this.applyBoxSelection(n),this.suppressClickForCurrentTick())}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){const c=e.catch.object,h=e.catch.object.id,d=this.engine.models.find(g=>g.url==c.url)?.nodesMap?.get(h),f=new Map;d?.indexes.forEach(g=>{this.getSceneModel(g[0])instanceof b.InstancedMesh&&(f.has(g[0])||f.set(g[0],[]),f.get(g[0])?.push(g[1]))});const m=[];return f.forEach((g,A)=>{const p=this.getSceneModel(A);g.forEach(x=>{const y=p.geometry.clone();y.applyMatrix4(p.matrixs[x]),m.push(new b.Mesh(y,p.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),m)}const i=e.catch.object,r=i.name,l=this.engine.models.find(c=>c.url===i.url)?.nodesMap?.get(r)?.infos?.map(c=>c.mesh)??[];return this.hoverOldId==r?[]:(this.hoverOldId=r,t||this.engine.hoverHighLight.clearHighlight(),l)}handleMouseClick(e){if(this.suppressClickOnce){this.suppressClickOnce=!1;return}if(this.isShiftDown){if(e.catch!=null){const i=e.catch.object;this.applyBoxDeselection([{url:i.url,ids:[i.name]}])}return}if(e.catch!=null){const n=e.catch,i=n.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();const o=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(o)}this.engine.controlModule.orbitControls.origin.set(n.point.x,n.point.y,n.point.z),this.engine.modelToolModule.highlightModel([{url:i.url,ids:[i.name]}]),this.engine.events.trigger(Ct.Click,[{url:i.url,ids:[i.name]}]);const r=new CustomEvent("D3ElementClick",{detail:{id:i.name}});window.dispatchEvent(r);return}const t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(!e.catch){this.engine.controlModule?.orbitControls.enabled&&this.engine.viewCube.CameraGoHome(500);return}const t=e.catch;if(this.engine.controlModule?.firstPersonControls?.enabled===!0&&t.point instanceof b.Vector3){const l=this.engine.camera,c=l.position.clone();let h=t.point.clone();const u=500,d=performance.now();let f=h.clone().sub(c).normalize();h=h.clone().sub(f.clone().setLength(.5));const m=()=>{const g=performance.now()-d,A=Math.min(g/u,1),p=A<.5?2*A*A:1-Math.pow(-2*A+2,2)/2;l.position.lerpVectors(c,h,p),A<1?requestAnimationFrame(m):this.engine.controlModule.firstPersonControls.setCameraHeight(l.position.y)};requestAnimationFrame(m);return}const n=t.object,r=this.engine.models.find(l=>l.url===n.url)?.nodesMap?.get(n.name);if(!r)return;if(t.object.isInstance){const l=t.matrix,c=[];r.indexes.forEach(u=>{const d=this.getSceneModel(u[0]);d?.geometry?.boundingSphere||d?.geometry?.computeBoundingSphere?.();const f=d?.geometry?.boundingSphere;if(!f)return;const m=new b.Box3,g=f.center.clone().applyMatrix4(l),A=f.radius,p=new b.Vector3().setFromMatrixScale(l),x=A*Math.max(p.x,p.y,p.z)*.15;m.min.set(g.x-x,g.y-x,g.z-x),m.max.set(g.x+x,g.y+x,g.z+x),c.push(m)});const h=this.getMergedBox(c);h!=null&&this.engine.viewCube.zoomToModel(h);return}const o=r.infos.map(l=>l.box).filter(l=>l instanceof b.Box3),a=this.getMergedBox(o);a!=null&&this.engine.viewCube.zoomToModel(a)}handleMouseClickInstance(e){return e.intersectObjects(iA(this.engine),!0)}ensureSelectionBox(){if(this.selectionBox!=null)return;const e=document.createElement("div");e.style.position="absolute",e.style.left="0px",e.style.top="0px",e.style.display="none",e.style.pointerEvents="none",e.style.border="1px dashed #00aaff",e.style.backgroundColor="rgba(0, 170, 255, 0.12)",e.style.boxSizing="border-box",e.style.zIndex="1001",this.engine.container?.appendChild(e),this.selectionBox=e}updateSelectionBox(){if(this.selectionBox==null)return;if(!this.hasSelectionBox()){this.selectionBox.style.display="none";return}const e=this.getSelectionRect();this.selectionBox.style.display="block",this.selectionBox.style.left=`${e.left}px`,this.selectionBox.style.top=`${e.top}px`,this.selectionBox.style.width=`${e.right-e.left}px`,this.selectionBox.style.height=`${e.bottom-e.top}px`}hideSelectionBox(){this.selectionBox!=null&&(this.selectionBox.style.display="none")}cancelBoxSelection(){this.isBoxSelecting=!1,this.hideSelectionBox(),this.engine.controls&&(this.engine.controls.enabled=!0)}clearHoverTimeout(){this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null)}clearHoverFeedback(){this.hoverOldId=null,this.engine.hoverHighLight.clearHighlight(),this.engine.hoverHighLight.showModelNameTag(null,null)}suppressClickForCurrentTick(){this.suppressClickOnce=!0,setTimeout(()=>{this.suppressClickOnce=!1},0)}hasSelectionBox(){return Math.abs(this.selectionEnd.x-this.selectionStart.x)>=this.selectionThreshold&&Math.abs(this.selectionEnd.y-this.selectionStart.y)>=this.selectionThreshold}getSelectionRect(){return{left:Math.min(this.selectionStart.x,this.selectionEnd.x),top:Math.min(this.selectionStart.y,this.selectionEnd.y),right:Math.max(this.selectionStart.x,this.selectionEnd.x),bottom:Math.max(this.selectionStart.y,this.selectionEnd.y)}}isContainMode(){return this.selectionEnd.x>=this.selectionStart.x&&this.selectionEnd.y>=this.selectionStart.y}isBoxSelectionModifierDown(){return this.isCtrlDown}isBoxDeselectMode(){return this.isShiftDown}collectModelsInSelection(){const e=this.getSelectionRect(),t=this.isContainMode(),n=new Map,i=this.getIgnoredSelectionIdsByUrl();return this.engine.models?.forEach(r=>{if(!r?.url||!r?.nodesMap)return;const o=i.get(r.url);r.nodesMap.forEach((a,l)=>{if(o?.has(l))return;const c=this.getNodeWorldBox(a);if(!this.isBoxVisibleUnderClipping(c))return;const h=this.projectBoxToScreenRect(c);h==null||!(t?this.containsRect(e,h):this.intersectsRect(e,h))||(n.has(r.url)||n.set(r.url,new Set),n.get(r.url)?.add(l))})}),Array.from(n.entries()).map(([r,o])=>({url:r,ids:Array.from(o)}))}getIgnoredSelectionIdsByUrl(){const e=new Map,t=n=>{n?.forEach(i=>{e.has(i.url)||e.set(i.url,new Set),i.ids.forEach(r=>e.get(i.url)?.add(r))})};return t(this.engine.engineStatus.hideModels),t(this.engine.engineStatus.translucentModels),e}isBoxVisibleUnderClipping(e){if(e==null||e.isEmpty())return!1;const t=this.getActiveClippingPlanes();if(t.length===0)return!0;const n=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)];return t.every(i=>n.some(r=>i.distanceToPoint(r)>=-1e-4))}getActiveClippingPlanes(){const e=this.engine.clipping,t=Array.isArray(this.engine.sectionPlane)?this.engine.sectionPlane:[],n=e?.currentClippingMode;if(n==="box")return t.slice(0,6).filter(i=>i instanceof b.Plane);if(n==="x"||n==="y"||n==="z"||n==="face"){const i=t[6];return i instanceof b.Plane?[i]:[]}return[]}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(Ct.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(Ct.SelectionChanged,t))}excludeHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}keepHighlightedModels(e){const t=new Map;return(this.engine.engineStatus.highlightModels??[]).forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),e.map(n=>({url:n.url,ids:n.ids.filter(i=>t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}removeModelsFromHighlightState(e){const t=new Map;e.forEach(n=>{t.has(n.url)||t.set(n.url,new Set),n.ids.forEach(i=>t.get(n.url)?.add(i))}),this.engine.engineStatus.highlightModels=(this.engine.engineStatus.highlightModels??[]).map(n=>({url:n.url,ids:n.ids.filter(i=>!t.get(n.url)?.has(i))})).filter(n=>n.ids.length>0)}getNodeWorldBox(e){if(Array.isArray(e?.infos)&&e.infos.length>0){const t=e.infos.map(n=>n?.box).filter(n=>n instanceof b.Box3);return this.getMergedBox(t)}if(Array.isArray(e?.indexes)&&e.indexes.length>0){const t=[];return e.indexes.forEach(n=>{const i=this.getSceneModel(n[0]),r=this.getInstanceWorldBox(i,n[1]);r!=null&&t.push(r)}),this.getMergedBox(t)}return null}getInstanceWorldBox(e,t){if(!(e instanceof b.InstancedMesh))return null;e.geometry.boundingBox||e.geometry.computeBoundingBox();const n=e.geometry.boundingBox;if(!n)return null;if(typeof e.getMatrixAt=="function")e.getMatrixAt(t,this.tempInstanceMatrix);else if(e.matrixs?.[t])this.tempInstanceMatrix.copy(e.matrixs[t]);else return null;return this.tempScale.setFromMatrixScale(this.tempInstanceMatrix),Math.abs(this.tempScale.x)+Math.abs(this.tempScale.y)+Math.abs(this.tempScale.z)<1e-6?null:n.clone().applyMatrix4(this.tempInstanceMatrix)}projectBoxToScreenRect(e){if(e==null||e.isEmpty())return null;const t=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)];let n=1/0,i=1/0,r=-1/0,o=-1/0;return t.forEach(a=>{const l=new vt(this.engine.camera,this.engine.renderer,this.engine.scene).worldToScreen(a);!Number.isFinite(l.x)||!Number.isFinite(l.y)||(n=Math.min(n,l.x),i=Math.min(i,l.y),r=Math.max(r,l.x),o=Math.max(o,l.y))}),!Number.isFinite(n)||!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(o)?null:{left:n,top:i,right:r,bottom:o}}containsRect(e,t){return t.left>=e.left&&t.top>=e.top&&t.right<=e.right&&t.bottom<=e.bottom}intersectsRect(e,t){return!(t.right<e.left||t.left>e.right||t.bottom<e.top||t.top>e.bottom)}getMergedBox(e){if(e.length===0)return null;const t=new b.Box3().makeEmpty();return e.forEach(n=>t.union(n)),t.isEmpty()?null:t}getSceneModel(e){return Fd(this.engine,e)}}class N2{engine;highlightMaterial;translucentMaterial;customModelColorRecords;constructor(e){this.engine=e,this.customModelColorRecords=new Map,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!0,transparent:!0,opacity:.3,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane,this.engine.events?.on?.(Ss.EngineFree,()=>{this.restoreSplitModelsOnIdle()})}split_merge_model(e){if(e.isSplit||e instanceof b.InstancedMesh)return;e.geometry!=null&&(e.__mergedGeometryBackup=e.geometry);let t=e.material,n=_i(e.geometrys,!0);n.computeVertexNormals(),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){if(e==null||e instanceof b.InstancedMesh||e.isSplit!==!0||this.shouldKeepSplitState(e))return;const t=e.__mergedGeometryBackup;if(t!=null){const r=e.geometry;e.geometry=t,e.material=e.material[0],e.needsUpdate=!0,e.isSplit=!1,r&&r!==t&&typeof r.dispose=="function"&&r.dispose(),console.log("merge");return}if(!Array.isArray(e.geometrys)||e.geometrys.length===0)return;const n=e.geometry,i=_i(e.geometrys,!1);i!=null&&(i.computeVertexNormals(),e.geometry=i,e.material=e.material[0],e.needsUpdate=!0,e.isSplit=!1,n&&n!==i&&typeof n.dispose=="function"&&n.dispose(),console.log("merge"))}shouldKeepSplitState(e){const t=e?.geometry?.groups;return!Array.isArray(t)||t.length===0?!1:t.some(n=>(typeof n.materialIndex=="number"?n.materialIndex:0)!==0||n.visible===!1)}areAllGroupsHidden(e){const t=e?.geometry?.groups;return!Array.isArray(t)||t.length===0?!1:t.every(n=>{const i=typeof n.materialIndex=="number"?n.materialIndex:0;return n.visible===!1||i===-1})}getEngineModelByUrl(e){return this.engine.models.find(t=>t.url==e)}appendUniqueIds(e,t){if(!Array.isArray(e)||!Array.isArray(t)||t.length===0)return e;const n=new Set(e);return t.forEach(i=>{n.has(i)||(e.push(i),n.add(i))}),e}restoreSplitModelsOnIdle(){if(!this.engine?.scene)return;rc(this.engine,t=>t instanceof b.Mesh&&!(t instanceof b.InstancedMesh)).forEach(t=>{t instanceof b.Mesh&&(t.isSplit===!0&&(t.visible=!this.areAllGroupsHidden(t)),t.isSplit===!0&&this.un_split_merge_model(t))})}getSceneModel(e){return Fd(this.engine,e)}updateMaterial(){let e=0;this.engine.engineStatus.highlightModels?.forEach(t=>{e=e+t.ids.length}),e>20?(this.highlightMaterial.depthTest=!0,this.highlightMaterial.transparent=!1):(this.highlightMaterial.depthTest=!1,this.highlightMaterial.transparent=!0)}highlightModel(e){e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(o=>{let a=n.nodesMap.get(o);a!=null&&a.indexes!=null&&a.indexes.forEach(l=>{const c=this.getSceneModel(l[0]);c instanceof b.InstancedMesh?i.has(l[0])?i.get(l[0])?.push(l[1]):i.set(l[0],[l[1]]):(this.split_merge_model(c),c.geometry.groups[l[1]].materialIndex=1)})}),z2(i,this.engine);let r=this.engine.engineStatus.highlightModels.find(o=>o.url==t.url);r!=null?r.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)}),this.updateMaterial()}unhighlightModel(e){e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(r=>{let o=n.nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):l.geometry.groups.length!=0&&(l.geometry.groups[a[1]].materialIndex=0)})}),fx(i,this.engine,"highlightModel")}),this.updateMaterial()}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[]),this.updateMaterial()}hideModel(e){e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(o=>{let a=n.nodesMap.get(o);this.engine.modelEdge.hideModelEdge(t.url,o),a!=null&&a.indexes!=null&&a.indexes.forEach(l=>{const c=this.getSceneModel(l[0]);c instanceof b.InstancedMesh?i.has(l[0])?i.get(l[0])?.push(l[1]):i.set(l[0],[l[1]]):(this.split_merge_model(c),c.geometry.groups[l[1]].materialIndex=-1,c.geometry.groups[l[1]].visible=!1)})}),i.size>0&&V2(i,this.engine);let r=this.engine.engineStatus.hideModels.find(o=>o.url==t.url);r!=null?this.appendUniqueIds(r.ids,t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:[...new Set(t.ids)]}),this.engine.engineStatus.highlightModels=[]})}showModel(e,t=!1){e.forEach(n=>{const i=this.getEngineModelByUrl(n.url);if(i==null)return;let r=new Map;if(n.ids.forEach(a=>{let l=i.nodesMap.get(a);this.engine.modelEdge.showModelEdge(n.url,a),l!=null&&l.indexes!=null&&l.indexes.forEach(c=>{const h=this.getSceneModel(c[0]);h instanceof b.InstancedMesh?r.has(c[0])?r.get(c[0])?.push(c[1]):r.set(c[0],[c[1]]):(h.visible=!0,h.geometry.groups[c[1]].materialIndex=0,h.geometry.groups[c[1]].visible=!0)})}),r.size>0&&px(r,this.engine),t)return;let o=this.engine.engineStatus.hideModels.find(a=>a.url==n.url);o&&(n.ids.forEach(a=>{const l=o.ids.indexOf(a);l!==-1&&o.ids.splice(l,1)}),o.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(a=>a!==o)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},r=e.find(o=>o.url==n.url);for(let o of n.nodesMap)r==null?i.ids.push(o[0]):r.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t=16777215,n=1){const i=this.normalizeOpacity(n);if(e instanceof b.Mesh&&!(e instanceof b.InstancedMesh)){e.material?.color!=null&&(e.material.color.set(t),this.clearMaterialTextures(e.material),e.material.transparent=i<1,e.material.opacity=i,e.material.needsUpdate=!0);return}if(!Array.isArray(e))return;const r=new b.Color(t);e.forEach(o=>{const a=this.getEngineModelByUrl(o.url);a==null||!Array.isArray(o.ids)||o.ids.forEach(l=>{let c=a.nodesMap.get(l);c==null||c.indexes==null||c.indexes.forEach(h=>{const u=this.getSceneModel(h[0]);u instanceof b.InstancedMesh?this.setInstanceModelColor(o.url,l,u,h[0],h[1],r,i):u instanceof b.Mesh&&this.setSimpleModelColor(o.url,l,u,h[1],r,i)})})})}restoreModelColor(e){Array.isArray(e)&&e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);n==null||!Array.isArray(t.ids)||t.ids.forEach(i=>{let r=n.nodesMap.get(i);r==null||r.indexes==null||r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof b.InstancedMesh?this.restoreInstanceModelColor(t.url,i,a,o[0],o[1]):a instanceof b.Mesh&&this.restoreSimpleModelColor(t.url,i,a,o[0],o[1])})})})}setAllModelsColor(e,t=1){const n=[];this.engine.models.forEach(i=>{let r={url:i.url,ids:[]};for(let o of i.nodesMap)r.ids.push(o[0]);n.push(r)}),this.setModelColor(n,e,t)}restoreAllModelsColor(){Array.from(this.customModelColorRecords.keys()).forEach(e=>{const t=this.customModelColorRecords.get(e);if(t==null)return;const n=this.getSceneModel(t.meshIndex);t.type==="instance"&&n instanceof b.InstancedMesh?this.restoreInstanceColorRecord(n,t):t.type==="mesh"&&n instanceof b.Mesh&&this.restoreSimpleColorRecord(n,t),this.customModelColorRecords.delete(e)})}setSimpleModelColor(e,t,n,i,r,o){this.split_merge_model(n);const a=n.geometry?.groups?.[i];if(a==null)return;const l=this.getCustomColorRecordKey(e,t,n.index,i);this.customModelColorRecords.has(l)||this.customModelColorRecords.set(l,{type:"mesh",meshIndex:n.index,groupIndex:i,materialIndex:a.materialIndex??0}),a.materialIndex=this.getCustomColorMaterialIndex(n,r,o)}restoreSimpleModelColor(e,t,n,i,r){const o=this.getCustomColorRecordKey(e,t,i,r),a=this.customModelColorRecords.get(o);a!=null&&(this.restoreSimpleColorRecord(n,a),this.customModelColorRecords.delete(o))}restoreSimpleColorRecord(e,t){const n=e.geometry?.groups?.[t.groupIndex];n!=null&&(n.materialIndex=t.materialIndex??0,this.un_split_merge_model(e))}setInstanceModelColor(e,t,n,i,r,o,a){const l=this.getCustomColorRecordKey(e,t,i,r);if(this.customModelColorRecords.has(l))this.removeCustomInstanceClone(this.customModelColorRecords.get(l));else{const h=new b.Matrix4;n.getMatrixAt(r,h),this.customModelColorRecords.set(l,{type:"instance",meshIndex:i,instanceIndex:r,matrix:h.clone(),cloneModel:null})}const c=this.customModelColorRecords.get(l);this.hideOriginalInstance(n,r),c.cloneModel=this.createCustomInstanceClone(n,i,r,c.matrix,o,a),this.engine.scene.add(c.cloneModel)}restoreInstanceModelColor(e,t,n,i,r){const o=this.getCustomColorRecordKey(e,t,i,r),a=this.customModelColorRecords.get(o);a!=null&&(this.restoreInstanceColorRecord(n,a),this.customModelColorRecords.delete(o))}restoreInstanceColorRecord(e,t){this.removeCustomInstanceClone(t),t.matrix!=null&&(e.setMatrixAt(t.instanceIndex,t.matrix),e.instanceMatrix.needsUpdate=!0)}getCustomColorRecordKey(e,t,n,i){return`${e}|${t}|${n}|${i}`}getCustomColorMaterialIndex(e,t,n){const i=`${t.getHexString()}|${n}`;e.__customColorMaterialIndexes instanceof Map||(e.__customColorMaterialIndexes=new Map);const r=e.__customColorMaterialIndexes.get(i);if(typeof r=="number"&&Array.isArray(e.material)&&e.material[r]!=null)return r;typeof r=="number"&&e.__customColorMaterialIndexes.delete(i),Array.isArray(e.material)||(e.material=[e.material]);const o=Array.isArray(e.material)?e.material[0]:e.material,a=typeof o?.clone=="function"?o.clone():new b.MeshBasicMaterial;a.color!=null&&a.color.copy(t),this.clearMaterialTextures(a),a.transparent=n<1,a.opacity=n,a.depthWrite=n>=1,a.clippingPlanes=this.engine.sectionPlane,a.needsUpdate=!0,e.material.push(a);const l=e.material.length-1;return e.__customColorMaterialIndexes.set(i,l),l}hideOriginalInstance(e,t){const n=new b.Matrix4;n.makeScale(0,0,0),e.setMatrixAt(t,n),e.instanceMatrix.needsUpdate=!0}createCustomInstanceClone(e,t,n,i,r,o){const a=new b.MeshBasicMaterial({color:r,transparent:o<1,opacity:o,depthWrite:o>=1,side:b.DoubleSide});this.clearMaterialTextures(a),a.clippingPlanes=this.engine.sectionPlane,a.needsUpdate=!0;const l=new b.InstancedMesh(e.geometry,a,1);return l.name="customColorModel",l.key=t,l.url=e.url,l.ids=Array.isArray(e.ids)?[e.ids[n]]:[],l.matrixs=[i.clone()],l.setMatrixAt(0,i),l.instanceMatrix.needsUpdate=!0,l}removeCustomInstanceClone(e){const t=e?.cloneModel;t!=null&&(t.parent!=null&&t.parent.remove(t),t.material?.dispose!=null&&t.material.dispose(),e.cloneModel=null)}normalizeOpacity(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):1}clearMaterialTextures(e){["map","alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","lightMap","metalnessMap","normalMap","roughnessMap","specularMap"].forEach(t=>{t in e&&(e[t]=null)})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(o=>{let a=n.nodesMap.get(o);a!=null&&a.indexes!=null&&a.indexes.forEach(l=>{const c=this.getSceneModel(l[0]);c instanceof b.InstancedMesh?i.has(l[0])?i.get(l[0])?.push(l[1]):i.set(l[0],[l[1]]):(this.split_merge_model(c),c.geometry.groups[l[1]].materialIndex=2)})}),G2(i,this.engine);let r=this.engine.engineStatus.translucentModels.find(o=>o.url==t.url);r!=null?r.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=>{const n=this.getEngineModelByUrl(t.url);if(n==null)return;let i=new Map;t.ids.forEach(r=>{let o=n.nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?i.has(a[0])?i.get(a[0])?.push(a[1]):i.set(a[0],[a[1]]):(this.split_merge_model(l),l.geometry.groups[a[1]].materialIndex=0)})}),i.size>0&&px(i,this.engine),fx(i,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}hideAllModels(){let e=[];this.engine.models.forEach(t=>{let n={url:t.url,ids:[]};for(let i of t.nodesMap)n.ids.push(i[0]);e.push(n)}),this.unhighlightAllModels(),this.hideModel(e)}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels,!0),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 z2(s,e){s.forEach((t,n)=>{const i=va(e,n);if(!(i instanceof b.InstancedMesh))return;const r=i.geometry,o=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide});o.clippingPlanes=e.sectionPlane;const a=new b.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=n,a.ids=[],a.matrixs=[],a.url=i.url,t.forEach(u=>{a.ids.push(i.ids[u]),a.matrixs.push(i.matrixs[u])});const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((u,d)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(d,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function fx(s,e,t){s.forEach((n,i)=>{const r=va(e,i);if(!(r instanceof b.InstancedMesh))return;n.forEach(a=>{const l=r.matrixsClone[a];l&&r.setMatrixAt(a,l)}),r.instanceMatrix.needsUpdate=!0;const o=[];e.scene.traverse(a=>{a.key==i&&a.name==t&&o.push(a)}),o.forEach(a=>{e.scene.remove(a)})})}function G2(s,e){s.forEach((t,n)=>{const i=va(e,n);if(!(i instanceof b.InstancedMesh))return;const r=i.geometry,o=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide});o.clippingPlanes=e.sectionPlane;const a=new b.InstancedMesh(r,o,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((u,d)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(d,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function V2(s,e){const t=[];e.scene.traverse(n=>{n.name=="highlightModel"&&t.push(n)}),t.forEach(n=>{e.scene.remove(n)}),s.forEach((n,i)=>{const r=va(e,i);if(!(r instanceof b.InstancedMesh))return;const o=new Map,a=new b.Matrix4,l=new b.Matrix4;l.makeScale(0,0,0),n.forEach((c,h)=>{r.getMatrixAt(c,a),o.set(c,a.clone()),r.setMatrixAt(c,l)}),r.instanceMatrix.needsUpdate=!0})}function px(s,e){s.forEach((t,n)=>{const i=va(e,n);i instanceof b.InstancedMesh&&(t.forEach(r=>{const o=i.matrixs[r];o&&i.setMatrixAt(r,o)}),i.instanceMatrix.needsUpdate=!0)})}function va(s,e){return Fd(s,e)}const gx="advanced";class Q2{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch(gx)}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(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!0);break;case"advanced":this.setShadows(!0),this.setGTAO(!0),this.setSSAO(!1),this.setSaturation(!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 b.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(r=>r instanceof b.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 Dc{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]);if(i.infos&&i.infos.length>0){let a=i.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:b.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(r=>r?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const r of i){let o=r.geometry.clone();o.computeVertexNormals();const a=new b.Mesh(o,this.overlayMaterial);r.updateWorldMatrix(!0,!1),a.matrix.copy(r.matrixWorld),a.matrixAutoUpdate=!1,this.engine.scene.add(a),this.overlayMeshes.push(a)}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/Dc.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/Dc.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),e.geometry?.dispose?.();this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.tagDiv?.remove?.(),this.tagDiv=null,this.animState="idle"}}var Pc={exports:{}},j2=Pc.exports,mx;function W2(){return mx||(mx=1,(function(s,e){(function(t,n){s.exports=n()})(j2,function(){var t=function(){function n(f){return o.appendChild(f.dom),f}function i(f){for(var m=0;m<o.children.length;m++)o.children[m].style.display=m===f?"block":"none";r=f}var r=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(f){f.preventDefault(),i(++r%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var f=(performance||Date).now();if(u.update(f-a,200),f>l+1e3&&(h.update(1e3*c/(f-l),100),l=f,c=0,d)){var m=performance.memory;d.update(m.usedJSHeapSize/1048576,m.jsHeapSizeLimit/1048576)}return f},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,r){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,d=3*c,f=2*c,m=3*c,g=15*c,A=74*c,p=30*c,x=document.createElement("canvas");x.width=h,x.height=u,x.style.cssText="width:80px;height:48px";var y=x.getContext("2d");return y.font="bold "+9*c+"px Helvetica,Arial,sans-serif",y.textBaseline="top",y.fillStyle=r,y.fillRect(0,0,h,u),y.fillStyle=i,y.fillText(n,d,f),y.fillRect(m,g,A,p),y.fillStyle=r,y.globalAlpha=.9,y.fillRect(m,g,A,p),{dom:x,update:function(v,_){o=Math.min(o,v),a=Math.max(a,v),y.fillStyle=r,y.globalAlpha=1,y.fillRect(0,0,h,g),y.fillStyle=i,y.fillText(l(v)+" "+n+" ("+l(o)+"-"+l(a)+")",d,f),y.drawImage(x,m+c,g,A-c,p,m,g,A-c,p),y.fillRect(m+A-c,g,c,p),y.fillStyle=r,y.globalAlpha=.9,y.fillRect(m+A-c,g,c,l((1-v/_)*p))}}},t})})(Pc)),Pc.exports}var H2=W2();const Ax=hA(H2);var vo=Object.freeze({Linear:Object.freeze({None:function(s){return s},In:function(s){return s},Out:function(s){return s},InOut:function(s){return s}}),Quadratic:Object.freeze({In:function(s){return s*s},Out:function(s){return s*(2-s)},InOut:function(s){return(s*=2)<1?.5*s*s:-.5*(--s*(s-2)-1)}}),Cubic:Object.freeze({In:function(s){return s*s*s},Out:function(s){return--s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s:.5*((s-=2)*s*s+2)}}),Quartic:Object.freeze({In:function(s){return s*s*s*s},Out:function(s){return 1- --s*s*s*s},InOut:function(s){return(s*=2)<1?.5*s*s*s*s:-.5*((s-=2)*s*s*s-2)}}),Quintic:Object.freeze({In:function(s){return s*s*s*s*s},Out:function(s){return--s*s*s*s*s+1},InOut:function(s){return(s*=2)<1?.5*s*s*s*s*s:.5*((s-=2)*s*s*s*s+2)}}),Sinusoidal:Object.freeze({In:function(s){return 1-Math.sin((1-s)*Math.PI/2)},Out:function(s){return Math.sin(s*Math.PI/2)},InOut:function(s){return .5*(1-Math.sin(Math.PI*(.5-s)))}}),Exponential:Object.freeze({In:function(s){return s===0?0:Math.pow(1024,s-1)},Out:function(s){return s===1?1:1-Math.pow(2,-10*s)},InOut:function(s){return s===0?0:s===1?1:(s*=2)<1?.5*Math.pow(1024,s-1):.5*(-Math.pow(2,-10*(s-1))+2)}}),Circular:Object.freeze({In:function(s){return 1-Math.sqrt(1-s*s)},Out:function(s){return Math.sqrt(1- --s*s)},InOut:function(s){return(s*=2)<1?-.5*(Math.sqrt(1-s*s)-1):.5*(Math.sqrt(1-(s-=2)*s)+1)}}),Elastic:Object.freeze({In:function(s){return s===0?0:s===1?1:-Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI)},Out:function(s){return s===0?0:s===1?1:Math.pow(2,-10*s)*Math.sin((s-.1)*5*Math.PI)+1},InOut:function(s){return s===0?0:s===1?1:(s*=2,s<1?-.5*Math.pow(2,10*(s-1))*Math.sin((s-1.1)*5*Math.PI):.5*Math.pow(2,-10*(s-1))*Math.sin((s-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(s){var e=1.70158;return s===1?1:s*s*((e+1)*s-e)},Out:function(s){var e=1.70158;return s===0?0:--s*s*((e+1)*s+e)+1},InOut:function(s){var e=2.5949095;return(s*=2)<1?.5*(s*s*((e+1)*s-e)):.5*((s-=2)*s*((e+1)*s+e)+2)}}),Bounce:Object.freeze({In:function(s){return 1-vo.Bounce.Out(1-s)},Out:function(s){return s<1/2.75?7.5625*s*s:s<2/2.75?7.5625*(s-=1.5/2.75)*s+.75:s<2.5/2.75?7.5625*(s-=2.25/2.75)*s+.9375:7.5625*(s-=2.625/2.75)*s+.984375},InOut:function(s){return s<.5?vo.Bounce.In(s*2)*.5:vo.Bounce.Out(s*2-1)*.5+.5}}),generatePow:function(s){return s===void 0&&(s=4),s=s<Number.EPSILON?Number.EPSILON:s,s=s>1e4?1e4:s,{In:function(e){return Math.pow(e,s)},Out:function(e){return 1-Math.pow(1-e,s)},InOut:function(e){return e<.5?Math.pow(e*2,s)/2:(1-Math.pow(2-e*2,s))/2+.5}}}}),_a=function(){return performance.now()},q2=(function(){function s(){this._tweens={},this._tweensAddedDuringUpdate={}}return s.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},s.prototype.removeAll=function(){this._tweens={}},s.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},s.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},s.prototype.update=function(e,t){e===void 0&&(e=_a()),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 r=this._tweens[n[i]],o=!t;r&&r.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},s})(),gf={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=gf.Utils.Linear;return e<0?r(s[0],s[1],n):e>1?r(s[t],s[t-1],t-n):r(s[i],s[i+1>t?t:i+1],n-i)},Utils:{Linear:function(s,e,t){return(e-s)*t+s}}},xx=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),mf=new q2,X2=(function(){function s(e,t){t===void 0&&(t=mf),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=vo.Linear.None,this._interpolationFunction=gf.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=xx.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return s.prototype.getId=function(){return this._id},s.prototype.isPlaying=function(){return this._isPlaying},s.prototype.isPaused=function(){return this._isPaused},s.prototype.getDuration=function(){return this._duration},s.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},s.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},s.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},s.prototype.start=function(e,t){if(e===void 0&&(e=_a()),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 r in this._valuesEnd)i[r]=this._valuesEnd[r];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},s.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},s.prototype._setupProperties=function(e,t,n,i,r){for(var o in n){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[o]);if(!(c==="undefined"||c==="function")){if(h){var u=n[o];if(u.length===0)continue;for(var d=[a],f=0,m=u.length;f<m;f+=1){var g=this._handleRelativeValue(a,u[f]);if(isNaN(g)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}d.push(g)}h&&(n[o]=d)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var A=a;for(var p in A)t[o][p]=A[p];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var x={};for(var p in u)x[p]=u[p];n[o]=u=x}this._setupProperties(A,t[o],u,i[o],r)}else(typeof t[o]>"u"||r)&&(t[o]=a),l||(t[o]*=1),h?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},s.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},s.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},s.prototype.pause=function(e){return e===void 0&&(e=_a()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},s.prototype.resume=function(e){return e===void 0&&(e=_a()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},s.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},s.prototype.group=function(e){return e===void 0&&(e=mf),this._group=e,this},s.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},s.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},s.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},s.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},s.prototype.easing=function(e){return e===void 0&&(e=vo.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=gf.Linear),this._interpolationFunction=e,this},s.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},s.prototype.onStart=function(e){return this._onStartCallback=e,this},s.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},s.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},s.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},s.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},s.prototype.onStop=function(e){return this._onStopCallback=e,this},s.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=_a()),t===void 0&&(t=!0),this._isPaused)return!0;var r,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)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),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var A=Math.trunc(a/l),p=a-A*l,x=Math.min(p/n._duration,1);return x===0&&a===n._duration?1:x},u=h(),d=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,d),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var f=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=f);for(r in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[r]=="string"&&(this._valuesStartRepeat[r]=this._valuesStartRepeat[r]+parseFloat(this._valuesEnd[r])),this._yoyo&&this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*f,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var m=0,g=this._chainedTweens.length;m<g;m++)this._chainedTweens[m].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},s.prototype._updateProperties=function(e,t,n,i){for(var r in n)if(t[r]!==void 0){var o=t[r]||0,a=n[r],l=Array.isArray(e[r]),c=Array.isArray(a),h=!l&&c;h?e[r]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[r],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[r]=o+(a-o)*i))}},s.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},s.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},s})();xx.nextId;var Ci=mf;Ci.getAll.bind(Ci),Ci.removeAll.bind(Ci),Ci.add.bind(Ci),Ci.remove.bind(Ci),Ci.update.bind(Ci);var wa={Easing:vo,Tween:X2};const pr=new w.Raycaster,sn=new w.Vector3,Es=new w.Vector3,wt=new w.Quaternion,yx={X:new w.Vector3(1,0,0),Y:new w.Vector3(0,1,0),Z:new w.Vector3(0,0,1)},Af={type:"change"},bx={type:"mouseDown",mode:null},vx={type:"mouseUp",mode:null},_x={type:"objectChange"};class wx extends w.Controls{constructor(e,t=null){super(void 0,t);const n=new eB(this);this._root=n;const i=new tB;this._gizmo=i,n.add(i);const r=new nB;this._plane=r,n.add(r);const o=this;function a(y,v){let _=v;Object.defineProperty(o,y,{get:function(){return _!==void 0?_:v},set:function(E){_!==E&&(_=E,r[y]=E,i[y]=E,o.dispatchEvent({type:y+"-changed",value:E}),o.dispatchEvent(Af))}}),o[y]=v,r[y]=v,i[y]=v}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new w.Vector3,c=new w.Vector3,h=new w.Quaternion,u=new w.Quaternion,d=new w.Vector3,f=new w.Quaternion,m=new w.Vector3,g=new w.Vector3,A=new w.Vector3,p=0,x=new w.Vector3;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",h),a("worldQuaternionStart",u),a("cameraPosition",d),a("cameraQuaternion",f),a("pointStart",m),a("pointEnd",g),a("rotationAxis",A),a("rotationAngle",p),a("eye",x),this._offset=new w.Vector3,this._startNorm=new w.Vector3,this._endNorm=new w.Vector3,this._cameraScale=new w.Vector3,this._parentPosition=new w.Vector3,this._parentQuaternion=new w.Quaternion,this._parentQuaternionInv=new w.Quaternion,this._parentScale=new w.Vector3,this._worldScaleStart=new w.Vector3,this._worldQuaternionInv=new w.Quaternion,this._worldScale=new w.Vector3,this._positionStart=new w.Vector3,this._quaternionStart=new w.Quaternion,this._scaleStart=new w.Vector3,this._getPointer=Y2.bind(this),this._onPointerDown=$2.bind(this),this._onPointerHover=K2.bind(this),this._onPointerMove=J2.bind(this),this._onPointerUp=Z2.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&pr.setFromCamera(e,this.camera);const t=xf(this._gizmo.picker[this.mode],pr);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&pr.setFromCamera(e,this.camera);const t=xf(this._plane,pr,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,bx.mode=this.mode,this.dispatchEvent(bx)}}pointerMove(e){const t=this.axis,n=this.mode,i=this.object;let r=this.space;if(n==="scale"?r="local":(t==="E"||t==="XYZE"||t==="XYZ")&&(r="world"),i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&pr.setFromCamera(e,this.camera);const o=xf(this._plane,pr,!0);if(o){if(this.pointEnd.copy(o.point).sub(this.worldPositionStart),n==="translate")this._offset.copy(this.pointEnd).sub(this.pointStart),r==="local"&&t!=="XYZ"&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf("X")===-1&&(this._offset.x=0),t.indexOf("Y")===-1&&(this._offset.y=0),t.indexOf("Z")===-1&&(this._offset.z=0),r==="local"&&t!=="XYZ"?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(r==="local"&&(i.position.applyQuaternion(wt.copy(this._quaternionStart).invert()),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.position.applyQuaternion(this._quaternionStart)),r==="world"&&(i.parent&&i.position.add(sn.setFromMatrixPosition(i.parent.matrixWorld)),t.search("X")!==-1&&(i.position.x=Math.round(i.position.x/this.translationSnap)*this.translationSnap),t.search("Y")!==-1&&(i.position.y=Math.round(i.position.y/this.translationSnap)*this.translationSnap),t.search("Z")!==-1&&(i.position.z=Math.round(i.position.z/this.translationSnap)*this.translationSnap),i.parent&&i.position.sub(sn.setFromMatrixPosition(i.parent.matrixWorld)))),i.position.x=Math.max(this.minX,Math.min(this.maxX,i.position.x)),i.position.y=Math.max(this.minY,Math.min(this.maxY,i.position.y)),i.position.z=Math.max(this.minZ,Math.min(this.maxZ,i.position.z));else if(n==="scale"){if(t.search("XYZ")!==-1){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),Es.set(a,a,a)}else sn.copy(this.pointStart),Es.copy(this.pointEnd),sn.applyQuaternion(this._worldQuaternionInv),Es.applyQuaternion(this._worldQuaternionInv),Es.divide(sn),t.search("X")===-1&&(Es.x=1),t.search("Y")===-1&&(Es.y=1),t.search("Z")===-1&&(Es.z=1);i.scale.copy(this._scaleStart).multiply(Es),this.scaleSnap&&(t.search("X")!==-1&&(i.scale.x=Math.round(i.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Y")!==-1&&(i.scale.y=Math.round(i.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search("Z")!==-1&&(i.scale.z=Math.round(i.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n==="rotate"){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(sn.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;t==="XYZE"?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(sn.copy(this.rotationAxis).cross(this.eye))*a):(t==="X"||t==="Y"||t==="Z")&&(this.rotationAxis.copy(yx[t]),sn.copy(yx[t]),r==="local"&&sn.applyQuaternion(this.worldQuaternion),sn.cross(this.eye),sn.length()===0?l=!0:this.rotationAngle=this._offset.dot(sn.normalize())*a),(t==="E"||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),r==="local"&&t!=="E"&&t!=="XYZE"?(i.quaternion.copy(this._quaternionStart),i.quaternion.multiply(wt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(wt.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Af),this.dispatchEvent(_x)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(vx.mode=this.mode,this.dispatchEvent(vx)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Af),this.dispatchEvent(_x),this.pointStart.copy(this.pointEnd))}getRaycaster(){return pr}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}setColors(e,t,n,i){const r=this._gizmo.materialLib;r.xAxis.color.set(e),r.yAxis.color.set(t),r.zAxis.color.set(n),r.active.color.set(i),r.xAxisTransparent.color.set(e),r.yAxisTransparent.color.set(t),r.zAxisTransparent.color.set(n),r.activeTransparent.color.set(i),r.xAxis._color&&r.xAxis._color.set(e),r.yAxis._color&&r.yAxis._color.set(t),r.zAxis._color&&r.zAxis._color.set(n),r.active._color&&r.active._color.set(i),r.xAxisTransparent._color&&r.xAxisTransparent._color.set(e),r.yAxisTransparent._color&&r.yAxisTransparent._color.set(t),r.zAxisTransparent._color&&r.zAxisTransparent._color.set(n),r.activeTransparent._color&&r.activeTransparent._color.set(i)}}function Y2(s){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:s.button};{const e=this.domElement.getBoundingClientRect();return{x:(s.clientX-e.left)/e.width*2-1,y:-(s.clientY-e.top)/e.height*2+1,button:s.button}}}function K2(s){if(this.enabled)switch(s.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(s));break}}function $2(s){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(s.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(s)),this.pointerDown(this._getPointer(s)))}function J2(s){this.enabled&&this.pointerMove(this._getPointer(s))}function Z2(s){this.enabled&&(this.domElement.releasePointerCapture(s.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(s)))}function xf(s,e,t){const n=e.intersectObject(s,!0);for(let i=0;i<n.length;i++)if(n[i].object.visible||t)return n[i];return!1}const Lc=new w.Euler,mt=new w.Vector3(0,1,0),Cx=new w.Vector3(0,0,0),Mx=new w.Matrix4,Rc=new w.Quaternion,kc=new w.Quaternion,Mi=new w.Vector3,Sx=new w.Matrix4,Ca=new w.Vector3(1,0,0),gr=new w.Vector3(0,1,0),Ma=new w.Vector3(0,0,1),Fc=new w.Vector3,Sa=new w.Vector3,Ea=new w.Vector3;class eB extends w.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class tB extends w.Object3D{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new w.MeshBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new w.LineBasicMaterial({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),n=e.clone();n.opacity=.15;const i=t.clone();i.opacity=.5;const r=e.clone();r.color.setHex(16711680);const o=e.clone();o.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const h=e.clone();h.color.setHex(255),h.opacity=.5;const u=e.clone();u.opacity=.25;const d=e.clone();d.color.setHex(16776960),d.opacity=.25;const f=e.clone();f.color.setHex(16776960);const m=e.clone();m.color.setHex(7895160),this.materialLib={xAxis:r,yAxis:o,zAxis:a,active:f,xAxisTransparent:l,yAxisTransparent:c,zAxisTransparent:h,activeTransparent:d};const g=new w.CylinderGeometry(0,.04,.1,12);g.translate(0,.05,0);const A=new w.BoxGeometry(.08,.08,.08);A.translate(0,.04,0);const p=new w.BufferGeometry;p.setAttribute("position",new w.Float32BufferAttribute([0,0,0,1,0,0],3));const x=new w.CylinderGeometry(.0075,.0075,.5,3);x.translate(0,.25,0);function y(F,N){const j=new w.TorusGeometry(F,.0075,3,64,N*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}function v(){const F=new w.BufferGeometry;return F.setAttribute("position",new w.Float32BufferAttribute([0,0,0,1,1,1],3)),F}const _={X:[[new w.Mesh(g,r),[.5,0,0],[0,0,-Math.PI/2]],[new w.Mesh(g,r),[-.5,0,0],[0,0,Math.PI/2]],[new w.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new w.Mesh(g,o),[0,.5,0]],[new w.Mesh(g,o),[0,-.5,0],[Math.PI,0,0]],[new w.Mesh(x,o)]],Z:[[new w.Mesh(g,a),[0,0,.5],[Math.PI/2,0,0]],[new w.Mesh(g,a),[0,0,-.5],[-Math.PI/2,0,0]],[new w.Mesh(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.OctahedronGeometry(.1,0),u),[0,0,0]]],XY:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]]},E={X:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.OctahedronGeometry(.2,0),n)]],XY:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]]},I={START:[[new w.Mesh(new w.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],END:[[new w.Mesh(new w.OctahedronGeometry(.01,2),i),null,null,null,"helper"]],DELTA:[[new w.Line(v(),i),null,null,null,"helper"]],X:[[new w.Line(p,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new w.Line(p,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new w.Line(p,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},B={XYZE:[[new w.Mesh(y(.5,1),m),null,[0,Math.PI/2,0]]],X:[[new w.Mesh(y(.5,.5),r)]],Y:[[new w.Mesh(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new w.Mesh(y(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new w.Mesh(y(.75,1),d),null,[0,Math.PI/2,0]]]},M={AXIS:[[new w.Line(p,i),[-1e3,0,0],null,[1e6,1,1],"helper"]]},C={XYZE:[[new w.Mesh(new w.SphereGeometry(.25,10,8),n)]],X:[[new w.Mesh(new w.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new w.Mesh(new w.TorusGeometry(.5,.1,4,24),n),[0,0,0],[Math.PI/2,0,0]]],Z:[[new w.Mesh(new w.TorusGeometry(.5,.1,4,24),n),[0,0,0],[0,0,-Math.PI/2]]],E:[[new w.Mesh(new w.TorusGeometry(.75,.1,2,24),n)]]},P={X:[[new w.Mesh(A,r),[.5,0,0],[0,0,-Math.PI/2]],[new w.Mesh(x,r),[0,0,0],[0,0,-Math.PI/2]],[new w.Mesh(A,r),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new w.Mesh(A,o),[0,.5,0]],[new w.Mesh(x,o)],[new w.Mesh(A,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new w.Mesh(A,a),[0,0,.5],[Math.PI/2,0,0]],[new w.Mesh(x,a),[0,0,0],[Math.PI/2,0,0]],[new w.Mesh(A,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),h),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.BoxGeometry(.1,.1,.1),u)]]},T={X:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[.3,0,0],[0,0,-Math.PI/2]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,.3,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,-.3,0],[0,0,Math.PI]]],Z:[[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,.3],[Math.PI/2,0,0]],[new w.Mesh(new w.CylinderGeometry(.2,0,.6,4),n),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,.15,0]]],YZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.01),n),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new w.Mesh(new w.BoxGeometry(.2,.2,.2),n),[0,0,0]]]},R={X:[[new w.Line(p,i),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new w.Line(p,i),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new w.Line(p,i),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function S(F){const N=new w.Object3D;for(const j in F)for(let q=F[j].length;q--;){const U=F[j][q][0].clone(),H=F[j][q][1],z=F[j][q][2],G=F[j][q][3],re=F[j][q][4];U.name=j,U.tag=re,H&&U.position.set(H[0],H[1],H[2]),z&&U.rotation.set(z[0],z[1],z[2]),G&&U.scale.set(G[0],G[1],G[2]),U.updateMatrix();const le=U.geometry.clone();le.applyMatrix4(U.matrix),U.geometry=le,U.renderOrder=1/0,U.position.set(0,0,0),U.rotation.set(0,0,0),U.scale.set(1,1,1),N.add(U)}return N}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=S(_)),this.add(this.gizmo.rotate=S(B)),this.add(this.gizmo.scale=S(P)),this.add(this.picker.translate=S(E)),this.add(this.picker.rotate=S(C)),this.add(this.picker.scale=S(T)),this.add(this.helper.translate=S(I)),this.add(this.helper.rotate=S(M)),this.add(this.helper.scale=S(R)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const n=(this.mode==="scale"?"local":this.space)==="local"?this.worldQuaternion:kc;this.gizmo.translate.visible=this.mode==="translate",this.gizmo.rotate.visible=this.mode==="rotate",this.gizmo.scale.visible=this.mode==="scale",this.helper.translate.visible=this.mode==="translate",this.helper.rotate.visible=this.mode==="rotate",this.helper.scale.visible=this.mode==="scale";let i=[];i=i.concat(this.picker[this.mode].children),i=i.concat(this.gizmo[this.mode].children),i=i.concat(this.helper[this.mode].children);for(let r=0;r<i.length;r++){const o=i[r];o.visible=!0,o.rotation.set(0,0,0),o.position.copy(this.worldPosition);let a;if(this.camera.isOrthographicCamera?a=(this.camera.top-this.camera.bottom)/this.camera.zoom:a=this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),o.scale.set(1,1,1).multiplyScalar(a*this.size/4),o.tag==="helper"){o.visible=!1,o.name==="AXIS"?(o.visible=!!this.axis,this.axis==="X"&&(wt.setFromEuler(Lc.set(0,0,0)),o.quaternion.copy(n).multiply(wt),Math.abs(mt.copy(Ca).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Y"&&(wt.setFromEuler(Lc.set(0,0,Math.PI/2)),o.quaternion.copy(n).multiply(wt),Math.abs(mt.copy(gr).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="Z"&&(wt.setFromEuler(Lc.set(0,Math.PI/2,0)),o.quaternion.copy(n).multiply(wt),Math.abs(mt.copy(Ma).applyQuaternion(n).dot(this.eye))>.9&&(o.visible=!1)),this.axis==="XYZE"&&(wt.setFromEuler(Lc.set(0,Math.PI/2,0)),mt.copy(this.rotationAxis),o.quaternion.setFromRotationMatrix(Mx.lookAt(Cx,mt,gr)),o.quaternion.multiply(wt),o.visible=this.dragging),this.axis==="E"&&(o.visible=!1)):o.name==="START"?(o.position.copy(this.worldPositionStart),o.visible=this.dragging):o.name==="END"?(o.position.copy(this.worldPosition),o.visible=this.dragging):o.name==="DELTA"?(o.position.copy(this.worldPositionStart),o.quaternion.copy(this.worldQuaternionStart),sn.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),sn.applyQuaternion(this.worldQuaternionStart.clone().invert()),o.scale.copy(sn),o.visible=this.dragging):(o.quaternion.copy(n),this.dragging?o.position.copy(this.worldPositionStart):o.position.copy(this.worldPosition),this.axis&&(o.visible=this.axis.search(o.name)!==-1));continue}o.quaternion.copy(n),this.mode==="translate"||this.mode==="scale"?(o.name==="X"&&Math.abs(mt.copy(Ca).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Y"&&Math.abs(mt.copy(gr).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="Z"&&Math.abs(mt.copy(Ma).applyQuaternion(n).dot(this.eye))>.99&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XY"&&Math.abs(mt.copy(Ma).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="YZ"&&Math.abs(mt.copy(Ca).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1),o.name==="XZ"&&Math.abs(mt.copy(gr).applyQuaternion(n).dot(this.eye))<.2&&(o.scale.set(1e-10,1e-10,1e-10),o.visible=!1)):this.mode==="rotate"&&(Rc.copy(n),mt.copy(this.eye).applyQuaternion(wt.copy(n).invert()),o.name.search("E")!==-1&&o.quaternion.setFromRotationMatrix(Mx.lookAt(this.eye,Cx,gr)),o.name==="X"&&(wt.setFromAxisAngle(Ca,Math.atan2(-mt.y,mt.z)),wt.multiplyQuaternions(Rc,wt),o.quaternion.copy(wt)),o.name==="Y"&&(wt.setFromAxisAngle(gr,Math.atan2(mt.x,mt.z)),wt.multiplyQuaternions(Rc,wt),o.quaternion.copy(wt)),o.name==="Z"&&(wt.setFromAxisAngle(Ma,Math.atan2(mt.y,mt.x)),wt.multiplyQuaternions(Rc,wt),o.quaternion.copy(wt))),o.visible=o.visible&&(o.name.indexOf("X")===-1||this.showX),o.visible=o.visible&&(o.name.indexOf("Y")===-1||this.showY),o.visible=o.visible&&(o.name.indexOf("Z")===-1||this.showZ),o.visible=o.visible&&(o.name.indexOf("E")===-1||this.showX&&this.showY&&this.showZ),o.material._color=o.material._color||o.material.color.clone(),o.material._opacity=o.material._opacity||o.material.opacity,o.material.color.copy(o.material._color),o.material.opacity=o.material._opacity,this.enabled&&this.axis&&(o.name===this.axis?(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1):this.axis.split("").some(function(l){return o.name===l})&&(o.material.color.copy(this.materialLib.active.color),o.material.opacity=1))}super.updateMatrixWorld(e)}}class nB extends w.Mesh{constructor(){super(new w.PlaneGeometry(1e5,1e5,2,2),new w.MeshBasicMaterial({visible:!1,wireframe:!0,side:w.DoubleSide,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode==="scale"&&(t="local"),Fc.copy(Ca).applyQuaternion(t==="local"?this.worldQuaternion:kc),Sa.copy(gr).applyQuaternion(t==="local"?this.worldQuaternion:kc),Ea.copy(Ma).applyQuaternion(t==="local"?this.worldQuaternion:kc),mt.copy(Sa),this.mode){case"translate":case"scale":switch(this.axis){case"X":mt.copy(this.eye).cross(Fc),Mi.copy(Fc).cross(mt);break;case"Y":mt.copy(this.eye).cross(Sa),Mi.copy(Sa).cross(mt);break;case"Z":mt.copy(this.eye).cross(Ea),Mi.copy(Ea).cross(mt);break;case"XY":Mi.copy(Ea);break;case"YZ":Mi.copy(Fc);break;case"XZ":mt.copy(Ea),Mi.copy(Sa);break;case"XYZ":case"E":Mi.set(0,0,0);break}break;case"rotate":default:Mi.set(0,0,0)}Mi.length()===0?this.quaternion.copy(this.cameraQuaternion):(Sx.lookAt(sn.set(0,0,0),Mi,mt),this.quaternion.setFromRotationMatrix(Sx)),super.updateMatrixWorld(e)}}class iB extends w.DataTextureLoader{constructor(e){super(e),this.type=w.HalfFloatType}parse(e){const o=function(B,M){switch(B){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(M||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(M||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(M||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(M||""))}},u=function(B,M,C){M=M||1024;let T=B.pos,R=-1,S=0,F="",N=String.fromCharCode.apply(null,new Uint16Array(B.subarray(T,T+128)));for(;0>(R=N.indexOf(`
|
|
4942
4942
|
`))&&S<M&&T<B.byteLength;)F+=N,S+=N.length,T+=128,N+=String.fromCharCode.apply(null,new Uint16Array(B.subarray(T,T+128)));return-1<R?(B.pos+=S+R+1,F+N.slice(0,R)):!1},d=function(B){const M=/^#\?(\S+)/,C=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,P=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,T=/^\s*FORMAT=(\S+)\s*$/,R=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,S={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let F,N;for((B.pos>=B.byteLength||!(F=u(B)))&&o(1,"no header found"),(N=F.match(M))||o(3,"bad initial token"),S.valid|=1,S.programtype=N[1],S.string+=F+`
|
|
4943
4943
|
`;F=u(B),F!==!1;){if(S.string+=F+`
|
|
4944
4944
|
`,F.charAt(0)==="#"){S.comments+=F+`
|
|
@@ -5550,7 +5550,7 @@ ${JSON.stringify(l,null,2)}
|
|
|
5550
5550
|
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
5551
5551
|
<path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
|
|
5552
5552
|
<path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
|
|
5553
|
-
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),r=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-r.left+"px",e.style.top=i.top-r.top+"px",e.style.right="auto",e.style.bottom="auto";const o=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-o-r.left+"px",e.style.top=h.clientY-a-r.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class Ly{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new WP(t,this))}_loadLayers(e=this.engine.dwgData?.layers??[]){this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t});this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}getDisplayColor(e){return this.engine.modelToolModule2d?.getDisplayColor(e)??e}refresh(){this.panelUI?.refresh()}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t),t||this.clearInteractiveStateForLayer(e)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}isLayerVisible(e){return e?this.layerMap.get(e)?.visible!==!1:!0}isModelVisibleByLayer(e){const t=this.engine.loaderModule2d?.model?.nodeMap?.get(String(e))??this.engine.loaderModule2d?.model?.nodeMap?.get(e);return!t||t.length===0?!0:t.some(n=>{const i=this.getNodeObject(n);return this.isLayerVisible(n?.layer)&&i?.visible!==!1})}_applyVisibility(e,t){const n=this.engine?.modelGroup??this.engine?.scene;if(!n)return;const i=e+"||";n.traverse(r=>{r.name?.startsWith(i)&&(r.visible=t)})}getNodeObject(e){return e?.object??e?.group?.children?.[e.indexes?.[0]]??this.engine.modelGroup?.children?.[e.indexes?.[0]]}clearInteractiveStateForLayer(e){const t=[...this.engine.engineStatus2d?.highlightModels??[],...this.engine.engineStatus2d?.highlightHoverModels??[]];t.length===0||!t.some(i=>(this.engine.loaderModule2d?.model?.nodeMap?.get(String(i))??this.engine.loaderModule2d?.model?.nodeMap?.get(i))?.some(o=>o?.layer===e))||(this.engine.modelToolModule2d?.unHighlightModelHover?.(),this.engine.modelToolModule2d?.unhighlightAllModels?.())}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}var li=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelLoadError="model-load-error",s.RenderStart="render-start",s.RenderEnd="render-end",s.CameraChanged="camera-changed",s.CameraReset="camera-reset",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.EntityClick="entity-click",s.LayerVisibilityChanged="layer-visibility-changed",s.LayerColorChanged="layer-color-changed",s.ViewZoomChanged="view-zoom-changed",s.ViewPanChanged="view-pan-changed",s.ToolActivated="tool-activated",s.ToolDeactivated="tool-deactivated",s.Error="error",s.Warning="warning",s))(li||{});class HP{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(li).forEach(t=>{this.listeners.set(t,new Set),this.onceListeners.set(t,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const n=this.listeners.get(e);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const n=this.listeners.get(e);n&&n.size>0&&n.forEach(r=>{try{r(t)}catch(o){console.error(`[EventModule2d] Error in listener for ${e}:`,o)}});const i=this.onceListeners.get(e);i&&i.size>0&&(i.forEach(r=>{try{r(t)}catch(o){console.error(`[EventModule2d] Error in once listener for ${e}:`,o)}}),i.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);t&&t.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);return(t?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(li)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}function ks(s){return Array.isArray(s)?new b.Vector3(s[0]??0,s[1]??0,s[2]??0):new b.Vector3(s?.x??0,s?.y??0,s?.z??0)}function Mr(s){return s?(s.computeBoundingBox(),{min:s.boundingBox?.min.clone()??new b.Vector3,max:s.boundingBox?.max.clone()??new b.Vector3}):{min:new b.Vector3,max:new b.Vector3}}function cp(s,e,t){const n=new b.Vector3(s[0]??0,s[1]??0,s[2]??0),i=new b.Euler(0,0,t??0),r=new b.Vector3(e[0]??1,e[1]??1,e[2]??1),o=new b.Quaternion().setFromEuler(i);return new b.Matrix4().compose(n,o,r)}function qP(s){return Array.isArray(s?.transformMatrix)&&s.transformMatrix.length===16?new b.Matrix4().fromArray(s.transformMatrix):cp(s.position??[0,0,0],s.scale??[1,1,1],s.rotation??0)}function Ry(s){if(s.length===0)return{min:new b.Vector3,max:new b.Vector3};const e=new b.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),t=new b.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return s.forEach(n=>{e.x=Math.min(e.x,n.x),e.y=Math.min(e.y,n.y),e.z=Math.min(e.z,n.z),t.x=Math.max(t.x,n.x),t.y=Math.max(t.y,n.y),t.z=Math.max(t.z,n.z)}),{min:e,max:t}}class XP{constructor(e){this.geometryFactory=e}cache=new Map;blockIndex=new Map;setBlocks(e){this.cache.clear(),this.blockIndex.clear(),(e??[]).forEach(t=>{t?.name&&this.blockIndex.set(t.name,t),t?.id&&this.blockIndex.set(t.id,t)})}clearCache(){this.cache.clear()}flattenRootEntities(e){return Array.from(this.iterateRootEntities(e))}*iterateRootEntities(e){yield*this.iterateEntities(e??[],new b.Matrix4,0)}flattenBlock(e,t,n){const i=this.cache.get(t);if(i)return i;const r=e.origin??[0,0,0],o=new b.Matrix4().makeTranslation(-r[0],-r[1],-(r[2]??0)),a=this.flattenEntities(e.entities??[],o,n);return this.cache.set(t,a),e.name&&this.cache.set(e.name,a),e.id&&this.cache.set(e.id,a),a}flattenEntities(e,t,n){return Array.from(this.iterateEntities(e,t,n))}*iterateEntities(e,t,n){if(n>20){console.warn("[LoaderModule2d] Block nesting is too deep, skip nested INSERT.");return}for(const i of e)if(i?.visible!==!1){if(i.type==="INSERT"){const r=this.getBlockItems(i.blockId,n+1),o=t.clone().multiply(qP(i)),a=this.getClipPolygon(i,t);for(const l of r){const c=this.cloneRenderItem(l,o,i),h=a?this.clipRenderItem(c,a):c;h&&(yield h)}a&&i.displayClipBoundary===!0&&(yield this.createClipBoundaryItem(i,a));continue}for(const r of this.geometryFactory.create(i,t))yield r}}getBlockItems(e,t){const n=this.cache.get(e);if(n)return n;const i=this.blockIndex.get(e);return i?this.flattenBlock(i,i.name??i.id??e,t):(console.warn(`[LoaderModule2d] Missing block: ${e}`),[])}cloneRenderItem(e,t,n){const i=e.layer==="0"&&n?.layer?n.layer:e.layer??n?.layer,r=e.color==null||e.color===0?n?.color??e.color??0:e.color,o=n?.linkId??n?.id??e.linkId;if(e.kind==="line")return{...e,layer:i,color:r,linkId:o,points:(e.points??[]).map(h=>h.clone().applyMatrix4(t))};const a=e.geometry?.clone();a?.applyMatrix4(t);const l=e.textAnchor?.clone().applyMatrix4(t),c=Mr(a);return{...e,layer:i,color:r,linkId:o,geometry:a,min:c.min,max:c.max,textAnchor:l}}getClipPolygon(e,t){if(e?.clipping!==!0||!Array.isArray(e?.clipBoundary))return null;const n=e.clipBoundary.map(r=>new b.Vector3(r?.[0]??r?.x??0,r?.[1]??r?.y??0,r?.[2]??r?.z??0)).filter(r=>Number.isFinite(r.x)&&Number.isFinite(r.y));if(n.length<3)return null;const i=this.getClipBoundaryMatrix(e,t);return i?n.map(r=>r.clone().applyMatrix4(i)):n}getClipBoundaryMatrix(e,t){return!Array.isArray(e?.clipInsertTransform)||e.clipInsertTransform.length!==16?null:t.clone().multiply(new b.Matrix4().fromArray(e.clipInsertTransform))}clipRenderItem(e,t){if(e.kind==="line"){const r=this.clipLinePoints(e.points??[],t);if(r.length===0)return null;const o=this.getPointsBounds(r);return{...e,points:r,min:o.min,max:o.max}}const n=this.clipGeometry(e.geometry,t);if(!n)return null;const i=Mr(n);return{...e,geometry:n,min:i.min,max:i.max}}clipLinePoints(e,t){const n=[];for(let i=0;i<e.length-1;i+=2)this.clipSegmentByPolygon(e[i],e[i+1],t).forEach(r=>{n.push(r[0],r[1])});return n}clipSegmentByPolygon(e,t,n){const i=t.clone().sub(e),r=[0,1];for(let l=0;l<n.length;l+=1){const c=this.getSegmentIntersectionParameter(e,t,n[l],n[(l+1)%n.length]);c!=null&&c>1e-9&&c<1-1e-9&&r.push(c)}const o=Array.from(new Set(r.map(l=>Number(l.toFixed(12))))).sort((l,c)=>l-c),a=[];for(let l=0;l<o.length-1;l+=1){const c=o[l],h=o[l+1];if(h-c<1e-10)continue;const u=(c+h)*.5,d=e.clone().add(i.clone().multiplyScalar(u));this.isPointInPolygon(d,n)&&a.push([e.clone().add(i.clone().multiplyScalar(c)),e.clone().add(i.clone().multiplyScalar(h))])}return a}getSegmentIntersectionParameter(e,t,n,i){const r=t.x-e.x,o=t.y-e.y,a=i.x-n.x,l=i.y-n.y,c=r*l-o*a;if(Math.abs(c)<1e-12)return null;const h=n.x-e.x,u=n.y-e.y,d=(h*l-u*a)/c,f=(h*o-u*r)/c;return d>=-1e-9&&d<=1+1e-9&&f>=-1e-9&&f<=1+1e-9?b.MathUtils.clamp(d,0,1):null}isPointInPolygon(e,t){let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i,i+=1){const o=t[i],a=t[r];if(this.isPointOnSegment(e,o,a))return!0;o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}isPointOnSegment(e,t,n){const i=(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x);if(Math.abs(i)>1e-8)return!1;const r=(e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y),o=(n.x-t.x)**2+(n.y-t.y)**2;return r>=-1e-8&&r<=o+1e-8}clipGeometry(e,t){if(!e?.attributes?.position)return null;const n=e.attributes.position,i=e.attributes.uv,r=e.index,o=[],a=[],l=!!i,c=this.triangulateClipPolygon(t),h=f=>({position:new b.Vector3(n.getX(f),n.getY(f),n.getZ(f)),uv:l?new b.Vector2(i.getX(f),i.getY(f)):void 0}),u=r?r.count:n.count;for(let f=0;f<u;f+=3){const m=r?r.getX(f):f,g=r?r.getX(f+1):f+1,A=r?r.getX(f+2):f+2,p=[h(m),h(g),h(A)];c.forEach(x=>{const y=this.clipTriangle(p,x);if(!(y.length<3))for(let v=1;v<y.length-1;v+=1)[y[0],y[v],y[v+1]].forEach(_=>{o.push(_.position.x,_.position.y,_.position.z),l&&_.uv&&a.push(_.uv.x,_.uv.y)})})}if(o.length===0)return null;const d=new b.BufferGeometry;return d.setAttribute("position",new b.Float32BufferAttribute(o,3)),l&&d.setAttribute("uv",new b.Float32BufferAttribute(a,2)),d.computeVertexNormals(),d}triangulateClipPolygon(e){const t=e.map(i=>new b.Vector2(i.x,i.y)),n=b.ShapeUtils.triangulateShape(t,[]);if(n.length===0){const i=[];for(let r=1;r<e.length-1;r+=1)i.push([e[0],e[r],e[r+1]]);return i}return n.map(i=>i.map(r=>e[r]))}clipTriangle(e,t){const n=this.getPolygonOrientation(t);let i=e;for(let r=0;r<t.length;r+=1){const o=t[r],a=t[(r+1)%t.length],l=i;if(i=[],l.length===0)break;let c=l[l.length-1],h=this.isInsideClipEdge(c.position,o,a,n);l.forEach(u=>{const d=this.isInsideClipEdge(u.position,o,a,n);d!==h&&i.push(this.intersectClipEdge(c,u,o,a,n)),d&&i.push(u),c=u,h=d})}return i}isInsideClipEdge(e,t,n,i){const r=n.x-t.x,o=n.y-t.y;return i*(r*(e.y-t.y)-o*(e.x-t.x))>=-1e-9}intersectClipEdge(e,t,n,i,r){const o=i.x-n.x,a=i.y-n.y,l=r*(o*(e.position.y-n.y)-a*(e.position.x-n.x)),c=r*(o*(t.position.y-n.y)-a*(t.position.x-n.x)),h=Math.abs(l-c)<1e-12?0:l/(l-c);return{position:e.position.clone().lerp(t.position,h),uv:e.uv&&t.uv?e.uv.clone().lerp(t.uv,h):void 0}}getPolygonOrientation(e){let t=0;for(let n=0;n<e.length;n+=1){const i=e[n],r=e[(n+1)%e.length];t+=i.x*r.y-r.x*i.y}return t>=0?1:-1}getPointsBounds(e){const t=new b.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n=new b.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return e.forEach(i=>{t.min(i),n.max(i)}),{min:t,max:n}}createClipBoundaryItem(e,t){const n=[];for(let r=0;r<t.length;r+=1)n.push(t[r].clone(),t[(r+1)%t.length].clone());const i=this.getPointsBounds(n);return{kind:"line",layer:e.layer??"0",color:e.clipBoundaryColor??16711935,lineType:"Continuous",linkId:e.linkId??e.id,points:n,min:i.min,max:i.max,info:e}}}class YP{zipObjectUrls=[];async load(e){if(this.clearZipObjectUrls(),this.is2dZipUrl(e))return this.loadZipData(e);const t=this.isManifestUrl(e)?e:this.joinUrl(this.normalizeDirectoryUrl(e),"manifest.json"),n=await this.fetchJson(t);if(!this.isSplitManifest(n))throw new Error("[LoaderModule2d] Expected split CAD manifest data.");return this.loadSplitData(this.getBaseUrl(t),n)}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async loadSplitData(e,t,n=r=>this.fetchJson(r),i=(r,o)=>Promise.resolve(this.resolveImageUrl(r,o))){const[r,o,a,l]=await Promise.all([n(this.joinUrl(e,t.metadataUrl??"metadata.json")),n(this.joinUrl(e,t.layersUrl??"layers.json")),this.loadBlocks(e,t.blocksUrl??"blocks/index.json",n),this.loadTiles(e,t.root,n)]);await this.resolveBlockAssets(a,e,i);const c=[];return l.forEach(h=>{h.inserts.forEach(u=>c.push(u))}),{version:t.version??"1.0",metadata:r,layers:o,blocks:a,entities:c,octree:t.root,tiles:l}}async loadBlocks(e,t,n){const r=(await n(this.joinUrl(e,t))).parts??[],o=await Promise.all(r.map(l=>this.loadBlockPart(this.joinUrl(e,l),n))),a=[];return o.forEach(l=>{(Array.isArray(l?.blocks)?l.blocks:[]).forEach(h=>a.push(h))}),a}async loadBlockPart(e,t){try{return await t(e)}catch(n){const i=n instanceof Error?n.message:String(n);return console.warn(`[LoaderModule2d] Skip missing block json: ${e}`,i),{blocks:[]}}}async resolveBlockAssets(e,t,n){await Promise.all(e.map(async i=>{const r=Array.isArray(i?.entities)?i.entities:[];await Promise.all(r.map(async o=>{String(o?.type).toUpperCase()==="IMAGE"&&(o.imageUrl=await n(o,t))}))}))}resolveImageUrl(e,t){const n=e.localPath||e.sourcePath||e.path||e.url||"";if(/^(https?:)?\/\//i.test(n)||n.startsWith("/"))return n;const r=String(n).replace(/\\/g,"/").split("/").filter(Boolean).pop();return r?this.joinUrl(t,r):""}async loadTiles(e,t,n){const i=this.collectTileNodes(t);return await Promise.all(i.map(async o=>{const a=o.tileUrl??"",l=await n(this.joinUrl(e,a)),c=this.normalizeTileInserts(l.inserts??[]);return o.elements=c.map(h=>h.linkId??h.id).filter(h=>h!=null),{id:o.id??l.id??a,url:a,node:o,inserts:c}}))}normalizeTileInserts(e){return e.map(t=>({...t,linkId:t.linkId??t.id,type:"INSERT",color:t.color??0,visible:t.visible??!0}))}collectTileNodes(e){if(!e)return[];const t=[],n=[e];for(;n.length>0;){const i=n.pop();if(!i)continue;i.tileUrl&&t.push(i);const r=i.children??[];for(let o=r.length-1;o>=0;o-=1)n.push(r[o])}return t}async loadZipData(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const n=await zd.loadAsync(await t.arrayBuffer()),i=this.findZipManifestPath(n),r=await this.fetchZipJson(n,i);if(!this.isSplitManifest(r))throw new Error("[LoaderModule2d] Expected split CAD manifest data in .2d package.");const o=this.getZipBasePath(i);return this.loadSplitData(o,r,a=>this.fetchZipJson(n,a),(a,l)=>this.resolveZipImageUrl(n,a,l))}findZipManifestPath(e){const t=Object.keys(e.files).filter(r=>!e.files[r].dir),i=t.find(r=>this.normalizeZipPath(r).toLowerCase()==="manifest.json")??t.find(r=>this.normalizeZipPath(r).toLowerCase().endsWith("/manifest.json"));if(!i)throw new Error("[LoaderModule2d] Missing manifest.json in .2d package.");return this.normalizeZipPath(i)}async fetchZipJson(e,t){if(/^(https?:)?\/\//i.test(t))return this.fetchJson(t);const n=this.getZipFile(e,t);if(!n)throw new Error(`[LoaderModule2d] Missing file in .2d package: ${t}`);return JSON.parse(await n.async("string"))}async resolveZipImageUrl(e,t,n){const i=t.localPath||t.sourcePath||t.path||t.url||"";if(/^(https?:)?\/\//i.test(i)||String(i).startsWith("blob:"))return i;const r=this.normalizeZipPath(String(i)),o=r.split("/").filter(Boolean).pop(),l=[this.joinUrl(n,r),o?this.joinUrl(n,o):"",r,o??""].filter(Boolean).map(h=>this.getZipFile(e,h)).find(h=>!!h);if(!l)return"";const c=URL.createObjectURL(new Blob([await l.async("arraybuffer")]));return this.zipObjectUrls.push(c),c}isSplitManifest(e){return!!e&&typeof e=="object"&&(e.splitType==="octree-2d"||!!e.blocksUrl)}is2dZipUrl(e){return/\.2d($|[?#])/i.test(e)}isManifestUrl(e){return/manifest\.json($|\?)/i.test(e)}getBaseUrl(e){const t=e.split("?")[0];return t.slice(0,t.lastIndexOf("/")+1)}getZipBasePath(e){const t=this.normalizeZipPath(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n+1):""}normalizeDirectoryUrl(e){return e.endsWith("/")?e:`${e}/`}joinUrl(e,t){return/^(https?:)?\/\//i.test(t)||t.startsWith("/")?t:`${e}${t}`.replace(/([^:]\/)\/+/g,"$1")}normalizeZipPath(e){return String(e).split("?")[0].split("#")[0].replace(/\\/g,"/").replace(/^\/+/,"")}getZipFile(e,t){const n=this.normalizeZipPath(t),i=e.file(n);if(i)return i;const r=n.toLowerCase(),o=Object.keys(e.files).find(a=>this.normalizeZipPath(a).toLowerCase()===r);return o?e.file(o):null}clearZipObjectUrls(){this.zipObjectUrls.forEach(e=>URL.revokeObjectURL(e)),this.zipObjectUrls=[]}}function ky(s,e,t){const n=t.length-s-1;if(e>=t[n])return n-1;if(e<=t[s])return s;let i=s,r=n,o=Math.floor((i+r)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?r=o:i=o,o=Math.floor((i+r)/2);return o}function KP(s,e,t,n){const i=[],r=[],o=[];i[0]=1;for(let a=1;a<=t;++a){r[a]=e-n[s+1-a],o[a]=n[s+a]-e;let l=0;for(let c=0;c<a;++c){const h=o[c+1],u=r[a-c],d=i[c]/(h+u);i[c]=l+h*d,l=u*d}i[a]=l}return i}function $P(s,e,t,n){const i=ky(s,n,e),r=KP(i,n,s,e),o=new w.Vector4(0,0,0,0);for(let a=0;a<=s;++a){const l=t[i-s+a],c=r[a],h=l.w*c;o.x+=l.x*h,o.y+=l.y*h,o.z+=l.z*h,o.w+=l.w*c}return o}function JP(s,e,t,n,i){const r=[];for(let u=0;u<=t;++u)r[u]=0;const o=[];for(let u=0;u<=n;++u)o[u]=r.slice(0);const a=[];for(let u=0;u<=t;++u)a[u]=r.slice(0);a[0][0]=1;const l=r.slice(0),c=r.slice(0);for(let u=1;u<=t;++u){l[u]=e-i[s+1-u],c[u]=i[s+u]-e;let d=0;for(let f=0;f<u;++f){const m=c[f+1],g=l[u-f];a[u][f]=m+g;const A=a[f][u-1]/a[u][f];a[f][u]=d+m*A,d=g*A}a[u][u]=d}for(let u=0;u<=t;++u)o[0][u]=a[u][t];for(let u=0;u<=t;++u){let d=0,f=1;const m=[];for(let g=0;g<=t;++g)m[g]=r.slice(0);m[0][0]=1;for(let g=1;g<=n;++g){let A=0;const p=u-g,x=t-g;u>=g&&(m[f][0]=m[d][0]/a[x+1][p],A=m[f][0]*a[p][x]);const y=p>=-1?1:-p,v=u-1<=x?g-1:t-u;for(let E=y;E<=v;++E)m[f][E]=(m[d][E]-m[d][E-1])/a[x+1][p+E],A+=m[f][E]*a[p+E][x];u<=x&&(m[f][g]=-m[d][g-1]/a[x+1][u],A+=m[f][g]*a[u][x]),o[g][u]=A;const _=d;d=f,f=_}}let h=t;for(let u=1;u<=n;++u){for(let d=0;d<=t;++d)o[u][d]*=h;h*=t-u}return o}function ZP(s,e,t,n,i){const r=i<s?i:s,o=[],a=ky(s,n,e),l=JP(a,n,s,r,e),c=[];for(let h=0;h<t.length;++h){const u=t[h].clone(),d=u.w;u.x*=d,u.y*=d,u.z*=d,c[h]=u}for(let h=0;h<=r;++h){const u=c[a-s].clone().multiplyScalar(l[h][0]);for(let d=1;d<=s;++d)u.add(c[a-s+d].clone().multiplyScalar(l[h][d]));o[h]=u}for(let h=r+1;h<=i+1;++h)o[h]=new w.Vector4(0,0,0);return o}function e3(s,e){let t=1;for(let i=2;i<=s;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=s-e;++i)n*=i;return t/n}function t3(s){const e=s.length,t=[],n=[];for(let r=0;r<e;++r){const o=s[r];t[r]=new w.Vector3(o.x,o.y,o.z),n[r]=o.w}const i=[];for(let r=0;r<e;++r){const o=t[r].clone();for(let a=1;a<=r;++a)o.sub(i[r-a].clone().multiplyScalar(e3(r,a)*n[a]));i[r]=o.divideScalar(n[0])}return i}function n3(s,e,t,n,i){const r=ZP(s,e,t,n,i);return t3(r)}class i3 extends w.Curve{constructor(e,t,n,i,r){super();const o=t?t.length-1:0,a=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||o;for(let l=0;l<a;++l){const c=n[l];this.controlPoints[l]=new w.Vector4(c.x,c.y,c.z,c.w)}}getPoint(e,t=new w.Vector3){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=$P(this.degree,this.knots,this.controlPoints,i);return r.w!==1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new w.Vector3){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=n3(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new w.Vector4(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}const Tt=1e-8,Fy=.001,s3=8421504;class r3{constructor(e){this.engine=e}create(e,t){const n=this.getLoopSet(e);if(n.outers.length===0)return[];if(this.isGradientFill(e))return this.createGradientItems(e,t,n);if(this.isSolidFill(e))return this.createSolidItems(e,t,n);const r=this.createPatternLineItem(e,t,n);return r?[r]:(this.warnUnknownPatternFallback(e),this.createSolidItems(e,t,n,s3))}isSolidFill(e){const t=String(e.pattern??e.patternName??"").toUpperCase();return e.solid===!0||t==="SOLID"}warnUnknownPatternFallback(e){const t=e.pattern??e.patternName??"UNKNOWN";this.engine.options?.debugHatch===!0&&console.warn(`[LoaderModule2d] HATCH pattern "${t}" cannot be rendered, use gray solid fallback.`)}isGradientFill(e){return e.gradient?.enabled===!0||String(e.patternType??"").toUpperCase()==="GRADIENTFILL"}getLoopSet(e){const t=(e.loops??[]).map(o=>this.normalizeLoop(o.points)).filter(o=>o.length>=3);if(t.length===0)return{outers:[],holes:[]};const n=(e.loops??[]).filter(o=>this.normalizeLoop(o.points).length>=3);if(!n.some(o=>o.type===!1))return this.classifyLoopsByContainment(t);const i=n.filter(o=>o.type!==!1).map(o=>this.normalizeLoop(o.points)),r=n.filter(o=>o.type===!1).map(o=>this.normalizeLoop(o.points));return i.length>0?{outers:i,holes:r}:{outers:[t[0]],holes:t.slice(1)}}classifyLoopsByContainment(e){const t=[...e].sort((r,o)=>Math.abs(this.signedArea(o))-Math.abs(this.signedArea(r))),n=[],i=[];return t.forEach((r,o)=>{const a=new b.Vector2(r[0][0],r[0][1]);t.slice(0,o).filter(c=>this.pointInPolygon(a,c)).length%2===0?n.push(r):i.push(r)}),{outers:n,holes:i}}signedArea(e){let t=0;for(let n=0;n<e.length;n+=1){const i=e[n],r=e[(n+1)%e.length];t+=i[0]*r[1]-r[0]*i[1]}return t/2}normalizeLoop(e){const t=[];(e??[]).forEach(r=>{if(!Array.isArray(r)||r.length<2)return;const o=[Number(r[0]),Number(r[1])];if(!Number.isFinite(o[0])||!Number.isFinite(o[1]))return;const a=t[t.length-1];(!a||Math.hypot(o[0]-a[0],o[1]-a[1])>Tt)&&t.push(o)});const n=t[0],i=t[t.length-1];return n&&i&&Math.hypot(n[0]-i[0],n[1]-i[1])<=Tt&&t.pop(),t}createSolidItems(e,t,n,i){const r=[];if(n.outers.forEach(l=>{const c=this.createShape(l);n.holes.filter(h=>this.pointInPolygon(new b.Vector2(h[0][0],h[0][1]),l)).forEach(h=>{c.holes.push(this.createPath(h))}),r.push(new b.ShapeGeometry(c))}),r.length===0)return[];const o=r.length===1?r[0]:_i(r,!1);o.applyMatrix4(t);const a=Mr(o);return[{kind:"hatch",layer:e.layer??"0",color:i??this.resolveEntityColor(e),linkId:e.linkId??e.id,geometry:o,min:a.min,max:a.max,info:e}]}createShape(e){const t=new b.Shape;t.moveTo(e[0][0],e[0][1]);for(let n=1;n<e.length;n+=1)t.lineTo(e[n][0],e[n][1]);return t.closePath(),t}createPath(e){const t=new b.Path;t.moveTo(e[0][0],e[0][1]);for(let n=1;n<e.length;n+=1)t.lineTo(e[n][0],e[n][1]);return t.closePath(),t}createGradientItems(e,t,n){const i=[];if(n.outers.forEach(a=>{const l=this.createShape(a);n.holes.filter(h=>this.pointInPolygon(new b.Vector2(h[0][0],h[0][1]),a)).forEach(h=>{l.holes.push(this.createPath(h))});const c=this.subdivideTriangles(new b.ShapeGeometry(l),this.engine.options?.hatchGradientSubdivisions??3);this.applyGradientVertexColors(c,a,e.gradient),i.push(c)}),i.length===0)return[];const r=i.length===1?i[0]:_i(i,!1);r.applyMatrix4(t);const o=Mr(r);return[{kind:"hatch",layer:e.layer??"0",color:this.resolveEntityColor(e),linkId:e.linkId??e.id,geometry:r,useVertexColors:!0,min:o.min,max:o.max,info:e}]}applyGradientVertexColors(e,t,n){const i=e.getAttribute("position"),r=[],o=this.resolveGradientStops(n),a=this.getBounds(t),l=new b.Vector2((a.minX+a.maxX)/2,(a.minY+a.maxY)/2),c=Math.max(a.maxX-a.minX,Tt),h=Math.max(a.maxY-a.minY,Tt),u=Math.max(Math.hypot(c/2,h/2),Tt),d=Number(n?.angle??0),f=new b.Vector2(Math.cos(d),Math.sin(d)).normalize(),m=new b.Vector2(-f.y,f.x);for(let g=0;g<i.count;g+=1){const A=new b.Vector2(i.getX(g),i.getY(g)),p=this.resolveGradientFactor(A,l,f,m,c,h,u,n),x=this.sampleGradientColor(o,p);r.push(x.r,x.g,x.b)}e.setAttribute("color",new b.Float32BufferAttribute(r,3))}subdivideTriangles(e,t){let n=e.index?e.toNonIndexed():e.clone();const i=Math.max(0,Math.min(Math.floor(Number(t)||0),5));for(let r=0;r<i;r+=1){const o=n.getAttribute("position"),a=[];for(let l=0;l<o.count;l+=3){const c=new b.Vector3(o.getX(l),o.getY(l),o.getZ(l)),h=new b.Vector3(o.getX(l+1),o.getY(l+1),o.getZ(l+1)),u=new b.Vector3(o.getX(l+2),o.getY(l+2),o.getZ(l+2)),d=c.clone().lerp(h,.5),f=h.clone().lerp(u,.5),m=u.clone().lerp(c,.5);this.pushTriangle(a,c,d,m),this.pushTriangle(a,d,h,f),this.pushTriangle(a,m,f,u),this.pushTriangle(a,d,f,m)}n=new b.BufferGeometry().setAttribute("position",new b.Float32BufferAttribute(a,3))}return n}pushTriangle(e,t,n,i){e.push(t.x,t.y,t.z,n.x,n.y,n.z,i.x,i.y,i.z)}resolveGradientFactor(e,t,n,i,r,o,a,l){const c=e.clone().sub(t),h=String(l?.name??"LINEAR").toUpperCase(),u=Number(l?.shift??0),d=Math.max(Math.abs(n.x)*r+Math.abs(n.y)*o,Tt),f=Math.max(Math.abs(i.x)*r+Math.abs(i.y)*o,Tt);let m=.5+c.dot(n)/d+u;return h.includes("CYLINDER")?m=Math.abs(c.dot(i))/(f/2):h.includes("SPHERICAL")?(m=c.length()/a,h.includes("HEMI")&&(m=Math.sqrt(m))):h.includes("CURVED")&&(m=Math.pow(Math.abs(c.dot(n))/(d/2),.65)),h.startsWith("INV")&&(m=1-m),b.MathUtils.clamp(m,0,1)}resolveGradientStops(e){const t=(e?.colors??[]).map(n=>({value:b.MathUtils.clamp(Number(n.value??0),0,1),color:this.resolveGradientStopColor(n)})).sort((n,i)=>n.value-i.value);if(t.length>=2)return t;if(t.length===1){const n=b.MathUtils.clamp(Number(e?.colorTint??0),0,1);return[{value:0,color:t[0].color.clone().lerp(new b.Color(16777215),n)},{value:1,color:t[0].color}]}return[{value:0,color:new b.Color(16777215)},{value:1,color:new b.Color(0)}]}resolveGradientStopColor(e){if(Array.isArray(e.rgb)&&e.rgb.length>=3){const[t,n,i]=e.rgb.map(r=>b.MathUtils.clamp(Number(r??0),0,255)/255);return new b.Color(t,n,i)}return new b.Color(e.color??16777215)}resolveEntityColor(e){if(Array.isArray(e.rgb)&&e.rgb.length>=3){const[t,n,i]=e.rgb.map(r=>Math.round(b.MathUtils.clamp(Number(r??0),0,255)));return t<<16|n<<8|i}return e.color??16777215}sampleGradientColor(e,t){if(t<=e[0].value)return e[0].color.clone();for(let n=0;n<e.length-1;n+=1){const i=e[n],r=e[n+1];if(t<=r.value+Tt){const o=Math.max(r.value-i.value,Tt);return i.color.clone().lerp(r.color,(t-i.value)/o)}}return e[e.length-1].color.clone()}createPatternLineItem(e,t,n){const i=[],r=this.engine.options?.hatchPatternMaxSegments??2e4;let o=0;for(const l of n.outers){const c=this.getBounds(l),h=Math.hypot(c.maxX-c.minX,c.maxY-c.minY);if(!(h<Tt))for(const u of e.patternLines??[]){if(o>=r)break;const d=this.createPatternFamilySegments(e,u,l,n.holes,c,h,r-o);d.forEach(([f,m])=>{i.push(new b.Vector3(f.x,f.y,Fy),new b.Vector3(m.x,m.y,Fy))}),o+=d.length}}if(i.length===0)return null;i.forEach(l=>l.applyMatrix4(t));const a=Ry(i);return{kind:"line",layer:e.layer??"0",color:this.resolveEntityColor(e),linkId:e.linkId??e.id,points:i,min:a.min,max:a.max,info:e}}createPatternFamilySegments(e,t,n,i,r,o,a){const l=this.resolvePatternLineTransform(e,t),c=l.dir,h=new b.Vector2(-c.y,c.x),u=l.base,d=l.offset;let f=d.dot(h);if(Math.abs(f)<Tt&&(f=Number(t.lineOffset??0)),Math.abs(f)<Tt)return[];const m=[new b.Vector2(r.minX,r.minY),new b.Vector2(r.maxX,r.minY),new b.Vector2(r.maxX,r.maxY),new b.Vector2(r.minX,r.maxY)],g=u.dot(h),A=m.map(I=>I.dot(h)-g),p=Math.min(...A)-o,x=Math.max(...A)+o,y=Math.floor(Math.min(p/f,x/f))-2,v=Math.ceil(Math.max(p/f,x/f))+2,_=[],E=new b.Vector2((r.minX+r.maxX)/2,(r.minY+r.maxY)/2);for(let I=y;I<=v&&_.length<a;I+=1){const B=u.clone().add(d.clone().multiplyScalar(I)),M=B.clone().add(c.clone().multiplyScalar(E.clone().sub(B).dot(c))),C=M.clone().add(c.clone().multiplyScalar(-o*2)),P=M.clone().add(c.clone().multiplyScalar(o*2));this.clipLineByPolygon(C,P,n).forEach(([R,S])=>{this.subtractHoles(R,S,i).forEach(([F,N])=>{this.appendDashedSegment(_,F,N,t.dashLengths,B,c)})})}return _.slice(0,a)}resolvePatternLineTransform(e,t){const n=Number(t.angle??e.patternAngle??0);return{dir:new b.Vector2(Math.cos(n),Math.sin(n)).normalize(),base:this.toVector2(t.basePoint),offset:this.toVector2(t.offset)}}toVector2(e){return new b.Vector2(e?.[0]??0,e?.[1]??0)}getBounds(e){return{minX:Math.min(...e.map(t=>t[0])),minY:Math.min(...e.map(t=>t[1])),maxX:Math.max(...e.map(t=>t[0])),maxY:Math.max(...e.map(t=>t[1]))}}clipLineByPolygon(e,t,n){const i=[0,1];for(let a=0;a<n.length;a+=1){const l=new b.Vector2(n[a][0],n[a][1]),c=new b.Vector2(n[(a+1)%n.length][0],n[(a+1)%n.length][1]),h=this.segmentIntersectionT(e,t,l,c);h!==null&&h>Tt&&h<1-Tt&&i.push(h)}const r=this.dedupeSorted(i.sort((a,l)=>a-l),1e-7),o=[];for(let a=0;a<r.length-1;a+=1){const l=r[a],c=r[a+1];if(c-l<1e-7)continue;const h=this.interpolate2(e,t,(l+c)/2);this.pointInPolygon(h,n)&&o.push([this.interpolate2(e,t,l),this.interpolate2(e,t,c)])}return o}subtractHoles(e,t,n){let i=[[e,t]];return n.forEach(r=>{const o=[];i.forEach(([a,l])=>{const c=this.clipLineByPolygon(a,l,r);o.push(...this.subtractSegments(a,l,c))}),i=o}),i}appendDashedSegment(e,t,n,i,r,o){const a=t.distanceTo(n);if(a<Tt)return;if(!i?.length){e.push([t,n]);return}const l=this.normalizeDashPattern(i),c=l.reduce((y,v)=>y+v.length,0);if(c<Tt){e.push([t,n]);return}const h=o?.clone().normalize()??n.clone().sub(t).normalize(),u=r??t,f=n.clone().sub(t).normalize().dot(h)>=0?1:-1,m=t.clone().sub(u).dot(h)*f,g=this.positiveModulo(m,c);let A=0,p=this.findDashIndex(l,g),x=g-l[p].start;for(;A<a-Tt;){const y=l[p],v=Math.max(y.length-x,Tt),_=Math.min(a,A+v);y.draw&&e.push([this.pointAtLength(t,n,A),this.pointAtLength(t,n,_)]),A=_,p=(p+1)%l.length,x=0}}normalizeDashPattern(e){let t=0;return e.map(n=>{const i=Number(n??0),r={length:Math.max(Math.abs(i),5e-4),draw:i>=0,start:t};return t+=r.length,r}).filter(n=>n.length>Tt)}findDashIndex(e,t){for(let n=e.length-1;n>=0;n-=1)if(t>=e[n].start-Tt)return n;return 0}positiveModulo(e,t){return(e%t+t)%t}subtractSegments(e,t,n){const i=n.map(([a,l])=>[this.projectT(e,t,a),this.projectT(e,t,l)]).map(([a,l])=>[Math.max(0,Math.min(a,l)),Math.min(1,Math.max(a,l))]).sort((a,l)=>a[0]-l[0]),r=[];let o=0;return i.forEach(([a,l])=>{a>o+Tt&&r.push([this.interpolate2(e,t,o),this.interpolate2(e,t,a)]),o=Math.max(o,l)}),o<1-Tt&&r.push([this.interpolate2(e,t,o),this.interpolate2(e,t,1)]),r}segmentIntersectionT(e,t,n,i){const r=t.clone().sub(e),o=i.clone().sub(n),a=this.cross2(r,o);if(Math.abs(a)<1e-10)return null;const l=n.clone().sub(e),c=this.cross2(l,o)/a,h=this.cross2(l,r)/a;return c>=-1e-8&&c<=1+1e-8&&h>=-1e-8&&h<=1+1e-8?c:null}pointInPolygon(e,t){let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i,i+=1){const o=t[i][0],a=t[i][1],l=t[r][0],c=t[r][1];a>e.y!=c>e.y&&e.x<(l-o)*(e.y-a)/(c-a+1e-20)+o&&(n=!n)}return n}cross2(e,t){return e.x*t.y-e.y*t.x}interpolate2(e,t,n){return e.clone().lerp(t,n)}projectT(e,t,n){const i=t.clone().sub(e),r=i.lengthSq();return r<1e-12?0:n.clone().sub(e).dot(i)/r}pointAtLength(e,t,n){const i=e.distanceTo(t);return this.interpolate2(e,t,i<1e-12?0:n/i)}dedupeSorted(e,t){const n=[];return e.forEach(i=>{(!n.length||Math.abs(i-n[n.length-1])>t)&&n.push(i)}),n}}class o3{constructor(e,t){this.engine=e,this.textFactory=t,this.hatchRenderer=new r3(e)}hatchRenderer;create(e,t){switch(e.type){case"LINE_GROUP":case"LINE":case"CIRCLE":case"POLYLINE":case"SPLINE":return this.createLineItem(e,t);case"MTEXT":case"TEXT":return this.textFactory.create(e,t);case"HATCH":return this.createHatch(e,t);case"IMAGE":return this.createImage(e,t);default:return[]}}createLineItem(e,t){const n=this.getEntityPoints(e).map(i=>i.clone().applyMatrix4(t));return n.length===0?[]:[{kind:"line",layer:e.layer,color:e.color,lineType:e.lineType,lineTypeScale:e.lineTypeScale,lineTypePattern:Array.isArray(e.lineTypePattern)?e.lineTypePattern:void 0,linkId:e.linkId??e.id,points:n,info:e}]}getEntityPoints(e){switch(e.type){case"LINE_GROUP":return this.getLineGroupPoints(e);case"LINE":return[ks(e.startPoint),ks(e.endPoint)];case"CIRCLE":return this.getCirclePoints(e);case"POLYLINE":return this.getPolylinePoints(e);case"SPLINE":return this.getSplinePoints(e);default:return[]}}getLineGroupPoints(e){const t=[];return(e.segments??[]).forEach(n=>{t.push(new b.Vector3(n[0]??0,n[1]??0,n[2]??0)),t.push(new b.Vector3(n[3]??0,n[4]??0,n[5]??0))}),t}getCirclePoints(e){const t=new b.EllipseCurve(e.center?.[0]??0,e.center?.[1]??0,e.radius??0,e.radius??0,e.startAngle??0,(e.endAngle??Math.PI*2)-1e-5,!1,0);return this.pointsToSegments(t.getPoints(this.engine.options?.circleSegments??48).map(n=>new b.Vector3(n.x,n.y,e.center?.[2]??0)))}getPolylinePoints(e){const t=[],n=e.points??[];for(let i=0;i<n.length-1;i+=1)this.getPolylineSegmentPoints(n[i],n[i+1]).forEach(r=>{t.push(r)});return e.closed&&n.length>1&&this.getPolylineSegmentPoints(n[n.length-1],n[0]).forEach(i=>{t.push(i)}),t}getPolylineSegmentPoints(e,t){const n=ks(e),i=ks(t),r=Number(e?.bulge??0);if(!Number.isFinite(r)||Math.abs(r)<1e-10)return[n,i];const o=i.clone().sub(n),a=o.length();if(a<1e-12)return[n,i];const l=4*Math.atan(r),c=a*(1+r*r)/(4*Math.abs(r)),h=n.clone().add(i).multiplyScalar(.5),u=new b.Vector3(-o.y/a,o.x/a,0),d=h.clone().add(u.multiplyScalar(a*(1-r*r)/(4*r))),f=Math.atan2(n.y-d.y,n.x-d.x),m=Math.max(4,Math.ceil(Math.abs(l)/(this.engine.options?.polylineArcAngleStep??Math.PI/18))),g=[];for(let A=0;A<=m;A+=1){const p=A/m,x=f+l*p;g.push(new b.Vector3(d.x+Math.cos(x)*c,d.y+Math.sin(x)*c,n.z+(i.z-n.z)*p))}return this.pointsToSegments(g)}getSplinePoints(e){const t=(e.points??[]).map(i=>ks(i));if(t.length<2)return[];const n=t.length===2?t:this.sampleSplineCurve(t,e);return this.pointsToSegments(n)}sampleSplineCurve(e,t){const n=Math.min(Math.max(Number(t.degree??this.engine.options?.splineDegree??6),1),e.length-1),i=Array.isArray(t.knots)&&t.knots.length===e.length+n+1?t.knots:this.createClampedUniformKnots(e.length,n),r=e.map((l,c)=>{const h=Array.isArray(t.weights)?Number(t.weights[c]??1):1;return new b.Vector4(l.x,l.y,l.z,Number.isFinite(h)?h:1)});let o=(e.length-1)*2;const a=new i3(n,i,r).getPoints(o);return t.closed===!0&&a.length>1&&a.push(a[0].clone()),a}createClampedUniformKnots(e,t){const n=[];for(let i=0;i<e+t+1;i+=1)i<=t?n.push(0):i>=e?n.push(1):n.push((i-t)/(e-t));return n}pointsToSegments(e){const t=[];for(let n=0;n<e.length-1;n+=1)t.push(e[n].clone(),e[n+1].clone());return t}createHatch(e,t){return this.hatchRenderer.create(e,t)}createImage(e,t){const n=e.imageUrl||e.url;if(!n)return[];const i=ks(e.position),r=ks(e.uVector),o=ks(e.vVector),a=Number(e.pixelWidth??e.width??1),l=Number(e.pixelHeight??e.height??1);if(!Number.isFinite(a)||!Number.isFinite(l)||a===0||l===0)return[];const c=r.multiplyScalar(a),h=o.multiplyScalar(l),u=i.clone(),d=i.clone().add(c),f=i.clone().add(c).add(h),m=i.clone().add(h);[u,d,f,m].forEach(x=>x.applyMatrix4(t));const g=new b.BufferGeometry;g.setAttribute("position",new b.Float32BufferAttribute([u.x,u.y,u.z,d.x,d.y,d.z,f.x,f.y,f.z,u.x,u.y,u.z,f.x,f.y,f.z,m.x,m.y,m.z],3)),g.setAttribute("uv",new b.Float32BufferAttribute([0,0,1,0,1,1,0,0,1,1,0,1],2)),g.computeVertexNormals();const A=Mr(g),p=Number(e.fade??0);return[{kind:"image",layer:e.layer??"0",color:e.color??16777215,linkId:e.linkId??e.id,geometry:g,imageUrl:n,opacity:Number.isFinite(p)?b.MathUtils.clamp(1-p/100,0,1):1,min:A.min,max:A.max,info:e}]}}class a3{constructor(e,t,n=e.modelGroup){this.model=t,this.targetGroup=n}modelMap=new Map;hatchMap=new Map;textMap=new Map;imageMap=new Map;textureLoader=new b.TextureLoader;addRenderItems(e){e.forEach(t=>this.addRenderItem(t))}buildSceneObjects(){this.buildImageObjects(),this.buildHatchObjects(),this.buildLineObjects(),this.buildTextObjects()}addRenderItem(e){const t=`${e.layer}||${e.color}`;if(e.kind==="line"){let o=this.modelMap.get(t);o||(o=new Map,this.modelMap.set(t,o));const a=this.resolveLinePoints(e),l=o.get(e.linkId);l?a.forEach(c=>l.push(c)):o.set(e.linkId,[...a]);return}const n=this.getItemMap(e),i=e.kind==="image"?`${t}||${e.imageUrl??""}`:t,r=n.get(i);r?r.push(e):n.set(i,[e])}getItemMap(e){return e.kind==="text"?this.textMap:e.kind==="image"?this.imageMap:this.hatchMap}resolveLinePoints(e){const t=e.points??[],n=this.resolveLineTypePattern(e);if(!n)return t;const i=[];for(let r=0;r<t.length-1;r+=2)this.applyDashPattern(t[r],t[r+1],n).forEach(o=>i.push(o));return i}resolveLineTypePattern(e){const t=this.model.layers.find(l=>l.name===e.layer),n=String(e.lineType??"").toLowerCase(),i=n==="bylayer"||n===""?String(t?.lineType??"").toLowerCase():n;if(!i||i==="continuous"||i==="byblock")return null;const r=Array.isArray(e.lineTypePattern)&&e.lineTypePattern.length>0?e.lineTypePattern:Array.isArray(t?.lineTypePattern)?t.lineTypePattern:this.getFallbackLineTypePattern(i);if(!r||r.length===0)return null;const o=this.resolveLineTypeScale(e,t),a=r.map(l=>Number(l)).filter(l=>Number.isFinite(l)).map(l=>l*o);return a.some(l=>Math.abs(l)>1e-12)?a:null}getFallbackLineTypePattern(e){return e.includes("dash")?[.25,-.1]:e.includes("dot")?[0,-.1]:null}resolveLineTypeScale(e,t){const n=Number(e.lineTypeScale??t?.lineTypeScale??1);return!Number.isFinite(n)||Math.abs(n)<1e-12?1:Math.abs(n)}applyDashPattern(e,t,n){const i=t.clone().sub(e),r=i.length();if(r<1e-12)return[];const o=i.multiplyScalar(1/r),a=n.reduce((d,f)=>d+Math.abs(f),0),l=Math.max(a*.05,r*.002,1e-6),c=[];let h=0,u=0;for(;h<r-1e-12;){const d=n[u%n.length],f=d>=0,m=Math.max(Math.abs(d),l),g=Math.min(h+m,r);if(f&&g>h&&c.push(e.clone().add(o.clone().multiplyScalar(h)),e.clone().add(o.clone().multiplyScalar(g))),h=g,u+=1,u>1e5)break}return c}buildLineObjects(){this.modelMap.forEach((e,t)=>{const[n]=t.split("||"),i=[];if(e.forEach(u=>{u.forEach(d=>i.push(d))}),i.length===0)return;const r=new b.BufferGeometry().setFromPoints(i),o=new b.LineBasicMaterial({color:this.resolveColor(t)}),a=new b.LineSegments(r,o);a.name=t;const l=r.getAttribute("position");a.clonePoints=l.array.slice(),a.materialClone=o.clone(),this.targetGroup.add(a);const c=this.targetGroup.children.length-1;let h=0;e.forEach((u,d)=>{const f=Ry(u);this.pushNodeMap(d,{indexes:[c,h,h+u.length*3],object:a,group:this.targetGroup,kind:"line",layer:n,min:f.min,max:f.max}),h+=u.length*3})})}buildTextObjects(){this.textMap.forEach((e,t)=>{const n=e.filter(a=>!!a.geometry),i=this.normalizeMeshGeometries(n,!1,!1);if(i.length===0)return;const r=this.mergeMeshGeometries(i),o=new b.MeshBasicMaterial({color:this.resolveColor(t),side:b.DoubleSide});t.includes("_hitbox")&&(o.visible=!1),this.addMeshObject(n,t,r,i,o)})}buildHatchObjects(){this.hatchMap.forEach((e,t)=>{const n=e.filter(l=>!!l.geometry),i=n.some(l=>l.useVertexColors===!0),r=this.normalizeMeshGeometries(n,!1,i);if(r.length===0)return;const o=this.mergeMeshGeometries(r),a=new b.MeshBasicMaterial({color:i?16777215:this.resolveColor(t),side:b.DoubleSide,transparent:!0,opacity:i?1:.5,vertexColors:i});this.addMeshObject(n,t,o,r,a)})}buildImageObjects(){this.imageMap.forEach((e,t)=>{const n=e.filter(h=>!!h.geometry),i=this.normalizeMeshGeometries(n,!0,!1);if(i.length===0)return;const r=n[0]?.imageUrl;if(!r)return;const o=this.mergeMeshGeometries(i),a=this.textureLoader.load(r);a.colorSpace=b.SRGBColorSpace,a.needsUpdate=!0;const l=n.reduce((h,u)=>Math.min(h,u.opacity??1),1),c=new b.MeshBasicMaterial({map:a,side:b.DoubleSide,transparent:!0,opacity:l,depthWrite:!1});this.addMeshObject(n,t,o,i,c)})}mergeMeshGeometries(e){const t=e.length===1?e[0]:_i(e,!0);if(t.groups.length===0){const n=t.getAttribute("position");t.addGroup(0,n?.count??0,0)}return t.groups.forEach(n=>{n.materialIndex=0}),t}normalizeMeshGeometries(e,t,n){return e.map(i=>{const r=i.geometry,o=r.index?r.toNonIndexed():r.clone(),a=o.getAttribute("position"),l=o.getAttribute("uv"),c=o.getAttribute("color"),h=new b.BufferGeometry;return h.setAttribute("position",a.clone()),t&&h.setAttribute("uv",l?l.clone():this.createEmptyUv(a.count)),n&&h.setAttribute("color",c?c.clone():this.createSolidColorAttribute(a.count,i.color)),h})}createEmptyUv(e){return new b.Float32BufferAttribute(new Array(e*2).fill(0),2)}createSolidColorAttribute(e,t){const n=new b.Color(t??16777215),i=[];for(let r=0;r<e;r+=1)i.push(n.r,n.g,n.b);return new b.Float32BufferAttribute(i,3)}addMeshObject(e,t,n,i,r){const o=new b.Mesh(n,r);o.name=t,o.materialClone=r.clone(),o.isSplit=!1,o.geometrys=void 0,i.forEach(l=>{l!==n&&l.dispose()}),this.targetGroup.add(o);const a=this.targetGroup.children.length-1;e.forEach((l,c)=>{const h=l.linkId??l.info?.id;this.pushNodeMap(h,{indexes:[a,c],object:o,group:this.targetGroup,kind:l.kind,layer:l.layer,info:l.info,min:l.min??new b.Vector3,max:l.max??new b.Vector3}),this.pushTextSearchItem(l,t)})}pushTextSearchItem(e,t){if(e.kind!=="text"||t.includes("_hitbox"))return;const n=e.info?.text,i=String(n??"").replace(/\r\n/g,`
|
|
5553
|
+
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),r=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-r.left+"px",e.style.top=i.top-r.top+"px",e.style.right="auto",e.style.bottom="auto";const o=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-o-r.left+"px",e.style.top=h.clientY-a-r.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class Ly{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new WP(t,this))}_loadLayers(e=this.engine.dwgData?.layers??[]){this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t});this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}getDisplayColor(e){return this.engine.modelToolModule2d?.getDisplayColor(e)??e}refresh(){this.panelUI?.refresh()}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t),t||this.clearInteractiveStateForLayer(e)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}isLayerVisible(e){return e?this.layerMap.get(e)?.visible!==!1:!0}isModelVisibleByLayer(e){const t=this.engine.loaderModule2d?.model?.nodeMap?.get(String(e))??this.engine.loaderModule2d?.model?.nodeMap?.get(e);return!t||t.length===0?!0:t.some(n=>{const i=this.getNodeObject(n);return this.isLayerVisible(n?.layer)&&i?.visible!==!1})}_applyVisibility(e,t){const n=this.engine?.modelGroup??this.engine?.scene;if(!n)return;const i=e+"||";n.traverse(r=>{r.name?.startsWith(i)&&(r.visible=t)})}getNodeObject(e){return e?.object??e?.group?.children?.[e.indexes?.[0]]??this.engine.modelGroup?.children?.[e.indexes?.[0]]}clearInteractiveStateForLayer(e){const t=[...this.engine.engineStatus2d?.highlightModels??[],...this.engine.engineStatus2d?.highlightHoverModels??[]];t.length===0||!t.some(i=>(this.engine.loaderModule2d?.model?.nodeMap?.get(String(i))??this.engine.loaderModule2d?.model?.nodeMap?.get(i))?.some(o=>o?.layer===e))||(this.engine.modelToolModule2d?.unHighlightModelHover?.(),this.engine.modelToolModule2d?.unhighlightAllModels?.())}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}var li=(s=>(s.ModelLoadStart="model-load-start",s.ModelLoadProgress="model-load-progress",s.ModelLoaded="model-loaded",s.ModelLoadError="model-load-error",s.RenderStart="render-start",s.RenderEnd="render-end",s.CameraChanged="camera-changed",s.CameraReset="camera-reset",s.SelectionChanged="selection-changed",s.HoverChanged="hover-changed",s.EntityClick="entity-click",s.LayerVisibilityChanged="layer-visibility-changed",s.LayerColorChanged="layer-color-changed",s.ViewZoomChanged="view-zoom-changed",s.ViewPanChanged="view-pan-changed",s.ToolActivated="tool-activated",s.ToolDeactivated="tool-deactivated",s.Error="error",s.Warning="warning",s))(li||{});class HP{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(li).forEach(t=>{this.listeners.set(t,new Set),this.onceListeners.set(t,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const n=this.listeners.get(e);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const n=this.listeners.get(e);n&&n.size>0&&n.forEach(r=>{try{r(t)}catch(o){console.error(`[EventModule2d] Error in listener for ${e}:`,o)}});const i=this.onceListeners.get(e);i&&i.size>0&&(i.forEach(r=>{try{r(t)}catch(o){console.error(`[EventModule2d] Error in once listener for ${e}:`,o)}}),i.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);t&&t.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);return(t?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(li)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}function ks(s){return Array.isArray(s)?new b.Vector3(s[0]??0,s[1]??0,s[2]??0):new b.Vector3(s?.x??0,s?.y??0,s?.z??0)}function Mr(s){return s?(s.computeBoundingBox(),{min:s.boundingBox?.min.clone()??new b.Vector3,max:s.boundingBox?.max.clone()??new b.Vector3}):{min:new b.Vector3,max:new b.Vector3}}function cp(s,e,t){const n=new b.Vector3(s[0]??0,s[1]??0,s[2]??0),i=new b.Euler(0,0,t??0),r=new b.Vector3(e[0]??1,e[1]??1,e[2]??1),o=new b.Quaternion().setFromEuler(i);return new b.Matrix4().compose(n,o,r)}function qP(s){return Array.isArray(s?.transformMatrix)&&s.transformMatrix.length===16?new b.Matrix4().fromArray(s.transformMatrix):cp(s.position??[0,0,0],s.scale??[1,1,1],s.rotation??0)}function Ry(s){if(s.length===0)return{min:new b.Vector3,max:new b.Vector3};const e=new b.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),t=new b.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return s.forEach(n=>{e.x=Math.min(e.x,n.x),e.y=Math.min(e.y,n.y),e.z=Math.min(e.z,n.z),t.x=Math.max(t.x,n.x),t.y=Math.max(t.y,n.y),t.z=Math.max(t.z,n.z)}),{min:e,max:t}}class XP{constructor(e){this.geometryFactory=e}cache=new Map;blockIndex=new Map;setBlocks(e){this.cache.clear(),this.blockIndex.clear(),(e??[]).forEach(t=>{t?.name&&this.blockIndex.set(t.name,t),t?.id&&this.blockIndex.set(t.id,t)})}clearCache(){this.cache.clear()}flattenRootEntities(e){return Array.from(this.iterateRootEntities(e))}*iterateRootEntities(e){yield*this.iterateEntities(e??[],new b.Matrix4,0)}flattenBlock(e,t,n){const i=this.cache.get(t);if(i)return i;const r=e.origin??[0,0,0],o=new b.Matrix4().makeTranslation(-r[0],-r[1],-(r[2]??0)),a=this.flattenEntities(e.entities??[],o,n);return this.cache.set(t,a),e.name&&this.cache.set(e.name,a),e.id&&this.cache.set(e.id,a),a}flattenEntities(e,t,n){return Array.from(this.iterateEntities(e,t,n))}*iterateEntities(e,t,n){if(n>20){console.warn("[LoaderModule2d] Block nesting is too deep, skip nested INSERT.");return}for(const i of e)if(i?.visible!==!1){if(i.type==="INSERT"){const r=this.getBlockItems(i.blockId,n+1),o=t.clone().multiply(qP(i)),a=this.getClipPolygon(i,t);for(const l of r){const c=this.cloneRenderItem(l,o,i),h=a?this.clipRenderItem(c,a):c;h&&(yield h)}a&&i.displayClipBoundary===!0&&(yield this.createClipBoundaryItem(i,a));continue}for(const r of this.geometryFactory.create(i,t))yield r}}getBlockItems(e,t){const n=this.cache.get(e);if(n)return n;const i=this.blockIndex.get(e);return i?this.flattenBlock(i,i.name??i.id??e,t):(console.warn(`[LoaderModule2d] Missing block: ${e}`),[])}cloneRenderItem(e,t,n){const i=e.layer==="0"&&n?.layer?n.layer:e.layer??n?.layer,r=e.color==null||e.color===0?n?.color??e.color??0:e.color,o=n?.linkId??n?.id??e.linkId;if(e.kind==="line")return{...e,layer:i,color:r,linkId:o,points:(e.points??[]).map(h=>h.clone().applyMatrix4(t))};const a=e.geometry?.clone();a?.applyMatrix4(t);const l=e.textAnchor?.clone().applyMatrix4(t),c=Mr(a);return{...e,layer:i,color:r,linkId:o,geometry:a,min:c.min,max:c.max,textAnchor:l}}getClipPolygon(e,t){if(e?.clipping!==!0||!Array.isArray(e?.clipBoundary))return null;const n=e.clipBoundary.map(r=>new b.Vector3(r?.[0]??r?.x??0,r?.[1]??r?.y??0,r?.[2]??r?.z??0)).filter(r=>Number.isFinite(r.x)&&Number.isFinite(r.y));if(n.length<3)return null;const i=this.getClipBoundaryMatrix(e,t);return i?n.map(r=>r.clone().applyMatrix4(i)):n}getClipBoundaryMatrix(e,t){return!Array.isArray(e?.clipInsertTransform)||e.clipInsertTransform.length!==16?null:t.clone().multiply(new b.Matrix4().fromArray(e.clipInsertTransform))}clipRenderItem(e,t){if(e.kind==="line"){const r=this.clipLinePoints(e.points??[],t);if(r.length===0)return null;const o=this.getPointsBounds(r);return{...e,points:r,min:o.min,max:o.max}}const n=this.clipGeometry(e.geometry,t);if(!n)return null;const i=Mr(n);return{...e,geometry:n,min:i.min,max:i.max}}clipLinePoints(e,t){const n=[];for(let i=0;i<e.length-1;i+=2)this.clipSegmentByPolygon(e[i],e[i+1],t).forEach(r=>{n.push(r[0],r[1])});return n}clipSegmentByPolygon(e,t,n){const i=t.clone().sub(e),r=[0,1];for(let l=0;l<n.length;l+=1){const c=this.getSegmentIntersectionParameter(e,t,n[l],n[(l+1)%n.length]);c!=null&&c>1e-9&&c<1-1e-9&&r.push(c)}const o=Array.from(new Set(r.map(l=>Number(l.toFixed(12))))).sort((l,c)=>l-c),a=[];for(let l=0;l<o.length-1;l+=1){const c=o[l],h=o[l+1];if(h-c<1e-10)continue;const u=(c+h)*.5,d=e.clone().add(i.clone().multiplyScalar(u));this.isPointInPolygon(d,n)&&a.push([e.clone().add(i.clone().multiplyScalar(c)),e.clone().add(i.clone().multiplyScalar(h))])}return a}getSegmentIntersectionParameter(e,t,n,i){const r=t.x-e.x,o=t.y-e.y,a=i.x-n.x,l=i.y-n.y,c=r*l-o*a;if(Math.abs(c)<1e-12)return null;const h=n.x-e.x,u=n.y-e.y,d=(h*l-u*a)/c,f=(h*o-u*r)/c;return d>=-1e-9&&d<=1+1e-9&&f>=-1e-9&&f<=1+1e-9?b.MathUtils.clamp(d,0,1):null}isPointInPolygon(e,t){let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i,i+=1){const o=t[i],a=t[r];if(this.isPointOnSegment(e,o,a))return!0;o.y>e.y!=a.y>e.y&&e.x<(a.x-o.x)*(e.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}isPointOnSegment(e,t,n){const i=(n.x-t.x)*(e.y-t.y)-(n.y-t.y)*(e.x-t.x);if(Math.abs(i)>1e-8)return!1;const r=(e.x-t.x)*(n.x-t.x)+(e.y-t.y)*(n.y-t.y),o=(n.x-t.x)**2+(n.y-t.y)**2;return r>=-1e-8&&r<=o+1e-8}clipGeometry(e,t){if(!e?.attributes?.position)return null;const n=e.attributes.position,i=e.attributes.uv,r=e.index,o=[],a=[],l=!!i,c=this.triangulateClipPolygon(t),h=f=>({position:new b.Vector3(n.getX(f),n.getY(f),n.getZ(f)),uv:l?new b.Vector2(i.getX(f),i.getY(f)):void 0}),u=r?r.count:n.count;for(let f=0;f<u;f+=3){const m=r?r.getX(f):f,g=r?r.getX(f+1):f+1,A=r?r.getX(f+2):f+2,p=[h(m),h(g),h(A)];c.forEach(x=>{const y=this.clipTriangle(p,x);if(!(y.length<3))for(let v=1;v<y.length-1;v+=1)[y[0],y[v],y[v+1]].forEach(_=>{o.push(_.position.x,_.position.y,_.position.z),l&&_.uv&&a.push(_.uv.x,_.uv.y)})})}if(o.length===0)return null;const d=new b.BufferGeometry;return d.setAttribute("position",new b.Float32BufferAttribute(o,3)),l&&d.setAttribute("uv",new b.Float32BufferAttribute(a,2)),d.computeVertexNormals(),d}triangulateClipPolygon(e){const t=e.map(i=>new b.Vector2(i.x,i.y)),n=b.ShapeUtils.triangulateShape(t,[]);if(n.length===0){const i=[];for(let r=1;r<e.length-1;r+=1)i.push([e[0],e[r],e[r+1]]);return i}return n.map(i=>i.map(r=>e[r]))}clipTriangle(e,t){const n=this.getPolygonOrientation(t);let i=e;for(let r=0;r<t.length;r+=1){const o=t[r],a=t[(r+1)%t.length],l=i;if(i=[],l.length===0)break;let c=l[l.length-1],h=this.isInsideClipEdge(c.position,o,a,n);l.forEach(u=>{const d=this.isInsideClipEdge(u.position,o,a,n);d!==h&&i.push(this.intersectClipEdge(c,u,o,a,n)),d&&i.push(u),c=u,h=d})}return i}isInsideClipEdge(e,t,n,i){const r=n.x-t.x,o=n.y-t.y;return i*(r*(e.y-t.y)-o*(e.x-t.x))>=-1e-9}intersectClipEdge(e,t,n,i,r){const o=i.x-n.x,a=i.y-n.y,l=r*(o*(e.position.y-n.y)-a*(e.position.x-n.x)),c=r*(o*(t.position.y-n.y)-a*(t.position.x-n.x)),h=Math.abs(l-c)<1e-12?0:l/(l-c);return{position:e.position.clone().lerp(t.position,h),uv:e.uv&&t.uv?e.uv.clone().lerp(t.uv,h):void 0}}getPolygonOrientation(e){let t=0;for(let n=0;n<e.length;n+=1){const i=e[n],r=e[(n+1)%e.length];t+=i.x*r.y-r.x*i.y}return t>=0?1:-1}getPointsBounds(e){const t=new b.Vector3(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),n=new b.Vector3(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);return e.forEach(i=>{t.min(i),n.max(i)}),{min:t,max:n}}createClipBoundaryItem(e,t){const n=[];for(let r=0;r<t.length;r+=1)n.push(t[r].clone(),t[(r+1)%t.length].clone());const i=this.getPointsBounds(n);return{kind:"line",layer:e.layer??"0",color:e.clipBoundaryColor??16711935,lineType:"Continuous",linkId:e.linkId??e.id,points:n,min:i.min,max:i.max,info:e}}}class YP{zipObjectUrls=[];async load(e){return this.clearZipObjectUrls(),this.loadZipData(e)}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return t.json()}async loadSplitData(e,t,n=r=>this.fetchJson(r),i=(r,o)=>Promise.resolve(this.resolveImageUrl(r,o))){const[r,o,a,l]=await Promise.all([n(this.joinUrl(e,t.metadataUrl??"metadata.json")),n(this.joinUrl(e,t.layersUrl??"layers.json")),this.loadBlocks(e,t.blocksUrl??"blocks/index.json",n),this.loadTiles(e,t.root,n)]);await this.resolveBlockAssets(a,e,i);const c=[];return l.forEach(h=>{h.inserts.forEach(u=>c.push(u))}),{version:t.version??"1.0",metadata:r,layers:o,blocks:a,entities:c,octree:t.root,tiles:l}}async loadBlocks(e,t,n){const r=(await n(this.joinUrl(e,t))).parts??[],o=await Promise.all(r.map(l=>this.loadBlockPart(this.joinUrl(e,l),n))),a=[];return o.forEach(l=>{(Array.isArray(l?.blocks)?l.blocks:[]).forEach(h=>a.push(h))}),a}async loadBlockPart(e,t){try{return await t(e)}catch(n){const i=n instanceof Error?n.message:String(n);return console.warn(`[LoaderModule2d] Skip missing block json: ${e}`,i),{blocks:[]}}}async resolveBlockAssets(e,t,n){await Promise.all(e.map(async i=>{const r=Array.isArray(i?.entities)?i.entities:[];await Promise.all(r.map(async o=>{String(o?.type).toUpperCase()==="IMAGE"&&(o.imageUrl=await n(o,t))}))}))}resolveImageUrl(e,t){const n=e.localPath||e.sourcePath||e.path||e.url||"";if(/^(https?:)?\/\//i.test(n)||n.startsWith("/"))return n;const r=String(n).replace(/\\/g,"/").split("/").filter(Boolean).pop();return r?this.joinUrl(t,r):""}async loadTiles(e,t,n){const i=this.collectTileNodes(t);return await Promise.all(i.map(async o=>{const a=o.tileUrl??"",l=await n(this.joinUrl(e,a)),c=this.normalizeTileInserts(l.inserts??[]);return o.elements=c.map(h=>h.linkId??h.id).filter(h=>h!=null),{id:o.id??l.id??a,url:a,node:o,inserts:c}}))}normalizeTileInserts(e){return e.map(t=>({...t,linkId:t.linkId??t.id,type:"INSERT",color:t.color??0,visible:t.visible??!0}))}collectTileNodes(e){if(!e)return[];const t=[],n=[e];for(;n.length>0;){const i=n.pop();if(!i)continue;i.tileUrl&&t.push(i);const r=i.children??[];for(let o=r.length-1;o>=0;o-=1)n.push(r[o])}return t}async loadZipData(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);const n=await zd.loadAsync(await t.arrayBuffer()),i=this.findZipManifestPath(n),r=await this.fetchZipJson(n,i);if(!this.isSplitManifest(r))throw new Error("[LoaderModule2d] Expected split CAD manifest data in .2d package.");const o=this.getZipBasePath(i);return this.loadSplitData(o,r,a=>this.fetchZipJson(n,a),(a,l)=>this.resolveZipImageUrl(n,a,l))}findZipManifestPath(e){const t=Object.keys(e.files).filter(r=>!e.files[r].dir),i=t.find(r=>this.normalizeZipPath(r).toLowerCase()==="manifest.json")??t.find(r=>this.normalizeZipPath(r).toLowerCase().endsWith("/manifest.json"));if(!i)throw new Error("[LoaderModule2d] Missing manifest.json in .2d package.");return this.normalizeZipPath(i)}async fetchZipJson(e,t){if(/^(https?:)?\/\//i.test(t))return this.fetchJson(t);const n=this.getZipFile(e,t);if(!n)throw new Error(`[LoaderModule2d] Missing file in .2d package: ${t}`);return JSON.parse(await n.async("string"))}async resolveZipImageUrl(e,t,n){const i=t.localPath||t.sourcePath||t.path||t.url||"";if(/^(https?:)?\/\//i.test(i)||String(i).startsWith("blob:"))return i;const r=this.normalizeZipPath(String(i)),o=r.split("/").filter(Boolean).pop(),l=[this.joinUrl(n,r),o?this.joinUrl(n,o):"",r,o??""].filter(Boolean).map(h=>this.getZipFile(e,h)).find(h=>!!h);if(!l)return"";const c=URL.createObjectURL(new Blob([await l.async("arraybuffer")]));return this.zipObjectUrls.push(c),c}isSplitManifest(e){return!!e&&typeof e=="object"&&(e.splitType==="octree-2d"||!!e.blocksUrl)}is2dZipUrl(e){return/\.2d($|[?#])/i.test(e)}isManifestUrl(e){return/manifest\.json($|\?)/i.test(e)}getBaseUrl(e){const t=e.split("?")[0];return t.slice(0,t.lastIndexOf("/")+1)}getZipBasePath(e){const t=this.normalizeZipPath(e),n=t.lastIndexOf("/");return n>=0?t.slice(0,n+1):""}normalizeDirectoryUrl(e){return e.endsWith("/")?e:`${e}/`}joinUrl(e,t){return/^(https?:)?\/\//i.test(t)||t.startsWith("/")?t:`${e}${t}`.replace(/([^:]\/)\/+/g,"$1")}normalizeZipPath(e){return String(e).split("?")[0].split("#")[0].replace(/\\/g,"/").replace(/^\/+/,"")}getZipFile(e,t){const n=this.normalizeZipPath(t),i=e.file(n);if(i)return i;const r=n.toLowerCase(),o=Object.keys(e.files).find(a=>this.normalizeZipPath(a).toLowerCase()===r);return o?e.file(o):null}clearZipObjectUrls(){this.zipObjectUrls.forEach(e=>URL.revokeObjectURL(e)),this.zipObjectUrls=[]}}function ky(s,e,t){const n=t.length-s-1;if(e>=t[n])return n-1;if(e<=t[s])return s;let i=s,r=n,o=Math.floor((i+r)/2);for(;e<t[o]||e>=t[o+1];)e<t[o]?r=o:i=o,o=Math.floor((i+r)/2);return o}function KP(s,e,t,n){const i=[],r=[],o=[];i[0]=1;for(let a=1;a<=t;++a){r[a]=e-n[s+1-a],o[a]=n[s+a]-e;let l=0;for(let c=0;c<a;++c){const h=o[c+1],u=r[a-c],d=i[c]/(h+u);i[c]=l+h*d,l=u*d}i[a]=l}return i}function $P(s,e,t,n){const i=ky(s,n,e),r=KP(i,n,s,e),o=new w.Vector4(0,0,0,0);for(let a=0;a<=s;++a){const l=t[i-s+a],c=r[a],h=l.w*c;o.x+=l.x*h,o.y+=l.y*h,o.z+=l.z*h,o.w+=l.w*c}return o}function JP(s,e,t,n,i){const r=[];for(let u=0;u<=t;++u)r[u]=0;const o=[];for(let u=0;u<=n;++u)o[u]=r.slice(0);const a=[];for(let u=0;u<=t;++u)a[u]=r.slice(0);a[0][0]=1;const l=r.slice(0),c=r.slice(0);for(let u=1;u<=t;++u){l[u]=e-i[s+1-u],c[u]=i[s+u]-e;let d=0;for(let f=0;f<u;++f){const m=c[f+1],g=l[u-f];a[u][f]=m+g;const A=a[f][u-1]/a[u][f];a[f][u]=d+m*A,d=g*A}a[u][u]=d}for(let u=0;u<=t;++u)o[0][u]=a[u][t];for(let u=0;u<=t;++u){let d=0,f=1;const m=[];for(let g=0;g<=t;++g)m[g]=r.slice(0);m[0][0]=1;for(let g=1;g<=n;++g){let A=0;const p=u-g,x=t-g;u>=g&&(m[f][0]=m[d][0]/a[x+1][p],A=m[f][0]*a[p][x]);const y=p>=-1?1:-p,v=u-1<=x?g-1:t-u;for(let E=y;E<=v;++E)m[f][E]=(m[d][E]-m[d][E-1])/a[x+1][p+E],A+=m[f][E]*a[p+E][x];u<=x&&(m[f][g]=-m[d][g-1]/a[x+1][u],A+=m[f][g]*a[u][x]),o[g][u]=A;const _=d;d=f,f=_}}let h=t;for(let u=1;u<=n;++u){for(let d=0;d<=t;++d)o[u][d]*=h;h*=t-u}return o}function ZP(s,e,t,n,i){const r=i<s?i:s,o=[],a=ky(s,n,e),l=JP(a,n,s,r,e),c=[];for(let h=0;h<t.length;++h){const u=t[h].clone(),d=u.w;u.x*=d,u.y*=d,u.z*=d,c[h]=u}for(let h=0;h<=r;++h){const u=c[a-s].clone().multiplyScalar(l[h][0]);for(let d=1;d<=s;++d)u.add(c[a-s+d].clone().multiplyScalar(l[h][d]));o[h]=u}for(let h=r+1;h<=i+1;++h)o[h]=new w.Vector4(0,0,0);return o}function e3(s,e){let t=1;for(let i=2;i<=s;++i)t*=i;let n=1;for(let i=2;i<=e;++i)n*=i;for(let i=2;i<=s-e;++i)n*=i;return t/n}function t3(s){const e=s.length,t=[],n=[];for(let r=0;r<e;++r){const o=s[r];t[r]=new w.Vector3(o.x,o.y,o.z),n[r]=o.w}const i=[];for(let r=0;r<e;++r){const o=t[r].clone();for(let a=1;a<=r;++a)o.sub(i[r-a].clone().multiplyScalar(e3(r,a)*n[a]));i[r]=o.divideScalar(n[0])}return i}function n3(s,e,t,n,i){const r=ZP(s,e,t,n,i);return t3(r)}class i3 extends w.Curve{constructor(e,t,n,i,r){super();const o=t?t.length-1:0,a=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=i||0,this.endKnot=r||o;for(let l=0;l<a;++l){const c=n[l];this.controlPoints[l]=new w.Vector4(c.x,c.y,c.z,c.w)}}getPoint(e,t=new w.Vector3){const n=t,i=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),r=$P(this.degree,this.knots,this.controlPoints,i);return r.w!==1&&r.divideScalar(r.w),n.set(r.x,r.y,r.z)}getTangent(e,t=new w.Vector3){const n=t,i=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),r=n3(this.degree,this.knots,this.controlPoints,i,1);return n.copy(r[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(t=>t.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(t=>new w.Vector4(t[0],t[1],t[2],t[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}const Tt=1e-8,Fy=.001,s3=8421504;class r3{constructor(e){this.engine=e}create(e,t){const n=this.getLoopSet(e);if(n.outers.length===0)return[];if(this.isGradientFill(e))return this.createGradientItems(e,t,n);if(this.isSolidFill(e))return this.createSolidItems(e,t,n);const r=this.createPatternLineItem(e,t,n);return r?[r]:(this.warnUnknownPatternFallback(e),this.createSolidItems(e,t,n,s3))}isSolidFill(e){const t=String(e.pattern??e.patternName??"").toUpperCase();return e.solid===!0||t==="SOLID"}warnUnknownPatternFallback(e){const t=e.pattern??e.patternName??"UNKNOWN";this.engine.options?.debugHatch===!0&&console.warn(`[LoaderModule2d] HATCH pattern "${t}" cannot be rendered, use gray solid fallback.`)}isGradientFill(e){return e.gradient?.enabled===!0||String(e.patternType??"").toUpperCase()==="GRADIENTFILL"}getLoopSet(e){const t=(e.loops??[]).map(o=>this.normalizeLoop(o.points)).filter(o=>o.length>=3);if(t.length===0)return{outers:[],holes:[]};const n=(e.loops??[]).filter(o=>this.normalizeLoop(o.points).length>=3);if(!n.some(o=>o.type===!1))return this.classifyLoopsByContainment(t);const i=n.filter(o=>o.type!==!1).map(o=>this.normalizeLoop(o.points)),r=n.filter(o=>o.type===!1).map(o=>this.normalizeLoop(o.points));return i.length>0?{outers:i,holes:r}:{outers:[t[0]],holes:t.slice(1)}}classifyLoopsByContainment(e){const t=[...e].sort((r,o)=>Math.abs(this.signedArea(o))-Math.abs(this.signedArea(r))),n=[],i=[];return t.forEach((r,o)=>{const a=new b.Vector2(r[0][0],r[0][1]);t.slice(0,o).filter(c=>this.pointInPolygon(a,c)).length%2===0?n.push(r):i.push(r)}),{outers:n,holes:i}}signedArea(e){let t=0;for(let n=0;n<e.length;n+=1){const i=e[n],r=e[(n+1)%e.length];t+=i[0]*r[1]-r[0]*i[1]}return t/2}normalizeLoop(e){const t=[];(e??[]).forEach(r=>{if(!Array.isArray(r)||r.length<2)return;const o=[Number(r[0]),Number(r[1])];if(!Number.isFinite(o[0])||!Number.isFinite(o[1]))return;const a=t[t.length-1];(!a||Math.hypot(o[0]-a[0],o[1]-a[1])>Tt)&&t.push(o)});const n=t[0],i=t[t.length-1];return n&&i&&Math.hypot(n[0]-i[0],n[1]-i[1])<=Tt&&t.pop(),t}createSolidItems(e,t,n,i){const r=[];if(n.outers.forEach(l=>{const c=this.createShape(l);n.holes.filter(h=>this.pointInPolygon(new b.Vector2(h[0][0],h[0][1]),l)).forEach(h=>{c.holes.push(this.createPath(h))}),r.push(new b.ShapeGeometry(c))}),r.length===0)return[];const o=r.length===1?r[0]:_i(r,!1);o.applyMatrix4(t);const a=Mr(o);return[{kind:"hatch",layer:e.layer??"0",color:i??this.resolveEntityColor(e),linkId:e.linkId??e.id,geometry:o,min:a.min,max:a.max,info:e}]}createShape(e){const t=new b.Shape;t.moveTo(e[0][0],e[0][1]);for(let n=1;n<e.length;n+=1)t.lineTo(e[n][0],e[n][1]);return t.closePath(),t}createPath(e){const t=new b.Path;t.moveTo(e[0][0],e[0][1]);for(let n=1;n<e.length;n+=1)t.lineTo(e[n][0],e[n][1]);return t.closePath(),t}createGradientItems(e,t,n){const i=[];if(n.outers.forEach(a=>{const l=this.createShape(a);n.holes.filter(h=>this.pointInPolygon(new b.Vector2(h[0][0],h[0][1]),a)).forEach(h=>{l.holes.push(this.createPath(h))});const c=this.subdivideTriangles(new b.ShapeGeometry(l),this.engine.options?.hatchGradientSubdivisions??3);this.applyGradientVertexColors(c,a,e.gradient),i.push(c)}),i.length===0)return[];const r=i.length===1?i[0]:_i(i,!1);r.applyMatrix4(t);const o=Mr(r);return[{kind:"hatch",layer:e.layer??"0",color:this.resolveEntityColor(e),linkId:e.linkId??e.id,geometry:r,useVertexColors:!0,min:o.min,max:o.max,info:e}]}applyGradientVertexColors(e,t,n){const i=e.getAttribute("position"),r=[],o=this.resolveGradientStops(n),a=this.getBounds(t),l=new b.Vector2((a.minX+a.maxX)/2,(a.minY+a.maxY)/2),c=Math.max(a.maxX-a.minX,Tt),h=Math.max(a.maxY-a.minY,Tt),u=Math.max(Math.hypot(c/2,h/2),Tt),d=Number(n?.angle??0),f=new b.Vector2(Math.cos(d),Math.sin(d)).normalize(),m=new b.Vector2(-f.y,f.x);for(let g=0;g<i.count;g+=1){const A=new b.Vector2(i.getX(g),i.getY(g)),p=this.resolveGradientFactor(A,l,f,m,c,h,u,n),x=this.sampleGradientColor(o,p);r.push(x.r,x.g,x.b)}e.setAttribute("color",new b.Float32BufferAttribute(r,3))}subdivideTriangles(e,t){let n=e.index?e.toNonIndexed():e.clone();const i=Math.max(0,Math.min(Math.floor(Number(t)||0),5));for(let r=0;r<i;r+=1){const o=n.getAttribute("position"),a=[];for(let l=0;l<o.count;l+=3){const c=new b.Vector3(o.getX(l),o.getY(l),o.getZ(l)),h=new b.Vector3(o.getX(l+1),o.getY(l+1),o.getZ(l+1)),u=new b.Vector3(o.getX(l+2),o.getY(l+2),o.getZ(l+2)),d=c.clone().lerp(h,.5),f=h.clone().lerp(u,.5),m=u.clone().lerp(c,.5);this.pushTriangle(a,c,d,m),this.pushTriangle(a,d,h,f),this.pushTriangle(a,m,f,u),this.pushTriangle(a,d,f,m)}n=new b.BufferGeometry().setAttribute("position",new b.Float32BufferAttribute(a,3))}return n}pushTriangle(e,t,n,i){e.push(t.x,t.y,t.z,n.x,n.y,n.z,i.x,i.y,i.z)}resolveGradientFactor(e,t,n,i,r,o,a,l){const c=e.clone().sub(t),h=String(l?.name??"LINEAR").toUpperCase(),u=Number(l?.shift??0),d=Math.max(Math.abs(n.x)*r+Math.abs(n.y)*o,Tt),f=Math.max(Math.abs(i.x)*r+Math.abs(i.y)*o,Tt);let m=.5+c.dot(n)/d+u;return h.includes("CYLINDER")?m=Math.abs(c.dot(i))/(f/2):h.includes("SPHERICAL")?(m=c.length()/a,h.includes("HEMI")&&(m=Math.sqrt(m))):h.includes("CURVED")&&(m=Math.pow(Math.abs(c.dot(n))/(d/2),.65)),h.startsWith("INV")&&(m=1-m),b.MathUtils.clamp(m,0,1)}resolveGradientStops(e){const t=(e?.colors??[]).map(n=>({value:b.MathUtils.clamp(Number(n.value??0),0,1),color:this.resolveGradientStopColor(n)})).sort((n,i)=>n.value-i.value);if(t.length>=2)return t;if(t.length===1){const n=b.MathUtils.clamp(Number(e?.colorTint??0),0,1);return[{value:0,color:t[0].color.clone().lerp(new b.Color(16777215),n)},{value:1,color:t[0].color}]}return[{value:0,color:new b.Color(16777215)},{value:1,color:new b.Color(0)}]}resolveGradientStopColor(e){if(Array.isArray(e.rgb)&&e.rgb.length>=3){const[t,n,i]=e.rgb.map(r=>b.MathUtils.clamp(Number(r??0),0,255)/255);return new b.Color(t,n,i)}return new b.Color(e.color??16777215)}resolveEntityColor(e){if(Array.isArray(e.rgb)&&e.rgb.length>=3){const[t,n,i]=e.rgb.map(r=>Math.round(b.MathUtils.clamp(Number(r??0),0,255)));return t<<16|n<<8|i}return e.color??16777215}sampleGradientColor(e,t){if(t<=e[0].value)return e[0].color.clone();for(let n=0;n<e.length-1;n+=1){const i=e[n],r=e[n+1];if(t<=r.value+Tt){const o=Math.max(r.value-i.value,Tt);return i.color.clone().lerp(r.color,(t-i.value)/o)}}return e[e.length-1].color.clone()}createPatternLineItem(e,t,n){const i=[],r=this.engine.options?.hatchPatternMaxSegments??2e4;let o=0;for(const l of n.outers){const c=this.getBounds(l),h=Math.hypot(c.maxX-c.minX,c.maxY-c.minY);if(!(h<Tt))for(const u of e.patternLines??[]){if(o>=r)break;const d=this.createPatternFamilySegments(e,u,l,n.holes,c,h,r-o);d.forEach(([f,m])=>{i.push(new b.Vector3(f.x,f.y,Fy),new b.Vector3(m.x,m.y,Fy))}),o+=d.length}}if(i.length===0)return null;i.forEach(l=>l.applyMatrix4(t));const a=Ry(i);return{kind:"line",layer:e.layer??"0",color:this.resolveEntityColor(e),linkId:e.linkId??e.id,points:i,min:a.min,max:a.max,info:e}}createPatternFamilySegments(e,t,n,i,r,o,a){const l=this.resolvePatternLineTransform(e,t),c=l.dir,h=new b.Vector2(-c.y,c.x),u=l.base,d=l.offset;let f=d.dot(h);if(Math.abs(f)<Tt&&(f=Number(t.lineOffset??0)),Math.abs(f)<Tt)return[];const m=[new b.Vector2(r.minX,r.minY),new b.Vector2(r.maxX,r.minY),new b.Vector2(r.maxX,r.maxY),new b.Vector2(r.minX,r.maxY)],g=u.dot(h),A=m.map(I=>I.dot(h)-g),p=Math.min(...A)-o,x=Math.max(...A)+o,y=Math.floor(Math.min(p/f,x/f))-2,v=Math.ceil(Math.max(p/f,x/f))+2,_=[],E=new b.Vector2((r.minX+r.maxX)/2,(r.minY+r.maxY)/2);for(let I=y;I<=v&&_.length<a;I+=1){const B=u.clone().add(d.clone().multiplyScalar(I)),M=B.clone().add(c.clone().multiplyScalar(E.clone().sub(B).dot(c))),C=M.clone().add(c.clone().multiplyScalar(-o*2)),P=M.clone().add(c.clone().multiplyScalar(o*2));this.clipLineByPolygon(C,P,n).forEach(([R,S])=>{this.subtractHoles(R,S,i).forEach(([F,N])=>{this.appendDashedSegment(_,F,N,t.dashLengths,B,c)})})}return _.slice(0,a)}resolvePatternLineTransform(e,t){const n=Number(t.angle??e.patternAngle??0);return{dir:new b.Vector2(Math.cos(n),Math.sin(n)).normalize(),base:this.toVector2(t.basePoint),offset:this.toVector2(t.offset)}}toVector2(e){return new b.Vector2(e?.[0]??0,e?.[1]??0)}getBounds(e){return{minX:Math.min(...e.map(t=>t[0])),minY:Math.min(...e.map(t=>t[1])),maxX:Math.max(...e.map(t=>t[0])),maxY:Math.max(...e.map(t=>t[1]))}}clipLineByPolygon(e,t,n){const i=[0,1];for(let a=0;a<n.length;a+=1){const l=new b.Vector2(n[a][0],n[a][1]),c=new b.Vector2(n[(a+1)%n.length][0],n[(a+1)%n.length][1]),h=this.segmentIntersectionT(e,t,l,c);h!==null&&h>Tt&&h<1-Tt&&i.push(h)}const r=this.dedupeSorted(i.sort((a,l)=>a-l),1e-7),o=[];for(let a=0;a<r.length-1;a+=1){const l=r[a],c=r[a+1];if(c-l<1e-7)continue;const h=this.interpolate2(e,t,(l+c)/2);this.pointInPolygon(h,n)&&o.push([this.interpolate2(e,t,l),this.interpolate2(e,t,c)])}return o}subtractHoles(e,t,n){let i=[[e,t]];return n.forEach(r=>{const o=[];i.forEach(([a,l])=>{const c=this.clipLineByPolygon(a,l,r);o.push(...this.subtractSegments(a,l,c))}),i=o}),i}appendDashedSegment(e,t,n,i,r,o){const a=t.distanceTo(n);if(a<Tt)return;if(!i?.length){e.push([t,n]);return}const l=this.normalizeDashPattern(i),c=l.reduce((y,v)=>y+v.length,0);if(c<Tt){e.push([t,n]);return}const h=o?.clone().normalize()??n.clone().sub(t).normalize(),u=r??t,f=n.clone().sub(t).normalize().dot(h)>=0?1:-1,m=t.clone().sub(u).dot(h)*f,g=this.positiveModulo(m,c);let A=0,p=this.findDashIndex(l,g),x=g-l[p].start;for(;A<a-Tt;){const y=l[p],v=Math.max(y.length-x,Tt),_=Math.min(a,A+v);y.draw&&e.push([this.pointAtLength(t,n,A),this.pointAtLength(t,n,_)]),A=_,p=(p+1)%l.length,x=0}}normalizeDashPattern(e){let t=0;return e.map(n=>{const i=Number(n??0),r={length:Math.max(Math.abs(i),5e-4),draw:i>=0,start:t};return t+=r.length,r}).filter(n=>n.length>Tt)}findDashIndex(e,t){for(let n=e.length-1;n>=0;n-=1)if(t>=e[n].start-Tt)return n;return 0}positiveModulo(e,t){return(e%t+t)%t}subtractSegments(e,t,n){const i=n.map(([a,l])=>[this.projectT(e,t,a),this.projectT(e,t,l)]).map(([a,l])=>[Math.max(0,Math.min(a,l)),Math.min(1,Math.max(a,l))]).sort((a,l)=>a[0]-l[0]),r=[];let o=0;return i.forEach(([a,l])=>{a>o+Tt&&r.push([this.interpolate2(e,t,o),this.interpolate2(e,t,a)]),o=Math.max(o,l)}),o<1-Tt&&r.push([this.interpolate2(e,t,o),this.interpolate2(e,t,1)]),r}segmentIntersectionT(e,t,n,i){const r=t.clone().sub(e),o=i.clone().sub(n),a=this.cross2(r,o);if(Math.abs(a)<1e-10)return null;const l=n.clone().sub(e),c=this.cross2(l,o)/a,h=this.cross2(l,r)/a;return c>=-1e-8&&c<=1+1e-8&&h>=-1e-8&&h<=1+1e-8?c:null}pointInPolygon(e,t){let n=!1;for(let i=0,r=t.length-1;i<t.length;r=i,i+=1){const o=t[i][0],a=t[i][1],l=t[r][0],c=t[r][1];a>e.y!=c>e.y&&e.x<(l-o)*(e.y-a)/(c-a+1e-20)+o&&(n=!n)}return n}cross2(e,t){return e.x*t.y-e.y*t.x}interpolate2(e,t,n){return e.clone().lerp(t,n)}projectT(e,t,n){const i=t.clone().sub(e),r=i.lengthSq();return r<1e-12?0:n.clone().sub(e).dot(i)/r}pointAtLength(e,t,n){const i=e.distanceTo(t);return this.interpolate2(e,t,i<1e-12?0:n/i)}dedupeSorted(e,t){const n=[];return e.forEach(i=>{(!n.length||Math.abs(i-n[n.length-1])>t)&&n.push(i)}),n}}class o3{constructor(e,t){this.engine=e,this.textFactory=t,this.hatchRenderer=new r3(e)}hatchRenderer;create(e,t){switch(e.type){case"LINE_GROUP":case"LINE":case"CIRCLE":case"POLYLINE":case"SPLINE":return this.createLineItem(e,t);case"MTEXT":case"TEXT":return this.textFactory.create(e,t);case"HATCH":return this.createHatch(e,t);case"IMAGE":return this.createImage(e,t);default:return[]}}createLineItem(e,t){const n=this.getEntityPoints(e).map(i=>i.clone().applyMatrix4(t));return n.length===0?[]:[{kind:"line",layer:e.layer,color:e.color,lineType:e.lineType,lineTypeScale:e.lineTypeScale,lineTypePattern:Array.isArray(e.lineTypePattern)?e.lineTypePattern:void 0,linkId:e.linkId??e.id,points:n,info:e}]}getEntityPoints(e){switch(e.type){case"LINE_GROUP":return this.getLineGroupPoints(e);case"LINE":return[ks(e.startPoint),ks(e.endPoint)];case"CIRCLE":return this.getCirclePoints(e);case"POLYLINE":return this.getPolylinePoints(e);case"SPLINE":return this.getSplinePoints(e);default:return[]}}getLineGroupPoints(e){const t=[];return(e.segments??[]).forEach(n=>{t.push(new b.Vector3(n[0]??0,n[1]??0,n[2]??0)),t.push(new b.Vector3(n[3]??0,n[4]??0,n[5]??0))}),t}getCirclePoints(e){const t=new b.EllipseCurve(e.center?.[0]??0,e.center?.[1]??0,e.radius??0,e.radius??0,e.startAngle??0,(e.endAngle??Math.PI*2)-1e-5,!1,0);return this.pointsToSegments(t.getPoints(this.engine.options?.circleSegments??48).map(n=>new b.Vector3(n.x,n.y,e.center?.[2]??0)))}getPolylinePoints(e){const t=[],n=e.points??[];for(let i=0;i<n.length-1;i+=1)this.getPolylineSegmentPoints(n[i],n[i+1]).forEach(r=>{t.push(r)});return e.closed&&n.length>1&&this.getPolylineSegmentPoints(n[n.length-1],n[0]).forEach(i=>{t.push(i)}),t}getPolylineSegmentPoints(e,t){const n=ks(e),i=ks(t),r=Number(e?.bulge??0);if(!Number.isFinite(r)||Math.abs(r)<1e-10)return[n,i];const o=i.clone().sub(n),a=o.length();if(a<1e-12)return[n,i];const l=4*Math.atan(r),c=a*(1+r*r)/(4*Math.abs(r)),h=n.clone().add(i).multiplyScalar(.5),u=new b.Vector3(-o.y/a,o.x/a,0),d=h.clone().add(u.multiplyScalar(a*(1-r*r)/(4*r))),f=Math.atan2(n.y-d.y,n.x-d.x),m=Math.max(4,Math.ceil(Math.abs(l)/(this.engine.options?.polylineArcAngleStep??Math.PI/18))),g=[];for(let A=0;A<=m;A+=1){const p=A/m,x=f+l*p;g.push(new b.Vector3(d.x+Math.cos(x)*c,d.y+Math.sin(x)*c,n.z+(i.z-n.z)*p))}return this.pointsToSegments(g)}getSplinePoints(e){const t=(e.points??[]).map(i=>ks(i));if(t.length<2)return[];const n=t.length===2?t:this.sampleSplineCurve(t,e);return this.pointsToSegments(n)}sampleSplineCurve(e,t){const n=Math.min(Math.max(Number(t.degree??this.engine.options?.splineDegree??6),1),e.length-1),i=Array.isArray(t.knots)&&t.knots.length===e.length+n+1?t.knots:this.createClampedUniformKnots(e.length,n),r=e.map((l,c)=>{const h=Array.isArray(t.weights)?Number(t.weights[c]??1):1;return new b.Vector4(l.x,l.y,l.z,Number.isFinite(h)?h:1)});let o=(e.length-1)*2;const a=new i3(n,i,r).getPoints(o);return t.closed===!0&&a.length>1&&a.push(a[0].clone()),a}createClampedUniformKnots(e,t){const n=[];for(let i=0;i<e+t+1;i+=1)i<=t?n.push(0):i>=e?n.push(1):n.push((i-t)/(e-t));return n}pointsToSegments(e){const t=[];for(let n=0;n<e.length-1;n+=1)t.push(e[n].clone(),e[n+1].clone());return t}createHatch(e,t){return this.hatchRenderer.create(e,t)}createImage(e,t){const n=e.imageUrl||e.url;if(!n)return[];const i=ks(e.position),r=ks(e.uVector),o=ks(e.vVector),a=Number(e.pixelWidth??e.width??1),l=Number(e.pixelHeight??e.height??1);if(!Number.isFinite(a)||!Number.isFinite(l)||a===0||l===0)return[];const c=r.multiplyScalar(a),h=o.multiplyScalar(l),u=i.clone(),d=i.clone().add(c),f=i.clone().add(c).add(h),m=i.clone().add(h);[u,d,f,m].forEach(x=>x.applyMatrix4(t));const g=new b.BufferGeometry;g.setAttribute("position",new b.Float32BufferAttribute([u.x,u.y,u.z,d.x,d.y,d.z,f.x,f.y,f.z,u.x,u.y,u.z,f.x,f.y,f.z,m.x,m.y,m.z],3)),g.setAttribute("uv",new b.Float32BufferAttribute([0,0,1,0,1,1,0,0,1,1,0,1],2)),g.computeVertexNormals();const A=Mr(g),p=Number(e.fade??0);return[{kind:"image",layer:e.layer??"0",color:e.color??16777215,linkId:e.linkId??e.id,geometry:g,imageUrl:n,opacity:Number.isFinite(p)?b.MathUtils.clamp(1-p/100,0,1):1,min:A.min,max:A.max,info:e}]}}class a3{constructor(e,t,n=e.modelGroup){this.model=t,this.targetGroup=n}modelMap=new Map;hatchMap=new Map;textMap=new Map;imageMap=new Map;textureLoader=new b.TextureLoader;addRenderItems(e){e.forEach(t=>this.addRenderItem(t))}buildSceneObjects(){this.buildImageObjects(),this.buildHatchObjects(),this.buildLineObjects(),this.buildTextObjects()}addRenderItem(e){const t=`${e.layer}||${e.color}`;if(e.kind==="line"){let o=this.modelMap.get(t);o||(o=new Map,this.modelMap.set(t,o));const a=this.resolveLinePoints(e),l=o.get(e.linkId);l?a.forEach(c=>l.push(c)):o.set(e.linkId,[...a]);return}const n=this.getItemMap(e),i=e.kind==="image"?`${t}||${e.imageUrl??""}`:t,r=n.get(i);r?r.push(e):n.set(i,[e])}getItemMap(e){return e.kind==="text"?this.textMap:e.kind==="image"?this.imageMap:this.hatchMap}resolveLinePoints(e){const t=e.points??[],n=this.resolveLineTypePattern(e);if(!n)return t;const i=[];for(let r=0;r<t.length-1;r+=2)this.applyDashPattern(t[r],t[r+1],n).forEach(o=>i.push(o));return i}resolveLineTypePattern(e){const t=this.model.layers.find(l=>l.name===e.layer),n=String(e.lineType??"").toLowerCase(),i=n==="bylayer"||n===""?String(t?.lineType??"").toLowerCase():n;if(!i||i==="continuous"||i==="byblock")return null;const r=Array.isArray(e.lineTypePattern)&&e.lineTypePattern.length>0?e.lineTypePattern:Array.isArray(t?.lineTypePattern)?t.lineTypePattern:this.getFallbackLineTypePattern(i);if(!r||r.length===0)return null;const o=this.resolveLineTypeScale(e,t),a=r.map(l=>Number(l)).filter(l=>Number.isFinite(l)).map(l=>l*o);return a.some(l=>Math.abs(l)>1e-12)?a:null}getFallbackLineTypePattern(e){return e.includes("dash")?[.25,-.1]:e.includes("dot")?[0,-.1]:null}resolveLineTypeScale(e,t){const n=Number(e.lineTypeScale??t?.lineTypeScale??1);return!Number.isFinite(n)||Math.abs(n)<1e-12?1:Math.abs(n)}applyDashPattern(e,t,n){const i=t.clone().sub(e),r=i.length();if(r<1e-12)return[];const o=i.multiplyScalar(1/r),a=n.reduce((d,f)=>d+Math.abs(f),0),l=Math.max(a*.05,r*.002,1e-6),c=[];let h=0,u=0;for(;h<r-1e-12;){const d=n[u%n.length],f=d>=0,m=Math.max(Math.abs(d),l),g=Math.min(h+m,r);if(f&&g>h&&c.push(e.clone().add(o.clone().multiplyScalar(h)),e.clone().add(o.clone().multiplyScalar(g))),h=g,u+=1,u>1e5)break}return c}buildLineObjects(){this.modelMap.forEach((e,t)=>{const[n]=t.split("||"),i=[];if(e.forEach(u=>{u.forEach(d=>i.push(d))}),i.length===0)return;const r=new b.BufferGeometry().setFromPoints(i),o=new b.LineBasicMaterial({color:this.resolveColor(t)}),a=new b.LineSegments(r,o);a.name=t;const l=r.getAttribute("position");a.clonePoints=l.array.slice(),a.materialClone=o.clone(),this.targetGroup.add(a);const c=this.targetGroup.children.length-1;let h=0;e.forEach((u,d)=>{const f=Ry(u);this.pushNodeMap(d,{indexes:[c,h,h+u.length*3],object:a,group:this.targetGroup,kind:"line",layer:n,min:f.min,max:f.max}),h+=u.length*3})})}buildTextObjects(){this.textMap.forEach((e,t)=>{const n=e.filter(a=>!!a.geometry),i=this.normalizeMeshGeometries(n,!1,!1);if(i.length===0)return;const r=this.mergeMeshGeometries(i),o=new b.MeshBasicMaterial({color:this.resolveColor(t),side:b.DoubleSide});t.includes("_hitbox")&&(o.visible=!1),this.addMeshObject(n,t,r,i,o)})}buildHatchObjects(){this.hatchMap.forEach((e,t)=>{const n=e.filter(l=>!!l.geometry),i=n.some(l=>l.useVertexColors===!0),r=this.normalizeMeshGeometries(n,!1,i);if(r.length===0)return;const o=this.mergeMeshGeometries(r),a=new b.MeshBasicMaterial({color:i?16777215:this.resolveColor(t),side:b.DoubleSide,transparent:!0,opacity:i?1:.5,vertexColors:i});this.addMeshObject(n,t,o,r,a)})}buildImageObjects(){this.imageMap.forEach((e,t)=>{const n=e.filter(h=>!!h.geometry),i=this.normalizeMeshGeometries(n,!0,!1);if(i.length===0)return;const r=n[0]?.imageUrl;if(!r)return;const o=this.mergeMeshGeometries(i),a=this.textureLoader.load(r);a.colorSpace=b.SRGBColorSpace,a.needsUpdate=!0;const l=n.reduce((h,u)=>Math.min(h,u.opacity??1),1),c=new b.MeshBasicMaterial({map:a,side:b.DoubleSide,transparent:!0,opacity:l,depthWrite:!1});this.addMeshObject(n,t,o,i,c)})}mergeMeshGeometries(e){const t=e.length===1?e[0]:_i(e,!0);if(t.groups.length===0){const n=t.getAttribute("position");t.addGroup(0,n?.count??0,0)}return t.groups.forEach(n=>{n.materialIndex=0}),t}normalizeMeshGeometries(e,t,n){return e.map(i=>{const r=i.geometry,o=r.index?r.toNonIndexed():r.clone(),a=o.getAttribute("position"),l=o.getAttribute("uv"),c=o.getAttribute("color"),h=new b.BufferGeometry;return h.setAttribute("position",a.clone()),t&&h.setAttribute("uv",l?l.clone():this.createEmptyUv(a.count)),n&&h.setAttribute("color",c?c.clone():this.createSolidColorAttribute(a.count,i.color)),h})}createEmptyUv(e){return new b.Float32BufferAttribute(new Array(e*2).fill(0),2)}createSolidColorAttribute(e,t){const n=new b.Color(t??16777215),i=[];for(let r=0;r<e;r+=1)i.push(n.r,n.g,n.b);return new b.Float32BufferAttribute(i,3)}addMeshObject(e,t,n,i,r){const o=new b.Mesh(n,r);o.name=t,o.materialClone=r.clone(),o.isSplit=!1,o.geometrys=void 0,i.forEach(l=>{l!==n&&l.dispose()}),this.targetGroup.add(o);const a=this.targetGroup.children.length-1;e.forEach((l,c)=>{const h=l.linkId??l.info?.id;this.pushNodeMap(h,{indexes:[a,c],object:o,group:this.targetGroup,kind:l.kind,layer:l.layer,info:l.info,min:l.min??new b.Vector3,max:l.max??new b.Vector3}),this.pushTextSearchItem(l,t)})}pushTextSearchItem(e,t){if(e.kind!=="text"||t.includes("_hitbox"))return;const n=e.info?.text,i=String(n??"").replace(/\r\n/g,`
|
|
5554
5554
|
`).replace(/\r/g,`
|
|
5555
5555
|
`).trim(),r=e.linkId??e.info?.id;!i||r==null||this.model.textItems.push({id:String(r),text:i,layer:e.layer,min:e.min,max:e.max,anchor:e.textAnchor,info:e.info})}resolveColor(e){const[t,n]=e.split("||");let i=Number.parseInt(n);return(i===0||Number.isNaN(i))&&(i=this.model.layers.find(o=>o.name===t)?.color??16777215),i}pushNodeMap(e,t){if(e==null)return;const n=String(e),i=this.model.nodeMap.get(n);i?i.push(t):this.model.nodeMap.set(n,[t])}}class l3{constructor(e,t){this.engine=e,this.font=t}create(e,t=new b.Matrix4){if(!e.text)return[];const n=this.normalizeText(e.text);if(!n.trim())return[];const i=this.engine.options?.textCurveSegments??1,r=this.createTextGeometry(n,e.height??100,i);if(!r)return[];const o=[...e.position??[0,0,0]];o[1]=o[1]-(e.height??0);const a=this.resolveWidthScale(e),l=new b.Vector3(o[0]??0,o[1]??0,o[2]??0).applyMatrix4(t),c=1.4*e.scale;r.applyMatrix4(t.clone().multiply(cp(o,[a*1.4,1*c,1*c],e.rotation??0)));const h=Mr(r),u=[{kind:"text",layer:e.layer,color:e.color,linkId:e.linkId??e.id,geometry:r,min:h.min,max:h.max,textAnchor:l,info:e}],d=this.createHitbox(r);if(d){const f=Mr(d);u.push({kind:"text",layer:e.layer,color:`${e.color}_hitbox`,linkId:e.linkId??e.id,geometry:d,min:f.min,max:f.max,textAnchor:l,info:e})}return u}resolveWidthScale(e){const t=Number(e.widthScale??e.widthFactor??1);return!Number.isFinite(t)||Math.abs(t)<1e-12?1:t}normalizeText(e){return String(e??"").replace(/\r\n/g,`
|
|
5556
5556
|
`).replace(/\r/g,`
|
|
@@ -6060,7 +6060,7 @@ void main() {
|
|
|
6060
6060
|
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
6061
6061
|
gl_FragColor = color;
|
|
6062
6062
|
}
|
|
6063
|
-
`}applyTo2d({imageData:{data:s}}){let e=-this.vibrance;for(let t=0;t<s.length;t+=4){let n=s[t],i=s[t+1],r=s[t+2],o=Math.max(n,i,r),a=(n+i+r)/3,l=2*Math.abs(o-a)/255*e;s[t]+=o===n?0:(o-n)*l,s[t+1]+=o===i?0:(o-i)*l,s[t+2]+=o===r?0:(o-r)*l}}sendUniformData(s,e){s.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};K(ml,"type","Vibrance"),K(ml,"defaults",{vibrance:0}),K(ml,"uniformLocations",["uVibrance"]),ke.setClass(ml),Ua({BaseFilter:()=>zt,BlackWhite:()=>OR,BlendColor:()=>nl,BlendImage:()=>il,Blur:()=>sl,Brightness:()=>rl,Brownie:()=>DR,ColorMatrix:()=>Ur,Composed:()=>ag,Contrast:()=>ol,Convolute:()=>al,Gamma:()=>ll,Grayscale:()=>cl,HueRotation:()=>qh,Invert:()=>hl,Kodachrome:()=>LR,Noise:()=>ul,Pixelate:()=>dl,Polaroid:()=>kR,RemoveColor:()=>fl,Resize:()=>pl,Saturation:()=>gl,Sepia:()=>FR,Technicolor:()=>RR,Vibrance:()=>ml,Vintage:()=>PR});function GR(s,e,t="bim-snapshot.png"){const n=s?.renderer,i=n?.domElement;if(!n||!i||!e)return null;const r=i.width||i.clientWidth,o=i.height||i.clientHeight;if(r<=0||o<=0)return null;let a=VR(i,r,o);if(!QR(a)){const d=jR(s,r,o);d&&(a=d)}const l=document.createElement("canvas");l.width=r,l.height=o;const c=l.getContext("2d");if(!c)return null;c.drawImage(a,0,0,r,o),c.drawImage(e,0,0,r,o);const h=l.toDataURL("image/png"),u=document.createElement("a");return u.href=h,u.download=t.toLowerCase().endsWith(".png")?t:`${t}.png`,u.click(),h}function VR(s,e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const i=n.getContext("2d");return i&&i.drawImage(s,0,0,e,t),n}function QR(s){const e=s.getContext("2d");if(!e||s.width<=0||s.height<=0)return!1;const t=Math.min(32,s.width),n=Math.min(32,s.height),i=Math.max(1,Math.floor(s.width/t)),r=Math.max(1,Math.floor(s.height/n));for(let o=0;o<s.height;o+=r)for(let a=0;a<s.width;a+=i){const l=e.getImageData(a,o,1,1).data;if(l[0]!==0||l[1]!==0||l[2]!==0||l[3]!==0)return!0}return!1}function jR(s,e,t){const n=s?.renderer,i=s?.scene,r=s?.camera;if(!n||!i||!r)return null;const o=new b.WebGLRenderTarget(e,t,{minFilter:b.LinearFilter,magFilter:b.LinearFilter,format:b.RGBAFormat,depthBuffer:!0,stencilBuffer:!0}),a=n.getRenderTarget(),l=n.autoClear,c=n.xr?.enabled??!1;try{n.xr&&(n.xr.enabled=!1),n.autoClear=!0,n.setRenderTarget(o),n.clear(!0,!0,!0),n.render(i,r);const h=new Uint8Array(e*t*4);return n.readRenderTargetPixels(o,0,0,e,t,h),WR(h,e,t)}catch{return null}finally{n.setRenderTarget(a),n.autoClear=l,n.xr&&(n.xr.enabled=c),o.dispose()}}function WR(s,e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const i=n.getContext("2d");if(!i)return n;const r=i.createImageData(e,t),o=e*4;for(let a=0;a<t;a++){const l=(t-1-a)*o,c=a*o;for(let h=0;h<o;h++)r.data[c+h]=s[l+h]}return i.putImageData(r,0,0),n}const HR=["#ffffff","#000000","#ff4d4f","#fa8c16","#fadb14","#52c41a","#13c2c2","#1677ff","#722ed1","#eb2f96"],qR={none:new URL("/assets/icon/%E9%80%89%E6%8B%A9.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,line:new URL("/assets/icon/%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,arrow:new URL("/assets/icon/%E7%AE%AD%E5%A4%B4.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,rect:new URL("/assets/icon/%E7%9F%A9%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,circle:new URL("/assets/icon/%E5%9C%86%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,text:new URL("/assets/icon/%E6%96%87%E5%AD%97.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,cloudline:new URL("/assets/icon/%E4%BA%91%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href},XR=new URL("/assets/icon/%E6%B5%8B%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,YR=new URL("/assets/icon/%E6%88%AA%E5%9B%BE.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,KR=new URL("/assets/icon/%E7%BA%BF%E5%AE%BD.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,$R=new URL("/assets/icon/%E5%AD%97%E5%8F%B7.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,JR=[{type:"distance",label:"距离"},{type:"clearDistance",label:"净距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],ZR={distance:new URL("/assets/icon/%E8%B7%9D%E7%A6%BB.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearDistance:new URL("/assets/icon/%E5%87%80%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearHeight:new URL("/assets/icon/%E5%87%80%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,elevation:new URL("/assets/icon/%E6%A0%87%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,point:new URL("/assets/icon/%E5%9D%90%E6%A0%87.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,angle:new URL("/assets/icon/%E8%A7%92%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,area:new URL("/assets/icon/%E9%9D%A2%E7%A7%AF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,slope:new URL("/assets/icon/%E5%9D%A1%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href};class ek{constructor(e,t){this.handlers=e,this.root=document.createElement("div"),this.root.style.position="absolute",this.root.style.top="8px",this.root.style.left="50%",this.root.style.transform="translateX(-50%)",this.root.style.display="none",this.root.style.padding="6px",this.root.style.background="#ffffff",this.root.style.border="1px solid #d9d9d9",this.root.style.borderRadius="8px",this.root.style.pointerEvents="auto",this.root.style.userSelect="none",this.root.style.boxShadow="0 4px 14px rgba(0, 0, 0, 0.12)",this.root.style.zIndex="1300",this.root.style.overflow="visible",this.editPanel=document.createElement("div"),this.editPanel.style.display="flex",this.editPanel.style.flexDirection="column",this.editPanel.style.gap="6px",this.viewPanel=document.createElement("div"),this.viewPanel.style.display="none",this.viewPanel.style.alignItems="center",this.viewPanel.style.gap="6px";const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.gap="6px",n.style.flexWrap="wrap",[{type:"none",label:"选择"},{type:"line",label:"线"},{type:"arrow",label:"箭头"},{type:"rect",label:"矩形"},{type:"circle",label:"圆形"},{type:"text",label:"文字"},{type:"cloudline",label:"云线"}].forEach(f=>{const m=this.createIconButton(f.label,qR[f.type]);m.onclick=()=>this.handlers.onDrawTypeChange(f.type),this.drawButtons[f.type]=m,n.appendChild(m)});const r=document.createElement("div");r.style.position="relative",r.style.display="flex",r.style.alignItems="center",this.colorTrigger=document.createElement("button"),this.colorTrigger.type="button",this.colorTrigger.title="颜色",this.colorTrigger.style.width="32px",this.colorTrigger.style.height="24px",this.colorTrigger.style.padding="2px",this.colorTrigger.style.border="1px solid #d9d9d9",this.colorTrigger.style.borderRadius="4px",this.colorTrigger.style.background="#ffffff",this.colorTrigger.style.cursor="pointer",this.colorTrigger.style.display="flex",this.colorTrigger.style.alignItems="center",this.colorTrigger.style.justifyContent="center",this.colorTrigger.onclick=()=>this.setColorPresetVisible(!this.isColorPresetOpen);const o=document.createElement("span");o.style.display="block",o.style.width="100%",o.style.height="100%",o.style.borderRadius="2px",o.style.border="1px solid rgba(0, 0, 0, 0.12)",this.colorTrigger.appendChild(o),r.appendChild(this.colorTrigger),this.colorInput=document.createElement("input"),this.colorInput.type="color",this.colorInput.value=t.stroke,this.colorInput.style.position="absolute",this.colorInput.style.width="1px",this.colorInput.style.height="1px",this.colorInput.style.opacity="0",this.colorInput.style.pointerEvents="none",this.colorInput.style.left="0",this.colorInput.style.top="0",this.colorInput.tabIndex=-1,this.colorInput.oninput=()=>{this.updateColorControl(this.colorInput.value),this.handlers.onColorChange(this.colorInput.value),this.setColorPresetVisible(!1)},r.appendChild(this.colorInput),this.colorPresetPanel=document.createElement("div"),this.colorPresetPanel.style.position="absolute",this.colorPresetPanel.style.top="30px",this.colorPresetPanel.style.left="0",this.colorPresetPanel.style.display="none",this.colorPresetPanel.style.padding="8px",this.colorPresetPanel.style.background="#ffffff",this.colorPresetPanel.style.border="1px solid #d9d9d9",this.colorPresetPanel.style.borderRadius="6px",this.colorPresetPanel.style.boxShadow="0 6px 18px rgba(0, 0, 0, 0.14)",this.colorPresetPanel.style.zIndex="20",this.colorPresetPanel.style.width="152px";const a=document.createElement("div");a.style.display="grid",a.style.gridTemplateColumns="repeat(5, 1fr)",a.style.gap="6px",HR.forEach(f=>{const m=document.createElement("button");m.type="button",m.title=f,m.style.width="22px",m.style.height="22px",m.style.padding="0",m.style.border="1px solid #d9d9d9",m.style.borderRadius="4px",m.style.background=f,m.style.cursor="pointer",m.onclick=()=>{this.updateColorControl(f),this.handlers.onColorChange(f),this.setColorPresetVisible(!1)},a.appendChild(m)}),this.colorPresetPanel.appendChild(a);const l=document.createElement("button");l.type="button",l.textContent="自定义",l.style.marginTop="8px",l.style.width="100%",l.style.height="26px",l.style.border="1px solid #d9d9d9",l.style.borderRadius="4px",l.style.background="#ffffff",l.style.color="#333333",l.style.cursor="pointer",l.onclick=()=>this.openNativeColorPicker(),this.colorPresetPanel.appendChild(l),r.appendChild(this.colorPresetPanel),this.updateColorControl(t.stroke),n.appendChild(this.createField("",r)),this.strokeWidthInput=document.createElement("input"),this.strokeWidthInput.type="number",this.strokeWidthInput.min="1",this.strokeWidthInput.max="20",this.strokeWidthInput.step="1",this.strokeWidthInput.value=String(t.strokeWidth),this.strokeWidthInput.style.width="46px",this.strokeWidthInput.oninput=()=>this.handlers.onStrokeWidthChange(this.strokeWidthInput.value),n.appendChild(this.createField("",this.strokeWidthInput,KR,"线宽")),this.fontSizeInput=document.createElement("input"),this.fontSizeInput.type="number",this.fontSizeInput.min="10",this.fontSizeInput.max="96",this.fontSizeInput.step="1",this.fontSizeInput.value=String(t.fontSize),this.fontSizeInput.style.width="46px",this.fontSizeInput.oninput=()=>this.handlers.onFontSizeChange(this.fontSizeInput.value),n.appendChild(this.createField("",this.fontSizeInput,$R,"字号")),this.distanceButton=this.createIconButton("测量",XR),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),n.appendChild(this.distanceButton);const c=this.createIconButton("截图",YR);c.onclick=()=>this.handlers.onScreenshot(),n.appendChild(c);const h=this.createTextButton("×","取消");h.onclick=()=>this.handlers.onCancel(),h.style.background="#ff4d4f",h.style.borderColor="#ff4d4f",h.style.color="#ffffff",n.appendChild(h);const u=this.createTextButton("✔","确定");u.onclick=()=>this.handlers.onConfirm(),u.style.background="#52c41a",u.style.borderColor="#52c41a",u.style.color="#ffffff",n.appendChild(u),this.measureSubPanel=document.createElement("div"),this.measureSubPanel.style.display="none",this.measureSubPanel.style.alignItems="center",this.measureSubPanel.style.gap="6px",this.measureSubPanel.style.flexWrap="wrap",this.measureSubPanel.style.paddingTop="2px",JR.forEach(f=>{const m=this.createSmallIconButton(f.label,ZR[f.type]);m.onclick=()=>this.handlers.onMeasureTypeChange(f.type),this.measureTypeButtons[f.type]=m,this.measureSubPanel.appendChild(m)}),this.editPanel.appendChild(n),this.editPanel.appendChild(this.measureSubPanel);const d=this.createTextButton("关闭","关闭");d.onclick=()=>this.handlers.onClose(),this.viewPanel.appendChild(d),this.root.appendChild(this.editPanel),this.root.appendChild(this.viewPanel),this.disabledMask=document.createElement("div"),this.disabledMask.style.position="absolute",this.disabledMask.style.inset="0",this.disabledMask.style.display="none",this.disabledMask.style.background="rgba(255, 255, 255, 0.55)",this.disabledMask.style.backdropFilter="blur(1px)",this.disabledMask.style.cursor="not-allowed",this.disabledMask.style.pointerEvents="auto",this.disabledMask.style.zIndex="10",this.root.appendChild(this.disabledMask),document.addEventListener("pointerdown",this.onDocumentPointerDown),this.setMode("edit")}root;disabledMask;drawButtons={};measureTypeButtons={};distanceButton;colorTrigger;colorInput;colorPresetPanel;strokeWidthInput;fontSizeInput;editPanel;viewPanel;measureSubPanel;mode="edit";isEditPanelMasked=!1;isColorPresetOpen=!1;onDocumentPointerDown=e=>{const t=e.target;t&&this.root.contains(t)||this.setColorPresetVisible(!1)};mount(e){e.appendChild(this.root)}show(){this.root.style.display="block"}hide(){this.root.style.display="none"}setMode(e){this.mode=e,this.editPanel.style.display=e==="edit"?"flex":"none",this.viewPanel.style.display=e==="view"?"flex":"none",e==="view"&&(this.setMeasurePanelVisible(!1),this.setColorPresetVisible(!1)),this.applyEditPanelMaskState()}setEditPanelMasked(e){this.isEditPanelMasked=e,this.applyEditPanelMaskState()}setDrawType(e){for(const t in this.drawButtons){const n=this.drawButtons[t];if(!n)continue;const i=t===e;n.style.background=i?"#eaf2ff":"#ffffff",n.style.borderColor=i?"#2f80ed":"#d9d9d9"}}setMeasurePanelVisible(e){if(this.mode!=="edit"){this.measureSubPanel.style.display="none";return}this.measureSubPanel.style.display=e?"flex":"none"}setMeasureState(e,t){this.distanceButton.style.background=e?"#eaf2ff":"#ffffff",this.distanceButton.style.borderColor=e?"#2f80ed":"#d9d9d9";for(const n in this.measureTypeButtons){const i=this.measureTypeButtons[n];if(!i)continue;const r=e&&t===n;i.style.background=r?"#eaf2ff":"#ffffff",i.style.borderColor=r?"#2f80ed":"#d9d9d9"}}setStyleValues(e){e.stroke&&this.updateColorControl(e.stroke),typeof e.strokeWidth=="number"&&(this.strokeWidthInput.value=String(e.strokeWidth)),typeof e.fontSize=="number"&&(this.fontSizeInput.value=String(e.fontSize))}dispose(){this.colorInput.oninput=null,this.strokeWidthInput.oninput=null,this.fontSizeInput.oninput=null,document.removeEventListener("pointerdown",this.onDocumentPointerDown),this.root.remove()}applyEditPanelMaskState(){const e=this.mode==="edit"&&this.isEditPanelMasked;this.disabledMask.style.display=e?"block":"none",e&&this.setColorPresetVisible(!1),this.editPanel.querySelectorAll("button, input").forEach(n=>{const i=n;i.disabled=e})}createField(e,t,n,i=""){const r=document.createElement("div");if(r.style.display="flex",r.style.alignItems="center",r.style.gap="4px",r.style.padding="0 2px",r.style.color="#333333",r.style.fontSize="12px",e){const o=document.createElement("span");o.textContent=e,r.appendChild(o)}if(n){const o=document.createElement("img");o.src=n,o.alt=i,o.style.width="14px",o.style.height="14px",o.style.display="block",r.appendChild(o)}return t instanceof HTMLInputElement&&(t.style.height="24px",t.style.border="1px solid #d9d9d9",t.style.borderRadius="4px",t.style.background="#ffffff",t.style.color="#333333",t.style.outline="none",t.style.padding="0 4px"),r.appendChild(t),r}updateColorControl(e){this.colorInput.value=e;const t=this.colorTrigger.firstElementChild;t&&(t.style.background=e)}setColorPresetVisible(e){this.isColorPresetOpen=e,this.colorPresetPanel.style.display=e?"block":"none",this.colorTrigger.style.borderColor=e?"#2f80ed":"#d9d9d9"}openNativeColorPicker(){const e=this.colorInput;if(typeof e.showPicker=="function"){e.showPicker();return}e.click()}createIconButton(e,t){const n=document.createElement("button");n.type="button",n.style.width="28px",n.style.height="28px",n.style.padding="0",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.border="1px solid #d9d9d9",n.style.borderRadius="4px",n.style.background="#ffffff",n.style.cursor="pointer";const i=document.createElement("img");return i.src=t,i.alt=e,i.style.width="16px",i.style.height="16px",i.style.display="block",n.appendChild(i),n}createSmallIconButton(e,t){const n=document.createElement("button");n.type="button",n.style.width="26px",n.style.height="26px",n.style.padding="0",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.border="1px solid #d9d9d9",n.style.borderRadius="4px",n.style.background="#ffffff",n.style.cursor="pointer";const i=document.createElement("img");return i.src=t,i.alt=e,i.style.width="14px",i.style.height="14px",i.style.display="block",n.appendChild(i),n}createTextButton(e,t){const n=document.createElement("button");return n.type="button",n.title=t,n.textContent=e,n.style.width="28px",n.style.height="28px",n.style.padding="0 10px",n.style.border="1px solid #d9d9d9",n.style.borderRadius="4px",n.style.background="#ffffff",n.style.color="#333333",n.style.fontSize="13px",n.style.lineHeight="1",n.style.cursor="pointer",n}}class tk{engine;wrapper;canvasEl;canvas;toolbar;isActive=!1;isVisible=!0;isViewLocked=!0;isDistanceMeasureMode=!1;isMeasurePanelExpanded=!1;drawType="none";mode="edit";currentMeasureType=null;sessionSnapshot=null;actionHandlers={};drawStyle={stroke:"#ff4d4f",strokeWidth:2,fill:"rgba(255, 77, 79, 0.08)",fontSize:16,text:"T",cloudRadius:10};startPoint=null;tempObject=null;cloudPoints=[];onMouseDown=e=>this.handleMouseDown(e);onMouseMove=e=>this.handleMouseMove(e);onMouseUp=e=>this.handleMouseUp(e);onMouseDblClick=e=>this.handleMouseDblClick(e);onSelectionChanged=()=>this.syncStyleFromSelection();onKeyDown=e=>this.handleKeyDown(e);constructor(e){this.engine=e;const t=this.engine.container;if(!t)throw new Error("FabricDraw: engine container not found.");this.wrapper=document.createElement("div"),this.wrapper.className="fabric-draw-layer",this.wrapper.style.position="absolute",this.wrapper.style.left="0",this.wrapper.style.top="0",this.wrapper.style.right="0",this.wrapper.style.bottom="0",this.wrapper.style.pointerEvents="none",this.canvasEl=document.createElement("canvas"),this.canvasEl.style.width="100%",this.canvasEl.style.height="100%",this.wrapper.appendChild(this.canvasEl),this.toolbar=new ek({onDrawTypeChange:i=>this.setDrawType(i),onMeasureToggle:()=>this.toggleMeasurePanel(),onMeasureTypeChange:i=>this.activateDistanceMeasure(i),onScreenshot:()=>{this.saveScreenshot(this.createScreenshotFileName())},onColorChange:i=>this.handleColorInputChange(i),onStrokeWidthChange:i=>this.handleStrokeWidthInputChange(i),onFontSizeChange:i=>this.handleFontSizeInputChange(i),onCancel:()=>{this.handleCancelClick()},onConfirm:()=>this.handleConfirmClick(),onClose:()=>{this.handleCloseClick()}},{stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize}),this.toolbar.mount(this.wrapper);const n=this.engine.renderer?.domElement;n?.nextSibling?t.insertBefore(this.wrapper,n.nextSibling):t.appendChild(this.wrapper),this.canvas=new Zp(this.canvasEl,{selection:!0,preserveObjectStacking:!0}),this.resize(),this.canvas.on("mouse:down",this.onMouseDown),this.canvas.on("mouse:move",this.onMouseMove),this.canvas.on("mouse:up",this.onMouseUp),this.canvas.on("mouse:dblclick",this.onMouseDblClick),this.canvas.on("selection:created",this.onSelectionChanged),this.canvas.on("selection:updated",this.onSelectionChanged),this.canvas.on("selection:cleared",this.onSelectionChanged),window.addEventListener("keydown",this.onKeyDown),this.refreshToolbarState()}active(e="edit"){this.isActive=!0,this.mode=e,this.isViewLocked=!0,this.drawType="none",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.canvas.defaultCursor="default",this.sessionSnapshot=e==="edit"?this.cloneJson(this.getAllShapes()):null,this.toolbar.setMode(e),this.applyCanvasInteractive(e==="edit"),this.isVisible&&this.toolbar.show(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActive(){this.isActive=!1,this.isViewLocked=!0,this.startPoint=null,this.cloudPoints=[],this.tempObject=null,this.drawType="none",this.mode="edit",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.sessionSnapshot=null,this.stopDistanceMeasureMode(),this.canvas.defaultCursor="default",this.canvas.discardActiveObject(),this.applyCanvasInteractive(!0),this.canvas.requestRenderAll(),this.toolbar.setMode("edit"),this.toolbar.hide(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}close(){this.disActive()}hide(){this.isVisible=!1,this.wrapper.style.display="none",this.toolbar.hide()}show(){this.isVisible=!0,this.wrapper.style.display="block",this.isActive&&this.toolbar.show(),this.resize()}isShown(){return this.isVisible}setDrawType(e,t){this.mode!=="view"&&(this.stopDistanceMeasureMode(),this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.drawType=e,t&&(this.drawStyle={...this.drawStyle,...t}),this.canvas.defaultCursor=e==="none"?"default":"crosshair",this.updateOverlayPointerEvents(),this.refreshToolbarState())}getDrawType(){return this.drawType}setActionHandlers(e){this.actionHandlers={...e}}drawLine(e,t,n){const i=this.mergeStyle(n),r=this.createLineObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawArrow(e,t,n){const i=this.mergeStyle(n),r=this.createArrowObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawRect(e,t,n){const i=this.mergeStyle(n),r=this.createRectObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCircle(e,t,n){const i=this.mergeStyle(n),r=this.createCircleObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawText(e,t,n){const i=this.mergeStyle(n),r=new Fr(t??i.text,{left:e.x,top:e.y,...this.createTextStyle(i),selectable:!0,evented:!0,objectCaching:!1});return r.annotationType="text",this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCloudLine(e,t){if(e.length<2)return null;const n=this.mergeStyle(t),i=this.createCloudObject(e,n,!0);return i?(this.canvas.add(i),this.canvas.requestRenderAll(),i):null}getAllShapes(){return this.canvas.toObject(["annotationType"])}clearAllShapes(){this.canvas.clear(),this.canvas.requestRenderAll()}async restoreAllShapes(e){await this.canvas.loadFromJSON(e),this.canvas.requestRenderAll()}saveScreenshot(e="bim-snapshot.png"){const t=this.canvas.lowerCanvasEl;return t?GR(this.engine,t,e):null}resize(e,t){const n=this.engine.container;if(!n)return;const i=e??n.clientWidth??1,r=t??n.clientHeight??1;this.canvas.setDimensions({width:i,height:r}),this.canvas.requestRenderAll()}dispose(){this.stopDistanceMeasureMode(),window.removeEventListener("keydown",this.onKeyDown),this.canvas.off("mouse:down",this.onMouseDown),this.canvas.off("mouse:move",this.onMouseMove),this.canvas.off("mouse:up",this.onMouseUp),this.canvas.off("mouse:dblclick",this.onMouseDblClick),this.canvas.off("selection:created",this.onSelectionChanged),this.canvas.off("selection:updated",this.onSelectionChanged),this.canvas.off("selection:cleared",this.onSelectionChanged),this.toolbar.dispose(),this.canvas.dispose(),this.wrapper.remove()}handleMouseDown(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||this.drawType==="none"||e?.target)return;const t=this.getPointFromEvent(e);if(this.drawType==="text"){const i=this.drawText(t);this.canvas.setActiveObject(i),this.canvas.requestRenderAll(),setTimeout(()=>{i.enterEditing(),i.hiddenTextarea?.focus(),i.selectAll()},0);return}this.startPoint=t,this.cloudPoints=[t],this.canvas.selection=!1,this.canvas.discardActiveObject();const n=this.createDraftObject(t,t);n&&(this.tempObject=n,this.canvas.add(n),this.canvas.requestRenderAll())}handleMouseMove(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||!this.startPoint||!this.tempObject)return;const t=this.getPointFromEvent(e),n=this.drawStyle;if(this.drawType==="cloudline"){if(this.shouldAppendCloudPoint(t)){this.cloudPoints.push(t),this.canvas.remove(this.tempObject);const i=this.createCloudObject(this.cloudPoints,n,!1);if(!i)return;this.tempObject=i,this.canvas.add(i),this.canvas.requestRenderAll()}return}if(this.drawType==="arrow"){this.canvas.remove(this.tempObject),this.tempObject=this.createArrowObject(this.startPoint,t,n,!1),this.canvas.add(this.tempObject),this.canvas.requestRenderAll();return}this.updateDraftObject(this.startPoint,t),this.canvas.requestRenderAll()}handleMouseUp(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||!this.startPoint)return;const t=this.getPointFromEvent(e);this.drawType==="cloudline"&&this.cloudPoints.length===1&&(this.cloudPoints.push(t),this.canvas.remove(this.tempObject),this.tempObject=this.createCloudObject(this.cloudPoints,this.drawStyle,!0),this.tempObject&&this.canvas.add(this.tempObject)),this.tempObject&&(this.tempObject.set({selectable:!0,evented:!0}),this.tempObject.setCoords?.(),this.canvas.requestRenderAll()),this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.selection=!0}handleMouseDblClick(e){const t=e?.target;this.isTextObject(t)&&(t.enterEditing(),t.hiddenTextarea?.focus(),t.selectAll?.())}handleKeyDown(e){if(!this.isActive)return;const t=this.canvas.getActiveObject();if(this.isTextObject(t)&&t?.isEditing||this.isInputElement(e.target))return;if(e.key==="Control"&&!e.repeat){this.toggleViewLock();return}if(e.key==="Escape"){e.preventDefault(),this.mode==="view"?this.handleCloseClick():this.handleCancelClick();return}if(e.key==="Enter"){this.mode==="edit"&&(e.preventDefault(),this.handleConfirmClick());return}if(e.key!=="Delete"&&e.key!=="Backspace"||!t)return;e.preventDefault(),this.canvas.getActiveObjects().forEach(r=>this.canvas.remove(r)),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}getPointFromEvent(e){if(e?.e){const n=this.canvas.getScenePoint(e.e);return{x:n.x,y:n.y}}const t=e?.scenePoint??e?.pointer??e?.absolutePointer;return t?{x:t.x,y:t.y}:{x:0,y:0}}shouldAppendCloudPoint(e){if(this.cloudPoints.length===0)return!0;const t=this.cloudPoints[this.cloudPoints.length-1],n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)>=6}createDraftObject(e,t){const n=this.drawStyle;switch(this.drawType){case"line":return this.createLineObject(e,t,n,!1);case"arrow":return this.createArrowObject(e,t,n,!1);case"rect":return this.createRectObject(e,t,n,!1);case"circle":return this.createCircleObject(e,t,n,!1);case"cloudline":return this.createCloudObject([e,t],n,!1);default:return null}}updateDraftObject(e,t){if(this.tempObject){if(this.drawType==="line"){this.tempObject.set({x2:t.x,y2:t.y});return}if(this.drawType==="rect"){const n=this.getBoxFromPoints(e,t);this.tempObject.set({left:n.left,top:n.top,width:n.width,height:n.height});return}if(this.drawType==="circle"){const n=this.getCircleFromPoints(e,t);this.tempObject.set({left:n.left,top:n.top,radius:n.radius})}}}mergeStyle(e){return{...this.drawStyle,...e??{}}}createObjectBase(e,t){return{stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,selectable:t,evented:t,objectCaching:!1}}createLineObject(e,t,n,i){const r=new Hs([e.x,e.y,t.x,t.y],{...this.createObjectBase(n,i),fill:"",strokeLineCap:"round"});return r.annotationType="line",r}createRectObject(e,t,n,i){const r=this.getBoxFromPoints(e,t),o=new Qs({...this.createObjectBase(n,i),left:r.left,top:r.top,width:r.width,height:r.height,originX:"left",originY:"top"});return o.annotationType="rect",o}createCircleObject(e,t,n,i){const r=this.getCircleFromPoints(e,t),o=new kr({...this.createObjectBase(n,i),left:r.left,top:r.top,radius:r.radius,originX:"left",originY:"top"});return o.annotationType="circle",o}createArrowObject(e,t,n,i){const r=t.x-e.x,o=t.y-e.y,a=Math.sqrt(r*r+o*o);if(a<1e-6){const B=new Hs([e.x,e.y,t.x,t.y],{stroke:n.stroke,strokeWidth:n.strokeWidth,fill:"",selectable:i,evented:i}),M=new js([B],{selectable:i,evented:i,objectCaching:!1});return M.annotationType="arrow",M}const l=r/a,c=o/a,h=-c,u=l,d=Math.max(10,n.strokeWidth*6),f=d*.72,m=t.x-l*d,g=t.y-c*d,A=m+h*(f*.5),p=g+u*(f*.5),x=m-h*(f*.5),y=g-u*(f*.5),v=new Hs([e.x,e.y,t.x,t.y],{stroke:n.stroke,strokeWidth:n.strokeWidth,fill:"",strokeLineCap:"round",selectable:!1,evented:!1}),_=`M ${t.x} ${t.y} L ${A} ${p} L ${x} ${y} Z`,E=new Rr(_,{fill:n.stroke,stroke:n.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),I=new js([v,E],{selectable:i,evented:i,objectCaching:!1});return I.annotationType="arrow",I}createCloudObject(e,t,n){const i=this.buildCloudPath(e,t.cloudRadius);if(!i)return null;const r=new Rr(i,{stroke:t.stroke,strokeWidth:t.strokeWidth,fill:"",strokeLineCap:"round",strokeLineJoin:"round",selectable:n,evented:n});return r.annotationType="cloudline",r}getBoxFromPoints(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}getCircleFromPoints(e,t){const n=t.x-e.x,i=t.y-e.y,r=Math.max(Math.abs(n),Math.abs(i)),o=n>=0?e.x:e.x-r,a=i>=0?e.y:e.y-r;return{left:o,top:a,radius:Math.max(r/2,1)}}buildCloudPath(e,t){if(e.length<2)return"";const n=Math.max(2,t),i=n*1.4;let r=`M ${e[0].x} ${e[0].y}`,o=1;for(let a=1;a<e.length;a++){const l=e[a-1],c=e[a],h=c.x-l.x,u=c.y-l.y,d=Math.sqrt(h*h+u*u);if(d<.1)continue;const f=-u/d,m=h/d,g=Math.max(1,Math.round(d/i));for(let A=1;A<=g;A++){const p=A/g,x=l.x+h*p,y=l.y+u*p,v=o%2===0?-1:1,_=x+f*n*v,E=y+m*n*v;r+=` Q ${_} ${E} ${x} ${y}`,o++}}return r}handleColorInputChange(e){this.drawStyle.stroke=e||this.drawStyle.stroke,this.drawStyle.fill=this.colorToAlpha(this.drawStyle.stroke,.08),this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleStrokeWidthInputChange(e){const t=this.parseNumber(e,this.drawStyle.strokeWidth,1,20);this.drawStyle.strokeWidth=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleFontSizeInputChange(e){const t=this.parseNumber(e,this.drawStyle.fontSize,1,200);this.drawStyle.fontSize=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}applyCurrentStyleToSelection(){const e=this.canvas.getActiveObjects();e.length!==0&&(e.forEach(t=>this.applyStyleToObject(t)),this.canvas.requestRenderAll())}applyStyleToObject(e){if(!e)return;if(e.annotationType==="arrow"&&Array.isArray(e._objects)){e._objects.forEach(n=>{if(n?.type==="triangle"||n?.type==="path"){n.set({fill:this.drawStyle.stroke,stroke:this.drawStyle.stroke,strokeWidth:1});return}n?.set({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,strokeLineCap:"round"})}),e.set({dirty:!0}),e.setCoords?.();return}if(this.isTextObject(e)){e.set({...this.createTextStyle(this.drawStyle),fontSize:this.drawStyle.fontSize}),e.setCoords?.();return}const t={stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth};e?.type==="line"||e?.type==="path"?t.fill="":t.fill=this.drawStyle.fill,e.set(t),e.setCoords?.()}syncStyleFromSelection(){const e=this.canvas.getActiveObject();if(!e)return;const t=this.readStyleFromObject(e);t.stroke&&(this.drawStyle.stroke=t.stroke,this.drawStyle.fill=this.colorToAlpha(t.stroke,.08)),typeof t.strokeWidth=="number"&&(this.drawStyle.strokeWidth=t.strokeWidth),typeof t.fontSize=="number"&&(this.drawStyle.fontSize=t.fontSize),this.refreshToolbarStyleValues()}readStyleFromObject(e){if(!e)return{};if(e.annotationType==="arrow"&&Array.isArray(e._objects)){const t=e._objects.find(n=>n?.type==="line")??e._objects[0];return{stroke:t?.stroke,strokeWidth:t?.strokeWidth}}return this.isTextObject(e)?{stroke:e.fill??this.drawStyle.stroke,fontSize:e.fontSize??this.drawStyle.fontSize}:{stroke:e.stroke??this.drawStyle.stroke,strokeWidth:e.strokeWidth??this.drawStyle.strokeWidth}}isTextObject(e){return e?e.type==="i-text"||e.type==="textbox"||e.annotationType==="text":!1}createTextStyle(e){return{fontSize:e.fontSize,fill:e.stroke,stroke:this.getTextOutlineColor(e.stroke),strokeWidth:3,strokeLineJoin:"round",paintFirst:"stroke"}}getTextOutlineColor(e){return this.isWhiteTextColor(e)?"#000000":"#ffffff"}isWhiteTextColor(e){const t=e.trim().toLowerCase();if(t==="#fff"||t==="#ffffff"||t==="white")return!0;const n=t.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})/);if(n){const[,i,r,o]=n;return Number(i)>=245&&Number(r)>=245&&Number(o)>=245}return!1}isInputElement(e){const t=e;if(!t||!t.tagName)return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||!!t.isContentEditable}applyCanvasInteractive(e){this.canvas.selection=e,this.canvas.getObjects().forEach(t=>{t.set({selectable:e,evented:e}),t.setCoords?.()}),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}parseNumber(e,t,n,i){const r=Number(e);return Number.isFinite(r)?Math.min(i,Math.max(n,r)):t}colorToAlpha(e,t){const n=e.trim(),i=/^#([0-9a-fA-F]{3})$/.exec(n);if(i){const o=i[1],a=parseInt(o[0]+o[0],16),l=parseInt(o[1]+o[1],16),c=parseInt(o[2]+o[2],16);return`rgba(${a}, ${l}, ${c}, ${t})`}const r=/^#([0-9a-fA-F]{6})$/.exec(n);if(r){const o=r[1],a=parseInt(o.slice(0,2),16),l=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16);return`rgba(${a}, ${l}, ${c}, ${t})`}return this.drawStyle.fill}toggleMeasurePanel(){!this.isActive||this.mode!=="edit"||(this.isMeasurePanelExpanded=!this.isMeasurePanelExpanded,this.refreshToolbarState())}activateDistanceMeasure(e){if(!this.isActive||this.mode!=="edit")return;this.drawType="none",this.canvas.defaultCursor="default",this.isDistanceMeasureMode=!0,this.isMeasurePanelExpanded=!0,this.currentMeasureType=e,this.canvas.discardActiveObject(),this.canvas.requestRenderAll();const t=this.engine.measure;t?.active?.(),this.disActiveMeasureTools(t),this.activeMeasureTool(t,e),this.updateOverlayPointerEvents(),this.refreshToolbarState()}stopDistanceMeasureMode(){if(!this.isDistanceMeasureMode)return;const e=this.engine.measure;this.disActiveMeasureTools(e),this.isDistanceMeasureMode=!1,this.currentMeasureType=null,this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActiveMeasureTools(e){e?.distanceMeasure?.disActive?.(),e?.faceDistanceMeasure?.disActive?.(),e?.clearHeightMeasure?.disActive?.(),e?.elevationMeasure?.disActive?.(),e?.pointMeasure?.disActive?.(),e?.angleMeasure?.disActive?.(),e?.areaMeasure?.disActive?.(),e?.slopeMeasure?.disActive?.()}activeMeasureTool(e,t){const i={distance:"distanceMeasure",clearDistance:"faceDistanceMeasure",clearHeight:"clearHeightMeasure",elevation:"elevationMeasure",point:"pointMeasure",angle:"angleMeasure",area:"areaMeasure",slope:"slopeMeasure"}[t];i&&e?.[i]?.active?.()}updateOverlayPointerEvents(){if(!this.isActive){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none";return}if(this.mode==="view"||this.isDistanceMeasureMode||!this.isViewLocked){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none",this.toolbar.root.style.pointerEvents="auto";return}this.wrapper.style.pointerEvents="auto",this.canvasEl.style.pointerEvents="auto",this.toolbar.root.style.pointerEvents="auto"}toggleViewLock(){!this.isActive||this.mode!=="edit"||this.isDistanceMeasureMode||(this.isViewLocked=!this.isViewLocked,this.isViewLocked?this.canvas.selection=!0:(this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.discardActiveObject(),this.canvas.selection=!1),this.canvas.requestRenderAll(),this.updateOverlayPointerEvents(),this.refreshToolbarState())}async handleCancelClick(){this.sessionSnapshot&&await this.restoreAllShapes(this.cloneJson(this.sessionSnapshot)),this.actionHandlers.onCancel?.(),this.disActive()}async handleCloseClick(){this.disActive()}handleConfirmClick(){const e=this.cloneJson(this.getAllShapes());this.actionHandlers.onConfirm?.(e),this.disActive()}refreshToolbarStyleValues(){this.toolbar.setStyleValues({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize})}refreshToolbarState(){this.toolbar.setDrawType(this.drawType),this.toolbar.setMode(this.mode),this.toolbar.setMeasurePanelVisible(this.isMeasurePanelExpanded),this.toolbar.setMeasureState(this.isDistanceMeasureMode,this.currentMeasureType),this.toolbar.setEditPanelMasked(!this.isViewLocked),this.refreshToolbarStyleValues()}createScreenshotFileName(){const e=new Date,t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`bim-snapshot-${t}${n}${i}-${r}${o}${a}.png`}cloneJson(e){return JSON.parse(JSON.stringify(e))}}class nk{engine;constructor(e){this.engine=e}get(){return{cameraPose:this.engine.cameraModule?.getCameraPose?.()??null,clipping:this.captureClippingState(),measureData:this.captureMeasureData(),annotationData:this.captureAnnotationData()}}async restore(e,t="view",n){if(!e){n?.(null);return}e.cameraPose&&this.engine.cameraModule?.restoreCameraPose?.(e.cameraPose),this.restoreClippingState(e.clipping),this.restoreMeasureData(e.measureData),await this.restoreAnnotationData(e.annotationData),this.applyAnnotationMode(t);const i=this.engine.fabricDraw;i&&i.setActionHandlers({onConfirm:r=>{const o=this.get();o.annotationData=this.serializeSnapshotValue(r),n&&n(o),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}})}create(e){const t=this.engine.fabricDraw;if(!t){e?.(this.get());return}t.setActionHandlers({onConfirm:n=>{const i=this.get();i.annotationData=this.serializeSnapshotValue(n),e?.(i),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}}),t.show?.(),t.active?.("edit"),t.setDrawType?.("none")}clearAnnotation(){this.engine.fabricDraw?.clearAllShapes?.(),this.engine.measure.disActive?.()}captureClippingState(){const e=this.engine.clipping,t=e?.sectionFace,n=e?.currentClippingMode??"",i={mode:n,fillCutFace:e?.getFillCutFace?.()??!0};if(n==="box"&&e?.sectionBox?.getboxXyz&&(i.box=e.sectionBox.getboxXyz()),n==="x"||n==="y"||n==="z"||n==="face"){const r=t?.normal;r&&(i.face={normal:{x:Number(r.x)||0,y:Number(r.y)||0,z:Number(r.z)||1},distance:Number(t?.distance)||0,direction:Number(t?.direction)===-1?-1:1})}return i}restoreClippingState(e){const t=this.engine.clipping;if(!t)return;typeof e?.fillCutFace=="boolean"&&t.setFillCutFace?.(e.fillCutFace);const n=e?.mode??"";if(!n){t.disActive?.();return}if(n==="box"){t.active?.("box"),e.box&&t.sectionBox?.setboxXyz?.(e.box);return}if(n==="x"||n==="y"||n==="z"){t.active?.(n),this.applyFaceState(e.face);return}if(n==="face"){this.restoreFaceMode(e.face);return}t.active?.(n)}restoreFaceMode(e){const t=this.engine.clipping,n=t?.sectionFace;!t||!n||(t.sectionBox?.disActive?.(),n.disActive?.(),n.active?.(),t.currentClippingMode="face",this.applyFaceState(e))}applyFaceState(e){if(!e)return;const t=this.engine.clipping?.sectionFace;if(!t)return;const n=new b.Vector3(e.normal.x,e.normal.y,e.normal.z).normalize();t.direction=e.direction===-1?-1:1,t.setFaceNormal?.(n,e.distance??0)}captureMeasureData(){const e=this.engine.measure?.annotationData;return e?this.serializeSnapshotValue(e):null}restoreMeasureData(e){const t=this.engine.measure;if(!t)return;try{t.clearAll?.()}catch{}if(!e)return;const n=this.deserializeSnapshotValue(e);(!t.annotationData||typeof t.annotationData!="object")&&(t.annotationData={}),Object.keys(t.annotationData).forEach(i=>{t.annotationData[i]=[]}),Object.keys(n).forEach(i=>{t.annotationData[i]=Array.isArray(n[i])?n[i]:[]}),t.tools?.drawNormalAnnotation?.()}captureAnnotationData(){const e=this.engine.fabricDraw;return e?.getAllShapes?this.serializeSnapshotValue(e.getAllShapes()):null}async restoreAnnotationData(e){const t=this.engine.fabricDraw;if(!t)return;if(!e){t.clearAllShapes?.();return}const n=this.deserializeSnapshotValue(e);await t.restoreAllShapes?.(n)}applyAnnotationMode(e){const t=this.engine.fabricDraw;t&&(t.setActionHandlers?.({}),t.show?.(),t.active?.(e),t.setDrawType?.("none"))}serializeSnapshotValue(e){if(e==null)return e;if(e instanceof b.Vector3)return{__type:"Vector3",x:e.x,y:e.y,z:e.z};if(Array.isArray(e))return e.map(t=>this.serializeSnapshotValue(t));if(typeof e=="object"){if(e instanceof HTMLElement||e instanceof SVGElement)return;const t={};return Object.keys(e).forEach(n=>{if(n==="container")return;const i=this.serializeSnapshotValue(e[n]);i!==void 0&&(t[n]=i)}),t}if(typeof e!="function")return e}deserializeSnapshotValue(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>this.deserializeSnapshotValue(t));if(typeof e=="object"){if(e.__type==="Vector3")return new b.Vector3(e.x,e.y,e.z);const t={};return Object.keys(e).forEach(n=>{t[n]=this.deserializeSnapshotValue(e[n])}),t}return e}}class ik{options;deviceType;animationId=null;isDisposed=!1;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=5;_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;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;fabricDraw;drawingPin;models=[];reactBoundingClientRect={left:0,top:0};version="3.8.3";versionEl=null;container;constructor(e){if(window.THREE=b,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new Q2(this),this.engineModelModule.init(),this.ai=new DP(this),this.deviceModule=new E_(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Sn(this),this.sceneModule=new S_(this),this.scene=this.sceneModule.scene,this.renderModule=new sE(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new dE(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new MP(this),this.clipping.init(),this.composerModule=new ME(this),this.composerModule.init(),this.events=new L2,this.engineStatus=new P2(this),this.engineStatus.init(),this.loaderModule=new D2(this),this.lightModule=new O2(this),this.lightModule.init(),this.viewCube=new aB(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=lB(this),this.rangeScale=new cB(this),this.rangeScale.init(),this.setting=new vB(this),this.engineModelModule.init(),this.handelBehaved=Od(this),this.modelMapperBatch=new TP(this),this.measure=new DB(this),this.modelToolModule=new N2(this),this.modelProperties=new IP(this),this.interactionModule=new U2(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Dc(this),this.modelEdge=new yB(this),this.modelTree=new SP(this),this.viewTree=new zP(this),this.merge2d=new c3(this),this.engineInfo=new EP(this),this.pathRoaming=new PP(this),this.pathRoaming.init(),this.oneClickEncoding=new NP(this),this.minMap=new LP(this),this.linkElement2d3d=new FP(this),this.linkView2d3d=new OP(this),this.grid=new dB(this),this.level=new xB(this),this.issueReport=new RP(this),this.fabricDraw=new tk(this),this.drawingPin=new nk(this),this.text=new kP(this),this.hdr=new gB(this),this.ground=new bf(this),this.ground.init(),this.skyManager=new bB(this),this.setting.init(),this.worldToScreen=new vt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Ax,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.renderer&&(i.renderer.interactionActive=!0),i.events.trigger(Ss.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.renderer&&(i.renderer.interactionActive=!1),i.events.trigger(Ss.EngineFree),i.container&&(i.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new b.Vector3;i.camera.getWorldDirection(r);const o=Math.atan2(r.x,-r.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:i.camera.position,rotation:o,type:i.camera.type}});window.dispatchEvent(a)}),this.events.on(Ss.LoadingCompleted,r=>{i.modelEdge.active()}),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.skyManager.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 r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const o=r-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,this._lowFpsCount=0)):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},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,n=!0){const i=new b.Vector3;e.getWorldDirection(i);const r=100,o=new b.Vector3().copy(i).multiplyScalar(-r),a=new b.Vector3(0,1,0),l=new b.Vector3().crossVectors(i,a).normalize();o.addScaledVector(a,r*.5),o.addScaledVector(l,r*.3),t.position.copy(e.position).add(o);const c=new b.Vector3().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(c),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 c=this.deviceModule.getContainerSize();e=e??c.width,t=t??c.height}if(!e||!t)return;const n=this.camera.position.clone(),i=this.camera.quaternion.clone(),r=this.camera.up.clone(),o=this.controls?.target?.clone?.(),a=this.controlModule?.orbitControls?.origin?.clone?.();this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const l=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=l,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const c=this.cameraModule.orthographicCamera,h=this.cameraModule.getOrthographicVisibleHeight(c);this.cameraModule.setOrthographicVisibleHeight(h,c,l),c.updateProjectionMatrix()}if(this.composerModule&&(typeof this.composerModule.resize=="function"?this.composerModule.resize(e,t):this.composerModule.composer&&this.composerModule.composer.setSize(e,t)),this.catchSvg&&this.catchSvg.setAttribute("viewBox",`0 0 ${e} ${t}`),this.fabricDraw&&this.fabricDraw.resize(e,t),this.camera.position.copy(n),this.camera.quaternion.copy(i),this.camera.up.copy(r),this.camera.updateMatrix(),this.camera.updateMatrixWorld(!0),o&&this.controls?.target&&this.controls.target.copy(o),a&&this.controlModule?.orbitControls?.origin&&this.controlModule.orbitControls.origin.copy(a),this.controlModule?.orbitControls){const c=this.controlModule.orbitControls;c._lastPosition?.copy?.(this.camera.position),c._lastTarget?.copy?.(c.target),c._lastUp?.copy?.(this.camera.up),c._lastQuaternion?.copy?.(this.camera.quaternion),c._lastZoom=this.camera.zoom}this.controlModule?.firstPersonControls?.syncRotationStateFromCamera?.(),this.controlModule?.firstPersonControls?.syncSharedTargetFromCamera?.(),this.events&&this.events.trigger(Ss.ViewportResize,{width:e,height:t})}dispose(){if(this.isDisposed)return;this.isDisposed=!0,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.invokeIfExists(this.rangeScale,"dispose"),this.invokeIfExists(this.measure,"dispose"),this.invokeIfExists(this.clipping,"disActive"),this.invokeIfExists(this.interactionModule,"dispose"),this.invokeIfExists(this.controlModule,"dispose"),this.invokeIfExists(this.pathRoaming,"dispose"),this.invokeIfExists(this.hoverHighLight,"dispose"),this.invokeIfExists(this.linkElement2d3d,"dispose"),this.invokeIfExists(this.linkView2d3d,"dispose"),this.invokeIfExists(this.skyManager,"close",!0),this.invokeIfExists(this.hdr,"dispose"),this.invokeIfExists(this.minMap,"dispose"),this.invokeIfExists(this.grid,"dispose"),this.invokeIfExists(this.level,"dispose"),this.invokeIfExists(this.ground,"dispose"),this.invokeIfExists(this.text,"dispose"),this.invokeIfExists(this.issueReport,"dispose"),this.invokeIfExists(this.fabricDraw,"dispose"),this.invokeIfExists(this.viewCube?.cubeTool,"dispose"),this.invokeIfExists(this.handelBehaved,"disActive")}catch(t){console.warn("[BimEngine] Error disposing managers:",t)}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(t){console.warn("[BimEngine] Error disposing controls:",t)}this.scene&&(this.disposeSceneAttachments(this.scene),this.clearScene(this.scene));try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(t=>{t?.dispose?.()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose(),this.composerModule.composer.dispose?.(),this.composerModule.composer.passes=[])}catch(t){console.warn("[BimEngine] Error disposing composer:",t)}try{this.renderModule?.disposeRenderer?.(),this.renderer&&(this.renderer.renderLists?.dispose?.(),this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(t){console.warn("[BimEngine] Error disposing renderer:",t)}try{this.stats?.dom?.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg?.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg),this.versionEl?.parentElement&&this.versionEl.parentElement.removeChild(this.versionEl)}catch(t){console.warn("[BimEngine] Error disposing DOM elements:",t)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(t){console.warn("[BimEngine] Error clearing event listeners:",t)}const e=this;e.scene=null,e.camera=null,e.renderer=null,e.controls=null,e.models=[],e.container=null,e.catchSvg=null,e.stats=null,e.versionEl=null,e.worldToScreen=null,e.measure=null,e.clipping=null,e.interactionModule=null,e.controlModule=null,e.sceneModule=null,e.cameraModule=null,e.deviceModule=null,e.renderModule=null,e.composerModule=null,e.loaderModule=null,e.lightModule=null,e.engineStatus=null,e.hoverHighLight=null,e.pathRoaming=null,e.hdr=null,e.skyManager=null,e.viewCube=null,e.grid=null,e.level=null,e.ground=null,e.minMap=null,e.fabricDraw=null,e.linkElement2d3d=null,e.linkView2d3d=null,e.rangeScale=null,e.text=null,e.issueReport=null,e.modelEdge=null,e.modelTree=null,e.modelProperties=null,e.modelMapperBatch=null,e.engineInfo=null,e.ai=null,e.oneClickEncoding=null,e.drawingPin=null,e.events=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 b.Mesh&&!(e instanceof b.InstancedMesh)&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof b.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.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 b.Sprite&&e.material&&this.disposeMaterial(e.material),e instanceof b.Light&&e.shadow?.dispose?.()}invokeIfExists(e,t,...n){const i=e?.[t];typeof i=="function"&&i.apply(e,n)}disposeSceneAttachments(e){new Set([e.background,e.environment,e.overrideMaterial]).forEach(n=>{this.disposeSceneAttachment(n)}),e.background=null,e.environment=null,e.overrideMaterial=null,e.dirLight=null,e.camera=null}disposeSceneAttachment(e){e&&(e instanceof b.Material||e instanceof b.Texture)&&e.dispose?.()}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 b.Texture&&i.dispose()}),e.dispose()}}const sk=`
|
|
6063
|
+
`}applyTo2d({imageData:{data:s}}){let e=-this.vibrance;for(let t=0;t<s.length;t+=4){let n=s[t],i=s[t+1],r=s[t+2],o=Math.max(n,i,r),a=(n+i+r)/3,l=2*Math.abs(o-a)/255*e;s[t]+=o===n?0:(o-n)*l,s[t+1]+=o===i?0:(o-i)*l,s[t+2]+=o===r?0:(o-r)*l}}sendUniformData(s,e){s.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}};K(ml,"type","Vibrance"),K(ml,"defaults",{vibrance:0}),K(ml,"uniformLocations",["uVibrance"]),ke.setClass(ml),Ua({BaseFilter:()=>zt,BlackWhite:()=>OR,BlendColor:()=>nl,BlendImage:()=>il,Blur:()=>sl,Brightness:()=>rl,Brownie:()=>DR,ColorMatrix:()=>Ur,Composed:()=>ag,Contrast:()=>ol,Convolute:()=>al,Gamma:()=>ll,Grayscale:()=>cl,HueRotation:()=>qh,Invert:()=>hl,Kodachrome:()=>LR,Noise:()=>ul,Pixelate:()=>dl,Polaroid:()=>kR,RemoveColor:()=>fl,Resize:()=>pl,Saturation:()=>gl,Sepia:()=>FR,Technicolor:()=>RR,Vibrance:()=>ml,Vintage:()=>PR});function GR(s,e,t="bim-snapshot.png"){const n=s?.renderer,i=n?.domElement;if(!n||!i||!e)return null;const r=i.width||i.clientWidth,o=i.height||i.clientHeight;if(r<=0||o<=0)return null;let a=VR(i,r,o);if(!QR(a)){const d=jR(s,r,o);d&&(a=d)}const l=document.createElement("canvas");l.width=r,l.height=o;const c=l.getContext("2d");if(!c)return null;c.drawImage(a,0,0,r,o),c.drawImage(e,0,0,r,o);const h=l.toDataURL("image/png"),u=document.createElement("a");return u.href=h,u.download=t.toLowerCase().endsWith(".png")?t:`${t}.png`,u.click(),h}function VR(s,e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const i=n.getContext("2d");return i&&i.drawImage(s,0,0,e,t),n}function QR(s){const e=s.getContext("2d");if(!e||s.width<=0||s.height<=0)return!1;const t=Math.min(32,s.width),n=Math.min(32,s.height),i=Math.max(1,Math.floor(s.width/t)),r=Math.max(1,Math.floor(s.height/n));for(let o=0;o<s.height;o+=r)for(let a=0;a<s.width;a+=i){const l=e.getImageData(a,o,1,1).data;if(l[0]!==0||l[1]!==0||l[2]!==0||l[3]!==0)return!0}return!1}function jR(s,e,t){const n=s?.renderer,i=s?.scene,r=s?.camera;if(!n||!i||!r)return null;const o=new b.WebGLRenderTarget(e,t,{minFilter:b.LinearFilter,magFilter:b.LinearFilter,format:b.RGBAFormat,depthBuffer:!0,stencilBuffer:!0}),a=n.getRenderTarget(),l=n.autoClear,c=n.xr?.enabled??!1;try{n.xr&&(n.xr.enabled=!1),n.autoClear=!0,n.setRenderTarget(o),n.clear(!0,!0,!0),n.render(i,r);const h=new Uint8Array(e*t*4);return n.readRenderTargetPixels(o,0,0,e,t,h),WR(h,e,t)}catch{return null}finally{n.setRenderTarget(a),n.autoClear=l,n.xr&&(n.xr.enabled=c),o.dispose()}}function WR(s,e,t){const n=document.createElement("canvas");n.width=e,n.height=t;const i=n.getContext("2d");if(!i)return n;const r=i.createImageData(e,t),o=e*4;for(let a=0;a<t;a++){const l=(t-1-a)*o,c=a*o;for(let h=0;h<o;h++)r.data[c+h]=s[l+h]}return i.putImageData(r,0,0),n}const HR=["#ffffff","#000000","#ff4d4f","#fa8c16","#fadb14","#52c41a","#13c2c2","#1677ff","#722ed1","#eb2f96"],qR={none:new URL("/assets/icon/%E9%80%89%E6%8B%A9.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,line:new URL("/assets/icon/%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,arrow:new URL("/assets/icon/%E7%AE%AD%E5%A4%B4.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,rect:new URL("/assets/icon/%E7%9F%A9%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,circle:new URL("/assets/icon/%E5%9C%86%E5%BD%A2.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,text:new URL("/assets/icon/%E6%96%87%E5%AD%97.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,cloudline:new URL("/assets/icon/%E4%BA%91%E7%BA%BF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href},XR=new URL("/assets/icon/%E6%B5%8B%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,YR=new URL("/assets/icon/%E6%88%AA%E5%9B%BE.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,KR=new URL("/assets/icon/%E7%BA%BF%E5%AE%BD.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,$R=new URL("/assets/icon/%E5%AD%97%E5%8F%B7.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,JR=[{type:"distance",label:"距离"},{type:"clearDistance",label:"净距"},{type:"clearHeight",label:"净高"},{type:"elevation",label:"标高"},{type:"point",label:"坐标"},{type:"angle",label:"角度"},{type:"area",label:"面积"},{type:"slope",label:"坡度"}],ZR={distance:new URL("/assets/icon/%E8%B7%9D%E7%A6%BB.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearDistance:new URL("/assets/icon/%E5%87%80%E8%B7%9D.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,clearHeight:new URL("/assets/icon/%E5%87%80%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,elevation:new URL("/assets/icon/%E6%A0%87%E9%AB%98.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,point:new URL("/assets/icon/%E5%9D%90%E6%A0%87.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,angle:new URL("/assets/icon/%E8%A7%92%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,area:new URL("/assets/icon/%E9%9D%A2%E7%A7%AF.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href,slope:new URL("/assets/icon/%E5%9D%A1%E5%BA%A6.svg",typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:ze&&ze.tagName.toUpperCase()==="SCRIPT"&&ze.src||new URL("bim-engine-sdk.umd.js",document.baseURI).href).href};class ek{constructor(e,t){this.handlers=e,this.root=document.createElement("div"),this.root.style.position="absolute",this.root.style.top="8px",this.root.style.left="50%",this.root.style.transform="translateX(-50%)",this.root.style.display="none",this.root.style.padding="6px",this.root.style.background="#ffffff",this.root.style.border="1px solid #d9d9d9",this.root.style.borderRadius="8px",this.root.style.pointerEvents="auto",this.root.style.userSelect="none",this.root.style.boxShadow="0 4px 14px rgba(0, 0, 0, 0.12)",this.root.style.zIndex="1300",this.root.style.overflow="visible",this.editPanel=document.createElement("div"),this.editPanel.style.display="flex",this.editPanel.style.flexDirection="column",this.editPanel.style.gap="6px",this.viewPanel=document.createElement("div"),this.viewPanel.style.display="none",this.viewPanel.style.alignItems="center",this.viewPanel.style.gap="6px";const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.gap="6px",n.style.flexWrap="wrap",[{type:"none",label:"选择"},{type:"line",label:"线"},{type:"arrow",label:"箭头"},{type:"rect",label:"矩形"},{type:"circle",label:"圆形"},{type:"text",label:"文字"},{type:"cloudline",label:"云线"}].forEach(f=>{const m=this.createIconButton(f.label,qR[f.type]);m.onclick=()=>this.handlers.onDrawTypeChange(f.type),this.drawButtons[f.type]=m,n.appendChild(m)});const r=document.createElement("div");r.style.position="relative",r.style.display="flex",r.style.alignItems="center",this.colorTrigger=document.createElement("button"),this.colorTrigger.type="button",this.colorTrigger.title="颜色",this.colorTrigger.style.width="32px",this.colorTrigger.style.height="24px",this.colorTrigger.style.padding="2px",this.colorTrigger.style.border="1px solid #d9d9d9",this.colorTrigger.style.borderRadius="4px",this.colorTrigger.style.background="#ffffff",this.colorTrigger.style.cursor="pointer",this.colorTrigger.style.display="flex",this.colorTrigger.style.alignItems="center",this.colorTrigger.style.justifyContent="center",this.colorTrigger.onclick=()=>this.setColorPresetVisible(!this.isColorPresetOpen);const o=document.createElement("span");o.style.display="block",o.style.width="100%",o.style.height="100%",o.style.borderRadius="2px",o.style.border="1px solid rgba(0, 0, 0, 0.12)",this.colorTrigger.appendChild(o),r.appendChild(this.colorTrigger),this.colorInput=document.createElement("input"),this.colorInput.type="color",this.colorInput.value=t.stroke,this.colorInput.style.position="absolute",this.colorInput.style.width="1px",this.colorInput.style.height="1px",this.colorInput.style.opacity="0",this.colorInput.style.pointerEvents="none",this.colorInput.style.left="0",this.colorInput.style.top="0",this.colorInput.tabIndex=-1,this.colorInput.oninput=()=>{this.updateColorControl(this.colorInput.value),this.handlers.onColorChange(this.colorInput.value),this.setColorPresetVisible(!1)},r.appendChild(this.colorInput),this.colorPresetPanel=document.createElement("div"),this.colorPresetPanel.style.position="absolute",this.colorPresetPanel.style.top="30px",this.colorPresetPanel.style.left="0",this.colorPresetPanel.style.display="none",this.colorPresetPanel.style.padding="8px",this.colorPresetPanel.style.background="#ffffff",this.colorPresetPanel.style.border="1px solid #d9d9d9",this.colorPresetPanel.style.borderRadius="6px",this.colorPresetPanel.style.boxShadow="0 6px 18px rgba(0, 0, 0, 0.14)",this.colorPresetPanel.style.zIndex="20",this.colorPresetPanel.style.width="152px";const a=document.createElement("div");a.style.display="grid",a.style.gridTemplateColumns="repeat(5, 1fr)",a.style.gap="6px",HR.forEach(f=>{const m=document.createElement("button");m.type="button",m.title=f,m.style.width="22px",m.style.height="22px",m.style.padding="0",m.style.border="1px solid #d9d9d9",m.style.borderRadius="4px",m.style.background=f,m.style.cursor="pointer",m.onclick=()=>{this.updateColorControl(f),this.handlers.onColorChange(f),this.setColorPresetVisible(!1)},a.appendChild(m)}),this.colorPresetPanel.appendChild(a);const l=document.createElement("button");l.type="button",l.textContent="自定义",l.style.marginTop="8px",l.style.width="100%",l.style.height="26px",l.style.border="1px solid #d9d9d9",l.style.borderRadius="4px",l.style.background="#ffffff",l.style.color="#333333",l.style.cursor="pointer",l.onclick=()=>this.openNativeColorPicker(),this.colorPresetPanel.appendChild(l),r.appendChild(this.colorPresetPanel),this.updateColorControl(t.stroke),n.appendChild(this.createField("",r)),this.strokeWidthInput=document.createElement("input"),this.strokeWidthInput.type="number",this.strokeWidthInput.min="1",this.strokeWidthInput.max="20",this.strokeWidthInput.step="1",this.strokeWidthInput.value=String(t.strokeWidth),this.strokeWidthInput.style.width="46px",this.strokeWidthInput.oninput=()=>this.handlers.onStrokeWidthChange(this.strokeWidthInput.value),n.appendChild(this.createField("",this.strokeWidthInput,KR,"线宽")),this.fontSizeInput=document.createElement("input"),this.fontSizeInput.type="number",this.fontSizeInput.min="10",this.fontSizeInput.max="96",this.fontSizeInput.step="1",this.fontSizeInput.value=String(t.fontSize),this.fontSizeInput.style.width="46px",this.fontSizeInput.oninput=()=>this.handlers.onFontSizeChange(this.fontSizeInput.value),n.appendChild(this.createField("",this.fontSizeInput,$R,"字号")),this.distanceButton=this.createIconButton("测量",XR),this.distanceButton.onclick=()=>this.handlers.onMeasureToggle(),n.appendChild(this.distanceButton);const c=this.createIconButton("截图",YR);c.onclick=()=>this.handlers.onScreenshot(),n.appendChild(c);const h=this.createTextButton("×","取消");h.onclick=()=>this.handlers.onCancel(),h.style.background="#ff4d4f",h.style.borderColor="#ff4d4f",h.style.color="#ffffff",n.appendChild(h);const u=this.createTextButton("✔","确定");u.onclick=()=>this.handlers.onConfirm(),u.style.background="#52c41a",u.style.borderColor="#52c41a",u.style.color="#ffffff",n.appendChild(u),this.measureSubPanel=document.createElement("div"),this.measureSubPanel.style.display="none",this.measureSubPanel.style.alignItems="center",this.measureSubPanel.style.gap="6px",this.measureSubPanel.style.flexWrap="wrap",this.measureSubPanel.style.paddingTop="2px",JR.forEach(f=>{const m=this.createSmallIconButton(f.label,ZR[f.type]);m.onclick=()=>this.handlers.onMeasureTypeChange(f.type),this.measureTypeButtons[f.type]=m,this.measureSubPanel.appendChild(m)}),this.editPanel.appendChild(n),this.editPanel.appendChild(this.measureSubPanel);const d=this.createTextButton("关闭","关闭");d.onclick=()=>this.handlers.onClose(),this.viewPanel.appendChild(d),this.root.appendChild(this.editPanel),this.root.appendChild(this.viewPanel),this.disabledMask=document.createElement("div"),this.disabledMask.style.position="absolute",this.disabledMask.style.inset="0",this.disabledMask.style.display="none",this.disabledMask.style.background="rgba(255, 255, 255, 0.55)",this.disabledMask.style.backdropFilter="blur(1px)",this.disabledMask.style.cursor="not-allowed",this.disabledMask.style.pointerEvents="auto",this.disabledMask.style.zIndex="10",this.root.appendChild(this.disabledMask),document.addEventListener("pointerdown",this.onDocumentPointerDown),this.setMode("edit")}root;disabledMask;drawButtons={};measureTypeButtons={};distanceButton;colorTrigger;colorInput;colorPresetPanel;strokeWidthInput;fontSizeInput;editPanel;viewPanel;measureSubPanel;mode="edit";isEditPanelMasked=!1;isColorPresetOpen=!1;onDocumentPointerDown=e=>{const t=e.target;t&&this.root.contains(t)||this.setColorPresetVisible(!1)};mount(e){e.appendChild(this.root)}show(){this.root.style.display="block"}hide(){this.root.style.display="none"}setMode(e){this.mode=e,this.editPanel.style.display=e==="edit"?"flex":"none",this.viewPanel.style.display=e==="view"?"flex":"none",e==="view"&&(this.setMeasurePanelVisible(!1),this.setColorPresetVisible(!1)),this.applyEditPanelMaskState()}setEditPanelMasked(e){this.isEditPanelMasked=e,this.applyEditPanelMaskState()}setDrawType(e){for(const t in this.drawButtons){const n=this.drawButtons[t];if(!n)continue;const i=t===e;n.style.background=i?"#eaf2ff":"#ffffff",n.style.borderColor=i?"#2f80ed":"#d9d9d9"}}setMeasurePanelVisible(e){if(this.mode!=="edit"){this.measureSubPanel.style.display="none";return}this.measureSubPanel.style.display=e?"flex":"none"}setMeasureState(e,t){this.distanceButton.style.background=e?"#eaf2ff":"#ffffff",this.distanceButton.style.borderColor=e?"#2f80ed":"#d9d9d9";for(const n in this.measureTypeButtons){const i=this.measureTypeButtons[n];if(!i)continue;const r=e&&t===n;i.style.background=r?"#eaf2ff":"#ffffff",i.style.borderColor=r?"#2f80ed":"#d9d9d9"}}setStyleValues(e){e.stroke&&this.updateColorControl(e.stroke),typeof e.strokeWidth=="number"&&(this.strokeWidthInput.value=String(e.strokeWidth)),typeof e.fontSize=="number"&&(this.fontSizeInput.value=String(e.fontSize))}dispose(){this.colorInput.oninput=null,this.strokeWidthInput.oninput=null,this.fontSizeInput.oninput=null,document.removeEventListener("pointerdown",this.onDocumentPointerDown),this.root.remove()}applyEditPanelMaskState(){const e=this.mode==="edit"&&this.isEditPanelMasked;this.disabledMask.style.display=e?"block":"none",e&&this.setColorPresetVisible(!1),this.editPanel.querySelectorAll("button, input").forEach(n=>{const i=n;i.disabled=e})}createField(e,t,n,i=""){const r=document.createElement("div");if(r.style.display="flex",r.style.alignItems="center",r.style.gap="4px",r.style.padding="0 2px",r.style.color="#333333",r.style.fontSize="12px",e){const o=document.createElement("span");o.textContent=e,r.appendChild(o)}if(n){const o=document.createElement("img");o.src=n,o.alt=i,o.style.width="14px",o.style.height="14px",o.style.display="block",r.appendChild(o)}return t instanceof HTMLInputElement&&(t.style.height="24px",t.style.border="1px solid #d9d9d9",t.style.borderRadius="4px",t.style.background="#ffffff",t.style.color="#333333",t.style.outline="none",t.style.padding="0 4px"),r.appendChild(t),r}updateColorControl(e){this.colorInput.value=e;const t=this.colorTrigger.firstElementChild;t&&(t.style.background=e)}setColorPresetVisible(e){this.isColorPresetOpen=e,this.colorPresetPanel.style.display=e?"block":"none",this.colorTrigger.style.borderColor=e?"#2f80ed":"#d9d9d9"}openNativeColorPicker(){const e=this.colorInput;if(typeof e.showPicker=="function"){e.showPicker();return}e.click()}createIconButton(e,t){const n=document.createElement("button");n.type="button",n.style.width="28px",n.style.height="28px",n.style.padding="0",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.border="1px solid #d9d9d9",n.style.borderRadius="4px",n.style.background="#ffffff",n.style.cursor="pointer";const i=document.createElement("img");return i.src=t,i.alt=e,i.style.width="16px",i.style.height="16px",i.style.display="block",n.appendChild(i),n}createSmallIconButton(e,t){const n=document.createElement("button");n.type="button",n.style.width="26px",n.style.height="26px",n.style.padding="0",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.border="1px solid #d9d9d9",n.style.borderRadius="4px",n.style.background="#ffffff",n.style.cursor="pointer";const i=document.createElement("img");return i.src=t,i.alt=e,i.style.width="14px",i.style.height="14px",i.style.display="block",n.appendChild(i),n}createTextButton(e,t){const n=document.createElement("button");return n.type="button",n.title=t,n.textContent=e,n.style.width="28px",n.style.height="28px",n.style.padding="0 10px",n.style.border="1px solid #d9d9d9",n.style.borderRadius="4px",n.style.background="#ffffff",n.style.color="#333333",n.style.fontSize="13px",n.style.lineHeight="1",n.style.cursor="pointer",n}}class tk{engine;wrapper;canvasEl;canvas;toolbar;isActive=!1;isVisible=!0;isViewLocked=!0;isDistanceMeasureMode=!1;isMeasurePanelExpanded=!1;drawType="none";mode="edit";currentMeasureType=null;sessionSnapshot=null;actionHandlers={};drawStyle={stroke:"#ff4d4f",strokeWidth:2,fill:"rgba(255, 77, 79, 0.08)",fontSize:16,text:"T",cloudRadius:10};startPoint=null;tempObject=null;cloudPoints=[];onMouseDown=e=>this.handleMouseDown(e);onMouseMove=e=>this.handleMouseMove(e);onMouseUp=e=>this.handleMouseUp(e);onMouseDblClick=e=>this.handleMouseDblClick(e);onSelectionChanged=()=>this.syncStyleFromSelection();onKeyDown=e=>this.handleKeyDown(e);constructor(e){this.engine=e;const t=this.engine.container;if(!t)throw new Error("FabricDraw: engine container not found.");this.wrapper=document.createElement("div"),this.wrapper.className="fabric-draw-layer",this.wrapper.style.position="absolute",this.wrapper.style.left="0",this.wrapper.style.top="0",this.wrapper.style.right="0",this.wrapper.style.bottom="0",this.wrapper.style.pointerEvents="none",this.canvasEl=document.createElement("canvas"),this.canvasEl.style.width="100%",this.canvasEl.style.height="100%",this.wrapper.appendChild(this.canvasEl),this.toolbar=new ek({onDrawTypeChange:i=>this.setDrawType(i),onMeasureToggle:()=>this.toggleMeasurePanel(),onMeasureTypeChange:i=>this.activateDistanceMeasure(i),onScreenshot:()=>{this.saveScreenshot(this.createScreenshotFileName())},onColorChange:i=>this.handleColorInputChange(i),onStrokeWidthChange:i=>this.handleStrokeWidthInputChange(i),onFontSizeChange:i=>this.handleFontSizeInputChange(i),onCancel:()=>{this.handleCancelClick()},onConfirm:()=>this.handleConfirmClick(),onClose:()=>{this.handleCloseClick()}},{stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize}),this.toolbar.mount(this.wrapper);const n=this.engine.renderer?.domElement;n?.nextSibling?t.insertBefore(this.wrapper,n.nextSibling):t.appendChild(this.wrapper),this.canvas=new Zp(this.canvasEl,{selection:!0,preserveObjectStacking:!0}),this.resize(),this.canvas.on("mouse:down",this.onMouseDown),this.canvas.on("mouse:move",this.onMouseMove),this.canvas.on("mouse:up",this.onMouseUp),this.canvas.on("mouse:dblclick",this.onMouseDblClick),this.canvas.on("selection:created",this.onSelectionChanged),this.canvas.on("selection:updated",this.onSelectionChanged),this.canvas.on("selection:cleared",this.onSelectionChanged),window.addEventListener("keydown",this.onKeyDown),this.refreshToolbarState()}active(e="edit"){this.isActive=!0,this.mode=e,this.isViewLocked=!0,this.drawType="none",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.canvas.defaultCursor="default",this.sessionSnapshot=e==="edit"?this.cloneJson(this.getAllShapes()):null,this.toolbar.setMode(e),this.applyCanvasInteractive(e==="edit"),this.isVisible&&this.toolbar.show(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActive(){this.isActive=!1,this.isViewLocked=!0,this.startPoint=null,this.cloudPoints=[],this.tempObject=null,this.drawType="none",this.mode="edit",this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.sessionSnapshot=null,this.stopDistanceMeasureMode(),this.canvas.defaultCursor="default",this.canvas.discardActiveObject(),this.applyCanvasInteractive(!0),this.canvas.requestRenderAll(),this.toolbar.setMode("edit"),this.toolbar.hide(),this.updateOverlayPointerEvents(),this.refreshToolbarState()}close(){this.disActive()}hide(){this.isVisible=!1,this.wrapper.style.display="none",this.toolbar.hide()}show(){this.isVisible=!0,this.wrapper.style.display="block",this.isActive&&this.toolbar.show(),this.resize()}isShown(){return this.isVisible}setDrawType(e,t){this.mode!=="view"&&(this.stopDistanceMeasureMode(),this.isMeasurePanelExpanded=!1,this.currentMeasureType=null,this.drawType=e,t&&(this.drawStyle={...this.drawStyle,...t}),this.canvas.defaultCursor=e==="none"?"default":"crosshair",this.updateOverlayPointerEvents(),this.refreshToolbarState())}getDrawType(){return this.drawType}setActionHandlers(e){this.actionHandlers={...e}}drawLine(e,t,n){const i=this.mergeStyle(n),r=this.createLineObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawArrow(e,t,n){const i=this.mergeStyle(n),r=this.createArrowObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawRect(e,t,n){const i=this.mergeStyle(n),r=this.createRectObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCircle(e,t,n){const i=this.mergeStyle(n),r=this.createCircleObject(e,t,i,!0);return this.canvas.add(r),this.canvas.requestRenderAll(),r}drawText(e,t,n){const i=this.mergeStyle(n),r=new Fr(t??i.text,{left:e.x,top:e.y,...this.createTextStyle(i),selectable:!0,evented:!0,objectCaching:!1});return r.annotationType="text",this.canvas.add(r),this.canvas.requestRenderAll(),r}drawCloudLine(e,t){if(e.length<2)return null;const n=this.mergeStyle(t),i=this.createCloudObject(e,n,!0);return i?(this.canvas.add(i),this.canvas.requestRenderAll(),i):null}getAllShapes(){return this.canvas.toObject(["annotationType"])}clearAllShapes(){this.canvas.clear(),this.canvas.requestRenderAll()}async restoreAllShapes(e){await this.canvas.loadFromJSON(e),this.canvas.requestRenderAll()}saveScreenshot(e="bim-snapshot.png"){const t=this.canvas.lowerCanvasEl;return t?GR(this.engine,t,e):null}resize(e,t){const n=this.engine.container;if(!n)return;const i=e??n.clientWidth??1,r=t??n.clientHeight??1;this.canvas.setDimensions({width:i,height:r}),this.canvas.requestRenderAll()}dispose(){this.stopDistanceMeasureMode(),window.removeEventListener("keydown",this.onKeyDown),this.canvas.off("mouse:down",this.onMouseDown),this.canvas.off("mouse:move",this.onMouseMove),this.canvas.off("mouse:up",this.onMouseUp),this.canvas.off("mouse:dblclick",this.onMouseDblClick),this.canvas.off("selection:created",this.onSelectionChanged),this.canvas.off("selection:updated",this.onSelectionChanged),this.canvas.off("selection:cleared",this.onSelectionChanged),this.toolbar.dispose(),this.canvas.dispose(),this.wrapper.remove()}handleMouseDown(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||this.drawType==="none"||e?.target)return;const t=this.getPointFromEvent(e);if(this.drawType==="text"){const i=this.drawText(t);this.canvas.setActiveObject(i),this.canvas.requestRenderAll(),setTimeout(()=>{i.enterEditing(),i.hiddenTextarea?.focus(),i.selectAll()},0);return}this.startPoint=t,this.cloudPoints=[t],this.canvas.selection=!1,this.canvas.discardActiveObject();const n=this.createDraftObject(t,t);n&&(this.tempObject=n,this.canvas.add(n),this.canvas.requestRenderAll())}handleMouseMove(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||!this.startPoint||!this.tempObject)return;const t=this.getPointFromEvent(e),n=this.drawStyle;if(this.drawType==="cloudline"){if(this.shouldAppendCloudPoint(t)){this.cloudPoints.push(t),this.canvas.remove(this.tempObject);const i=this.createCloudObject(this.cloudPoints,n,!1);if(!i)return;this.tempObject=i,this.canvas.add(i),this.canvas.requestRenderAll()}return}if(this.drawType==="arrow"){this.canvas.remove(this.tempObject),this.tempObject=this.createArrowObject(this.startPoint,t,n,!1),this.canvas.add(this.tempObject),this.canvas.requestRenderAll();return}this.updateDraftObject(this.startPoint,t),this.canvas.requestRenderAll()}handleMouseUp(e){if(!this.isActive||this.mode==="view"||!this.isViewLocked||!this.startPoint)return;const t=this.getPointFromEvent(e);this.drawType==="cloudline"&&this.cloudPoints.length===1&&(this.cloudPoints.push(t),this.canvas.remove(this.tempObject),this.tempObject=this.createCloudObject(this.cloudPoints,this.drawStyle,!0),this.tempObject&&this.canvas.add(this.tempObject)),this.tempObject&&(this.tempObject.set({selectable:!0,evented:!0}),this.tempObject.setCoords?.(),this.canvas.requestRenderAll()),this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.selection=!0}handleMouseDblClick(e){const t=e?.target;this.isTextObject(t)&&(t.enterEditing(),t.hiddenTextarea?.focus(),t.selectAll?.())}handleKeyDown(e){if(!this.isActive)return;const t=this.canvas.getActiveObject();if(this.isTextObject(t)&&t?.isEditing||this.isInputElement(e.target))return;if(e.key==="Control"&&!e.repeat){this.toggleViewLock();return}if(e.key==="Escape"){e.preventDefault(),this.mode==="view"?this.handleCloseClick():this.handleCancelClick();return}if(e.key==="Enter"){this.mode==="edit"&&(e.preventDefault(),this.handleConfirmClick());return}if(e.key!=="Delete"&&e.key!=="Backspace"||!t)return;e.preventDefault(),this.canvas.getActiveObjects().forEach(r=>this.canvas.remove(r)),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}getPointFromEvent(e){if(e?.e){const n=this.canvas.getScenePoint(e.e);return{x:n.x,y:n.y}}const t=e?.scenePoint??e?.pointer??e?.absolutePointer;return t?{x:t.x,y:t.y}:{x:0,y:0}}shouldAppendCloudPoint(e){if(this.cloudPoints.length===0)return!0;const t=this.cloudPoints[this.cloudPoints.length-1],n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)>=6}createDraftObject(e,t){const n=this.drawStyle;switch(this.drawType){case"line":return this.createLineObject(e,t,n,!1);case"arrow":return this.createArrowObject(e,t,n,!1);case"rect":return this.createRectObject(e,t,n,!1);case"circle":return this.createCircleObject(e,t,n,!1);case"cloudline":return this.createCloudObject([e,t],n,!1);default:return null}}updateDraftObject(e,t){if(this.tempObject){if(this.drawType==="line"){this.tempObject.set({x2:t.x,y2:t.y});return}if(this.drawType==="rect"){const n=this.getBoxFromPoints(e,t);this.tempObject.set({left:n.left,top:n.top,width:n.width,height:n.height});return}if(this.drawType==="circle"){const n=this.getCircleFromPoints(e,t);this.tempObject.set({left:n.left,top:n.top,radius:n.radius})}}}mergeStyle(e){return{...this.drawStyle,...e??{}}}createObjectBase(e,t){return{stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,selectable:t,evented:t,objectCaching:!1}}createLineObject(e,t,n,i){const r=new Hs([e.x,e.y,t.x,t.y],{...this.createObjectBase(n,i),fill:"",strokeLineCap:"round"});return r.annotationType="line",r}createRectObject(e,t,n,i){const r=this.getBoxFromPoints(e,t),o=new Qs({...this.createObjectBase(n,i),left:r.left,top:r.top,width:r.width,height:r.height,originX:"left",originY:"top"});return o.annotationType="rect",o}createCircleObject(e,t,n,i){const r=this.getCircleFromPoints(e,t),o=new kr({...this.createObjectBase(n,i),left:r.left,top:r.top,radius:r.radius,originX:"left",originY:"top"});return o.annotationType="circle",o}createArrowObject(e,t,n,i){const r=t.x-e.x,o=t.y-e.y,a=Math.sqrt(r*r+o*o);if(a<1e-6){const B=new Hs([e.x,e.y,t.x,t.y],{stroke:n.stroke,strokeWidth:n.strokeWidth,fill:"",selectable:i,evented:i}),M=new js([B],{selectable:i,evented:i,objectCaching:!1});return M.annotationType="arrow",M}const l=r/a,c=o/a,h=-c,u=l,d=Math.max(10,n.strokeWidth*6),f=d*.72,m=t.x-l*d,g=t.y-c*d,A=m+h*(f*.5),p=g+u*(f*.5),x=m-h*(f*.5),y=g-u*(f*.5),v=new Hs([e.x,e.y,t.x,t.y],{stroke:n.stroke,strokeWidth:n.strokeWidth,fill:"",strokeLineCap:"round",selectable:!1,evented:!1}),_=`M ${t.x} ${t.y} L ${A} ${p} L ${x} ${y} Z`,E=new Rr(_,{fill:n.stroke,stroke:n.stroke,strokeWidth:1,selectable:!1,evented:!1,objectCaching:!1}),I=new js([v,E],{selectable:i,evented:i,objectCaching:!1});return I.annotationType="arrow",I}createCloudObject(e,t,n){const i=this.buildCloudPath(e,t.cloudRadius);if(!i)return null;const r=new Rr(i,{stroke:t.stroke,strokeWidth:t.strokeWidth,fill:"",strokeLineCap:"round",strokeLineJoin:"round",selectable:n,evented:n});return r.annotationType="cloudline",r}getBoxFromPoints(e,t){return{left:Math.min(e.x,t.x),top:Math.min(e.y,t.y),width:Math.abs(t.x-e.x),height:Math.abs(t.y-e.y)}}getCircleFromPoints(e,t){const n=t.x-e.x,i=t.y-e.y,r=Math.max(Math.abs(n),Math.abs(i)),o=n>=0?e.x:e.x-r,a=i>=0?e.y:e.y-r;return{left:o,top:a,radius:Math.max(r/2,1)}}buildCloudPath(e,t){if(e.length<2)return"";const n=Math.max(2,t),i=n*1.4;let r=`M ${e[0].x} ${e[0].y}`,o=1;for(let a=1;a<e.length;a++){const l=e[a-1],c=e[a],h=c.x-l.x,u=c.y-l.y,d=Math.sqrt(h*h+u*u);if(d<.1)continue;const f=-u/d,m=h/d,g=Math.max(1,Math.round(d/i));for(let A=1;A<=g;A++){const p=A/g,x=l.x+h*p,y=l.y+u*p,v=o%2===0?-1:1,_=x+f*n*v,E=y+m*n*v;r+=` Q ${_} ${E} ${x} ${y}`,o++}}return r}handleColorInputChange(e){this.drawStyle.stroke=e||this.drawStyle.stroke,this.drawStyle.fill=this.colorToAlpha(this.drawStyle.stroke,.08),this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleStrokeWidthInputChange(e){const t=this.parseNumber(e,this.drawStyle.strokeWidth,1,20);this.drawStyle.strokeWidth=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}handleFontSizeInputChange(e){const t=this.parseNumber(e,this.drawStyle.fontSize,1,200);this.drawStyle.fontSize=t,this.applyCurrentStyleToSelection(),this.refreshToolbarStyleValues()}applyCurrentStyleToSelection(){const e=this.canvas.getActiveObjects();e.length!==0&&(e.forEach(t=>this.applyStyleToObject(t)),this.canvas.requestRenderAll())}applyStyleToObject(e){if(!e)return;if(e.annotationType==="arrow"&&Array.isArray(e._objects)){e._objects.forEach(n=>{if(n?.type==="triangle"||n?.type==="path"){n.set({fill:this.drawStyle.stroke,stroke:this.drawStyle.stroke,strokeWidth:1});return}n?.set({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,strokeLineCap:"round"})}),e.set({dirty:!0}),e.setCoords?.();return}if(this.isTextObject(e)){e.set({...this.createTextStyle(this.drawStyle),fontSize:this.drawStyle.fontSize}),e.setCoords?.();return}const t={stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth};e?.type==="line"||e?.type==="path"?t.fill="":t.fill=this.drawStyle.fill,e.set(t),e.setCoords?.()}syncStyleFromSelection(){const e=this.canvas.getActiveObject();if(!e)return;const t=this.readStyleFromObject(e);t.stroke&&(this.drawStyle.stroke=t.stroke,this.drawStyle.fill=this.colorToAlpha(t.stroke,.08)),typeof t.strokeWidth=="number"&&(this.drawStyle.strokeWidth=t.strokeWidth),typeof t.fontSize=="number"&&(this.drawStyle.fontSize=t.fontSize),this.refreshToolbarStyleValues()}readStyleFromObject(e){if(!e)return{};if(e.annotationType==="arrow"&&Array.isArray(e._objects)){const t=e._objects.find(n=>n?.type==="line")??e._objects[0];return{stroke:t?.stroke,strokeWidth:t?.strokeWidth}}return this.isTextObject(e)?{stroke:e.fill??this.drawStyle.stroke,fontSize:e.fontSize??this.drawStyle.fontSize}:{stroke:e.stroke??this.drawStyle.stroke,strokeWidth:e.strokeWidth??this.drawStyle.strokeWidth}}isTextObject(e){return e?e.type==="i-text"||e.type==="textbox"||e.annotationType==="text":!1}createTextStyle(e){return{fontSize:e.fontSize,fill:e.stroke,stroke:this.getTextOutlineColor(e.stroke),strokeWidth:3,strokeLineJoin:"round",paintFirst:"stroke"}}getTextOutlineColor(e){return this.isWhiteTextColor(e)?"#000000":"#ffffff"}isWhiteTextColor(e){const t=e.trim().toLowerCase();if(t==="#fff"||t==="#ffffff"||t==="white")return!0;const n=t.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})/);if(n){const[,i,r,o]=n;return Number(i)>=245&&Number(r)>=245&&Number(o)>=245}return!1}isInputElement(e){const t=e;if(!t||!t.tagName)return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||!!t.isContentEditable}applyCanvasInteractive(e){this.canvas.selection=e,this.canvas.getObjects().forEach(t=>{t.set({selectable:e,evented:e}),t.setCoords?.()}),this.canvas.discardActiveObject(),this.canvas.requestRenderAll()}parseNumber(e,t,n,i){const r=Number(e);return Number.isFinite(r)?Math.min(i,Math.max(n,r)):t}colorToAlpha(e,t){const n=e.trim(),i=/^#([0-9a-fA-F]{3})$/.exec(n);if(i){const o=i[1],a=parseInt(o[0]+o[0],16),l=parseInt(o[1]+o[1],16),c=parseInt(o[2]+o[2],16);return`rgba(${a}, ${l}, ${c}, ${t})`}const r=/^#([0-9a-fA-F]{6})$/.exec(n);if(r){const o=r[1],a=parseInt(o.slice(0,2),16),l=parseInt(o.slice(2,4),16),c=parseInt(o.slice(4,6),16);return`rgba(${a}, ${l}, ${c}, ${t})`}return this.drawStyle.fill}toggleMeasurePanel(){!this.isActive||this.mode!=="edit"||(this.isMeasurePanelExpanded=!this.isMeasurePanelExpanded,this.refreshToolbarState())}activateDistanceMeasure(e){if(!this.isActive||this.mode!=="edit")return;this.drawType="none",this.canvas.defaultCursor="default",this.isDistanceMeasureMode=!0,this.isMeasurePanelExpanded=!0,this.currentMeasureType=e,this.canvas.discardActiveObject(),this.canvas.requestRenderAll();const t=this.engine.measure;t?.active?.(),this.disActiveMeasureTools(t),this.activeMeasureTool(t,e),this.updateOverlayPointerEvents(),this.refreshToolbarState()}stopDistanceMeasureMode(){if(!this.isDistanceMeasureMode)return;const e=this.engine.measure;this.disActiveMeasureTools(e),this.isDistanceMeasureMode=!1,this.currentMeasureType=null,this.updateOverlayPointerEvents(),this.refreshToolbarState()}disActiveMeasureTools(e){e?.distanceMeasure?.disActive?.(),e?.faceDistanceMeasure?.disActive?.(),e?.clearHeightMeasure?.disActive?.(),e?.elevationMeasure?.disActive?.(),e?.pointMeasure?.disActive?.(),e?.angleMeasure?.disActive?.(),e?.areaMeasure?.disActive?.(),e?.slopeMeasure?.disActive?.()}activeMeasureTool(e,t){const i={distance:"distanceMeasure",clearDistance:"faceDistanceMeasure",clearHeight:"clearHeightMeasure",elevation:"elevationMeasure",point:"pointMeasure",angle:"angleMeasure",area:"areaMeasure",slope:"slopeMeasure"}[t];i&&e?.[i]?.active?.()}updateOverlayPointerEvents(){if(!this.isActive){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none";return}if(this.mode==="view"||this.isDistanceMeasureMode||!this.isViewLocked){this.wrapper.style.pointerEvents="none",this.canvasEl.style.pointerEvents="none",this.toolbar.root.style.pointerEvents="auto";return}this.wrapper.style.pointerEvents="auto",this.canvasEl.style.pointerEvents="auto",this.toolbar.root.style.pointerEvents="auto"}toggleViewLock(){!this.isActive||this.mode!=="edit"||this.isDistanceMeasureMode||(this.isViewLocked=!this.isViewLocked,this.isViewLocked?this.canvas.selection=!0:(this.startPoint=null,this.tempObject=null,this.cloudPoints=[],this.canvas.discardActiveObject(),this.canvas.selection=!1),this.canvas.requestRenderAll(),this.updateOverlayPointerEvents(),this.refreshToolbarState())}async handleCancelClick(){this.sessionSnapshot&&await this.restoreAllShapes(this.cloneJson(this.sessionSnapshot)),this.actionHandlers.onCancel?.(),this.disActive()}async handleCloseClick(){this.disActive()}handleConfirmClick(){const e=this.cloneJson(this.getAllShapes());this.actionHandlers.onConfirm?.(e),this.disActive()}refreshToolbarStyleValues(){this.toolbar.setStyleValues({stroke:this.drawStyle.stroke,strokeWidth:this.drawStyle.strokeWidth,fontSize:this.drawStyle.fontSize})}refreshToolbarState(){this.toolbar.setDrawType(this.drawType),this.toolbar.setMode(this.mode),this.toolbar.setMeasurePanelVisible(this.isMeasurePanelExpanded),this.toolbar.setMeasureState(this.isDistanceMeasureMode,this.currentMeasureType),this.toolbar.setEditPanelMasked(!this.isViewLocked),this.refreshToolbarStyleValues()}createScreenshotFileName(){const e=new Date,t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),r=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0");return`bim-snapshot-${t}${n}${i}-${r}${o}${a}.png`}cloneJson(e){return JSON.parse(JSON.stringify(e))}}class nk{engine;constructor(e){this.engine=e}get(){return{cameraPose:this.engine.cameraModule?.getCameraPose?.()??null,clipping:this.captureClippingState(),measureData:this.captureMeasureData(),annotationData:this.captureAnnotationData()}}async restore(e,t="view",n){if(!e){n?.(null);return}e.cameraPose&&this.engine.cameraModule?.restoreCameraPose?.(e.cameraPose),this.restoreClippingState(e.clipping),this.restoreMeasureData(e.measureData),await this.restoreAnnotationData(e.annotationData),this.applyAnnotationMode(t);const i=this.engine.fabricDraw;i&&i.setActionHandlers({onConfirm:r=>{const o=this.get();o.annotationData=this.serializeSnapshotValue(r),n&&n(o),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}})}create(e){const t=this.engine.fabricDraw;if(!t){e?.(this.get());return}t.setActionHandlers({onConfirm:n=>{const i=this.get();i.annotationData=this.serializeSnapshotValue(n),e?.(i),this.clearAnnotation()},onCancel:()=>{this.clearAnnotation()}}),t.show?.(),t.active?.("edit"),t.setDrawType?.("none")}clearAnnotation(){this.engine.fabricDraw?.clearAllShapes?.(),this.engine.measure.disActive?.()}captureClippingState(){const e=this.engine.clipping,t=e?.sectionFace,n=e?.currentClippingMode??"",i={mode:n,fillCutFace:e?.getFillCutFace?.()??!0};if(n==="box"&&e?.sectionBox?.getboxXyz&&(i.box=e.sectionBox.getboxXyz()),n==="x"||n==="y"||n==="z"||n==="face"){const r=t?.normal;r&&(i.face={normal:{x:Number(r.x)||0,y:Number(r.y)||0,z:Number(r.z)||1},distance:Number(t?.distance)||0,direction:Number(t?.direction)===-1?-1:1})}return i}restoreClippingState(e){const t=this.engine.clipping;if(!t)return;typeof e?.fillCutFace=="boolean"&&t.setFillCutFace?.(e.fillCutFace);const n=e?.mode??"";if(!n){t.disActive?.();return}if(n==="box"){t.active?.("box"),e.box&&t.sectionBox?.setboxXyz?.(e.box);return}if(n==="x"||n==="y"||n==="z"){t.active?.(n),this.applyFaceState(e.face);return}if(n==="face"){this.restoreFaceMode(e.face);return}t.active?.(n)}restoreFaceMode(e){const t=this.engine.clipping,n=t?.sectionFace;!t||!n||(t.sectionBox?.disActive?.(),n.disActive?.(),n.active?.(),t.currentClippingMode="face",this.applyFaceState(e))}applyFaceState(e){if(!e)return;const t=this.engine.clipping?.sectionFace;if(!t)return;const n=new b.Vector3(e.normal.x,e.normal.y,e.normal.z).normalize();t.direction=e.direction===-1?-1:1,t.setFaceNormal?.(n,e.distance??0)}captureMeasureData(){const e=this.engine.measure?.annotationData;return e?this.serializeSnapshotValue(e):null}restoreMeasureData(e){const t=this.engine.measure;if(!t)return;try{t.clearAll?.()}catch{}if(!e)return;const n=this.deserializeSnapshotValue(e);(!t.annotationData||typeof t.annotationData!="object")&&(t.annotationData={}),Object.keys(t.annotationData).forEach(i=>{t.annotationData[i]=[]}),Object.keys(n).forEach(i=>{t.annotationData[i]=Array.isArray(n[i])?n[i]:[]}),t.tools?.drawNormalAnnotation?.()}captureAnnotationData(){const e=this.engine.fabricDraw;return e?.getAllShapes?this.serializeSnapshotValue(e.getAllShapes()):null}async restoreAnnotationData(e){const t=this.engine.fabricDraw;if(!t)return;if(!e){t.clearAllShapes?.();return}const n=this.deserializeSnapshotValue(e);await t.restoreAllShapes?.(n)}applyAnnotationMode(e){const t=this.engine.fabricDraw;t&&(t.setActionHandlers?.({}),t.show?.(),t.active?.(e),t.setDrawType?.("none"))}serializeSnapshotValue(e){if(e==null)return e;if(e instanceof b.Vector3)return{__type:"Vector3",x:e.x,y:e.y,z:e.z};if(Array.isArray(e))return e.map(t=>this.serializeSnapshotValue(t));if(typeof e=="object"){if(e instanceof HTMLElement||e instanceof SVGElement)return;const t={};return Object.keys(e).forEach(n=>{if(n==="container")return;const i=this.serializeSnapshotValue(e[n]);i!==void 0&&(t[n]=i)}),t}if(typeof e!="function")return e}deserializeSnapshotValue(e){if(e==null)return e;if(Array.isArray(e))return e.map(t=>this.deserializeSnapshotValue(t));if(typeof e=="object"){if(e.__type==="Vector3")return new b.Vector3(e.x,e.y,e.z);const t={};return Object.keys(e).forEach(n=>{t[n]=this.deserializeSnapshotValue(e[n])}),t}return e}}class ik{options;deviceType;animationId=null;isDisposed=!1;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=5;_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;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;issueReport;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;fabricDraw;drawingPin;models=[];reactBoundingClientRect={left:0,top:0};version="3.8.5";versionEl=null;container;constructor(e){if(window.THREE=b,this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);if(this.engineModelModule=new Q2(this),this.engineModelModule.init(),this.ai=new DP(this),this.deviceModule=new E_(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Sn(this),this.sceneModule=new S_(this),this.scene=this.sceneModule.scene,this.renderModule=new sE(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.renderer){const r=this.renderer;r.interactionCullingEnabled=!0,r.interactionActive=!1,r.interactionRenderScene=this.scene,r.interactionFrameBudgetMs=this.options.interactionFrameBudgetMs??6,r.interactionSkipShadows=this.options.interactionSkipShadows??!0}this.controlModule=new dE(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new MP(this),this.clipping.init(),this.composerModule=new ME(this),this.composerModule.init(),this.events=new L2,this.engineStatus=new P2(this),this.engineStatus.init(),this.loaderModule=new D2(this),this.lightModule=new O2(this),this.lightModule.init(),this.viewCube=new aB(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=lB(this),this.rangeScale=new cB(this),this.rangeScale.init(),this.setting=new vB(this),this.engineModelModule.init(),this.handelBehaved=Od(this),this.modelMapperBatch=new TP(this),this.measure=new DB(this),this.modelToolModule=new N2(this),this.modelProperties=new IP(this),this.interactionModule=new U2(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Dc(this),this.modelEdge=new yB(this),this.modelTree=new SP(this),this.viewTree=new zP(this),this.merge2d=new c3(this),this.engineInfo=new EP(this),this.pathRoaming=new PP(this),this.pathRoaming.init(),this.oneClickEncoding=new NP(this),this.minMap=new LP(this),this.linkElement2d3d=new FP(this),this.linkView2d3d=new OP(this),this.grid=new dB(this),this.level=new xB(this),this.issueReport=new RP(this),this.fabricDraw=new tk(this),this.drawingPin=new nk(this),this.text=new kP(this),this.hdr=new gB(this),this.ground=new bf(this),this.ground.init(),this.skyManager=new bB(this),this.setting.init(),this.worldToScreen=new vt(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Ax,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.renderer&&(i.renderer.interactionActive=!0),i.events.trigger(Ss.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.renderer&&(i.renderer.interactionActive=!1),i.events.trigger(Ss.EngineFree),i.container&&(i.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const r=new b.Vector3;i.camera.getWorldDirection(r);const o=Math.atan2(r.x,-r.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:i.camera.position,rotation:o,type:i.camera.type}});window.dispatchEvent(a)}),this.events.on(Ss.LoadingCompleted,r=>{i.modelEdge.active()}),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.skyManager.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 r=performance.now();if(r-this._fpsLastCheck>=this._fpsCheckInterval){const o=r-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=r,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&r-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=r,this._lowFpsCount=0)):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},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,n=!0){const i=new b.Vector3;e.getWorldDirection(i);const r=100,o=new b.Vector3().copy(i).multiplyScalar(-r),a=new b.Vector3(0,1,0),l=new b.Vector3().crossVectors(i,a).normalize();o.addScaledVector(a,r*.5),o.addScaledVector(l,r*.3),t.position.copy(e.position).add(o);const c=new b.Vector3().copy(e.position).add(i.multiplyScalar(20));t.target.position.copy(c),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 c=this.deviceModule.getContainerSize();e=e??c.width,t=t??c.height}if(!e||!t)return;const n=this.camera.position.clone(),i=this.camera.quaternion.clone(),r=this.camera.up.clone(),o=this.controls?.target?.clone?.(),a=this.controlModule?.orbitControls?.origin?.clone?.();this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const l=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=l,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const c=this.cameraModule.orthographicCamera,h=this.cameraModule.getOrthographicVisibleHeight(c);this.cameraModule.setOrthographicVisibleHeight(h,c,l),c.updateProjectionMatrix()}if(this.composerModule&&(typeof this.composerModule.resize=="function"?this.composerModule.resize(e,t):this.composerModule.composer&&this.composerModule.composer.setSize(e,t)),this.catchSvg&&this.catchSvg.setAttribute("viewBox",`0 0 ${e} ${t}`),this.fabricDraw&&this.fabricDraw.resize(e,t),this.camera.position.copy(n),this.camera.quaternion.copy(i),this.camera.up.copy(r),this.camera.updateMatrix(),this.camera.updateMatrixWorld(!0),o&&this.controls?.target&&this.controls.target.copy(o),a&&this.controlModule?.orbitControls?.origin&&this.controlModule.orbitControls.origin.copy(a),this.controlModule?.orbitControls){const c=this.controlModule.orbitControls;c._lastPosition?.copy?.(this.camera.position),c._lastTarget?.copy?.(c.target),c._lastUp?.copy?.(this.camera.up),c._lastQuaternion?.copy?.(this.camera.quaternion),c._lastZoom=this.camera.zoom}this.controlModule?.firstPersonControls?.syncRotationStateFromCamera?.(),this.controlModule?.firstPersonControls?.syncSharedTargetFromCamera?.(),this.events&&this.events.trigger(Ss.ViewportResize,{width:e,height:t})}dispose(){if(this.isDisposed)return;this.isDisposed=!0,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.invokeIfExists(this.rangeScale,"dispose"),this.invokeIfExists(this.measure,"dispose"),this.invokeIfExists(this.clipping,"disActive"),this.invokeIfExists(this.interactionModule,"dispose"),this.invokeIfExists(this.controlModule,"dispose"),this.invokeIfExists(this.pathRoaming,"dispose"),this.invokeIfExists(this.hoverHighLight,"dispose"),this.invokeIfExists(this.linkElement2d3d,"dispose"),this.invokeIfExists(this.linkView2d3d,"dispose"),this.invokeIfExists(this.skyManager,"close",!0),this.invokeIfExists(this.hdr,"dispose"),this.invokeIfExists(this.minMap,"dispose"),this.invokeIfExists(this.grid,"dispose"),this.invokeIfExists(this.level,"dispose"),this.invokeIfExists(this.ground,"dispose"),this.invokeIfExists(this.text,"dispose"),this.invokeIfExists(this.issueReport,"dispose"),this.invokeIfExists(this.fabricDraw,"dispose"),this.invokeIfExists(this.viewCube?.cubeTool,"dispose"),this.invokeIfExists(this.handelBehaved,"disActive")}catch(t){console.warn("[BimEngine] Error disposing managers:",t)}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(t){console.warn("[BimEngine] Error disposing controls:",t)}this.scene&&(this.disposeSceneAttachments(this.scene),this.clearScene(this.scene));try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(t=>{t?.dispose?.()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose(),this.composerModule.composer.dispose?.(),this.composerModule.composer.passes=[])}catch(t){console.warn("[BimEngine] Error disposing composer:",t)}try{this.renderModule?.disposeRenderer?.(),this.renderer&&(this.renderer.renderLists?.dispose?.(),this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(t){console.warn("[BimEngine] Error disposing renderer:",t)}try{this.stats?.dom?.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg?.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg),this.versionEl?.parentElement&&this.versionEl.parentElement.removeChild(this.versionEl)}catch(t){console.warn("[BimEngine] Error disposing DOM elements:",t)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(t){console.warn("[BimEngine] Error clearing event listeners:",t)}const e=this;e.scene=null,e.camera=null,e.renderer=null,e.controls=null,e.models=[],e.container=null,e.catchSvg=null,e.stats=null,e.versionEl=null,e.worldToScreen=null,e.measure=null,e.clipping=null,e.interactionModule=null,e.controlModule=null,e.sceneModule=null,e.cameraModule=null,e.deviceModule=null,e.renderModule=null,e.composerModule=null,e.loaderModule=null,e.lightModule=null,e.engineStatus=null,e.hoverHighLight=null,e.pathRoaming=null,e.hdr=null,e.skyManager=null,e.viewCube=null,e.grid=null,e.level=null,e.ground=null,e.minMap=null,e.fabricDraw=null,e.linkElement2d3d=null,e.linkView2d3d=null,e.rangeScale=null,e.text=null,e.issueReport=null,e.modelEdge=null,e.modelTree=null,e.modelProperties=null,e.modelMapperBatch=null,e.engineInfo=null,e.ai=null,e.oneClickEncoding=null,e.drawingPin=null,e.events=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 b.Mesh&&!(e instanceof b.InstancedMesh)&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof b.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.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 b.Sprite&&e.material&&this.disposeMaterial(e.material),e instanceof b.Light&&e.shadow?.dispose?.()}invokeIfExists(e,t,...n){const i=e?.[t];typeof i=="function"&&i.apply(e,n)}disposeSceneAttachments(e){new Set([e.background,e.environment,e.overrideMaterial]).forEach(n=>{this.disposeSceneAttachment(n)}),e.background=null,e.environment=null,e.overrideMaterial=null,e.dirLight=null,e.camera=null}disposeSceneAttachment(e){e&&(e instanceof b.Material||e instanceof b.Texture)&&e.dispose?.()}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 b.Texture&&i.dispose()}),e.dispose()}}const sk=`
|
|
6064
6064
|
varying vec2 vWorldPos;
|
|
6065
6065
|
|
|
6066
6066
|
void main() {
|