@terra.gl/core 0.0.1-alpha.15 → 0.0.1-alpha.16

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,8 +3,8 @@ var fv = (l, t, e) => t in l ? dv(l, t, { enumerable: !0, configurable: !0, writ
3
3
  var S = (l, t, e) => fv(l, typeof t != "symbol" ? t + "" : t, e);
4
4
  import * as It from "three";
5
5
  import { REVISION as Rh, TrianglesDrawMode as pv, TriangleFanDrawMode as Oa, TriangleStripDrawMode as Ch, Mesh as ut, Vector3 as j, Color as Le, FrontSide as to, Plane as Vh, Matrix4 as Se, Vector4 as an, PerspectiveCamera as Li, WebGLRenderTarget as mv, UniformsUtils as Bs, UniformsLib as js, ShaderMaterial as sl, MOUSE as Qn, TOUCH as qn, Spherical as Bu, Quaternion as tn, OrthographicCamera as Ir, Vector2 as Ie, Ray as gv, Loader as ol, LoaderUtils as Bi, FileLoader as ii, MeshPhysicalMaterial as vn, SpotLight as Eh, PointLight as Ka, DirectionalLight as Js, InstancedMesh as al, InstancedBufferAttribute as Ya, Object3D as rn, TextureLoader as no, ImageBitmapLoader as yv, BufferAttribute as Yt, InterleavedBuffer as vv, InterleavedBufferAttribute as _i, LinearMipmapLinearFilter as ll, NearestMipmapLinearFilter as wv, LinearMipmapNearestFilter as xv, NearestMipmapNearestFilter as bv, LinearFilter as Qs, NearestFilter as Ah, RepeatWrapping as Cn, MirroredRepeatWrapping as _v, ClampToEdgeWrapping as Ua, PointsMaterial as io, Material as La, LineBasicMaterial as Xh, MeshStandardMaterial as Er, DoubleSide as cl, MeshBasicMaterial as mn, PropertyBinding as Cr, BufferGeometry as nn, SkinnedMesh as Fh, LineSegments as Tv, Line as kh, LineLoop as Lv, Points as Ar, Group as sn, MathUtils as ct, Skeleton as zh, AnimationClip as Dh, Bone as Ha, InterpolateDiscrete as Mv, InterpolateLinear as Oh, Texture as Qi, VectorKeyframeTrack as Na, NumberKeyframeTrack as Ba, QuaternionKeyframeTrack as ja, Interpolant as Sv, Box3 as Zi, Sphere as ul, Curve as Zv, MeshPhongMaterial as Ma, MeshLambertMaterial as Kh, EquirectangularReflectionMapping as Gv, AmbientLight as Yh, Float32BufferAttribute as $n, Uint16BufferAttribute as Wv, Matrix3 as Iv, Euler as Sr, DataTextureLoader as Pv, HalfFloatType as Rs, FloatType as Hs, DataUtils as Cs, InstancedBufferGeometry as Uh, InstancedInterleavedBuffer as Ja, WireframeGeometry as Rv, Line3 as Cv, EventDispatcher as Hh, Clock as hl, Scene as Vv, FogExp2 as ju, CubeTextureLoader as Ev, WebGLRenderer as Av, PCFSoftShadowMap as Xv, ACESFilmicToneMapping as Fv, CameraHelper as kv, CubicBezierCurve3 as zv, PlaneGeometry as ji, Frustum as Dv, Raycaster as dl, CanvasTexture as Xr, SpriteMaterial as Fr, Sprite as Gi, DynamicDrawUsage as Ju, NormalBlending as Ov, BackSide as Kv, Shape as Yv, ShapeGeometry as Uv, CylinderGeometry as Hv, AdditiveBlending as Nv, AnimationMixer as Bv, LoopRepeat as jv, LoopOnce as Jv, LoadingManager as Qv, Box2 as qv, ImageLoader as Nh, SRGBColorSpace as $v } from "three";
6
- const ew = "0.0.1-alpha.15", Sa = {
7
- name: "criska"
6
+ const ew = "0.0.1-alpha.16", Sa = {
7
+ name: "Criska"
8
8
  };
9
9
  var Pr = function() {
10
10
  var l = 0, t = document.createElement("div");
@@ -16390,7 +16390,7 @@ function x_(l, t) {
16390
16390
  }
16391
16391
  const b_ = `{
16392
16392
  "name": "@terra.gl/core",
16393
- "version": "0.0.1-alpha.15",
16393
+ "version": "0.0.1-alpha.16",
16394
16394
  "type": "module",
16395
16395
  "files": [
16396
16396
  "dist"
@@ -16406,10 +16406,10 @@ const b_ = `{
16406
16406
  }
16407
16407
  },
16408
16408
  "author": {
16409
- "name": "criska"
16409
+ "name": "Criska"
16410
16410
  },
16411
16411
  "description": "a map using threejs",
16412
- "license": "MIT",
16412
+ "license": "Apache-2.0",
16413
16413
  "keywords": [
16414
16414
  "three",
16415
16415
  "gis",
@@ -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 Ab=Object.defineProperty;var Fb=(ee,m,cr)=>m in ee?Ab(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:cr}):ee[m]=cr;var T=(ee,m,cr)=>Fb(ee,typeof m!="symbol"?m+"":m,cr);function cr(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const wt=cr(m),Vh="0.0.1-alpha.15",Zs={name:"criska"};var Cr=function(){var l=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(++l%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";l=p}var r=(performance||Date).now(),s=r,a=0,c=e(new Cr.Panel("FPS","#0ff","#002")),u=e(new Cr.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=e(new Cr.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:e,showPanel:n,begin:function(){r=(performance||Date).now()},end:function(){a++;var p=(performance||Date).now();if(u.update(p-r,200),p>=s+1e3&&(c.update(a*1e3/(p-s),100),s=p,a=0,d)){var f=performance.memory;d.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){r=this.end()},domElement:t,setMode:n}};Cr.Panel=function(l,t,e){var n=1/0,r=0,s=Math.round,a=s(window.devicePixelRatio||1),c=80*a,u=48*a,d=3*a,p=2*a,f=3*a,y=15*a,v=74*a,x=30*a,L=document.createElement("canvas");L.width=c,L.height=u,L.style.cssText="width:80px;height:48px";var _=L.getContext("2d");return _.font="bold "+9*a+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=e,_.fillRect(0,0,c,u),_.fillStyle=t,_.fillText(l,d,p),_.fillRect(f,y,v,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f,y,v,x),{dom:L,update:function(S,Z){n=Math.min(n,S),r=Math.max(r,S),_.fillStyle=e,_.globalAlpha=1,_.fillRect(0,0,c,y),_.fillStyle=t,_.fillText(s(S)+" "+l+" ("+s(n)+"-"+s(r)+")",d,p),_.drawImage(L,f+a,y,v-a,x,f,y,v-a,x),_.fillRect(f+v-a,y,a,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f+v-a,y,a,s((1-S/Z)*x))}}};const fi=parseInt(m.REVISION.replace(/\D+/g,"")),Ts=fi>=125?"uv1":"uv2";function Wa(l,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let e=l.getIndex();if(e===null){const a=[],c=l.getAttribute("position");if(c!==void 0){for(let u=0;u<c.count;u++)a.push(u);l.setIndex(a),e=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=e.count-2,r=[];if(e)if(t===m.TriangleFanDrawMode)for(let a=1;a<=n;a++)r.push(e.getX(0)),r.push(e.getX(a)),r.push(e.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(r.push(e.getX(a)),r.push(e.getX(a+1)),r.push(e.getX(a+2))):(r.push(e.getX(a+2)),r.push(e.getX(a+1)),r.push(e.getX(a)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=l.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),l}var Tt=Uint8Array,bn=Uint16Array,Gs=Uint32Array,Ca=new Tt([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]),Va=new Tt([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]),Ah=new Tt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Aa=function(l,t){for(var e=new bn(31),n=0;n<31;++n)e[n]=t+=1<<l[n-1];for(var r=new Gs(e[30]),n=1;n<30;++n)for(var s=e[n];s<e[n+1];++s)r[s]=s-e[n]<<5|n;return[e,r]},Fa=Aa(Ca,2),Xa=Fa[0],Fh=Fa[1];Xa[28]=258,Fh[258]=28;for(var Xh=Aa(Va,0),kh=Xh[0],Ps=new bn(32768),We=0;We<32768;++We){var _n=(We&43690)>>>1|(We&21845)<<1;_n=(_n&52428)>>>2|(_n&13107)<<2,_n=(_n&61680)>>>4|(_n&3855)<<4,Ps[We]=((_n&65280)>>>8|(_n&255)<<8)>>>1}for(var Vr=function(l,t,e){for(var n=l.length,r=0,s=new bn(t);r<n;++r)++s[l[r]-1];var a=new bn(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;var c;if(e){c=new bn(1<<t);var u=15-t;for(r=0;r<n;++r)if(l[r])for(var d=r<<4|l[r],p=t-l[r],f=a[l[r]-1]++<<p,y=f|(1<<p)-1;f<=y;++f)c[Ps[f]>>>u]=d}else for(c=new bn(n),r=0;r<n;++r)l[r]&&(c[r]=Ps[a[l[r]-1]++]>>>15-l[r]);return c},Ar=new Tt(288),We=0;We<144;++We)Ar[We]=8;for(var We=144;We<256;++We)Ar[We]=9;for(var We=256;We<280;++We)Ar[We]=7;for(var We=280;We<288;++We)Ar[We]=8;for(var ka=new Tt(32),We=0;We<32;++We)ka[We]=5;var Dh=Vr(Ar,9,1),zh=Vr(ka,5,1),Is=function(l){for(var t=l[0],e=1;e<l.length;++e)l[e]>t&&(t=l[e]);return t},Kt=function(l,t,e){var n=t/8|0;return(l[n]|l[n+1]<<8)>>(t&7)&e},Ws=function(l,t){var e=t/8|0;return(l[e]|l[e+1]<<8|l[e+2]<<16)>>(t&7)},Oh=function(l){return(l/8|0)+(l&7&&1)},Kh=function(l,t,e){(e==null||e>l.length)&&(e=l.length);var n=new(l instanceof bn?bn:l instanceof Gs?Gs:Tt)(e-t);return n.set(l.subarray(t,e)),n},Rh=function(l,t,e){var n=l.length;if(!n||e&&!e.l&&n<5)return t||new Tt(0);var r=!t||e,s=!e||e.i;e||(e={}),t||(t=new Tt(n*3));var a=function(je){var Je=t.length;if(je>Je){var Qe=new Tt(Math.max(Je*2,je));Qe.set(t),t=Qe}},c=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,y=e.m,v=e.n,x=n*8;do{if(!p){e.f=c=Kt(l,u,1);var L=Kt(l,u+1,3);if(u+=3,L)if(L==1)p=Dh,f=zh,y=9,v=5;else if(L==2){var G=Kt(l,u,31)+257,A=Kt(l,u+10,15)+4,K=G+Kt(l,u+5,31)+1;u+=14;for(var D=new Tt(K),O=new Tt(19),V=0;V<A;++V)O[Ah[V]]=Kt(l,u+V*3,7);u+=A*3;for(var R=Is(O),W=(1<<R)-1,k=Vr(O,R,1),V=0;V<K;){var N=k[Kt(l,u,W)];u+=N&15;var _=N>>>4;if(_<16)D[V++]=_;else{var H=0,j=0;for(_==16?(j=3+Kt(l,u,3),u+=2,H=D[V-1]):_==17?(j=3+Kt(l,u,7),u+=3):_==18&&(j=11+Kt(l,u,127),u+=7);j--;)D[V++]=H}}var q=D.subarray(0,G),J=D.subarray(G);y=Is(q),v=Is(J),p=Vr(q,y,1),f=Vr(J,v,1)}else throw"invalid block type";else{var _=Oh(u)+4,S=l[_-4]|l[_-3]<<8,Z=_+S;if(Z>n){if(s)throw"unexpected EOF";break}r&&a(d+S),t.set(l.subarray(_,Z),d),e.b=d+=S,e.p=u=Z*8;continue}if(u>x){if(s)throw"unexpected EOF";break}}r&&a(d+131072);for(var oe=(1<<y)-1,ie=(1<<v)-1,te=u;;te=u){var H=p[Ws(l,u)&oe],me=H>>>4;if(u+=H&15,u>x){if(s)throw"unexpected EOF";break}if(!H)throw"invalid length/literal";if(me<256)t[d++]=me;else if(me==256){te=u,p=null;break}else{var be=me-254;if(me>264){var V=me-257,he=Ca[V];be=Kt(l,u,(1<<he)-1)+Xa[V],u+=he}var ve=f[Ws(l,u)&ie],ke=ve>>>4;if(!ve)throw"invalid distance";u+=ve&15;var J=kh[ke];if(ke>3){var he=Va[ke];J+=Ws(l,u)&(1<<he)-1,u+=he}if(u>x){if(s)throw"unexpected EOF";break}r&&a(d+131072);for(var Ye=d+be;d<Ye;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=Ye}}e.l=p,e.p=te,e.b=d,p&&(c=1,e.m=y,e.d=f,e.n=v)}while(!c);return d==t.length?t:Kh(t,0,d)},Yh=new Tt(0),Uh=function(l){if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Bh(l,t){return Rh((Uh(l),l.subarray(2,-4)),t)}var Nh=typeof TextDecoder<"u"&&new TextDecoder,jh=0;try{Nh.decode(Yh,{stream:!0}),jh=1}catch{}class Jh extends m.Mesh{constructor(t,e={}){super(t),this.isWater=!0;const n=this,r=e.textureWidth!==void 0?e.textureWidth:512,s=e.textureHeight!==void 0?e.textureHeight:512,a=e.clipBias!==void 0?e.clipBias:0,c=e.alpha!==void 0?e.alpha:1,u=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),x=e.distortionScale!==void 0?e.distortionScale:20,L=e.side!==void 0?e.side:m.FrontSide,_=e.fog!==void 0?e.fog:!1,S=new m.Plane,Z=new m.Vector3,G=new m.Vector3,A=new m.Vector3,K=new m.Matrix4,D=new m.Vector3(0,0,-1),O=new m.Vector4,V=new m.Vector3,R=new m.Vector3,W=new m.Vector4,k=new m.Matrix4,N=new m.PerspectiveCamera,H=new m.WebGLRenderTarget(r,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 Ab=Object.defineProperty;var Fb=(ee,m,cr)=>m in ee?Ab(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:cr}):ee[m]=cr;var T=(ee,m,cr)=>Fb(ee,typeof m!="symbol"?m+"":m,cr);function cr(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const wt=cr(m),Vh="0.0.1-alpha.16",Zs={name:"Criska"};var Cr=function(){var l=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(++l%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";l=p}var r=(performance||Date).now(),s=r,a=0,c=e(new Cr.Panel("FPS","#0ff","#002")),u=e(new Cr.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var d=e(new Cr.Panel("MB","#f08","#201"));return n(0),{REVISION:16,dom:t,addPanel:e,showPanel:n,begin:function(){r=(performance||Date).now()},end:function(){a++;var p=(performance||Date).now();if(u.update(p-r,200),p>=s+1e3&&(c.update(a*1e3/(p-s),100),s=p,a=0,d)){var f=performance.memory;d.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){r=this.end()},domElement:t,setMode:n}};Cr.Panel=function(l,t,e){var n=1/0,r=0,s=Math.round,a=s(window.devicePixelRatio||1),c=80*a,u=48*a,d=3*a,p=2*a,f=3*a,y=15*a,v=74*a,x=30*a,L=document.createElement("canvas");L.width=c,L.height=u,L.style.cssText="width:80px;height:48px";var _=L.getContext("2d");return _.font="bold "+9*a+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=e,_.fillRect(0,0,c,u),_.fillStyle=t,_.fillText(l,d,p),_.fillRect(f,y,v,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f,y,v,x),{dom:L,update:function(S,Z){n=Math.min(n,S),r=Math.max(r,S),_.fillStyle=e,_.globalAlpha=1,_.fillRect(0,0,c,y),_.fillStyle=t,_.fillText(s(S)+" "+l+" ("+s(n)+"-"+s(r)+")",d,p),_.drawImage(L,f+a,y,v-a,x,f,y,v-a,x),_.fillRect(f+v-a,y,a,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f+v-a,y,a,s((1-S/Z)*x))}}};const fi=parseInt(m.REVISION.replace(/\D+/g,"")),Ts=fi>=125?"uv1":"uv2";function Wa(l,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let e=l.getIndex();if(e===null){const a=[],c=l.getAttribute("position");if(c!==void 0){for(let u=0;u<c.count;u++)a.push(u);l.setIndex(a),e=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=e.count-2,r=[];if(e)if(t===m.TriangleFanDrawMode)for(let a=1;a<=n;a++)r.push(e.getX(0)),r.push(e.getX(a)),r.push(e.getX(a+1));else for(let a=0;a<n;a++)a%2===0?(r.push(e.getX(a)),r.push(e.getX(a+1)),r.push(e.getX(a+2))):(r.push(e.getX(a+2)),r.push(e.getX(a+1)),r.push(e.getX(a)));r.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=l.clone();return s.setIndex(r),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),l}var Tt=Uint8Array,bn=Uint16Array,Gs=Uint32Array,Ca=new Tt([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]),Va=new Tt([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]),Ah=new Tt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Aa=function(l,t){for(var e=new bn(31),n=0;n<31;++n)e[n]=t+=1<<l[n-1];for(var r=new Gs(e[30]),n=1;n<30;++n)for(var s=e[n];s<e[n+1];++s)r[s]=s-e[n]<<5|n;return[e,r]},Fa=Aa(Ca,2),Xa=Fa[0],Fh=Fa[1];Xa[28]=258,Fh[258]=28;for(var Xh=Aa(Va,0),kh=Xh[0],Ps=new bn(32768),We=0;We<32768;++We){var _n=(We&43690)>>>1|(We&21845)<<1;_n=(_n&52428)>>>2|(_n&13107)<<2,_n=(_n&61680)>>>4|(_n&3855)<<4,Ps[We]=((_n&65280)>>>8|(_n&255)<<8)>>>1}for(var Vr=function(l,t,e){for(var n=l.length,r=0,s=new bn(t);r<n;++r)++s[l[r]-1];var a=new bn(t);for(r=0;r<t;++r)a[r]=a[r-1]+s[r-1]<<1;var c;if(e){c=new bn(1<<t);var u=15-t;for(r=0;r<n;++r)if(l[r])for(var d=r<<4|l[r],p=t-l[r],f=a[l[r]-1]++<<p,y=f|(1<<p)-1;f<=y;++f)c[Ps[f]>>>u]=d}else for(c=new bn(n),r=0;r<n;++r)l[r]&&(c[r]=Ps[a[l[r]-1]++]>>>15-l[r]);return c},Ar=new Tt(288),We=0;We<144;++We)Ar[We]=8;for(var We=144;We<256;++We)Ar[We]=9;for(var We=256;We<280;++We)Ar[We]=7;for(var We=280;We<288;++We)Ar[We]=8;for(var ka=new Tt(32),We=0;We<32;++We)ka[We]=5;var Dh=Vr(Ar,9,1),zh=Vr(ka,5,1),Is=function(l){for(var t=l[0],e=1;e<l.length;++e)l[e]>t&&(t=l[e]);return t},Kt=function(l,t,e){var n=t/8|0;return(l[n]|l[n+1]<<8)>>(t&7)&e},Ws=function(l,t){var e=t/8|0;return(l[e]|l[e+1]<<8|l[e+2]<<16)>>(t&7)},Oh=function(l){return(l/8|0)+(l&7&&1)},Kh=function(l,t,e){(e==null||e>l.length)&&(e=l.length);var n=new(l instanceof bn?bn:l instanceof Gs?Gs:Tt)(e-t);return n.set(l.subarray(t,e)),n},Rh=function(l,t,e){var n=l.length;if(!n||e&&!e.l&&n<5)return t||new Tt(0);var r=!t||e,s=!e||e.i;e||(e={}),t||(t=new Tt(n*3));var a=function(je){var Je=t.length;if(je>Je){var Qe=new Tt(Math.max(Je*2,je));Qe.set(t),t=Qe}},c=e.f||0,u=e.p||0,d=e.b||0,p=e.l,f=e.d,y=e.m,v=e.n,x=n*8;do{if(!p){e.f=c=Kt(l,u,1);var L=Kt(l,u+1,3);if(u+=3,L)if(L==1)p=Dh,f=zh,y=9,v=5;else if(L==2){var G=Kt(l,u,31)+257,A=Kt(l,u+10,15)+4,K=G+Kt(l,u+5,31)+1;u+=14;for(var D=new Tt(K),O=new Tt(19),V=0;V<A;++V)O[Ah[V]]=Kt(l,u+V*3,7);u+=A*3;for(var R=Is(O),W=(1<<R)-1,k=Vr(O,R,1),V=0;V<K;){var N=k[Kt(l,u,W)];u+=N&15;var _=N>>>4;if(_<16)D[V++]=_;else{var H=0,j=0;for(_==16?(j=3+Kt(l,u,3),u+=2,H=D[V-1]):_==17?(j=3+Kt(l,u,7),u+=3):_==18&&(j=11+Kt(l,u,127),u+=7);j--;)D[V++]=H}}var q=D.subarray(0,G),J=D.subarray(G);y=Is(q),v=Is(J),p=Vr(q,y,1),f=Vr(J,v,1)}else throw"invalid block type";else{var _=Oh(u)+4,S=l[_-4]|l[_-3]<<8,Z=_+S;if(Z>n){if(s)throw"unexpected EOF";break}r&&a(d+S),t.set(l.subarray(_,Z),d),e.b=d+=S,e.p=u=Z*8;continue}if(u>x){if(s)throw"unexpected EOF";break}}r&&a(d+131072);for(var oe=(1<<y)-1,ie=(1<<v)-1,te=u;;te=u){var H=p[Ws(l,u)&oe],me=H>>>4;if(u+=H&15,u>x){if(s)throw"unexpected EOF";break}if(!H)throw"invalid length/literal";if(me<256)t[d++]=me;else if(me==256){te=u,p=null;break}else{var be=me-254;if(me>264){var V=me-257,he=Ca[V];be=Kt(l,u,(1<<he)-1)+Xa[V],u+=he}var ve=f[Ws(l,u)&ie],ke=ve>>>4;if(!ve)throw"invalid distance";u+=ve&15;var J=kh[ke];if(ke>3){var he=Va[ke];J+=Ws(l,u)&(1<<he)-1,u+=he}if(u>x){if(s)throw"unexpected EOF";break}r&&a(d+131072);for(var Ye=d+be;d<Ye;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=Ye}}e.l=p,e.p=te,e.b=d,p&&(c=1,e.m=y,e.d=f,e.n=v)}while(!c);return d==t.length?t:Kh(t,0,d)},Yh=new Tt(0),Uh=function(l){if((l[0]&15)!=8||l[0]>>>4>7||(l[0]<<8|l[1])%31)throw"invalid zlib data";if(l[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Bh(l,t){return Rh((Uh(l),l.subarray(2,-4)),t)}var Nh=typeof TextDecoder<"u"&&new TextDecoder,jh=0;try{Nh.decode(Yh,{stream:!0}),jh=1}catch{}class Jh extends m.Mesh{constructor(t,e={}){super(t),this.isWater=!0;const n=this,r=e.textureWidth!==void 0?e.textureWidth:512,s=e.textureHeight!==void 0?e.textureHeight:512,a=e.clipBias!==void 0?e.clipBias:0,c=e.alpha!==void 0?e.alpha:1,u=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),x=e.distortionScale!==void 0?e.distortionScale:20,L=e.side!==void 0?e.side:m.FrontSide,_=e.fog!==void 0?e.fog:!1,S=new m.Plane,Z=new m.Vector3,G=new m.Vector3,A=new m.Vector3,K=new m.Matrix4,D=new m.Vector3(0,0,-1),O=new m.Vector4,V=new m.Vector3,R=new m.Vector3,W=new m.Vector4,k=new m.Matrix4,N=new m.PerspectiveCamera,H=new m.WebGLRenderTarget(r,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
 
@@ -654,7 +654,7 @@ function print() { __p += __j.call(arguments, '') }
654
654
  }
655
655
  `)}setDiffusionFromObject(e){if(!this.shaderOption.effects?.diffusion)return;const n=new wt.Box3().setFromObject(e);if(n.isEmpty())return;const r=new wt.Vector3;n.getCenter(r);const s=[new wt.Vector3(n.min.x,n.min.y,n.min.z),new wt.Vector3(n.max.x,n.max.y,n.max.z)];let a=0;s.forEach(c=>{const u=r.distanceTo(c);u>a&&(a=u)}),this.shaderOption.effects.diffusion={...this.shaderOption.effects.diffusion,center:r,maxDistance:a},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 Pp={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class Fl extends Ur{constructor(e){super(e);T(this,"_type","Model");T(this,"_emissive",!1);T(this,"_emissiveIntensity",1);T(this,"_emissiveColor","#ffffff");T(this,"_mixer",null);T(this,"_currentAction",null);T(this,"_animations",[]);T(this,"_clock",new m.Clock);T(this,"_autoUpdate",!0);T(this,"_animationRequestId",null);T(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 Df(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,r){this._emissive=e,n!==void 0&&(this._emissiveIntensity=n),r!==void 0&&(this._emissiveColor=r),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(r=>r.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(r=>r.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()}_rendercity(){this.traverse(async e=>{if(e instanceof m.Mesh&&e.material){if(e.castShadow=!0,e.name==="building"){const n=new Gp({color:new m.Color("#6BA7EC").multiplyScalar(1.8),opacity:.95,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}}}}),r=new m.Box3().setFromObject(e);n.updateBoundingBox(r.min.y,r.max.y),n.setDiffusionFromObject(e),e.material=n,e.material.needsUpdate=!0}e.name==="grass"&&(e.castShadow=!1,e.receiveShadow=!0,e.material.color=new m.Color("#81e4d8ff)").multiplyScalar(.7),e.material.metalness=.2,e.material.roughness=.8,["metalnessMap","normalMap","roughnessMap","specularColorMap"].forEach(n=>{const r=e.material[n];r&&(r.wrapS=r.wrapT=m.RepeatWrapping,r.repeat.set(.3,.3),r.needsUpdate=!0)}),e.material.normalScale=new m.Vector2(3,3))}})}}Fl.mergeOptions(Pp);const Ip={};class Xl extends Ur{constructor(e){super(e);T(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=1e3,e&&(e._clouds.add(this._threeGeometry),e._clouds.updateMatrixWorld()))}async _createObject(e){switch(e.config.type){case"cloud":return Yf(e.config,this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Xl.mergeOptions(Ip);const Wp={};class kl extends Ur{constructor(e){super(e);T(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 Bf(e.config,new m.Vector3(0,0,0),this.getMap());case"canvas-label":return Uf(e.config,new m.Vector3(0,0,0));default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}kl.mergeOptions(Wp);const Cp={};class Dl extends Ur{constructor(e){super(e);T(this,"_type","TPoints");T(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 Qf(e.config,this._geometries,this.getMap());default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Dl.mergeOptions(Cp);function Ii(l,t){if(!l||l===!0)return!0;if(!Array.isArray(l))return!!l;switch(l[0]){case"all":return l.slice(1).every(n=>Ii(n,t));case"any":return l.slice(1).some(n=>Ii(n,t));case"!":return!Ii(l[1],t);case"==":{const n=it(l[1],t),r=it(l[2],t);return Wi(n)==Wi(r)}case"!=":{const n=it(l[1],t),r=it(l[2],t);return Wi(n)!=Wi(r)}case">":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)>Zn(r)}case"<":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)<Zn(r)}case">=":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)>=Zn(r)}case"<=":{const n=it(l[1],t),r=it(l[2],t);return Zn(n)<=Zn(r)}case"in":{const n=it(l[1],t);return l.slice(2).map(s=>it(s,t)).includes(n)}case"!in":{const n=it(l[1],t);return!l.slice(2).map(s=>it(s,t)).includes(n)}case"has":{const n=l[1];return t!=null&&Object.prototype.hasOwnProperty.call(t,n)}case"!has":{const n=l[1];return!(t!=null&&Object.prototype.hasOwnProperty.call(t,n))}default:return!0}}function it(l,t){if(Array.isArray(l))switch(l[0]){case"get":return t?t[l[1]]:void 0;default:return l}return l}function Wi(l){if(l==null)return null;if(typeof l=="string"){const t=Number(l);if(!isNaN(t)&&l.trim()!=="")return t}return typeof l=="boolean"?l?1:0:l}function Zn(l){if(l==null)return 0;if(typeof l=="number")return l;if(typeof l=="boolean")return l?1:0;if(typeof l=="string"){const t=Number(l);return isNaN(t)?0:t}return Number(l)}class Vp extends Bn{constructor(e,n){super(e,n);T(this,"TILE_SIZE");T(this,"EXTENT");T(this,"style");T(this,"_tileFeatureMap",new Map);T(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 r=this.getMap(),s=`${e.z}-${e.x}-${e.y}`,a=this._tileFeatureMap.get(s);if(a&&a.length>0){a.forEach(p=>{p.visible=!0,this.children.some(f=>f&&p&&f.uuid===p.uuid)||p.addTo(this)});return}const c=n.vectorData;if(!c||!c.layers||!r||this.style.length===0)return;const u=[],d=this.style;Object.keys(c.layers).forEach(p=>{const f=c.layers[p];for(let y=0;y<f.length;y++){const v=f[y],x=v.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(v.properties))continue;let L=null;for(const _ of d)if(this._evaluateFilter(_.filter,v.properties,p,v.geometry.type)){L=_.style;break}if(L){const _={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:x,extent:this.EXTENT,tileSize:this.TILE_SIZE},S=this._createFeatureInstance(v.geometry,v.geometry.type,L,v.properties);S&&(S.userData.tileData=_,S.style=Pt.create(L),S.addTo(this),S.initializeGeometry(),u.push(S))}}}),this._tileFeatureMap.set(s,u)}_evaluateFilter(e,n,r,s){if(!e||e===!0)return!0;const a={...n,$layer:r,$type:s};return Ii(e,a)}hideFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&n.forEach(r=>{r.visible=!1})}removeFeaturesByTileKey(e){this._removeFeaturesByTileKey(e)}_removeFeaturesByTileKey(e){const n=this._tileFeatureMap.get(e);n&&(n.forEach(r=>{r._remove()}),this._tileFeatureMap.delete(e))}_createFeatureInstance(e,n,r,s){const c={geometry:{ismvt:!0,...e},style:r,userData:s};switch(n){case"Point":return new ro(c);case"LineString":return new io(c);default:return null}}setFeatureFilter(e){this._activeFeatureFilter=e}clearFeatureFilter(){this._activeFeatureFilter=void 0}setOpacity(e){this.opacity=e,this._tileFeatureMap.forEach(n=>{n.forEach(r=>{r.material&&(r.material.opacity=e,r.material.transparent=e<1)})})}_onMapUpdate(){}validateFeature(e){return e instanceof Sn}dispose(){this._tileFeatureMap.forEach((e,n)=>{this._removeFeaturesByTileKey(n)}),super.dispose()}}class zl extends Si{constructor(e,n){super(e,n);T(this,"isTileLayer",!0);T(this,"layerType","base");T(this,"isBaseLayer",!1);T(this,"_enabled",!0);T(this,"_visible",!0);T(this,"_rootTile");T(this,"_loader");T(this,"_LODThreshold",1);T(this,"isSceneLayer",!1);T(this,"opacity",1);T(this,"source");T(this,"projection");T(this,"minLevel",2);T(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 Ol extends m.LoadingManager{constructor(){super(...arguments);T(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const Xe={manager:new Ol,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(l){Xe.imgLoaderMap.set(l.dataType,l),l.info.author=l.info.author??Zs.name},registerGeometryLoader(l){Xe.demLoaderMap.set(l.dataType,l),l.info.author=l.info.author??Zs.name},registerMeshLoader(l){Xe.meshLoaderMap.set(l.dataType,l),l.info.author=l.info.author??Zs.name},getMaterialLoader(l){const t=Xe.imgLoaderMap.get(l.dataType);if(t)return t;throw`Source dataType "${l.dataType}" is not support!`},getGeometryLoader(l){const t=Xe.demLoaderMap.get(l.dataType);if(t)return t;throw`Source dataType "${l.dataType}" is not support!`},getMeshLoader(l){const t=Xe.meshLoaderMap.get(l.dataType);if(t)return t;throw`Source dataType "${l.dataType}" is not support!`}};class Ap{constructor(t){T(this,"worker");this.worker=t()}async run(t,e){return new Promise(n=>{this.worker.onmessage=r=>{n(r.data)},this.worker.postMessage(t,e)})}terminate(){this.worker.terminate()}}const Fp=4096,Kl=Math.PI;function so(l,t){const e=Math.floor(l[0]*t),n=Math.floor(l[1]*t),r=Math.floor((l[2]-l[0])*t),s=Math.floor((l[3]-l[1])*t);return{sx:e,sy:n,sw:r,sh:s}}function oo(l,t,e,n){if(n<l.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=l.maxLevel)return{url:l._getUrl(t,e,n),clipBounds:[0,0,1,1]};const r=Xp(t,e,n,l.maxLevel),s=r.parentNO;return{url:l._getUrl(s.x,s.y,s.z),clipBounds:r.bounds}}function Xp(l,t,e,n){const r=e-n,s={x:l>>r,y:t>>r,z:e-r},a=Math.pow(2,r),c=Math.pow(.5,r),u=l%a/a-.5+c/2,d=t%a/a-.5+c/2,p=new m.Vector2(u,d),f=new m.Box2().setFromCenterAndSize(p,new m.Vector2(c,c)),y=[f.min.x+.5,f.min.y+.5,f.max.x+.5,f.max.y+.5];return{parentNO:s,bounds:y}}function ao(l,t,e,n,r=Fp){const{x:s,y:a}=l,c=(t+s/r)/Math.pow(2,n),u=(e+a/r)/Math.pow(2,n),d=c*360-180,f=Math.atan(Math.sinh(Kl*(1-2*u)))*180/Kl;return[parseFloat(d.toFixed(8)),parseFloat(f.toFixed(8))]}function kp(l,t,e,n){if(!l||!l.coordinates)throw new Error("无效的geometry数据格式");const r={type:l.type,coordinates:null};function s(a){if(typeof a=="object"&&a.x!==void 0&&a.y!==void 0)return ao(a,t,e,n);if(Array.isArray(a)&&a.length>0){const c=a[0];return typeof c=="object"&&c.x!==void 0&&c.y!==void 0?a.map(u=>ao(u,t,e,n)):a.map(u=>s(u))}return a}return r.coordinates=s(l.coordinates),r}class Ci{constructor(){T(this,"_imgSource",[]);T(this,"_demSource");T(this,"_vtSource");T(this,"manager",Xe.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 r=0;r<n.length;r++)e.addGroup(0,1/0,r);return{materials:n,geometry:e}}unload(t){const e=t.material,n=t.geometry;for(let r=0;r<e.length;r++)e[r].dispose();n.dispose()}async loadGeometry(t){let e;if(this.demSource&&t.z>=this.demSource.minLevel&&this._isBoundsInSourceBounds(this.demSource,t.bounds)){const n=Xe.getGeometryLoader(this.demSource),r=this.demSource;e=await n.load({source:r,...t}).catch(s=>(console.error("Load material error",r.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=Xe.getMeshLoader(this.vtSource),r=this.vtSource;e=await n.load({source:r,...t}).catch(s=>(console.error("Load geometry error",r.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(r=>t.z>=r.minLevel&&this._isBoundsInSourceBounds(r,t.bounds)).map(async r=>{const s=Xe.getMaterialLoader(r),a=await s.load({source:r,...t}).catch(u=>(console.error("Load material error",r.dataType,t.x,t.y,t.z),new m.MeshBasicMaterial)),c=u=>{s.unload&&s.unload(u.target),u.target.removeEventListener("dispose",c)};return a instanceof m.MeshBasicMaterial||a.addEventListener("dispose",c),a});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 Br(...l){const t=l,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((a,c)=>a+c.length,0),r=new e(n);let s=0;for(const a of t)r.set(a,s),s+=a.length;return r}function Rl(l,t,e,n){const r=n?zp(n,l.position.value):Dp(t),s=r.length,a=new Float32Array(s*6),c=new Float32Array(s*4),u=new t.constructor(s*6),d=new Float32Array(s*6);for(let f=0;f<s;f++)Op({edge:r[f],edgeIndex:f,attributes:l,skirtHeight:e,newPosition:a,newTexcoord0:c,newTriangles:u,newNormals:d});l.position.value=Br(l.position.value,a),l.texcoord.value=Br(l.texcoord.value,c),l.normal.value=Br(l.normal.value,d);const p=Br(t,u);return{attributes:l,indices:p}}function Dp(l){const t=[],e=Array.isArray(l)?l:Array.from(l);for(let r=0;r<e.length;r+=3){const s=e[r],a=e[r+1],c=e[r+2];t.push([s,a],[a,c],[c,s])}t.sort(([r,s],[a,c])=>{const u=Math.min(r,s),d=Math.min(a,c);return u!==d?u-d:Math.max(r,s)-Math.max(a,c)});const n=[];for(let r=0;r<t.length;r++)r+1<t.length&&t[r][0]===t[r+1][1]&&t[r][1]===t[r+1][0]?r++:n.push(t[r]);return n}function zp(l,t){const e=(r,s)=>{r.sort(s)};e(l.westIndices,(r,s)=>t[3*r+1]-t[3*s+1]),e(l.eastIndices,(r,s)=>t[3*s+1]-t[3*r+1]),e(l.southIndices,(r,s)=>t[3*s]-t[3*r]),e(l.northIndices,(r,s)=>t[3*r]-t[3*s]);const n=[];return Object.values(l).forEach(r=>{if(r.length>1)for(let s=0;s<r.length-1;s++)n.push([r[s],r[s+1]])}),n}function Op({edge:l,edgeIndex:t,attributes:e,skirtHeight:n,newPosition:r,newTexcoord0:s,newTriangles:a,newNormals:c}){const u=e.position.value.length,d=t*2,p=d+1;r.set(e.position.value.subarray(l[0]*3,l[0]*3+3),d*3),r[d*3+2]=r[d*3+2]-n,r.set(e.position.value.subarray(l[1]*3,l[1]*3+3),p*3),r[p*3+2]=r[p*3+2]-n,s.set(e.texcoord.value.subarray(l[0]*2,l[0]*2+2),d*2),s.set(e.texcoord.value.subarray(l[1]*2,l[1]*2+2),p*2);const f=t*2*3;a[f]=l[0],a[f+1]=u/3+p,a[f+2]=l[1],a[f+3]=u/3+p,a[f+4]=l[0],a[f+5]=u/3+d,c[f]=0,c[f+1]=0,c[f+2]=1,c[f+3]=0,c[f+4]=0,c[f+5]=1}function Yl(l){if(l.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${l.length}!`);const t=Math.floor(Math.sqrt(l.length)),e=t,n=t,r=lo(n,e);return{attributes:Kp(l,n,e),indices:r}}function Kp(l,t,e){const n=e*t,r=new Float32Array(n*3),s=new Float32Array(n*2);let a=0;for(let c=0;c<t;c++)for(let u=0;u<e;u++){const d=u/(e-1),p=c/(t-1);s[a*2]=d,s[a*2+1]=p,r[a*3]=d-.5,r[a*3+1]=p-.5,r[a*3+2]=l[(t-c-1)*e+u],a++}return{position:{value:r,size:3},texcoord:{value:s,size:2},normal:{value:co(r,lo(t,e)),size:3}}}function lo(l,t){const e=6*(t-1)*(l-1),n=new Uint16Array(e);let r=0;for(let s=0;s<l-1;s++)for(let a=0;a<t-1;a++){const c=s*t+a,u=c+1,d=c+t,p=d+1,f=r*6;n[f]=c,n[f+1]=u,n[f+2]=d,n[f+3]=d,n[f+4]=u,n[f+5]=p,r++}return n}function co(l,t){const e=new Float32Array(l.length);for(let n=0;n<t.length;n+=3){const r=t[n]*3,s=t[n+1]*3,a=t[n+2]*3,c=l[r],u=l[r+1],d=l[r+2],p=l[s],f=l[s+1],y=l[s+2],v=l[a],x=l[a+1],L=l[a+2],_=p-c,S=f-u,Z=y-d,G=v-c,A=x-u,K=L-d,D=S*K-Z*A,O=Z*G-_*K,V=_*A-S*G,R=Math.sqrt(D*D+O*O+V*V),W=[0,0,1];if(R>0){const k=1/R;W[0]=D*k,W[1]=O*k,W[2]=V*k}for(let k=0;k<3;k++)e[r+k]=e[s+k]=e[a+k]=W[k]}return e}class fr extends m.PlaneGeometry{constructor(){super(...arguments);T(this,"type","TileGeometry")}setData(e,n=1e3){let r=e instanceof Float32Array?Yl(e):e;r=Rl(r.attributes,r.indices,n);const{attributes:s,indices:a}=r;return this.setIndex(new m.BufferAttribute(a,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 Ul{constructor(t=257){T(this,"gridSize");T(this,"numTriangles");T(this,"numParentTriangles");T(this,"indices");T(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 r=n+2,s=0,a=0,c=0,u=0,d=0,p=0;for(r&1?c=u=d=e:s=a=p=e;(r>>=1)>1;){const y=s+c>>1,v=a+u>>1;r&1?(c=s,u=a,s=d,a=p):(s=c,a=u,c=d,u=p),d=y,p=v}const f=n*4;this.coords[f+0]=s,this.coords[f+1]=a,this.coords[f+2]=c,this.coords[f+3]=u}}createTile(t){return new Rp(t,this)}}class Rp{constructor(t,e){T(this,"martini");T(this,"terrain");T(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:r}=this.martini,{terrain:s,errors:a}=this;for(let c=t-1;c>=0;c--){const u=c*4,d=n[u+0],p=n[u+1],f=n[u+2],y=n[u+3],v=d+f>>1,x=p+y>>1,L=v+x-p,_=x+d-v,S=(s[p*r+d]+s[y*r+f])/2,Z=x*r+v,G=Math.abs(S-s[Z]);if(a[Z]=Math.max(a[Z],G),c<e){const A=(p+_>>1)*r+(d+L>>1),K=(y+_>>1)*r+(f+L>>1);a[Z]=Math.max(a[Z],a[A],a[K])}}}getGeometryData(t=0){const{gridSize:e,indices:n}=this.martini,{errors:r}=this;let s=0,a=0;const c=e-1;let u,d,p=0;n.fill(0);function f(Z,G,A,K,D,O){const V=Z+A>>1,R=G+K>>1;Math.abs(Z-D)+Math.abs(G-O)>1&&r[R*e+V]>t?(f(D,O,Z,G,V,R),f(A,K,D,O,V,R)):(u=G*e+Z,d=K*e+A,p=O*e+D,n[u]===0&&(n[u]=++s),n[d]===0&&(n[d]=++s),n[p]===0&&(n[p]=++s),a++)}f(0,0,c,c,c,0),f(c,c,0,0,0,c);const y=s*2,v=a*3,x=new Uint16Array(y),L=new Uint32Array(v);let _=0;function S(Z,G,A,K,D,O){const V=Z+A>>1,R=G+K>>1;if(Math.abs(Z-D)+Math.abs(G-O)>1&&r[R*e+V]>t)S(D,O,Z,G,V,R),S(A,K,D,O,V,R);else{const W=n[G*e+Z]-1,k=n[K*e+A]-1,N=n[O*e+D]-1;x[2*W]=Z,x[2*W+1]=G,x[2*k]=A,x[2*k+1]=K,x[2*N]=D,x[2*N+1]=O,L[_++]=W,L[_++]=k,L[_++]=N}}return S(0,0,c,c,c,0),S(c,c,0,0,0,c),{attributes:this._getMeshAttributes(this.terrain,x,L),indices:L}}_getMeshAttributes(t,e,n){const r=Math.floor(Math.sqrt(t.length)),s=r-1,a=e.length/2,c=new Float32Array(a*3),u=new Float32Array(a*2);for(let p=0;p<a;p++){const f=e[p*2],y=e[p*2+1],v=y*r+f;c[3*p+0]=f/s-.5,c[3*p+1]=.5-y/s,c[3*p+2]=t[v],u[2*p+0]=f/s,u[2*p+1]=1-y/s}const d=co(c,n);return{position:{value:c,size:3},texcoord:{value:u,size:2},normal:{value:d,size:3}}}}class uo{constructor(){T(this,"info",{version:"0.10.0",description:"Terrain loader base class"});T(this,"dataType","")}async load(t){const{source:e,x:n,y:r,z:s}=t,{url:a,clipBounds:c}=oo(e,n,r,s);if(!a)return new fr;const u=await this.doLoad(a,{source:e,x:n,y:r,z:s,bounds:c});return Xe.manager.parseEnd(a),u}}class ho 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 tt=(l=>(l[l.Unknown=0]="Unknown",l[l.Point=1]="Point",l[l.Linestring=2]="Linestring",l[l.Polygon=3]="Polygon",l))(tt||{});class Bl{render(t,e,n,r,s=1){switch(t.lineCap="round",t.lineJoin="round",(r.shadowBlur??0)>0&&(t.shadowBlur=r.shadowBlur??2,t.shadowColor=r.shadowColor??"black",t.shadowOffsetX=r.shadowOffset?r.shadowOffset[0]:0,t.shadowOffsetY=r.shadowOffset?r.shadowOffset[1]:0),e){case tt.Point:t.textAlign="center",t.textBaseline="middle",t.font=r.font??"14px Arial",t.fillStyle=r.fontColor??"white",this._renderPointText(t,n,s,r.textField??"name",r.fontOffset??[0,-8]);break;case tt.Linestring:this._renderLineString(t,n,s);break;case tt.Polygon:this._renderPolygon(t,n,s);break;default:console.warn(`Unknown feature type: ${e}`)}(r.fill||e===tt.Point)&&(t.globalAlpha=r.fillOpacity||.5,t.fillStyle=r.fillColor||r.color||"#3388ff",t.fill(r.fillRule||"evenodd")),(r.stroke??!0)&&(r.weight??1)>0&&(t.globalAlpha=r.opacity||1,t.lineWidth=r.weight||1,t.strokeStyle=r.color||"#3388ff",t.setLineDash(r.dashArray||[]),t.stroke())}_renderPointText(t,e,n=1,r="name",s=[0,0]){const a=e.geometry;t.beginPath();for(const u of a)for(let d=0;d<u.length;d++){const p=u[d];t.arc(p.x*n,p.y*n,2,0,2*Math.PI)}const c=e.properties;c&&c[r]&&t.fillText(c[r],a[0][0].x*n+s[0],a[0][0].y*n+s[1])}_renderLineString(t,e,n){const r=e.geometry;t.beginPath();for(const s of r)for(let a=0;a<s.length;a++){const{x:c,y:u}=s[a];a===0?t.moveTo(c*n,u*n):t.lineTo(c*n,u*n)}}_renderPolygon(t,e,n){const r=e.geometry;t.beginPath();for(let s=0;s<r.length;s++){const a=r[s];for(let c=0;c<a.length;c++){const{x:u,y:d}=a[c];c===0?t.moveTo(u*n,d*n):t.lineTo(u*n,d*n)}t.closePath()}}}class fo{constructor(){T(this,"info",{version:"0.10.0",description:"Image loader base class"});T(this,"dataType","")}async load(t){const{source:e,x:n,y:r,z:s}=t,a=new ho,{url:c,clipBounds:u}=oo(e,n,r,s);if(c){const d=await this.doLoad(c,{source:e,x:n,y:r,z:s,bounds:u});a.map=d,Xe.manager.parseEnd(c)}return a}}class Yp{constructor(){T(this,"info",{version:"0.10.0",description:"Canvas tile abstract loader"});T(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 ho({transparent:!0,map:n,opacity:t.source.opacity})}_creatCanvasContext(t,e){const r=new OffscreenCanvas(t,e).getContext("2d");if(!r)throw new Error("create canvas context failed");return r.scale(1,-1),r.translate(0,-e),r}}class Up extends fo{constructor(){super(...arguments);T(this,"info",{version:"0.10.0",description:"Tile image loader. It can load xyz tile image."});T(this,"dataType","image");T(this,"loader",new m.ImageLoader(Xe.manager))}async doLoad(e,n){const r=await this.loader.loadAsync(e).catch(c=>new Image(1,1)),s=new m.Texture;s.colorSpace=m.SRGBColorSpace;const{bounds:a}=n;return a[2]-a[0]<1?s.image=Bp(r,a):s.image=r,s.needsUpdate=!0,s}}function Bp(l,t){const e=l.width,n=new OffscreenCanvas(e,e),r=n.getContext("2d"),{sx:s,sy:a,sw:c,sh:u}=so(t,l.width);return r.drawImage(l,s,a,c,u,0,0,e,e),n}const Np=`{
656
656
  "name": "@terra.gl/core",
657
- "version": "0.0.1-alpha.15",
657
+ "version": "0.0.1-alpha.16",
658
658
  "type": "module",
659
659
  "files": [
660
660
  "dist"
@@ -670,10 +670,10 @@ function print() { __p += __j.call(arguments, '') }
670
670
  }
671
671
  },
672
672
  "author": {
673
- "name": "criska"
673
+ "name": "Criska"
674
674
  },
675
675
  "description": "a map using threejs",
676
- "license": "MIT",
676
+ "license": "Apache-2.0",
677
677
  "keywords": [
678
678
  "three",
679
679
  "gis",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terra.gl/core",
3
- "version": "0.0.1-alpha.15",
3
+ "version": "0.0.1-alpha.16",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -16,10 +16,10 @@
16
16
  }
17
17
  },
18
18
  "author": {
19
- "name": "criska"
19
+ "name": "Criska"
20
20
  },
21
21
  "description": "a map using threejs",
22
- "license": "MIT",
22
+ "license": "Apache-2.0",
23
23
  "keywords": [
24
24
  "three",
25
25
  "gis",