@terra.gl/core 0.0.1-alpha.22 → 0.0.1-alpha.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var vw = (o, t, e) => t in o ? yw(o, t, { enumerable: !0, configurable: !0, writ
3
3
  var S = (o, t, e) => vw(o, typeof t != "symbol" ? t + "" : t, e);
4
4
  import * as ct from "three";
5
5
  import { REVISION as zh, TrianglesDrawMode as ww, TriangleFanDrawMode as Ya, TriangleStripDrawMode as Dh, Mesh as ft, Vector3 as U, Color as _e, FrontSide as ro, Plane as kh, Matrix4 as Me, Vector4 as on, PerspectiveCamera as Li, WebGLRenderTarget as xw, UniformsUtils as qs, UniformsLib as $s, ShaderMaterial as ll, MOUSE as qn, TOUCH as $n, Spherical as $u, Quaternion as en, OrthographicCamera as Rr, Vector2 as Se, Ray as bw, Loader as cl, LoaderUtils as Bi, FileLoader as ri, MeshPhysicalMaterial as xn, SpotLight as Oh, PointLight as Ha, DirectionalLight as eo, InstancedMesh as ul, InstancedBufferAttribute as Ua, Object3D as nn, TextureLoader as so, ImageBitmapLoader as _w, BufferAttribute as tn, InterleavedBuffer as Tw, InterleavedBufferAttribute as _i, LinearMipmapLinearFilter as hl, NearestMipmapLinearFilter as Lw, LinearMipmapNearestFilter as Mw, NearestMipmapNearestFilter as Sw, LinearFilter as Er, NearestFilter as dl, RepeatWrapping as En, MirroredRepeatWrapping as Zw, ClampToEdgeWrapping as Na, PointsMaterial as oo, Material as La, LineBasicMaterial as Kh, MeshStandardMaterial as Xr, DoubleSide as fl, MeshBasicMaterial as gn, PropertyBinding as Vr, BufferGeometry as yn, SkinnedMesh as Yh, LineSegments as Gw, Line as Hh, LineLoop as Ww, Points as Fr, Group as rn, MathUtils as dt, Skeleton as Uh, AnimationClip as Nh, Bone as Ba, InterpolateDiscrete as Iw, InterpolateLinear as Bh, Texture as Qi, VectorKeyframeTrack as ja, NumberKeyframeTrack as Ja, QuaternionKeyframeTrack as Qa, Interpolant as Rw, Box3 as Zi, Sphere as pl, Curve as Pw, MeshPhongMaterial as Ma, MeshLambertMaterial as jh, EquirectangularReflectionMapping as Cw, AmbientLight as Jh, Float32BufferAttribute as ei, Uint16BufferAttribute as Ew, Matrix3 as Vw, Euler as Zr, DataTextureLoader as Aw, HalfFloatType as As, FloatType as Js, DataUtils as Xs, InstancedBufferGeometry as Qh, InstancedInterleavedBuffer as qa, WireframeGeometry as Xw, Line3 as Fw, EventDispatcher as qh, Clock as ml, Scene as zw, FogExp2 as eh, CubeTextureLoader as Dw, WebGLRenderer as kw, PCFSoftShadowMap as Ow, ACESFilmicToneMapping as Kw, CameraHelper as Yw, CubicBezierCurve3 as Hw, PlaneGeometry as ji, Frustum as Uw, Raycaster as gl, CanvasTexture as zr, SpriteMaterial as Dr, Sprite as $i, DynamicDrawUsage as th, NormalBlending as Nw, BackSide as Bw, Shape as jw, ShapeGeometry as Jw, CylinderGeometry as Qw, AdditiveBlending as qw, AnimationMixer as $w, LoopRepeat as e1, LoopOnce as t1, LoadingManager as n1, Box2 as i1, ImageLoader as $h, SRGBColorSpace as r1 } from "three";
6
- const s1 = "0.0.1-alpha.22", Sa = {
6
+ const s1 = "0.0.1-alpha.23", Sa = {
7
7
  name: "Criska"
8
8
  };
9
9
  var Pr = function() {
@@ -16557,7 +16557,7 @@ function I_(o, t) {
16557
16557
  }
16558
16558
  const R_ = `{
16559
16559
  "name": "@terra.gl/core",
16560
- "version": "0.0.1-alpha.22",
16560
+ "version": "0.0.1-alpha.23",
16561
16561
  "type": "module",
16562
16562
  "files": [
16563
16563
  "dist"
@@ -1,4 +1,4 @@
1
- (function(ee,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],m):(ee=typeof globalThis<"u"?globalThis:ee||self,m(ee["terra-gl"]={},ee.THREE))})(this,function(ee,m){"use strict";var Ux=Object.defineProperty;var Bx=(ee,m,ci)=>m in ee?Ux(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:ci}):ee[m]=ci;var Z=(ee,m,ci)=>Bx(ee,typeof m!="symbol"?m+"":m,ci);function ci(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const rt=ci(m),Dh="0.0.1-alpha.22",Ts={name:"Criska"};var Vi=function(){var o=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(p){p.preventDefault(),n(++o%t.children.length)},!1);function e(p){return t.appendChild(p.dom),p}function n(p){for(var f=0;f<t.children.length;f++)t.children[f].style.display=f===p?"block":"none";o=p}var i=(performance||Date).now(),s=i,l=0,u=e(new Vi.Panel("FPS","#0ff","#002")),c=e(new Vi.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=e(new Vi.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:e,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){l++;var p=(performance||Date).now();if(c.update(p-i,200),p>=s+1e3&&(u.update(l*1e3/(p-s),100),s=p,l=0,d)){var f=performance.memory;d.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){i=this.end()},domElement:t,setMode:n}};Vi.Panel=function(o,t,e){var n=1/0,i=0,s=Math.round,l=s(window.devicePixelRatio||1),u=80*l,c=48*l,d=3*l,p=2*l,f=3*l,y=15*l,v=74*l,b=30*l,L=document.createElement("canvas");L.width=u,L.height=c,L.style.cssText="width:80px;height:48px";var M=L.getContext("2d");return M.font="bold "+9*l+"px Helvetica,Arial,sans-serif",M.textBaseline="top",M.fillStyle=e,M.fillRect(0,0,u,c),M.fillStyle=t,M.fillText(o,d,p),M.fillRect(f,y,v,b),M.fillStyle=e,M.globalAlpha=.9,M.fillRect(f,y,v,b),{dom:L,update:function(T,S){n=Math.min(n,T),i=Math.max(i,T),M.fillStyle=e,M.globalAlpha=1,M.fillRect(0,0,u,y),M.fillStyle=t,M.fillText(s(T)+" "+o+" ("+s(n)+"-"+s(i)+")",d,p),M.drawImage(L,f+l,y,v-l,b,f,y,v-l,b),M.fillRect(f+v-l,y,l,b),M.fillStyle=e,M.globalAlpha=.9,M.fillRect(f+v-l,y,l,s((1-T/S)*b))}}};const gr=parseInt(m.REVISION.replace(/\D+/g,"")),Zs=gr>=125?"uv1":"uv2";function Xa(o,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let e=o.getIndex();if(e===null){const l=[],u=o.getAttribute("position");if(u!==void 0){for(let c=0;c<u.count;c++)l.push(c);o.setIndex(l),e=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=e.count-2,i=[];if(e)if(t===m.TriangleFanDrawMode)for(let l=1;l<=n;l++)i.push(e.getX(0)),i.push(e.getX(l)),i.push(e.getX(l+1));else for(let l=0;l<n;l++)l%2===0?(i.push(e.getX(l)),i.push(e.getX(l+1)),i.push(e.getX(l+2))):(i.push(e.getX(l+2)),i.push(e.getX(l+1)),i.push(e.getX(l)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),o}var Zt=Uint8Array,Mn=Uint16Array,Gs=Uint32Array,Da=new Zt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),za=new Zt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),zh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ka=function(o,t){for(var e=new Mn(31),n=0;n<31;++n)e[n]=t+=1<<o[n-1];for(var i=new Gs(e[30]),n=1;n<30;++n)for(var s=e[n];s<e[n+1];++s)i[s]=s-e[n]<<5|n;return[e,i]},Oa=ka(Da,2),Ka=Oa[0],kh=Oa[1];Ka[28]=258,kh[258]=28;for(var Oh=ka(za,0),Kh=Oh[0],Ws=new Mn(32768),Ie=0;Ie<32768;++Ie){var Ln=(Ie&43690)>>>1|(Ie&21845)<<1;Ln=(Ln&52428)>>>2|(Ln&13107)<<2,Ln=(Ln&61680)>>>4|(Ln&3855)<<4,Ws[Ie]=((Ln&65280)>>>8|(Ln&255)<<8)>>>1}for(var Ai=function(o,t,e){for(var n=o.length,i=0,s=new Mn(t);i<n;++i)++s[o[i]-1];var l=new Mn(t);for(i=0;i<t;++i)l[i]=l[i-1]+s[i-1]<<1;var u;if(e){u=new Mn(1<<t);var c=15-t;for(i=0;i<n;++i)if(o[i])for(var d=i<<4|o[i],p=t-o[i],f=l[o[i]-1]++<<p,y=f|(1<<p)-1;f<=y;++f)u[Ws[f]>>>c]=d}else for(u=new Mn(n),i=0;i<n;++i)o[i]&&(u[i]=Ws[l[o[i]-1]++]>>>15-o[i]);return u},Fi=new Zt(288),Ie=0;Ie<144;++Ie)Fi[Ie]=8;for(var Ie=144;Ie<256;++Ie)Fi[Ie]=9;for(var Ie=256;Ie<280;++Ie)Fi[Ie]=7;for(var Ie=280;Ie<288;++Ie)Fi[Ie]=8;for(var Ra=new Zt(32),Ie=0;Ie<32;++Ie)Ra[Ie]=5;var Rh=Ai(Fi,9,1),Yh=Ai(Ra,5,1),Ps=function(o){for(var t=o[0],e=1;e<o.length;++e)o[e]>t&&(t=o[e]);return t},Rt=function(o,t,e){var n=t/8|0;return(o[n]|o[n+1]<<8)>>(t&7)&e},Is=function(o,t){var e=t/8|0;return(o[e]|o[e+1]<<8|o[e+2]<<16)>>(t&7)},Uh=function(o){return(o/8|0)+(o&7&&1)},Bh=function(o,t,e){(e==null||e>o.length)&&(e=o.length);var n=new(o instanceof Mn?Mn:o instanceof Gs?Gs:Zt)(e-t);return n.set(o.subarray(t,e)),n},Nh=function(o,t,e){var n=o.length;if(!n||e&&!e.l&&n<5)return t||new Zt(0);var i=!t||e,s=!e||e.i;e||(e={}),t||(t=new Zt(n*3));var l=function(Ne){var ot=t.length;if(Ne>ot){var je=new Zt(Math.max(ot*2,Ne));je.set(t),t=je}},u=e.f||0,c=e.p||0,d=e.b||0,p=e.l,f=e.d,y=e.m,v=e.n,b=n*8;do{if(!p){e.f=u=Rt(o,c,1);var L=Rt(o,c+1,3);if(c+=3,L)if(L==1)p=Rh,f=Yh,y=9,v=5;else if(L==2){var G=Rt(o,c,31)+257,A=Rt(o,c+10,15)+4,K=G+Rt(o,c+5,31)+1;c+=14;for(var z=new Zt(K),O=new Zt(19),V=0;V<A;++V)O[zh[V]]=Rt(o,c+V*3,7);c+=A*3;for(var Y=Ps(O),I=(1<<Y)-1,D=Ai(O,Y,1),V=0;V<K;){var N=D[Rt(o,c,I)];c+=N&15;var M=N>>>4;if(M<16)z[V++]=M;else{var H=0,j=0;for(M==16?(j=3+Rt(o,c,3),c+=2,H=z[V-1]):M==17?(j=3+Rt(o,c,7),c+=3):M==18&&(j=11+Rt(o,c,127),c+=7);j--;)z[V++]=H}}var q=z.subarray(0,G),J=z.subarray(G);y=Ps(q),v=Ps(J),p=Ai(q,y,1),f=Ai(J,v,1)}else throw"invalid block type";else{var M=Uh(c)+4,T=o[M-4]|o[M-3]<<8,S=M+T;if(S>n){if(s)throw"unexpected EOF";break}i&&l(d+T),t.set(o.subarray(M,S),d),e.b=d+=T,e.p=c=S*8;continue}if(c>b){if(s)throw"unexpected EOF";break}}i&&l(d+131072);for(var re=(1<<y)-1,ie=(1<<v)-1,ae=c;;ae=c){var H=p[Is(o,c)&re],me=H>>>4;if(c+=H&15,c>b){if(s)throw"unexpected EOF";break}if(!H)throw"invalid length/literal";if(me<256)t[d++]=me;else if(me==256){ae=c,p=null;break}else{var ve=me-254;if(me>264){var V=me-257,fe=Da[V];ve=Rt(o,c,(1<<fe)-1)+Ka[V],c+=fe}var Te=f[Is(o,c)&ie],Be=Te>>>4;if(!Te)throw"invalid distance";c+=Te&15;var J=Kh[Be];if(Be>3){var fe=za[Be];J+=Is(o,c)&(1<<fe)-1,c+=fe}if(c>b){if(s)throw"unexpected EOF";break}i&&l(d+131072);for(var et=d+ve;d<et;d+=4)t[d]=t[d-J],t[d+1]=t[d+1-J],t[d+2]=t[d+2-J],t[d+3]=t[d+3-J];d=et}}e.l=p,e.p=ae,e.b=d,p&&(u=1,e.m=y,e.d=f,e.n=v)}while(!u);return d==t.length?t:Bh(t,0,d)},jh=new Zt(0),Jh=function(o){if((o[0]&15)!=8||o[0]>>>4>7||(o[0]<<8|o[1])%31)throw"invalid zlib data";if(o[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Qh(o,t){return Nh((Jh(o),o.subarray(2,-4)),t)}var Hh=typeof TextDecoder<"u"&&new TextDecoder,Eh=0;try{Hh.decode(jh,{stream:!0}),Eh=1}catch{}class qh extends m.Mesh{constructor(t,e={}){super(t),this.isWater=!0;const n=this,i=e.textureWidth!==void 0?e.textureWidth:512,s=e.textureHeight!==void 0?e.textureHeight:512,l=e.clipBias!==void 0?e.clipBias:0,u=e.alpha!==void 0?e.alpha:1,c=e.time!==void 0?e.time:0,d=e.waterNormals!==void 0?e.waterNormals:null,p=e.sunDirection!==void 0?e.sunDirection:new m.Vector3(.70707,.70707,0),f=new m.Color(e.sunColor!==void 0?e.sunColor:16777215),y=new m.Color(e.waterColor!==void 0?e.waterColor:8355711),v=e.eye!==void 0?e.eye:new m.Vector3(0,0,0),b=e.distortionScale!==void 0?e.distortionScale:20,L=e.side!==void 0?e.side:m.FrontSide,M=e.fog!==void 0?e.fog:!1,T=new m.Plane,S=new m.Vector3,G=new m.Vector3,A=new m.Vector3,K=new m.Matrix4,z=new m.Vector3(0,0,-1),O=new m.Vector4,V=new m.Vector3,Y=new m.Vector3,I=new m.Vector4,D=new m.Matrix4,N=new m.PerspectiveCamera,H=new m.WebGLRenderTarget(i,s),j={uniforms:m.UniformsUtils.merge([m.UniformsLib.fog,m.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new m.Matrix4},sunColor:{value:new m.Color(8355711)},sunDirection:{value:new m.Vector3(.70707,.70707,0)},eye:{value:new m.Vector3},waterColor:{value:new m.Color(5592405)}}]),vertexShader:`
1
+ (function(ee,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],m):(ee=typeof globalThis<"u"?globalThis:ee||self,m(ee["terra-gl"]={},ee.THREE))})(this,function(ee,m){"use strict";var Ux=Object.defineProperty;var Bx=(ee,m,ci)=>m in ee?Ux(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:ci}):ee[m]=ci;var Z=(ee,m,ci)=>Bx(ee,typeof m!="symbol"?m+"":m,ci);function ci(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const rt=ci(m),Dh="0.0.1-alpha.23",Ts={name:"Criska"};var Vi=function(){var o=0,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",function(p){p.preventDefault(),n(++o%t.children.length)},!1);function e(p){return t.appendChild(p.dom),p}function n(p){for(var f=0;f<t.children.length;f++)t.children[f].style.display=f===p?"block":"none";o=p}var i=(performance||Date).now(),s=i,l=0,u=e(new Vi.Panel("FPS","#0ff","#002")),c=e(new Vi.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=e(new Vi.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:e,showPanel:n,begin:function(){i=(performance||Date).now()},end:function(){l++;var p=(performance||Date).now();if(c.update(p-i,200),p>=s+1e3&&(u.update(l*1e3/(p-s),100),s=p,l=0,d)){var f=performance.memory;d.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){i=this.end()},domElement:t,setMode:n}};Vi.Panel=function(o,t,e){var n=1/0,i=0,s=Math.round,l=s(window.devicePixelRatio||1),u=80*l,c=48*l,d=3*l,p=2*l,f=3*l,y=15*l,v=74*l,b=30*l,L=document.createElement("canvas");L.width=u,L.height=c,L.style.cssText="width:80px;height:48px";var M=L.getContext("2d");return M.font="bold "+9*l+"px Helvetica,Arial,sans-serif",M.textBaseline="top",M.fillStyle=e,M.fillRect(0,0,u,c),M.fillStyle=t,M.fillText(o,d,p),M.fillRect(f,y,v,b),M.fillStyle=e,M.globalAlpha=.9,M.fillRect(f,y,v,b),{dom:L,update:function(T,S){n=Math.min(n,T),i=Math.max(i,T),M.fillStyle=e,M.globalAlpha=1,M.fillRect(0,0,u,y),M.fillStyle=t,M.fillText(s(T)+" "+o+" ("+s(n)+"-"+s(i)+")",d,p),M.drawImage(L,f+l,y,v-l,b,f,y,v-l,b),M.fillRect(f+v-l,y,l,b),M.fillStyle=e,M.globalAlpha=.9,M.fillRect(f+v-l,y,l,s((1-T/S)*b))}}};const gr=parseInt(m.REVISION.replace(/\D+/g,"")),Zs=gr>=125?"uv1":"uv2";function Xa(o,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let e=o.getIndex();if(e===null){const l=[],u=o.getAttribute("position");if(u!==void 0){for(let c=0;c<u.count;c++)l.push(c);o.setIndex(l),e=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=e.count-2,i=[];if(e)if(t===m.TriangleFanDrawMode)for(let l=1;l<=n;l++)i.push(e.getX(0)),i.push(e.getX(l)),i.push(e.getX(l+1));else for(let l=0;l<n;l++)l%2===0?(i.push(e.getX(l)),i.push(e.getX(l+1)),i.push(e.getX(l+2))):(i.push(e.getX(l+2)),i.push(e.getX(l+1)),i.push(e.getX(l)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),o}var Zt=Uint8Array,Mn=Uint16Array,Gs=Uint32Array,Da=new Zt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),za=new Zt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),zh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ka=function(o,t){for(var e=new Mn(31),n=0;n<31;++n)e[n]=t+=1<<o[n-1];for(var i=new Gs(e[30]),n=1;n<30;++n)for(var s=e[n];s<e[n+1];++s)i[s]=s-e[n]<<5|n;return[e,i]},Oa=ka(Da,2),Ka=Oa[0],kh=Oa[1];Ka[28]=258,kh[258]=28;for(var Oh=ka(za,0),Kh=Oh[0],Ws=new Mn(32768),Ie=0;Ie<32768;++Ie){var Ln=(Ie&43690)>>>1|(Ie&21845)<<1;Ln=(Ln&52428)>>>2|(Ln&13107)<<2,Ln=(Ln&61680)>>>4|(Ln&3855)<<4,Ws[Ie]=((Ln&65280)>>>8|(Ln&255)<<8)>>>1}for(var Ai=function(o,t,e){for(var n=o.length,i=0,s=new Mn(t);i<n;++i)++s[o[i]-1];var l=new Mn(t);for(i=0;i<t;++i)l[i]=l[i-1]+s[i-1]<<1;var u;if(e){u=new Mn(1<<t);var c=15-t;for(i=0;i<n;++i)if(o[i])for(var d=i<<4|o[i],p=t-o[i],f=l[o[i]-1]++<<p,y=f|(1<<p)-1;f<=y;++f)u[Ws[f]>>>c]=d}else for(u=new Mn(n),i=0;i<n;++i)o[i]&&(u[i]=Ws[l[o[i]-1]++]>>>15-o[i]);return u},Fi=new Zt(288),Ie=0;Ie<144;++Ie)Fi[Ie]=8;for(var Ie=144;Ie<256;++Ie)Fi[Ie]=9;for(var Ie=256;Ie<280;++Ie)Fi[Ie]=7;for(var Ie=280;Ie<288;++Ie)Fi[Ie]=8;for(var Ra=new Zt(32),Ie=0;Ie<32;++Ie)Ra[Ie]=5;var Rh=Ai(Fi,9,1),Yh=Ai(Ra,5,1),Ps=function(o){for(var t=o[0],e=1;e<o.length;++e)o[e]>t&&(t=o[e]);return t},Rt=function(o,t,e){var n=t/8|0;return(o[n]|o[n+1]<<8)>>(t&7)&e},Is=function(o,t){var e=t/8|0;return(o[e]|o[e+1]<<8|o[e+2]<<16)>>(t&7)},Uh=function(o){return(o/8|0)+(o&7&&1)},Bh=function(o,t,e){(e==null||e>o.length)&&(e=o.length);var n=new(o instanceof Mn?Mn:o instanceof Gs?Gs:Zt)(e-t);return n.set(o.subarray(t,e)),n},Nh=function(o,t,e){var n=o.length;if(!n||e&&!e.l&&n<5)return t||new Zt(0);var i=!t||e,s=!e||e.i;e||(e={}),t||(t=new Zt(n*3));var l=function(Ne){var ot=t.length;if(Ne>ot){var je=new Zt(Math.max(ot*2,Ne));je.set(t),t=je}},u=e.f||0,c=e.p||0,d=e.b||0,p=e.l,f=e.d,y=e.m,v=e.n,b=n*8;do{if(!p){e.f=u=Rt(o,c,1);var L=Rt(o,c+1,3);if(c+=3,L)if(L==1)p=Rh,f=Yh,y=9,v=5;else if(L==2){var G=Rt(o,c,31)+257,A=Rt(o,c+10,15)+4,K=G+Rt(o,c+5,31)+1;c+=14;for(var z=new Zt(K),O=new Zt(19),V=0;V<A;++V)O[zh[V]]=Rt(o,c+V*3,7);c+=A*3;for(var Y=Ps(O),I=(1<<Y)-1,D=Ai(O,Y,1),V=0;V<K;){var N=D[Rt(o,c,I)];c+=N&15;var M=N>>>4;if(M<16)z[V++]=M;else{var H=0,j=0;for(M==16?(j=3+Rt(o,c,3),c+=2,H=z[V-1]):M==17?(j=3+Rt(o,c,7),c+=3):M==18&&(j=11+Rt(o,c,127),c+=7);j--;)z[V++]=H}}var q=z.subarray(0,G),J=z.subarray(G);y=Ps(q),v=Ps(J),p=Ai(q,y,1),f=Ai(J,v,1)}else throw"invalid block type";else{var M=Uh(c)+4,T=o[M-4]|o[M-3]<<8,S=M+T;if(S>n){if(s)throw"unexpected EOF";break}i&&l(d+T),t.set(o.subarray(M,S),d),e.b=d+=T,e.p=c=S*8;continue}if(c>b){if(s)throw"unexpected EOF";break}}i&&l(d+131072);for(var re=(1<<y)-1,ie=(1<<v)-1,ae=c;;ae=c){var H=p[Is(o,c)&re],me=H>>>4;if(c+=H&15,c>b){if(s)throw"unexpected EOF";break}if(!H)throw"invalid length/literal";if(me<256)t[d++]=me;else if(me==256){ae=c,p=null;break}else{var ve=me-254;if(me>264){var V=me-257,fe=Da[V];ve=Rt(o,c,(1<<fe)-1)+Ka[V],c+=fe}var Te=f[Is(o,c)&ie],Be=Te>>>4;if(!Te)throw"invalid distance";c+=Te&15;var J=Kh[Be];if(Be>3){var fe=za[Be];J+=Is(o,c)&(1<<fe)-1,c+=fe}if(c>b){if(s)throw"unexpected EOF";break}i&&l(d+131072);for(var et=d+ve;d<et;d+=4)t[d]=t[d-J],t[d+1]=t[d+1-J],t[d+2]=t[d+2-J],t[d+3]=t[d+3-J];d=et}}e.l=p,e.p=ae,e.b=d,p&&(u=1,e.m=y,e.d=f,e.n=v)}while(!u);return d==t.length?t:Bh(t,0,d)},jh=new Zt(0),Jh=function(o){if((o[0]&15)!=8||o[0]>>>4>7||(o[0]<<8|o[1])%31)throw"invalid zlib data";if(o[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Qh(o,t){return Nh((Jh(o),o.subarray(2,-4)),t)}var Hh=typeof TextDecoder<"u"&&new TextDecoder,Eh=0;try{Hh.decode(jh,{stream:!0}),Eh=1}catch{}class qh extends m.Mesh{constructor(t,e={}){super(t),this.isWater=!0;const n=this,i=e.textureWidth!==void 0?e.textureWidth:512,s=e.textureHeight!==void 0?e.textureHeight:512,l=e.clipBias!==void 0?e.clipBias:0,u=e.alpha!==void 0?e.alpha:1,c=e.time!==void 0?e.time:0,d=e.waterNormals!==void 0?e.waterNormals:null,p=e.sunDirection!==void 0?e.sunDirection:new m.Vector3(.70707,.70707,0),f=new m.Color(e.sunColor!==void 0?e.sunColor:16777215),y=new m.Color(e.waterColor!==void 0?e.waterColor:8355711),v=e.eye!==void 0?e.eye:new m.Vector3(0,0,0),b=e.distortionScale!==void 0?e.distortionScale:20,L=e.side!==void 0?e.side:m.FrontSide,M=e.fog!==void 0?e.fog:!1,T=new m.Plane,S=new m.Vector3,G=new m.Vector3,A=new m.Vector3,K=new m.Matrix4,z=new m.Vector3(0,0,-1),O=new m.Vector4,V=new m.Vector3,Y=new m.Vector3,I=new m.Vector4,D=new m.Matrix4,N=new m.PerspectiveCamera,H=new m.WebGLRenderTarget(i,s),j={uniforms:m.UniformsUtils.merge([m.UniformsLib.fog,m.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new m.Matrix4},sunColor:{value:new m.Color(8355711)},sunDirection:{value:new m.Vector3(.70707,.70707,0)},eye:{value:new m.Vector3},waterColor:{value:new m.Color(5592405)}}]),vertexShader:`
2
2
  uniform mat4 textureMatrix;
3
3
  uniform float time;
4
4
 
@@ -692,7 +692,7 @@ function print() { __p += __j.call(arguments, '') }
692
692
  }
693
693
  `)}setDiffusionFromObject(e){if(!this.shaderOption.effects?.diffusion)return;const n=new rt.Box3().setFromObject(e);if(n.isEmpty())return;const i=new rt.Vector3;n.getCenter(i);const s=[new rt.Vector3(n.min.x,n.min.y,n.min.z),new rt.Vector3(n.max.x,n.max.y,n.max.z)];let l=0;s.forEach(u=>{const c=i.distanceTo(u);c>l&&(l=c)}),this.shaderOption.effects.diffusion={...this.shaderOption.effects.diffusion,center:i,maxDistance:l},this.needsUpdate=!0}updateBoundingBox(e,n){this.shaderOption.minY=e,this.shaderOption.maxY=n,this.needsUpdate=!0}updateEffects(e){this.shaderOption.effects={...this.shaderOption.effects,...e},this.needsUpdate=!0}animate(){requestAnimationFrame(()=>this.animate()),this.time.value=this.clock.getElapsedTime(),this.startTime.value<1&&(this.startTime.value+=.01)}}const kp={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class kl extends ji{constructor(e){super(e);Z(this,"_type","Model");Z(this,"_emissive",!1);Z(this,"_emissiveIntensity",1);Z(this,"_emissiveColor","#ffffff");Z(this,"_mixer",null);Z(this,"_currentAction",null);Z(this,"_animations",[]);Z(this,"_clock",new m.Clock);Z(this,"_autoUpdate",!0);Z(this,"_animationRequestId",null);Z(this,"_iscity",!1);this._emissive=e.emissive||!1,this._emissiveIntensity=e.emissiveIntensity||1,this._emissiveColor=e.emissiveColor||"#ffffff",this.castShadow=e.castShadow||!1,this.receiveShadow=e.receiveShadow||!1,this._iscity=e.iscity||!1}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this.modelunino=await this._createObject(this._style),this._threeGeometry=this.modelunino.model,this._threeGeometry.userData._type="Model",this.modelunino.animations&&this.modelunino.animations.length>0&&(this._animations=this.modelunino.animations,this._mixer=new m.AnimationMixer(this._threeGeometry),this._startAnimationLoop(),this.playAnimation({name:this._animations[0].name,loop:!0,speed:1.5,fadeInDuration:.5,fadeOutDuration:.3})),this._updateGeometry(),this.setShadows({cast:this.castShadow,receive:this.receiveShadow}),this._applyEmissionProperties(),this._iscity&&this._rendercity())}async _createObject(e){switch(e.config.type){case"fbx":case"gltf":return Yf(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_applyEmissionProperties(){this._threeGeometry&&this._threeGeometry.traverse(e=>{if("material"in e){const n=e.material;n&&(n.emissiveIntensity=this._emissive?this._emissiveIntensity:0,n.emissive&&n.emissive.setStyle(this._emissiveColor))}})}get emissive(){return this._emissive}set emissive(e){this._emissive=e,this._applyEmissionProperties()}get emissiveIntensity(){return this._emissiveIntensity}set emissiveIntensity(e){this._emissiveIntensity=e,this._applyEmissionProperties()}get emissiveColor(){return this._emissiveColor}set emissiveColor(e){this._emissiveColor=e,this._applyEmissionProperties()}setEmission(e,n,i){this._emissive=e,n!==void 0&&(this._emissiveIntensity=n),i!==void 0&&(this._emissiveColor=i),this._applyEmissionProperties()}async setShadows(e){this.castShadow=e.cast,this.receiveShadow=e.receive,this._threeGeometry&&this._threeGeometry.traverse(n=>{n.isMesh&&n.material&&(n.castShadow=e.cast,n.receiveShadow=e.receive)})}playAnimation(e){if(!this._mixer||this._animations.length===0){console.warn("模型没有可用的动画");return}this._currentAction&&(e.fadeOutDuration&&e.fadeOutDuration>0?this._currentAction.fadeOut(e.fadeOutDuration):this._currentAction.stop());const n=typeof e.name=="number"?this._animations[e.name]:this._animations.find(i=>i.name===e.name);if(!n){console.warn(`找不到动画: ${e.name}`);return}this._currentAction=this._mixer.clipAction(n),this._currentAction.setLoop(e.loop?m.LoopRepeat:m.LoopOnce,e.loop?1/0:1),this._currentAction.timeScale=e.speed||1,this._currentAction.time=e.startAt||0,this._currentAction.setEffectiveWeight(e.weight||1),e.fadeInDuration&&e.fadeInDuration>0&&this._currentAction.fadeIn(e.fadeInDuration),this._currentAction.play(),this._autoUpdate&&this._animationRequestId===null&&this._startAnimationLoop()}stopAnimation(e={}){this._currentAction&&(e.fadeDuration&&e.fadeDuration>0?(this._currentAction.fadeOut(e.fadeDuration),setTimeout(()=>{this._currentAction&&(this._currentAction.stop(),this._currentAction=null)},e.fadeDuration*1e3)):(this._currentAction.stop(),this._currentAction=null))}setAnimationPaused(e){this._currentAction&&(this._currentAction.paused=e.paused)}setAnimationSpeed(e){this._currentAction&&(this._currentAction.timeScale=e.speed)}updateAnimation(e){this._mixer&&this._mixer.update(e.deltaTime)}getAnimationNames(){return this._animations.map(e=>e.name)}getCurrentAnimationName(){return this._currentAction?this._currentAction.getClip().name:null}getAnimationDuration(e){let n;return typeof e.name=="number"?n=this._animations[e.name]:n=this._animations.find(i=>i.name===e.name),n?n.duration:null}dispose(){this._stopAnimationLoop(),this._mixer&&(this._mixer.stopAllAction(),this._mixer.uncacheRoot(this._threeGeometry)),super.dispose()}_startAnimationLoop(){if(!this._autoUpdate||this._animationRequestId!==null)return;const e=()=>{if(this._mixer){const n=this._clock.getDelta();this._mixer.update(n)}this._animationRequestId=requestAnimationFrame(e)};this._clock.start(),this._animationRequestId=requestAnimationFrame(e)}_stopAnimationLoop(){this._animationRequestId!==null&&(cancelAnimationFrame(this._animationRequestId),this._animationRequestId=null),this._clock.stop()}setAutoUpdate(e){this._autoUpdate=e,e?this._startAnimationLoop():this._stopAnimationLoop()}_computeOverlayVertices(e){const n=e.feature;if(n&&Array.isArray(n._vertexPoints)&&n._vertexPoints.length>=6){const d=n.getMap?.()||this.getMap();if(d&&d.prjcenter){const p=d.prjcenter,f=n._vertexPoints,y=[];for(let v=0;v+2<f.length;v+=3){const b=f[v],L=f[v+2],M=p.x+b,T=p.z+L;y.push(new m.Vector2(M,T))}if(y.length>=3)return y}}const i=this.getMap();if(!i||!e.geometry)return null;const s=e.geometry;let l;if(s.type==="Polygon")l=s.coordinates;else if(s.type==="MultiPolygon"){if(!s.coordinates.length)return null;l=s.coordinates[0]}else return null;if(!l.length||!l[0].length)return null;const u=l[0],c=[];for(const d of u){const p=d[0],f=d[1],y=i.geo2world(new m.Vector3(p,f,0));c.push(new m.Vector2(y.x,y.z))}return c.length<3?null:c}_rendercity(){const e=this.getLayer();let n=null;if(e&&e.getRegionOverlays){const i=e.getRegionOverlays()||[];if(i.length){const s=i.filter(u=>(u.mode??"overlay")==="overlay").sort((u,c)=>(u.zIndex??0)-(c.zIndex??0)),l=s[s.length-1];if(l&&(l.geometry||l.feature)){const u=this._computeOverlayVertices(l);u&&u.length>=3&&(n={color:new m.Color(l.color??"#00FF88"),opacity:l.opacity??.3,vertices:u})}}}this.traverse(async i=>{if(i instanceof m.Mesh&&i.material){if(i.castShadow=!0,i.name==="building"){const s=new zp({color:new m.Color("#6BA7EC").multiplyScalar(1.8),opacity:.9,shaderOption:{minY:0,maxY:50,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!0,color:new m.Color("#FFFFF"),width:300,speed:.05},flow:{enabled:!1,color:new m.Color("#FFFFF"),range:1e3,speed:3e3},sweep:{enabled:!0,color:new m.Color("#ffffff"),width:3,speed:5}}},regionOverlay:n||void 0}),l=new m.Box3().setFromObject(i);s.updateBoundingBox(l.min.y,l.max.y),s.setDiffusionFromObject(i),i.receiveShadow=!1,i.material=s,i.material.needsUpdate=!0}i.name==="grass"&&(i.castShadow=!1,i.receiveShadow=!0,i.material.color=new m.Color("#81e4d8ff)").multiplyScalar(.7),i.material.metalness=.2,i.material.roughness=.8,["metalnessMap","normalMap","roughnessMap","specularColorMap"].forEach(s=>{const l=i.material[s];l&&(l.wrapS=l.wrapT=m.RepeatWrapping,l.repeat.set(.3,.3),l.needsUpdate=!0)}),i.material.normalScale=new m.Vector2(3,3))}})}}kl.mergeOptions(kp);const Op={};class Ol extends ji{constructor(e){super(e);Z(this,"_type","Cloud")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._disposeGeometry();const e=this.getLayer();this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry.renderOrder=99,e&&(e._clouds.add(this._threeGeometry),e._clouds.updateMatrixWorld()))}async _createObject(e){switch(e.config.type){case"cloud":return Jf(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Ol.mergeOptions(Op);const Kp={};class Kl extends ji{constructor(e){super(e);Z(this,"_type","Label")}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"canvas-label-fixed":return Hf(e.config,new m.Vector3(0,0,0),this.getMap());case"canvas-label":return Qf(e.config,new m.Vector3(0,0,0));default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Kl.mergeOptions(Kp);const Rp={};class Rl extends ji{constructor(e){super(e);Z(this,"_type","TPoints");Z(this,"_geometries");this._geometries=e.geometries}async _toThreeJSGeometry(){this._position=this._coordsTransform(),this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}_updateGeometry(){this._threeGeometry&&(this._threeGeometry.points&&this.add(this._threeGeometry.points),this._threeGeometry.InstancedCol&&this.add(this._threeGeometry.InstancedCol),this.updateMatrixWorld(!0))}async _createObject(e){switch(e.config.type){case"light":return sp(e.config,this._geometries,this.getMap());default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Rl.mergeOptions(Rp);function Pr(o,t){if(!o||o===!0)return!0;if(!Array.isArray(o))return!!o;switch(o[0]){case"all":return o.slice(1).every(n=>Pr(n,t));case"any":return o.slice(1).some(n=>Pr(n,t));case"!":return!Pr(o[1],t);case"==":{const n=st(o[1],t),i=st(o[2],t);return Ir(n)==Ir(i)}case"!=":{const n=st(o[1],t),i=st(o[2],t);return Ir(n)!=Ir(i)}case">":{const n=st(o[1],t),i=st(o[2],t);return Zn(n)>Zn(i)}case"<":{const n=st(o[1],t),i=st(o[2],t);return Zn(n)<Zn(i)}case">=":{const n=st(o[1],t),i=st(o[2],t);return Zn(n)>=Zn(i)}case"<=":{const n=st(o[1],t),i=st(o[2],t);return Zn(n)<=Zn(i)}case"in":{const n=st(o[1],t);return o.slice(2).map(s=>st(s,t)).includes(n)}case"!in":{const n=st(o[1],t);return!o.slice(2).map(s=>st(s,t)).includes(n)}case"has":{const n=o[1];return t!=null&&Object.prototype.hasOwnProperty.call(t,n)}case"!has":{const n=o[1];return!(t!=null&&Object.prototype.hasOwnProperty.call(t,n))}default:return!0}}function st(o,t){if(Array.isArray(o))switch(o[0]){case"get":return t?t[o[1]]:void 0;default:return o}return o}function Ir(o){if(o==null)return null;if(typeof o=="string"){const t=Number(o);if(!isNaN(t)&&o.trim()!=="")return t}return typeof o=="boolean"?o?1:0:o}function Zn(o){if(o==null)return 0;if(typeof o=="number")return o;if(typeof o=="boolean")return o?1:0;if(typeof o=="string"){const t=Number(o);return isNaN(t)?0:t}return Number(o)}class ao extends Bn{constructor(e,n){super(e,n);Z(this,"TILE_SIZE");Z(this,"EXTENT");Z(this,"style");Z(this,"_tileFeatureMap",new Map);Z(this,"_activeFeatureFilter");this.TILE_SIZE=n.tileSize??256,this.EXTENT=n.extent??4096,this.style=n.style||[],this._onMapUpdate=this._onMapUpdate.bind(this)}processTileData(e,n){const i=this.getMap(),s=`${e.z}-${e.x}-${e.y}`,l=this._tileFeatureMap.get(s);if(l&&l.length>0){l.forEach(p=>{p.visible=!0,this.children.some(f=>f&&p&&f.uuid===p.uuid)||p.addTo(this)});return}const u=n.vectorData;if(!u||!u.layers||!i||this.style.length===0)return;const c=[],d=this.style;Object.keys(u.layers).forEach(p=>{const f=u.layers[p];for(let y=0;y<f.length;y++){const v=f[y],b=v.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(v.properties))continue;let L=null;for(const M of d)if(this._evaluateFilter(M.filter,v.properties,p,v.geometry.type)){L=M.style;break}if(L){const M={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:b,extent:this.EXTENT,tileSize:this.TILE_SIZE},T=this._createFeatureInstance(v.geometry,v.geometry.type,L,v.properties);T&&(T.userData.tileData=M,T.style=Wt.create(L),T.addTo(this),T.initializeGeometry(),c.push(T))}}}),this._tileFeatureMap.set(s,c)}_evaluateFilter(e,n,i,s){if(!e||e===!0)return!0;const l={...n,$layer:i,$type:s};return Pr(e,l)}hideFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&n.forEach(i=>{i.visible=!1})}removeFeaturesByTileKey(e){this._removeFeaturesByTileKey(e)}_removeFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&(n.forEach(i=>{i._remove()}),this._tileFeatureMap.delete(e))}_createFeatureInstance(e,n,i,s){const u={geometry:{ismvt:!0,...e},style:i,userData:s};switch(n){case"Point":return new ro(u);case"LineString":return new so(u);default:return null}}setFeatureFilter(e){this._activeFeatureFilter=e}clearFeatureFilter(){this._activeFeatureFilter=void 0}setOpacity(e){this.opacity=e,this._tileFeatureMap.forEach(n=>{n.forEach(i=>{i.material&&(i.material.opacity=e,i.material.transparent=e<1)})})}_onMapUpdate(){}validateFeature(e){return e instanceof fn}dispose(){this._tileFeatureMap.forEach((e,n)=>{this._removeFeaturesByTileKey(n)}),super.dispose()}}class Yl extends Tr{constructor(e,n){super(e,n);Z(this,"isTileLayer",!0);Z(this,"layerType","base");Z(this,"isBaseLayer",!1);Z(this,"_enabled",!0);Z(this,"_visible",!0);Z(this,"_rootTile");Z(this,"_loader");Z(this,"_LODThreshold",1);Z(this,"isSceneLayer",!1);Z(this,"opacity",1);Z(this,"source");Z(this,"projection");Z(this,"minLevel",2);Z(this,"maxLevel",19);this.layerId=e,this.source=n.source,this.projection=n.projection,this.minLevel=n.minLevel??2,this.maxLevel=n.maxLevel??19,this._LODThreshold=n.LODThreshold??1,this.opacity=n.opacity??1,this.name=`Layer-${e}`,this._loader=this.createLoader(),this._rootTile=new nn,this._rootTile.matrixAutoUpdate=!0,this._rootTile.scale.set(this.projection.mapWidth,this.projection.mapHeight,1),this.add(this._rootTile),this._rootTile.updateMatrix(),this.layerId=e,this.name==="Layer-label-layer"&&this.position.set(0,0,1)}get LODThreshold(){return this._LODThreshold}set LODThreshold(e){this._LODThreshold=e}get loader(){return this._loader}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._rootTile&&(this._rootTile.visible=e&&this._visible)}get ivisible(){return this._visible&&super._visible}set ivisible(e){this._visible=e,this._rootTile&&(this._rootTile.visible=e&&this._enabled)}update(e){if(!(!this._enabled||!this._visible)){try{this._rootTile.update({camera:e,loader:this._loader,minLevel:this.minLevel,maxLevel:this.maxLevel,LODThreshold:this.LODThreshold})}catch{}console.groupEnd()}}_debugTileTree(){this._rootTile.traverse(e=>{e.isTile&&(e.loaded,e.visible,e.inFrustum,e.loaded)})}_getLODThreshold(){return 1}_getCurrentTileLevel(){let e=0;return this._rootTile.traverse(n=>{n.isTile&&n.loaded&&(e=Math.max(e,n.z))}),`最大层级: ${e}`}dispose(){this.remove(this._rootTile),this._rootTile.reload(this._loader)}reload(){this._rootTile.reload(this._loader)}setElevation(e){this.position.y=e,this.updateMatrix(),this.updateMatrixWorld(!0)}raiseElevation(e){this.position.z+=e,this.updateMatrix(),this.updateMatrixWorld(!0)}getElevation(){return this.position.y}}class Ul extends m.LoadingManager{constructor(){super(...arguments);Z(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const De={manager:new Ul,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(o){De.imgLoaderMap.set(o.dataType,o),o.info.author=o.info.author??Ts.name},registerGeometryLoader(o){De.demLoaderMap.set(o.dataType,o),o.info.author=o.info.author??Ts.name},registerMeshLoader(o){De.meshLoaderMap.set(o.dataType,o),o.info.author=o.info.author??Ts.name},getMaterialLoader(o){const t=De.imgLoaderMap.get(o.dataType);if(t)return t;throw`Source dataType "${o.dataType}" is not support!`},getGeometryLoader(o){const t=De.demLoaderMap.get(o.dataType);if(t)return t;throw`Source dataType "${o.dataType}" is not support!`},getMeshLoader(o){const t=De.meshLoaderMap.get(o.dataType);if(t)return t;throw`Source dataType "${o.dataType}" is not support!`}};class Yp{constructor(t){Z(this,"worker");this.worker=t()}async run(t,e){return new Promise(n=>{this.worker.onmessage=i=>{n(i.data)},this.worker.postMessage(t,e)})}terminate(){this.worker.terminate()}}const Up=4096,Bl=Math.PI;function lo(o,t){const e=Math.floor(o[0]*t),n=Math.floor(o[1]*t),i=Math.floor((o[2]-o[0])*t),s=Math.floor((o[3]-o[1])*t);return{sx:e,sy:n,sw:i,sh:s}}function co(o,t,e,n){if(n<o.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=o.maxLevel)return{url:o._getUrl(t,e,n),clipBounds:[0,0,1,1]};const i=Bp(t,e,n,o.maxLevel),s=i.parentNO;return{url:o._getUrl(s.x,s.y,s.z),clipBounds:i.bounds}}function Bp(o,t,e,n){const i=e-n,s={x:o>>i,y:t>>i,z:e-i},l=Math.pow(2,i),u=Math.pow(.5,i),c=o%l/l-.5+u/2,d=t%l/l-.5+u/2,p=new m.Vector2(c,d),f=new m.Box2().setFromCenterAndSize(p,new m.Vector2(u,u)),y=[f.min.x+.5,f.min.y+.5,f.max.x+.5,f.max.y+.5];return{parentNO:s,bounds:y}}function uo(o,t,e,n,i=Up){const{x:s,y:l}=o,u=(t+s/i)/Math.pow(2,n),c=(e+l/i)/Math.pow(2,n),d=u*360-180,f=Math.atan(Math.sinh(Bl*(1-2*c)))*180/Bl;return[parseFloat(d.toFixed(8)),parseFloat(f.toFixed(8))]}function Np(o,t,e,n){if(!o||!o.coordinates)throw new Error("无效的geometry数据格式");const i={type:o.type,coordinates:null};function s(l){if(typeof l=="object"&&l.x!==void 0&&l.y!==void 0)return uo(l,t,e,n);if(Array.isArray(l)&&l.length>0){const u=l[0];return typeof u=="object"&&u.x!==void 0&&u.y!==void 0?l.map(c=>uo(c,t,e,n)):l.map(c=>s(c))}return l}return i.coordinates=s(o.coordinates),i}class Cr{constructor(){Z(this,"_imgSource",[]);Z(this,"_demSource");Z(this,"_vtSource");Z(this,"manager",De.manager)}get imgSource(){return this._imgSource}set imgSource(t){this._imgSource=t}get demSource(){return this._demSource}set demSource(t){this._demSource=t}get vtSource(){return this._vtSource}set vtSource(t){this._vtSource=t}async load(t){const e=await this.loadGeometry(t),n=await this.loadMaterial(t);console.assert(!!n&&!!e);for(let i=0;i<n.length;i++)e.addGroup(0,1/0,i);return{materials:n,geometry:e}}unload(t){const e=t.material,n=t.geometry;for(let i=0;i<e.length;i++)e[i].dispose();n.dispose()}async loadGeometry(t){let e;if(this.demSource&&t.z>=this.demSource.minLevel&&this._isBoundsInSourceBounds(this.demSource,t.bounds)){const n=De.getGeometryLoader(this.demSource),i=this.demSource;e=await n.load({source:i,...t}).catch(s=>(console.error("Load material error",i.dataType,t.x,t.y,t.z),new m.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else if(this.vtSource&&t.z>=this.vtSource.minLevel&&this._isBoundsInSourceBounds(this.vtSource,t.bounds)){const n=De.getMeshLoader(this.vtSource),i=this.vtSource;e=await n.load({source:i,...t}).catch(s=>(console.error("Load geometry error",i.dataType,t.x,t.y,t.z),new m.PlaneGeometry)),e.addEventListener("dispose",()=>{n.unload&&n.unload(e)})}else e=new m.PlaneGeometry;return e}async loadMaterial(t){const n=this.imgSource.filter(i=>t.z>=i.minLevel&&this._isBoundsInSourceBounds(i,t.bounds)).map(async i=>{const s=De.getMaterialLoader(i),l=await s.load({source:i,...t}).catch(c=>(console.error("Load material error",i.dataType,t.x,t.y,t.z),new m.MeshBasicMaterial)),u=c=>{s.unload&&s.unload(c.target),c.target.removeEventListener("dispose",u)};return l instanceof m.MeshBasicMaterial||l.addEventListener("dispose",u),l});return Promise.all(n)}_isBoundsInSourceBounds(t,e){const n=t._projectionBounds;return!(e[2]<n[0]||e[3]<n[1]||e[0]>n[2]||e[1]>n[3])}}function Ji(...o){const t=o,e=t&&t.length>1&&t[0].constructor||null;if(!e)throw new Error("concatenateTypedArrays - incorrect quantity of arguments or arguments have incompatible data types");const n=t.reduce((l,u)=>l+u.length,0),i=new e(n);let s=0;for(const l of t)i.set(l,s),s+=l.length;return i}function Nl(o,t,e,n){const i=n?Jp(n,o.position.value):jp(t),s=i.length,l=new Float32Array(s*6),u=new Float32Array(s*4),c=new t.constructor(s*6),d=new Float32Array(s*6);for(let f=0;f<s;f++)Qp({edge:i[f],edgeIndex:f,attributes:o,skirtHeight:e,newPosition:l,newTexcoord0:u,newTriangles:c,newNormals:d});o.position.value=Ji(o.position.value,l),o.texcoord.value=Ji(o.texcoord.value,u),o.normal.value=Ji(o.normal.value,d);const p=Ji(t,c);return{attributes:o,indices:p}}function jp(o){const t=[],e=Array.isArray(o)?o:Array.from(o);for(let i=0;i<e.length;i+=3){const s=e[i],l=e[i+1],u=e[i+2];t.push([s,l],[l,u],[u,s])}t.sort(([i,s],[l,u])=>{const c=Math.min(i,s),d=Math.min(l,u);return c!==d?c-d:Math.max(i,s)-Math.max(l,u)});const n=[];for(let i=0;i<t.length;i++)i+1<t.length&&t[i][0]===t[i+1][1]&&t[i][1]===t[i+1][0]?i++:n.push(t[i]);return n}function Jp(o,t){const e=(i,s)=>{i.sort(s)};e(o.westIndices,(i,s)=>t[3*i+1]-t[3*s+1]),e(o.eastIndices,(i,s)=>t[3*s+1]-t[3*i+1]),e(o.southIndices,(i,s)=>t[3*s]-t[3*i]),e(o.northIndices,(i,s)=>t[3*i]-t[3*s]);const n=[];return Object.values(o).forEach(i=>{if(i.length>1)for(let s=0;s<i.length-1;s++)n.push([i[s],i[s+1]])}),n}function Qp({edge:o,edgeIndex:t,attributes:e,skirtHeight:n,newPosition:i,newTexcoord0:s,newTriangles:l,newNormals:u}){const c=e.position.value.length,d=t*2,p=d+1;i.set(e.position.value.subarray(o[0]*3,o[0]*3+3),d*3),i[d*3+2]=i[d*3+2]-n,i.set(e.position.value.subarray(o[1]*3,o[1]*3+3),p*3),i[p*3+2]=i[p*3+2]-n,s.set(e.texcoord.value.subarray(o[0]*2,o[0]*2+2),d*2),s.set(e.texcoord.value.subarray(o[1]*2,o[1]*2+2),p*2);const f=t*2*3;l[f]=o[0],l[f+1]=c/3+p,l[f+2]=o[1],l[f+3]=c/3+p,l[f+4]=o[0],l[f+5]=c/3+d,u[f]=0,u[f+1]=0,u[f+2]=1,u[f+3]=0,u[f+4]=0,u[f+5]=1}function jl(o){if(o.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${o.length}!`);const t=Math.floor(Math.sqrt(o.length)),e=t,n=t,i=ho(n,e);return{attributes:Hp(o,n,e),indices:i}}function Hp(o,t,e){const n=e*t,i=new Float32Array(n*3),s=new Float32Array(n*2);let l=0;for(let u=0;u<t;u++)for(let c=0;c<e;c++){const d=c/(e-1),p=u/(t-1);s[l*2]=d,s[l*2+1]=p,i[l*3]=d-.5,i[l*3+1]=p-.5,i[l*3+2]=o[(t-u-1)*e+c],l++}return{position:{value:i,size:3},texcoord:{value:s,size:2},normal:{value:fo(i,ho(t,e)),size:3}}}function ho(o,t){const e=6*(t-1)*(o-1),n=new Uint16Array(e);let i=0;for(let s=0;s<o-1;s++)for(let l=0;l<t-1;l++){const u=s*t+l,c=u+1,d=u+t,p=d+1,f=i*6;n[f]=u,n[f+1]=c,n[f+2]=d,n[f+3]=d,n[f+4]=c,n[f+5]=p,i++}return n}function fo(o,t){const e=new Float32Array(o.length);for(let n=0;n<t.length;n+=3){const i=t[n]*3,s=t[n+1]*3,l=t[n+2]*3,u=o[i],c=o[i+1],d=o[i+2],p=o[s],f=o[s+1],y=o[s+2],v=o[l],b=o[l+1],L=o[l+2],M=p-u,T=f-c,S=y-d,G=v-u,A=b-c,K=L-d,z=T*K-S*A,O=S*G-M*K,V=M*A-T*G,Y=Math.sqrt(z*z+O*O+V*V),I=[0,0,1];if(Y>0){const D=1/Y;I[0]=z*D,I[1]=O*D,I[2]=V*D}for(let D=0;D<3;D++)e[i+D]=e[s+D]=e[l+D]=I[D]}return e}class fi extends m.PlaneGeometry{constructor(){super(...arguments);Z(this,"type","TileGeometry")}setData(e,n=1e3){let i=e instanceof Float32Array?jl(e):e;i=Nl(i.attributes,i.indices,n);const{attributes:s,indices:l}=i;return this.setIndex(new m.BufferAttribute(l,1)),this.setAttribute("position",new m.BufferAttribute(s.position.value,s.position.size)),this.setAttribute("uv",new m.BufferAttribute(s.texcoord.value,s.texcoord.size)),this.setAttribute("normal",new m.BufferAttribute(s.normal.value,s.normal.size)),this.computeBoundingBox(),this.computeBoundingSphere(),this}}class Jl{constructor(t=257){Z(this,"gridSize");Z(this,"numTriangles");Z(this,"numParentTriangles");Z(this,"indices");Z(this,"coords");this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let i=n+2,s=0,l=0,u=0,c=0,d=0,p=0;for(i&1?u=c=d=e:s=l=p=e;(i>>=1)>1;){const y=s+u>>1,v=l+c>>1;i&1?(u=s,c=l,s=d,l=p):(s=u,l=c,u=d,c=p),d=y,p=v}const f=n*4;this.coords[f+0]=s,this.coords[f+1]=l,this.coords[f+2]=u,this.coords[f+3]=c}}createTile(t){return new Ep(t,this)}}class Ep{constructor(t,e){Z(this,"martini");Z(this,"terrain");Z(this,"errors");const n=e.gridSize;if(t.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:n,gridSize:i}=this.martini,{terrain:s,errors:l}=this;for(let u=t-1;u>=0;u--){const c=u*4,d=n[c+0],p=n[c+1],f=n[c+2],y=n[c+3],v=d+f>>1,b=p+y>>1,L=v+b-p,M=b+d-v,T=(s[p*i+d]+s[y*i+f])/2,S=b*i+v,G=Math.abs(T-s[S]);if(l[S]=Math.max(l[S],G),u<e){const A=(p+M>>1)*i+(d+L>>1),K=(y+M>>1)*i+(f+L>>1);l[S]=Math.max(l[S],l[A],l[K])}}}getGeometryData(t=0){const{gridSize:e,indices:n}=this.martini,{errors:i}=this;let s=0,l=0;const u=e-1;let c,d,p=0;n.fill(0);function f(S,G,A,K,z,O){const V=S+A>>1,Y=G+K>>1;Math.abs(S-z)+Math.abs(G-O)>1&&i[Y*e+V]>t?(f(z,O,S,G,V,Y),f(A,K,z,O,V,Y)):(c=G*e+S,d=K*e+A,p=O*e+z,n[c]===0&&(n[c]=++s),n[d]===0&&(n[d]=++s),n[p]===0&&(n[p]=++s),l++)}f(0,0,u,u,u,0),f(u,u,0,0,0,u);const y=s*2,v=l*3,b=new Uint16Array(y),L=new Uint32Array(v);let M=0;function T(S,G,A,K,z,O){const V=S+A>>1,Y=G+K>>1;if(Math.abs(S-z)+Math.abs(G-O)>1&&i[Y*e+V]>t)T(z,O,S,G,V,Y),T(A,K,z,O,V,Y);else{const I=n[G*e+S]-1,D=n[K*e+A]-1,N=n[O*e+z]-1;b[2*I]=S,b[2*I+1]=G,b[2*D]=A,b[2*D+1]=K,b[2*N]=z,b[2*N+1]=O,L[M++]=I,L[M++]=D,L[M++]=N}}return T(0,0,u,u,u,0),T(u,u,0,0,0,u),{attributes:this._getMeshAttributes(this.terrain,b,L),indices:L}}_getMeshAttributes(t,e,n){const i=Math.floor(Math.sqrt(t.length)),s=i-1,l=e.length/2,u=new Float32Array(l*3),c=new Float32Array(l*2);for(let p=0;p<l;p++){const f=e[p*2],y=e[p*2+1],v=y*i+f;u[3*p+0]=f/s-.5,u[3*p+1]=.5-y/s,u[3*p+2]=t[v],c[2*p+0]=f/s,c[2*p+1]=1-y/s}const d=fo(u,n);return{position:{value:u,size:3},texcoord:{value:c,size:2},normal:{value:d,size:3}}}}class po{constructor(){Z(this,"info",{version:"0.10.0",description:"Terrain loader base class"});Z(this,"dataType","")}async load(t){const{source:e,x:n,y:i,z:s}=t,{url:l,clipBounds:u}=co(e,n,i,s);if(!l)return new fi;const c=await this.doLoad(l,{source:e,x:n,y:i,z:s,bounds:u});return De.manager.parseEnd(l),c}}class mo extends m.MeshStandardMaterial{constructor(t={}){super({transparent:!0,side:m.FrontSide,...t})}setTexture(t){this.map=t,this.needsUpdate=!0}dispose(){const t=this.map;t&&(t.image instanceof ImageBitmap&&t.image.close(),t.dispose())}}var $e=(o=>(o[o.Unknown=0]="Unknown",o[o.Point=1]="Point",o[o.Linestring=2]="Linestring",o[o.Polygon=3]="Polygon",o))($e||{});class Ql{render(t,e,n,i,s=1){switch(t.lineCap="round",t.lineJoin="round",(i.shadowBlur??0)>0&&(t.shadowBlur=i.shadowBlur??2,t.shadowColor=i.shadowColor??"black",t.shadowOffsetX=i.shadowOffset?i.shadowOffset[0]:0,t.shadowOffsetY=i.shadowOffset?i.shadowOffset[1]:0),e){case $e.Point:t.textAlign="center",t.textBaseline="middle",t.font=i.font??"14px Arial",t.fillStyle=i.fontColor??"white",this._renderPointText(t,n,s,i.textField??"name",i.fontOffset??[0,-8]);break;case $e.Linestring:this._renderLineString(t,n,s);break;case $e.Polygon:this._renderPolygon(t,n,s);break;default:console.warn(`Unknown feature type: ${e}`)}(i.fill||e===$e.Point)&&(t.globalAlpha=i.fillOpacity||.5,t.fillStyle=i.fillColor||i.color||"#3388ff",t.fill(i.fillRule||"evenodd")),(i.stroke??!0)&&(i.weight??1)>0&&(t.globalAlpha=i.opacity||1,t.lineWidth=i.weight||1,t.strokeStyle=i.color||"#3388ff",t.setLineDash(i.dashArray||[]),t.stroke())}_renderPointText(t,e,n=1,i="name",s=[0,0]){const l=e.geometry;t.beginPath();for(const c of l)for(let d=0;d<c.length;d++){const p=c[d];t.arc(p.x*n,p.y*n,2,0,2*Math.PI)}const u=e.properties;u&&u[i]&&t.fillText(u[i],l[0][0].x*n+s[0],l[0][0].y*n+s[1])}_renderLineString(t,e,n){const i=e.geometry;t.beginPath();for(const s of i)for(let l=0;l<s.length;l++){const{x:u,y:c}=s[l];l===0?t.moveTo(u*n,c*n):t.lineTo(u*n,c*n)}}_renderPolygon(t,e,n){const i=e.geometry;t.beginPath();for(let s=0;s<i.length;s++){const l=i[s];for(let u=0;u<l.length;u++){const{x:c,y:d}=l[u];u===0?t.moveTo(c*n,d*n):t.lineTo(c*n,d*n)}t.closePath()}}}class go{constructor(){Z(this,"info",{version:"0.10.0",description:"Image loader base class"});Z(this,"dataType","")}async load(t){const{source:e,x:n,y:i,z:s}=t,l=new mo,{url:u,clipBounds:c}=co(e,n,i,s);if(u){const d=await this.doLoad(u,{source:e,x:n,y:i,z:s,bounds:c});l.map=d,De.manager.parseEnd(u)}return l}}class qp{constructor(){Z(this,"info",{version:"0.10.0",description:"Canvas tile abstract loader"});Z(this,"dataType","")}async load(t){const e=this._creatCanvasContext(256,256);this.drawTile(e,t);const n=new m.CanvasTexture(e.canvas.transferToImageBitmap());return new mo({transparent:!0,map:n,opacity:t.source.opacity})}_creatCanvasContext(t,e){const i=new OffscreenCanvas(t,e).getContext("2d");if(!i)throw new Error("create canvas context failed");return i.scale(1,-1),i.translate(0,-e),i}}class $p extends go{constructor(){super(...arguments);Z(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."});Z(this,"dataType","image");Z(this,"loader",new m.ImageLoader(De.manager))}async doLoad(e,n){const i=await this.loader.loadAsync(e).catch(u=>new Image(1,1)),s=new m.Texture;s.colorSpace=m.SRGBColorSpace;const{bounds:l}=n;return l[2]-l[0]<1?s.image=em(i,l):s.image=i,s.needsUpdate=!0,s}}function em(o,t){const e=o.width,n=new OffscreenCanvas(e,e),i=n.getContext("2d"),{sx:s,sy:l,sw:u,sh:c}=lo(t,o.width);return i.drawImage(o,s,l,u,c,0,0,e,e),n}const tm=`{
694
694
  "name": "@terra.gl/core",
695
- "version": "0.0.1-alpha.22",
695
+ "version": "0.0.1-alpha.23",
696
696
  "type": "module",
697
697
  "files": [
698
698
  "dist"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terra.gl/core",
3
- "version": "0.0.1-alpha.22",
3
+ "version": "0.0.1-alpha.24",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"