iflow-engine-base 3.4.6 → 3.4.7
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.
|
@@ -4936,7 +4936,7 @@ void main() {
|
|
|
4936
4936
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[ud]=this[ud]={accessors:{}}).accessors,i=this.prototype;function r(o){const a=fr(o);n[a]||(ky(i,o),n[a]=!0)}return le.isArray(e)?e.forEach(r):r(e),this}};$t.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),le.reduceDescriptors($t.prototype,({value:s},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>s,set(n){this[t]=n}}}),le.freezeMethods($t);function oc(s,e){const t=this||dr,n=e||t,i=$t.from(n.headers);let r=n.data;return le.forEach(s,function(a){r=a.call(t,r,i.normalize(),e?e.status:void 0)}),i.normalize(),r}function dd(s){return!!(s&&s.__CANCEL__)}function Ns(s,e,t){qe.call(this,s??"canceled",qe.ERR_CANCELED,e,t),this.name="CanceledError"}le.inherits(Ns,qe,{__CANCEL__:!0});function fd(s,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?s(t):e(new qe("Request failed with status code "+t.status,[qe.ERR_BAD_REQUEST,qe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function By(s){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(s);return e&&e[1]||""}function zy(s,e){s=s||10;const t=new Array(s),n=new Array(s);let i=0,r=0,o;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),h=n[r];o||(o=c),t[i]=l,n[i]=c;let u=r,f=0;for(;u!==i;)f+=t[u++],u=u%s;if(i=(i+1)%s,i===r&&(r=(r+1)%s),c-o<e)return;const d=h&&c-h;return d?Math.round(f*1e3/d):void 0}}function Vy(s,e){let t=0,n=1e3/e,i,r;const o=(c,h=Date.now())=>{t=h,i=null,r&&(clearTimeout(r),r=null),s(...c)};return[(...c)=>{const h=Date.now(),u=h-t;u>=n?o(c,h):(i=c,r||(r=setTimeout(()=>{r=null,o(i)},n-u)))},()=>i&&o(i)]}const Io=(s,e,t=3)=>{let n=0;const i=zy(50,250);return Vy(r=>{const o=r.loaded,a=r.lengthComputable?r.total:void 0,l=o-n,c=i(l),h=o<=a;n=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&h?(a-o)/c:void 0,event:r,lengthComputable:a!=null,[e?"download":"upload"]:!0};s(u)},t)},pd=(s,e)=>{const t=s!=null;return[n=>e[0]({lengthComputable:t,total:s,loaded:n}),e[1]]},md=s=>(...e)=>le.asap(()=>s(...e)),Gy=kt.hasStandardBrowserEnv?((s,e)=>t=>(t=new URL(t,kt.origin),s.protocol===t.protocol&&s.host===t.host&&(e||s.port===t.port)))(new URL(kt.origin),kt.navigator&&/(msie|trident)/i.test(kt.navigator.userAgent)):()=>!0,Wy=kt.hasStandardBrowserEnv?{write(s,e,t,n,i,r,o){if(typeof document>"u")return;const a=[`${s}=${encodeURIComponent(e)}`];le.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),le.isString(n)&&a.push(`path=${n}`),le.isString(i)&&a.push(`domain=${i}`),r===!0&&a.push("secure"),le.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(s){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+s+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(s){this.write(s,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Hy(s){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(s)}function Xy(s,e){return e?s.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):s}function gd(s,e,t){let n=!Hy(e);return s&&(n||t==!1)?Xy(s,e):e}const xd=s=>s instanceof $t?{...s}:s;function Yi(s,e){e=e||{};const t={};function n(c,h,u,f){return le.isPlainObject(c)&&le.isPlainObject(h)?le.merge.call({caseless:f},c,h):le.isPlainObject(h)?le.merge({},h):le.isArray(h)?h.slice():h}function i(c,h,u,f){if(le.isUndefined(h)){if(!le.isUndefined(c))return n(void 0,c,u,f)}else return n(c,h,u,f)}function r(c,h){if(!le.isUndefined(h))return n(void 0,h)}function o(c,h){if(le.isUndefined(h)){if(!le.isUndefined(c))return n(void 0,c)}else return n(void 0,h)}function a(c,h,u){if(u in e)return n(c,h);if(u in s)return n(void 0,c)}const l={url:r,method:r,data:r,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,h,u)=>i(xd(c),xd(h),u,!0)};return le.forEach(Object.keys({...s,...e}),function(h){const u=l[h]||i,f=u(s[h],e[h],h);le.isUndefined(f)&&u!==a||(t[h]=f)}),t}const _d=s=>{const e=Yi({},s);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:r,headers:o,auth:a}=e;if(e.headers=o=$t.from(o),e.url=ad(gd(e.baseURL,e.url,e.allowAbsoluteUrls),s.params,s.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),le.isFormData(t)){if(kt.hasStandardBrowserEnv||kt.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(le.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,u])=>{c.includes(h.toLowerCase())&&o.set(h,u)})}}if(kt.hasStandardBrowserEnv&&(n&&le.isFunction(n)&&(n=n(e)),n||n!==!1&&Gy(e.url))){const l=i&&r&&Wy.read(r);l&&o.set(i,l)}return e},jy=typeof XMLHttpRequest<"u"&&function(s){return new Promise(function(t,n){const i=_d(s);let r=i.data;const o=$t.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,h,u,f,d,g;function p(){d&&d(),g&&g(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let m=new XMLHttpRequest;m.open(i.method.toUpperCase(),i.url,!0),m.timeout=i.timeout;function x(){if(!m)return;const v=$t.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),M={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:v,config:s,request:m};fd(function(E){t(E),p()},function(E){n(E),p()},M),m=null}"onloadend"in m?m.onloadend=x:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(x)},m.onabort=function(){m&&(n(new qe("Request aborted",qe.ECONNABORTED,s,m)),m=null)},m.onerror=function(y){const M=y&&y.message?y.message:"Network Error",S=new qe(M,qe.ERR_NETWORK,s,m);S.event=y||null,n(S),m=null},m.ontimeout=function(){let y=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const M=i.transitional||cd;i.timeoutErrorMessage&&(y=i.timeoutErrorMessage),n(new qe(y,M.clarifyTimeoutError?qe.ETIMEDOUT:qe.ECONNABORTED,s,m)),m=null},r===void 0&&o.setContentType(null),"setRequestHeader"in m&&le.forEach(o.toJSON(),function(y,M){m.setRequestHeader(M,y)}),le.isUndefined(i.withCredentials)||(m.withCredentials=!!i.withCredentials),a&&a!=="json"&&(m.responseType=i.responseType),c&&([f,g]=Io(c,!0),m.addEventListener("progress",f)),l&&m.upload&&([u,d]=Io(l),m.upload.addEventListener("progress",u),m.upload.addEventListener("loadend",d)),(i.cancelToken||i.signal)&&(h=v=>{m&&(n(!v||v.type?new Ns(null,s,m):v),m.abort(),m=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));const _=By(i.url);if(_&&kt.protocols.indexOf(_)===-1){n(new qe("Unsupported protocol "+_+":",qe.ERR_BAD_REQUEST,s));return}m.send(r||null)})},Yy=(s,e)=>{const{length:t}=s=s?s.filter(Boolean):[];if(e||t){let n=new AbortController,i;const r=function(c){if(!i){i=!0,a();const h=c instanceof Error?c:this.reason;n.abort(h instanceof qe?h:new Ns(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,r(new qe(`timeout ${e} of ms exceeded`,qe.ETIMEDOUT))},e);const a=()=>{s&&(o&&clearTimeout(o),o=null,s.forEach(c=>{c.unsubscribe?c.unsubscribe(r):c.removeEventListener("abort",r)}),s=null)};s.forEach(c=>c.addEventListener("abort",r));const{signal:l}=n;return l.unsubscribe=()=>le.asap(a),l}},qy=function*(s,e){let t=s.byteLength;if(t<e){yield s;return}let n=0,i;for(;n<t;)i=n+e,yield s.slice(n,i),n=i},$y=async function*(s,e){for await(const t of Ky(s))yield*qy(t,e)},Ky=async function*(s){if(s[Symbol.asyncIterator]){yield*s;return}const e=s.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},vd=(s,e,t,n)=>{const i=$y(s,e);let r=0,o,a=l=>{o||(o=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await i.next();if(c){a(),l.close();return}let u=h.byteLength;if(t){let f=r+=u;t(f)}l.enqueue(new Uint8Array(h))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},yd=64*1024,{isFunction:No}=le,Zy=(({Request:s,Response:e})=>({Request:s,Response:e}))(le.global),{ReadableStream:Md,TextEncoder:bd}=le.global,Sd=(s,...e)=>{try{return!!s(...e)}catch{return!1}},Jy=s=>{s=le.merge.call({skipUndefined:!0},Zy,s);const{fetch:e,Request:t,Response:n}=s,i=e?No(e):typeof fetch=="function",r=No(t),o=No(n);if(!i)return!1;const a=i&&No(Md),l=i&&(typeof bd=="function"?(g=>p=>g.encode(p))(new bd):async g=>new Uint8Array(await new t(g).arrayBuffer())),c=r&&a&&Sd(()=>{let g=!1;const p=new t(kt.origin,{body:new Md,method:"POST",get duplex(){return g=!0,"half"}}).headers.has("Content-Type");return g&&!p}),h=o&&a&&Sd(()=>le.isReadableStream(new n("").body)),u={stream:h&&(g=>g.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(g=>{!u[g]&&(u[g]=(p,m)=>{let x=p&&p[g];if(x)return x.call(p);throw new qe(`Response type '${g}' is not supported`,qe.ERR_NOT_SUPPORT,m)})});const f=async g=>{if(g==null)return 0;if(le.isBlob(g))return g.size;if(le.isSpecCompliantForm(g))return(await new t(kt.origin,{method:"POST",body:g}).arrayBuffer()).byteLength;if(le.isArrayBufferView(g)||le.isArrayBuffer(g))return g.byteLength;if(le.isURLSearchParams(g)&&(g=g+""),le.isString(g))return(await l(g)).byteLength},d=async(g,p)=>{const m=le.toFiniteNumber(g.getContentLength());return m??f(p)};return async g=>{let{url:p,method:m,data:x,signal:_,cancelToken:v,timeout:y,onDownloadProgress:M,onUploadProgress:S,responseType:E,headers:D,withCredentials:A="same-origin",fetchOptions:T}=_d(g),I=e||fetch;E=E?(E+"").toLowerCase():"text";let P=Yy([_,v&&v.toAbortSignal()],y),N=null;const w=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let O;try{if(S&&c&&m!=="get"&&m!=="head"&&(O=await d(D,x))!==0){let X=new t(p,{method:"POST",body:x,duplex:"half"}),j;if(le.isFormData(x)&&(j=X.headers.get("content-type"))&&D.setContentType(j),X.body){const[pe,xe]=pd(O,Io(md(S)));x=vd(X.body,yd,pe,xe)}}le.isString(A)||(A=A?"include":"omit");const k=r&&"credentials"in t.prototype,H={...T,signal:P,method:m.toUpperCase(),headers:D.normalize().toJSON(),body:x,duplex:"half",credentials:k?A:void 0};N=r&&new t(p,H);let Y=await(r?I(N,T):I(p,H));const W=h&&(E==="stream"||E==="response");if(h&&(M||W&&w)){const X={};["status","statusText","headers"].forEach(ue=>{X[ue]=Y[ue]});const j=le.toFiniteNumber(Y.headers.get("content-length")),[pe,xe]=M&&pd(j,Io(md(M),!0))||[];Y=new n(vd(Y.body,yd,pe,()=>{xe&&xe(),w&&w()}),X)}E=E||"text";let Q=await u[le.findKey(u,E)||"text"](Y,g);return!W&&w&&w(),await new Promise((X,j)=>{fd(X,j,{data:Q,headers:$t.from(Y.headers),status:Y.status,statusText:Y.statusText,config:g,request:N})})}catch(k){throw w&&w(),k&&k.name==="TypeError"&&/Load failed|fetch/i.test(k.message)?Object.assign(new qe("Network Error",qe.ERR_NETWORK,g,N),{cause:k.cause||k}):qe.from(k,k&&k.code,g,N)}}},Qy=new Map,wd=s=>{let e=s&&s.env||{};const{fetch:t,Request:n,Response:i}=e,r=[n,i,t];let o=r.length,a=o,l,c,h=Qy;for(;a--;)l=r[a],c=h.get(l),c===void 0&&h.set(l,c=a?new Map:Jy(e)),h=c;return c};wd();const ac={http:My,xhr:jy,fetch:{get:wd}};le.forEach(ac,(s,e)=>{if(s){try{Object.defineProperty(s,"name",{value:e})}catch{}Object.defineProperty(s,"adapterName",{value:e})}});const Ad=s=>`- ${s}`,eM=s=>le.isFunction(s)||s===null||s===!1;function tM(s,e){s=le.isArray(s)?s:[s];const{length:t}=s;let n,i;const r={};for(let o=0;o<t;o++){n=s[o];let a;if(i=n,!eM(n)&&(i=ac[(a=String(n)).toLowerCase()],i===void 0))throw new qe(`Unknown adapter '${a}'`);if(i&&(le.isFunction(i)||(i=i.get(e))))break;r[a||"#"+o]=i}if(!i){const o=Object.entries(r).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=t?o.length>1?`since :
|
|
4937
4937
|
`+o.map(Ad).join(`
|
|
4938
4938
|
`):" "+Ad(o[0]):"as no adapter specified";throw new qe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const Ed={getAdapter:tM,adapters:ac};function lc(s){if(s.cancelToken&&s.cancelToken.throwIfRequested(),s.signal&&s.signal.aborted)throw new Ns(null,s)}function Td(s){return lc(s),s.headers=$t.from(s.headers),s.data=oc.call(s,s.transformRequest),["post","put","patch"].indexOf(s.method)!==-1&&s.headers.setContentType("application/x-www-form-urlencoded",!1),Ed.getAdapter(s.adapter||dr.adapter,s)(s).then(function(n){return lc(s),n.data=oc.call(s,s.transformResponse,n),n.headers=$t.from(n.headers),n},function(n){return dd(n)||(lc(s),n&&n.response&&(n.response.data=oc.call(s,s.transformResponse,n.response),n.response.headers=$t.from(n.response.headers))),Promise.reject(n)})}const Cd="1.13.2",Uo={};["object","boolean","number","function","string","symbol"].forEach((s,e)=>{Uo[s]=function(n){return typeof n===s||"a"+(e<1?"n ":" ")+s}});const Pd={};Uo.transitional=function(e,t,n){function i(r,o){return"[Axios v"+Cd+"] Transitional option '"+r+"'"+o+(n?". "+n:"")}return(r,o,a)=>{if(e===!1)throw new qe(i(o," has been removed"+(t?" in "+t:"")),qe.ERR_DEPRECATED);return t&&!Pd[o]&&(Pd[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}},Uo.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function nM(s,e,t){if(typeof s!="object")throw new qe("options must be an object",qe.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 qe("option "+r+" must be "+l,qe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new qe("Unknown option "+r,qe.ERR_BAD_OPTION)}}const Fo={assertOptions:nM,validators:Uo},Ln=Fo.validators;let qi=class{constructor(e){this.defaults=e||{},this.interceptors={request:new ld,response:new ld}}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
|
-
`+r):n.stack=r}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Yi(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:r}=t;n!==void 0&&Fo.assertOptions(n,{silentJSONParsing:Ln.transitional(Ln.boolean),forcedJSONParsing:Ln.transitional(Ln.boolean),clarifyTimeoutError:Ln.transitional(Ln.boolean)},!1),i!=null&&(le.isFunction(i)?t.paramsSerializer={serialize:i}:Fo.assertOptions(i,{encode:Ln.function,serialize:Ln.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Fo.assertOptions(t,{baseUrl:Ln.spelling("baseURL"),withXsrfToken:Ln.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&le.merge(r.common,r[t.method]);r&&le.forEach(["delete","get","head","post","put","patch","common"],g=>{delete r[g]}),t.headers=$t.concat(o,r);const a=[];let l=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(t)===!1||(l=l&&p.synchronous,a.unshift(p.fulfilled,p.rejected))});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let h,u=0,f;if(!l){const g=[Td.bind(this),void 0];for(g.unshift(...a),g.push(...c),f=g.length,h=Promise.resolve(t);u<f;)h=h.then(g[u++],g[u++]);return h}f=a.length;let d=t;for(;u<f;){const g=a[u++],p=a[u++];try{d=g(d)}catch(m){p.call(this,m);break}}try{h=Td.call(this,d)}catch(g){return Promise.reject(g)}for(u=0,f=c.length;u<f;)h=h.then(c[u++],c[u++]);return h}getUri(e){e=Yi(this.defaults,e);const t=gd(e.baseURL,e.url,e.allowAbsoluteUrls);return ad(t,e.params,e.paramsSerializer)}};le.forEach(["delete","get","head","options"],function(e){qi.prototype[e]=function(t,n){return this.request(Yi(n||{},{method:e,url:t,data:(n||{}).data}))}}),le.forEach(["post","put","patch"],function(e){function t(n){return function(r,o,a){return this.request(Yi(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}qi.prototype[e]=t(),qi.prototype[e+"Form"]=t(!0)});let iM=class yp{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 Ns(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 yp(function(i){e=i}),cancel:e}}};function sM(s){return function(t){return s.apply(null,t)}}function rM(s){return le.isObject(s)&&s.isAxiosError===!0}const cc={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(cc).forEach(([s,e])=>{cc[e]=s});function Dd(s){const e=new qi(s),t=ju(qi.prototype.request,e);return le.extend(t,qi.prototype,e,{allOwnKeys:!0}),le.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Dd(Yi(s,i))},t}const mt=Dd(dr);mt.Axios=qi,mt.CanceledError=Ns,mt.CancelToken=iM,mt.isCancel=dd,mt.VERSION=Cd,mt.toFormData=Ro,mt.AxiosError=qe,mt.Cancel=mt.CanceledError,mt.all=function(e){return Promise.all(e)},mt.spread=sM,mt.isAxiosError=rM,mt.mergeConfig=Yi,mt.AxiosHeaders=$t,mt.formToJSON=s=>hd(le.isHTMLForm(s)?new FormData(s):s),mt.getAdapter=Ed.getAdapter,mt.HttpStatusCode=cc,mt.default=mt;const{Axios:wE,AxiosError:AE,CanceledError:EE,isCancel:TE,CancelToken:CE,VERSION:PE,all:DE,Cancel:RE,isAxiosError:LE,spread:IE,toFormData:NE,AxiosHeaders:UE,HttpStatusCode:FE,formToJSON:OE,getAdapter:kE,mergeConfig:BE}=mt;function pr(s,e,t){mt({method:"get",responseType:"blob",url:s}).then(i=>{let r=new window.File([i.data],"semantics",{type:"zip"});Xu.loadAsync(r).then(o=>{for(let a in o.files){const l=o.file(o.files[a].name);l&&l.async("blob").then(c=>{n(c,"utf-8",function(h,u){e(u)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(i=>{t()});function n(i,r,o){var a=new FileReader,l=new Blob([i]);a.onload=function(c){o(null,c.target.result)},a.onerror=function(c){o(c.error,null)},a.readAsText(l,r)}}function oM(s,e,t,n){let i=0,r=0,o=0,a=s.models.find(d=>d.url==t),l=e.circularMeps,c=e.rectMeps?.filter(d=>d.type==="风管"),h=e.rectMeps?.filter(d=>d.type==="桥架"),u=e.ellipseMeps,f=s.scene;if(new b.MeshBasicMaterial,new b.BufferGeometry,l&&l.length){let d=[],g=0;for(let p of l)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Circle",f,d,t)}if(c&&c.length){let d=[],g=0;for(let p of c)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Rect",f,d,t)}if(u&&u.length){let d=[],g=0;for(let p of u)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Ellipse",f,d,t)}if(h&&h.length){let d=[],g=0;for(let p of h)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Bridge",f,d,t)}}function Oo(s,e,t,n,i){let r,o,a={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":o=ko("Rect",a);break;case"Bridge":o=ko("Bridge",a);break;case"Circle":o=ko("Circle",a);break;case"Ellipse":o=ko("Ellipse",a);break}o&&(r=new b.InstancedMesh(o.geometry,o.material,t.length),r.url=n,e.add(r),r.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let d=t[h],g=new b.Vector3(d.startPoint.X,0,-d.startPoint.Y),p=new b.Vector3(d.endPoint.X,0,-d.endPoint.Y),m=new b.Vector3(d.startPoint.X,d.startPoint.Z,-d.startPoint.Y),x=new b.Vector3(d.endPoint.X,d.endPoint.Z,-d.endPoint.Y),_=0,v=0,y=0;if(Math.abs(p.clone().sub(g.clone()).z)<.01&&Math.abs(p.clone().sub(g.clone()).x)<.01){if(_=(d.startPoint.Z>d.endPoint.Z?1:-1)*Math.PI*.5,d.base_x!=null){var u=new b.Vector3(d.base_x.X,0,-d.base_x.Y);v=(u.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*u.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else v=(p.clone().sub(g.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*p.clone().sub(g.clone()).angleTo(new b.Vector3(0,0,1)),_=(d.startPoint.Z>d.endPoint.Z?1:-1)*p.clone().sub(g.clone()).angleTo(x.clone().sub(m.clone()));let M=new b.Matrix4;const S=new b.Euler(_,v,y,"YXZ");let E=M.clone().makeRotationFromEuler(S),D,A;s==="Circle"?(D=d.diameter,A=d.diameter):(D=d.width,A=d.height);let T=M.clone().makeScale(D,A,d.length);M.multiplyMatrices(E,T),M.setPosition(d.position.x,d.position.y,d.position.z),r.setMatrixAt(h,M.clone()),r.setColorAt(h,d.color),r.geometry.computeBoundingBox();let I=r.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),P=r.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),N=new b.Vector3(Math.min(I.x,P.x),Math.min(I.y,P.y),Math.min(I.z,P.z)),w=new b.Vector3(Math.max(I.x,P.x),Math.max(I.y,P.y),Math.max(I.z,P.z)),O=N.clone().add(w.clone()).multiplyScalar(.5),k={name:d.name,min:N,max:w,center:O,dbid:h,materialName:o.material.name},H=null,Y=null;s==="Circle"&&(H={x:d.startPoint.X*.3048,y:d.startPoint.Z*.3048,z:-d.startPoint.Y*.3048},Y={x:d.endPoint.X*.3048,y:d.endPoint.Z*.3048,z:-d.endPoint.Y*.3048},k.minC=H,k.maxC=Y),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(M.clone()),c.push(M.clone()),r.ids.push(Number(d.id)),l.push(k)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=s,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let f=[];f={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=f,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function ko(s,e,t){let n=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return r(n,i,e.color,e.position,e.rotation);function r(o,a,l,c,h){let u=new b.ExtrudeGeometry(o,a),f=new b.MeshStandardMaterial({color:l,side:b.DoubleSide}),d=new b.Mesh(u,f);return d.position.set(c.x,c.y,c.z),d.rotation._order="YXZ",d.rotation.set(h.x,h.y,h.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 C.BufferGeometry;let c=0;for(let h=0;h<s.length;++h){const u=s[h];let f=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 d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;r[d]===void 0&&(r[d]=[]),r[d].push(u.attributes[d]),f++}if(f!==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 d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=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,d,h),c+=d}}if(t){let h=0;const u=[];for(let f=0;f<s.length;++f){const d=s[f].index;for(let g=0;g<d.count;++g)u.push(d.getX(g)+h);h+=s[f].attributes.position.count}l.setIndex(u)}for(const h in r){const u=Rd(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 f=0;f<u;++f){const d=[];for(let p=0;p<o[h].length;++p)d.push(o[h][p][f]);const g=Rd(d);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(g)}}return l}function Rd(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 C.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 f=0,d=h.count;f<d;f++)for(let g=0;g<t;g++){const p=h.getComponent(f,g);a.setComponent(f+u,g,p)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Ld(s,e){if(e===C.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===C.TriangleFanDrawMode||e===C.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===C.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 aM(s){const e=new Map,t=new Map,n=s.clone();return Id(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 Id(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Id(s.children[n],e.children[n],t)}class lM extends C.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new fM(t)}),this.register(function(t){return new pM(t)}),this.register(function(t){return new SM(t)}),this.register(function(t){return new wM(t)}),this.register(function(t){return new AM(t)}),this.register(function(t){return new gM(t)}),this.register(function(t){return new xM(t)}),this.register(function(t){return new _M(t)}),this.register(function(t){return new vM(t)}),this.register(function(t){return new dM(t)}),this.register(function(t){return new yM(t)}),this.register(function(t){return new mM(t)}),this.register(function(t){return new bM(t)}),this.register(function(t){return new MM(t)}),this.register(function(t){return new hM(t)}),this.register(function(t){return new Nd(t,Ze.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Nd(t,Ze.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new EM(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=C.LoaderUtils.extractUrlBase(e);o=C.LoaderUtils.resolveURL(c,this.path)}else o=C.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 C.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))===Ud){try{o[Ze.KHR_BINARY_GLTF]=new TM(e)}catch(u){i&&i(u);return}r=JSON.parse(o[Ze.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 zM(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],f=r.extensionsRequired||[];switch(u){case Ze.KHR_MATERIALS_UNLIT:o[u]=new uM;break;case Ze.KHR_DRACO_MESH_COMPRESSION:o[u]=new CM(r,this.dracoLoader);break;case Ze.KHR_TEXTURE_TRANSFORM:o[u]=new PM;break;case Ze.KHR_MESH_QUANTIZATION:o[u]=new DM;break;default:f.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 cM(){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 bt(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const Ze={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 hM{constructor(e){this.parser=e,this.name=Ze.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 C.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],C.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new C.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new C.PointLight(h),c.distance=u;break;case"spot":c=new C.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),In(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 uM{constructor(){this.name=Ze.KHR_MATERIALS_UNLIT}getMaterialType(){return C.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new C.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],C.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,C.SRGBColorSpace))}return Promise.all(i)}}class dM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class fM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 C.Vector2(r,r)}return Promise.all(i)}}class pM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_DISPERSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class mM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 gM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_SHEEN}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new C.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],C.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,C.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class xM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 _M{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_VOLUME}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 C.Color().setRGB(r[0],r[1],r[2],C.LinearSRGBColorSpace),Promise.all(i)}}class vM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_IOR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class yM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_SPECULAR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 C.Color().setRGB(r[0],r[1],r[2],C.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,C.SRGBColorSpace)),Promise.all(i)}}class MM{constructor(e){this.parser=e,this.name=Ze.EXT_MATERIALS_BUMP}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 bM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 SM{constructor(e){this.parser=e,this.name=Ze.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 wM{constructor(e){this.parser=e,this.name=Ze.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 AM{constructor(e){this.parser=e,this.name=Ze.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 Nd{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,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class EM{constructor(e){this.name=Ze.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!==un.TRIANGLES&&c.mode!==un.TRIANGLE_STRIP&&c.mode!==un.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],f=c[0].count,d=[];for(const g of u){const p=new C.Matrix4,m=new C.Vector3,x=new C.Quaternion,_=new C.Vector3(1,1,1),v=new C.InstancedMesh(g.geometry,g.material,f);for(let y=0;y<f;y++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&x.fromBufferAttribute(l.ROTATION,y),l.SCALE&&_.fromBufferAttribute(l.SCALE,y),v.setMatrixAt(y,p.compose(m,x,_));for(const y in l)if(y==="_COLOR_0"){const M=l[y];v.instanceColor=new C.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,l[y]);C.Object3D.prototype.copy.call(v,g),this.parser.assignFinalMaterial(v),d.push(v)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const Ud="glTF",mr=12,Fd={JSON:1313821514,BIN:5130562};class TM{constructor(e){this.name=Ze.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,mr),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!==Ud)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-mr,r=new DataView(e,mr);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===Fd.JSON){const c=new Uint8Array(e,mr+o,a);this.content=n.decode(c)}else if(l===Fd.BIN){const c=mr+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class CM{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ze.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=uc[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=uc[h]||h.toLowerCase();if(o[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Us[f.componentType];c[u]=d.name,l[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){i.decodeDracoFile(h,function(d){for(const g in d.attributes){const p=d.attributes[g],m=l[g];m!==void 0&&(p.normalized=m)}u(d)},a,c,C.LinearSRGBColorSpace,f)})})}}class PM{constructor(){this.name=Ze.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 DM{constructor(){this.name=Ze.KHR_MESH_QUANTIZATION}}class Od extends C.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,f=u*u,d=f*u,g=e*c,p=g-c,m=-2*d+3*f,x=d-f,_=1-m,v=x-f+u;for(let y=0;y!==a;y++){const M=o[p+y+a],S=o[p+y+l]*h,E=o[g+y+a],D=o[g+y]*h;r[y]=_*M+v*S+m*E+x*D}return r}}const RM=new C.Quaternion;class LM extends Od{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return RM.fromArray(r).normalize().toArray(r),r}}const un={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Us={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kd={9728:C.NearestFilter,9729:C.LinearFilter,9984:C.NearestMipmapNearestFilter,9985:C.LinearMipmapNearestFilter,9986:C.NearestMipmapLinearFilter,9987:C.LinearMipmapLinearFilter},Bd={33071:C.ClampToEdgeWrapping,33648:C.MirroredRepeatWrapping,10497:C.RepeatWrapping},hc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},uc={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"},bi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},IM={CUBICSPLINE:void 0,LINEAR:C.InterpolateLinear,STEP:C.InterpolateDiscrete},dc={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function NM(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new C.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:C.FrontSide})),s.DefaultMaterial}function Ki(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 In(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 UM(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 f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(f)}if(r){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],f=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function FM(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 OM(s){let e;const t=s.extensions&&s.extensions[Ze.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+fc(t.attributes):e=s.indices+":"+fc(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+fc(s.targets[n]);return e}function fc(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 pc(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 kM(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 BM=new C.Matrix4;class zM{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new cM,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 C.TextureLoader(this.options.manager):this.textureLoader=new C.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new C.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 Ki(r,a,i),In(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[Ze.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(C.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=hc[i.type],a=Us[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new C.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=hc[i.type],c=Us[i.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,f=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let p,m;if(d&&d!==u){const x=Math.floor(f/d),_="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+x+":"+i.count;let v=t.cache.get(_);v||(p=new c(a,x*d,i.count*d/h),v=new C.InterleavedBuffer(p,d/h),t.cache.add(_,v)),m=new C.InterleavedBufferAttribute(v,l,f%d/h,g)}else a===null?p=new c(i.count*l):p=new c(a,f,i.count*l),m=new C.BufferAttribute(p,l,g);if(i.sparse!==void 0){const x=hc.SCALAR,_=Us[i.sparse.indices.componentType],v=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,M=new _(o[1],v,i.sparse.count*x),S=new c(o[2],y,i.sparse.count*l);a!==null&&(m=new C.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let E=0,D=M.length;E<D;E++){const A=M[E];if(m.setX(A,S[E*l]),l>=2&&m.setY(A,S[E*l+1]),l>=3&&m.setZ(A,S[E*l+2]),l>=4&&m.setW(A,S[E*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}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 f=(r.samplers||{})[o.sampler]||{};return h.magFilter=kd[f.magFilter]||C.LinearFilter,h.minFilter=kd[f.minFilter]||C.LinearMipmapLinearFilter,h.wrapS=Bd[f.wrapS]||C.RepeatWrapping,h.wrapT=Bd[f.wrapT]||C.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==C.NearestFilter&&h.minFilter!==C.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 f=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(f),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(f,d){let g=f;t.isImageBitmapLoader===!0&&(g=function(p){const m=new C.Texture(p);m.needsUpdate=!0,f(m)}),t.load(C.LoaderUtils.resolveURL(u,r.path),g,void 0,d)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),In(u,o),u.userData.mimeType=o.mimeType||kM(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[Ze.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[Ze.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[Ze.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 C.PointsMaterial,C.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 C.LineBasicMaterial,C.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 C.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[Ze.KHR_MATERIALS_UNLIT]){const u=i[Ze.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new C.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],C.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,C.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(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=C.DoubleSide);const h=r.alphaMode||dc.OPAQUE;if(h===dc.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===dc.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==C.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new C.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==C.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==C.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new C.Color().setRGB(u[0],u[1],u[2],C.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==C.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,C.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return r.name&&(u.name=r.name),In(u,r),t.associations.set(u,{materials:e}),r.extensions&&Ki(i,u,r),u})}createUniqueName(e){const t=C.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[Ze.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return zd(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=OM(c),u=i[h];if(u)o.push(u.promise);else{let f;c.extensions&&c.extensions[Ze.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=zd(new C.BufferGeometry,c,t),i[h]={primitive:c,promise:f},o.push(f)}}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?NM(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 d=0,g=h.length;d<g;d++){const p=h[d],m=o[d];let x;const _=c[d];if(m.mode===un.TRIANGLES||m.mode===un.TRIANGLE_STRIP||m.mode===un.TRIANGLE_FAN||m.mode===void 0)x=r.isSkinnedMesh===!0?new C.SkinnedMesh(p,_):new C.Mesh(p,_),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),m.mode===un.TRIANGLE_STRIP?x.geometry=Ld(x.geometry,C.TriangleStripDrawMode):m.mode===un.TRIANGLE_FAN&&(x.geometry=Ld(x.geometry,C.TriangleFanDrawMode));else if(m.mode===un.LINES)x=new C.LineSegments(p,_);else if(m.mode===un.LINE_STRIP)x=new C.Line(p,_);else if(m.mode===un.LINE_LOOP)x=new C.LineLoop(p,_);else if(m.mode===un.POINTS)x=new C.Points(p,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(x.geometry.morphAttributes).length>0&&FM(x,r),x.name=t.createUniqueName(r.name||"mesh_"+e),In(x,r),m.extensions&&Ki(i,x,m),t.assignFinalMaterial(x),u.push(x)}for(let d=0,g=u.length;d<g;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return r.extensions&&Ki(i,u[0],r),u[0];const f=new C.Group;r.extensions&&Ki(i,f,r),t.associations.set(f,{meshes:e});for(let d=0,g=u.length;d<g;d++)f.add(u[d]);return f})}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 C.PerspectiveCamera(C.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new C.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),In(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 f=new C.Matrix4;r!==null&&f.fromArray(r.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new C.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,f=i.channels.length;u<f;u++){const d=i.channels[u],g=i.samplers[d.sampler],p=d.target,m=p.node,x=i.parameters!==void 0?i.parameters[g.input]:g.input,_=i.parameters!==void 0?i.parameters[g.output]:g.output;p.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",x)),l.push(this.getDependency("accessor",_)),c.push(g),h.push(p))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],g=u[2],p=u[3],m=u[4],x=[];for(let v=0,y=f.length;v<y;v++){const M=f[v],S=d[v],E=g[v],D=p[v],A=m[v];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const T=n._createAnimationTracks(M,S,E,D,A);if(T)for(let I=0;I<T.length;I++)x.push(T[I])}const _=new C.AnimationClip(r,void 0,x);return In(_,i),_})}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],f=c[2];f!==null&&h.traverse(function(d){d.isSkinnedMesh&&d.bind(f,BM)});for(let d=0,g=u.length;d<g;d++)h.add(u[d]);if(h.userData.pivot!==void 0&&u.length>0){const d=h.userData.pivot,g=u[0];h.pivot=new C.Vector3().fromArray(d),h.position.x-=d[0],h.position.y-=d[1],h.position.z-=d[2],g.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 C.Bone:c.length>1?h=new C.Group:c.length===1?h=c[0]:h=new C.Object3D,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=o),In(h,r),r.extensions&&Ki(n,h,r),r.matrix!==void 0){const u=new C.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 C.Group;n.name&&(r.name=i.createUniqueName(n.name)),In(r,n),n.extensions&&Ki(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 f=l[h];f.parent!==null?r.add(aM(f)):r.add(f)}const c=h=>{const u=new Map;for(const[f,d]of i.associations)(f instanceof C.Material||f instanceof C.Texture)&&u.set(f,d);return h.traverse(f=>{const d=i.associations.get(f);d!=null&&u.set(f,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];bi[r.path]===bi.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let c;switch(bi[r.path]){case bi.weights:c=C.NumberKeyframeTrack;break;case bi.rotation:c=C.QuaternionKeyframeTrack;break;case bi.translation:case bi.scale:c=C.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=C.NumberKeyframeTrack;break;case 2:case 3:default:c=C.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?IM[i.interpolation]:C.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let f=0,d=l.length;f<d;f++){const g=new c(l[f]+"."+bi[r.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=pc(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 C.QuaternionKeyframeTrack?LM:Od;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function VM(s,e,t){const n=e.attributes,i=new C.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 C.Vector3(l[0],l[1],l[2]),new C.Vector3(c[0],c[1],c[2])),a.normalized){const h=pc(Us[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 C.Vector3,l=new C.Vector3;for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],d=f.min,g=f.max;if(d!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),f.normalized){const p=pc(Us[f.componentType]);l.multiplyScalar(p)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new C.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function zd(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=uc[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 C.ColorManagement.workingColorSpace!==C.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${C.ColorManagement.workingColorSpace}" not supported.`),In(s,e),VM(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?UM(s,e.targets,t):s})}var gt=(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))(gt||{});const GM=8,Vd=24,WM=24,HM=64,XM=60;function jM(){return new URL("draco/",document.baseURI).toString()}function Gd(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function YM(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function qM(s){return s?.engineStatus?.isFree===!1||YM()}async function ei(s,e,t){if(e)return t;const n=performance.now();return qM(s)||n-t>=GM?(await Gd(),performance.now()):t}function $M(s){return new Promise((e,t)=>{pr(s,n=>{if(n==null){t(new Error(`[loadLightModel] empty zip json: ${s}`));return}e(n)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${s}`))})})}function KM(s){return mt({method:"get",responseType:"arraybuffer",url:s}).then(e=>Xu.loadAsync(e.data))}function Wd(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function Hd(s,e){const t=new Set(e.map(n=>Wd(n)));for(const n of Object.keys(s.files))if(t.has(Wd(n)))return s.files[n];return null}function Xd(s,e){const t=Hd(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function ZM(s){return s.charCodeAt(0)===65279?s.slice(1):s}function mc(s){return JSON.parse(ZM(s))}function JM(s,e){const t=Hd(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function QM(s){return new Promise((e,t)=>{new lM().parse(s,document.baseURI,e,t)})}function Bo(s,e){return s.models.find(t=>t.url==e)}function jd(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function eb(s){return jd(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function Yd(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(n=>eb(n))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(gt.LoadingCompleted,{}))}function qd(s){return s===!0||s==="loading"}function $d(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function tb(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)%WM===0&&(n=await ei(s,t,n))}}async function nb(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 ei(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 ei(s,t,r)}return n}async function ib(s,e,t,n){const i=Bo(s,e.url);if(i?.nodesMap==null)return[];const r=await nb(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 f of u){const d=t.glbs?.[f.glb]?.[f.mesh];if(d?.geometry==null||d.material==null)continue;const g=new b.Matrix4;g.elements=f.matrix;const p=d.geometry.clone();p.applyMatrix4(g),p.computeBoundingBox();const m=new b.Mesh(p,d.material);f.box=p.boundingBox?.clone(),f.mesh=m,m.name=Number(c),m.glb=f.glb,m.url=e.url,p.attributes.position!=null&&o.push(m),l++,l%Vd===0&&(a=await ei(s,n,a))}}return o}function sb(s,e,t,n,i){const r=$i(n.map(a=>a.geometry),!1),o=new b.Mesh(r,i);return o.castShadow=!0,o.receiveShadow=!0,e.scene.add(o),o.index=e.scene.children.length-1,o.url=s,o.glb=t,o.materialClone=i,o.geometrys=n.map(a=>a.geometry),o.geometry.computeVertexNormals(),o}function rb(s,e,t,n){return s.scene.children.find(i=>{const r=i;return i instanceof b.Mesh&&r.url==e&&r.glb==t&&r.materialClone===n})}function ob(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 ab(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=Bo(e,s);let o=performance.now();for(const[a,l]of i.entries()){const c=n?l.length:XM;for(let h=0;h<l.length;h+=c){const u=l.slice(h,h+c);if(u.length===0)continue;const f=xb(u[0].material,e);let d=rb(e,s,a,f),g=0,p=0;d=null,d!=null?(g=Array.isArray(d.geometrys)?d.geometrys.length:0,p=$d(d.geometry),ob(d,u)):d=sb(s,e,a,u,f);const m=new Map;let x=p;u.forEach((_,v)=>{const y=Number(_.name),M=$d(_.geometry),S=m.get(y)??[];if(S.push([x,x+M]),m.set(y,S),r?.nodesMap?.has(y)){const E=r.nodesMap.get(y);E.indexes==null&&(E.indexes=[]),E.indexes.push([d.index,g+v,x,x+M])}x+=M}),d.indexes==null&&(d.indexes=new Map),m.forEach((_,v)=>{const y=d.indexes.get(v)??[];y.push(..._),d.indexes.set(v,y)}),o=await ei(e,n,o)}}}async function lb(s,e,t,n,i,r){if(n==null||i==null||i.length===0)return;const o=Bo(t,s);if(o==null)return;const a=new b.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(a);const l=new Float32Array(i.length*3);for(let u=0;u<i.length;u++)l[u*3]=1,l[u*3+1]=1,l[u*3+2]=1;a.instanceColor=new b.InstancedBufferAttribute(l,3);let c=performance.now();const h=[];for(let u=0;u<i.length;u++){const f=i[u],d=new b.Matrix4;if(d.elements=f.matrix,a.setMatrixAt(u,d),a.matrixs||(a.matrixs=[]),a.matrixs.push(d.clone()),h.push(d.clone()),o.nodesMap.has(f.id)){const g=o.nodesMap.get(f.id);g.indexes==null&&(g.indexes=[]),g.indexes.push([t.scene.children.length-1,u,0,0])}else o.nodesMap.set(f.id,{instance:!0,info:f,indexes:[[t.scene.children.length-1,u,0,0]]});(u+1)%HM===0&&(c=await ei(t,r,c))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.index=t.scene.children.length-1,a.materialClone=n.material,a.url=s,a.glb=n.glb,a.ids=i.map(u=>u.id),a.matrixsClone=h,a.meshIndex=e}async function cb(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 lb(s.url,a.mesh,t,l,a.children,n)}r=await ei(t,n,r)}}async function hb(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 ib(s,e,t,n);await ab(e.url,s,i,n),await cb(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 ub(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 KM(e.url+t.path),r=await Xd(i,["/nodes.json","nodes.json"]);if(r==null)return;const o=mc(r),a=Bo(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 d=0;d<u.length;d++){const g=u[d];g.glb=h,a.nodesMap.has(g.id)===!1?a.nodesMap.set(g.id,{infos:[g]}):a.nodesMap.get(g.id).infos.push(g),(d+1)%Vd===0&&(l=await ei(s,n,l))}const f=await JM(i,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(f==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 d=await QM(f);t.glbs[h]=d.scene.children,await tb(s,t.glbs[h],n)}catch(d){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:jM(),error:d})}l=await ei(s,n,l)}const c=await Xd(i,["/instances.json","instances.json"]);t.instanceNodes=c!=null?mc(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function db(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;e.getWorldDirection(c),s.camera.matrixWorld.extractBasis(l,c,new b.Vector3);const h=o.clone().add(c.setLength(-a)),u=h.clone().add(l.setLength(t.maxSize)),f=new it(s.camera,s.renderer,s.scene).worldToScreen(h),d=new it(s.camera,s.renderer,s.scene).worldToScreen(u);return f.distanceTo(d)}async function fb(s,e,t,n){t.maxSize<1e6&&(!(db(s,s.camera,t)>=20)||t.status===!0)||(await ub(s,e,t,n),t.loadSuccess===!0&&await hb(s,e,t,n))}function pb(s,e,t){if(qd(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await Gd(),oM(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,Yd(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)})}function mb(s,e,t,n){const i=new b.Group;i.name=e,s.scene.add(i),s.models||(s.models=[]),window.startTime=Date.now(),$M(e+"/info").then(r=>{const o=mc(r);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:o,name:o.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),s.models.push({url:e,nodesMap:new Map,grids:o.modelGrid,levels:o.modelLevel,rooms:o.modelRoom,views:o.modelView,boundingBox:{min:new b.Vector3(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new b.Vector3(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),s.models.length==n&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{Kd(s,e,!1)},100))}).catch(r=>{console.error("[loadLightModel] failed to load model info",{url:e,error:r})})}async function Kd(s,e,t=!1){const n=s.engineStatus.models.filter(i=>e==null||i.url==e);for(const i of n)if(jd(i),!(i.status!=="loading"||i.type!=="light")&&(pb(s,i,t),!qd(i.loadStatus.normal))){i.loadStatus.normal="loading";try{await gb(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"),Yd(s)}}}async function gb(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 fb(s,e,n,t)}function xb(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 _b{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&mb(this.engine,i,t,e.length);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var Fs=(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))(Fs||{});class vb{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(Fs.EngineFree,e=>{this.updateFree(!0),Kd(this.engine,e,!1)}),this.engine.events.on(Fs.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let yb=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)}})}};class Mb{engine;constructor(e){this.engine=e}init(){const e=new b.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new b.AmbientLight(16777215,1);this.engine.scene.add(i)}}class bb{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()}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))}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}}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.suppressClickOnce=!0)}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,f=this.engine.models.find(p=>p.url==c.url)?.nodesMap?.get(h),d=new Map;f?.indexes.forEach(p=>{this.getSceneModel(p[0])instanceof b.InstancedMesh&&(d.has(p[0])||d.set(p[0],[]),d.get(p[0])?.push(p[1]))});const g=[];return d.forEach((p,m)=>{const x=this.getSceneModel(m);p.forEach(_=>{const v=x.geometry.clone();v.applyMatrix4(x.matrixs[_]),g.push(new b.Mesh(v,x.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),g)}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&&!this.isCtrlDown)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(gt.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.viewCube.CameraGoHome(500);return}const t=e.catch,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 f=this.getSceneModel(u[0]);f?.geometry?.boundingSphere||f?.geometry?.computeBoundingSphere?.();const d=f?.geometry?.boundingSphere;if(!d)return;const g=new b.Box3,p=d.center.clone().applyMatrix4(l),m=d.radius,x=new b.Vector3().setFromMatrixScale(l),_=m*Math.max(x.x,x.y,x.z);g.min.set(p.x-_,p.y-_,p.z-_),g.max.set(p.x+_,p.y+_,p.z+_),c.push(g)});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(this.engine.scene.children.filter(t=>t instanceof b.InstancedMesh),!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)}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;return this.engine.models?.forEach(i=>{!i?.url||!i?.nodesMap||i.nodesMap.forEach((r,o)=>{const a=this.getNodeWorldBox(r),l=this.projectBoxToScreenRect(a);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(n.has(i.url)||n.set(i.url,new Set),n.get(i.url)?.add(o))})}),Array.from(n.entries()).map(([i,r])=>({url:i,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(gt.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(gt.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 it(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 this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class Sb{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),this.hideMaterial=new b.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof b.InstancedMesh)return;let t=e.materialClone.clone(),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){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.getSceneModel(a[0]).materialClone.color),this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),wb(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof b.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),Zd(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Eb(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Jd(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i&&(t.ids.forEach(r=>{const o=i.ids.indexOf(r);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==i)))})}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)});debugger;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){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),Ab(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof b.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&Jd(n,this.engine),Zd(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function wb(s,e){s.forEach((t,n)=>{const i=gr(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}),a=new b.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((u,f)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(f,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Zd(s,e,t){s.forEach((n,i)=>{const r=gr(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,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function Ab(s,e){s.forEach((t,n)=>{const i=gr(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}),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,f)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(f,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Eb(s,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),s.forEach((t,n)=>{const i=gr(e,n);if(!(i instanceof b.InstancedMesh))return;const r=new Map,o=new b.Matrix4,a=new b.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,o),r.set(l,o.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Jd(s,e){s.forEach((t,n)=>{const i=gr(e,n);i instanceof b.InstancedMesh&&(t.forEach(r=>{const o=i.matrixs[r];o&&i.setMatrixAt(r,o)}),i.instanceMatrix.needsUpdate=!0)})}function gr(s,e){return s.scene.children.find(t=>t.index==e)}class Tb{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){debugger;this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof 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 zo{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/zo.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/zo.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Vo={exports:{}},Cb=Vo.exports,Qd;function Pb(){return Qd||(Qd=1,(function(s,e){(function(t,n){s.exports=n()})(Cb,function(){var t=function(){function n(d){return o.appendChild(d.dom),d}function i(d){for(var g=0;g<o.children.length;g++)o.children[g].style.display=g===d?"block":"none";r=d}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(d){d.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 f=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 d=(performance||Date).now();if(u.update(d-a,200),d>l+1e3&&(h.update(1e3*c/(d-l),100),l=d,c=0,f)){var g=performance.memory;f.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return d},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,f=3*c,d=2*c,g=3*c,p=15*c,m=74*c,x=30*c,_=document.createElement("canvas");_.width=h,_.height=u,_.style.cssText="width:80px;height:48px";var v=_.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,h,u),v.fillStyle=i,v.fillText(n,f,d),v.fillRect(g,p,m,x),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(g,p,m,x),{dom:_,update:function(y,M){o=Math.min(o,y),a=Math.max(a,y),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,h,p),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(a)+")",f,d),v.drawImage(_,g+c,p,m-c,x,g,p,m-c,x),v.fillRect(g+m-c,p,c,x),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(g+m-c,p,c,l((1-y/M)*x))}}},t})})(Vo)),Vo.exports}var Db=Pb();const Rb=Wu(Db);var Os=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-Os.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?Os.Bounce.In(s*2)*.5:Os.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}}}}),xr=function(){return performance.now()},Lb=(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=xr()),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})(),gc={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=gc.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}}},ef=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),xc=new Lb,Ib=(function(){function s(e,t){t===void 0&&(t=xc),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=Os.Linear.None,this._interpolationFunction=gc.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ef.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=xr()),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 f=[a],d=0,g=u.length;d<g;d+=1){var p=this._handleRelativeValue(a,u[d]);if(isNaN(p)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(p)}h&&(n[o]=f)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var m=a;for(var x in m)t[o][x]=m[x];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var _={};for(var x in u)_[x]=u[x];n[o]=u=_}this._setupProperties(m,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=xr()),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=xr()),!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=xc),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=Os.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=gc.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=xr()),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 m=Math.trunc(a/l),x=a-m*l,_=Math.min(x/n._duration,1);return _===0&&a===n._duration?1:_},u=h(),f=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,f),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var d=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=d);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*d,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,p=this._chainedTweens.length;g<p;g++)this._chainedTweens[g].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})();ef.nextId;var Nn=xc;Nn.getAll.bind(Nn),Nn.removeAll.bind(Nn),Nn.add.bind(Nn),Nn.remove.bind(Nn),Nn.update.bind(Nn);var _r={Easing:Os,Tween:Ib};const tf={type:"change"},_c={type:"start"},nf={type:"end"},Go=new C.Ray,sf=new C.Plane,Nb=Math.cos(70*C.MathUtils.DEG2RAD),Dt=new C.Vector3,Kt=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},vc=1e-6;class Ub extends C.Controls{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new C.Vector3,this.cursor=new C.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:C.MOUSE.ROTATE,MIDDLE:C.MOUSE.DOLLY,RIGHT:C.MOUSE.PAN},this.touches={ONE:C.TOUCH.ROTATE,TWO:C.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new C.Vector3,this._lastQuaternion=new C.Quaternion,this._lastTargetPosition=new C.Vector3,this._quat=new C.Quaternion().setFromUnitVectors(e.up,new C.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new C.Spherical,this._sphericalDelta=new C.Spherical,this._scale=1,this._panOffset=new C.Vector3,this._rotateStart=new C.Vector2,this._rotateEnd=new C.Vector2,this._rotateDelta=new C.Vector2,this._panStart=new C.Vector2,this._panEnd=new C.Vector2,this._panDelta=new C.Vector2,this._dollyStart=new C.Vector2,this._dollyEnd=new C.Vector2,this._dollyDelta=new C.Vector2,this._dollyDirection=new C.Vector3,this._mouse=new C.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ob.bind(this),this._onPointerDown=Fb.bind(this),this._onPointerUp=kb.bind(this),this._onContextMenu=Xb.bind(this),this._onMouseWheel=Vb.bind(this),this._onKeyDown=Gb.bind(this),this._onTouchStart=Wb.bind(this),this._onTouchMove=Hb.bind(this),this._onMouseDown=Bb.bind(this),this._onMouseMove=zb.bind(this),this._interceptControlDown=jb.bind(this),this._interceptControlUp=Yb.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(tf),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Dt.copy(t).sub(this.target),Dt.applyQuaternion(this._quat),this._spherical.setFromVector3(Dt),this.autoRotate&&this.state===lt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Kt:n>Math.PI&&(n-=Kt),i<-Math.PI?i+=Kt:i>Math.PI&&(i-=Kt),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Dt.setFromSpherical(this._spherical),Dt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Dt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Dt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new C.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new C.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Dt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Go.origin.copy(this.object.position),Go.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Go.direction))<Nb?this.object.lookAt(this.target):(sf.setFromNormalAndCoplanarPoint(this.object.up,this.target),Go.intersectPlane(sf,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>vc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>vc||this._lastTargetPosition.distanceToSquared(this.target)>vc?(this.dispatchEvent(tf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Kt/60*this.autoRotateSpeed*e:Kt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Dt.setFromMatrixColumn(t,0),Dt.multiplyScalar(-e),this._panOffset.add(Dt)}_panUp(e,t){this.screenSpacePanning===!0?Dt.setFromMatrixColumn(t,1):(Dt.setFromMatrixColumn(t,0),Dt.crossVectors(this.object.up,Dt)),Dt.multiplyScalar(e),this._panOffset.add(Dt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Dt.copy(i).sub(this.target);let r=Dt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new C.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Fb(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Ob(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function kb(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(nf),this.state=lt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Bb(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case C.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=lt.DOLLY;break;case C.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}break;case C.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(_c)}function zb(s){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Vb(s){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(s.preventDefault(),this.dispatchEvent(_c),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(nf))}function Gb(s){this.enabled!==!1&&this._handleKeyDown(s)}function Wb(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case C.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=lt.TOUCH_ROTATE;break;case C.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case C.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=lt.TOUCH_DOLLY_PAN;break;case C.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(_c)}function Hb(s){switch(this._trackPointer(s),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=lt.NONE}}function Xb(s){this.enabled!==!1&&s.preventDefault()}function jb(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Yb(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class qb extends C.DataTextureLoader{constructor(e){super(e),this.type=C.HalfFloatType}parse(e){const o=function(D,A){switch(D){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(A||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(A||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(A||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(A||""))}},u=function(D,A,T){A=A||1024;let P=D.pos,N=-1,w=0,O="",k=String.fromCharCode.apply(null,new Uint16Array(D.subarray(P,P+128)));for(;0>(N=k.indexOf(`
|
|
4939
|
+
`+r):n.stack=r}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Yi(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:r}=t;n!==void 0&&Fo.assertOptions(n,{silentJSONParsing:Ln.transitional(Ln.boolean),forcedJSONParsing:Ln.transitional(Ln.boolean),clarifyTimeoutError:Ln.transitional(Ln.boolean)},!1),i!=null&&(le.isFunction(i)?t.paramsSerializer={serialize:i}:Fo.assertOptions(i,{encode:Ln.function,serialize:Ln.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Fo.assertOptions(t,{baseUrl:Ln.spelling("baseURL"),withXsrfToken:Ln.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=r&&le.merge(r.common,r[t.method]);r&&le.forEach(["delete","get","head","post","put","patch","common"],g=>{delete r[g]}),t.headers=$t.concat(o,r);const a=[];let l=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(t)===!1||(l=l&&p.synchronous,a.unshift(p.fulfilled,p.rejected))});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let h,u=0,f;if(!l){const g=[Td.bind(this),void 0];for(g.unshift(...a),g.push(...c),f=g.length,h=Promise.resolve(t);u<f;)h=h.then(g[u++],g[u++]);return h}f=a.length;let d=t;for(;u<f;){const g=a[u++],p=a[u++];try{d=g(d)}catch(m){p.call(this,m);break}}try{h=Td.call(this,d)}catch(g){return Promise.reject(g)}for(u=0,f=c.length;u<f;)h=h.then(c[u++],c[u++]);return h}getUri(e){e=Yi(this.defaults,e);const t=gd(e.baseURL,e.url,e.allowAbsoluteUrls);return ad(t,e.params,e.paramsSerializer)}};le.forEach(["delete","get","head","options"],function(e){qi.prototype[e]=function(t,n){return this.request(Yi(n||{},{method:e,url:t,data:(n||{}).data}))}}),le.forEach(["post","put","patch"],function(e){function t(n){return function(r,o,a){return this.request(Yi(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:r,data:o}))}}qi.prototype[e]=t(),qi.prototype[e+"Form"]=t(!0)});let iM=class yp{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 Ns(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 yp(function(i){e=i}),cancel:e}}};function sM(s){return function(t){return s.apply(null,t)}}function rM(s){return le.isObject(s)&&s.isAxiosError===!0}const cc={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(cc).forEach(([s,e])=>{cc[e]=s});function Dd(s){const e=new qi(s),t=ju(qi.prototype.request,e);return le.extend(t,qi.prototype,e,{allOwnKeys:!0}),le.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Dd(Yi(s,i))},t}const mt=Dd(dr);mt.Axios=qi,mt.CanceledError=Ns,mt.CancelToken=iM,mt.isCancel=dd,mt.VERSION=Cd,mt.toFormData=Ro,mt.AxiosError=qe,mt.Cancel=mt.CanceledError,mt.all=function(e){return Promise.all(e)},mt.spread=sM,mt.isAxiosError=rM,mt.mergeConfig=Yi,mt.AxiosHeaders=$t,mt.formToJSON=s=>hd(le.isHTMLForm(s)?new FormData(s):s),mt.getAdapter=Ed.getAdapter,mt.HttpStatusCode=cc,mt.default=mt;const{Axios:wE,AxiosError:AE,CanceledError:EE,isCancel:TE,CancelToken:CE,VERSION:PE,all:DE,Cancel:RE,isAxiosError:LE,spread:IE,toFormData:NE,AxiosHeaders:UE,HttpStatusCode:FE,formToJSON:OE,getAdapter:kE,mergeConfig:BE}=mt;function pr(s,e,t){mt({method:"get",responseType:"blob",url:s}).then(i=>{let r=new window.File([i.data],"semantics",{type:"zip"});Xu.loadAsync(r).then(o=>{for(let a in o.files){const l=o.file(o.files[a].name);l&&l.async("blob").then(c=>{n(c,"utf-8",function(h,u){e(u)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(i=>{t()});function n(i,r,o){var a=new FileReader,l=new Blob([i]);a.onload=function(c){o(null,c.target.result)},a.onerror=function(c){o(c.error,null)},a.readAsText(l,r)}}function oM(s,e,t,n){let i=0,r=0,o=0,a=s.models.find(d=>d.url==t),l=e.circularMeps,c=e.rectMeps?.filter(d=>d.type==="风管"),h=e.rectMeps?.filter(d=>d.type==="桥架"),u=e.ellipseMeps,f=s.scene;if(new b.MeshBasicMaterial,new b.BufferGeometry,l&&l.length){let d=[],g=0;for(let p of l)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Circle",f,d,t)}if(c&&c.length){let d=[],g=0;for(let p of c)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Rect",f,d,t)}if(u&&u.length){let d=[],g=0;for(let p of u)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Ellipse",f,d,t)}if(h&&h.length){let d=[],g=0;for(let p of h)p.color=p.color.split(",").map(m=>parseInt(m)/255),p.color=new b.Color(p.color[0],p.color[1],p.color[2]),p.position={x:p.startPoint.X*.3048+i,y:p.startPoint.Z*.3048+r,z:-p.startPoint.Y*.3048+o},p.rotation={x:0,y:0,z:0},p.indexes=[[s.scene.children.length,g++,0,0]],a.nodesMap.set(Number(p.id),p),d.push(p);Oo("Bridge",f,d,t)}}function Oo(s,e,t,n,i){let r,o,a={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":o=ko("Rect",a);break;case"Bridge":o=ko("Bridge",a);break;case"Circle":o=ko("Circle",a);break;case"Ellipse":o=ko("Ellipse",a);break}o&&(r=new b.InstancedMesh(o.geometry,o.material,t.length),r.url=n,e.add(r),r.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let d=t[h],g=new b.Vector3(d.startPoint.X,0,-d.startPoint.Y),p=new b.Vector3(d.endPoint.X,0,-d.endPoint.Y),m=new b.Vector3(d.startPoint.X,d.startPoint.Z,-d.startPoint.Y),x=new b.Vector3(d.endPoint.X,d.endPoint.Z,-d.endPoint.Y),_=0,v=0,y=0;if(Math.abs(p.clone().sub(g.clone()).z)<.01&&Math.abs(p.clone().sub(g.clone()).x)<.01){if(_=(d.startPoint.Z>d.endPoint.Z?1:-1)*Math.PI*.5,d.base_x!=null){var u=new b.Vector3(d.base_x.X,0,-d.base_x.Y);v=(u.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*u.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else v=(p.clone().sub(g.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*p.clone().sub(g.clone()).angleTo(new b.Vector3(0,0,1)),_=(d.startPoint.Z>d.endPoint.Z?1:-1)*p.clone().sub(g.clone()).angleTo(x.clone().sub(m.clone()));let M=new b.Matrix4;const S=new b.Euler(_,v,y,"YXZ");let E=M.clone().makeRotationFromEuler(S),D,A;s==="Circle"?(D=d.diameter,A=d.diameter):(D=d.width,A=d.height);let T=M.clone().makeScale(D,A,d.length);M.multiplyMatrices(E,T),M.setPosition(d.position.x,d.position.y,d.position.z),r.setMatrixAt(h,M.clone()),r.setColorAt(h,d.color),r.geometry.computeBoundingBox();let I=r.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),P=r.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),N=new b.Vector3(Math.min(I.x,P.x),Math.min(I.y,P.y),Math.min(I.z,P.z)),w=new b.Vector3(Math.max(I.x,P.x),Math.max(I.y,P.y),Math.max(I.z,P.z)),O=N.clone().add(w.clone()).multiplyScalar(.5),k={name:d.name,min:N,max:w,center:O,dbid:h,materialName:o.material.name},H=null,Y=null;s==="Circle"&&(H={x:d.startPoint.X*.3048,y:d.startPoint.Z*.3048,z:-d.startPoint.Y*.3048},Y={x:d.endPoint.X*.3048,y:d.endPoint.Z*.3048,z:-d.endPoint.Y*.3048},k.minC=H,k.maxC=Y),r.ids||(r.ids=[]),r.matrixs||(r.matrixs=[]),r.matrixs.push(M.clone()),c.push(M.clone()),r.ids.push(Number(d.id)),l.push(k)}r.castShadow=!0,r.ElementInfos=l,r.name="rootModel",r.TypeName="InstancedMesh-Pipe",r.PipeType=s,r.MeshId=null,r.realMaterial=r.material.clone(),r.originalMaterial=r.material.clone(),r.matrixsClone=c;let f=[];f={geometry:r.geometry,matrix:r.matrix,position:r.position,rotation:r.rotation},r.meshs=f,r.instanceMatrix&&r.instanceMatrix.array&&(r.cloneInstanceMatrix=Array.from(r.instanceMatrix.array))}function ko(s,e,t){let n=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,s){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return r(n,i,e.color,e.position,e.rotation);function r(o,a,l,c,h){let u=new b.ExtrudeGeometry(o,a),f=new b.MeshStandardMaterial({color:l,side:b.DoubleSide}),d=new b.Mesh(u,f);return d.position.set(c.x,c.y,c.z),d.rotation._order="YXZ",d.rotation.set(h.x,h.y,h.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 C.BufferGeometry;let c=0;for(let h=0;h<s.length;++h){const u=s[h];let f=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 d in u.attributes){if(!n.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+d+'" attribute exists among all geometries, or in none of them.'),null;r[d]===void 0&&(r[d]=[]),r[d].push(u.attributes[d]),f++}if(f!==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 d in u.morphAttributes){if(!i.has(d))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[d]===void 0&&(o[d]=[]),o[d].push(u.morphAttributes[d])}if(e){let d;if(t)d=u.index.count;else if(u.attributes.position!==void 0)d=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,d,h),c+=d}}if(t){let h=0;const u=[];for(let f=0;f<s.length;++f){const d=s[f].index;for(let g=0;g<d.count;++g)u.push(d.getX(g)+h);h+=s[f].attributes.position.count}l.setIndex(u)}for(const h in r){const u=Rd(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 f=0;f<u;++f){const d=[];for(let p=0;p<o[h].length;++p)d.push(o[h][p][f]);const g=Rd(d);if(!g)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(g)}}return l}function Rd(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 C.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 f=0,d=h.count;f<d;f++)for(let g=0;g<t;g++){const p=h.getComponent(f,g);a.setComponent(f+u,g,p)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Ld(s,e){if(e===C.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),s;if(e===C.TriangleFanDrawMode||e===C.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===C.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 aM(s){const e=new Map,t=new Map,n=s.clone();return Id(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 Id(s,e,t){t(s,e);for(let n=0;n<s.children.length;n++)Id(s.children[n],e.children[n],t)}class lM extends C.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new fM(t)}),this.register(function(t){return new pM(t)}),this.register(function(t){return new SM(t)}),this.register(function(t){return new wM(t)}),this.register(function(t){return new AM(t)}),this.register(function(t){return new gM(t)}),this.register(function(t){return new xM(t)}),this.register(function(t){return new _M(t)}),this.register(function(t){return new vM(t)}),this.register(function(t){return new dM(t)}),this.register(function(t){return new yM(t)}),this.register(function(t){return new mM(t)}),this.register(function(t){return new bM(t)}),this.register(function(t){return new MM(t)}),this.register(function(t){return new hM(t)}),this.register(function(t){return new Nd(t,Ze.EXT_MESHOPT_COMPRESSION)}),this.register(function(t){return new Nd(t,Ze.KHR_MESHOPT_COMPRESSION)}),this.register(function(t){return new EM(t)})}load(e,t,n,i){const r=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=C.LoaderUtils.extractUrlBase(e);o=C.LoaderUtils.resolveURL(c,this.path)}else o=C.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 C.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))===Ud){try{o[Ze.KHR_BINARY_GLTF]=new TM(e)}catch(u){i&&i(u);return}r=JSON.parse(o[Ze.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 zM(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],f=r.extensionsRequired||[];switch(u){case Ze.KHR_MATERIALS_UNLIT:o[u]=new uM;break;case Ze.KHR_DRACO_MESH_COMPRESSION:o[u]=new CM(r,this.dracoLoader);break;case Ze.KHR_TEXTURE_TRANSFORM:o[u]=new PM;break;case Ze.KHR_MESH_QUANTIZATION:o[u]=new DM;break;default:f.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 cM(){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 bt(s,e,t){const n=s.json.materials[e];return n.extensions&&n.extensions[t]?n.extensions[t]:null}const Ze={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 hM{constructor(e){this.parser=e,this.name=Ze.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 C.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],C.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new C.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new C.PointLight(h),c.distance=u;break;case"spot":c=new C.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),In(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 uM{constructor(){this.name=Ze.KHR_MATERIALS_UNLIT}getMaterialType(){return C.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new C.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],C.LinearSRGBColorSpace),e.opacity=o[3]}r.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",r.baseColorTexture,C.SRGBColorSpace))}return Promise.all(i)}}class dM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||n.emissiveStrength!==void 0&&(t.emissiveIntensity=n.emissiveStrength),Promise.resolve()}}class fM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 C.Vector2(r,r)}return Promise.all(i)}}class pM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_DISPERSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.dispersion=n.dispersion!==void 0?n.dispersion:0),Promise.resolve()}}class mM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 gM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_SHEEN}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);if(n===null)return Promise.resolve();const i=[];if(t.sheenColor=new C.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],C.LinearSRGBColorSpace)}return n.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=n.sheenRoughnessFactor),n.sheenColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenColorMap",n.sheenColorTexture,C.SRGBColorSpace)),n.sheenRoughnessTexture!==void 0&&i.push(this.parser.assignTexture(t,"sheenRoughnessMap",n.sheenRoughnessTexture)),Promise.all(i)}}class xM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 _M{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_VOLUME}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 C.Color().setRGB(r[0],r[1],r[2],C.LinearSRGBColorSpace),Promise.all(i)}}class vM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_IOR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(this.parser,e,this.name);return n===null||(t.ior=n.ior!==void 0?n.ior:1.5),Promise.resolve()}}class yM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_SPECULAR}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 C.Color().setRGB(r[0],r[1],r[2],C.LinearSRGBColorSpace),n.specularColorTexture!==void 0&&i.push(this.parser.assignTexture(t,"specularColorMap",n.specularColorTexture,C.SRGBColorSpace)),Promise.all(i)}}class MM{constructor(e){this.parser=e,this.name=Ze.EXT_MATERIALS_BUMP}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 bM{constructor(e){this.parser=e,this.name=Ze.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){return bt(this.parser,e,this.name)!==null?C.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const n=bt(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 SM{constructor(e){this.parser=e,this.name=Ze.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 wM{constructor(e){this.parser=e,this.name=Ze.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 AM{constructor(e){this.parser=e,this.name=Ze.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 Nd{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,f=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,f,i.mode,i.filter).then(function(d){return d.buffer}):o.ready.then(function(){const d=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(d),h,u,f,i.mode,i.filter),d})})}else return null}}class EM{constructor(e){this.name=Ze.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!==un.TRIANGLES&&c.mode!==un.TRIANGLE_STRIP&&c.mode!==un.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],f=c[0].count,d=[];for(const g of u){const p=new C.Matrix4,m=new C.Vector3,x=new C.Quaternion,_=new C.Vector3(1,1,1),v=new C.InstancedMesh(g.geometry,g.material,f);for(let y=0;y<f;y++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,y),l.ROTATION&&x.fromBufferAttribute(l.ROTATION,y),l.SCALE&&_.fromBufferAttribute(l.SCALE,y),v.setMatrixAt(y,p.compose(m,x,_));for(const y in l)if(y==="_COLOR_0"){const M=l[y];v.instanceColor=new C.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else y!=="TRANSLATION"&&y!=="ROTATION"&&y!=="SCALE"&&g.geometry.setAttribute(y,l[y]);C.Object3D.prototype.copy.call(v,g),this.parser.assignFinalMaterial(v),d.push(v)}return h.isGroup?(h.clear(),h.add(...d),h):d[0]}))}}const Ud="glTF",mr=12,Fd={JSON:1313821514,BIN:5130562};class TM{constructor(e){this.name=Ze.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,mr),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!==Ud)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-mr,r=new DataView(e,mr);let o=0;for(;o<i;){const a=r.getUint32(o,!0);o+=4;const l=r.getUint32(o,!0);if(o+=4,l===Fd.JSON){const c=new Uint8Array(e,mr+o,a);this.content=n.decode(c)}else if(l===Fd.BIN){const c=mr+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class CM{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=Ze.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=uc[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=uc[h]||h.toLowerCase();if(o[h]!==void 0){const f=n.accessors[e.attributes[h]],d=Us[f.componentType];c[u]=d.name,l[u]=f.normalized===!0}}return t.getDependency("bufferView",r).then(function(h){return new Promise(function(u,f){i.decodeDracoFile(h,function(d){for(const g in d.attributes){const p=d.attributes[g],m=l[g];m!==void 0&&(p.normalized=m)}u(d)},a,c,C.LinearSRGBColorSpace,f)})})}}class PM{constructor(){this.name=Ze.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 DM{constructor(){this.name=Ze.KHR_MESH_QUANTIZATION}}class Od extends C.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,f=u*u,d=f*u,g=e*c,p=g-c,m=-2*d+3*f,x=d-f,_=1-m,v=x-f+u;for(let y=0;y!==a;y++){const M=o[p+y+a],S=o[p+y+l]*h,E=o[g+y+a],D=o[g+y]*h;r[y]=_*M+v*S+m*E+x*D}return r}}const RM=new C.Quaternion;class LM extends Od{interpolate_(e,t,n,i){const r=super.interpolate_(e,t,n,i);return RM.fromArray(r).normalize().toArray(r),r}}const un={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Us={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},kd={9728:C.NearestFilter,9729:C.LinearFilter,9984:C.NearestMipmapNearestFilter,9985:C.LinearMipmapNearestFilter,9986:C.NearestMipmapLinearFilter,9987:C.LinearMipmapLinearFilter},Bd={33071:C.ClampToEdgeWrapping,33648:C.MirroredRepeatWrapping,10497:C.RepeatWrapping},hc={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},uc={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"},bi={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},IM={CUBICSPLINE:void 0,LINEAR:C.InterpolateLinear,STEP:C.InterpolateDiscrete},dc={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function NM(s){return s.DefaultMaterial===void 0&&(s.DefaultMaterial=new C.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:C.FrontSide})),s.DefaultMaterial}function Ki(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 In(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 UM(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 f=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):s.attributes.position;o.push(f)}if(i){const f=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):s.attributes.normal;a.push(f)}if(r){const f=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):s.attributes.color;l.push(f)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],f=c[2];return n&&(s.morphAttributes.position=h),i&&(s.morphAttributes.normal=u),r&&(s.morphAttributes.color=f),s.morphTargetsRelative=!0,s})}function FM(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 OM(s){let e;const t=s.extensions&&s.extensions[Ze.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+fc(t.attributes):e=s.indices+":"+fc(s.attributes)+":"+s.mode,s.targets!==void 0)for(let n=0,i=s.targets.length;n<i;n++)e+=":"+fc(s.targets[n]);return e}function fc(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 pc(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 kM(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 BM=new C.Matrix4;class zM{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new cM,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 C.TextureLoader(this.options.manager):this.textureLoader=new C.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new C.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 Ki(r,a,i),In(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[Ze.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(r,o){n.load(C.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=hc[i.type],a=Us[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new C.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=hc[i.type],c=Us[i.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,f=i.byteOffset||0,d=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,g=i.normalized===!0;let p,m;if(d&&d!==u){const x=Math.floor(f/d),_="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+x+":"+i.count;let v=t.cache.get(_);v||(p=new c(a,x*d,i.count*d/h),v=new C.InterleavedBuffer(p,d/h),t.cache.add(_,v)),m=new C.InterleavedBufferAttribute(v,l,f%d/h,g)}else a===null?p=new c(i.count*l):p=new c(a,f,i.count*l),m=new C.BufferAttribute(p,l,g);if(i.sparse!==void 0){const x=hc.SCALAR,_=Us[i.sparse.indices.componentType],v=i.sparse.indices.byteOffset||0,y=i.sparse.values.byteOffset||0,M=new _(o[1],v,i.sparse.count*x),S=new c(o[2],y,i.sparse.count*l);a!==null&&(m=new C.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let E=0,D=M.length;E<D;E++){const A=M[E];if(m.setX(A,S[E*l]),l>=2&&m.setY(A,S[E*l+1]),l>=3&&m.setZ(A,S[E*l+2]),l>=4&&m.setW(A,S[E*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=g}return m})}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 f=(r.samplers||{})[o.sampler]||{};return h.magFilter=kd[f.magFilter]||C.LinearFilter,h.minFilter=kd[f.minFilter]||C.LinearMipmapLinearFilter,h.wrapS=Bd[f.wrapS]||C.RepeatWrapping,h.wrapT=Bd[f.wrapT]||C.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==C.NearestFilter&&h.minFilter!==C.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 f=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(f),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(f,d){let g=f;t.isImageBitmapLoader===!0&&(g=function(p){const m=new C.Texture(p);m.needsUpdate=!0,f(m)}),t.load(C.LoaderUtils.resolveURL(u,r.path),g,void 0,d)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),In(u,o),u.userData.mimeType=o.mimeType||kM(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[Ze.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[Ze.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=r.associations.get(o);o=r.extensions[Ze.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 C.PointsMaterial,C.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 C.LineBasicMaterial,C.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 C.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[Ze.KHR_MATERIALS_UNLIT]){const u=i[Ze.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,r,t))}else{const u=r.pbrMetallicRoughness||{};if(a.color=new C.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const f=u.baseColorFactor;a.color.setRGB(f[0],f[1],f[2],C.LinearSRGBColorSpace),a.opacity=f[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,C.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(f){return f.getMaterialType&&f.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(f){return f.extendMaterialParams&&f.extendMaterialParams(e,a)})))}r.doubleSided===!0&&(a.side=C.DoubleSide);const h=r.alphaMode||dc.OPAQUE;if(h===dc.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===dc.MASK&&(a.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&o!==C.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",r.normalTexture)),a.normalScale=new C.Vector2(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;a.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&o!==C.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&o!==C.MeshBasicMaterial){const u=r.emissiveFactor;a.emissive=new C.Color().setRGB(u[0],u[1],u[2],C.LinearSRGBColorSpace)}return r.emissiveTexture!==void 0&&o!==C.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",r.emissiveTexture,C.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return r.name&&(u.name=r.name),In(u,r),t.associations.set(u,{materials:e}),r.extensions&&Ki(i,u,r),u})}createUniqueName(e){const t=C.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[Ze.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return zd(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=OM(c),u=i[h];if(u)o.push(u.promise);else{let f;c.extensions&&c.extensions[Ze.KHR_DRACO_MESH_COMPRESSION]?f=r(c):f=zd(new C.BufferGeometry,c,t),i[h]={primitive:c,promise:f},o.push(f)}}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?NM(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 d=0,g=h.length;d<g;d++){const p=h[d],m=o[d];let x;const _=c[d];if(m.mode===un.TRIANGLES||m.mode===un.TRIANGLE_STRIP||m.mode===un.TRIANGLE_FAN||m.mode===void 0)x=r.isSkinnedMesh===!0?new C.SkinnedMesh(p,_):new C.Mesh(p,_),x.isSkinnedMesh===!0&&x.normalizeSkinWeights(),m.mode===un.TRIANGLE_STRIP?x.geometry=Ld(x.geometry,C.TriangleStripDrawMode):m.mode===un.TRIANGLE_FAN&&(x.geometry=Ld(x.geometry,C.TriangleFanDrawMode));else if(m.mode===un.LINES)x=new C.LineSegments(p,_);else if(m.mode===un.LINE_STRIP)x=new C.Line(p,_);else if(m.mode===un.LINE_LOOP)x=new C.LineLoop(p,_);else if(m.mode===un.POINTS)x=new C.Points(p,_);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(x.geometry.morphAttributes).length>0&&FM(x,r),x.name=t.createUniqueName(r.name||"mesh_"+e),In(x,r),m.extensions&&Ki(i,x,m),t.assignFinalMaterial(x),u.push(x)}for(let d=0,g=u.length;d<g;d++)t.associations.set(u[d],{meshes:e,primitives:d});if(u.length===1)return r.extensions&&Ki(i,u[0],r),u[0];const f=new C.Group;r.extensions&&Ki(i,f,r),t.associations.set(f,{meshes:e});for(let d=0,g=u.length;d<g;d++)f.add(u[d]);return f})}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 C.PerspectiveCamera(C.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new C.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),In(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 f=new C.Matrix4;r!==null&&f.fromArray(r.array,c*16),l.push(f)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new C.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,f=i.channels.length;u<f;u++){const d=i.channels[u],g=i.samplers[d.sampler],p=d.target,m=p.node,x=i.parameters!==void 0?i.parameters[g.input]:g.input,_=i.parameters!==void 0?i.parameters[g.output]:g.output;p.node!==void 0&&(o.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",x)),l.push(this.getDependency("accessor",_)),c.push(g),h.push(p))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){const f=u[0],d=u[1],g=u[2],p=u[3],m=u[4],x=[];for(let v=0,y=f.length;v<y;v++){const M=f[v],S=d[v],E=g[v],D=p[v],A=m[v];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const T=n._createAnimationTracks(M,S,E,D,A);if(T)for(let I=0;I<T.length;I++)x.push(T[I])}const _=new C.AnimationClip(r,void 0,x);return In(_,i),_})}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],f=c[2];f!==null&&h.traverse(function(d){d.isSkinnedMesh&&d.bind(f,BM)});for(let d=0,g=u.length;d<g;d++)h.add(u[d]);if(h.userData.pivot!==void 0&&u.length>0){const d=h.userData.pivot,g=u[0];h.pivot=new C.Vector3().fromArray(d),h.position.x-=d[0],h.position.y-=d[1],h.position.z-=d[2],g.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 C.Bone:c.length>1?h=new C.Group:c.length===1?h=c[0]:h=new C.Object3D,h!==c[0])for(let u=0,f=c.length;u<f;u++)h.add(c[u]);if(r.name&&(h.userData.name=r.name,h.name=o),In(h,r),r.extensions&&Ki(n,h,r),r.matrix!==void 0){const u=new C.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 C.Group;n.name&&(r.name=i.createUniqueName(n.name)),In(r,n),n.extensions&&Ki(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 f=l[h];f.parent!==null?r.add(aM(f)):r.add(f)}const c=h=>{const u=new Map;for(const[f,d]of i.associations)(f instanceof C.Material||f instanceof C.Texture)&&u.set(f,d);return h.traverse(f=>{const d=i.associations.get(f);d!=null&&u.set(f,d)}),u};return i.associations=c(r),r})}_createAnimationTracks(e,t,n,i,r){const o=[],a=e.name?e.name:e.uuid,l=[];bi[r.path]===bi.weights?e.traverse(function(f){f.morphTargetInfluences&&l.push(f.name?f.name:f.uuid)}):l.push(a);let c;switch(bi[r.path]){case bi.weights:c=C.NumberKeyframeTrack;break;case bi.rotation:c=C.QuaternionKeyframeTrack;break;case bi.translation:case bi.scale:c=C.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=C.NumberKeyframeTrack;break;case 2:case 3:default:c=C.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?IM[i.interpolation]:C.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let f=0,d=l.length;f<d;f++){const g=new c(l[f]+"."+bi[r.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(g),o.push(g)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=pc(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 C.QuaternionKeyframeTrack?LM:Od;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function VM(s,e,t){const n=e.attributes,i=new C.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 C.Vector3(l[0],l[1],l[2]),new C.Vector3(c[0],c[1],c[2])),a.normalized){const h=pc(Us[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 C.Vector3,l=new C.Vector3;for(let c=0,h=r.length;c<h;c++){const u=r[c];if(u.POSITION!==void 0){const f=t.json.accessors[u.POSITION],d=f.min,g=f.max;if(d!==void 0&&g!==void 0){if(l.setX(Math.max(Math.abs(d[0]),Math.abs(g[0]))),l.setY(Math.max(Math.abs(d[1]),Math.abs(g[1]))),l.setZ(Math.max(Math.abs(d[2]),Math.abs(g[2]))),f.normalized){const p=pc(Us[f.componentType]);l.multiplyScalar(p)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}s.boundingBox=i;const o=new C.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,s.boundingSphere=o}function zd(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=uc[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 C.ColorManagement.workingColorSpace!==C.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${C.ColorManagement.workingColorSpace}" not supported.`),In(s,e),VM(s,e,t),Promise.all(i).then(function(){return e.targets!==void 0?UM(s,e.targets,t):s})}var gt=(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))(gt||{});const GM=8,Vd=24,WM=24,HM=64,XM=60;function jM(){return new URL("draco/",document.baseURI).toString()}function Gd(){return new Promise(s=>{if(typeof requestAnimationFrame=="function"){requestAnimationFrame(()=>s());return}setTimeout(s,16)})}function YM(){const s=navigator?.scheduling;return typeof s?.isInputPending=="function"?s.isInputPending():!1}function qM(s){return s?.engineStatus?.isFree===!1||YM()}async function ei(s,e,t){if(e)return t;const n=performance.now();return qM(s)||n-t>=GM?(await Gd(),performance.now()):t}function $M(s){return new Promise((e,t)=>{pr(s,n=>{if(n==null){t(new Error(`[loadLightModel] empty zip json: ${s}`));return}e(n)},()=>{t(new Error(`[loadLightModel] failed to load zip json: ${s}`))})})}function KM(s){return mt({method:"get",responseType:"arraybuffer",url:s}).then(e=>Xu.loadAsync(e.data))}function Wd(s){return s.replace(/\\/g,"/").replace(/^\/+/,"")}function Hd(s,e){const t=new Set(e.map(n=>Wd(n)));for(const n of Object.keys(s.files))if(t.has(Wd(n)))return s.files[n];return null}function Xd(s,e){const t=Hd(s,e);return t==null||t.dir?Promise.resolve(null):t.async("string")}function ZM(s){return s.charCodeAt(0)===65279?s.slice(1):s}function mc(s){return JSON.parse(ZM(s))}function JM(s,e){const t=Hd(s,e);return t==null||t.dir?Promise.resolve(null):t.async("arraybuffer")}function QM(s){return new Promise((e,t)=>{new lM().parse(s,document.baseURI,e,t)})}function Bo(s,e){return s.models.find(t=>t.url==e)}function jd(s){s.loadStatus==null&&(s.loadStatus={}),s.loadStatus.modelMep==null&&(s.loadStatus.modelMep=!1),s.loadStatus.normal==null&&(s.loadStatus.normal=!1)}function eb(s){return jd(s),s.status==="loaded"&&s.loadStatus.normal===!0&&s.loadStatus.modelMep===!0}function Yd(s){const e=s?.engineStatus?.models;!Array.isArray(e)||e.length===0||!e.every(n=>eb(n))||s.__loadingCompletedTriggered===!0||(s.__loadingCompletedTriggered=!0,s.events?.trigger?.(gt.LoadingCompleted,{}))}function qd(s){return s===!0||s==="loading"}function $d(s){return s.index!=null?s.index.count:s.attributes.position?.count??0}async function tb(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)%WM===0&&(n=await ei(s,t,n))}}async function nb(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 ei(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 ei(s,t,r)}return n}async function ib(s,e,t,n){const i=Bo(s,e.url);if(i?.nodesMap==null)return[];const r=await nb(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 f of u){const d=t.glbs?.[f.glb]?.[f.mesh];if(d?.geometry==null||d.material==null)continue;const g=new b.Matrix4;g.elements=f.matrix;const p=d.geometry.clone();p.applyMatrix4(g),p.computeBoundingBox();const m=new b.Mesh(p,d.material);f.box=p.boundingBox?.clone(),f.mesh=m,m.name=Number(c),m.glb=f.glb,m.url=e.url,p.attributes.position!=null&&o.push(m),l++,l%Vd===0&&(a=await ei(s,n,a))}}return o}function sb(s,e,t,n,i){const r=$i(n.map(a=>a.geometry),!1),o=new b.Mesh(r,i);return o.castShadow=!0,o.receiveShadow=!0,e.scene.add(o),o.index=e.scene.children.length-1,o.url=s,o.glb=t,o.materialClone=i,o.geometrys=n.map(a=>a.geometry),o.geometry.computeVertexNormals(),o}function rb(s,e,t,n){return s.scene.children.find(i=>{const r=i;return i instanceof b.Mesh&&r.url==e&&r.glb==t&&r.materialClone===n})}function ob(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 ab(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=Bo(e,s);let o=performance.now();for(const[a,l]of i.entries()){const c=n?l.length:XM;for(let h=0;h<l.length;h+=c){const u=l.slice(h,h+c);if(u.length===0)continue;const f=xb(u[0].material,e);let d=rb(e,s,a,f),g=0,p=0;d=null,d!=null?(g=Array.isArray(d.geometrys)?d.geometrys.length:0,p=$d(d.geometry),ob(d,u)):d=sb(s,e,a,u,f);const m=new Map;let x=p;u.forEach((_,v)=>{const y=Number(_.name),M=$d(_.geometry),S=m.get(y)??[];if(S.push([x,x+M]),m.set(y,S),r?.nodesMap?.has(y)){const E=r.nodesMap.get(y);E.indexes==null&&(E.indexes=[]),E.indexes.push([d.index,g+v,x,x+M])}x+=M}),d.indexes==null&&(d.indexes=new Map),m.forEach((_,v)=>{const y=d.indexes.get(v)??[];y.push(..._),d.indexes.set(v,y)}),o=await ei(e,n,o)}}}async function lb(s,e,t,n,i,r){if(n==null||i==null||i.length===0)return;const o=Bo(t,s);if(o==null)return;const a=new b.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(a);const l=new Float32Array(i.length*3);for(let u=0;u<i.length;u++)l[u*3]=1,l[u*3+1]=1,l[u*3+2]=1;a.instanceColor=new b.InstancedBufferAttribute(l,3);let c=performance.now();const h=[];for(let u=0;u<i.length;u++){const f=i[u],d=new b.Matrix4;if(d.elements=f.matrix,a.setMatrixAt(u,d),a.matrixs||(a.matrixs=[]),a.matrixs.push(d.clone()),h.push(d.clone()),o.nodesMap.has(f.id)){const g=o.nodesMap.get(f.id);g.indexes==null&&(g.indexes=[]),g.indexes.push([t.scene.children.length-1,u,0,0])}else o.nodesMap.set(f.id,{instance:!0,info:f,indexes:[[t.scene.children.length-1,u,0,0]]});(u+1)%HM===0&&(c=await ei(t,r,c))}a.instanceMatrix.needsUpdate=!0,a.instanceColor!=null&&(a.instanceColor.needsUpdate=!0),a.index=t.scene.children.length-1,a.materialClone=n.material,a.url=s,a.glb=n.glb,a.ids=i.map(u=>u.id),a.matrixsClone=h,a.meshIndex=e}async function cb(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 lb(s.url,a.mesh,t,l,a.children,n)}r=await ei(t,n,r)}}async function hb(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 ib(s,e,t,n);await ab(e.url,s,i,n),await cb(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 ub(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 KM(e.url+t.path),r=await Xd(i,["/nodes.json","nodes.json"]);if(r==null)return;const o=mc(r),a=Bo(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 d=0;d<u.length;d++){const g=u[d];g.glb=h,a.nodesMap.has(g.id)===!1?a.nodesMap.set(g.id,{infos:[g]}):a.nodesMap.get(g.id).infos.push(g),(d+1)%Vd===0&&(l=await ei(s,n,l))}const f=await JM(i,[`/${h}.glb`,`${h}.glb`,h+".glb"]);if(f==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 d=await QM(f);t.glbs[h]=d.scene.children,await tb(s,t.glbs[h],n)}catch(d){console.error("[loadLightModel] failed to load glb",{modelUrl:e.url,lodPath:t.path,glbKey:`${h}.glb`,dracoDecoderPath:jM(),error:d})}l=await ei(s,n,l)}const c=await Xd(i,["/instances.json","instances.json"]);t.instanceNodes=c!=null?mc(c):null,t.loadSuccess=!0})().finally(()=>{t.preparePromise=null}),await t.preparePromise}}function db(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;e.getWorldDirection(c),s.camera.matrixWorld.extractBasis(l,c,new b.Vector3);const h=o.clone().add(c.setLength(-a)),u=h.clone().add(l.setLength(t.maxSize)),f=new it(s.camera,s.renderer,s.scene).worldToScreen(h),d=new it(s.camera,s.renderer,s.scene).worldToScreen(u);return f.distanceTo(d)}async function fb(s,e,t,n){t.maxSize<1e6&&t.path!="/lod0"&&(!(db(s,s.camera,t)>=20)||t.status===!0)||(await ub(s,e,t,n),t.loadSuccess===!0&&await hb(s,e,t,n))}function pb(s,e,t){if(qd(e.loadStatus.modelMep))return;e.loadStatus.modelMep="loading",e.info.modelMep==null&&(e.info.modelMep={}),(async()=>{t||await Gd(),oM(s,e.info.modelMep,e.url),e.loadStatus.modelMep=!0,Yd(s)})().catch(i=>{e.loadStatus.modelMep=!1,console.error("[loadLightModel] failed to load mep model",i)})}function mb(s,e,t,n){const i=new b.Group;i.name=e,s.scene.add(i),s.models||(s.models=[]),window.startTime=Date.now(),$M(e+"/info").then(r=>{const o=mc(r);s.__loadingCompletedTriggered=!1,s.engineStatus.models.push({type:"light",info:o,name:o.baseInfo.name,status:"loading",url:e,elements:new Map,loadStatus:{modelMep:!1,normal:!1}}),s.models.push({url:e,nodesMap:new Map,grids:o.modelGrid,levels:o.modelLevel,rooms:o.modelRoom,views:o.modelView,boundingBox:{min:new b.Vector3(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new b.Vector3(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),s.models.length==n&&(s.viewCube.CameraGoHome(1),setTimeout(()=>{Kd(s,null,!1)},100))}).catch(r=>{console.error("[loadLightModel] failed to load model info",{url:e,error:r})})}async function Kd(s,e,t=!1){const n=s.engineStatus.models.filter(i=>e==null||i.url==e);for(const i of n)if(jd(i),!(i.status!=="loading"||i.type!=="light")&&(pb(s,i,t),!qd(i.loadStatus.normal))){i.loadStatus.normal="loading";try{await gb(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"),Yd(s)}}}async function gb(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 fb(s,e,n,t)}function xb(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 _b{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&mb(this.engine,i,t,e.length);function n(i){const r=i.split(".").pop();return r==="glb"||r==="gltf"?"gltf":"light"}}}var Fs=(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))(Fs||{});class vb{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(Fs.EngineFree,e=>{this.updateFree(!0),Kd(this.engine,e,!1)}),this.engine.events.on(Fs.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let yb=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)}})}};class Mb{engine;constructor(e){this.engine=e}init(){const e=new b.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new b.AmbientLight(16777215,2);this.engine.scene.add(i)}}class bb{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()}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))}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}}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.suppressClickOnce=!0)}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,f=this.engine.models.find(p=>p.url==c.url)?.nodesMap?.get(h),d=new Map;f?.indexes.forEach(p=>{this.getSceneModel(p[0])instanceof b.InstancedMesh&&(d.has(p[0])||d.set(p[0],[]),d.get(p[0])?.push(p[1]))});const g=[];return d.forEach((p,m)=>{const x=this.getSceneModel(m);p.forEach(_=>{const v=x.geometry.clone();v.applyMatrix4(x.matrixs[_]),g.push(new b.Mesh(v,x.material))})}),this.hoverOldId==h?[]:(this.hoverOldId=h,t||this.engine.hoverHighLight.clearHighlight(),g)}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&&!this.isCtrlDown)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(gt.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.viewCube.CameraGoHome(500);return}const t=e.catch,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 f=this.getSceneModel(u[0]);f?.geometry?.boundingSphere||f?.geometry?.computeBoundingSphere?.();const d=f?.geometry?.boundingSphere;if(!d)return;const g=new b.Box3,p=d.center.clone().applyMatrix4(l),m=d.radius,x=new b.Vector3().setFromMatrixScale(l),_=m*Math.max(x.x,x.y,x.z);g.min.set(p.x-_,p.y-_,p.z-_),g.max.set(p.x+_,p.y+_,p.z+_),c.push(g)});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(this.engine.scene.children.filter(t=>t instanceof b.InstancedMesh),!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)}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;return this.engine.models?.forEach(i=>{!i?.url||!i?.nodesMap||i.nodesMap.forEach((r,o)=>{const a=this.getNodeWorldBox(r),l=this.projectBoxToScreenRect(a);l==null||!(t?this.containsRect(e,l):this.intersectsRect(e,l))||(n.has(i.url)||n.set(i.url,new Set),n.get(i.url)?.add(o))})}),Array.from(n.entries()).map(([i,r])=>({url:i,ids:Array.from(r)}))}applyBoxSelection(e){const t=this.excludeHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.highlightModel(t),this.engine.events.trigger(gt.SelectionChanged,t))}applyBoxDeselection(e){const t=this.keepHighlightedModels(e);t.length!==0&&(this.engine.modelToolModule.unhighlightModel(t),this.removeModelsFromHighlightState(t),this.engine.events.trigger(gt.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 it(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 this.engine.scene.children.find(t=>t.index===e)??this.engine.scene.children[e]}}class Sb{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),this.hideMaterial=new b.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof b.InstancedMesh)return;let t=e.materialClone.clone(),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){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.getSceneModel(a[0]).materialClone.color),this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),wb(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof b.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),Zd(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.hideModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Eb(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);this.engine.modelEdge.showModelEdge(t.url,r),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Jd(n,this.engine);let i=this.engine.engineStatus.hideModels.find(r=>r.url==t.url);i&&(t.ids.forEach(r=>{const o=i.ids.indexOf(r);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(r=>r!==i)))})}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)});debugger;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){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(r=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(r);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),Ab(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(r=>r.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let r=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);r!=null&&r.indexes!=null&&r.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof b.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&Jd(n,this.engine),Zd(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function wb(s,e){s.forEach((t,n)=>{const i=gr(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}),a=new b.InstancedMesh(r,o,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((u,f)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(f,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Zd(s,e,t){s.forEach((n,i)=>{const r=gr(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,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function Ab(s,e){s.forEach((t,n)=>{const i=gr(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}),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,f)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(f,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Eb(s,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),s.forEach((t,n)=>{const i=gr(e,n);if(!(i instanceof b.InstancedMesh))return;const r=new Map,o=new b.Matrix4,a=new b.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,o),r.set(l,o.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Jd(s,e){s.forEach((t,n)=>{const i=gr(e,n);i instanceof b.InstancedMesh&&(t.forEach(r=>{const o=i.matrixs[r];o&&i.setMatrixAt(r,o)}),i.instanceMatrix.needsUpdate=!0)})}function gr(s,e){return s.scene.children.find(t=>t.index==e)}class Tb{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){debugger;this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof 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 zo{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/zo.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/zo.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Vo={exports:{}},Cb=Vo.exports,Qd;function Pb(){return Qd||(Qd=1,(function(s,e){(function(t,n){s.exports=n()})(Cb,function(){var t=function(){function n(d){return o.appendChild(d.dom),d}function i(d){for(var g=0;g<o.children.length;g++)o.children[g].style.display=g===d?"block":"none";r=d}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(d){d.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 f=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 d=(performance||Date).now();if(u.update(d-a,200),d>l+1e3&&(h.update(1e3*c/(d-l),100),l=d,c=0,f)){var g=performance.memory;f.update(g.usedJSHeapSize/1048576,g.jsHeapSizeLimit/1048576)}return d},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,f=3*c,d=2*c,g=3*c,p=15*c,m=74*c,x=30*c,_=document.createElement("canvas");_.width=h,_.height=u,_.style.cssText="width:80px;height:48px";var v=_.getContext("2d");return v.font="bold "+9*c+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=r,v.fillRect(0,0,h,u),v.fillStyle=i,v.fillText(n,f,d),v.fillRect(g,p,m,x),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(g,p,m,x),{dom:_,update:function(y,M){o=Math.min(o,y),a=Math.max(a,y),v.fillStyle=r,v.globalAlpha=1,v.fillRect(0,0,h,p),v.fillStyle=i,v.fillText(l(y)+" "+n+" ("+l(o)+"-"+l(a)+")",f,d),v.drawImage(_,g+c,p,m-c,x,g,p,m-c,x),v.fillRect(g+m-c,p,c,x),v.fillStyle=r,v.globalAlpha=.9,v.fillRect(g+m-c,p,c,l((1-y/M)*x))}}},t})})(Vo)),Vo.exports}var Db=Pb();const Rb=Wu(Db);var Os=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-Os.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?Os.Bounce.In(s*2)*.5:Os.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}}}}),xr=function(){return performance.now()},Lb=(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=xr()),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})(),gc={Linear:function(s,e){var t=s.length-1,n=t*e,i=Math.floor(n),r=gc.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}}},ef=(function(){function s(){}return s.nextId=function(){return s._nextId++},s._nextId=0,s})(),xc=new Lb,Ib=(function(){function s(e,t){t===void 0&&(t=xc),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=Os.Linear.None,this._interpolationFunction=gc.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=ef.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=xr()),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 f=[a],d=0,g=u.length;d<g;d+=1){var p=this._handleRelativeValue(a,u[d]);if(isNaN(p)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}f.push(p)}h&&(n[o]=f)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var m=a;for(var x in m)t[o][x]=m[x];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var _={};for(var x in u)_[x]=u[x];n[o]=u=_}this._setupProperties(m,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=xr()),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=xr()),!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=xc),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=Os.Linear.None),this._easingFunction=e,this},s.prototype.interpolation=function(e){return e===void 0&&(e=gc.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=xr()),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 m=Math.trunc(a/l),x=a-m*l,_=Math.min(x/n._duration,1);return _===0&&a===n._duration?1:_},u=h(),f=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,f),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var d=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=d);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*d,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var g=0,p=this._chainedTweens.length;g<p;g++)this._chainedTweens[g].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})();ef.nextId;var Nn=xc;Nn.getAll.bind(Nn),Nn.removeAll.bind(Nn),Nn.add.bind(Nn),Nn.remove.bind(Nn),Nn.update.bind(Nn);var _r={Easing:Os,Tween:Ib};const tf={type:"change"},_c={type:"start"},nf={type:"end"},Go=new C.Ray,sf=new C.Plane,Nb=Math.cos(70*C.MathUtils.DEG2RAD),Dt=new C.Vector3,Kt=2*Math.PI,lt={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},vc=1e-6;class Ub extends C.Controls{constructor(e,t=null){super(e,t),this.state=lt.NONE,this.target=new C.Vector3,this.cursor=new C.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:C.MOUSE.ROTATE,MIDDLE:C.MOUSE.DOLLY,RIGHT:C.MOUSE.PAN},this.touches={ONE:C.TOUCH.ROTATE,TWO:C.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._cursorStyle="auto",this._domElementKeyEvents=null,this._lastPosition=new C.Vector3,this._lastQuaternion=new C.Quaternion,this._lastTargetPosition=new C.Vector3,this._quat=new C.Quaternion().setFromUnitVectors(e.up,new C.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new C.Spherical,this._sphericalDelta=new C.Spherical,this._scale=1,this._panOffset=new C.Vector3,this._rotateStart=new C.Vector2,this._rotateEnd=new C.Vector2,this._rotateDelta=new C.Vector2,this._panStart=new C.Vector2,this._panEnd=new C.Vector2,this._panDelta=new C.Vector2,this._dollyStart=new C.Vector2,this._dollyEnd=new C.Vector2,this._dollyDelta=new C.Vector2,this._dollyDirection=new C.Vector3,this._mouse=new C.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ob.bind(this),this._onPointerDown=Fb.bind(this),this._onPointerUp=kb.bind(this),this._onContextMenu=Xb.bind(this),this._onMouseWheel=Vb.bind(this),this._onKeyDown=Gb.bind(this),this._onTouchStart=Wb.bind(this),this._onTouchMove=Hb.bind(this),this._onMouseDown=Bb.bind(this),this._onMouseMove=zb.bind(this),this._interceptControlDown=jb.bind(this),this._interceptControlUp=Yb.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}set cursorStyle(e){this._cursorStyle=e,e==="grab"?this.domElement.style.cursor="grab":this.domElement.style.cursor="auto"}get cursorStyle(){return this._cursorStyle}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(tf),this.update(),this.state=lt.NONE}pan(e,t){this._pan(e,t),this.update()}dollyIn(e){this._dollyIn(e),this.update()}dollyOut(e){this._dollyOut(e),this.update()}rotateLeft(e){this._rotateLeft(e),this.update()}rotateUp(e){this._rotateUp(e),this.update()}update(e=null){const t=this.object.position;Dt.copy(t).sub(this.target),Dt.applyQuaternion(this._quat),this._spherical.setFromVector3(Dt),this.autoRotate&&this.state===lt.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Kt:n>Math.PI&&(n-=Kt),i<-Math.PI?i+=Kt:i>Math.PI&&(i-=Kt),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=o!=this._spherical.radius}if(Dt.setFromSpherical(this._spherical),Dt.applyQuaternion(this._quatInverse),t.copy(this.target).add(Dt),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=Dt.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const a=new C.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new C.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=Dt.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(Go.origin.copy(this.object.position),Go.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Go.direction))<Nb?this.object.lookAt(this.target):(sf.setFromNormalAndCoplanarPoint(this.object.up,this.target),Go.intersectPlane(sf,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),r=!0)}return this._scale=1,this._performCursorZoom=!1,r||this._lastPosition.distanceToSquared(this.object.position)>vc||8*(1-this._lastQuaternion.dot(this.object.quaternion))>vc||this._lastTargetPosition.distanceToSquared(this.target)>vc?(this.dispatchEvent(tf),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Kt/60*this.autoRotateSpeed*e:Kt/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Dt.setFromMatrixColumn(t,0),Dt.multiplyScalar(-e),this._panOffset.add(Dt)}_panUp(e,t){this.screenSpacePanning===!0?Dt.setFromMatrixColumn(t,1):(Dt.setFromMatrixColumn(t,0),Dt.crossVectors(this.object.up,Dt)),Dt.multiplyScalar(e),this._panOffset.add(Dt)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Dt.copy(i).sub(this.target);let r=Dt.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrix),this._panUp(2*t*r/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,r=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(r/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Kt*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),r=.5*(e.pageY+n.y);this._rotateEnd.set(i,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Kt*this._rotateDelta.x/t.clientHeight),this._rotateUp(Kt*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,r=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new C.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Fb(s){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(s.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(s)&&(this._addPointer(s),s.pointerType==="touch"?this._onTouchStart(s):this._onMouseDown(s),this._cursorStyle==="grab"&&(this.domElement.style.cursor="grabbing")))}function Ob(s){this.enabled!==!1&&(s.pointerType==="touch"?this._onTouchMove(s):this._onMouseMove(s))}function kb(s){switch(this._removePointer(s),this._pointers.length){case 0:this.domElement.releasePointerCapture(s.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(nf),this.state=lt.NONE,this._cursorStyle==="grab"&&(this.domElement.style.cursor="grab");break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Bb(s){let e;switch(s.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case C.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(s),this.state=lt.DOLLY;break;case C.MOUSE.ROTATE:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}break;case C.MOUSE.PAN:if(s.ctrlKey||s.metaKey||s.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(s),this.state=lt.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(s),this.state=lt.PAN}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(_c)}function zb(s){switch(this.state){case lt.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(s);break;case lt.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(s);break;case lt.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(s);break}}function Vb(s){this.enabled===!1||this.enableZoom===!1||this.state!==lt.NONE||(s.preventDefault(),this.dispatchEvent(_c),this._handleMouseWheel(this._customWheelEvent(s)),this.dispatchEvent(nf))}function Gb(s){this.enabled!==!1&&this._handleKeyDown(s)}function Wb(s){switch(this._trackPointer(s),this._pointers.length){case 1:switch(this.touches.ONE){case C.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(s),this.state=lt.TOUCH_ROTATE;break;case C.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(s),this.state=lt.TOUCH_PAN;break;default:this.state=lt.NONE}break;case 2:switch(this.touches.TWO){case C.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(s),this.state=lt.TOUCH_DOLLY_PAN;break;case C.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(s),this.state=lt.TOUCH_DOLLY_ROTATE;break;default:this.state=lt.NONE}break;default:this.state=lt.NONE}this.state!==lt.NONE&&this.dispatchEvent(_c)}function Hb(s){switch(this._trackPointer(s),this.state){case lt.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(s),this.update();break;case lt.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(s),this.update();break;case lt.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(s),this.update();break;case lt.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(s),this.update();break;default:this.state=lt.NONE}}function Xb(s){this.enabled!==!1&&s.preventDefault()}function jb(s){s.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Yb(s){s.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class qb extends C.DataTextureLoader{constructor(e){super(e),this.type=C.HalfFloatType}parse(e){const o=function(D,A){switch(D){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(A||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(A||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(A||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(A||""))}},u=function(D,A,T){A=A||1024;let P=D.pos,N=-1,w=0,O="",k=String.fromCharCode.apply(null,new Uint16Array(D.subarray(P,P+128)));for(;0>(N=k.indexOf(`
|
|
4940
4940
|
`))&&w<A&&P<D.byteLength;)O+=k,w+=k.length,P+=128,k+=String.fromCharCode.apply(null,new Uint16Array(D.subarray(P,P+128)));return-1<N?(D.pos+=w+N+1,O+k.slice(0,N)):!1},f=function(D){const A=/^#\?(\S+)/,T=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,I=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,P=/^\s*FORMAT=(\S+)\s*$/,N=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,w={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let O,k;for((D.pos>=D.byteLength||!(O=u(D)))&&o(1,"no header found"),(k=O.match(A))||o(3,"bad initial token"),w.valid|=1,w.programtype=k[1],w.string+=O+`
|
|
4941
4941
|
`;O=u(D),O!==!1;){if(w.string+=O+`
|
|
4942
4942
|
`,O.charAt(0)==="#"){w.comments+=O+`
|
|
@@ -5371,7 +5371,7 @@ ${JSON.stringify(l,null,2)}
|
|
|
5371
5371
|
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
5372
5372
|
<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"/>
|
|
5373
5373
|
<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"/>
|
|
5374
|
-
</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 rp{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 F1(t,this))}_loadLayers(){let 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())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}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)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(r=>{r.name?.startsWith(i)&&(r.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}class op{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new b.Group,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup);this.engine.modelGroup.children.length>0;)this.engine.modelGroup.remove(this.engine.modelGroup.children[0])}async loadModel(e,t={}){if(!e.includes(".json"))this.engine.events&&this.engine.events.trigger(rn.ModelLoadStart,{url:e}),pr(e,async n=>{const i=JSON.parse(n);this.engine.dwgData=i,this.data=i,await this.buildScene(i);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new rp(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(rn.ModelLoaded,{})},n=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(rn.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const n=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const i=this.parseData(n);if(this.engine.dwgData=i,!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(rn.ModelLoaded,{})}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;async loadFont(){const e=this.engine.options?.fontUrl??"/fonts/simfang.ttf",t=await Pr.fromUrl(e);return Pr.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(rn.ModelLoadProgress,{progress:e,text:t})}async buildScene(e){this._emitProgress(10,"正在加载"),this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,this.model.nodeMap=new Map,console.log(this.model.layers),this._emitProgress(10,"正在加载..."),await Promise.resolve(),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.loadBlock({entities:e.entities},"",!1),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(o=>{for(const a of o)i.push(a)}),i.length!=0){const o=new b.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var r=this.model.layers.find(u=>u.name==n.split("||")[0]);a=r.color}const l=new b.LineBasicMaterial({color:a}),c=new b.LineSegments(o,l);c.name=n,c.clonePoints=[],i.forEach(u=>{c.clonePoints.push(u.x),c.clonePoints.push(u.y),c.clonePoints.push(u.z)}),c.materialClone=l.clone(),this.engine.modelGroup.add(c);let h=0;t.forEach((u,f)=>{this.model.nodeMap.has(f)?this.model.nodeMap.get(f).push({indexes:[this.engine.modelGroup.children.length-1,h,h+u.length*3],min:new b.Vector3(Math.min(...u.map(d=>d.x)),Math.min(...u.map(d=>d.y)),0),max:new b.Vector3(Math.max(...u.map(d=>d.x)),Math.max(...u.map(d=>d.y)),0)}):this.model.nodeMap.set(f,[{indexes:[this.engine.modelGroup.children.length-1,h,h+u.length*3],min:new b.Vector3(Math.min(...u.map(d=>d.x)),Math.min(...u.map(d=>d.y)),0),max:new b.Vector3(Math.max(...u.map(d=>d.x)),Math.max(...u.map(d=>d.y)),0)}]),h=h+u.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,n)=>{const i=$i(t.map(c=>c.geometry),!1);let r=Number.parseInt(n.split("||")[1]);if(r===0){const c=this.model.layers.find(h=>h.name===n.split("||")[0]);c&&(r=c.color)}const o=new b.MeshBasicMaterial({color:r,side:b.DoubleSide});n.includes("_hitbox")&&(o.visible=!1);let a=new b.Mesh(i,o);a.name=n,a.materialClone=o.clone(),a.isSplit=!1,a.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(a);let l=0;t.forEach(c=>{this.model.nodeMap.has(c.info.linkId)?this.model.nodeMap.get(c.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,l++],min:new b.Vector3(c.info.min[0],c.info.min[1],0),max:new b.Vector3(c.info.max[0],c.info.max[1],0)}):this.model.nodeMap.set(c.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,l++],min:new b.Vector3(c.info.min[0],c.info.min[1],0),max:new b.Vector3(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,n)=>{let i=$i(t.map(h=>h.geometry),!1),r=parseInt(n.split("||")[1]);if(r==0){var o=this.model.layers.find(h=>h.name==n.split("||")[0]);r=o.color}const a=new b.MeshBasicMaterial({color:r,side:b.DoubleSide,transparent:!0,opacity:.5});let l=new b.Mesh(i,a);l.name=n,l.materialClone=a.clone(),l.isSplit=!1,l.geometrys=t.map(h=>h.geometry),this.engine.modelGroup.add(l);let c=0;t.forEach(h=>{this.model.nodeMap.has(h.info.linkId)?this.model.nodeMap.get(h.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,c++],min:new b.Vector3(h.info.min[0],h.info.min[1],0),max:new b.Vector3(h.info.max[0],h.info.max[1],0)}):this.model.nodeMap.set(h.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,c++],min:new b.Vector3(h.info.min[0],h.info.min[1],0),max:new b.Vector3(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,n,i=0){let r=[0,0,0];n&&(r=e.origin),e.entities.forEach(o=>{const a=o.layer+"||"+o.color;let l=new Map;n?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(a),l==null&&(l=new Map,this.model.modelMap.set(a,l)));let c=[];switch(o.type){case"LINE":c=this.getPoint_line(o,r);break;case"CIRCLE":c=this.getPoint_arc(o,r);break;case"POLYLINE":c=this.getPoint_polyline(o,r);break;case"MTEXT":this.create_text(o);break;case"HATCH":this.create_hatch(o);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(o.blockId);h?.forEach(f=>{c.push(...f.map(d=>d.clone()))});const u=this.getMatrix(o.position,o.scale,o.rotation);c.forEach(f=>{f.applyMatrix4(u)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${o.type}`),null}l.has(o.linkId)?l.get(o.linkId).push(...c):l.set(o.linkId,c)})}getPoint_polyline(e,t){let n=[];for(let i=0;i<e.points.length-1;i++)n.push(new b.Vector3(e.points[i].x,e.points[i].y,0)),n.push(new b.Vector3(e.points[i+1].x,e.points[i+1].y,0));return e.closed&&(n.push(new b.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),n.push(new b.Vector3(e.points[0].x,e.points[0].y,0))),n.forEach(i=>{i[0]=i[0]-t[0],i[1]=i[1]-t[1]}),n}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(a=>a.type===!0),n=e.loops.filter(a=>a.type===!1),i=[];for(const a of t){if(!a.points||a.points.length<3)continue;const l=new b.Shape;l.moveTo(a.points[0][0],a.points[0][1]);for(let c=1;c<a.points.length;c++)l.lineTo(a.points[c][0],a.points[c][1]);l.closePath();for(const c of n){if(!c.points||c.points.length<3)continue;const h=new b.Path;h.moveTo(c.points[0][0],c.points[0][1]);for(let u=1;u<c.points.length;u++)h.lineTo(c.points[u][0],c.points[u][1]);h.closePath(),l.holes.push(h)}i.push(new b.ShapeGeometry(l))}if(i.length===0)return;const r=i.length===1?i[0]:$i(i,!1),o=e.layer+"||"+e.color;this.model.hatchMap.has(o)?this.model.hatchMap.get(o).push({geometry:r,info:e}):this.model.hatchMap.set(o,[{geometry:r,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new R1(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}]),t.computeBoundingBox();const r=t.boundingBox;if(r){const o=r.max.x-r.min.x,a=r.max.y-r.min.y,l=new b.PlaneGeometry(o,a);new b.MeshBasicMaterial({visible:!1,side:b.DoubleSide,depthWrite:!1});let c=[(r.min.x+r.max.x)/2,(r.min.y+r.max.y)/2,0],h=this.getMatrix(c,[1,1,1],0);l.applyMatrix4(h);const u=e.layer+"||"+e.color+"_hitbox";this.model.textMap.has(u)?this.model.textMap.get(u).push({geometry:l,info:e}):this.model.textMap.set(u,[{geometry:l,info:e}])}}getPoint_line(e,t){const n=new b.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),i=new b.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let r=[n,i];return r.forEach(o=>{o[0]=o[0]-t[0],o[1]=o[1]-t[1]}),r}getPoint_arc(e,t){const n=e.center[0],i=e.center[1],r=e.radius,a=new b.EllipseCurve(n,i,r,r,e.startAngle,e.endAngle,!1,0).getPoints(30).map(c=>new b.Vector3(c.x,c.y,0));let l=[];for(let c=0;c<a.length-1;c++)l.push(a[c].clone()),l.push(a[c+1].clone());return l.forEach(c=>{c[0]=c[0]-t[0],c[1]=c[1]-t[1]}),l}getMatrix(e,t,n){const i=new b.Vector3(e[0],e[1],e[2]),r=new b.Euler(0,0,n),o=new b.Vector3(t[0],t[1],t[2]),a=new b.Quaternion;a.setFromEuler(r);const l=new b.Matrix4;return l.compose(i,a,o),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class O1{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new op(this.engine)}async attachSectionPlane(e,t,n,i){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let r=new b.Vector3(n.x,n.y,n.z),o=new b.Vector3(i.x,i.y,i.z);const a=new b.Vector3().copy(o);let l=r.clone().sub(this.engine.modelGroup.position.clone()).dot(o);this.engine.modelGroup.lookAt(a);let c=this.engine.modelGroup.position.clone().add(o.setLength(l));this.engine.modelGroup.position.set(c.x,c.y,c.z),console.log("绘制完成")}removeSectionPlane(){this.engine.scene.remove(this.engine.modelGroup)}getMatrix(e,t){const n=new b.Vector3(e.x,e.y,e.z),i=new b.Euler(t.x,t.y,t.z),r=new b.Vector3(1,1,1),o=new b.Quaternion;o.setFromEuler(i);const a=new b.Matrix4;return a.compose(n,o,r),a}computeMatrixFromOriginAndDirection(e,t){const n=new b.Matrix4,i=t.clone().normalize();if(i.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),n.identity();const r=new b.Vector3(0,1,0);let o=new b.Vector3().crossVectors(r,i);if(o.length()<1e-4){const c=new b.Vector3(0,0,1);o=new b.Vector3().crossVectors(c,i).normalize()}else o.normalize();const a=new b.Vector3().crossVectors(o,i).normalize(),l=new b.Matrix4;return l.set(o.x,i.x,a.x,0,o.y,i.y,a.y,0,o.z,i.z,a.z,0,0,0,0,1),l.setPosition(e),l}}class k1{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=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;models=[];reactBoundingClientRect={left:0,top:0};version="3.4.6";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 Tb(this),this.engineModelModule.init(),this.ai=new u1(this),this.deviceModule=new wp(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new ci(this),this.sceneModule=new Sp(this),this.scene=this.sceneModule.scene,this.renderModule=new tv(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 Mv(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new s1(this),this.clipping.init(),this.composerModule=new Nv(this),this.composerModule.init(),this.events=new yb,this.engineStatus=new vb(this),this.engineStatus.init(),this.loaderModule=new _b(this),this.lightModule=new Mb(this),this.lightModule.init(),this.viewCube=new Jb(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Qb(this),this.rangeScale=new eS(this),this.rangeScale.init(),this.setting=new tS(this),this.engineModelModule.init(),this.handelBehaved=Kl(this),this.modelMapperBatch=new l1(this),this.measure=new hS(this),this.modelToolModule=new Sb(this),this.modelProperties=new a1(this),this.interactionModule=new bb(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new zo(this),this.modelEdge=new c1(this),this.modelTree=new r1(this),this.viewTree=new P1(this),this.merge2d=new O1(this),this.engineInfo=new o1(this),this.pathRoaming=new d1(this),this.pathRoaming.init(),this.oneClickEncoding=new C1(this),this.minMap=new f1(this),this.linkElement2d3d=new E1(this),this.linkView2d3d=new T1(this),this.grid=new g1(this),this.level=new v1(this),this.issueReport=new y1(this),this.text=new M1(this),this.hdr=new b1(this),this.ground=new rh(this),this.ground.init(),this.skyManager=new A1(this),this.setting.init(),this.worldToScreen=new it(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Rb,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(Fs.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.renderer&&(i.renderer.interactionActive=!1),i.events.trigger(Fs.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.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)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,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){const n=new b.Vector3;e.getWorldDirection(n);const i=100,r=new b.Vector3().copy(n).multiplyScalar(-i),o=new b.Vector3(0,1,0),a=new b.Vector3().crossVectors(n,o).normalize();r.addScaledVector(o,i*.5),r.addScaledVector(a,i*.3),t.position.copy(e.position).add(r);const l=new b.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,r=this.cameraModule.getOrthographicVisibleHeight(i);this.cameraModule.setOrthographicVisibleHeight(r,i),i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${r}`)}this.events&&this.events.trigger(Fs.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof b.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof 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)}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 B1=`
|
|
5374
|
+
</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 rp{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 F1(t,this))}_loadLayers(){let 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())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}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)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(r=>{r.name?.startsWith(i)&&(r.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}class op{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new b.Group,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup);this.engine.modelGroup.children.length>0;)this.engine.modelGroup.remove(this.engine.modelGroup.children[0])}async loadModel(e,t={}){if(!e.includes(".json"))this.engine.events&&this.engine.events.trigger(rn.ModelLoadStart,{url:e}),pr(e,async n=>{const i=JSON.parse(n);this.engine.dwgData=i,this.data=i,await this.buildScene(i);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new rp(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(rn.ModelLoaded,{})},n=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(rn.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const n=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const i=this.parseData(n);if(this.engine.dwgData=i,!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(rn.ModelLoaded,{})}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;async loadFont(){const e=this.engine.options?.fontUrl??"/fonts/simfang.ttf",t=await Pr.fromUrl(e);return Pr.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(rn.ModelLoadProgress,{progress:e,text:t})}async buildScene(e){this._emitProgress(10,"正在加载"),this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,this.model.nodeMap=new Map,console.log(this.model.layers),this._emitProgress(10,"正在加载..."),await Promise.resolve(),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.loadBlock({entities:e.entities},"",!1),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(o=>{for(const a of o)i.push(a)}),i.length!=0){const o=new b.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var r=this.model.layers.find(u=>u.name==n.split("||")[0]);a=r.color}const l=new b.LineBasicMaterial({color:a}),c=new b.LineSegments(o,l);c.name=n,c.clonePoints=[],i.forEach(u=>{c.clonePoints.push(u.x),c.clonePoints.push(u.y),c.clonePoints.push(u.z)}),c.materialClone=l.clone(),this.engine.modelGroup.add(c);let h=0;t.forEach((u,f)=>{this.model.nodeMap.has(f)?this.model.nodeMap.get(f).push({indexes:[this.engine.modelGroup.children.length-1,h,h+u.length*3],min:new b.Vector3(Math.min(...u.map(d=>d.x)),Math.min(...u.map(d=>d.y)),0),max:new b.Vector3(Math.max(...u.map(d=>d.x)),Math.max(...u.map(d=>d.y)),0)}):this.model.nodeMap.set(f,[{indexes:[this.engine.modelGroup.children.length-1,h,h+u.length*3],min:new b.Vector3(Math.min(...u.map(d=>d.x)),Math.min(...u.map(d=>d.y)),0),max:new b.Vector3(Math.max(...u.map(d=>d.x)),Math.max(...u.map(d=>d.y)),0)}]),h=h+u.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,n)=>{const i=$i(t.map(c=>c.geometry),!1);let r=Number.parseInt(n.split("||")[1]);if(r===0){const c=this.model.layers.find(h=>h.name===n.split("||")[0]);c&&(r=c.color)}const o=new b.MeshBasicMaterial({color:r,side:b.DoubleSide});n.includes("_hitbox")&&(o.visible=!1);let a=new b.Mesh(i,o);a.name=n,a.materialClone=o.clone(),a.isSplit=!1,a.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(a);let l=0;t.forEach(c=>{this.model.nodeMap.has(c.info.linkId)?this.model.nodeMap.get(c.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,l++],min:new b.Vector3(c.info.min[0],c.info.min[1],0),max:new b.Vector3(c.info.max[0],c.info.max[1],0)}):this.model.nodeMap.set(c.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,l++],min:new b.Vector3(c.info.min[0],c.info.min[1],0),max:new b.Vector3(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,n)=>{let i=$i(t.map(h=>h.geometry),!1),r=parseInt(n.split("||")[1]);if(r==0){var o=this.model.layers.find(h=>h.name==n.split("||")[0]);r=o.color}const a=new b.MeshBasicMaterial({color:r,side:b.DoubleSide,transparent:!0,opacity:.5});let l=new b.Mesh(i,a);l.name=n,l.materialClone=a.clone(),l.isSplit=!1,l.geometrys=t.map(h=>h.geometry),this.engine.modelGroup.add(l);let c=0;t.forEach(h=>{this.model.nodeMap.has(h.info.linkId)?this.model.nodeMap.get(h.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,c++],min:new b.Vector3(h.info.min[0],h.info.min[1],0),max:new b.Vector3(h.info.max[0],h.info.max[1],0)}):this.model.nodeMap.set(h.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,c++],min:new b.Vector3(h.info.min[0],h.info.min[1],0),max:new b.Vector3(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,n,i=0){let r=[0,0,0];n&&(r=e.origin),e.entities.forEach(o=>{const a=o.layer+"||"+o.color;let l=new Map;n?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(a),l==null&&(l=new Map,this.model.modelMap.set(a,l)));let c=[];switch(o.type){case"LINE":c=this.getPoint_line(o,r);break;case"CIRCLE":c=this.getPoint_arc(o,r);break;case"POLYLINE":c=this.getPoint_polyline(o,r);break;case"MTEXT":this.create_text(o);break;case"HATCH":this.create_hatch(o);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(o.blockId);h?.forEach(f=>{c.push(...f.map(d=>d.clone()))});const u=this.getMatrix(o.position,o.scale,o.rotation);c.forEach(f=>{f.applyMatrix4(u)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${o.type}`),null}l.has(o.linkId)?l.get(o.linkId).push(...c):l.set(o.linkId,c)})}getPoint_polyline(e,t){let n=[];for(let i=0;i<e.points.length-1;i++)n.push(new b.Vector3(e.points[i].x,e.points[i].y,0)),n.push(new b.Vector3(e.points[i+1].x,e.points[i+1].y,0));return e.closed&&(n.push(new b.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),n.push(new b.Vector3(e.points[0].x,e.points[0].y,0))),n.forEach(i=>{i[0]=i[0]-t[0],i[1]=i[1]-t[1]}),n}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(a=>a.type===!0),n=e.loops.filter(a=>a.type===!1),i=[];for(const a of t){if(!a.points||a.points.length<3)continue;const l=new b.Shape;l.moveTo(a.points[0][0],a.points[0][1]);for(let c=1;c<a.points.length;c++)l.lineTo(a.points[c][0],a.points[c][1]);l.closePath();for(const c of n){if(!c.points||c.points.length<3)continue;const h=new b.Path;h.moveTo(c.points[0][0],c.points[0][1]);for(let u=1;u<c.points.length;u++)h.lineTo(c.points[u][0],c.points[u][1]);h.closePath(),l.holes.push(h)}i.push(new b.ShapeGeometry(l))}if(i.length===0)return;const r=i.length===1?i[0]:$i(i,!1),o=e.layer+"||"+e.color;this.model.hatchMap.has(o)?this.model.hatchMap.get(o).push({geometry:r,info:e}):this.model.hatchMap.set(o,[{geometry:r,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new R1(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}]),t.computeBoundingBox();const r=t.boundingBox;if(r){const o=r.max.x-r.min.x,a=r.max.y-r.min.y,l=new b.PlaneGeometry(o,a);new b.MeshBasicMaterial({visible:!1,side:b.DoubleSide,depthWrite:!1});let c=[(r.min.x+r.max.x)/2,(r.min.y+r.max.y)/2,0],h=this.getMatrix(c,[1,1,1],0);l.applyMatrix4(h);const u=e.layer+"||"+e.color+"_hitbox";this.model.textMap.has(u)?this.model.textMap.get(u).push({geometry:l,info:e}):this.model.textMap.set(u,[{geometry:l,info:e}])}}getPoint_line(e,t){const n=new b.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),i=new b.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let r=[n,i];return r.forEach(o=>{o[0]=o[0]-t[0],o[1]=o[1]-t[1]}),r}getPoint_arc(e,t){const n=e.center[0],i=e.center[1],r=e.radius,a=new b.EllipseCurve(n,i,r,r,e.startAngle,e.endAngle,!1,0).getPoints(30).map(c=>new b.Vector3(c.x,c.y,0));let l=[];for(let c=0;c<a.length-1;c++)l.push(a[c].clone()),l.push(a[c+1].clone());return l.forEach(c=>{c[0]=c[0]-t[0],c[1]=c[1]-t[1]}),l}getMatrix(e,t,n){const i=new b.Vector3(e[0],e[1],e[2]),r=new b.Euler(0,0,n),o=new b.Vector3(t[0],t[1],t[2]),a=new b.Quaternion;a.setFromEuler(r);const l=new b.Matrix4;return l.compose(i,a,o),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class O1{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new op(this.engine)}async attachSectionPlane(e,t,n,i){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let r=new b.Vector3(n.x,n.y,n.z),o=new b.Vector3(i.x,i.y,i.z);const a=new b.Vector3().copy(o);let l=r.clone().sub(this.engine.modelGroup.position.clone()).dot(o);this.engine.modelGroup.lookAt(a);let c=this.engine.modelGroup.position.clone().add(o.setLength(l));this.engine.modelGroup.position.set(c.x,c.y,c.z),console.log("绘制完成")}removeSectionPlane(){this.engine.scene.remove(this.engine.modelGroup)}getMatrix(e,t){const n=new b.Vector3(e.x,e.y,e.z),i=new b.Euler(t.x,t.y,t.z),r=new b.Vector3(1,1,1),o=new b.Quaternion;o.setFromEuler(i);const a=new b.Matrix4;return a.compose(n,o,r),a}computeMatrixFromOriginAndDirection(e,t){const n=new b.Matrix4,i=t.clone().normalize();if(i.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),n.identity();const r=new b.Vector3(0,1,0);let o=new b.Vector3().crossVectors(r,i);if(o.length()<1e-4){const c=new b.Vector3(0,0,1);o=new b.Vector3().crossVectors(c,i).normalize()}else o.normalize();const a=new b.Vector3().crossVectors(o,i).normalize(),l=new b.Matrix4;return l.set(o.x,i.x,a.x,0,o.y,i.y,a.y,0,o.z,i.z,a.z,0,0,0,0,1),l.setPosition(e),l}}class k1{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=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;models=[];reactBoundingClientRect={left:0,top:0};version="3.4.7";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 Tb(this),this.engineModelModule.init(),this.ai=new u1(this),this.deviceModule=new wp(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new ci(this),this.sceneModule=new Sp(this),this.scene=this.sceneModule.scene,this.renderModule=new tv(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 Mv(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.clipping=new s1(this),this.clipping.init(),this.composerModule=new Nv(this),this.composerModule.init(),this.events=new yb,this.engineStatus=new vb(this),this.engineStatus.init(),this.loaderModule=new _b(this),this.lightModule=new Mb(this),this.lightModule.init(),this.viewCube=new Jb(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Qb(this),this.rangeScale=new eS(this),this.rangeScale.init(),this.setting=new tS(this),this.engineModelModule.init(),this.handelBehaved=Kl(this),this.modelMapperBatch=new l1(this),this.measure=new hS(this),this.modelToolModule=new Sb(this),this.modelProperties=new a1(this),this.interactionModule=new bb(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new zo(this),this.modelEdge=new c1(this),this.modelTree=new r1(this),this.viewTree=new P1(this),this.merge2d=new O1(this),this.engineInfo=new o1(this),this.pathRoaming=new d1(this),this.pathRoaming.init(),this.oneClickEncoding=new C1(this),this.minMap=new f1(this),this.linkElement2d3d=new E1(this),this.linkView2d3d=new T1(this),this.grid=new g1(this),this.level=new v1(this),this.issueReport=new y1(this),this.text=new M1(this),this.hdr=new b1(this),this.ground=new rh(this),this.ground.init(),this.skyManager=new A1(this),this.setting.init(),this.worldToScreen=new it(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Rb,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(Fs.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.renderer&&(i.renderer.interactionActive=!1),i.events.trigger(Fs.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.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)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,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){const n=new b.Vector3;e.getWorldDirection(n);const i=100,r=new b.Vector3().copy(n).multiplyScalar(-i),o=new b.Vector3(0,1,0),a=new b.Vector3().crossVectors(n,o).normalize();r.addScaledVector(o,i*.5),r.addScaledVector(a,i*.3),t.position.copy(e.position).add(r);const l=new b.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,r=this.cameraModule.getOrthographicVisibleHeight(i);this.cameraModule.setOrthographicVisibleHeight(r,i),i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,r=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${r}`)}this.events&&this.events.trigger(Fs.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.issueReport&&this.issueReport.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof b.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof 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)}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 B1=`
|
|
5375
5375
|
varying vec2 vWorldPos;
|
|
5376
5376
|
|
|
5377
5377
|
void main() {
|