(function(E,V){typeof exports=="object"&&typeof module!="undefined"?V(exports,require("three/examples/jsm/loaders/GLTFLoader.js"),require("three/examples/jsm/loaders/DRACOLoader.js"),require("three")):typeof define=="function"&&define.amd?define(["exports","three/examples/jsm/loaders/GLTFLoader.js","three/examples/jsm/loaders/DRACOLoader.js","three"],V):(E=typeof globalThis!="undefined"?globalThis:E||self,V(E.AMap=E.AMap||{},E.THREE,E.THREE,E.THREE))})(this,function(E,V,qe,m){"use strict";var Je=typeof global=="object"&&global&&global.Object===Object&&global,Ye=Je,Ze=typeof self=="object"&&self&&self.Object===Object&&self,Ke=Ye||Ze||Function("return this")(),I=Ke,Xe=I.Symbol,lt=Xe,Gt=Object.prototype,tn=Gt.hasOwnProperty,en=Gt.toString,K=lt?lt.toStringTag:void 0;function nn(n){var t=tn.call(n,K),e=n[K];try{n[K]=void 0;var r=!0}catch(i){}var s=en.call(n);return r&&(t?n[K]=e:delete n[K]),s}var rn=Object.prototype,sn=rn.toString;function on(n){return sn.call(n)}var an="[object Null]",ln="[object Undefined]",Wt=lt?lt.toStringTag:void 0;function Ht(n){return n==null?n===void 0?ln:an:Wt&&Wt in Object(n)?nn(n):on(n)}function Qt(n){return n!=null&&typeof n=="object"}var cn="[object Symbol]";function un(n){return typeof n=="symbol"||Qt(n)&&Ht(n)==cn}var hn=Array.isArray,dn=hn,pn=/\s/;function fn(n){for(var t=n.length;t--&&pn.test(n.charAt(t)););return t}var mn=/^\s+/;function gn(n){return n&&n.slice(0,fn(n)+1).replace(mn,"")}function z(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}var qt=0/0,_n=/^[-+]0x[0-9a-f]+$/i,vn=/^0b[01]+$/i,bn=/^0o[0-7]+$/i,yn=parseInt;function wn(n){if(typeof n=="number")return n;if(un(n))return qt;if(z(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=z(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=gn(n);var e=vn.test(n);return e||bn.test(n)?yn(n.slice(2),e?2:8):_n.test(n)?qt:+n}var Jt=1/0,Tn=17976931348623157e292;function xn(n){if(!n)return n===0?n:0;if(n=wn(n),n===Jt||n===-Jt){var t=n<0?-1:1;return t*Tn}return n===n?n:0}function Yt(n){var t=xn(n),e=t%1;return t===t?e?t-e:t:0}function yt(n){return n}var $n="[object AsyncFunction]",Sn="[object Function]",Mn="[object GeneratorFunction]",Ln="[object Proxy]";function Cn(n){if(!z(n))return!1;var t=Ht(n);return t==Sn||t==Mn||t==$n||t==Ln}var En=I["__core-js_shared__"],wt=En,Zt=function(){var n=/[^.]+$/.exec(wt&&wt.keys&&wt.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function Fn(n){return!!Zt&&Zt in n}var Rn=Function.prototype,On=Rn.toString;function Pn(n){if(n!=null){try{return On.call(n)}catch(t){}try{return n+""}catch(t){}}return""}var kn=/[\\^$.*+?()[\]{}|]/g,Un=/^\[object .+?Constructor\]$/,An=Function.prototype,Vn=Object.prototype,Dn=An.toString,In=Vn.hasOwnProperty,Nn=RegExp("^"+Dn.call(In).replace(kn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Bn(n){if(!z(n)||Fn(n))return!1;var t=Cn(n)?Nn:Un;return t.test(Pn(n))}function jn(n,t){return n==null?void 0:n[t]}function Kt(n,t){var e=jn(n,t);return Bn(e)?e:void 0}var zn=Kt(I,"WeakMap"),Xt=zn,Gn=Xt&&new Xt,ct=Gn,Wn=ct?function(n,t){return ct.set(n,t),n}:yt,te=Wn,ee=Object.create,Hn=function(){function n(){}return function(t){if(!z(t))return{};if(ee)return ee(t);n.prototype=t;var e=new n;return n.prototype=void 0,e}}(),Tt=Hn;function X(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var e=Tt(n.prototype),r=n.apply(e,t);return z(r)?r:e}}var Qn=1;function qn(n,t,e){var r=t&Qn,s=X(n);function i(){var a=this&&this!==I&&this instanceof i?s:n;return a.apply(r?e:this,arguments)}return i}function xt(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var Jn=Math.max;function ne(n,t,e,r){for(var s=-1,i=n.length,a=e.length,o=-1,c=t.length,u=Jn(i-a,0),h=Array(c+u),l=!r;++o0){if(++t>=cr)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}var dr=ae(te),le=dr,pr=/\{\n\/\* \[wrapped with (.+)\] \*/,fr=/,? & /;function mr(n){var t=n.match(pr);return t?t[1].split(fr):[]}var gr=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/;function _r(n,t){var e=t.length;if(!e)return n;var r=e-1;return t[r]=(e>1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(gr,`{ /* [wrapped with `+t+`] */ `)}function vr(n){return function(){return n}}var br=function(){try{var n=Kt(Object,"defineProperty");return n({},"",{}),n}catch(t){}}(),ce=br,yr=ce?function(n,t){return ce(n,"toString",{configurable:!0,enumerable:!1,value:vr(t),writable:!0})}:yt,wr=yr,Tr=ae(wr),ue=Tr;function xr(n,t){for(var e=-1,r=n==null?0:n.length;++e-1}var Er=1,Fr=2,Rr=8,Or=16,Pr=32,kr=64,Ur=128,Ar=256,Vr=512,Dr=[["ary",Ur],["bind",Er],["bindKey",Fr],["curry",Rr],["curryRight",Or],["flip",Vr],["partial",Pr],["partialRight",kr],["rearg",Ar]];function Ir(n,t){return xr(Dr,function(e){var r="_."+e[0];t&e[1]&&!Cr(n,r)&&n.push(r)}),n.sort()}function he(n,t,e){var r=t+"";return ue(n,_r(r,Ir(mr(r),e)))}var Nr=1,Br=2,jr=4,zr=8,de=32,pe=64;function fe(n,t,e,r,s,i,a,o,c,u){var h=t&zr,l=h?a:void 0,f=h?void 0:a,p=h?i:void 0,d=h?void 0:i;t|=h?de:pe,t&=~(h?pe:de),t&jr||(t&=~(Nr|Br));var g=[n,t,s,p,l,d,f,o,c,u],_=e.apply(void 0,g);return lr(n)&&le(_,g),_.placeholder=r,he(_,n,t)}function St(n){var t=n;return t.placeholder}var Gr=9007199254740991,Wr=/^(?:0|[1-9]\d*)$/;function Hr(n,t){var e=typeof n;return t=t==null?Gr:t,!!t&&(e=="number"||e!="symbol"&&Wr.test(n))&&n>-1&&n%1==0&&n1&&v.reverse(),h&&c0){for(let s=0;s0)for(let s=0;st.get(e)}isFull(){return this.itemSet.size>=this.maxSize}add(t,e){const r=this.itemSet;if(r.has(t)||this.isFull())return!1;const s=this.usedSet,i=this.itemList,a=this.callbacks;return i.push(t),s.add(t),r.set(t,Date.now()),a.set(t,e),!0}remove(t){const e=this.usedSet,r=this.itemSet,s=this.itemList,i=this.callbacks;if(r.has(t)){i.get(t)(t);const a=s.indexOf(t);return s.splice(a,1),e.delete(t),r.delete(t),i.delete(t),!0}return!1}markUsed(t){const e=this.itemSet,r=this.usedSet;e.has(t)&&!r.has(t)&&(e.set(t,Date.now()),r.add(t))}markAllUnused(){this.usedSet.clear()}unloadUnusedContent(){const t=this.unloadPercent,e=this.minSize,r=this.itemList,s=this.itemSet,i=this.usedSet,a=this.callbacks,o=r.length-i.size,c=r.length-e,u=this.unloadPriorityCallback||this.defaultPriorityCallback;if(c>0&&o>0){r.sort((d,g)=>{const _=i.has(d),y=i.has(g);return _&&y?0:!_&&!y?u(g)-u(d):_?1:-1});const h=Math.min(c,o),l=Math.max(e*t,h*t);let f=Math.min(l,o);f=Math.ceil(f);const p=r.splice(0,f);for(let d=0,g=p.length;d{this.scheduled=!1,this.unloadUnusedContent(),t&&this.markAllUnused()}))}}class $e{constructor(){this.maxJobs=6,this.items=[],this.callbacks=new Map,this.currJobs=0,this.scheduled=!1,this.autoUpdate=!0,this.priorityCallback=()=>{throw new Error("PriorityQueue: PriorityCallback function not defined.")},this.schedulingCallback=t=>{requestAnimationFrame(t)},this._runjobs=()=>{this.tryRunJobs(),this.scheduled=!1}}sort(){const t=this.priorityCallback;this.items.sort(t)}add(t,e){return new Promise((r,s)=>{const i=(...c)=>e(...c).then(r).catch(s),a=this.items,o=this.callbacks;a.push(t),o.set(t,i),this.autoUpdate&&this.scheduleJobRun()})}remove(t){const e=this.items,r=this.callbacks,s=e.indexOf(t);s!==-1&&(e.splice(s,1),r.delete(t))}tryRunJobs(){this.sort();const t=this.items,e=this.callbacks,r=this.maxJobs;let s=this.currJobs;for(;r>s&&t.length>0;){s++;const i=t.pop(),a=e.get(i);e.delete(i),a(i).then(()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()}).catch(()=>{this.currJobs--,this.autoUpdate&&this.scheduleJobRun()})}this.currJobs=s}scheduleJobRun(){this.scheduled||(this.schedulingCallback(this._runjobs),this.scheduled=!0)}}const ht=0,dt=1,Pt=2,nt=3,pt=4,Se=6378137,bs=.0033528106647474805,ys=-(bs*6378137-6378137);function kt(n){return n===nt||n===pt}function N(n,t){return n.__lastFrameVisited===t&&n.__used}function Me(n,t){n.__lastFrameVisited!==t&&(n.__lastFrameVisited=t,n.__used=!1,n.__inFrustum=!1,n.__isLeaf=!1,n.__visible=!1,n.__active=!1,n.__error=1/0,n.__distanceFromCamera=1/0,n.__childrenWereVisible=!1,n.__allChildrenLoaded=!1)}function Le(n,t,e){if(Me(n,t),n.__used=!0,e.markUsed(n),n.__contentEmpty){const r=n.children;for(let s=0,i=r.length;s0&&n.__depth+1>=i))return!0;let u=!1;const h=n.children;for(let l=0,f=h.length;ln.__depth!==t.__depth?n.__depth>t.__depth?-1:1:n.__inFrustum!==t.__inFrustum?n.__inFrustum?1:-1:n.__used!==t.__used?n.__used?1:-1:n.__error!==t.__error?n.__error>t.__error?1:-1:n.__distanceFromCamera!==t.__distanceFromCamera?n.__distanceFromCamera>t.__distanceFromCamera?-1:1:0,ws=n=>1/(n.__depthFromRenderedParent+1);class Ts{get rootTileSet(){const t=this.tileSets[this.rootURL];return!t||t instanceof Promise?null:t}get root(){const t=this.rootTileSet;return t?t.root:null}constructor(t){this.tileSets={},this.rootURL=t,this.fetchOptions={},this.preprocessURL=null;const e=new vs;e.unloadPriorityCallback=ws;const r=new $e;r.maxJobs=4,r.priorityCallback=Pe;const s=new $e;s.maxJobs=1,s.priorityCallback=Pe,this.lruCache=e,this.downloadQueue=r,this.parseQueue=s,this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0,this.errorTarget=6,this.errorThreshold=1/0,this.loadSiblings=!0,this.displayActiveTiles=!1,this.maxDepth=1/0,this.stopAtEmptyTiles=!0}traverse(t,e){const r=this.tileSets[this.rootURL];!r||!r.root||Ut(r.root,t,e)}update(){const t=this.stats,e=this.lruCache,r=this.tileSets,s=r[this.rootURL];if(this.rootURL in r){if(!s||!s.root)return}else{this.loadRootTileSet(this.rootURL);return}const i=s.root;t.inFrustum=0,t.used=0,t.active=0,t.visible=0,this.frameCount++,Ee(i,this),Fe(i,this),Re(i,this),Oe(i,this),e.scheduleUnload()}parseTile(t,e,r){return null}disposeTile(t){}preprocessNode(t,e,r){if(t.content&&(!("uri"in t.content)&&"url"in t.content&&(t.content.uri=t.content.url,delete t.content.url),t.content.uri&&(t.content.uri=new URL(t.content.uri,r+"/").toString()),t.content.boundingVolume&&!("box"in t.content.boundingVolume||"sphere"in t.content.boundingVolume||"region"in t.content.boundingVolume)&&delete t.content.boundingVolume),t.parent=e,t.children=t.children||[],t.content&&t.content.uri){const s=xe(t.content.uri),i=Boolean(s&&s.toLowerCase()==="json");t.__externalTileSet=i,t.__contentEmpty=i}else t.__externalTileSet=!1,t.__contentEmpty=!0;t.__distanceFromCamera=1/0,t.__error=1/0,t.__inFrustum=!1,t.__isLeaf=!1,t.__usedLastFrame=!1,t.__used=!1,t.__wasSetVisible=!1,t.__visible=!1,t.__childrenWereVisible=!1,t.__allChildrenLoaded=!1,t.__wasSetActive=!1,t.__active=!1,t.__loadingState=ht,t.__loadIndex=0,t.__loadAbort=null,t.__depthFromRenderedParent=-1,e===null?(t.__depth=0,t.refine=t.refine||"REPLACE"):(t.__depth=e.__depth+1,t.refine=t.refine||e.refine)}setTileActive(t,e){}setTileVisible(t,e){}calculateError(t){return 0}tileInView(t){return!0}resetFailedTiles(){const t=this.stats;t.failed!==0&&(this.traverse(e=>{e.__loadingState===pt&&(e.__loadingState=ht)}),t.failed=0)}fetchTileSet(t,e,r=null){return fetch(t,e).then(s=>{if(s.ok)return s.json();throw new Error(`TilesRenderer: Failed to load tileset "${t}" with status ${s.status} : ${s.statusText}`)}).then(s=>{const i=s.asset.version;console.assert(i==="1.0"||i==="0.0",'asset.version is expected to be a string of "1.0" or "0.0"');let a=t.replace(/\/[^\/]*\/?$/,"");return a=new URL(a,window.location.href).toString(),Ut(s.root,(o,c)=>this.preprocessNode(o,c,a),null,r,r?r.__depth:0),s})}loadRootTileSet(t){const e=this.tileSets;if(t in e)return e[t]instanceof Error?Promise.reject(e[t]):Promise.resolve(e[t]);{const r=this.fetchTileSet(this.preprocessURL?this.preprocessURL(t):t,this.fetchOptions).then(s=>{e[t]=s});return r.catch(s=>{console.error(s),e[t]=s}),e[t]=r,r}}requestTileContents(t){if(t.__loadingState!==ht)return;const e=this.stats,r=this.lruCache,s=this.downloadQueue,i=this.parseQueue,a=t.__externalTileSet;r.add(t,l=>{l.__loadingState===dt?(l.__loadAbort.abort(),l.__loadAbort=null):a?l.children.length=0:this.disposeTile(l),l.__loadingState===dt?e.downloading--:l.__loadingState===Pt&&e.parsing--,l.__loadingState=ht,l.__loadIndex++,i.remove(l),s.remove(l)}),t.__loadIndex++;const o=t.__loadIndex,c=new AbortController,u=c.signal;e.downloading++,t.__loadAbort=c,t.__loadingState=dt;const h=l=>{t.__loadIndex===o&&(l.name!=="AbortError"?(i.remove(t),s.remove(t),t.__loadingState===Pt?e.parsing--:t.__loadingState===dt&&e.downloading--,e.failed++,console.error(`TilesRenderer : Failed to load tile at url "${t.content.uri}".`),console.error(l),t.__loadingState=pt):r.remove(t))};a?s.add(t,l=>{if(l.__loadIndex!==o)return Promise.resolve();const f=this.preprocessURL?this.preprocessURL(l.content.uri):l.content.uri;return this.fetchTileSet(f,Object.assign({signal:u},this.fetchOptions),l)}).then(l=>{t.__loadIndex===o&&(e.downloading--,t.__loadAbort=null,t.__loadingState=nt,t.children.push(l.root))}).catch(h):s.add(t,l=>{if(l.__loadIndex!==o)return Promise.resolve();const f=this.preprocessURL?this.preprocessURL(l.content.uri):l.content.uri;return fetch(f,Object.assign({signal:u},this.fetchOptions))}).then(l=>{if(t.__loadIndex===o){if(l.ok)return l.arrayBuffer();throw new Error(`Failed to load model with error code ${l.status}`)}}).then(l=>{if(t.__loadIndex===o)return e.downloading--,e.parsing++,t.__loadAbort=null,t.__loadingState=Pt,i.add(t,f=>{if(f.__loadIndex!==o)return Promise.resolve();const p=f.content.uri,d=xe(p);return this.parseTile(l,f,d)})}).then(()=>{t.__loadIndex===o&&(e.parsing--,t.__loadingState=nt,t.__wasSetVisible&&this.setTileVisible(t,!0),t.__wasSetActive&&this.setTileActive(t,!0))}).catch(h)}dispose(){const t=this.lruCache;this.traverse(e=>{t.remove(e)}),this.stats={parsing:0,downloading:0,failed:0,inFrustum:0,used:0,active:0,visible:0},this.frameCount=0}}function ke(n){return new TextDecoder().decode(n)}class ft{constructor(t,e,r,s){this.buffer=t,this.binOffset=e+r,this.binLength=s;let i=null;if(r!==0){const a=new Uint8Array(t,e,r);i=JSON.parse(ke(a))}else i={};this.header=i}getKeys(){return Object.keys(this.header)}getData(t,e,r=null,s=null){const i=this.header;if(!(t in i))return null;const a=i[t];if(a instanceof Object){if(Array.isArray(a))return a;{const{buffer:o,binOffset:c,binLength:u}=this,h=a.byteOffset||0,l=a.type||s,f=a.componentType||r;if("type"in a&&s&&a.type!==s)throw new Error("FeatureTable: Specified type does not match expected type.");let p;switch(l){case"SCALAR":p=1;break;case"VEC2":p=2;break;case"VEC3":p=3;break;case"VEC4":p=4;break;default:throw new Error(`FeatureTable : Feature type not provided for "${t}".`)}let d;const g=c+h,_=e*p;switch(f){case"BYTE":d=new Int8Array(o,g,_);break;case"UNSIGNED_BYTE":d=new Uint8Array(o,g,_);break;case"SHORT":d=new Int16Array(o,g,_);break;case"UNSIGNED_SHORT":d=new Uint16Array(o,g,_);break;case"INT":d=new Int32Array(o,g,_);break;case"UNSIGNED_INT":d=new Uint32Array(o,g,_);break;case"FLOAT":d=new Float32Array(o,g,_);break;case"DOUBLE":d=new Float64Array(o,g,_);break;default:throw new Error(`FeatureTable : Feature component type not provided for "${t}".`)}if(g+_*d.BYTES_PER_ELEMENT>c+u)throw new Error("FeatureTable: Feature data read outside binary body length.");return d}}else return a}}class At extends ft{constructor(t,e,r,s,i){super(t,r,s,i),this.batchSize=e}getData(t,e=null,r=null){return super.getData(t,this.batchSize,e,r)}}class rt{constructor(){this.fetchOptions={},this.workingPath=""}load(t){return fetch(t,this.fetchOptions).then(e=>{if(!e.ok)throw new Error(`Failed to load file "${t}" with status ${e.status} : ${e.statusText}`);return e.arrayBuffer()}).then(e=>(this.workingPath===""&&(this.workingPath=this.workingPathForURL(t)),this.parse(e)))}resolveExternalURL(t){return/^[^\\/]/.test(t)?this.workingPath+"/"+t:t}workingPathForURL(t){const e=t.split(/[\\/]/g);return e.pop(),e.join("/")+"/"}parse(t){throw new Error("LoaderBase: Parse not implemented.")}}function H(n){let t;if(n instanceof DataView?t=n:t=new DataView(n),String.fromCharCode(t.getUint8(0))==="{")return null;let e="";for(let r=0;r<4;r++)e+=String.fromCharCode(t.getUint8(r));return e}class xs extends rt{parse(t){const e=new DataView(t),r=H(e);console.assert(r==="b3dm");const s=e.getUint32(4,!0);console.assert(s===1);const i=e.getUint32(8,!0);console.assert(i===t.byteLength);const a=e.getUint32(12,!0),o=e.getUint32(16,!0),c=e.getUint32(20,!0),u=e.getUint32(24,!0),h=28,l=t.slice(h,h+a+o),f=new ft(l,0,a,o),p=h+a+o,d=t.slice(p,p+c+u),g=new At(d,f.getData("BATCH_LENGTH"),0,c,u),_=p+c+u,y=new Uint8Array(t,_,i-_);return{version:s,featureTable:f,batchTable:g,glbBytes:y}}}class Ue extends xs{constructor(t=m.DefaultLoadingManager){super(),this.manager=t,this.adjustmentTransform=new m.Matrix4}parse(t){const e=super.parse(t),r=e.glbBytes.slice().buffer;return new Promise((s,i)=>{const a=this.manager,o=this.fetchOptions,c=a.getHandler("path.gltf")||new V.GLTFLoader(a);o.credentials==="include"&&o.mode==="cors"&&c.setCrossOrigin("use-credentials"),"credentials"in o&&c.setWithCredentials(o.credentials==="include"),o.headers&&c.setRequestHeader(o.headers);let u=this.workingPath;!/[\\/]$/.test(u)&&u.length&&(u+="/");const h=this.adjustmentTransform;c.parse(r,u,l=>{const{batchTable:f,featureTable:p}=e,{scene:d}=l,g=p.getData("RTC_CENTER");g&&(d.position.x+=g[0],d.position.y+=g[1],d.position.z+=g[2]),l.scene.updateMatrix(),l.scene.matrix.multiply(h),l.scene.matrix.decompose(l.scene.position,l.scene.quaternion,l.scene.scale),l.batchTable=f,l.featureTable=p,d.batchTable=f,d.featureTable=p,s(l)},i)})}}class $s extends rt{parse(t){const e=new DataView(t),r=H(e);console.assert(r==="pnts");const s=e.getUint32(4,!0);console.assert(s===1);const i=e.getUint32(8,!0);console.assert(i===t.byteLength);const a=e.getUint32(12,!0),o=e.getUint32(16,!0),c=e.getUint32(20,!0),u=e.getUint32(24,!0),h=28,l=t.slice(h,h+a+o),f=new ft(l,0,a,o),p=h+a+o,d=t.slice(p,p+c+u),g=new At(d,f.getData("BATCH_LENGTH")||f.getData("POINTS_LENGTH"),0,c,u);return Promise.resolve({version:s,featureTable:f,batchTable:g})}}class Ae extends $s{constructor(t=m.DefaultLoadingManager){super(),this.manager=t}parse(t){return super.parse(t).then(e=>{const{featureTable:r}=e,s=r.getData("POINTS_LENGTH"),i=r.getData("POSITION",s,"FLOAT","VEC3"),a=r.getData("RGB",s,"UNSIGNED_BYTE","VEC3");["QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","CONSTANT_RGBA","BATCH_LENGTH","POSITION_QUANTIZED","RGBA","RGB565","NORMAL","NORMAL_OCT16P"].forEach(l=>{l in r.header&&console.warn(`PNTSLoader: Unsupported FeatureTable feature "${l}" detected.`)});const o=new m.BufferGeometry;o.setAttribute("position",new m.BufferAttribute(i,3,!1));const c=new m.PointsMaterial;c.size=2,c.sizeAttenuation=!1,a!==null&&(o.setAttribute("color",new m.BufferAttribute(a,3,!0)),c.vertexColors=!0);const u=new m.Points(o,c);e.scene=u,e.scene.featureTable=r;const h=r.getData("RTC_CENTER");return h&&(e.scene.position.x+=h[0],e.scene.position.y+=h[1],e.scene.position.z+=h[2]),e})}}class Ss extends rt{parse(t){const e=new DataView(t),r=H(e);console.assert(r==="i3dm");const s=e.getUint32(4,!0);console.assert(s===1);const i=e.getUint32(8,!0);console.assert(i===t.byteLength);const a=e.getUint32(12,!0),o=e.getUint32(16,!0),c=e.getUint32(20,!0),u=e.getUint32(24,!0),h=e.getUint32(28,!0),l=32,f=t.slice(l,l+a+o),p=new ft(f,0,a,o),d=l+a+o,g=t.slice(d,d+c+u),_=new At(g,p.getData("INSTANCES_LENGTH"),0,c,u),y=d+c+u,v=new Uint8Array(t,y,i-y);let w=null,T=null;if(h)w=v,T=Promise.resolve();else{const S=this.resolveExternalURL(ke(v));T=fetch(S,this.fetchOptions).then(x=>{if(!x.ok)throw new Error(`I3DMLoaderBase : Failed to load file "${S}" with status ${x.status} : ${x.statusText}`);return x.arrayBuffer()}).then(x=>{w=new Uint8Array(x)})}return T.then(()=>({version:s,featureTable:p,batchTable:_,glbBytes:w}))}}const Ve=new m.Vector3,Vt=new m.Vector3,Dt=new m.Vector3,De=new m.Vector3,It=new m.Quaternion,mt=new m.Vector3,gt=new m.Matrix4;class Ie extends Ss{constructor(t=m.DefaultLoadingManager){super(),this.manager=t,this.adjustmentTransform=new m.Matrix4}resolveExternalURL(t){return this.manager.resolveURL(super.resolveExternalURL(t))}parse(t){return super.parse(t).then(e=>{const{featureTable:r,batchTable:s}=e,i=e.glbBytes.slice().buffer;return new Promise((a,o)=>{const c=this.fetchOptions,u=this.manager,h=u.getHandler("path.gltf")||new V.GLTFLoader(u);c.credentials==="include"&&c.mode==="cors"&&h.setCrossOrigin("use-credentials"),"credentials"in c&&h.setWithCredentials(c.credentials==="include"),c.headers&&h.setRequestHeader(c.headers);let l=this.workingPath;/[\\/]$/.test(l)||(l+="/");const f=this.adjustmentTransform;h.parse(i,l,p=>{const d=r.getData("INSTANCES_LENGTH"),g=r.getData("POSITION",d,"FLOAT","VEC3"),_=r.getData("NORMAL_UP",d,"FLOAT","VEC3"),y=r.getData("NORMAL_RIGHT",d,"FLOAT","VEC3"),v=r.getData("SCALE_NON_UNIFORM",d,"FLOAT","VEC3"),w=r.getData("SCALE",d,"FLOAT","SCALAR");["RTC_CENTER","QUANTIZED_VOLUME_OFFSET","QUANTIZED_VOLUME_SCALE","EAST_NORTH_UP","POSITION_QUANTIZED","NORMAL_UP_OCT32P","NORMAL_RIGHT_OCT32P"].forEach(b=>{b in r.header&&console.warn(`I3DMLoader: Unsupported FeatureTable feature "${b}" detected.`)});const T=new Map,S=[];p.scene.traverse(b=>{if(b.isMesh){const{geometry:M,material:j}=b,at=new m.InstancedMesh(M,j,d);at.position.copy(b.position),at.rotation.copy(b.rotation),at.scale.copy(b.scale),S.push(at),T.set(b,at)}});const x=new m.Vector3;for(let b=0;b{const j=M.parent;j&&(j.remove(M),j.add(b),b.updateMatrixWorld(),b.position.copy(x).applyMatrix4(b.matrixWorld))});for(let b=0;b{const o=new m.Group;return a.forEach(c=>{o.add(c.scene)}),{tiles:a,scene:o}})}}class Cs{constructor(){this.name="CESIUM_RTC"}afterRoot(t){const{center:e}=t.parser.json.extensions.CESIUM_RTC;t.scene.position.x+=e[0],t.scene.position.y+=e[1],t.scene.position.z+=e[2]}}class Es extends rt{constructor(t=m.DefaultLoadingManager){super(),this.manager=t}parse(t){return new Promise((e,r)=>{const s=this.manager,i=this.fetchOptions;let a=s.getHandler("path.gltf")||s.getHandler("path.glb");a||(a=new V.GLTFLoader(s),a.register(()=>new Cs),i.credentials==="include"&&i.mode==="cors"&&a.setCrossOrigin("use-credentials"),"credentials"in i&&a.setWithCredentials(i.credentials==="include"),i.headers&&a.setRequestHeader(i.headers));let o=a.resourcePath||a.path||this.workingPath;!/[\\/]$/.test(o)&&o.length&&(o+="/"),a.parse(t,o,c=>{e(c)},r)})}}const _t=new m.Matrix4;class Fs extends m.Group{constructor(t){super(),this.name="TilesRenderer.TilesGroup",this.tilesRenderer=t}raycast(t,e){this.tilesRenderer.optimizeRaycast&&this.tilesRenderer.raycast(t,e)}updateMatrixWorld(t){if(this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||t){this.parent===null?_t.copy(this.matrix):_t.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1;const e=_t.elements,r=this.matrixWorld.elements;let s=!1;for(let i=0;i<16;i++){const a=e[i],o=r[i];if(Math.abs(a-o)>Number.EPSILON){s=!0;break}}if(s){this.matrixWorld.copy(_t);const i=this.children;for(let a=0,o=i.length;a=e&&v<=r&&w>=s&&w<=i){const T=Ps(t);f.push(T),this.getCartographicToPosition(v,w,g,T)}}}return f}getBoundingBox(t,e){je();const{latStart:r,latEnd:s,lonStart:i,lonEnd:a}=this;if(s-r{Object.getPrototypeOf(r).raycast.call(r,t,e)})}function Ge(n,t,e,r){if(e.has(n))if(jt(n.cached.scene,r,$),$.length>0){$.length>1&&$.sort(Bt);const c=$[0];return $.length=0,c}else return null;const s=[],i=n.children;for(let c=0,u=i.length;c1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when raycasting.");const y={distance:1/0,tile:null};s.push(y),y.distance=ze.distanceToSquared(Z.origin)*_*_,y.tile=h}else continue}s.sort(Bt);let a=1/0,o=null;for(let c=0,u=s.length;ca)break;{const l=h.tile,f=l.cached.scene;let p=null;if(e.has(l)?(jt(f,r,$),$.length>0&&($.length>1&&$.sort(Bt),p=$[0])):p=Ge(l,t,e,r),p){const d=p.distance*p.distance;d{e.frustumCulled=e[He]&&t})}class Vs extends Ts{get autoDisableRendererCulling(){return this._autoDisableRendererCulling}set autoDisableRendererCulling(t){this._autoDisableRendererCulling!==t&&(super._autoDisableRendererCulling=t,this.forEachLoadedModel(e=>{Qe(e,!t)}))}constructor(...t){super(...t),this.group=new Fs(this),this.cameras=[],this.cameraMap=new Map,this.cameraInfo=[],this.activeTiles=new Set,this.visibleTiles=new Set,this._autoDisableRendererCulling=!0,this.optimizeRaycast=!0,this.onLoadTileSet=null,this.onLoadModel=null,this.onDisposeModel=null,this.onTileVisibilityChange=null;const e=new m.LoadingManager;e.setURLModifier(s=>this.preprocessURL?this.preprocessURL(s):s),this.manager=e;const r=this;this._overridenRaycast=function(s,i){r.optimizeRaycast||Object.getPrototypeOf(this).raycast.call(this,s,i)}}getBounds(t){if(!this.root)return!1;const e=this.root.cached,r=e.box,s=e.boxTransform;return r?(t.copy(r),t.applyMatrix4(s),!0):!1}getOrientedBounds(t,e){if(!this.root)return!1;const r=this.root.cached,s=r.box,i=r.boxTransform;return s?(t.copy(s),e.copy(i),!0):!1}getBoundingSphere(t){if(!this.root)return!1;const e=this.root.cached.sphere;return e?(t.copy(e),!0):!1}forEachLoadedModel(t){this.traverse(e=>{const r=e.cached.scene;r&&t(r,e)})}raycast(t,e){if(this.root)if(t.firstHitOnly){const r=Ge(this.root,this.group,this.activeTiles,t);r&&e.push(r)}else We(this.root,this.group,this.activeTiles,t,e)}hasCamera(t){return this.cameraMap.has(t)}setCamera(t){const e=this.cameras,r=this.cameraMap;return r.has(t)?!1:(r.set(t,new m.Vector2),e.push(t),!0)}setResolution(t,e,r){const s=this.cameraMap;return s.has(t)?(e instanceof m.Vector2?s.get(t).copy(e):s.get(t).set(e,r),!0):!1}setResolutionFromRenderer(t,e){const r=this.cameraMap;if(!r.has(t))return!1;const s=r.get(t);return e.getSize(s),s.multiplyScalar(e.getPixelRatio()),!0}deleteCamera(t){const e=this.cameras,r=this.cameraMap;if(r.has(t)){const s=e.indexOf(t);return e.splice(s,1),r.delete(t),!0}return!1}fetchTileSet(t,...e){const r=super.fetchTileSet(t,...e);return r.then(s=>{this.onLoadTileSet&&Promise.resolve().then(()=>{this.onLoadTileSet(s,t)})}),r}update(){const t=this.group,e=this.cameras,r=this.cameraMap,s=this.cameraInfo;if(e.length===0){console.warn("TilesRenderer: no cameras defined. Cannot update 3d tiles.");return}for(;s.length>e.length;)s.pop();for(;s.length1e-6&&console.warn("ThreeTilesRenderer : Non uniform scale used for tile which may cause issues when calculating screen space error.");for(let a=0,o=s.length;a_.scene);break}case"pnts":{const g=new Ae(o);g.workingPath=i,g.fetchOptions=a,u=g.parse(t).then(_=>_.scene);break}case"i3dm":{const g=new Ie(o);g.workingPath=i,g.fetchOptions=a,g.adjustmentTransform.copy(L),u=g.parse(t).then(_=>_.scene);break}case"cmpt":{const g=new Ls(o);g.workingPath=i,g.fetchOptions=a,g.adjustmentTransform.copy(L),u=g.parse(t).then(_=>_.scene);break}case"gltf":case"glb":const d=new Es(o);d.workingPath=i,d.fetchOptions=a,u=d.parse(t).then(g=>g.scene);break;default:console.warn(`TilesRenderer: Content type "${p}" not supported.`),u=Promise.resolve(null);break}return u.then(d=>{if(e._loadIndex!==c)return;d.updateMatrix(),(p==="glb"||p==="gltf")&&d.matrix.multiply(L),d.matrix.premultiply(f),d.matrix.decompose(d.position,d.quaternion,d.scale),d.traverse(v=>{v[He]=v.frustumCulled}),Qe(d,!this.autoDisableRendererCulling),l.scene=d,d.traverse(v=>{v.raycast=this._overridenRaycast});const g=[],_=[],y=[];d.traverse(v=>{if(v.geometry&&_.push(v.geometry),v.material){const w=v.material;g.push(v.material);for(const T in w){const S=w[T];S&&S.isTexture&&y.push(S)}}}),l.materials=g,l.geometry=_,l.textures=y,this.onLoadModel&&this.onLoadModel(d,e)})}disposeTile(t){const e=t.cached;if(e.scene){const r=e.materials,s=e.geometry,i=e.textures,a=e.scene.parent;for(let o=0,c=s.length;o{t.disposeTile(e)}),t.lruCache.itemSet.clear(),t.lruCache.itemList=[],t.lruCache.callbacks.clear(),t.lruCache=null,t.visibleTiles.clear(),t.activeTiles.clear(),t.downloadQueue.callbacks.clear(),t.downloadQueue.items=[],t.downloadQueue=null,t.parseQueue.callbacks.clear(),t.parseQueue.items=[],t.parseQueue=null,this.clearGroup(this.group),t.tileSets={},t.cameraMap.clear(),t.cameras=[],t.cameraInfo=[],t.group=null}clearGroup(t){t.traverse(e=>{e.isMesh&&(e.geometry.dispose(),e.material.dispose(),e.material.texture&&e.material.texture.dispose&&e.material.texture.dispose()),delete e.featureTable,delete e.batchTable}),delete t.tilesRenderer,t.remove(...t.children)}}class Is extends gs{constructor(t,e){super(),this.animationFrame=-1,this.mouse=new m.Vector2,this.layer=t;const r=new Ds(e.url);r.setCamera(this.layer.getCamera()),r.setResolutionFromRenderer(this.layer.getCamera(),this.layer.getRender());const s=e.fetchOptions||{},i=new V.GLTFLoader(r.manager);s.credentials==="include"&&s.mode==="cors"&&i.setCrossOrigin("use-credentials"),"credentials"in s&&i.setWithCredentials(s.credentials==="include"),s.headers&&i.setRequestHeader(s.headers);const a=new qe.DRACOLoader,o=e.dracoDecoderPath||"https://cdn.jsdelivr.net/npm/three@0.143/examples/js/libs/draco/";if(a.setDecoderPath(o),i.setDRACOLoader(a),r.manager.addHandler(/\.gltf$/i,i),r.onLoadTileSet=c=>{this.emit("loadTileSet",c)},r.onLoadModel=(c,u)=>{this.emit("loadModel",{scene:c,tile:u})},r.onDisposeModel=(c,u)=>{this.emit("disposeModel",{scene:c,tile:u})},r.downloadQueue.maxJobs=6,r.parseQueue.maxJobs=6,this.group=r.group,this.layer.add(this.group),this.tilesRenderer=r,e.position&&this.setPosition(e.position),e.rotation&&this.setRotation(e.rotation),e.translate&&this.setTranslate(e.translate),e.scale&&this.setScale(e.scale),this.animate(),e.debug){const c=document.createElement("div");c.style.position="absolute",c.style.top="0px",c.style.left="0px",c.style.color="white",c.style.width="100%",c.style.textAlign="center",c.style.padding="5px",c.style.pointerEvents="none",c.style.lineHeight="1.5em",document.body.appendChild(c),this.statsContainer=c}this.bindEvents(e.mouseEvent)}bindEvents(t){if(t){this.raycaster=new m.Raycaster,this.raycaster.firstHitOnly=!0;const e=this.layer.getMap();this.clickMapFn=Ot(this.clickMap,this),e.on("click",this.clickMapFn),this.mousemoveMapFn=Ot(this.mousemoveMap,this),e.on("mousemove",this.mousemoveMapFn),this.rightClickMapFn=Ot(this.rightClickMap,this),e.on("rightclick",this.rightClickMapFn)}}unbindEvents(){const t=this.layer.getMap();this.clickMapFn&&(t.off("click",this.clickMapFn),this.clickMapFn=null),this.mousemoveMapFn&&(t.off("mousemove",this.mousemoveMapFn),this.mousemoveMapFn=null),this.rightClickMapFn&&(t.off("rightclick",this.rightClickMapFn),this.rightClickMapFn=null),this.tilesRenderer&&(this.tilesRenderer.onLoadTileSet=null,this.tilesRenderer.onLoadModel=null,this.tilesRenderer.onDisposeModel=null)}clickMap(t){const e=this._intersectGltf(t);this.emit("click",e)}mousemoveMap(t){const e=this._intersectGltf(t);this.emit("mousemove",e)}rightClickMap(t){const e=this._intersectGltf(t);this.emit("rightClick",e)}_intersectGltf(t){var e,r;const s=this.layer.getMap().getContainer().getBoundingClientRect(),i=this.mouse;i.x=t.originEvent.clientX-s.x,i.y=t.originEvent.clientY-s.y,i.x=i.x/s.width*2-1,i.y=-(i.y/s.height)*2+1;const a=this.layer.getCamera();(e=this.raycaster)===null||e===void 0||e.setFromCamera(i,a);const o=(r=this.raycaster)===null||r===void 0?void 0:r.intersectObject(this.group,!0);if(o!=null&&o.length){const c=o[0].object,u={},h=this.getBatchTable(c);return h&&h.getKeys().forEach(l=>{u[l]=h.getData(l)}),{object:c,batchData:u}}return null}getBatchTable(t){return t?t.batchTable?t.batchTable:this.getBatchTable(t.parent):null}setPosition(t){const e=this.layer.convertLngLat(t);this.group.position.setX(e[0]),this.group.position.setY(e[1]),this.refresh()}setRotation(t){if(t){const e=Math.PI/180*(t.x||0),r=Math.PI/180*(t.y||0),s=Math.PI/180*(t.z||0);this.group.rotation.set(e,r,s),this.refresh()}}setTranslate(t){t&&(this.group.translateX(t.x),this.group.translateY(t.y),this.group.translateZ(t.z),this.refresh())}setScale(t){let e;typeof t=="number"?e={x:t,y:t,z:t}:e=t,this.group.scale.set(e.x,e.y,e.z),this.refresh()}refresh(){this.layer.update()}show(){this.group.visible=!0,this.refresh()}hide(){this.group.visible=!1,this.refresh()}animate(){this.animationFrame=requestAnimationFrame(()=>{this.update(),this.animate()})}update(){var t;if(this.layer.getCamera().updateMatrixWorld(),(t=this.tilesRenderer)===null||t===void 0||t.update(),this.layer.update(),this.statsContainer){const e=this.tilesRenderer;this.statsContainer.innerHTML=`\u6B63\u5728\u4E0B\u8F7D: ${e.stats.downloading} \u6B63\u5728\u7F16\u8BD1: ${e.stats.parsing} \u5DF2\u663E\u793A: ${e.group.children.length-2}`}}getGroup(){return this.group}getTilesRenderer(){return this.tilesRenderer}destroy(){var t;cancelAnimationFrame(this.animationFrame),this.unbindEvents(),this.layer.remove(this.group),(t=this.tilesRenderer)===null||t===void 0||t.dispose(),this.group=null,this.layer=null,this.statsContainer&&(this.statsContainer.remove(),this.statsContainer=void 0)}}E.Layer3DTiles=Is,Object.defineProperty(E,"__esModule",{value:!0})}); //# sourceMappingURL=index.js.map