@terra.gl/core 0.0.1-alpha.19 → 0.0.1-alpha.21
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 +14 -14
- package/dist/index.umd.cjs +6 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var vw = (a, t, e) => t in a ? yw(a, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var M = (a, t, e) => vw(a, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import * as at from "three";
|
|
5
5
|
import { REVISION as zh, TrianglesDrawMode as ww, TriangleFanDrawMode as Ya, TriangleStripDrawMode as Dh, Mesh as ht, Vector3 as B, Color as Te, FrontSide as ro, Plane as kh, Matrix4 as Se, Vector4 as sn, PerspectiveCamera as Li, WebGLRenderTarget as xw, UniformsUtils as Qs, UniformsLib as qs, ShaderMaterial as ll, MOUSE as qn, TOUCH as $n, Spherical as $u, Quaternion as $t, OrthographicCamera as Ir, Vector2 as Ze, Ray as bw, Loader as cl, LoaderUtils as Bi, FileLoader as ri, MeshPhysicalMaterial as vn, SpotLight as Oh, PointLight as Ha, DirectionalLight as $s, InstancedMesh as ul, InstancedBufferAttribute as Ua, Object3D as tn, TextureLoader as so, ImageBitmapLoader as _w, BufferAttribute as en, InterleavedBuffer as Tw, InterleavedBufferAttribute as _i, LinearMipmapLinearFilter as hl, NearestMipmapLinearFilter as Lw, LinearMipmapNearestFilter as Mw, NearestMipmapNearestFilter as Sw, LinearFilter as eo, NearestFilter as Kh, RepeatWrapping as Cn, MirroredRepeatWrapping as Zw, ClampToEdgeWrapping as Na, PointsMaterial as oo, Material as La, LineBasicMaterial as Yh, MeshStandardMaterial as Ar, DoubleSide as dl, MeshBasicMaterial as pn, PropertyBinding as Er, BufferGeometry as mn, SkinnedMesh as Hh, LineSegments as Gw, Line as Uh, LineLoop as Ww, Points as Xr, Group as nn, MathUtils as ut, Skeleton as Nh, AnimationClip as Bh, Bone as Ba, InterpolateDiscrete as Rw, InterpolateLinear as jh, Texture as Qi, VectorKeyframeTrack as ja, NumberKeyframeTrack as Ja, QuaternionKeyframeTrack as Qa, Interpolant as Iw, Box3 as Zi, Sphere as fl, Curve as Pw, MeshPhongMaterial as Ma, MeshLambertMaterial as Jh, EquirectangularReflectionMapping as Cw, AmbientLight as Qh, Float32BufferAttribute as ei, Uint16BufferAttribute as Ew, Matrix3 as Vw, Euler as Zr, DataTextureLoader as Aw, HalfFloatType as Vs, FloatType as js, DataUtils as As, InstancedBufferGeometry as qh, InstancedInterleavedBuffer as qa, WireframeGeometry as Xw, Line3 as Fw, EventDispatcher as $h, Clock as pl, 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 ml, CanvasTexture as Fr, SpriteMaterial as zr, 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 ex, LoopOnce as tx, LoadingManager as nx, Box2 as ix, ImageLoader as ed, SRGBColorSpace as rx } from "three";
|
|
6
|
-
const sx = "0.0.1-alpha.
|
|
6
|
+
const sx = "0.0.1-alpha.21", Sa = {
|
|
7
7
|
name: "Criska"
|
|
8
8
|
};
|
|
9
9
|
var Pr = function() {
|
|
@@ -8094,7 +8094,7 @@ async function cb(a, t) {
|
|
|
8094
8094
|
// 如果纹理加载失败,map 为 null,使用纯色占位
|
|
8095
8095
|
map: e ?? null,
|
|
8096
8096
|
color: a.color || 16777215,
|
|
8097
|
-
transparent: !0,
|
|
8097
|
+
transparent: a.transparent ?? !0,
|
|
8098
8098
|
opacity: a.opacity ?? 1,
|
|
8099
8099
|
sizeAttenuation: a.sizeAttenuation ?? !0,
|
|
8100
8100
|
depthTest: a.depthTest ?? !0,
|
|
@@ -8110,7 +8110,7 @@ function _l(a, t) {
|
|
|
8110
8110
|
const i = new kr({
|
|
8111
8111
|
color: new Te(a.color ?? 16777215).getHex(),
|
|
8112
8112
|
linewidth: a.width ?? 2,
|
|
8113
|
-
transparent: !0,
|
|
8113
|
+
transparent: a.transparent ?? !0,
|
|
8114
8114
|
opacity: a.opacity ?? 1,
|
|
8115
8115
|
dashed: !!a.dashArray,
|
|
8116
8116
|
dashScale: a.dashArray?.[0] ?? 1,
|
|
@@ -8136,7 +8136,7 @@ async function ub(a, t) {
|
|
|
8136
8136
|
function hb(a, t) {
|
|
8137
8137
|
const { geometry: e, center: n, avgY: i } = Tl(t), s = a.depthOffset ?? 0, l = s !== 0, u = new pn({
|
|
8138
8138
|
color: new Te(a.color ?? 16777215),
|
|
8139
|
-
transparent: a.
|
|
8139
|
+
transparent: a.transparent ?? !0,
|
|
8140
8140
|
opacity: a.opacity ?? 1,
|
|
8141
8141
|
wireframe: a.wireframe ?? !1,
|
|
8142
8142
|
side: a.side === "back" ? Bw : a.side === "double" ? dl : ro,
|
|
@@ -8216,7 +8216,7 @@ function db(a, t) {
|
|
|
8216
8216
|
if (uOpacity >= 0.99) gl_FragDepthEXT = gl_FragCoord.z;
|
|
8217
8217
|
}
|
|
8218
8218
|
`,
|
|
8219
|
-
transparent: !0,
|
|
8219
|
+
transparent: a.transparent ?? !0,
|
|
8220
8220
|
side: dl,
|
|
8221
8221
|
depthTest: a.depthTest ?? !0,
|
|
8222
8222
|
depthWrite: a.depthWrite ?? !0
|
|
@@ -8274,14 +8274,14 @@ async function pb(a, t) {
|
|
|
8274
8274
|
roughness: 0.1,
|
|
8275
8275
|
// 稍微增加粗糙度更真实
|
|
8276
8276
|
metalness: 0.8,
|
|
8277
|
-
transparent: !0,
|
|
8277
|
+
transparent: a.transparent ?? !0,
|
|
8278
8278
|
opacity: 0.9,
|
|
8279
8279
|
fog: !1,
|
|
8280
8280
|
normalMap: s,
|
|
8281
8281
|
normalScale: new Ze(1.5, 1.5),
|
|
8282
8282
|
// environmentMap: viewer.scene.environment,
|
|
8283
8283
|
envMapIntensity: 2,
|
|
8284
|
-
//
|
|
8284
|
+
// 提高环境贴图的强度,让反射更亮
|
|
8285
8285
|
// clearcoat: 1.0, // 启用 Clearcoat,强度 1.0
|
|
8286
8286
|
// clearcoatRoughness: 0.0, // Clearcoat 粗糙度 0.0,实现锋利高光
|
|
8287
8287
|
depthTest: a.depthTest ?? !0,
|
|
@@ -8351,7 +8351,7 @@ async function gb(a, t) {
|
|
|
8351
8351
|
b.magFilter = Kh, b.minFilter = hl, b.anisotropy = 16;
|
|
8352
8352
|
const S = new zr({
|
|
8353
8353
|
map: b,
|
|
8354
|
-
transparent: !0,
|
|
8354
|
+
transparent: a.transparent ?? !0,
|
|
8355
8355
|
depthTest: a.depthTest ?? !0,
|
|
8356
8356
|
depthWrite: a.depthWrite ?? !0,
|
|
8357
8357
|
fog: !1
|
|
@@ -8407,7 +8407,7 @@ async function yb(a, t, e) {
|
|
|
8407
8407
|
), c.fill(), c.globalAlpha = 1, c.strokeStyle = i.bubbleBorderColor, c.lineWidth = i.bubbleBorderWidth, c.stroke())), c.textAlign = "center", c.textBaseline = "middle", i.strokeWidth > 0 && (c.strokeStyle = i.strokeColor, c.lineWidth = i.strokeWidth, c.lineJoin = "round", c.strokeText(i.text, u.width / 2, u.height / 2)), c.fillStyle = i.textColor, c.fillText(i.text, u.width / 2, u.height / 2), c.shadowColor = "transparent";
|
|
8408
8408
|
const b = new Fr(u), S = new zr({
|
|
8409
8409
|
map: b,
|
|
8410
|
-
transparent: !0,
|
|
8410
|
+
transparent: a.transparent ?? !0,
|
|
8411
8411
|
depthTest: a.depthTest ?? !0,
|
|
8412
8412
|
depthWrite: a.depthWrite ?? !0,
|
|
8413
8413
|
fog: !1
|
|
@@ -8506,7 +8506,7 @@ async function vb(a, t, e) {
|
|
|
8506
8506
|
F.needsUpdate = !0;
|
|
8507
8507
|
const I = new zr({
|
|
8508
8508
|
map: F,
|
|
8509
|
-
transparent: !0,
|
|
8509
|
+
transparent: a.transparent ?? !0,
|
|
8510
8510
|
depthTest: a.depthTest ?? !0,
|
|
8511
8511
|
depthWrite: a.depthWrite ?? !0,
|
|
8512
8512
|
blending: Nw,
|
|
@@ -8594,7 +8594,7 @@ async function bb(a, t, e) {
|
|
|
8594
8594
|
size: 80 * window.innerHeight / window.innerHeight,
|
|
8595
8595
|
fog: !1,
|
|
8596
8596
|
opacity: 1,
|
|
8597
|
-
transparent: !0,
|
|
8597
|
+
transparent: a.transparent ?? !0,
|
|
8598
8598
|
toneMapped: !1,
|
|
8599
8599
|
blending: qw,
|
|
8600
8600
|
map: l,
|
|
@@ -14480,7 +14480,7 @@ class qb extends En {
|
|
|
14480
14480
|
}
|
|
14481
14481
|
const n = this.getMap();
|
|
14482
14482
|
try {
|
|
14483
|
-
e === "basic-polygon" ? (this._threeGeometry.renderOrder =
|
|
14483
|
+
e === "basic-polygon" ? (this._threeGeometry.renderOrder = 90, this._threeGeometry.position.add(n?.prjcenter), this._threeGeometry.updateMatrix(), this.add(this._threeGeometry)) : (e === "extrude-polygon" || e?.includes("water")) && (this._threeGeometry.renderOrder = 90, this._threeGeometry.position.add(n?.prjcenter), this._threeGeometry.updateMatrix(), this.add(this._threeGeometry));
|
|
14484
14484
|
} catch (i) {
|
|
14485
14485
|
throw console.error("更新多边形位置失败:", i), i;
|
|
14486
14486
|
}
|
|
@@ -15284,7 +15284,7 @@ class s_ extends Yr {
|
|
|
15284
15284
|
// 新增:把算好的 overlayParams 传给材质
|
|
15285
15285
|
regionOverlay: n || void 0
|
|
15286
15286
|
}), l = new Zi().setFromObject(i);
|
|
15287
|
-
s.updateBoundingBox(l.min.y, l.max.y), s.setDiffusionFromObject(i), i.material = s, i.material.needsUpdate = !0;
|
|
15287
|
+
s.updateBoundingBox(l.min.y, l.max.y), s.setDiffusionFromObject(i), i.receiveShadow = !1, i.material = s, i.material.needsUpdate = !0;
|
|
15288
15288
|
}
|
|
15289
15289
|
i.name === "grass" && (i.castShadow = !1, i.receiveShadow = !0, i.material.color = new Te("#81e4d8ff)").multiplyScalar(0.7), i.material.metalness = 0.2, i.material.roughness = 0.8, ["metalnessMap", "normalMap", "roughnessMap", "specularColorMap"].forEach((s) => {
|
|
15290
15290
|
const l = i.material[s];
|
|
@@ -16582,7 +16582,7 @@ function M_(a, t) {
|
|
|
16582
16582
|
}
|
|
16583
16583
|
const S_ = `{
|
|
16584
16584
|
"name": "@terra.gl/core",
|
|
16585
|
-
"version": "0.0.1-alpha.
|
|
16585
|
+
"version": "0.0.1-alpha.21",
|
|
16586
16586
|
"type": "module",
|
|
16587
16587
|
"files": [
|
|
16588
16588
|
"dist"
|
package/dist/index.umd.cjs
CHANGED
|
@@ -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 kb=Object.defineProperty;var Ob=(ee,m,ci)=>m in ee?kb(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:ci}):ee[m]=ci;var T=(ee,m,ci)=>Ob(ee,typeof m!="symbol"?m+"":m,ci);function ci(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const rt=ci(m),zh="0.0.1-alpha.
|
|
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 kb=Object.defineProperty;var Ob=(ee,m,ci)=>m in ee?kb(ee,m,{enumerable:!0,configurable:!0,writable:!0,value:ci}):ee[m]=ci;var T=(ee,m,ci)=>Ob(ee,typeof m!="symbol"?m+"":m,ci);function ci(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const rt=ci(m),zh="0.0.1-alpha.21",Ts={name:"Criska"};var Vi=function(){var a=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(++a%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";a=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(a,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,x=30*l,S=document.createElement("canvas");S.width=u,S.height=c,S.style.cssText="width:80px;height:48px";var _=S.getContext("2d");return _.font="bold "+9*l+"px Helvetica,Arial,sans-serif",_.textBaseline="top",_.fillStyle=e,_.fillRect(0,0,u,c),_.fillStyle=t,_.fillText(a,d,p),_.fillRect(f,y,v,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f,y,v,x),{dom:S,update:function(Z,M){n=Math.min(n,Z),i=Math.max(i,Z),_.fillStyle=e,_.globalAlpha=1,_.fillRect(0,0,u,y),_.fillStyle=t,_.fillText(s(Z)+" "+a+" ("+s(n)+"-"+s(i)+")",d,p),_.drawImage(S,f+l,y,v-l,x,f,y,v-l,x),_.fillRect(f+v-l,y,l,x),_.fillStyle=e,_.globalAlpha=.9,_.fillRect(f+v-l,y,l,s((1-Z/M)*x))}}};const gr=parseInt(m.REVISION.replace(/\D+/g,"")),Zs=gr>=125?"uv1":"uv2";function za(a,t){if(t===m.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),a;if(t===m.TriangleFanDrawMode||t===m.TriangleStripDrawMode){let e=a.getIndex();if(e===null){const l=[],u=a.getAttribute("position");if(u!==void 0){for(let c=0;c<u.count;c++)l.push(c);a.setIndex(l),e=a.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),a}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=a.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),a}var Zt=Uint8Array,_n=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]),ka=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]),Dh=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Oa=function(a,t){for(var e=new _n(31),n=0;n<31;++n)e[n]=t+=1<<a[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]},Ra=Oa(Da,2),Ka=Ra[0],kh=Ra[1];Ka[28]=258,kh[258]=28;for(var Oh=Oa(ka,0),Rh=Oh[0],Ws=new _n(32768),Ie=0;Ie<32768;++Ie){var Mn=(Ie&43690)>>>1|(Ie&21845)<<1;Mn=(Mn&52428)>>>2|(Mn&13107)<<2,Mn=(Mn&61680)>>>4|(Mn&3855)<<4,Ws[Ie]=((Mn&65280)>>>8|(Mn&255)<<8)>>>1}for(var Ai=function(a,t,e){for(var n=a.length,i=0,s=new _n(t);i<n;++i)++s[a[i]-1];var l=new _n(t);for(i=0;i<t;++i)l[i]=l[i-1]+s[i-1]<<1;var u;if(e){u=new _n(1<<t);var c=15-t;for(i=0;i<n;++i)if(a[i])for(var d=i<<4|a[i],p=t-a[i],f=l[a[i]-1]++<<p,y=f|(1<<p)-1;f<=y;++f)u[Ws[f]>>>c]=d}else for(u=new _n(n),i=0;i<n;++i)a[i]&&(u[i]=Ws[l[a[i]-1]++]>>>15-a[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 Ya=new Zt(32),Ie=0;Ie<32;++Ie)Ya[Ie]=5;var Kh=Ai(Fi,9,1),Yh=Ai(Ya,5,1),Ps=function(a){for(var t=a[0],e=1;e<a.length;++e)a[e]>t&&(t=a[e]);return t},Rt=function(a,t,e){var n=t/8|0;return(a[n]|a[n+1]<<8)>>(t&7)&e},Is=function(a,t){var e=t/8|0;return(a[e]|a[e+1]<<8|a[e+2]<<16)>>(t&7)},Uh=function(a){return(a/8|0)+(a&7&&1)},Bh=function(a,t,e){(e==null||e>a.length)&&(e=a.length);var n=new(a instanceof _n?_n:a instanceof Gs?Gs:Zt)(e-t);return n.set(a.subarray(t,e)),n},Nh=function(a,t,e){var n=a.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(je){var Je=t.length;if(je>Je){var Qe=new Zt(Math.max(Je*2,je));Qe.set(t),t=Qe}},u=e.f||0,c=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=u=Rt(a,c,1);var S=Rt(a,c+1,3);if(c+=3,S)if(S==1)p=Kh,f=Yh,y=9,v=5;else if(S==2){var G=Rt(a,c,31)+257,A=Rt(a,c+10,15)+4,R=G+Rt(a,c+5,31)+1;c+=14;for(var D=new Zt(R),k=new Zt(19),C=0;C<A;++C)k[Dh[C]]=Rt(a,c+C*3,7);c+=A*3;for(var K=Ps(k),I=(1<<K)-1,z=Ai(k,K,1),C=0;C<R;){var N=z[Rt(a,c,I)];c+=N&15;var _=N>>>4;if(_<16)D[C++]=_;else{var H=0,j=0;for(_==16?(j=3+Rt(a,c,3),c+=2,H=D[C-1]):_==17?(j=3+Rt(a,c,7),c+=3):_==18&&(j=11+Rt(a,c,127),c+=7);j--;)D[C++]=H}}var q=D.subarray(0,G),J=D.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 _=Uh(c)+4,Z=a[_-4]|a[_-3]<<8,M=_+Z;if(M>n){if(s)throw"unexpected EOF";break}i&&l(d+Z),t.set(a.subarray(_,M),d),e.b=d+=Z,e.p=c=M*8;continue}if(c>x){if(s)throw"unexpected EOF";break}}i&&l(d+131072);for(var oe=(1<<y)-1,re=(1<<v)-1,te=c;;te=c){var H=p[Is(a,c)&oe],me=H>>>4;if(c+=H&15,c>x){if(s)throw"unexpected EOF";break}if(!H)throw"invalid length/literal";if(me<256)t[d++]=me;else if(me==256){te=c,p=null;break}else{var be=me-254;if(me>264){var C=me-257,he=Da[C];be=Rt(a,c,(1<<he)-1)+Ka[C],c+=he}var ve=f[Is(a,c)&re],ze=ve>>>4;if(!ve)throw"invalid distance";c+=ve&15;var J=Rh[ze];if(ze>3){var he=ka[ze];J+=Is(a,c)&(1<<he)-1,c+=he}if(c>x){if(s)throw"unexpected EOF";break}i&&l(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&&(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(a){if((a[0]&15)!=8||a[0]>>>4>7||(a[0]<<8|a[1])%31)throw"invalid zlib data";if(a[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Qh(a,t){return Nh((Jh(a),a.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),x=e.distortionScale!==void 0?e.distortionScale:20,S=e.side!==void 0?e.side:m.FrontSide,_=e.fog!==void 0?e.fog:!1,Z=new m.Plane,M=new m.Vector3,G=new m.Vector3,A=new m.Vector3,R=new m.Matrix4,D=new m.Vector3(0,0,-1),k=new m.Vector4,C=new m.Vector3,K=new m.Vector3,I=new m.Vector4,z=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
|
|
|
@@ -514,7 +514,7 @@
|
|
|
514
514
|
`),e.fragmentShader=`varying float vOpacity;
|
|
515
515
|
`+e.fragmentShader.replace(`#include <${t}>`,`#include <${t}>
|
|
516
516
|
gl_FragColor = vec4(outgoingLight, diffuseColor.a * vOpacity);
|
|
517
|
-
`)}}};class kf extends m.Group{constructor({limit:t=200,range:e,material:n=m.MeshLambertMaterial,texture:i,frustumCulled:s=!0}={}){super(),this.name="Clouds",this.ref=this;const l=this,u=new m.PlaneGeometry(1,1),c=new Float32Array(Array.from({length:t},()=>1)),d=new Float32Array(Array.from({length:t},()=>[1,1,1]).flat()),p=new m.InstancedBufferAttribute(c,1);p.setUsage(m.DynamicDrawUsage),u.setAttribute("cloudOpacity",p);const f=Df(n),y=new f;y.map=i,y.transparent=!0,y.depthWrite=!1,y.needsUpdate=!0,this.cloudMaterial=y,this.instance=new m.InstancedMesh(u,y,t);const v=this.instance;v.matrixAutoUpdate=!1,v.frustumCulled=s,v.instanceColor=new m.InstancedBufferAttribute(d,3),v.instanceColor.setUsage(m.DynamicDrawUsage),l.add(v);const x=[],S=()=>{const k=x.length;let C=0;for(let K=0;K<this.ref.children.length;K++){const I=this.ref.children[K];I.cloudStateArray&&(C+=I.cloudStateArray.length)}if(k===C)return x;x.length=0;for(let K=0;K<this.ref.children.length;K++){const I=this.ref.children[K];I.cloudStateArray&&x.push(...I.cloudStateArray)}return _(),x},_=()=>{const k=Math.min(t,e!==void 0?e:t,x.length);v.count=k,$s(v.instanceMatrix,{offset:0,count:k*16}),v.instanceColor&&$s(v.instanceColor,{offset:0,count:k*3}),$s(v.geometry.attributes.cloudOpacity,{offset:0,count:k})};let Z=0,M=0,G;const A=new m.Quaternion,R=new m.Vector3(0,0,1),D=new m.Vector3;this.update=(k,C,K)=>{Z=C,Ll.copy(v.matrixWorld).invert(),k.matrixWorld.decompose(Sl,Tl,Bi);const I=S();for(M=0;M<I.length;M++)G=I[M],G.ref.matrixWorld.decompose(Zr,Gr,Bi),Zr.add(D.copy(G.position).applyQuaternion(Gr).multiply(Bi)),Gr.copy(Tl).multiply(A.setFromAxisAngle(R,G.rotation+=K*G.rotationFactor)),Bi.multiplyScalar(G.volume+(1+Math.sin(Z*G.density*G.speed))/2*G.growth),G.matrix.compose(Zr,Gr,Bi).premultiply(Ll),G.dist=Zr.distanceTo(Sl);for(I.sort((z,N)=>N.dist-z.dist),M=0;M<I.length;M++)G=I[M],c[M]=G.opacity*(G.dist<G.fade-1?G.dist/G.fade:1),v.setMatrixAt(M,G.matrix),v.setColorAt(M,G.color);v.geometry.attributes.cloudOpacity.needsUpdate=!0,v.instanceMatrix.needsUpdate=!0,v.instanceColor&&(v.instanceColor.needsUpdate=!0)}}}let Of=0;class Rf extends m.Group{constructor({opacity:t=1,speed:e=0,bounds:n=new m.Vector3().fromArray([5,1,1]),segments:i=20,color:s=new m.Color("#ffffff"),fade:l=10,volume:u=6,smallestVolume:c=.25,distribute:d=null,growth:p=4,concentrate:f="inside",seed:y=Math.random()}={}){super(),this.name="cloud_"+Of++,this.seed=y,this.segments=i,this.bounds=n,this.concentrate=f,this.volume=u,this.smallestVolume=c,this.distribute=d,this.growth=p,this.speed=e,this.fade=l,this.opacity=t,this.color=s,this.ref=this,this.cloudStateArray=[],this.updateCloud()}updateCloudStateArray(){if(this.cloudStateArray.length===this.segments)return;const{segments:t,uuid:e}=this;if(this.cloudStateArray.length>this.segments)this.cloudStateArray.splice(0,this.cloudStateArray.length-this.segments);else for(let n=this.cloudStateArray.length;n<t;n++)this.cloudStateArray.push({segments:t,bounds:new m.Vector3(1,1,1),position:new m.Vector3,uuid:e,index:n,ref:this,dist:0,matrix:new m.Matrix4,volume:0,length:0,speed:0,growth:0,opacity:1,fade:0,density:0,rotation:n*(Math.PI/t),rotationFactor:0,color:new m.Color})}updateCloud(){const{volume:t,color:e,speed:n,growth:i,opacity:s,fade:l,bounds:u,seed:c,cloudStateArray:d,distribute:p,segments:f,concentrate:y,smallestVolume:v}=this;this.updateCloudStateArray();let x=0;function S(){const _=Math.sin(c+x)*1e4;return x++,_-Math.floor(_)}d.forEach((_,Z)=>{_.segments=f,_.volume=t,_.color=e,_.speed=n,_.growth=i,_.opacity=s,_.fade=l,_.bounds.copy(u),_.density=Math.max(.5,S()),_.rotationFactor=Math.max(.2,.5*S())*n;const M=p?.(_,Z);if(M||f>1){var G;_.position.copy(_.bounds).multiply((G=M?.point)!==null&&G!==void 0?G:{x:S()*2-1,y:S()*2-1,z:S()*2-1})}const A=Math.abs(_.position.x),R=Math.abs(_.position.y),D=Math.abs(_.position.z),k=Math.max(A,R,D);_.length=1,A===k&&(_.length-=A/_.bounds.x),R===k&&(_.length-=R/_.bounds.y),D===k&&(_.length-=D/_.bounds.z),_.volume=(M?.volume!==void 0?M.volume:Math.max(Math.max(0,v),y==="random"?S():y==="inside"?_.length:1-_.length))*t})}}class eo{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t<this.pool;t++)if(!(this.workerStatus&1<<t))return t;return-1}_onMessage(t,e){const n=this.workersResolve[t];if(n&&n(e),this.queue.length){const{resolve:i,msg:s,transfer:l}=this.queue.shift();this.workersResolve[t]=i,this.workers[t].postMessage(s,l)}else this.workerStatus^=1<<t}setWorkerCreator(t){this.workerCreator=t}setWorkerLimit(t){this.pool=t}postMessage(t,e){return new Promise(n=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(t,e)):this.queue.push({resolve:n,msg:t,transfer:e})})}dispose(){this.workers.forEach(t=>t.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}function Zl(a,t){const e=new m.BufferGeometry;e.setAttribute("position",new m.BufferAttribute(new Float32Array([0,0,0]),3));const n=new m.Points(e,new m.PointsMaterial({size:a.size,color:a.color||16777215,sizeAttenuation:!a.glow,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}));return n.position.copy(t),n}async function Kf(a,t){let e=null;try{e=await Wt._loadTexture(a.url)}catch(d){console.error("IconPoint texture load failed:",a.url,d)}const n=new m.SpriteMaterial({map:e??null,color:a.color||16777215,transparent
|
|
517
|
+
`)}}};class kf extends m.Group{constructor({limit:t=200,range:e,material:n=m.MeshLambertMaterial,texture:i,frustumCulled:s=!0}={}){super(),this.name="Clouds",this.ref=this;const l=this,u=new m.PlaneGeometry(1,1),c=new Float32Array(Array.from({length:t},()=>1)),d=new Float32Array(Array.from({length:t},()=>[1,1,1]).flat()),p=new m.InstancedBufferAttribute(c,1);p.setUsage(m.DynamicDrawUsage),u.setAttribute("cloudOpacity",p);const f=Df(n),y=new f;y.map=i,y.transparent=!0,y.depthWrite=!1,y.needsUpdate=!0,this.cloudMaterial=y,this.instance=new m.InstancedMesh(u,y,t);const v=this.instance;v.matrixAutoUpdate=!1,v.frustumCulled=s,v.instanceColor=new m.InstancedBufferAttribute(d,3),v.instanceColor.setUsage(m.DynamicDrawUsage),l.add(v);const x=[],S=()=>{const k=x.length;let C=0;for(let K=0;K<this.ref.children.length;K++){const I=this.ref.children[K];I.cloudStateArray&&(C+=I.cloudStateArray.length)}if(k===C)return x;x.length=0;for(let K=0;K<this.ref.children.length;K++){const I=this.ref.children[K];I.cloudStateArray&&x.push(...I.cloudStateArray)}return _(),x},_=()=>{const k=Math.min(t,e!==void 0?e:t,x.length);v.count=k,$s(v.instanceMatrix,{offset:0,count:k*16}),v.instanceColor&&$s(v.instanceColor,{offset:0,count:k*3}),$s(v.geometry.attributes.cloudOpacity,{offset:0,count:k})};let Z=0,M=0,G;const A=new m.Quaternion,R=new m.Vector3(0,0,1),D=new m.Vector3;this.update=(k,C,K)=>{Z=C,Ll.copy(v.matrixWorld).invert(),k.matrixWorld.decompose(Sl,Tl,Bi);const I=S();for(M=0;M<I.length;M++)G=I[M],G.ref.matrixWorld.decompose(Zr,Gr,Bi),Zr.add(D.copy(G.position).applyQuaternion(Gr).multiply(Bi)),Gr.copy(Tl).multiply(A.setFromAxisAngle(R,G.rotation+=K*G.rotationFactor)),Bi.multiplyScalar(G.volume+(1+Math.sin(Z*G.density*G.speed))/2*G.growth),G.matrix.compose(Zr,Gr,Bi).premultiply(Ll),G.dist=Zr.distanceTo(Sl);for(I.sort((z,N)=>N.dist-z.dist),M=0;M<I.length;M++)G=I[M],c[M]=G.opacity*(G.dist<G.fade-1?G.dist/G.fade:1),v.setMatrixAt(M,G.matrix),v.setColorAt(M,G.color);v.geometry.attributes.cloudOpacity.needsUpdate=!0,v.instanceMatrix.needsUpdate=!0,v.instanceColor&&(v.instanceColor.needsUpdate=!0)}}}let Of=0;class Rf extends m.Group{constructor({opacity:t=1,speed:e=0,bounds:n=new m.Vector3().fromArray([5,1,1]),segments:i=20,color:s=new m.Color("#ffffff"),fade:l=10,volume:u=6,smallestVolume:c=.25,distribute:d=null,growth:p=4,concentrate:f="inside",seed:y=Math.random()}={}){super(),this.name="cloud_"+Of++,this.seed=y,this.segments=i,this.bounds=n,this.concentrate=f,this.volume=u,this.smallestVolume=c,this.distribute=d,this.growth=p,this.speed=e,this.fade=l,this.opacity=t,this.color=s,this.ref=this,this.cloudStateArray=[],this.updateCloud()}updateCloudStateArray(){if(this.cloudStateArray.length===this.segments)return;const{segments:t,uuid:e}=this;if(this.cloudStateArray.length>this.segments)this.cloudStateArray.splice(0,this.cloudStateArray.length-this.segments);else for(let n=this.cloudStateArray.length;n<t;n++)this.cloudStateArray.push({segments:t,bounds:new m.Vector3(1,1,1),position:new m.Vector3,uuid:e,index:n,ref:this,dist:0,matrix:new m.Matrix4,volume:0,length:0,speed:0,growth:0,opacity:1,fade:0,density:0,rotation:n*(Math.PI/t),rotationFactor:0,color:new m.Color})}updateCloud(){const{volume:t,color:e,speed:n,growth:i,opacity:s,fade:l,bounds:u,seed:c,cloudStateArray:d,distribute:p,segments:f,concentrate:y,smallestVolume:v}=this;this.updateCloudStateArray();let x=0;function S(){const _=Math.sin(c+x)*1e4;return x++,_-Math.floor(_)}d.forEach((_,Z)=>{_.segments=f,_.volume=t,_.color=e,_.speed=n,_.growth=i,_.opacity=s,_.fade=l,_.bounds.copy(u),_.density=Math.max(.5,S()),_.rotationFactor=Math.max(.2,.5*S())*n;const M=p?.(_,Z);if(M||f>1){var G;_.position.copy(_.bounds).multiply((G=M?.point)!==null&&G!==void 0?G:{x:S()*2-1,y:S()*2-1,z:S()*2-1})}const A=Math.abs(_.position.x),R=Math.abs(_.position.y),D=Math.abs(_.position.z),k=Math.max(A,R,D);_.length=1,A===k&&(_.length-=A/_.bounds.x),R===k&&(_.length-=R/_.bounds.y),D===k&&(_.length-=D/_.bounds.z),_.volume=(M?.volume!==void 0?M.volume:Math.max(Math.max(0,v),y==="random"?S():y==="inside"?_.length:1-_.length))*t})}}class eo{constructor(t=4){this.pool=t,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(t){if(!this.workers[t]){const e=this.workerCreator();e.addEventListener("message",this._onMessage.bind(this,t)),this.workers[t]=e}}_getIdleWorker(){for(let t=0;t<this.pool;t++)if(!(this.workerStatus&1<<t))return t;return-1}_onMessage(t,e){const n=this.workersResolve[t];if(n&&n(e),this.queue.length){const{resolve:i,msg:s,transfer:l}=this.queue.shift();this.workersResolve[t]=i,this.workers[t].postMessage(s,l)}else this.workerStatus^=1<<t}setWorkerCreator(t){this.workerCreator=t}setWorkerLimit(t){this.pool=t}postMessage(t,e){return new Promise(n=>{const i=this._getIdleWorker();i!==-1?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(t,e)):this.queue.push({resolve:n,msg:t,transfer:e})})}dispose(){this.workers.forEach(t=>t.terminate()),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}function Zl(a,t){const e=new m.BufferGeometry;e.setAttribute("position",new m.BufferAttribute(new Float32Array([0,0,0]),3));const n=new m.Points(e,new m.PointsMaterial({size:a.size,color:a.color||16777215,sizeAttenuation:!a.glow,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}));return n.position.copy(t),n}async function Kf(a,t){let e=null;try{e=await Wt._loadTexture(a.url)}catch(d){console.error("IconPoint texture load failed:",a.url,d)}const n=new m.SpriteMaterial({map:e??null,color:a.color||16777215,transparent:a.transparent??!0,opacity:a.opacity??1,sizeAttenuation:a.sizeAttenuation??!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),i=new m.Sprite(n),s=.002,l=a.size,[u,c]=Array.isArray(l)?l:[l,l];return i.scale.set(u*s,c*s,1),a.rotation&&(i.rotation.z=a.rotation),a.anchor&&i.center.set(a.anchor[0],a.anchor[1]),i.position.copy(t),i}function to(a,t){let e;t instanceof Float32Array?e=Array.from(t):Array.isArray(t)&&typeof t[0]=="number"?e=t:e=t.flatMap(s=>[s.x,s.y,s.z]);const n=new xr;n.setPositions(e);const i=new zi({color:new m.Color(a.color??16777215).getHex(),linewidth:a.width??2,transparent:a.transparent??!0,opacity:a.opacity??1,dashed:!!a.dashArray,dashScale:a.dashArray?.[0]??1,dashSize:a.dashArray?.[0]??1,gapSize:a.dashArray?.[1]??0,resolution:new m.Vector2(window.innerWidth,window.innerHeight),alphaToCoverage:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0});return window.addEventListener("resize",()=>{i.resolution.set(window.innerWidth,window.innerHeight)}),new Ys(n,i)}async function Yf(a,t){const e=a.type||(a.url.toLowerCase().endsWith(".fbx")?"fbx":"gltf");return await qs.init().load({...a,type:e,position:t})}function Uf(a,t){const{geometry:e,center:n,avgY:i}=no(t),s=a.depthOffset??0,l=s!==0,u=new m.MeshBasicMaterial({color:new m.Color(a.color??16777215),transparent:a.transparent??!0,opacity:a.opacity??1,wireframe:a.wireframe??!1,side:a.side==="back"?m.BackSide:a.side==="double"?m.DoubleSide:m.FrontSide,polygonOffset:l,polygonOffsetFactor:l?s:0,polygonOffsetUnits:l?s:0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),c=new m.Mesh(e,u);if(c.rotation.x=-Math.PI/2,c.position.set(n.x,i,n.z),(a.borderWidth??0)>0){const f={color:a.borderColor??a.color??0,width:a.borderWidth,opacity:a.opacity},y=[];for(let x=0;x<t.length;x+=3){const S=t[x],_=t[x+2];y.push(S-n.x,-(_-n.z),0)}const v=to(f,y);v.position.z+=.1,c.add(v)}return c}function Bf(a,t){const e=a.extrude?.height||2e3,n=[],i=[],s=[];for(let f=0;f<t.length;f+=3){const y=t[f],v=t[f+1],x=t[f+2];i.push(new m.Vector3(y,v,x)),s.push(new m.Vector3(y,v+e,x))}n.push(...i,...s);const l=new m.BufferGeometry;l.setFromPoints(n);const u=[],c=i.length;for(let f=0;f<c;f++){const y=(f+1)%c;u.push(f,f+c,y),u.push(y,f+c,y+c)}for(let f=2;f<c;f++)u.push(0,f-1,f),u.push(c,c+f-1,c+f);l.setIndex(u),l.computeVertexNormals();const d=new m.ShaderMaterial({uniforms:{uColor:{value:new m.Color(a.color??16777215)},uOpacity:{value:a.opacity??1},uBrightness:{value:1.2}},vertexShader:`
|
|
518
518
|
varying vec3 vWorldPosition;
|
|
519
519
|
varying vec3 vNormal;
|
|
520
520
|
void main() {
|
|
@@ -536,7 +536,7 @@
|
|
|
536
536
|
gl_FragColor = vec4(finalColor, uOpacity);
|
|
537
537
|
if (uOpacity >= 0.99) gl_FragDepthEXT = gl_FragCoord.z;
|
|
538
538
|
}
|
|
539
|
-
`,transparent:!0,side:m.DoubleSide,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0});return new m.Mesh(l,d)}function Nf(a,t,e){const{geometry:n,center:i,avgY:s}=no(e),l=new qh(n,{textureWidth:512,textureHeight:512,waterNormals:new m.TextureLoader().load(a.normalMap,function(d){d.wrapS=d.wrapT=m.RepeatWrapping}),waterColor:a.color||"#19AAEE",sunColor:a.sunColor||"#05FFF8",distortionScale:1,alpha:a.opacity||.8}),u=l.onBeforeRender,c=l.onAfterRender;return l.onBeforeRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!1,u.call(l,d,p,f,y,v,x)},l.onAfterRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!0,c.call(l,d,p,f,y,v,x)},l.material.uniforms.size.value=.1,l.rotation.x=-Math.PI/2,l.position.set(i.x,s,i.z),t.viewer.addEventListener("update",()=>{l.material.uniforms.time.value+=1/60}),l}function no(a){let t=0;for(let l=1;l<a.length;l+=3)t+=a[l];t/=a.length/3;const e={x:0,z:0},n=[];for(let l=0;l<a.length;l+=3)e.x+=a[l],e.z+=a[l+2];e.x/=a.length/3,e.z/=a.length/3;for(let l=0;l<a.length;l+=3)n.push(new m.Vector2(a[l]-e.x,-(a[l+2]-e.z)));const i=new m.Shape(n);return{geometry:new m.ShapeGeometry(i),center:e,avgY:t}}async function jf(a,t){const{geometry:e,center:n,avgY:i}=no(t),s=await Wt._loadTexture(a.normalMap),l=await Wt._loadTexture(a.normalMap);s.wrapS=s.wrapT=m.RepeatWrapping,l.wrapS=l.wrapT=m.RepeatWrapping,s.repeat.set(.015,.015),l.repeat.set(.005,.005);const u=new m.MeshStandardMaterial({color:new m.Color(a.color).multiplyScalar(3.5),roughness:.1,metalness:.8,transparent:!0,opacity:.9,fog:!1,normalMap:s,normalScale:new m.Vector2(1.5,1.5),envMapIntensity:2,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),c=new m.Mesh(e,u);c.rotation.x=-Math.PI/2,c.position.set(n.x,i+.15,n.z),c.castShadow=!1,c.receiveShadow=!0;let d=0;return c.onBeforeRender=()=>{const p=performance.now(),f=d?(p-d)/1e3:.016;s.offset.x+=f*.08,s.offset.y+=f*.03,l.offset.x-=f*.12,l.offset.y+=f*.02,c.position.y=i+.5+Math.sin(p*.02)*.02,d=p},c}function Jf(a,t){a.color=new m.Color(a.hexcolor),a.boundstext&&(a.bounds=new m.Vector3(a.boundstext.x,a.boundstext.y,a.boundstext.z));const e=new Rf(a);return e.castShadow=!0,e.scale.setScalar(50),e.position.copy(t),e}async function Qf(a,t){const n={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,fixedSize:50},...a};n.screenSpaceSize==null&&n.fixedSize!=null&&(n.screenSpaceSize=n.fixedSize);const s=(typeof window<"u"&&window.devicePixelRatio||1)*4,l=a.screenSpaceSize!=null||a.fixedSize!=null;if(a.fontSizeDpi==null&&l){const A=a.screenSpaceSize??a.fixedSize??n.screenSpaceSize;n.fontSizeDpi=A*s}n.fontSizeDpi=Math.min(Math.max(n.fontSizeDpi,8),128);const u=document.createElement("canvas"),c=u.getContext("2d");if(!c)throw new Error("canvas context is null");const d=`${n.fontStyle} ${n.fontWeight} ${n.fontSizeDpi}px ${n.fontFamily}`;c.font=d;const p=n.showBackground?20:0,f=100,y=50,v=c.measureText(n.text),x=Math.max(f,v.width+p*2),S=Math.max(y,n.fontSizeDpi*1.5+p*2);u.width=Math.min(x,2048),u.height=Math.min(S,2048),c.clearRect(0,0,u.width,u.height),c.font=d,n.showBackground&&(n.bgStyle===1?(c.fillStyle=n.bgColor,c.globalAlpha=n.bgOpacity,c.beginPath(),Gl(c,p/2,p/2,u.width-p,u.height-p,n.roundRectRadius),c.fill(),c.globalAlpha=1,c.shadowColor=n.shadowColor,c.shadowBlur=n.shadowBlur,c.shadowOffsetX=n.shadowOffsetX,c.shadowOffsetY=n.shadowOffsetY):(c.fillStyle=n.bgColor,c.globalAlpha=n.bgOpacity,c.beginPath(),Wl(c,u.width/2,u.height/2,u.width*.8,u.height*.8,n.roundRectRadius,n.bubblePointerHeight,n.bubblePointerWidth),c.fill(),c.globalAlpha=1,c.strokeStyle=n.bubbleBorderColor,c.lineWidth=n.bubbleBorderWidth,c.stroke())),c.textAlign="center",c.textBaseline="middle",n.strokeWidth>0&&(c.strokeStyle=n.strokeColor,c.lineWidth=n.strokeWidth,c.lineJoin="round",c.strokeText(n.text,u.width/2,u.height/2)),c.fillStyle=n.textColor,c.fillText(n.text,u.width/2,u.height/2),c.shadowColor="transparent";const _=new m.CanvasTexture(u);_.magFilter=m.NearestFilter,_.minFilter=m.LinearMipmapLinearFilter,_.anisotropy=16;const Z=new m.SpriteMaterial({map:_,transparent:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,fog:!1}),M=new m.Sprite(Z),G=n.screenSpaceSize??n.fixedSize;return M.scale.set(u.width*G/100,u.height*G/100,1),t&&M.position.copy(t),M}async function Hf(a,t,e){const i={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,maxVisibleDistance:1/0},...a};i.screenSpaceSize==null&&a.fixedSize!=null&&(i.screenSpaceSize=a.fixedSize);const l=(typeof window<"u"&&window.devicePixelRatio||1)*4;a.fontSizeDpi==null&&(i.fontSizeDpi=i.screenSpaceSize*l),i.fontSizeDpi=Math.max(i.fontSizeDpi,8);const u=document.createElement("canvas"),c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");const d=`${i.fontStyle} ${i.fontWeight} ${i.fontSizeDpi}px ${i.fontFamily}`;c.font=d;const p=i.showBackground?20:0,f=100,y=50,v=c.measureText(i.text),x=Math.max(f,v.width+p*2),S=Math.max(y,i.fontSizeDpi*1.5+p*2);u.width=Math.min(x,2048),u.height=Math.min(S,2048),c.clearRect(0,0,u.width,u.height),c.font=d,i.showBackground&&(i.bgStyle===1?(c.fillStyle=i.bgColor,c.globalAlpha=i.bgOpacity,c.beginPath(),Gl(c,p/2,p/2,u.width-p,u.height-p,i.roundRectRadius),c.fill(),c.globalAlpha=1,c.shadowColor=i.shadowColor,c.shadowBlur=i.shadowBlur,c.shadowOffsetX=i.shadowOffsetX,c.shadowOffsetY=i.shadowOffsetY):(c.fillStyle=i.bgColor,c.globalAlpha=i.bgOpacity,c.beginPath(),Wl(c,u.width/2,u.height/2,u.width*.8,u.height*.8,i.roundRectRadius,i.bubblePointerHeight,i.bubblePointerWidth),c.fill(),c.globalAlpha=1,c.strokeStyle=i.bubbleBorderColor,c.lineWidth=i.bubbleBorderWidth,c.stroke())),c.textAlign="center",c.textBaseline="middle",i.strokeWidth>0&&(c.strokeStyle=i.strokeColor,c.lineWidth=i.strokeWidth,c.lineJoin="round",c.strokeText(i.text,u.width/2,u.height/2)),c.fillStyle=i.textColor,c.fillText(i.text,u.width/2,u.height/2),c.shadowColor="transparent";const _=new m.CanvasTexture(u),Z=new m.SpriteMaterial({map:_,transparent:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,fog:!1}),M=new m.Sprite(Z);M.position.copy(t),M.userData.isLabel=!0;const G=()=>{if(!M.visible)return;const R=e.viewer.camera.position.distanceTo(M.position);if(R>i.maxVisibleDistance){M.visible=!1;return}M.visible=!0;const D=new m.Vector2;e.viewer.renderer.getSize(D);const k=D.height,C=m.MathUtils.degToRad(e.viewer.camera.fov),K=typeof window<"u"&&window.devicePixelRatio||1,z=i.screenSpaceSize*K/u.height*(2*R*Math.tan(C/2)/k);M.scale.set(z*u.width,z*u.height,1),M.lookAt(e.viewer.camera.position)};G();const A=()=>G();return M.addEventListener("dispose",()=>{e.viewer.renderer.domElement.removeEventListener("resize",G)}),e.viewer.renderer.domElement.addEventListener("resize",G),e.viewer.camera.addEventListener("change",G),M.onBeforeRender=A,M}function Gl(a,t,e,n,i,s){a.beginPath(),a.moveTo(t+s,e),a.lineTo(t+n-s,e),a.quadraticCurveTo(t+n,e,t+n,e+s),a.lineTo(t+n,e+i-s),a.quadraticCurveTo(t+n,e+i,t+n-s,e+i),a.lineTo(t+s,e+i),a.quadraticCurveTo(t,e+i,t,e+i-s),a.lineTo(t,e+s),a.quadraticCurveTo(t,e,t+s,e),a.closePath()}function Wl(a,t,e,n,i,s,l,u){if(n<=0)throw new Error("Width must be positive");if(i<=0)throw new Error("Height must be positive");if(s<0)throw new Error("Radius cannot be negative");const c=n,d=i,p=Math.min(s,n/2,i/2),f=l??10,y=u??15;a.beginPath(),a.moveTo(t-c/2+p,e-d/2),a.lineTo(t+c/2-p,e-d/2),a.quadraticCurveTo(t+c/2,e-d/2,t+c/2,e-d/2+p),a.lineTo(t+c/2,e+d/2-p),a.quadraticCurveTo(t+c/2,e+d/2,t+c/2-p,e+d/2),a.lineTo(t+y/2,e+d/2),a.lineTo(t,e+d/2+f),a.lineTo(t-y/2,e+d/2),a.lineTo(t-c/2+p,e+d/2),a.quadraticCurveTo(t-c/2,e+d/2,t-c/2,e+d/2-p),a.lineTo(t-c/2,e-d/2+p),a.quadraticCurveTo(t-c/2,e-d/2,t-c/2+p,e-d/2),a.closePath()}async function Ef(a,t,e){const{text:n,iconUrl:i,fontSize:s=30,iconSize:l=60,fontFamily:u="Arial",padding:c={},bgColor:d="rgba(0,0,0,0.0)",textColor:p="rgb(255,255,255)",strokeColor:f="rgb(0,0,0)",strokeWidth:y=s/9,iconScale:v=.8,canvasScale:x=1,renderbg:S=!0,textOffset:_={x:0,y:0}}=a,Z={top:0,right:1,bottom:0,left:0,...c};let M=null;i&&(M=await $f(i));const{canvas:G,width:A,height:R,center:D}=await qf({text:n,iconImage:M,fontSize:s,iconSize:l,fontFamily:u,padding:Z,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:S,textOffset:_},t),k=new m.Texture(G);k.needsUpdate=!0;const C=new m.SpriteMaterial({map:k,transparent:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,blending:m.NormalBlending,sizeAttenuation:!1,alphaTest:.01}),K=new m.Sprite(C),I=.001;return K.scale.set(A*I,R*I,1),K.center.set(D[0],D[1]),e&&K.position.copy(e),K}async function qf(a,t){return new Promise(e=>{const{text:n,iconImage:i,fontSize:s,iconSize:l,fontFamily:u,padding:c,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:S,textOffset:_={x:0,y:0}}=a,M=document.createElement("canvas").getContext("2d");if(!M)throw new Error("Could not get temp canvas context");M.font=`500 ${s}px ${u}`;const G=M.measureText(n),A=G.width,R=G.actualBoundingBoxAscent||s*.8,D=G.actualBoundingBoxDescent||s*.2,k=i!==null;let C=0,K=0,I=0,z=0;if(k){C=0,K=0,I=l,z=l;const he=l/2+_.x,ve=l/2+_.y,ze=he,Ye=he+A,je=ve-R,Je=ve+D;C=Math.min(C,ze),I=Math.max(I,Ye),K=Math.min(K,je),z=Math.max(z,Je)}else{const he=_.x,ve=_.x+A,ze=_.y-R,Ye=_.y+D;C=he,I=ve,K=ze,z=Ye}const N=I-C,H=z-K,j=Math.ceil(N+c.left+c.right)*x,q=Math.ceil(H+c.top+c.bottom)*x,J=c.left-C,oe=c.top-K,re=t._getCanvas(j,q,n);re.width=j,re.height=q;const te=re.getContext("2d");if(!te)throw new Error("Could not get canvas context");te.clearRect(0,0,j,q),te.globalCompositeOperation="source-over",te.save(),te.scale(x,x);const me=j/x,be=q/x;if(S&&(te.fillStyle=d,te.fillRect(0,0,me,be)),i){const he=J,ve=oe,ze=l*v,Ye=(l-ze)/2,je=(l-ze)/2;te.imageSmoothingEnabled=!1,te.drawImage(i,he+Ye,ve+je,ze,ze),te.font=`500 ${s}px ${u}`,te.textBaseline="alphabetic",te.textAlign="left";const Je=J+l/2+_.x,Qe=oe+l/2+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,Je,Qe)),te.fillStyle=p,te.fillText(n,Je,Qe)}else{te.font=`500 ${s}px ${u}`,te.textBaseline="alphabetic",te.textAlign="left";const he=J+_.x,ve=oe+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,he,ve)),te.fillStyle=p,te.fillText(n,he,ve)}te.restore(),e({canvas:re,width:me,height:be,center:[(l*.5+c.left)/me,(1-v)*.5]})})}function $f(a){return new Promise((t,e)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>t(n),n.onerror=i=>e(new Error(`Failed to load image: ${a} ${i}`)),n.src=a})}async function ep(a,t,e){const i=new m.CylinderGeometry(.2,.2,24,12),s=new m.MeshBasicMaterial({color:a.color}),l=await Wt._loadTexture(a.icon),u=new m.PointsMaterial({size:80*window.innerHeight/window.innerHeight,fog:!1,opacity:1,transparent:!0,toneMapped:!1,blending:m.AdditiveBlending,map:l,sizeAttenuation:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!1}),c=new m.InstancedMesh(i,s,t.length);c.position.add(e.prjcenter),c.castShadow=!0;const d=new m.Object3D,p=[];for(let x=0;x<t.length;x++){const S=t[x],_=new m.Vector3(S.coordinates[0],S.coordinates[1],S.coordinates[2]||0),M=e.geo2world(_).sub(e.prjcenter);d.position.copy(M),d.updateMatrix(),c.setMatrixAt(x,d.matrix),p.push(M.x,0,M.z)}const f=new Float32Array(p),y=new m.BufferGeometry;y.setAttribute("position",new m.BufferAttribute(f,3));const v=new m.Points(y,u);return v.position.add(e.prjcenter),v.position.y=1.5*10,v.renderOrder=99999999,v.visible=!0,console.log(e,"map"),{points:v,InstancedCol:c}}const rn=class rn{constructor(t){this.config=t}async applyTo(t){if(!t)return!1;try{switch(t.visible=this.config.visible!==!1,this.config.type){case"basic-point":case"icon-point":case"icon-label-point":return this._applyPointStyle(t);case"basic-line":return this._applyLineStyle(t);case"gltf":case"fbx":return this._applyModelStyle(t);case"basic-polygon":return this._applyPolygonStyle(t);case"extrude-polygon":return this._applyExtrudeStyle(t);case"water":case"base-water":return this._applyWaterStyle(t);case"cloud":return this._applyCloudStyle(t);case"canvas-label":case"canvas-label-fixed":return this._applyTextSpriteStyle(t);case"light":return this._applyLightStyle(t);case"custom":return this._applyCustomStyle(t);default:throw new Error("Unknown style type")}}catch(e){return console.error("Style apply failed:",e),t.visible=!1,!1}}async _applyPointStyle(t){const e=this.config;return e.type==="icon-point"?await this._applyIconPoint(t,e):e.type==="basic-point"?this._applyBasicPoint(t,e):e.type==="icon-label-point"&&this._applyIconLabelPoint(t,e),!0}async _applyIconPoint(t,e){return!0}_applyBasicPoint(t,e){let n;if(t instanceof m.Points)n=t;else if(n=Zl(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),t.parent){let s=t.parent;s._threeGeometry=n,s._updateGeometry()}const i=n.material;i.size=e.size,e.color&&i.color.set(e.color),e.glow&&(i.sizeAttenuation=!1)}_applyIconLabelPoint(t,e){return!0}_applyLineStyle(t){return this.config,!0}_applyPolygonStyle(t){return!0}_applyExtrudeStyle(t){return!0}_applyWaterStyle(t){return!0}_applyCloudStyle(t){return!0}_applyTextSpriteStyle(t){return!0}_applyLightStyle(t){return!0}async _applyModelStyle(t){return!0}async _applyCustomStyle(t){const n=await this.config.build();return t instanceof m.Group&&(t.clear(),t.add(n)),!0}static async _loadTexture(t){if(rn._textureCache.has(t))return rn._textureCache.get(t);const e=await new Promise((n,i)=>{rn._textureLoader.load(t,n,void 0,i)});return e.premultiplyAlpha=!0,rn._textureCache.set(t,e),e}static create(t){return t instanceof rn?t:new rn(t)}};T(rn,"_textureCache",new Map),T(rn,"_textureLoader",new m.TextureLoader);let Wt=rn;const et=[];for(let a=0;a<256;++a)et.push((a+256).toString(16).slice(1));function tp(a,t=0){return(et[a[t+0]]+et[a[t+1]]+et[a[t+2]]+et[a[t+3]]+"-"+et[a[t+4]]+et[a[t+5]]+"-"+et[a[t+6]]+et[a[t+7]]+"-"+et[a[t+8]]+et[a[t+9]]+"-"+et[a[t+10]]+et[a[t+11]]+et[a[t+12]]+et[a[t+13]]+et[a[t+14]]+et[a[t+15]]).toLowerCase()}let io;const np=new Uint8Array(16);function ip(){if(!io){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");io=crypto.getRandomValues.bind(crypto)}return io(np)}const Pl={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rp(a,t,e){if(Pl.randomUUID&&!a)return Pl.randomUUID();a=a||{};const n=a.random??a.rng?.()??ip();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,tp(n)}var Il=(a=>(a.POINT="point",a.LINE_VERTEX="line_vertex",a.POLYGON_CENTER="polygon_center",a.LABEL="label",a.ICON="icon",a.CLUSTER="cluster",a))(Il||{}),nn=(a=>(a.NO_COLLISION="no_collision",a.PRIORITY_LOST="priority_lost",a.OUT_OF_VIEWPORT="out_of_viewport",a.ZOOM_FILTERED="zoom_filtered",a.MANUAL_HIDDEN="manual_hidden",a.GROUP_COLLISION="group_collision",a))(nn||{});class hn extends Es(Yi(Ui(m.Object3D))){constructor(e){super();T(this,"_position");T(this,"_threeGeometry");T(this,"_geometry");T(this,"_layer");T(this,"_style");T(this,"_id");T(this,"_styleQueue",[]);T(this,"_isApplyingStyle",!1);T(this,"_isGeometryInitializing",!1);T(this,"_collisionState",{visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:Date.now()});T(this,"_collisionConfig",{enabled:!0,priority:50,padding:4,minZoom:0,maxZoom:24});T(this,"_animationRef",null);Ns(e.geometry,"geometry","geometry must be specified"),this._geometry=e.geometry,this._position=new m.Vector3(0,0,0),this._threeGeometry=new m.Object3D,e.userData&&(this.userData=Object.assign({},JSON.parse(JSON.stringify(e.userData)))),e.style&&this.setStyle(e.style),e.id?this._id=e.id:this._id=rp()}async initializeGeometry(){if(!(this._isGeometryInitializing||this._threeGeometry)){this._isGeometryInitializing=!0;try{await this._toThreeJSGeometry(),this._processStyleQueue()}finally{this._isGeometryInitializing=!1}}}setStyle(e){const n=e instanceof Wt?e:new Wt(e);this._style=n;const i=JSON.parse(JSON.stringify(n.config));return this._styleQueue.push(i),this._tryProcessQueue(),this}getStyle(){return this._style}async _applyStyleWithRetry(e,n=3,i=100){let s=null;for(let l=1;l<=n;l++)try{this._threeGeometry.parent||(this.add(this._threeGeometry),await new Promise(u=>requestAnimationFrame(u))),await e.applyTo(this._threeGeometry);return}catch(u){if(s=u,l<n){const c=i*Math.pow(2,l-1);await new Promise(d=>setTimeout(d,c))}}throw s||new Error("样式应用失败,重试次数耗尽")}async _processStyleQueue(){if(!this._threeGeometry||this._isApplyingStyle||this._styleQueue.length===0)return;this._isApplyingStyle=!0;const e=this._styleQueue[0];try{const n=new Wt(JSON.parse(JSON.stringify(e)));await this._applyStyleWithRetry(n),this._styleQueue.shift(),this._styleQueue.length>0&&await this._processStyleQueue()}catch(n){throw n}finally{this._isApplyingStyle=!1,this._styleQueue.length>0&&this._tryProcessQueue()}}_tryProcessQueue(){this._threeGeometry&&!this._isApplyingStyle&&this._styleQueue.length>0?this._processStyleQueue().catch(n=>{this._isApplyingStyle=!1,this._tryProcessQueue(),console.warn(n)}):!this._threeGeometry&&!this._isGeometryInitializing&&this.initializeGeometry()}addTo(e){return e.addFeature(this),this}getLayer(){return this._layer||null}getMap(){return this._layer?.getMap()||null}_bindLayer(e){if(this._layer&&this._layer!==e)throw new Error("Feature cannot be added to multiple layers");this._layer=e}_updateGeometry(){this._disposeGeometry(),this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry?.userData?._type==="Model"?this._threeGeometry.renderOrder=0:this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue())}_remove(){return this.getLayer()?(this._unbind(),this):this}_unbind(){const e=this.getLayer();e&&(e.onRemoveFeature&&e.onRemoveFeature(this),delete this._layer)}_disposeGeometry(){this._threeGeometry&&(this.clear(),"traverse"in this&&this._threeGeometry.traverse(e=>{e instanceof m.Mesh?(e.geometry?.dispose(),Array.isArray(e.material)?e.material.forEach(n=>n.dispose()):e.material?.dispose()):"isLine"in e&&e.isLine&&(e.geometry?.dispose(),e.material?.dispose())}))}get collidable(){return this._collisionConfig.enabled}get collisionType(){return Il.POINT}getCollisionPriority(){return this.userData.collisionPriority??this._style?.config.collisionPriority??this._collisionConfig.priority}getScreenBoundingBox(e,n){if(!this.collidable)return null;try{const i=new m.Vector3;this._threeGeometry.getWorldPosition(i);const s=i.clone().project(e);if(!(s.x>=-1.1&&s.x<=1.1&&s.y>=-1.1&&s.y<=1.1&&s.z>=-1&&s.z<=1))return null;const{width:u,height:c}=n.domElement,d=(s.x*.5+.5)*u,p=(-s.y*.5+.5)*c,f=this._calculateCollisionBoundingBox(e,n);return f?{id:this._id,x:d+f.offsetX,y:p+f.offsetY,width:20+this._collisionConfig.padding*2,height:20+this._collisionConfig.padding*2,priority:this.getCollisionPriority(),featureId:this._id,layerId:this._layer?.getId()||"unknown",type:this.collisionType,data:this.getCollisionData()}:null}catch(i){return console.warn(`Feature ${this._id} 包围盒计算失败:`,i),null}}setCollisionVisibility(e,n=nn.MANUAL_HIDDEN){this._collisionState.visible!==e&&(this._animationRef!==null&&(cancelAnimationFrame(this._animationRef),this._animationRef=null),this.visible=e,this._applyFinalAlpha(e?1:0),this._collisionState={visible:e,reason:n,collidedWith:e?[]:this._collisionState.collidedWith,timestamp:Date.now()})}getCollisionVisibility(){return this._collisionState.visible}setCollisionConfig(e){return Object.assign(this._collisionConfig,e),this}enableCollision(){return this._collisionConfig.enabled=!0,this}disableCollision(){return this._collisionConfig.enabled=!1,this.setCollisionVisibility(!0,nn.MANUAL_HIDDEN),this}_applyVisibilityAlpha(e){this.traverse(n=>{n instanceof m.Mesh&&(Array.isArray(n.material)?n.material.forEach(i=>{i.opacity!==void 0&&(i.opacity=e)}):n.material.opacity!==void 0&&(n.material.opacity=e))})}_applyFinalAlpha(e){this._applyVisibilityAlpha(e),this.traverse(n=>{n instanceof m.Mesh&&(n.material.needsUpdate=!0)})}getCollisionData(){return{featureType:this.constructor.name,userData:this.userData,styleConfig:this._style?.config}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{const i=new m.Box3().setFromObject(this._threeGeometry);if(i.isEmpty())return this._getFallbackBoundingBox();const s=[new m.Vector3(i.min.x,i.min.y,i.min.z),new m.Vector3(i.max.x,i.min.y,i.min.z),new m.Vector3(i.min.x,i.max.y,i.min.z),new m.Vector3(i.max.x,i.max.y,i.min.z),new m.Vector3(i.min.x,i.min.y,i.max.z),new m.Vector3(i.max.x,i.min.y,i.max.z),new m.Vector3(i.min.x,i.max.y,i.max.z),new m.Vector3(i.max.x,i.max.y,i.max.z)],{width:l,height:u}=n.domElement,c=[];s.forEach(D=>{const k=D.clone().project(e),C=(k.x*.5+.5)*l,K=(-k.y*.5+.5)*u;c.push(new m.Vector2(C,K))});let d=1/0,p=-1/0,f=1/0,y=-1/0;c.forEach(D=>{d=Math.min(d,D.x),p=Math.max(p,D.x),f=Math.min(f,D.y),y=Math.max(y,D.y)});const v=p-d,x=y-f,S=4,_=Math.max(v,S),Z=Math.max(x,S),M=new m.Vector3;i.getCenter(M);const G=M.clone().project(e),A=(G.x*.5+.5)*l,R=(-G.y*.5+.5)*u;return{width:_,height:Z,offsetX:d-A,offsetY:f-R}}catch(i){return console.warn("包围盒计算失败:",i),this._getFallbackBoundingBox()}}_getFallbackBoundingBox(){return{width:20,height:20,offsetX:-10,offsetY:-10}}_tileCoordToLocalWorld(e,n,i,s){const{tileZ:l,tileX:u,tileY:c,extent:d,tileSize:p}=i,f=(e/d-.5)*p,y=(.5-n/d)*p;return s.tileIDToWorldCenter(l,u,c).clone().add(new m.Vector3(f,y,0)).sub(s.prjcenter)}}class Bn extends Tr{constructor(e,n){super(e,n);T(this,"_feaList");T(this,"_collision",!1);this._feaList=[],n?.collision&&(this._collision=!0)}addFeature(e){const n=Array.isArray(e)?e:[e];for(const i of n)if(!(!i||!(i instanceof hn))&&!i.getLayer()){if(!this.validateFeature(i)){console.error(`Feature ${i.id} does not match the layer's type requirements`);continue}i._bindLayer(this),this._feaList.push(i),i.getMap()&&i._toThreeJSGeometry(),this._clouds&&(this.map.viewer.scene.add(this._clouds),console.log("我是云朵被添加cloud",this.map.viewer.scene)),this.add(i)}return this}getFeatures(e,n){if(!e)return this._feaList.slice(0);const i=[];let s,l;for(let u=0,c=this._feaList.length;u<c;u++)s=this._feaList[u],n?l=e.call(n,s):l=e(s),l&&i.push(s);return i}getCount(){return this._feaList.length}isEmpty(){return!this._feaList.length}removeFeature(e){if(!Array.isArray(e))return this.removeFeature([e]);for(let n=e.length-1;n>=0;n--)e[n]instanceof hn||(e[n]=this.removeFeature(e[n])),!(!e[n]||this!==e[n].getLayer())&&e[n]._remove();return this}clear(){const e=this._feaList.slice();for(const n of e)n._remove();return this}onRemoveFeature(e){if(!e)return;const n=e.getLayer();if(!n||n!==this)return;const i=this._findInList(e);i>=0&&this._feaList.splice(i,1),e.parent&&e.parent===this?this.remove(e):console.warn("Feature parent mismatch:",e.parent),this._disposeFeatureResources(e)}_findInList(e){const n=this._feaList.length;if(n===0)return-1;let i=0,s=n-1,l;for(;i<=s;){if(l=Math.floor((i+s)/2),this._feaList[l]===e)return l;i=l+1}return-1}_disposeFeatureResources(e){try{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>n.dispose?.()):e.material.dispose&&e.material.dispose()),e instanceof m.Object3D&&e.traverse(n=>{n!==e&&this._disposeFeatureResources(n)})}catch(n){console.error("Error disposing feature resources:",n)}}_mergedGeometry(){this.traverse(e=>{e.isMesh&&e.geometry&&e.material&&console.log("几何体合并中",e)})}setCollisionEngine(e){return this._collisionEngine=e,this}}class sp extends m.Group{constructor(){super(...arguments);T(this,"_layers",new Set);T(this,"_layerids",new Set)}add(...e){return e.forEach(n=>{if(!(n instanceof Tr))throw new Error("LayerContainer只能包含Layer实例!");const i=n.getId();if(this._layerids.has(i))throw new Error(`ID为'${i}'的图层已存在于容器中!`);this._layers.add(n),this._layerids.add(i),super.add(n)}),this}remove(...e){return e.forEach(n=>{this._layers.delete(n),this._layerids.delete(n.getId()),super.remove(n)}),this}getLayers(){return Array.from(this._layers)}getLayerById(e){for(const n of this._layers)if(n.getId()===e)return n}clearLayers(){return this._layers.clear(),this._layerids.clear(),super.clear(),this}}class op{constructor(){T(this,"canvasDict",{})}getCanvas(t=40,e=30,n=1,i){const s=Math.ceil(t*n),l=Math.ceil(e*n),u=i?`${s}_${l}_${i}`:`${s}_${l}`;if(!this.canvasDict[u]){const p=document.createElement("canvas");p.width=s,p.height=l,this.canvasDict[u]=p}const c=this.canvasDict[u],d=c.getContext("2d");return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.scale(n,n),c}}function ap(a){const t=+this._x.call(null,a),e=+this._y.call(null,a);return Cl(this.cover(t,e),t,e,a)}function Cl(a,t,e,n){if(isNaN(t)||isNaN(e))return a;var i,s=a._root,l={data:n},u=a._x0,c=a._y0,d=a._x1,p=a._y1,f,y,v,x,S,_,Z,M;if(!s)return a._root=l,a;for(;s.length;)if((S=t>=(f=(u+d)/2))?u=f:d=f,(_=e>=(y=(c+p)/2))?c=y:p=y,i=s,!(s=s[Z=_<<1|S]))return i[Z]=l,a;if(v=+a._x.call(null,s.data),x=+a._y.call(null,s.data),t===v&&e===x)return l.next=s,i?i[Z]=l:a._root=l,a;do i=i?i[Z]=new Array(4):a._root=new Array(4),(S=t>=(f=(u+d)/2))?u=f:d=f,(_=e>=(y=(c+p)/2))?c=y:p=y;while((Z=_<<1|S)===(M=(x>=y)<<1|v>=f));return i[M]=s,i[Z]=l,a}function lp(a){var t,e,n=a.length,i,s,l=new Array(n),u=new Array(n),c=1/0,d=1/0,p=-1/0,f=-1/0;for(e=0;e<n;++e)isNaN(i=+this._x.call(null,t=a[e]))||isNaN(s=+this._y.call(null,t))||(l[e]=i,u[e]=s,i<c&&(c=i),i>p&&(p=i),s<d&&(d=s),s>f&&(f=s));if(c>p||d>f)return this;for(this.cover(c,d).cover(p,f),e=0;e<n;++e)Cl(this,l[e],u[e],a[e]);return this}function cp(a,t){if(isNaN(a=+a)||isNaN(t=+t))return this;var e=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(e))i=(e=Math.floor(a))+1,s=(n=Math.floor(t))+1;else{for(var l=i-e||1,u=this._root,c,d;e>a||a>=i||n>t||t>=s;)switch(d=(t<n)<<1|a<e,c=new Array(4),c[d]=u,u=c,l*=2,d){case 0:i=e+l,s=n+l;break;case 1:e=i-l,s=n+l;break;case 2:i=e+l,n=s-l;break;case 3:e=i-l,n=s-l;break}this._root&&this._root.length&&(this._root=u)}return this._x0=e,this._y0=n,this._x1=i,this._y1=s,this}function up(){var a=[];return this.visit(function(t){if(!t.length)do a.push(t.data);while(t=t.next)}),a}function hp(a){return arguments.length?this.cover(+a[0][0],+a[0][1]).cover(+a[1][0],+a[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function lt(a,t,e,n,i){this.node=a,this.x0=t,this.y0=e,this.x1=n,this.y1=i}function dp(a,t,e){var n,i=this._x0,s=this._y0,l,u,c,d,p=this._x1,f=this._y1,y=[],v=this._root,x,S;for(v&&y.push(new lt(v,i,s,p,f)),e==null?e=1/0:(i=a-e,s=t-e,p=a+e,f=t+e,e*=e);x=y.pop();)if(!(!(v=x.node)||(l=x.x0)>p||(u=x.y0)>f||(c=x.x1)<i||(d=x.y1)<s))if(v.length){var _=(l+c)/2,Z=(u+d)/2;y.push(new lt(v[3],_,Z,c,d),new lt(v[2],l,Z,_,d),new lt(v[1],_,u,c,Z),new lt(v[0],l,u,_,Z)),(S=(t>=Z)<<1|a>=_)&&(x=y[y.length-1],y[y.length-1]=y[y.length-1-S],y[y.length-1-S]=x)}else{var M=a-+this._x.call(null,v.data),G=t-+this._y.call(null,v.data),A=M*M+G*G;if(A<e){var R=Math.sqrt(e=A);i=a-R,s=t-R,p=a+R,f=t+R,n=v.data}}return n}function fp(a){if(isNaN(p=+this._x.call(null,a))||isNaN(f=+this._y.call(null,a)))return this;var t,e=this._root,n,i,s,l=this._x0,u=this._y0,c=this._x1,d=this._y1,p,f,y,v,x,S,_,Z;if(!e)return this;if(e.length)for(;;){if((x=p>=(y=(l+c)/2))?l=y:c=y,(S=f>=(v=(u+d)/2))?u=v:d=v,t=e,!(e=e[_=S<<1|x]))return this;if(!e.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(n=t,Z=_)}for(;e.data!==a;)if(i=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,i?(s?i.next=s:delete i.next,this):t?(s?t[_]=s:delete t[_],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(n?n[Z]=e:this._root=e),this):(this._root=s,this)}function pp(a){for(var t=0,e=a.length;t<e;++t)this.remove(a[t]);return this}function mp(){return this._root}function gp(){var a=0;return this.visit(function(t){if(!t.length)do++a;while(t=t.next)}),a}function yp(a){var t=[],e,n=this._root,i,s,l,u,c;for(n&&t.push(new lt(n,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!a(n=e.node,s=e.x0,l=e.y0,u=e.x1,c=e.y1)&&n.length){var d=(s+u)/2,p=(l+c)/2;(i=n[3])&&t.push(new lt(i,d,p,u,c)),(i=n[2])&&t.push(new lt(i,s,p,d,c)),(i=n[1])&&t.push(new lt(i,d,l,u,p)),(i=n[0])&&t.push(new lt(i,s,l,d,p))}return this}function vp(a){var t=[],e=[],n;for(this._root&&t.push(new lt(this._root,this._x0,this._y0,this._x1,this._y1));n=t.pop();){var i=n.node;if(i.length){var s,l=n.x0,u=n.y0,c=n.x1,d=n.y1,p=(l+c)/2,f=(u+d)/2;(s=i[0])&&t.push(new lt(s,l,u,p,f)),(s=i[1])&&t.push(new lt(s,p,u,c,f)),(s=i[2])&&t.push(new lt(s,l,f,p,d)),(s=i[3])&&t.push(new lt(s,p,f,c,d))}e.push(n)}for(;n=e.pop();)a(n.node,n.x0,n.y0,n.x1,n.y1);return this}function wp(a){return a[0]}function xp(a){return arguments.length?(this._x=a,this):this._x}function bp(a){return a[1]}function _p(a){return arguments.length?(this._y=a,this):this._y}function Vl(a,t,e){var n=new ro(t??wp,e??bp,NaN,NaN,NaN,NaN);return a==null?n:n.addAll(a)}function ro(a,t,e,n,i,s){this._x=a,this._y=t,this._x0=e,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function Al(a){for(var t={data:a.data},e=t;a=a.next;)e=e.next={data:a.data};return t}var ct=Vl.prototype=ro.prototype;ct.copy=function(){var a=new ro(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,n;if(!t)return a;if(!t.length)return a._root=Al(t),a;for(e=[{source:t,target:a._root=new Array(4)}];t=e.pop();)for(var i=0;i<4;++i)(n=t.source[i])&&(n.length?e.push({source:n,target:t.target[i]=new Array(4)}):t.target[i]=Al(n));return a},ct.add=ap,ct.addAll=lp,ct.cover=cp,ct.data=up,ct.extent=hp,ct.find=dp,ct.remove=fp,ct.removeAll=pp,ct.root=mp,ct.size=gp,ct.visit=yp,ct.visitAfter=vp,ct.x=xp,ct.y=_p;class Fl{constructor(t){T(this,"_quadtree");T(this,"_viewport");this._viewport=t,this._rebuildQuadTree()}updateViewport(t){(t.width!==this._viewport.width||t.height!==this._viewport.height)&&(this._viewport=t,this._rebuildQuadTree())}addBoxes(t){t.forEach(e=>{this._isBoxInViewport(e)&&this._quadtree.add(e)})}findCollisions(t){const e=[],n=this._getSearchBounds(t);return this._quadtree.visit((i,s,l,u,c)=>this._checkNodeCollision(n,s,l,u,c)?(i.length||this._getNodeData(i).forEach(p=>{p.id!==t.id&&this._checkBoxCollision(t,p)&&e.push(p)}),!1):void 0),e}clear(){this._rebuildQuadTree()}getAllBoxes(){const t=[];return this._quadtree.visit(e=>{if(!e.length){const n=this._getNodeData(e);t.push(...n)}return!1}),t}_rebuildQuadTree(){this._quadtree=Vl().x(t=>t.x).y(t=>t.y).extent([[0,0],[this._viewport.width,this._viewport.height]])}_isBoxInViewport(t){const e=t.width/2,n=t.height/2;return t.x+e>=0&&t.x-e<=this._viewport.width&&t.y+n>=0&&t.y-n<=this._viewport.height}_getSearchBounds(t){return{x:t.x,y:t.y,width:t.width*2,height:t.height*2}}_checkNodeCollision(t,e,n,i,s){const l=(e+i)/2,u=(n+s)/2,c=i-e,d=s-n;return Math.abs(t.x-l)*2<t.width+c&&Math.abs(t.y-u)*2<t.height+d}_checkBoxCollision(t,e){return Math.abs(t.x-e.x)*2<t.width+e.width&&Math.abs(t.y-e.y)*2<t.height+e.height}_getNodeData(t){return t?Array.isArray(t.data)?t.data:t.data?[t.data]:[]:[]}removeBox(t){const n=this.getAllBoxes().filter(i=>i.id!==t);this.clear(),n.length>0&&this.addBoxes(n)}}class Mp{constructor(){T(this,"_strategies",new Map);T(this,"_executionOrder",[])}registerStrategy(t,e){return this._strategies.set(t.name,t),e!==void 0?this._executionOrder.splice(e,0,t.name):this._executionOrder.push(t.name),this}async executeStrategies(t,e){const n=new Map;t.forEach(i=>{n.set(i._id,{featureId:i._id,visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})});for(const i of this._executionOrder){const s=this._strategies.get(i);if(s?.enabled)try{const l=await s.execute(t,e,n);this._mergeResults(n,l)}catch(l){console.error(`策略 ${i} 执行失败:`,l)}}return n}_mergeResults(t,e){e.forEach(n=>{const i=t.get(n.featureId);i&&!i.visible||t.set(n.featureId,n)})}}class Lp{constructor(){T(this,"frameStats",new Map);T(this,"summaryStats",{totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0});T(this,"sampleWindowSize",60);T(this,"currentFrameId",0);T(this,"lastReportTime",0);T(this,"reportInterval",5e3);T(this,"performanceThresholds",{criticalFrameTime:33,warningFrameTime:16,idealFrameTime:8});this.lastReportTime=Date.now()}startFrame(t){this.currentFrameId=t;const e={frameId:t,startTime:performance.now(),endTime:0,duration:0,featureCount:0,visibleCount:0,hiddenCount:0,collisionChecks:0,memoryUsage:0,strategyTimes:new Map};this.frameStats.set(t,e),this.cleanupOldFrames()}endFrame(t,e){const n=this.frameStats.get(t);if(!n)return;const i=performance.now();n.endTime=i,n.duration=i-n.startTime,e&&Object.assign(n,e),"memory"in performance&&(n.memoryUsage=performance.memory.usedJSHeapSize),this.updateSummaryStats(n),this.maybeOutputReport()}recordStrategyTime(t,e){const n=this.frameStats.get(this.currentFrameId);n&&n.strategyTimes.set(t,e)}recordCollisionChecks(t){const e=this.frameStats.get(this.currentFrameId);e&&(e.collisionChecks+=t)}getStats(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.calculateFPS(t),n=this.calculateAverageFrameTime(t);return{summary:{...this.summaryStats},recent:{fps:e,frameTime:n,frameTimeStdDev:this.calculateFrameTimeStdDev(t),averageFeaturesPerFrame:this.calculateAverageFeatures(t),performanceLevel:this.getPerformanceLevel(n)},currentFrame:this.frameStats.get(this.currentFrameId)||null,strategies:this.getStrategyPerformance(t),warnings:this.getPerformanceWarnings(t)}}getDetailedReport(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.getStats();return{...e,frameHistory:Array.from(t.values()),trends:this.calculateTrends(t),recommendations:this.getPerformanceRecommendations(e)}}reset(){this.frameStats.clear(),this.summaryStats={totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0},this.currentFrameId=0,this.lastReportTime=Date.now()}cleanupOldFrames(){this.frameStats.size>this.sampleWindowSize*2&&Array.from(this.frameStats.keys()).sort((e,n)=>e-n).slice(0,this.frameStats.size-this.sampleWindowSize).forEach(e=>{this.frameStats.delete(e)})}updateSummaryStats(t){this.summaryStats.totalFrames++,this.summaryStats.totalFeaturesProcessed+=t.featureCount||0,this.summaryStats.averageFrameTime=(this.summaryStats.averageFrameTime*(this.summaryStats.totalFrames-1)+t.duration)/this.summaryStats.totalFrames,this.summaryStats.minFrameTime=Math.min(this.summaryStats.minFrameTime,t.duration),this.summaryStats.maxFrameTime=Math.max(this.summaryStats.maxFrameTime,t.duration),this.summaryStats.averageFPS=1e3/this.summaryStats.averageFrameTime}maybeOutputReport(){const t=Date.now();if(t-this.lastReportTime>=this.reportInterval){const e=this.getStats();e.warnings.length>0?console.warn("避让系统性能报告:",e):console.log("避让系统性能正常:",e),this.lastReportTime=t}}getRecentFrames(t){return Array.from(this.frameStats.values()).slice(-t).filter(n=>n.duration>0)}calculateFPS(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t);return e>0?1e3/e:0}calculateAverageFrameTime(t){return t.length===0?0:t.reduce((e,n)=>e+n.duration,0)/t.length}calculateFrameTimeStdDev(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t),n=t.map(i=>Math.pow(i.duration-e,2));return Math.sqrt(n.reduce((i,s)=>i+s,0)/t.length)}calculateAverageFeatures(t){return t.length===0?0:t.reduce((e,n)=>e+(n.featureCount||0),0)/t.length}getPerformanceLevel(t){return t>this.performanceThresholds.criticalFrameTime?"critical":t>this.performanceThresholds.warningFrameTime?"warning":t>this.performanceThresholds.idealFrameTime?"good":"excellent"}getStrategyPerformance(t){const e=new Map;return t.forEach(n=>{n.strategyTimes.forEach((i,s)=>{e.has(s)||e.set(s,[]),e.get(s).push(i)})}),Array.from(e.entries()).map(([n,i])=>({name:n,averageTime:i.reduce((s,l)=>s+l,0)/i.length,maxTime:Math.max(...i),minTime:Math.min(...i),callCount:i.length}))}getPerformanceWarnings(t){const e=[],n=t.slice(-30);if(n.length===0)return e;const i=this.calculateAverageFrameTime(n);i>this.performanceThresholds.criticalFrameTime?e.push({type:"critical",message:`帧率过低: ${Math.round(1e3/i)}fps`,suggestion:"考虑减少要素数量或简化避让策略"}):i>this.performanceThresholds.warningFrameTime&&e.push({type:"warning",message:`帧率较低: ${Math.round(1e3/i)}fps`,suggestion:"建议优化避让算法或增加更新间隔"});const s=n.map(l=>l.memoryUsage).filter(l=>l>0);if(s.length>0){const l=s.reduce((u,c)=>u+c,0)/s.length;l>100*1024*1024&&e.push({type:"warning",message:`内存使用较高: ${(l/1024/1024).toFixed(1)}MB`,suggestion:"检查内存泄漏,及时清理无用资源"})}return e}calculateTrends(t){if(t.length<2)return{frameTime:"stable",fps:"stable",features:"stable"};const e=t.slice(0,Math.floor(t.length/2)),n=t.slice(Math.floor(t.length/2)),i=this.calculateAverageFrameTime(e),l=(this.calculateAverageFrameTime(n)-i)/i*100;return{frameTime:Math.abs(l)<5?"stable":l>0?"worsening":"improving",fps:Math.abs(l)<5?"stable":l>0?"improving":"worsening",features:"stable"}}getPerformanceRecommendations(t){const e=[];return t.recent.performanceLevel==="critical"&&(e.push("建议启用要素抽样或聚合显示"),e.push("考虑增加避让更新间隔时间"),e.push("检查是否有不必要的避让策略")),t.recent.averageFeaturesPerFrame>5e3&&e.push("要素数量过多,建议启用LOD分级"),t.strategies.forEach(n=>{n.averageTime>10&&e.push(`策略 "${n.name}" 执行时间较长,考虑优化`)}),e}}class Sp{constructor(){T(this,"name","priority");T(this,"enabled",!0);T(this,"weight",1);T(this,"description","基于优先级的避让策略,数值越小优先级越高")}async execute(t,e,n){const i=[],s=new Fl(e.viewport),l=[],u=new Map;return t.forEach(c=>{if(!c.collidable)return;const d=c.getScreenBoundingBox(e.camera,e.renderer);d&&(l.push(d),u.set(c._id,c),n?.get(c._id)?.visible)}),l.sort((c,d)=>c.priority-d.priority),l.forEach(c=>{const d=s.findCollisions(c);d.length===0?(s.addBoxes([c]),i.push({featureId:c.featureId,visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})):d.some(f=>f.priority<c.priority)?i.push({featureId:c.featureId,visible:!1,reason:nn.PRIORITY_LOST,collidedWith:d.map(f=>f.featureId),timestamp:e.timestamp}):(s.addBoxes([c]),i.push({featureId:c.featureId,visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp}),d.forEach(f=>{i.push({featureId:f.featureId,visible:!1,reason:nn.PRIORITY_LOST,collidedWith:[c.featureId],timestamp:e.timestamp})}))}),i}}class Tp{constructor(t,e={}){T(this,"_quadTreeManager");T(this,"_strategyOrchestrator");T(this,"_performanceMonitor");T(this,"_layers",new Set);T(this,"_config");T(this,"_isUpdating",!1);T(this,"_lastUpdateTime",0);T(this,"_frameCount",0);this.renderer=t,this._config={enabled:!0,padding:4,updateInterval:0,animationDuration:300,maxFeaturesPerFrame:2e3,viewportMargin:50,strategies:{priority:!0,grouping:!1,proximity:!1},...e},this._initializeComponents(),this._setupPerformanceMonitoring()}async update(t){if(!this._config.enabled||this._isUpdating)return;const e=Date.now();if(!(this._config.updateInterval>0&&e-this._lastUpdateTime<this._config.updateInterval)){this._isUpdating=!0,this._frameCount++;try{this._resetAllFeaturesVisibility();const n=this._createCollisionContext(t,e),i=this._collectCollidableFeatures();if(i.length===0)return;this._performanceMonitor.startFrame(this._frameCount);const s=await this._strategyOrchestrator.executeStrategies(i,n);await this._applyCollisionResults(s,i),this._performanceMonitor.endFrame(this._frameCount,{featureCount:i.length,visibleCount:Array.from(s.values()).filter(l=>l.visible).length,hiddenCount:Array.from(s.values()).filter(l=>!l.visible).length}),this._lastUpdateTime=e}catch(n){console.error("避让引擎更新失败:",n)}finally{this._isUpdating=!1}}}_resetAllFeaturesVisibility(){this._layers.forEach(t=>{t.getFeatures().filter(n=>n.collidable).forEach(n=>{n.setCollisionVisibility(!0,nn.NO_COLLISION)})})}registerLayer(t){return this._layers.add(t),this}unregisterLayer(t){return this._layers.delete(t),this}setConfig(t){return Object.assign(this._config,t),this}getPerformanceStats(){return this._performanceMonitor.getStats()}_initializeComponents(){const t={width:this.renderer.domElement.width,height:this.renderer.domElement.height};this._quadTreeManager=new Fl(t),this._strategyOrchestrator=new Mp,this._performanceMonitor=new Lp,this._strategyOrchestrator.registerStrategy(new Sp,0),this._setupViewportResizeHandler()}_createCollisionContext(t,e){return{camera:t,renderer:this.renderer,viewport:{width:this.renderer.domElement.width,height:this.renderer.domElement.height},zoomLevel:t.position.z,timestamp:e,frameNumber:this._frameCount}}_collectCollidableFeatures(){const t=[];return this._layers.forEach(e=>{const n=e.getFeatures().filter(i=>i.collidable&&i instanceof hn);if(t.length+n.length>this._config.maxFeaturesPerFrame){console.warn(`达到每帧最大要素处理限制: ${this._config.maxFeaturesPerFrame}`);return}t.push(...n)}),t}async _applyCollisionResults(t,e){const n=e.map(i=>{const s=t.get(i._id);return s&&i.setCollisionVisibility(s.visible,s.reason),Promise.resolve()});await Promise.all(n)}_setupViewportResizeHandler(){new ResizeObserver(e=>{e.forEach(n=>{const{width:i,height:s}=n.contentRect;this._quadTreeManager.updateViewport({width:i,height:s})})}).observe(this.renderer.domElement)}_setupPerformanceMonitoring(){setInterval(()=>{const t=this.getPerformanceStats();t.frameRate<30&&console.warn("避让系统性能警告:",t)},5e3)}}var Ni=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Wr={exports:{}};/**
|
|
539
|
+
`,transparent:a.transparent??!0,side:m.DoubleSide,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0});return new m.Mesh(l,d)}function Nf(a,t,e){const{geometry:n,center:i,avgY:s}=no(e),l=new qh(n,{textureWidth:512,textureHeight:512,waterNormals:new m.TextureLoader().load(a.normalMap,function(d){d.wrapS=d.wrapT=m.RepeatWrapping}),waterColor:a.color||"#19AAEE",sunColor:a.sunColor||"#05FFF8",distortionScale:1,alpha:a.opacity||.8}),u=l.onBeforeRender,c=l.onAfterRender;return l.onBeforeRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!1,u.call(l,d,p,f,y,v,x)},l.onAfterRender=(d,p,f,y,v,x)=>{t.tilemap.autoUpdate=!0,c.call(l,d,p,f,y,v,x)},l.material.uniforms.size.value=.1,l.rotation.x=-Math.PI/2,l.position.set(i.x,s,i.z),t.viewer.addEventListener("update",()=>{l.material.uniforms.time.value+=1/60}),l}function no(a){let t=0;for(let l=1;l<a.length;l+=3)t+=a[l];t/=a.length/3;const e={x:0,z:0},n=[];for(let l=0;l<a.length;l+=3)e.x+=a[l],e.z+=a[l+2];e.x/=a.length/3,e.z/=a.length/3;for(let l=0;l<a.length;l+=3)n.push(new m.Vector2(a[l]-e.x,-(a[l+2]-e.z)));const i=new m.Shape(n);return{geometry:new m.ShapeGeometry(i),center:e,avgY:t}}async function jf(a,t){const{geometry:e,center:n,avgY:i}=no(t),s=await Wt._loadTexture(a.normalMap),l=await Wt._loadTexture(a.normalMap);s.wrapS=s.wrapT=m.RepeatWrapping,l.wrapS=l.wrapT=m.RepeatWrapping,s.repeat.set(.015,.015),l.repeat.set(.005,.005);const u=new m.MeshStandardMaterial({color:new m.Color(a.color).multiplyScalar(3.5),roughness:.1,metalness:.8,transparent:a.transparent??!0,opacity:.9,fog:!1,normalMap:s,normalScale:new m.Vector2(1.5,1.5),envMapIntensity:2,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0}),c=new m.Mesh(e,u);c.rotation.x=-Math.PI/2,c.position.set(n.x,i+.15,n.z),c.castShadow=!1,c.receiveShadow=!0;let d=0;return c.onBeforeRender=()=>{const p=performance.now(),f=d?(p-d)/1e3:.016;s.offset.x+=f*.08,s.offset.y+=f*.03,l.offset.x-=f*.12,l.offset.y+=f*.02,c.position.y=i+.5+Math.sin(p*.02)*.02,d=p},c}function Jf(a,t){a.color=new m.Color(a.hexcolor),a.boundstext&&(a.bounds=new m.Vector3(a.boundstext.x,a.boundstext.y,a.boundstext.z));const e=new Rf(a);return e.castShadow=!0,e.scale.setScalar(50),e.position.copy(t),e}async function Qf(a,t){const n={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,fixedSize:50},...a};n.screenSpaceSize==null&&n.fixedSize!=null&&(n.screenSpaceSize=n.fixedSize);const s=(typeof window<"u"&&window.devicePixelRatio||1)*4,l=a.screenSpaceSize!=null||a.fixedSize!=null;if(a.fontSizeDpi==null&&l){const A=a.screenSpaceSize??a.fixedSize??n.screenSpaceSize;n.fontSizeDpi=A*s}n.fontSizeDpi=Math.min(Math.max(n.fontSizeDpi,8),128);const u=document.createElement("canvas"),c=u.getContext("2d");if(!c)throw new Error("canvas context is null");const d=`${n.fontStyle} ${n.fontWeight} ${n.fontSizeDpi}px ${n.fontFamily}`;c.font=d;const p=n.showBackground?20:0,f=100,y=50,v=c.measureText(n.text),x=Math.max(f,v.width+p*2),S=Math.max(y,n.fontSizeDpi*1.5+p*2);u.width=Math.min(x,2048),u.height=Math.min(S,2048),c.clearRect(0,0,u.width,u.height),c.font=d,n.showBackground&&(n.bgStyle===1?(c.fillStyle=n.bgColor,c.globalAlpha=n.bgOpacity,c.beginPath(),Gl(c,p/2,p/2,u.width-p,u.height-p,n.roundRectRadius),c.fill(),c.globalAlpha=1,c.shadowColor=n.shadowColor,c.shadowBlur=n.shadowBlur,c.shadowOffsetX=n.shadowOffsetX,c.shadowOffsetY=n.shadowOffsetY):(c.fillStyle=n.bgColor,c.globalAlpha=n.bgOpacity,c.beginPath(),Wl(c,u.width/2,u.height/2,u.width*.8,u.height*.8,n.roundRectRadius,n.bubblePointerHeight,n.bubblePointerWidth),c.fill(),c.globalAlpha=1,c.strokeStyle=n.bubbleBorderColor,c.lineWidth=n.bubbleBorderWidth,c.stroke())),c.textAlign="center",c.textBaseline="middle",n.strokeWidth>0&&(c.strokeStyle=n.strokeColor,c.lineWidth=n.strokeWidth,c.lineJoin="round",c.strokeText(n.text,u.width/2,u.height/2)),c.fillStyle=n.textColor,c.fillText(n.text,u.width/2,u.height/2),c.shadowColor="transparent";const _=new m.CanvasTexture(u);_.magFilter=m.NearestFilter,_.minFilter=m.LinearMipmapLinearFilter,_.anisotropy=16;const Z=new m.SpriteMaterial({map:_,transparent:a.transparent??!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,fog:!1}),M=new m.Sprite(Z),G=n.screenSpaceSize??n.fixedSize;return M.scale.set(u.width*G/100,u.height*G/100,1),t&&M.position.copy(t),M}async function Hf(a,t,e){const i={...{fontSizeDpi:48,fontFamily:"'Microsoft YaHei', sans-serif",fontWeight:"bold",fontStyle:"normal",textColor:"#ffffff",strokeColor:"#000000",strokeWidth:2,showBackground:!0,bgStyle:1,bgColor:"#3498db",bgOpacity:.8,shadowColor:"rgba(0, 0, 0, 0.5)",shadowBlur:5,shadowOffsetX:3,shadowOffsetY:3,roundRectRadius:20,bubblePointerHeight:10,bubblePointerWidth:15,bubbleBorderColor:"#ffffff",bubbleBorderWidth:3,screenSpaceSize:20,maxVisibleDistance:1/0},...a};i.screenSpaceSize==null&&a.fixedSize!=null&&(i.screenSpaceSize=a.fixedSize);const l=(typeof window<"u"&&window.devicePixelRatio||1)*4;a.fontSizeDpi==null&&(i.fontSizeDpi=i.screenSpaceSize*l),i.fontSizeDpi=Math.max(i.fontSizeDpi,8);const u=document.createElement("canvas"),c=u.getContext("2d");if(!c)throw new Error("Failed to get canvas context");const d=`${i.fontStyle} ${i.fontWeight} ${i.fontSizeDpi}px ${i.fontFamily}`;c.font=d;const p=i.showBackground?20:0,f=100,y=50,v=c.measureText(i.text),x=Math.max(f,v.width+p*2),S=Math.max(y,i.fontSizeDpi*1.5+p*2);u.width=Math.min(x,2048),u.height=Math.min(S,2048),c.clearRect(0,0,u.width,u.height),c.font=d,i.showBackground&&(i.bgStyle===1?(c.fillStyle=i.bgColor,c.globalAlpha=i.bgOpacity,c.beginPath(),Gl(c,p/2,p/2,u.width-p,u.height-p,i.roundRectRadius),c.fill(),c.globalAlpha=1,c.shadowColor=i.shadowColor,c.shadowBlur=i.shadowBlur,c.shadowOffsetX=i.shadowOffsetX,c.shadowOffsetY=i.shadowOffsetY):(c.fillStyle=i.bgColor,c.globalAlpha=i.bgOpacity,c.beginPath(),Wl(c,u.width/2,u.height/2,u.width*.8,u.height*.8,i.roundRectRadius,i.bubblePointerHeight,i.bubblePointerWidth),c.fill(),c.globalAlpha=1,c.strokeStyle=i.bubbleBorderColor,c.lineWidth=i.bubbleBorderWidth,c.stroke())),c.textAlign="center",c.textBaseline="middle",i.strokeWidth>0&&(c.strokeStyle=i.strokeColor,c.lineWidth=i.strokeWidth,c.lineJoin="round",c.strokeText(i.text,u.width/2,u.height/2)),c.fillStyle=i.textColor,c.fillText(i.text,u.width/2,u.height/2),c.shadowColor="transparent";const _=new m.CanvasTexture(u),Z=new m.SpriteMaterial({map:_,transparent:a.transparent??!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,fog:!1}),M=new m.Sprite(Z);M.position.copy(t),M.userData.isLabel=!0;const G=()=>{if(!M.visible)return;const R=e.viewer.camera.position.distanceTo(M.position);if(R>i.maxVisibleDistance){M.visible=!1;return}M.visible=!0;const D=new m.Vector2;e.viewer.renderer.getSize(D);const k=D.height,C=m.MathUtils.degToRad(e.viewer.camera.fov),K=typeof window<"u"&&window.devicePixelRatio||1,z=i.screenSpaceSize*K/u.height*(2*R*Math.tan(C/2)/k);M.scale.set(z*u.width,z*u.height,1),M.lookAt(e.viewer.camera.position)};G();const A=()=>G();return M.addEventListener("dispose",()=>{e.viewer.renderer.domElement.removeEventListener("resize",G)}),e.viewer.renderer.domElement.addEventListener("resize",G),e.viewer.camera.addEventListener("change",G),M.onBeforeRender=A,M}function Gl(a,t,e,n,i,s){a.beginPath(),a.moveTo(t+s,e),a.lineTo(t+n-s,e),a.quadraticCurveTo(t+n,e,t+n,e+s),a.lineTo(t+n,e+i-s),a.quadraticCurveTo(t+n,e+i,t+n-s,e+i),a.lineTo(t+s,e+i),a.quadraticCurveTo(t,e+i,t,e+i-s),a.lineTo(t,e+s),a.quadraticCurveTo(t,e,t+s,e),a.closePath()}function Wl(a,t,e,n,i,s,l,u){if(n<=0)throw new Error("Width must be positive");if(i<=0)throw new Error("Height must be positive");if(s<0)throw new Error("Radius cannot be negative");const c=n,d=i,p=Math.min(s,n/2,i/2),f=l??10,y=u??15;a.beginPath(),a.moveTo(t-c/2+p,e-d/2),a.lineTo(t+c/2-p,e-d/2),a.quadraticCurveTo(t+c/2,e-d/2,t+c/2,e-d/2+p),a.lineTo(t+c/2,e+d/2-p),a.quadraticCurveTo(t+c/2,e+d/2,t+c/2-p,e+d/2),a.lineTo(t+y/2,e+d/2),a.lineTo(t,e+d/2+f),a.lineTo(t-y/2,e+d/2),a.lineTo(t-c/2+p,e+d/2),a.quadraticCurveTo(t-c/2,e+d/2,t-c/2,e+d/2-p),a.lineTo(t-c/2,e-d/2+p),a.quadraticCurveTo(t-c/2,e-d/2,t-c/2+p,e-d/2),a.closePath()}async function Ef(a,t,e){const{text:n,iconUrl:i,fontSize:s=30,iconSize:l=60,fontFamily:u="Arial",padding:c={},bgColor:d="rgba(0,0,0,0.0)",textColor:p="rgb(255,255,255)",strokeColor:f="rgb(0,0,0)",strokeWidth:y=s/9,iconScale:v=.8,canvasScale:x=1,renderbg:S=!0,textOffset:_={x:0,y:0}}=a,Z={top:0,right:1,bottom:0,left:0,...c};let M=null;i&&(M=await $f(i));const{canvas:G,width:A,height:R,center:D}=await qf({text:n,iconImage:M,fontSize:s,iconSize:l,fontFamily:u,padding:Z,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:S,textOffset:_},t),k=new m.Texture(G);k.needsUpdate=!0;const C=new m.SpriteMaterial({map:k,transparent:a.transparent??!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!0,blending:m.NormalBlending,sizeAttenuation:!1,alphaTest:.01}),K=new m.Sprite(C),I=.001;return K.scale.set(A*I,R*I,1),K.center.set(D[0],D[1]),e&&K.position.copy(e),K}async function qf(a,t){return new Promise(e=>{const{text:n,iconImage:i,fontSize:s,iconSize:l,fontFamily:u,padding:c,bgColor:d,textColor:p,strokeColor:f,strokeWidth:y,iconScale:v,canvasScale:x,renderbg:S,textOffset:_={x:0,y:0}}=a,M=document.createElement("canvas").getContext("2d");if(!M)throw new Error("Could not get temp canvas context");M.font=`500 ${s}px ${u}`;const G=M.measureText(n),A=G.width,R=G.actualBoundingBoxAscent||s*.8,D=G.actualBoundingBoxDescent||s*.2,k=i!==null;let C=0,K=0,I=0,z=0;if(k){C=0,K=0,I=l,z=l;const he=l/2+_.x,ve=l/2+_.y,ze=he,Ye=he+A,je=ve-R,Je=ve+D;C=Math.min(C,ze),I=Math.max(I,Ye),K=Math.min(K,je),z=Math.max(z,Je)}else{const he=_.x,ve=_.x+A,ze=_.y-R,Ye=_.y+D;C=he,I=ve,K=ze,z=Ye}const N=I-C,H=z-K,j=Math.ceil(N+c.left+c.right)*x,q=Math.ceil(H+c.top+c.bottom)*x,J=c.left-C,oe=c.top-K,re=t._getCanvas(j,q,n);re.width=j,re.height=q;const te=re.getContext("2d");if(!te)throw new Error("Could not get canvas context");te.clearRect(0,0,j,q),te.globalCompositeOperation="source-over",te.save(),te.scale(x,x);const me=j/x,be=q/x;if(S&&(te.fillStyle=d,te.fillRect(0,0,me,be)),i){const he=J,ve=oe,ze=l*v,Ye=(l-ze)/2,je=(l-ze)/2;te.imageSmoothingEnabled=!1,te.drawImage(i,he+Ye,ve+je,ze,ze),te.font=`500 ${s}px ${u}`,te.textBaseline="alphabetic",te.textAlign="left";const Je=J+l/2+_.x,Qe=oe+l/2+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,Je,Qe)),te.fillStyle=p,te.fillText(n,Je,Qe)}else{te.font=`500 ${s}px ${u}`,te.textBaseline="alphabetic",te.textAlign="left";const he=J+_.x,ve=oe+_.y;y>0&&(te.strokeStyle=f,te.lineWidth=y,te.strokeText(n,he,ve)),te.fillStyle=p,te.fillText(n,he,ve)}te.restore(),e({canvas:re,width:me,height:be,center:[(l*.5+c.left)/me,(1-v)*.5]})})}function $f(a){return new Promise((t,e)=>{const n=new Image;n.crossOrigin="Anonymous",n.onload=()=>t(n),n.onerror=i=>e(new Error(`Failed to load image: ${a} ${i}`)),n.src=a})}async function ep(a,t,e){const i=new m.CylinderGeometry(.2,.2,24,12),s=new m.MeshBasicMaterial({color:a.color}),l=await Wt._loadTexture(a.icon),u=new m.PointsMaterial({size:80*window.innerHeight/window.innerHeight,fog:!1,opacity:1,transparent:a.transparent??!0,toneMapped:!1,blending:m.AdditiveBlending,map:l,sizeAttenuation:!0,depthTest:a.depthTest??!0,depthWrite:a.depthWrite??!1}),c=new m.InstancedMesh(i,s,t.length);c.position.add(e.prjcenter),c.castShadow=!0;const d=new m.Object3D,p=[];for(let x=0;x<t.length;x++){const S=t[x],_=new m.Vector3(S.coordinates[0],S.coordinates[1],S.coordinates[2]||0),M=e.geo2world(_).sub(e.prjcenter);d.position.copy(M),d.updateMatrix(),c.setMatrixAt(x,d.matrix),p.push(M.x,0,M.z)}const f=new Float32Array(p),y=new m.BufferGeometry;y.setAttribute("position",new m.BufferAttribute(f,3));const v=new m.Points(y,u);return v.position.add(e.prjcenter),v.position.y=1.5*10,v.renderOrder=99999999,v.visible=!0,console.log(e,"map"),{points:v,InstancedCol:c}}const rn=class rn{constructor(t){this.config=t}async applyTo(t){if(!t)return!1;try{switch(t.visible=this.config.visible!==!1,this.config.type){case"basic-point":case"icon-point":case"icon-label-point":return this._applyPointStyle(t);case"basic-line":return this._applyLineStyle(t);case"gltf":case"fbx":return this._applyModelStyle(t);case"basic-polygon":return this._applyPolygonStyle(t);case"extrude-polygon":return this._applyExtrudeStyle(t);case"water":case"base-water":return this._applyWaterStyle(t);case"cloud":return this._applyCloudStyle(t);case"canvas-label":case"canvas-label-fixed":return this._applyTextSpriteStyle(t);case"light":return this._applyLightStyle(t);case"custom":return this._applyCustomStyle(t);default:throw new Error("Unknown style type")}}catch(e){return console.error("Style apply failed:",e),t.visible=!1,!1}}async _applyPointStyle(t){const e=this.config;return e.type==="icon-point"?await this._applyIconPoint(t,e):e.type==="basic-point"?this._applyBasicPoint(t,e):e.type==="icon-label-point"&&this._applyIconLabelPoint(t,e),!0}async _applyIconPoint(t,e){return!0}_applyBasicPoint(t,e){let n;if(t instanceof m.Points)n=t;else if(n=Zl(e,t.position),n.position.copy(t.position),n.rotation.copy(t.rotation),n.scale.copy(t.scale),t.parent){let s=t.parent;s._threeGeometry=n,s._updateGeometry()}const i=n.material;i.size=e.size,e.color&&i.color.set(e.color),e.glow&&(i.sizeAttenuation=!1)}_applyIconLabelPoint(t,e){return!0}_applyLineStyle(t){return this.config,!0}_applyPolygonStyle(t){return!0}_applyExtrudeStyle(t){return!0}_applyWaterStyle(t){return!0}_applyCloudStyle(t){return!0}_applyTextSpriteStyle(t){return!0}_applyLightStyle(t){return!0}async _applyModelStyle(t){return!0}async _applyCustomStyle(t){const n=await this.config.build();return t instanceof m.Group&&(t.clear(),t.add(n)),!0}static async _loadTexture(t){if(rn._textureCache.has(t))return rn._textureCache.get(t);const e=await new Promise((n,i)=>{rn._textureLoader.load(t,n,void 0,i)});return e.premultiplyAlpha=!0,rn._textureCache.set(t,e),e}static create(t){return t instanceof rn?t:new rn(t)}};T(rn,"_textureCache",new Map),T(rn,"_textureLoader",new m.TextureLoader);let Wt=rn;const et=[];for(let a=0;a<256;++a)et.push((a+256).toString(16).slice(1));function tp(a,t=0){return(et[a[t+0]]+et[a[t+1]]+et[a[t+2]]+et[a[t+3]]+"-"+et[a[t+4]]+et[a[t+5]]+"-"+et[a[t+6]]+et[a[t+7]]+"-"+et[a[t+8]]+et[a[t+9]]+"-"+et[a[t+10]]+et[a[t+11]]+et[a[t+12]]+et[a[t+13]]+et[a[t+14]]+et[a[t+15]]).toLowerCase()}let io;const np=new Uint8Array(16);function ip(){if(!io){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");io=crypto.getRandomValues.bind(crypto)}return io(np)}const Pl={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function rp(a,t,e){if(Pl.randomUUID&&!a)return Pl.randomUUID();a=a||{};const n=a.random??a.rng?.()??ip();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,tp(n)}var Il=(a=>(a.POINT="point",a.LINE_VERTEX="line_vertex",a.POLYGON_CENTER="polygon_center",a.LABEL="label",a.ICON="icon",a.CLUSTER="cluster",a))(Il||{}),nn=(a=>(a.NO_COLLISION="no_collision",a.PRIORITY_LOST="priority_lost",a.OUT_OF_VIEWPORT="out_of_viewport",a.ZOOM_FILTERED="zoom_filtered",a.MANUAL_HIDDEN="manual_hidden",a.GROUP_COLLISION="group_collision",a))(nn||{});class hn extends Es(Yi(Ui(m.Object3D))){constructor(e){super();T(this,"_position");T(this,"_threeGeometry");T(this,"_geometry");T(this,"_layer");T(this,"_style");T(this,"_id");T(this,"_styleQueue",[]);T(this,"_isApplyingStyle",!1);T(this,"_isGeometryInitializing",!1);T(this,"_collisionState",{visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:Date.now()});T(this,"_collisionConfig",{enabled:!0,priority:50,padding:4,minZoom:0,maxZoom:24});T(this,"_animationRef",null);Ns(e.geometry,"geometry","geometry must be specified"),this._geometry=e.geometry,this._position=new m.Vector3(0,0,0),this._threeGeometry=new m.Object3D,e.userData&&(this.userData=Object.assign({},JSON.parse(JSON.stringify(e.userData)))),e.style&&this.setStyle(e.style),e.id?this._id=e.id:this._id=rp()}async initializeGeometry(){if(!(this._isGeometryInitializing||this._threeGeometry)){this._isGeometryInitializing=!0;try{await this._toThreeJSGeometry(),this._processStyleQueue()}finally{this._isGeometryInitializing=!1}}}setStyle(e){const n=e instanceof Wt?e:new Wt(e);this._style=n;const i=JSON.parse(JSON.stringify(n.config));return this._styleQueue.push(i),this._tryProcessQueue(),this}getStyle(){return this._style}async _applyStyleWithRetry(e,n=3,i=100){let s=null;for(let l=1;l<=n;l++)try{this._threeGeometry.parent||(this.add(this._threeGeometry),await new Promise(u=>requestAnimationFrame(u))),await e.applyTo(this._threeGeometry);return}catch(u){if(s=u,l<n){const c=i*Math.pow(2,l-1);await new Promise(d=>setTimeout(d,c))}}throw s||new Error("样式应用失败,重试次数耗尽")}async _processStyleQueue(){if(!this._threeGeometry||this._isApplyingStyle||this._styleQueue.length===0)return;this._isApplyingStyle=!0;const e=this._styleQueue[0];try{const n=new Wt(JSON.parse(JSON.stringify(e)));await this._applyStyleWithRetry(n),this._styleQueue.shift(),this._styleQueue.length>0&&await this._processStyleQueue()}catch(n){throw n}finally{this._isApplyingStyle=!1,this._styleQueue.length>0&&this._tryProcessQueue()}}_tryProcessQueue(){this._threeGeometry&&!this._isApplyingStyle&&this._styleQueue.length>0?this._processStyleQueue().catch(n=>{this._isApplyingStyle=!1,this._tryProcessQueue(),console.warn(n)}):!this._threeGeometry&&!this._isGeometryInitializing&&this.initializeGeometry()}addTo(e){return e.addFeature(this),this}getLayer(){return this._layer||null}getMap(){return this._layer?.getMap()||null}_bindLayer(e){if(this._layer&&this._layer!==e)throw new Error("Feature cannot be added to multiple layers");this._layer=e}_updateGeometry(){this._disposeGeometry(),this._threeGeometry&&(this._threeGeometry.position.copy(this._position),this._threeGeometry?.userData?._type==="Model"?this._threeGeometry.renderOrder=0:this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue())}_remove(){return this.getLayer()?(this._unbind(),this):this}_unbind(){const e=this.getLayer();e&&(e.onRemoveFeature&&e.onRemoveFeature(this),delete this._layer)}_disposeGeometry(){this._threeGeometry&&(this.clear(),"traverse"in this&&this._threeGeometry.traverse(e=>{e instanceof m.Mesh?(e.geometry?.dispose(),Array.isArray(e.material)?e.material.forEach(n=>n.dispose()):e.material?.dispose()):"isLine"in e&&e.isLine&&(e.geometry?.dispose(),e.material?.dispose())}))}get collidable(){return this._collisionConfig.enabled}get collisionType(){return Il.POINT}getCollisionPriority(){return this.userData.collisionPriority??this._style?.config.collisionPriority??this._collisionConfig.priority}getScreenBoundingBox(e,n){if(!this.collidable)return null;try{const i=new m.Vector3;this._threeGeometry.getWorldPosition(i);const s=i.clone().project(e);if(!(s.x>=-1.1&&s.x<=1.1&&s.y>=-1.1&&s.y<=1.1&&s.z>=-1&&s.z<=1))return null;const{width:u,height:c}=n.domElement,d=(s.x*.5+.5)*u,p=(-s.y*.5+.5)*c,f=this._calculateCollisionBoundingBox(e,n);return f?{id:this._id,x:d+f.offsetX,y:p+f.offsetY,width:20+this._collisionConfig.padding*2,height:20+this._collisionConfig.padding*2,priority:this.getCollisionPriority(),featureId:this._id,layerId:this._layer?.getId()||"unknown",type:this.collisionType,data:this.getCollisionData()}:null}catch(i){return console.warn(`Feature ${this._id} 包围盒计算失败:`,i),null}}setCollisionVisibility(e,n=nn.MANUAL_HIDDEN){this._collisionState.visible!==e&&(this._animationRef!==null&&(cancelAnimationFrame(this._animationRef),this._animationRef=null),this.visible=e,this._applyFinalAlpha(e?1:0),this._collisionState={visible:e,reason:n,collidedWith:e?[]:this._collisionState.collidedWith,timestamp:Date.now()})}getCollisionVisibility(){return this._collisionState.visible}setCollisionConfig(e){return Object.assign(this._collisionConfig,e),this}enableCollision(){return this._collisionConfig.enabled=!0,this}disableCollision(){return this._collisionConfig.enabled=!1,this.setCollisionVisibility(!0,nn.MANUAL_HIDDEN),this}_applyVisibilityAlpha(e){this.traverse(n=>{n instanceof m.Mesh&&(Array.isArray(n.material)?n.material.forEach(i=>{i.opacity!==void 0&&(i.opacity=e)}):n.material.opacity!==void 0&&(n.material.opacity=e))})}_applyFinalAlpha(e){this._applyVisibilityAlpha(e),this.traverse(n=>{n instanceof m.Mesh&&(n.material.needsUpdate=!0)})}getCollisionData(){return{featureType:this.constructor.name,userData:this.userData,styleConfig:this._style?.config}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{const i=new m.Box3().setFromObject(this._threeGeometry);if(i.isEmpty())return this._getFallbackBoundingBox();const s=[new m.Vector3(i.min.x,i.min.y,i.min.z),new m.Vector3(i.max.x,i.min.y,i.min.z),new m.Vector3(i.min.x,i.max.y,i.min.z),new m.Vector3(i.max.x,i.max.y,i.min.z),new m.Vector3(i.min.x,i.min.y,i.max.z),new m.Vector3(i.max.x,i.min.y,i.max.z),new m.Vector3(i.min.x,i.max.y,i.max.z),new m.Vector3(i.max.x,i.max.y,i.max.z)],{width:l,height:u}=n.domElement,c=[];s.forEach(D=>{const k=D.clone().project(e),C=(k.x*.5+.5)*l,K=(-k.y*.5+.5)*u;c.push(new m.Vector2(C,K))});let d=1/0,p=-1/0,f=1/0,y=-1/0;c.forEach(D=>{d=Math.min(d,D.x),p=Math.max(p,D.x),f=Math.min(f,D.y),y=Math.max(y,D.y)});const v=p-d,x=y-f,S=4,_=Math.max(v,S),Z=Math.max(x,S),M=new m.Vector3;i.getCenter(M);const G=M.clone().project(e),A=(G.x*.5+.5)*l,R=(-G.y*.5+.5)*u;return{width:_,height:Z,offsetX:d-A,offsetY:f-R}}catch(i){return console.warn("包围盒计算失败:",i),this._getFallbackBoundingBox()}}_getFallbackBoundingBox(){return{width:20,height:20,offsetX:-10,offsetY:-10}}_tileCoordToLocalWorld(e,n,i,s){const{tileZ:l,tileX:u,tileY:c,extent:d,tileSize:p}=i,f=(e/d-.5)*p,y=(.5-n/d)*p;return s.tileIDToWorldCenter(l,u,c).clone().add(new m.Vector3(f,y,0)).sub(s.prjcenter)}}class Bn extends Tr{constructor(e,n){super(e,n);T(this,"_feaList");T(this,"_collision",!1);this._feaList=[],n?.collision&&(this._collision=!0)}addFeature(e){const n=Array.isArray(e)?e:[e];for(const i of n)if(!(!i||!(i instanceof hn))&&!i.getLayer()){if(!this.validateFeature(i)){console.error(`Feature ${i.id} does not match the layer's type requirements`);continue}i._bindLayer(this),this._feaList.push(i),i.getMap()&&i._toThreeJSGeometry(),this._clouds&&(this.map.viewer.scene.add(this._clouds),console.log("我是云朵被添加cloud",this.map.viewer.scene)),this.add(i)}return this}getFeatures(e,n){if(!e)return this._feaList.slice(0);const i=[];let s,l;for(let u=0,c=this._feaList.length;u<c;u++)s=this._feaList[u],n?l=e.call(n,s):l=e(s),l&&i.push(s);return i}getCount(){return this._feaList.length}isEmpty(){return!this._feaList.length}removeFeature(e){if(!Array.isArray(e))return this.removeFeature([e]);for(let n=e.length-1;n>=0;n--)e[n]instanceof hn||(e[n]=this.removeFeature(e[n])),!(!e[n]||this!==e[n].getLayer())&&e[n]._remove();return this}clear(){const e=this._feaList.slice();for(const n of e)n._remove();return this}onRemoveFeature(e){if(!e)return;const n=e.getLayer();if(!n||n!==this)return;const i=this._findInList(e);i>=0&&this._feaList.splice(i,1),e.parent&&e.parent===this?this.remove(e):console.warn("Feature parent mismatch:",e.parent),this._disposeFeatureResources(e)}_findInList(e){const n=this._feaList.length;if(n===0)return-1;let i=0,s=n-1,l;for(;i<=s;){if(l=Math.floor((i+s)/2),this._feaList[l]===e)return l;i=l+1}return-1}_disposeFeatureResources(e){try{e.geometry&&e.geometry.dispose&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>n.dispose?.()):e.material.dispose&&e.material.dispose()),e instanceof m.Object3D&&e.traverse(n=>{n!==e&&this._disposeFeatureResources(n)})}catch(n){console.error("Error disposing feature resources:",n)}}_mergedGeometry(){this.traverse(e=>{e.isMesh&&e.geometry&&e.material&&console.log("几何体合并中",e)})}setCollisionEngine(e){return this._collisionEngine=e,this}}class sp extends m.Group{constructor(){super(...arguments);T(this,"_layers",new Set);T(this,"_layerids",new Set)}add(...e){return e.forEach(n=>{if(!(n instanceof Tr))throw new Error("LayerContainer只能包含Layer实例!");const i=n.getId();if(this._layerids.has(i))throw new Error(`ID为'${i}'的图层已存在于容器中!`);this._layers.add(n),this._layerids.add(i),super.add(n)}),this}remove(...e){return e.forEach(n=>{this._layers.delete(n),this._layerids.delete(n.getId()),super.remove(n)}),this}getLayers(){return Array.from(this._layers)}getLayerById(e){for(const n of this._layers)if(n.getId()===e)return n}clearLayers(){return this._layers.clear(),this._layerids.clear(),super.clear(),this}}class op{constructor(){T(this,"canvasDict",{})}getCanvas(t=40,e=30,n=1,i){const s=Math.ceil(t*n),l=Math.ceil(e*n),u=i?`${s}_${l}_${i}`:`${s}_${l}`;if(!this.canvasDict[u]){const p=document.createElement("canvas");p.width=s,p.height=l,this.canvasDict[u]=p}const c=this.canvasDict[u],d=c.getContext("2d");return d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.scale(n,n),c}}function ap(a){const t=+this._x.call(null,a),e=+this._y.call(null,a);return Cl(this.cover(t,e),t,e,a)}function Cl(a,t,e,n){if(isNaN(t)||isNaN(e))return a;var i,s=a._root,l={data:n},u=a._x0,c=a._y0,d=a._x1,p=a._y1,f,y,v,x,S,_,Z,M;if(!s)return a._root=l,a;for(;s.length;)if((S=t>=(f=(u+d)/2))?u=f:d=f,(_=e>=(y=(c+p)/2))?c=y:p=y,i=s,!(s=s[Z=_<<1|S]))return i[Z]=l,a;if(v=+a._x.call(null,s.data),x=+a._y.call(null,s.data),t===v&&e===x)return l.next=s,i?i[Z]=l:a._root=l,a;do i=i?i[Z]=new Array(4):a._root=new Array(4),(S=t>=(f=(u+d)/2))?u=f:d=f,(_=e>=(y=(c+p)/2))?c=y:p=y;while((Z=_<<1|S)===(M=(x>=y)<<1|v>=f));return i[M]=s,i[Z]=l,a}function lp(a){var t,e,n=a.length,i,s,l=new Array(n),u=new Array(n),c=1/0,d=1/0,p=-1/0,f=-1/0;for(e=0;e<n;++e)isNaN(i=+this._x.call(null,t=a[e]))||isNaN(s=+this._y.call(null,t))||(l[e]=i,u[e]=s,i<c&&(c=i),i>p&&(p=i),s<d&&(d=s),s>f&&(f=s));if(c>p||d>f)return this;for(this.cover(c,d).cover(p,f),e=0;e<n;++e)Cl(this,l[e],u[e],a[e]);return this}function cp(a,t){if(isNaN(a=+a)||isNaN(t=+t))return this;var e=this._x0,n=this._y0,i=this._x1,s=this._y1;if(isNaN(e))i=(e=Math.floor(a))+1,s=(n=Math.floor(t))+1;else{for(var l=i-e||1,u=this._root,c,d;e>a||a>=i||n>t||t>=s;)switch(d=(t<n)<<1|a<e,c=new Array(4),c[d]=u,u=c,l*=2,d){case 0:i=e+l,s=n+l;break;case 1:e=i-l,s=n+l;break;case 2:i=e+l,n=s-l;break;case 3:e=i-l,n=s-l;break}this._root&&this._root.length&&(this._root=u)}return this._x0=e,this._y0=n,this._x1=i,this._y1=s,this}function up(){var a=[];return this.visit(function(t){if(!t.length)do a.push(t.data);while(t=t.next)}),a}function hp(a){return arguments.length?this.cover(+a[0][0],+a[0][1]).cover(+a[1][0],+a[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}function lt(a,t,e,n,i){this.node=a,this.x0=t,this.y0=e,this.x1=n,this.y1=i}function dp(a,t,e){var n,i=this._x0,s=this._y0,l,u,c,d,p=this._x1,f=this._y1,y=[],v=this._root,x,S;for(v&&y.push(new lt(v,i,s,p,f)),e==null?e=1/0:(i=a-e,s=t-e,p=a+e,f=t+e,e*=e);x=y.pop();)if(!(!(v=x.node)||(l=x.x0)>p||(u=x.y0)>f||(c=x.x1)<i||(d=x.y1)<s))if(v.length){var _=(l+c)/2,Z=(u+d)/2;y.push(new lt(v[3],_,Z,c,d),new lt(v[2],l,Z,_,d),new lt(v[1],_,u,c,Z),new lt(v[0],l,u,_,Z)),(S=(t>=Z)<<1|a>=_)&&(x=y[y.length-1],y[y.length-1]=y[y.length-1-S],y[y.length-1-S]=x)}else{var M=a-+this._x.call(null,v.data),G=t-+this._y.call(null,v.data),A=M*M+G*G;if(A<e){var R=Math.sqrt(e=A);i=a-R,s=t-R,p=a+R,f=t+R,n=v.data}}return n}function fp(a){if(isNaN(p=+this._x.call(null,a))||isNaN(f=+this._y.call(null,a)))return this;var t,e=this._root,n,i,s,l=this._x0,u=this._y0,c=this._x1,d=this._y1,p,f,y,v,x,S,_,Z;if(!e)return this;if(e.length)for(;;){if((x=p>=(y=(l+c)/2))?l=y:c=y,(S=f>=(v=(u+d)/2))?u=v:d=v,t=e,!(e=e[_=S<<1|x]))return this;if(!e.length)break;(t[_+1&3]||t[_+2&3]||t[_+3&3])&&(n=t,Z=_)}for(;e.data!==a;)if(i=e,!(e=e.next))return this;return(s=e.next)&&delete e.next,i?(s?i.next=s:delete i.next,this):t?(s?t[_]=s:delete t[_],(e=t[0]||t[1]||t[2]||t[3])&&e===(t[3]||t[2]||t[1]||t[0])&&!e.length&&(n?n[Z]=e:this._root=e),this):(this._root=s,this)}function pp(a){for(var t=0,e=a.length;t<e;++t)this.remove(a[t]);return this}function mp(){return this._root}function gp(){var a=0;return this.visit(function(t){if(!t.length)do++a;while(t=t.next)}),a}function yp(a){var t=[],e,n=this._root,i,s,l,u,c;for(n&&t.push(new lt(n,this._x0,this._y0,this._x1,this._y1));e=t.pop();)if(!a(n=e.node,s=e.x0,l=e.y0,u=e.x1,c=e.y1)&&n.length){var d=(s+u)/2,p=(l+c)/2;(i=n[3])&&t.push(new lt(i,d,p,u,c)),(i=n[2])&&t.push(new lt(i,s,p,d,c)),(i=n[1])&&t.push(new lt(i,d,l,u,p)),(i=n[0])&&t.push(new lt(i,s,l,d,p))}return this}function vp(a){var t=[],e=[],n;for(this._root&&t.push(new lt(this._root,this._x0,this._y0,this._x1,this._y1));n=t.pop();){var i=n.node;if(i.length){var s,l=n.x0,u=n.y0,c=n.x1,d=n.y1,p=(l+c)/2,f=(u+d)/2;(s=i[0])&&t.push(new lt(s,l,u,p,f)),(s=i[1])&&t.push(new lt(s,p,u,c,f)),(s=i[2])&&t.push(new lt(s,l,f,p,d)),(s=i[3])&&t.push(new lt(s,p,f,c,d))}e.push(n)}for(;n=e.pop();)a(n.node,n.x0,n.y0,n.x1,n.y1);return this}function wp(a){return a[0]}function xp(a){return arguments.length?(this._x=a,this):this._x}function bp(a){return a[1]}function _p(a){return arguments.length?(this._y=a,this):this._y}function Vl(a,t,e){var n=new ro(t??wp,e??bp,NaN,NaN,NaN,NaN);return a==null?n:n.addAll(a)}function ro(a,t,e,n,i,s){this._x=a,this._y=t,this._x0=e,this._y0=n,this._x1=i,this._y1=s,this._root=void 0}function Al(a){for(var t={data:a.data},e=t;a=a.next;)e=e.next={data:a.data};return t}var ct=Vl.prototype=ro.prototype;ct.copy=function(){var a=new ro(this._x,this._y,this._x0,this._y0,this._x1,this._y1),t=this._root,e,n;if(!t)return a;if(!t.length)return a._root=Al(t),a;for(e=[{source:t,target:a._root=new Array(4)}];t=e.pop();)for(var i=0;i<4;++i)(n=t.source[i])&&(n.length?e.push({source:n,target:t.target[i]=new Array(4)}):t.target[i]=Al(n));return a},ct.add=ap,ct.addAll=lp,ct.cover=cp,ct.data=up,ct.extent=hp,ct.find=dp,ct.remove=fp,ct.removeAll=pp,ct.root=mp,ct.size=gp,ct.visit=yp,ct.visitAfter=vp,ct.x=xp,ct.y=_p;class Fl{constructor(t){T(this,"_quadtree");T(this,"_viewport");this._viewport=t,this._rebuildQuadTree()}updateViewport(t){(t.width!==this._viewport.width||t.height!==this._viewport.height)&&(this._viewport=t,this._rebuildQuadTree())}addBoxes(t){t.forEach(e=>{this._isBoxInViewport(e)&&this._quadtree.add(e)})}findCollisions(t){const e=[],n=this._getSearchBounds(t);return this._quadtree.visit((i,s,l,u,c)=>this._checkNodeCollision(n,s,l,u,c)?(i.length||this._getNodeData(i).forEach(p=>{p.id!==t.id&&this._checkBoxCollision(t,p)&&e.push(p)}),!1):void 0),e}clear(){this._rebuildQuadTree()}getAllBoxes(){const t=[];return this._quadtree.visit(e=>{if(!e.length){const n=this._getNodeData(e);t.push(...n)}return!1}),t}_rebuildQuadTree(){this._quadtree=Vl().x(t=>t.x).y(t=>t.y).extent([[0,0],[this._viewport.width,this._viewport.height]])}_isBoxInViewport(t){const e=t.width/2,n=t.height/2;return t.x+e>=0&&t.x-e<=this._viewport.width&&t.y+n>=0&&t.y-n<=this._viewport.height}_getSearchBounds(t){return{x:t.x,y:t.y,width:t.width*2,height:t.height*2}}_checkNodeCollision(t,e,n,i,s){const l=(e+i)/2,u=(n+s)/2,c=i-e,d=s-n;return Math.abs(t.x-l)*2<t.width+c&&Math.abs(t.y-u)*2<t.height+d}_checkBoxCollision(t,e){return Math.abs(t.x-e.x)*2<t.width+e.width&&Math.abs(t.y-e.y)*2<t.height+e.height}_getNodeData(t){return t?Array.isArray(t.data)?t.data:t.data?[t.data]:[]:[]}removeBox(t){const n=this.getAllBoxes().filter(i=>i.id!==t);this.clear(),n.length>0&&this.addBoxes(n)}}class Mp{constructor(){T(this,"_strategies",new Map);T(this,"_executionOrder",[])}registerStrategy(t,e){return this._strategies.set(t.name,t),e!==void 0?this._executionOrder.splice(e,0,t.name):this._executionOrder.push(t.name),this}async executeStrategies(t,e){const n=new Map;t.forEach(i=>{n.set(i._id,{featureId:i._id,visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})});for(const i of this._executionOrder){const s=this._strategies.get(i);if(s?.enabled)try{const l=await s.execute(t,e,n);this._mergeResults(n,l)}catch(l){console.error(`策略 ${i} 执行失败:`,l)}}return n}_mergeResults(t,e){e.forEach(n=>{const i=t.get(n.featureId);i&&!i.visible||t.set(n.featureId,n)})}}class Lp{constructor(){T(this,"frameStats",new Map);T(this,"summaryStats",{totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0});T(this,"sampleWindowSize",60);T(this,"currentFrameId",0);T(this,"lastReportTime",0);T(this,"reportInterval",5e3);T(this,"performanceThresholds",{criticalFrameTime:33,warningFrameTime:16,idealFrameTime:8});this.lastReportTime=Date.now()}startFrame(t){this.currentFrameId=t;const e={frameId:t,startTime:performance.now(),endTime:0,duration:0,featureCount:0,visibleCount:0,hiddenCount:0,collisionChecks:0,memoryUsage:0,strategyTimes:new Map};this.frameStats.set(t,e),this.cleanupOldFrames()}endFrame(t,e){const n=this.frameStats.get(t);if(!n)return;const i=performance.now();n.endTime=i,n.duration=i-n.startTime,e&&Object.assign(n,e),"memory"in performance&&(n.memoryUsage=performance.memory.usedJSHeapSize),this.updateSummaryStats(n),this.maybeOutputReport()}recordStrategyTime(t,e){const n=this.frameStats.get(this.currentFrameId);n&&n.strategyTimes.set(t,e)}recordCollisionChecks(t){const e=this.frameStats.get(this.currentFrameId);e&&(e.collisionChecks+=t)}getStats(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.calculateFPS(t),n=this.calculateAverageFrameTime(t);return{summary:{...this.summaryStats},recent:{fps:e,frameTime:n,frameTimeStdDev:this.calculateFrameTimeStdDev(t),averageFeaturesPerFrame:this.calculateAverageFeatures(t),performanceLevel:this.getPerformanceLevel(n)},currentFrame:this.frameStats.get(this.currentFrameId)||null,strategies:this.getStrategyPerformance(t),warnings:this.getPerformanceWarnings(t)}}getDetailedReport(){const t=this.getRecentFrames(this.sampleWindowSize),e=this.getStats();return{...e,frameHistory:Array.from(t.values()),trends:this.calculateTrends(t),recommendations:this.getPerformanceRecommendations(e)}}reset(){this.frameStats.clear(),this.summaryStats={totalFrames:0,averageFrameTime:0,averageFPS:0,minFrameTime:1/0,maxFrameTime:0,totalFeaturesProcessed:0},this.currentFrameId=0,this.lastReportTime=Date.now()}cleanupOldFrames(){this.frameStats.size>this.sampleWindowSize*2&&Array.from(this.frameStats.keys()).sort((e,n)=>e-n).slice(0,this.frameStats.size-this.sampleWindowSize).forEach(e=>{this.frameStats.delete(e)})}updateSummaryStats(t){this.summaryStats.totalFrames++,this.summaryStats.totalFeaturesProcessed+=t.featureCount||0,this.summaryStats.averageFrameTime=(this.summaryStats.averageFrameTime*(this.summaryStats.totalFrames-1)+t.duration)/this.summaryStats.totalFrames,this.summaryStats.minFrameTime=Math.min(this.summaryStats.minFrameTime,t.duration),this.summaryStats.maxFrameTime=Math.max(this.summaryStats.maxFrameTime,t.duration),this.summaryStats.averageFPS=1e3/this.summaryStats.averageFrameTime}maybeOutputReport(){const t=Date.now();if(t-this.lastReportTime>=this.reportInterval){const e=this.getStats();e.warnings.length>0?console.warn("避让系统性能报告:",e):console.log("避让系统性能正常:",e),this.lastReportTime=t}}getRecentFrames(t){return Array.from(this.frameStats.values()).slice(-t).filter(n=>n.duration>0)}calculateFPS(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t);return e>0?1e3/e:0}calculateAverageFrameTime(t){return t.length===0?0:t.reduce((e,n)=>e+n.duration,0)/t.length}calculateFrameTimeStdDev(t){if(t.length===0)return 0;const e=this.calculateAverageFrameTime(t),n=t.map(i=>Math.pow(i.duration-e,2));return Math.sqrt(n.reduce((i,s)=>i+s,0)/t.length)}calculateAverageFeatures(t){return t.length===0?0:t.reduce((e,n)=>e+(n.featureCount||0),0)/t.length}getPerformanceLevel(t){return t>this.performanceThresholds.criticalFrameTime?"critical":t>this.performanceThresholds.warningFrameTime?"warning":t>this.performanceThresholds.idealFrameTime?"good":"excellent"}getStrategyPerformance(t){const e=new Map;return t.forEach(n=>{n.strategyTimes.forEach((i,s)=>{e.has(s)||e.set(s,[]),e.get(s).push(i)})}),Array.from(e.entries()).map(([n,i])=>({name:n,averageTime:i.reduce((s,l)=>s+l,0)/i.length,maxTime:Math.max(...i),minTime:Math.min(...i),callCount:i.length}))}getPerformanceWarnings(t){const e=[],n=t.slice(-30);if(n.length===0)return e;const i=this.calculateAverageFrameTime(n);i>this.performanceThresholds.criticalFrameTime?e.push({type:"critical",message:`帧率过低: ${Math.round(1e3/i)}fps`,suggestion:"考虑减少要素数量或简化避让策略"}):i>this.performanceThresholds.warningFrameTime&&e.push({type:"warning",message:`帧率较低: ${Math.round(1e3/i)}fps`,suggestion:"建议优化避让算法或增加更新间隔"});const s=n.map(l=>l.memoryUsage).filter(l=>l>0);if(s.length>0){const l=s.reduce((u,c)=>u+c,0)/s.length;l>100*1024*1024&&e.push({type:"warning",message:`内存使用较高: ${(l/1024/1024).toFixed(1)}MB`,suggestion:"检查内存泄漏,及时清理无用资源"})}return e}calculateTrends(t){if(t.length<2)return{frameTime:"stable",fps:"stable",features:"stable"};const e=t.slice(0,Math.floor(t.length/2)),n=t.slice(Math.floor(t.length/2)),i=this.calculateAverageFrameTime(e),l=(this.calculateAverageFrameTime(n)-i)/i*100;return{frameTime:Math.abs(l)<5?"stable":l>0?"worsening":"improving",fps:Math.abs(l)<5?"stable":l>0?"improving":"worsening",features:"stable"}}getPerformanceRecommendations(t){const e=[];return t.recent.performanceLevel==="critical"&&(e.push("建议启用要素抽样或聚合显示"),e.push("考虑增加避让更新间隔时间"),e.push("检查是否有不必要的避让策略")),t.recent.averageFeaturesPerFrame>5e3&&e.push("要素数量过多,建议启用LOD分级"),t.strategies.forEach(n=>{n.averageTime>10&&e.push(`策略 "${n.name}" 执行时间较长,考虑优化`)}),e}}class Sp{constructor(){T(this,"name","priority");T(this,"enabled",!0);T(this,"weight",1);T(this,"description","基于优先级的避让策略,数值越小优先级越高")}async execute(t,e,n){const i=[],s=new Fl(e.viewport),l=[],u=new Map;return t.forEach(c=>{if(!c.collidable)return;const d=c.getScreenBoundingBox(e.camera,e.renderer);d&&(l.push(d),u.set(c._id,c),n?.get(c._id)?.visible)}),l.sort((c,d)=>c.priority-d.priority),l.forEach(c=>{const d=s.findCollisions(c);d.length===0?(s.addBoxes([c]),i.push({featureId:c.featureId,visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp})):d.some(f=>f.priority<c.priority)?i.push({featureId:c.featureId,visible:!1,reason:nn.PRIORITY_LOST,collidedWith:d.map(f=>f.featureId),timestamp:e.timestamp}):(s.addBoxes([c]),i.push({featureId:c.featureId,visible:!0,reason:nn.NO_COLLISION,collidedWith:[],timestamp:e.timestamp}),d.forEach(f=>{i.push({featureId:f.featureId,visible:!1,reason:nn.PRIORITY_LOST,collidedWith:[c.featureId],timestamp:e.timestamp})}))}),i}}class Tp{constructor(t,e={}){T(this,"_quadTreeManager");T(this,"_strategyOrchestrator");T(this,"_performanceMonitor");T(this,"_layers",new Set);T(this,"_config");T(this,"_isUpdating",!1);T(this,"_lastUpdateTime",0);T(this,"_frameCount",0);this.renderer=t,this._config={enabled:!0,padding:4,updateInterval:0,animationDuration:300,maxFeaturesPerFrame:2e3,viewportMargin:50,strategies:{priority:!0,grouping:!1,proximity:!1},...e},this._initializeComponents(),this._setupPerformanceMonitoring()}async update(t){if(!this._config.enabled||this._isUpdating)return;const e=Date.now();if(!(this._config.updateInterval>0&&e-this._lastUpdateTime<this._config.updateInterval)){this._isUpdating=!0,this._frameCount++;try{this._resetAllFeaturesVisibility();const n=this._createCollisionContext(t,e),i=this._collectCollidableFeatures();if(i.length===0)return;this._performanceMonitor.startFrame(this._frameCount);const s=await this._strategyOrchestrator.executeStrategies(i,n);await this._applyCollisionResults(s,i),this._performanceMonitor.endFrame(this._frameCount,{featureCount:i.length,visibleCount:Array.from(s.values()).filter(l=>l.visible).length,hiddenCount:Array.from(s.values()).filter(l=>!l.visible).length}),this._lastUpdateTime=e}catch(n){console.error("避让引擎更新失败:",n)}finally{this._isUpdating=!1}}}_resetAllFeaturesVisibility(){this._layers.forEach(t=>{t.getFeatures().filter(n=>n.collidable).forEach(n=>{n.setCollisionVisibility(!0,nn.NO_COLLISION)})})}registerLayer(t){return this._layers.add(t),this}unregisterLayer(t){return this._layers.delete(t),this}setConfig(t){return Object.assign(this._config,t),this}getPerformanceStats(){return this._performanceMonitor.getStats()}_initializeComponents(){const t={width:this.renderer.domElement.width,height:this.renderer.domElement.height};this._quadTreeManager=new Fl(t),this._strategyOrchestrator=new Mp,this._performanceMonitor=new Lp,this._strategyOrchestrator.registerStrategy(new Sp,0),this._setupViewportResizeHandler()}_createCollisionContext(t,e){return{camera:t,renderer:this.renderer,viewport:{width:this.renderer.domElement.width,height:this.renderer.domElement.height},zoomLevel:t.position.z,timestamp:e,frameNumber:this._frameCount}}_collectCollidableFeatures(){const t=[];return this._layers.forEach(e=>{const n=e.getFeatures().filter(i=>i.collidable&&i instanceof hn);if(t.length+n.length>this._config.maxFeaturesPerFrame){console.warn(`达到每帧最大要素处理限制: ${this._config.maxFeaturesPerFrame}`);return}t.push(...n)}),t}async _applyCollisionResults(t,e){const n=e.map(i=>{const s=t.get(i._id);return s&&i.setCollisionVisibility(s.visible,s.reason),Promise.resolve()});await Promise.all(n)}_setupViewportResizeHandler(){new ResizeObserver(e=>{e.forEach(n=>{const{width:i,height:s}=n.contentRect;this._quadTreeManager.updateViewport({width:i,height:s})})}).observe(this.renderer.domElement)}_setupPerformanceMonitoring(){setInterval(()=>{const t=this.getPerformanceStats();t.frameRate<30&&console.warn("避让系统性能警告:",t)},5e3)}}var Ni=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Wr={exports:{}};/**
|
|
540
540
|
* @license
|
|
541
541
|
* Lodash <https://lodash.com/>
|
|
542
542
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
@@ -562,7 +562,7 @@ __p += '`),Le&&(Q+=`' +
|
|
|
562
562
|
function print() { __p += __j.call(arguments, '') }
|
|
563
563
|
`:`;
|
|
564
564
|
`)+Q+`return __p
|
|
565
|
-
}`;var ge=Vh(function(){return Te(L,ie+"return "+Q).apply(e,W)});if(ge.source=Q,Ta(ge))throw ge;return ge}function N1(r){return Ze(r).toLowerCase()}function j1(r){return Ze(r).toUpperCase()}function J1(r,o,h){if(r=Ze(r),r&&(h||o===e))return Kc(r);if(!r||!(o=Mt(o)))return r;var g=jt(r),w=jt(o),L=Yc(g,w),W=Uc(g,w)+1;return On(g,L,W).join("")}function Q1(r,o,h){if(r=Ze(r),r&&(h||o===e))return r.slice(0,Nc(r)+1);if(!r||!(o=Mt(o)))return r;var g=jt(r),w=Uc(g,jt(o))+1;return On(g,0,w).join("")}function H1(r,o,h){if(r=Ze(r),r&&(h||o===e))return r.replace(To,"");if(!r||!(o=Mt(o)))return r;var g=jt(r),w=Yc(g,jt(o));return On(g,w).join("")}function E1(r,o){var h=I,g=z;if(Fe(o)){var w="separator"in o?o.separator:w;h="length"in o?pe(o.length):h,g="omission"in o?Mt(o.omission):g}r=Ze(r);var L=r.length;if(bi(r)){var W=jt(r);L=W.length}if(h>=L)return r;var P=h-_i(g);if(P<1)return g;var F=W?On(W,0,P).join(""):r.slice(0,P);if(w===e)return F+g;if(W&&(P+=F.length-P),Za(w)){if(r.slice(P).search(w)){var U,B=F;for(w.global||(w=Yo(w.source,Ze(uc.exec(w))+"g")),w.lastIndex=0;U=w.exec(B);)var Q=U.index;F=F.slice(0,Q===e?P:Q)}}else if(r.indexOf(Mt(w),P)!=P){var $=F.lastIndexOf(w);$>-1&&(F=F.slice(0,$))}return F+g}function q1(r){return r=Ze(r),r&&cc.test(r)?r.replace(Ct,Zg):r}var $1=Wi(function(r,o,h){return r+(h?" ":"")+o.toUpperCase()}),Pa=Au("toUpperCase");function Ch(r,o,h){return r=Ze(r),o=h?e:o,o===e?_g(r)?Pg(r):fg(r):r.match(o)||[]}var Vh=ye(function(r,o){try{return bt(r,e,o)}catch(h){return Ta(h)?h:new de(h)}}),eb=yn(function(r,o){return At(o,function(h){h=ln(h),mn(r,h,La(r[h],r))}),r});function tb(r){var o=r==null?0:r.length,h=ae();return r=o?Ve(r,function(g){if(typeof g[1]!="function")throw new Ft(l);return[h(g[0]),g[1]]}):[],ye(function(g){for(var w=-1;++w<o;){var L=r[w];if(bt(L[0],this,g))return bt(L[1],this,g)}})}function nb(r){return Zy(zt(r,f))}function Ia(r){return function(){return r}}function ib(r,o){return r==null||r!==r?o:r}var rb=Xu(),sb=Xu(!0);function wt(r){return r}function Ca(r){return du(typeof r=="function"?r:zt(r,f))}function ob(r){return pu(zt(r,f))}function ab(r,o){return mu(r,zt(o,f))}var lb=ye(function(r,o){return function(h){return cr(h,r,o)}}),cb=ye(function(r,o){return function(h){return cr(r,h,o)}});function Va(r,o,h){var g=He(o),w=os(o,g);h==null&&!(Fe(o)&&(w.length||!g.length))&&(h=o,o=r,r=this,w=os(o,He(o)));var L=!(Fe(h)&&"chain"in h)||!!h.chain,W=wn(r);return At(w,function(P){var F=o[P];r[P]=F,W&&(r.prototype[P]=function(){var U=this.__chain__;if(L||U){var B=r(this.__wrapped__),Q=B.__actions__=gt(this.__actions__);return Q.push({func:F,args:arguments,thisArg:r}),B.__chain__=U,B}return F.apply(r,An([this.value()],arguments))})}),r}function ub(){return nt._===this&&(nt._=Xg),this}function Aa(){}function hb(r){return r=pe(r),ye(function(o){return gu(o,r)})}var db=ha(Ve),fb=ha(zc),pb=ha(Xo);function Ah(r){return va(r)?zo(ln(r)):Uy(r)}function mb(r){return function(o){return r==null?e:si(r,o)}}var gb=Du(),yb=Du(!0);function Fa(){return[]}function Xa(){return!1}function vb(){return{}}function wb(){return""}function xb(){return!0}function bb(r,o){if(r=pe(r),r<1||r>re)return[];var h=be,g=ot(r,be);o=ae(o),r-=be;for(var w=Oo(g,o);++h<r;)o(h);return w}function _b(r){return fe(r)?Ve(r,ln):Lt(r)?[r]:gt(eh(Ze(r)))}function Mb(r){var o=++Ag;return Ze(r)+o}var Lb=ds(function(r,o){return r+o},0),Sb=da("ceil"),Tb=ds(function(r,o){return r/o},1),Zb=da("floor");function Gb(r){return r&&r.length?ss(r,wt,Eo):e}function Wb(r,o){return r&&r.length?ss(r,ae(o,2),Eo):e}function Pb(r){return Oc(r,wt)}function Ib(r,o){return Oc(r,ae(o,2))}function Cb(r){return r&&r.length?ss(r,wt,ta):e}function Vb(r,o){return r&&r.length?ss(r,ae(o,2),ta):e}var Ab=ds(function(r,o){return r*o},1),Fb=da("round"),Xb=ds(function(r,o){return r-o},0);function zb(r){return r&&r.length?ko(r,wt):0}function Db(r,o){return r&&r.length?ko(r,ae(o,2)):0}return b.after=ox,b.ary=hh,b.assign=jx,b.assignIn=Sh,b.assignInWith=Ss,b.assignWith=Jx,b.at=Qx,b.before=dh,b.bind=La,b.bindAll=eb,b.bindKey=fh,b.castArray=vx,b.chain=lh,b.chunk=Zv,b.compact=Gv,b.concat=Wv,b.cond=tb,b.conforms=nb,b.constant=Ia,b.countBy=zw,b.create=Hx,b.curry=ph,b.curryRight=mh,b.debounce=gh,b.defaults=Ex,b.defaultsDeep=qx,b.defer=ax,b.delay=lx,b.difference=Pv,b.differenceBy=Iv,b.differenceWith=Cv,b.drop=Vv,b.dropRight=Av,b.dropRightWhile=Fv,b.dropWhile=Xv,b.fill=zv,b.filter=kw,b.flatMap=Kw,b.flatMapDeep=Yw,b.flatMapDepth=Uw,b.flatten=rh,b.flattenDeep=Dv,b.flattenDepth=kv,b.flip=cx,b.flow=rb,b.flowRight=sb,b.fromPairs=Ov,b.functions=s1,b.functionsIn=o1,b.groupBy=Bw,b.initial=Kv,b.intersection=Yv,b.intersectionBy=Uv,b.intersectionWith=Bv,b.invert=l1,b.invertBy=c1,b.invokeMap=jw,b.iteratee=Ca,b.keyBy=Jw,b.keys=He,b.keysIn=vt,b.map=ws,b.mapKeys=h1,b.mapValues=d1,b.matches=ob,b.matchesProperty=ab,b.memoize=bs,b.merge=f1,b.mergeWith=Th,b.method=lb,b.methodOf=cb,b.mixin=Va,b.negate=_s,b.nthArg=hb,b.omit=p1,b.omitBy=m1,b.once=ux,b.orderBy=Qw,b.over=db,b.overArgs=hx,b.overEvery=fb,b.overSome=pb,b.partial=Sa,b.partialRight=yh,b.partition=Hw,b.pick=g1,b.pickBy=Zh,b.property=Ah,b.propertyOf=mb,b.pull=Qv,b.pullAll=oh,b.pullAllBy=Hv,b.pullAllWith=Ev,b.pullAt=qv,b.range=gb,b.rangeRight=yb,b.rearg=dx,b.reject=$w,b.remove=$v,b.rest=fx,b.reverse=_a,b.sampleSize=tx,b.set=v1,b.setWith=w1,b.shuffle=nx,b.slice=ew,b.sortBy=sx,b.sortedUniq=aw,b.sortedUniqBy=lw,b.split=K1,b.spread=px,b.tail=cw,b.take=uw,b.takeRight=hw,b.takeRightWhile=dw,b.takeWhile=fw,b.tap=Gw,b.throttle=mx,b.thru=vs,b.toArray=_h,b.toPairs=Gh,b.toPairsIn=Wh,b.toPath=_b,b.toPlainObject=Lh,b.transform=x1,b.unary=gx,b.union=pw,b.unionBy=mw,b.unionWith=gw,b.uniq=yw,b.uniqBy=vw,b.uniqWith=ww,b.unset=b1,b.unzip=Ma,b.unzipWith=ah,b.update=_1,b.updateWith=M1,b.values=Ci,b.valuesIn=L1,b.without=xw,b.words=Ch,b.wrap=yx,b.xor=bw,b.xorBy=_w,b.xorWith=Mw,b.zip=Lw,b.zipObject=Sw,b.zipObjectDeep=Tw,b.zipWith=Zw,b.entries=Gh,b.entriesIn=Wh,b.extend=Sh,b.extendWith=Ss,Va(b,b),b.add=Lb,b.attempt=Vh,b.camelCase=G1,b.capitalize=Ph,b.ceil=Sb,b.clamp=S1,b.clone=wx,b.cloneDeep=bx,b.cloneDeepWith=_x,b.cloneWith=xx,b.conformsTo=Mx,b.deburr=Ih,b.defaultTo=ib,b.divide=Tb,b.endsWith=W1,b.eq=Qt,b.escape=P1,b.escapeRegExp=I1,b.every=Dw,b.find=Ow,b.findIndex=nh,b.findKey=$x,b.findLast=Rw,b.findLastIndex=ih,b.findLastKey=e1,b.floor=Zb,b.forEach=ch,b.forEachRight=uh,b.forIn=t1,b.forInRight=n1,b.forOwn=i1,b.forOwnRight=r1,b.get=Ga,b.gt=Lx,b.gte=Sx,b.has=a1,b.hasIn=Wa,b.head=sh,b.identity=wt,b.includes=Nw,b.indexOf=Rv,b.inRange=T1,b.invoke=u1,b.isArguments=li,b.isArray=fe,b.isArrayBuffer=Tx,b.isArrayLike=yt,b.isArrayLikeObject=Oe,b.isBoolean=Zx,b.isBuffer=Rn,b.isDate=Gx,b.isElement=Wx,b.isEmpty=Px,b.isEqual=Ix,b.isEqualWith=Cx,b.isError=Ta,b.isFinite=Vx,b.isFunction=wn,b.isInteger=vh,b.isLength=Ms,b.isMap=wh,b.isMatch=Ax,b.isMatchWith=Fx,b.isNaN=Xx,b.isNative=zx,b.isNil=kx,b.isNull=Dx,b.isNumber=xh,b.isObject=Fe,b.isObjectLike=De,b.isPlainObject=mr,b.isRegExp=Za,b.isSafeInteger=Ox,b.isSet=bh,b.isString=Ls,b.isSymbol=Lt,b.isTypedArray=Ii,b.isUndefined=Rx,b.isWeakMap=Kx,b.isWeakSet=Yx,b.join=Nv,b.kebabCase=C1,b.last=kt,b.lastIndexOf=jv,b.lowerCase=V1,b.lowerFirst=A1,b.lt=Ux,b.lte=Bx,b.max=Gb,b.maxBy=Wb,b.mean=Pb,b.meanBy=Ib,b.min=Cb,b.minBy=Vb,b.stubArray=Fa,b.stubFalse=Xa,b.stubObject=vb,b.stubString=wb,b.stubTrue=xb,b.multiply=Ab,b.nth=Jv,b.noConflict=ub,b.noop=Aa,b.now=xs,b.pad=F1,b.padEnd=X1,b.padStart=z1,b.parseInt=D1,b.random=Z1,b.reduce=Ew,b.reduceRight=qw,b.repeat=k1,b.replace=O1,b.result=y1,b.round=Fb,b.runInContext=V,b.sample=ex,b.size=ix,b.snakeCase=R1,b.some=rx,b.sortedIndex=tw,b.sortedIndexBy=nw,b.sortedIndexOf=iw,b.sortedLastIndex=rw,b.sortedLastIndexBy=sw,b.sortedLastIndexOf=ow,b.startCase=Y1,b.startsWith=U1,b.subtract=Xb,b.sum=zb,b.sumBy=Db,b.template=B1,b.times=bb,b.toFinite=xn,b.toInteger=pe,b.toLength=Mh,b.toLower=N1,b.toNumber=Ot,b.toSafeInteger=Nx,b.toString=Ze,b.toUpper=j1,b.trim=J1,b.trimEnd=Q1,b.trimStart=H1,b.truncate=E1,b.unescape=q1,b.uniqueId=Mb,b.upperCase=$1,b.upperFirst=Pa,b.each=ch,b.eachRight=uh,b.first=sh,Va(b,function(){var r={};return on(b,function(o,h){Ge.call(b.prototype,h)||(r[h]=o)}),r}(),{chain:!1}),b.VERSION=n,At(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){b[r].placeholder=b}),At(["drop","take"],function(r,o){Me.prototype[r]=function(h){h=h===e?1:Ne(pe(h),0);var g=this.__filtered__&&!o?new Me(this):this.clone();return g.__filtered__?g.__takeCount__=ot(h,g.__takeCount__):g.__views__.push({size:ot(h,be),type:r+(g.__dir__<0?"Right":"")}),g},Me.prototype[r+"Right"]=function(h){return this.reverse()[r](h).reverse()}}),At(["filter","map","takeWhile"],function(r,o){var h=o+1,g=h==j||h==J;Me.prototype[r]=function(w){var L=this.clone();return L.__iteratees__.push({iteratee:ae(w,3),type:h}),L.__filtered__=L.__filtered__||g,L}}),At(["head","last"],function(r,o){var h="take"+(o?"Right":"");Me.prototype[r]=function(){return this[h](1).value()[0]}}),At(["initial","tail"],function(r,o){var h="drop"+(o?"":"Right");Me.prototype[r]=function(){return this.__filtered__?new Me(this):this[h](1)}}),Me.prototype.compact=function(){return this.filter(wt)},Me.prototype.find=function(r){return this.filter(r).head()},Me.prototype.findLast=function(r){return this.reverse().find(r)},Me.prototype.invokeMap=ye(function(r,o){return typeof r=="function"?new Me(this):this.map(function(h){return cr(h,r,o)})}),Me.prototype.reject=function(r){return this.filter(_s(ae(r)))},Me.prototype.slice=function(r,o){r=pe(r);var h=this;return h.__filtered__&&(r>0||o<0)?new Me(h):(r<0?h=h.takeRight(-r):r&&(h=h.drop(r)),o!==e&&(o=pe(o),h=o<0?h.dropRight(-o):h.take(o-r)),h)},Me.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},Me.prototype.toArray=function(){return this.take(be)},on(Me.prototype,function(r,o){var h=/^(?:filter|find|map|reject)|While$/.test(o),g=/^(?:head|last)$/.test(o),w=b[g?"take"+(o=="last"?"Right":""):o],L=g||/^find/.test(o);w&&(b.prototype[o]=function(){var W=this.__wrapped__,P=g?[1]:arguments,F=W instanceof Me,U=P[0],B=F||fe(W),Q=function(_e){var Le=w.apply(b,An([_e],P));return g&&$?Le[0]:Le};B&&h&&typeof U=="function"&&U.length!=1&&(F=B=!1);var $=this.__chain__,ie=!!this.__actions__.length,le=L&&!$,ge=F&&!ie;if(!L&&B){W=ge?W:new Me(this);var ce=r.apply(W,P);return ce.__actions__.push({func:vs,args:[Q],thisArg:e}),new Xt(ce,$)}return le&&ge?r.apply(this,P):(ce=this.thru(Q),le?g?ce.value()[0]:ce.value():ce)})}),At(["pop","push","shift","sort","splice","unshift"],function(r){var o=Ur[r],h=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",g=/^(?:pop|shift)$/.test(r);b.prototype[r]=function(){var w=arguments;if(g&&!this.__chain__){var L=this.value();return o.apply(fe(L)?L:[],w)}return this[h](function(W){return o.apply(fe(W)?W:[],w)})}}),on(Me.prototype,function(r,o){var h=b[o];if(h){var g=h.name+"";Ge.call(Ti,g)||(Ti[g]=[]),Ti[g].push({name:o,func:h})}}),Ti[hs(e,Z).name]=[{name:"wrapper",func:e}],Me.prototype.clone=qg,Me.prototype.reverse=$g,Me.prototype.value=ey,b.prototype.at=Ww,b.prototype.chain=Pw,b.prototype.commit=Iw,b.prototype.next=Cw,b.prototype.plant=Aw,b.prototype.reverse=Fw,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Xw,b.prototype.first=b.prototype.head,nr&&(b.prototype[nr]=Vw),b},Mi=Ig();ei?((ei.exports=Mi)._=Mi,Co._=Mi):nt._=Mi}).call(Ni)}(Wr,Wr.exports);var Zp=Wr.exports;let ji=class extends hn{constructor(e){super(e);T(this,"_baseType","Point");this._threeGeometry=this._createThreeGeometry(),this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=new m.Vector3(this._geometry.coordinates[0],this._geometry.coordinates[1],this._geometry.coordinates[2]||0);return e?e.geo2world(n):n}_toThreeJSGeometry(){}_createThreeGeometry(){return new m.Points(new m.BufferGeometry,new m.PointsMaterial({size:1,color:8947848}))}};const Gp={};class so extends ji{constructor(e){super(e);T(this,"_type","Maker")}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"basic-point":return Zl(e.config,new m.Vector3(0,0,0));case"icon-point":return Kf(e.config,this._position);case"icon-label-point":return Ef(e.config,this.getMap(),this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{switch(this._style?.config.type){case"icon-point":return this._calculateSpriteBoundingBox(this._threeGeometry);default:return this._getFallbackBoundingBox()}}catch(i){return console.warn(`Maker ${this._id} 包围盒计算失败:`,i),this._getFallbackBoundingBox()}}_calculateSpriteBoundingBox(e){try{const i=Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))/.002;return{width:i,height:i,offsetX:-i/2,offsetY:-i/2}}catch{return{width:20,height:20,offsetX:-10,offsetY:-10}}}_getFallbackBoundingBox(){switch(this.getStyle()?.config.type){case"icon-point":case"icon-label-point":return{width:20,height:20,offsetX:-10,offsetY:-10};case"basic-point":return{width:10,height:10,offsetX:-5,offsetY:-5};default:return{width:15,height:15,offsetX:-7.5,offsetY:-7.5}}}}so.mergeOptions(Gp);class Xl extends hn{constructor(e){super(e);T(this,"_baseType","Line");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=this._geometry,i=e?.prjcenter;if(this._geometry.type==="LineString"){let l=n.coordinates.map(c=>{const d=new m.Vector3(c[0],c[1],c[2]||0);return(e?e.geo2world(d):d).sub(i)}),u=l.flatMap(c=>[c.x,c.y,c.z]);return{_position:l,_vertexPoints:u}}}_toThreeJSGeometry(){}_createThreeGeometry(){const e=new xr,n=new zi({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Ys(e,n)}}const Wp={};class oo extends Xl{constructor(e){super(e);T(this,"_type","LineString")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-line":return to(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_updateGeometry(){const e=this.getMap();if(this._disposeGeometry(),this._threeGeometry){const i=this._threeGeometry.geometry;i.setPositions(this._vertexPoints),i.computeBoundingSphere(),i.computeBoundingBox(),this._threeGeometry.position.add(e?.prjcenter),this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue()}}}oo.mergeOptions(Wp);class Pp extends hn{constructor(e){super(e);T(this,"_baseType","Surface");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=e?.prjcenter,i=this._geometry;if(!i)throw new Error("几何数据未定义");if(i.type==="Polygon"){const s=i.coordinates;let l=[],u=[];return s.forEach(c=>{const d=c.map(p=>{const f=new m.Vector3(p[0],p[1],p[2]||0);return(e?e.geo2world(f):f).sub(n)});l.push(d),u.push(...d.flatMap(p=>[p.x,p.y,p.z]))}),{_positions:l,_vertexPoints:u}}else if(i.type==="MultiPolygon"){const s=i.coordinates;let l=[],u=[];return s.forEach(c=>{const d=[];c.forEach(p=>{const f=p.map(y=>{const v=new m.Vector3(y[0],y[1],y[2]||0);return(e?e.geo2world(v):v).sub(n)});d.push(f),u.push(...f.flatMap(y=>[y.x,y.y,y.z]))}),l.push(d)}),{_positions:l,_vertexPoints:u}}else throw new Error(`不支持的几何类型: ${i.type}`)}_updateGeometry(){const e=this._style?.config.type;if(this.clear(),!this._threeGeometry||!this._vertexPoints?.length){console.warn("无法更新几何体:缺少几何体或顶点数据");return}const n=this.getMap();try{e==="basic-polygon"?(this._threeGeometry.renderOrder=99,this._threeGeometry.position.add(n?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry)):(e==="extrude-polygon"||e?.includes("water"))&&(this._threeGeometry.renderOrder=99,this._threeGeometry.position.add(n?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry))}catch(i){throw console.error("更新多边形位置失败:",i),i}}_createThreeGeometry(){const e=new xr,n=new zi({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Ys(e,n)}}const Ip={};class zl extends Pp{constructor(e){super(e);T(this,"_type","Polygon")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this.remove(this._threeGeometry),this._threeGeometry=await this._createObject(this._style),this._updateGeometry(),await this._style.applyTo(this._threeGeometry))}async _createObject(e){switch(e.config.type){case"basic-polygon":return Uf(e.config,this._vertexPoints);case"extrude-polygon":return Bf(e.config,this._vertexPoints);case"water":return Nf(e.config,this.getMap(),this._vertexPoints);case"base-water":return jf(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(){return null}}zl.mergeOptions(Ip);const Cp={};class Dl extends Xl{constructor(e){super(e);T(this,"_type","MultiLineString");T(this,"_lineObjects",[]);T(this,"_linesContainer");this._linesContainer=new m.Group}async _toThreeJSGeometry(){debugger;const{_position:e}=this._coordsTransform(),n=this.getMap();if(this.clearLines(),this._disposeGeometry(),this._style){for(const i of e){const s=i.flatMap(u=>[u.x,u.y,u.z]),l=await this._createLineObject(this._style,s);l.position.add(n?.prjcenter),l.updateMatrixWorld(!0),l.renderOrder=99,this._lineObjects.push(l),this._linesContainer.add(l)}this._linesContainer.renderOrder=99,this._threeGeometry=this._linesContainer,this.add(this._threeGeometry),this._updateContainer(),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0),this._tryProcessQueue()}}async _createLineObject(e,n){switch(e.config.type){case"basic-line":return to(e.config,n);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(this._geometry.type==="MultiLineString"){const i=e?.prjcenter;return{_position:n.coordinates.map(l=>l.map(u=>{const c=new m.Vector3(u[0],u[1],u[2]||0);return(e?e.geo2world(c):c).sub(i)}))}}}_updateContainer(){this._linesContainer.updateMatrixWorld(!0)}clearLines(){this._lineObjects.forEach(e=>{this._linesContainer.remove(e),e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this._lineObjects=[]}_updateGeometry(){this._toThreeJSGeometry()}_disposeObject(){}}Dl.mergeOptions(Cp);const ao=64;class Vp extends rt.MeshStandardMaterial{constructor(e={}){const{shaderOption:n,regionOverlay:i,...s}=e;super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,depthWrite:!0,depthTest:!0,...s});T(this,"shaderOption");T(this,"clock");T(this,"time");T(this,"startTime");T(this,"regionOverlay");if(i&&i.vertices&&i.vertices.length>0){const l=i.vertices.slice(0,ao).map(c=>c.clone()),u=l.length;for(;l.length<ao;)l.push(new rt.Vector2(0,0));this.regionOverlay={color:i.color,opacity:i.opacity,vertices:l,vertexCount:u}}this.shaderOption={minY:0,maxY:100,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!1,color:new rt.Color("#9ECDEC"),width:20,speed:1,maxDistance:100,center:void 0},flow:{enabled:!1,color:new rt.Color("#00E4FF"),range:10,speed:20},sweep:{enabled:!1,color:new rt.Color("#FFFFFF"),width:1.5,speed:10}},...n},this.clock=new rt.Clock,this.time={value:0},this.startTime={value:0},this.animate()}onBeforeCompile(e){const{minY:n,maxY:i,minRate:s,maxRate:l,effects:u}=this.shaderOption,c=i-n,d=!!this.regionOverlay;e.uniforms={...e.uniforms,time:this.time,uStartTime:this.startTime,uMinY:{value:n},uMaxY:{value:i},uHeightRange:{value:c},uMinRate:{value:s},uMaxRate:{value:l},uDiffusionEnabled:{value:u?.diffusion?.enabled?1:0},uDiffusionColor:{value:u?.diffusion?.color||new rt.Color("#9ECDEC")},uDiffusionWidth:{value:u?.diffusion?.width||20},uDiffusionSpeed:{value:u?.diffusion?.speed||1},uDiffusionMaxDistance:{value:u?.diffusion?.maxDistance||100},uDiffusionCenter:{value:u?.diffusion?.center||new rt.Vector3(0,0,0)},uFlowEnabled:{value:u?.flow?.enabled?1:0},uFlowColor:{value:u?.flow?.color||new rt.Color("#00E4FF")},uFlowRange:{value:u?.flow?.range||10},uFlowSpeed:{value:u?.flow?.speed||20},uSweepEnabled:{value:u?.sweep?.enabled?1:0},uSweepColor:{value:u?.sweep?.color||new rt.Color("#FFFFFF")},uSweepWidth:{value:u?.sweep?.width||1.5},uSweepSpeed:{value:u?.sweep?.speed||10},uRegionOverlayEnabled:{value:d?1:0},uRegionOverlayColor:{value:this.regionOverlay?.color||new rt.Color("#00FF88")},uRegionOverlayOpacity:{value:this.regionOverlay?.opacity??0},uRegionOverlayVertexCount:{value:this.regionOverlay?.vertexCount??0},uRegionOverlayVertices:{value:this.regionOverlay?.vertices||new Array(ao).fill(0).map(()=>new rt.Vector2(0,0))}},e.vertexShader=`
|
|
565
|
+
}`;var ge=Vh(function(){return Te(L,ie+"return "+Q).apply(e,W)});if(ge.source=Q,Ta(ge))throw ge;return ge}function N1(r){return Ze(r).toLowerCase()}function j1(r){return Ze(r).toUpperCase()}function J1(r,o,h){if(r=Ze(r),r&&(h||o===e))return Kc(r);if(!r||!(o=Mt(o)))return r;var g=jt(r),w=jt(o),L=Yc(g,w),W=Uc(g,w)+1;return On(g,L,W).join("")}function Q1(r,o,h){if(r=Ze(r),r&&(h||o===e))return r.slice(0,Nc(r)+1);if(!r||!(o=Mt(o)))return r;var g=jt(r),w=Uc(g,jt(o))+1;return On(g,0,w).join("")}function H1(r,o,h){if(r=Ze(r),r&&(h||o===e))return r.replace(To,"");if(!r||!(o=Mt(o)))return r;var g=jt(r),w=Yc(g,jt(o));return On(g,w).join("")}function E1(r,o){var h=I,g=z;if(Fe(o)){var w="separator"in o?o.separator:w;h="length"in o?pe(o.length):h,g="omission"in o?Mt(o.omission):g}r=Ze(r);var L=r.length;if(bi(r)){var W=jt(r);L=W.length}if(h>=L)return r;var P=h-_i(g);if(P<1)return g;var F=W?On(W,0,P).join(""):r.slice(0,P);if(w===e)return F+g;if(W&&(P+=F.length-P),Za(w)){if(r.slice(P).search(w)){var U,B=F;for(w.global||(w=Yo(w.source,Ze(uc.exec(w))+"g")),w.lastIndex=0;U=w.exec(B);)var Q=U.index;F=F.slice(0,Q===e?P:Q)}}else if(r.indexOf(Mt(w),P)!=P){var $=F.lastIndexOf(w);$>-1&&(F=F.slice(0,$))}return F+g}function q1(r){return r=Ze(r),r&&cc.test(r)?r.replace(Ct,Zg):r}var $1=Wi(function(r,o,h){return r+(h?" ":"")+o.toUpperCase()}),Pa=Au("toUpperCase");function Ch(r,o,h){return r=Ze(r),o=h?e:o,o===e?_g(r)?Pg(r):fg(r):r.match(o)||[]}var Vh=ye(function(r,o){try{return bt(r,e,o)}catch(h){return Ta(h)?h:new de(h)}}),eb=yn(function(r,o){return At(o,function(h){h=ln(h),mn(r,h,La(r[h],r))}),r});function tb(r){var o=r==null?0:r.length,h=ae();return r=o?Ve(r,function(g){if(typeof g[1]!="function")throw new Ft(l);return[h(g[0]),g[1]]}):[],ye(function(g){for(var w=-1;++w<o;){var L=r[w];if(bt(L[0],this,g))return bt(L[1],this,g)}})}function nb(r){return Zy(zt(r,f))}function Ia(r){return function(){return r}}function ib(r,o){return r==null||r!==r?o:r}var rb=Xu(),sb=Xu(!0);function wt(r){return r}function Ca(r){return du(typeof r=="function"?r:zt(r,f))}function ob(r){return pu(zt(r,f))}function ab(r,o){return mu(r,zt(o,f))}var lb=ye(function(r,o){return function(h){return cr(h,r,o)}}),cb=ye(function(r,o){return function(h){return cr(r,h,o)}});function Va(r,o,h){var g=He(o),w=os(o,g);h==null&&!(Fe(o)&&(w.length||!g.length))&&(h=o,o=r,r=this,w=os(o,He(o)));var L=!(Fe(h)&&"chain"in h)||!!h.chain,W=wn(r);return At(w,function(P){var F=o[P];r[P]=F,W&&(r.prototype[P]=function(){var U=this.__chain__;if(L||U){var B=r(this.__wrapped__),Q=B.__actions__=gt(this.__actions__);return Q.push({func:F,args:arguments,thisArg:r}),B.__chain__=U,B}return F.apply(r,An([this.value()],arguments))})}),r}function ub(){return nt._===this&&(nt._=Xg),this}function Aa(){}function hb(r){return r=pe(r),ye(function(o){return gu(o,r)})}var db=ha(Ve),fb=ha(zc),pb=ha(Xo);function Ah(r){return va(r)?zo(ln(r)):Uy(r)}function mb(r){return function(o){return r==null?e:si(r,o)}}var gb=Du(),yb=Du(!0);function Fa(){return[]}function Xa(){return!1}function vb(){return{}}function wb(){return""}function xb(){return!0}function bb(r,o){if(r=pe(r),r<1||r>re)return[];var h=be,g=ot(r,be);o=ae(o),r-=be;for(var w=Oo(g,o);++h<r;)o(h);return w}function _b(r){return fe(r)?Ve(r,ln):Lt(r)?[r]:gt(eh(Ze(r)))}function Mb(r){var o=++Ag;return Ze(r)+o}var Lb=ds(function(r,o){return r+o},0),Sb=da("ceil"),Tb=ds(function(r,o){return r/o},1),Zb=da("floor");function Gb(r){return r&&r.length?ss(r,wt,Eo):e}function Wb(r,o){return r&&r.length?ss(r,ae(o,2),Eo):e}function Pb(r){return Oc(r,wt)}function Ib(r,o){return Oc(r,ae(o,2))}function Cb(r){return r&&r.length?ss(r,wt,ta):e}function Vb(r,o){return r&&r.length?ss(r,ae(o,2),ta):e}var Ab=ds(function(r,o){return r*o},1),Fb=da("round"),Xb=ds(function(r,o){return r-o},0);function zb(r){return r&&r.length?ko(r,wt):0}function Db(r,o){return r&&r.length?ko(r,ae(o,2)):0}return b.after=ox,b.ary=hh,b.assign=jx,b.assignIn=Sh,b.assignInWith=Ss,b.assignWith=Jx,b.at=Qx,b.before=dh,b.bind=La,b.bindAll=eb,b.bindKey=fh,b.castArray=vx,b.chain=lh,b.chunk=Zv,b.compact=Gv,b.concat=Wv,b.cond=tb,b.conforms=nb,b.constant=Ia,b.countBy=zw,b.create=Hx,b.curry=ph,b.curryRight=mh,b.debounce=gh,b.defaults=Ex,b.defaultsDeep=qx,b.defer=ax,b.delay=lx,b.difference=Pv,b.differenceBy=Iv,b.differenceWith=Cv,b.drop=Vv,b.dropRight=Av,b.dropRightWhile=Fv,b.dropWhile=Xv,b.fill=zv,b.filter=kw,b.flatMap=Kw,b.flatMapDeep=Yw,b.flatMapDepth=Uw,b.flatten=rh,b.flattenDeep=Dv,b.flattenDepth=kv,b.flip=cx,b.flow=rb,b.flowRight=sb,b.fromPairs=Ov,b.functions=s1,b.functionsIn=o1,b.groupBy=Bw,b.initial=Kv,b.intersection=Yv,b.intersectionBy=Uv,b.intersectionWith=Bv,b.invert=l1,b.invertBy=c1,b.invokeMap=jw,b.iteratee=Ca,b.keyBy=Jw,b.keys=He,b.keysIn=vt,b.map=ws,b.mapKeys=h1,b.mapValues=d1,b.matches=ob,b.matchesProperty=ab,b.memoize=bs,b.merge=f1,b.mergeWith=Th,b.method=lb,b.methodOf=cb,b.mixin=Va,b.negate=_s,b.nthArg=hb,b.omit=p1,b.omitBy=m1,b.once=ux,b.orderBy=Qw,b.over=db,b.overArgs=hx,b.overEvery=fb,b.overSome=pb,b.partial=Sa,b.partialRight=yh,b.partition=Hw,b.pick=g1,b.pickBy=Zh,b.property=Ah,b.propertyOf=mb,b.pull=Qv,b.pullAll=oh,b.pullAllBy=Hv,b.pullAllWith=Ev,b.pullAt=qv,b.range=gb,b.rangeRight=yb,b.rearg=dx,b.reject=$w,b.remove=$v,b.rest=fx,b.reverse=_a,b.sampleSize=tx,b.set=v1,b.setWith=w1,b.shuffle=nx,b.slice=ew,b.sortBy=sx,b.sortedUniq=aw,b.sortedUniqBy=lw,b.split=K1,b.spread=px,b.tail=cw,b.take=uw,b.takeRight=hw,b.takeRightWhile=dw,b.takeWhile=fw,b.tap=Gw,b.throttle=mx,b.thru=vs,b.toArray=_h,b.toPairs=Gh,b.toPairsIn=Wh,b.toPath=_b,b.toPlainObject=Lh,b.transform=x1,b.unary=gx,b.union=pw,b.unionBy=mw,b.unionWith=gw,b.uniq=yw,b.uniqBy=vw,b.uniqWith=ww,b.unset=b1,b.unzip=Ma,b.unzipWith=ah,b.update=_1,b.updateWith=M1,b.values=Ci,b.valuesIn=L1,b.without=xw,b.words=Ch,b.wrap=yx,b.xor=bw,b.xorBy=_w,b.xorWith=Mw,b.zip=Lw,b.zipObject=Sw,b.zipObjectDeep=Tw,b.zipWith=Zw,b.entries=Gh,b.entriesIn=Wh,b.extend=Sh,b.extendWith=Ss,Va(b,b),b.add=Lb,b.attempt=Vh,b.camelCase=G1,b.capitalize=Ph,b.ceil=Sb,b.clamp=S1,b.clone=wx,b.cloneDeep=bx,b.cloneDeepWith=_x,b.cloneWith=xx,b.conformsTo=Mx,b.deburr=Ih,b.defaultTo=ib,b.divide=Tb,b.endsWith=W1,b.eq=Qt,b.escape=P1,b.escapeRegExp=I1,b.every=Dw,b.find=Ow,b.findIndex=nh,b.findKey=$x,b.findLast=Rw,b.findLastIndex=ih,b.findLastKey=e1,b.floor=Zb,b.forEach=ch,b.forEachRight=uh,b.forIn=t1,b.forInRight=n1,b.forOwn=i1,b.forOwnRight=r1,b.get=Ga,b.gt=Lx,b.gte=Sx,b.has=a1,b.hasIn=Wa,b.head=sh,b.identity=wt,b.includes=Nw,b.indexOf=Rv,b.inRange=T1,b.invoke=u1,b.isArguments=li,b.isArray=fe,b.isArrayBuffer=Tx,b.isArrayLike=yt,b.isArrayLikeObject=Oe,b.isBoolean=Zx,b.isBuffer=Rn,b.isDate=Gx,b.isElement=Wx,b.isEmpty=Px,b.isEqual=Ix,b.isEqualWith=Cx,b.isError=Ta,b.isFinite=Vx,b.isFunction=wn,b.isInteger=vh,b.isLength=Ms,b.isMap=wh,b.isMatch=Ax,b.isMatchWith=Fx,b.isNaN=Xx,b.isNative=zx,b.isNil=kx,b.isNull=Dx,b.isNumber=xh,b.isObject=Fe,b.isObjectLike=De,b.isPlainObject=mr,b.isRegExp=Za,b.isSafeInteger=Ox,b.isSet=bh,b.isString=Ls,b.isSymbol=Lt,b.isTypedArray=Ii,b.isUndefined=Rx,b.isWeakMap=Kx,b.isWeakSet=Yx,b.join=Nv,b.kebabCase=C1,b.last=kt,b.lastIndexOf=jv,b.lowerCase=V1,b.lowerFirst=A1,b.lt=Ux,b.lte=Bx,b.max=Gb,b.maxBy=Wb,b.mean=Pb,b.meanBy=Ib,b.min=Cb,b.minBy=Vb,b.stubArray=Fa,b.stubFalse=Xa,b.stubObject=vb,b.stubString=wb,b.stubTrue=xb,b.multiply=Ab,b.nth=Jv,b.noConflict=ub,b.noop=Aa,b.now=xs,b.pad=F1,b.padEnd=X1,b.padStart=z1,b.parseInt=D1,b.random=Z1,b.reduce=Ew,b.reduceRight=qw,b.repeat=k1,b.replace=O1,b.result=y1,b.round=Fb,b.runInContext=V,b.sample=ex,b.size=ix,b.snakeCase=R1,b.some=rx,b.sortedIndex=tw,b.sortedIndexBy=nw,b.sortedIndexOf=iw,b.sortedLastIndex=rw,b.sortedLastIndexBy=sw,b.sortedLastIndexOf=ow,b.startCase=Y1,b.startsWith=U1,b.subtract=Xb,b.sum=zb,b.sumBy=Db,b.template=B1,b.times=bb,b.toFinite=xn,b.toInteger=pe,b.toLength=Mh,b.toLower=N1,b.toNumber=Ot,b.toSafeInteger=Nx,b.toString=Ze,b.toUpper=j1,b.trim=J1,b.trimEnd=Q1,b.trimStart=H1,b.truncate=E1,b.unescape=q1,b.uniqueId=Mb,b.upperCase=$1,b.upperFirst=Pa,b.each=ch,b.eachRight=uh,b.first=sh,Va(b,function(){var r={};return on(b,function(o,h){Ge.call(b.prototype,h)||(r[h]=o)}),r}(),{chain:!1}),b.VERSION=n,At(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){b[r].placeholder=b}),At(["drop","take"],function(r,o){Me.prototype[r]=function(h){h=h===e?1:Ne(pe(h),0);var g=this.__filtered__&&!o?new Me(this):this.clone();return g.__filtered__?g.__takeCount__=ot(h,g.__takeCount__):g.__views__.push({size:ot(h,be),type:r+(g.__dir__<0?"Right":"")}),g},Me.prototype[r+"Right"]=function(h){return this.reverse()[r](h).reverse()}}),At(["filter","map","takeWhile"],function(r,o){var h=o+1,g=h==j||h==J;Me.prototype[r]=function(w){var L=this.clone();return L.__iteratees__.push({iteratee:ae(w,3),type:h}),L.__filtered__=L.__filtered__||g,L}}),At(["head","last"],function(r,o){var h="take"+(o?"Right":"");Me.prototype[r]=function(){return this[h](1).value()[0]}}),At(["initial","tail"],function(r,o){var h="drop"+(o?"":"Right");Me.prototype[r]=function(){return this.__filtered__?new Me(this):this[h](1)}}),Me.prototype.compact=function(){return this.filter(wt)},Me.prototype.find=function(r){return this.filter(r).head()},Me.prototype.findLast=function(r){return this.reverse().find(r)},Me.prototype.invokeMap=ye(function(r,o){return typeof r=="function"?new Me(this):this.map(function(h){return cr(h,r,o)})}),Me.prototype.reject=function(r){return this.filter(_s(ae(r)))},Me.prototype.slice=function(r,o){r=pe(r);var h=this;return h.__filtered__&&(r>0||o<0)?new Me(h):(r<0?h=h.takeRight(-r):r&&(h=h.drop(r)),o!==e&&(o=pe(o),h=o<0?h.dropRight(-o):h.take(o-r)),h)},Me.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},Me.prototype.toArray=function(){return this.take(be)},on(Me.prototype,function(r,o){var h=/^(?:filter|find|map|reject)|While$/.test(o),g=/^(?:head|last)$/.test(o),w=b[g?"take"+(o=="last"?"Right":""):o],L=g||/^find/.test(o);w&&(b.prototype[o]=function(){var W=this.__wrapped__,P=g?[1]:arguments,F=W instanceof Me,U=P[0],B=F||fe(W),Q=function(_e){var Le=w.apply(b,An([_e],P));return g&&$?Le[0]:Le};B&&h&&typeof U=="function"&&U.length!=1&&(F=B=!1);var $=this.__chain__,ie=!!this.__actions__.length,le=L&&!$,ge=F&&!ie;if(!L&&B){W=ge?W:new Me(this);var ce=r.apply(W,P);return ce.__actions__.push({func:vs,args:[Q],thisArg:e}),new Xt(ce,$)}return le&&ge?r.apply(this,P):(ce=this.thru(Q),le?g?ce.value()[0]:ce.value():ce)})}),At(["pop","push","shift","sort","splice","unshift"],function(r){var o=Ur[r],h=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",g=/^(?:pop|shift)$/.test(r);b.prototype[r]=function(){var w=arguments;if(g&&!this.__chain__){var L=this.value();return o.apply(fe(L)?L:[],w)}return this[h](function(W){return o.apply(fe(W)?W:[],w)})}}),on(Me.prototype,function(r,o){var h=b[o];if(h){var g=h.name+"";Ge.call(Ti,g)||(Ti[g]=[]),Ti[g].push({name:o,func:h})}}),Ti[hs(e,Z).name]=[{name:"wrapper",func:e}],Me.prototype.clone=qg,Me.prototype.reverse=$g,Me.prototype.value=ey,b.prototype.at=Ww,b.prototype.chain=Pw,b.prototype.commit=Iw,b.prototype.next=Cw,b.prototype.plant=Aw,b.prototype.reverse=Fw,b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=Xw,b.prototype.first=b.prototype.head,nr&&(b.prototype[nr]=Vw),b},Mi=Ig();ei?((ei.exports=Mi)._=Mi,Co._=Mi):nt._=Mi}).call(Ni)}(Wr,Wr.exports);var Zp=Wr.exports;let ji=class extends hn{constructor(e){super(e);T(this,"_baseType","Point");this._threeGeometry=this._createThreeGeometry(),this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=new m.Vector3(this._geometry.coordinates[0],this._geometry.coordinates[1],this._geometry.coordinates[2]||0);return e?e.geo2world(n):n}_toThreeJSGeometry(){}_createThreeGeometry(){return new m.Points(new m.BufferGeometry,new m.PointsMaterial({size:1,color:8947848}))}};const Gp={};class so extends ji{constructor(e){super(e);T(this,"_type","Maker")}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"basic-point":return Zl(e.config,new m.Vector3(0,0,0));case"icon-point":return Kf(e.config,this._position);case"icon-label-point":return Ef(e.config,this.getMap(),this._position);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(e,n){if(!this.visible||!this._threeGeometry||!e||!n)return null;try{switch(this._style?.config.type){case"icon-point":return this._calculateSpriteBoundingBox(this._threeGeometry);default:return this._getFallbackBoundingBox()}}catch(i){return console.warn(`Maker ${this._id} 包围盒计算失败:`,i),this._getFallbackBoundingBox()}}_calculateSpriteBoundingBox(e){try{const i=Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))/.002;return{width:i,height:i,offsetX:-i/2,offsetY:-i/2}}catch{return{width:20,height:20,offsetX:-10,offsetY:-10}}}_getFallbackBoundingBox(){switch(this.getStyle()?.config.type){case"icon-point":case"icon-label-point":return{width:20,height:20,offsetX:-10,offsetY:-10};case"basic-point":return{width:10,height:10,offsetX:-5,offsetY:-5};default:return{width:15,height:15,offsetX:-7.5,offsetY:-7.5}}}}so.mergeOptions(Gp);class Xl extends hn{constructor(e){super(e);T(this,"_baseType","Line");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=this._geometry,i=e?.prjcenter;if(this._geometry.type==="LineString"){let l=n.coordinates.map(c=>{const d=new m.Vector3(c[0],c[1],c[2]||0);return(e?e.geo2world(d):d).sub(i)}),u=l.flatMap(c=>[c.x,c.y,c.z]);return{_position:l,_vertexPoints:u}}}_toThreeJSGeometry(){}_createThreeGeometry(){const e=new xr,n=new zi({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Ys(e,n)}}const Wp={};class oo extends Xl{constructor(e){super(e);T(this,"_type","LineString")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this._disposeGeometry(),this._threeGeometry=await this._createObject(this._style),this._updateGeometry())}async _createObject(e){switch(e.config.type){case"basic-line":return to(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_updateGeometry(){const e=this.getMap();if(this._disposeGeometry(),this._threeGeometry){const i=this._threeGeometry.geometry;i.setPositions(this._vertexPoints),i.computeBoundingSphere(),i.computeBoundingBox(),this._threeGeometry.position.add(e?.prjcenter),this._threeGeometry.renderOrder=99,this.add(this._threeGeometry),this.updateMatrixWorld(!0),this._tryProcessQueue()}}}oo.mergeOptions(Wp);class Pp extends hn{constructor(e){super(e);T(this,"_baseType","Surface");T(this,"_vertexPoints");this._threeGeometry=this._createThreeGeometry(),this._vertexPoints=[0,0,0],this._style&&this._style.applyTo(this._threeGeometry)}_coordsTransform(){const e=this.getMap(),n=e?.prjcenter,i=this._geometry;if(!i)throw new Error("几何数据未定义");if(i.type==="Polygon"){const s=i.coordinates;let l=[],u=[];return s.forEach(c=>{const d=c.map(p=>{const f=new m.Vector3(p[0],p[1],p[2]||0);return(e?e.geo2world(f):f).sub(n)});l.push(d),u.push(...d.flatMap(p=>[p.x,p.y,p.z]))}),{_positions:l,_vertexPoints:u}}else if(i.type==="MultiPolygon"){const s=i.coordinates;let l=[],u=[];return s.forEach(c=>{const d=[];c.forEach(p=>{const f=p.map(y=>{const v=new m.Vector3(y[0],y[1],y[2]||0);return(e?e.geo2world(v):v).sub(n)});d.push(f),u.push(...f.flatMap(y=>[y.x,y.y,y.z]))}),l.push(d)}),{_positions:l,_vertexPoints:u}}else throw new Error(`不支持的几何类型: ${i.type}`)}_updateGeometry(){const e=this._style?.config.type;if(this.clear(),!this._threeGeometry||!this._vertexPoints?.length){console.warn("无法更新几何体:缺少几何体或顶点数据");return}const n=this.getMap();try{e==="basic-polygon"?(this._threeGeometry.renderOrder=90,this._threeGeometry.position.add(n?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry)):(e==="extrude-polygon"||e?.includes("water"))&&(this._threeGeometry.renderOrder=90,this._threeGeometry.position.add(n?.prjcenter),this._threeGeometry.updateMatrix(),this.add(this._threeGeometry))}catch(i){throw console.error("更新多边形位置失败:",i),i}}_createThreeGeometry(){const e=new xr,n=new zi({color:8947848,linewidth:.1,dashed:!1,resolution:new m.Vector2(window.innerWidth,window.innerHeight)});return new Ys(e,n)}}const Ip={};class zl extends Pp{constructor(e){super(e);T(this,"_type","Polygon")}async _toThreeJSGeometry(){let{_vertexPoints:e}=this._coordsTransform();this._vertexPoints=e,this._style&&(this._threeGeometry&&this.remove(this._threeGeometry),this._threeGeometry=await this._createObject(this._style),this._updateGeometry(),await this._style.applyTo(this._threeGeometry))}async _createObject(e){switch(e.config.type){case"basic-polygon":return Uf(e.config,this._vertexPoints);case"extrude-polygon":return Bf(e.config,this._vertexPoints);case"water":return Nf(e.config,this.getMap(),this._vertexPoints);case"base-water":return jf(e.config,this._vertexPoints);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_calculateCollisionBoundingBox(){return null}}zl.mergeOptions(Ip);const Cp={};class Dl extends Xl{constructor(e){super(e);T(this,"_type","MultiLineString");T(this,"_lineObjects",[]);T(this,"_linesContainer");this._linesContainer=new m.Group}async _toThreeJSGeometry(){debugger;const{_position:e}=this._coordsTransform(),n=this.getMap();if(this.clearLines(),this._disposeGeometry(),this._style){for(const i of e){const s=i.flatMap(u=>[u.x,u.y,u.z]),l=await this._createLineObject(this._style,s);l.position.add(n?.prjcenter),l.updateMatrixWorld(!0),l.renderOrder=99,this._lineObjects.push(l),this._linesContainer.add(l)}this._linesContainer.renderOrder=99,this._threeGeometry=this._linesContainer,this.add(this._threeGeometry),this._updateContainer(),this.updateMatrixWorld(!0),this._threeGeometry.updateMatrixWorld(!0),this._tryProcessQueue()}}async _createLineObject(e,n){switch(e.config.type){case"basic-line":return to(e.config,n);default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}_coordsTransform(){const e=this.getMap(),n=this._geometry;if(this._geometry.type==="MultiLineString"){const i=e?.prjcenter;return{_position:n.coordinates.map(l=>l.map(u=>{const c=new m.Vector3(u[0],u[1],u[2]||0);return(e?e.geo2world(c):c).sub(i)}))}}}_updateContainer(){this._linesContainer.updateMatrixWorld(!0)}clearLines(){this._lineObjects.forEach(e=>{this._linesContainer.remove(e),e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),this._lineObjects=[]}_updateGeometry(){this._toThreeJSGeometry()}_disposeObject(){}}Dl.mergeOptions(Cp);const ao=64;class Vp extends rt.MeshStandardMaterial{constructor(e={}){const{shaderOption:n,regionOverlay:i,...s}=e;super({color:"rgb(58,126,182)",roughness:.7,metalness:.1,transparent:!0,opacity:.9,envMapIntensity:.8,depthWrite:!0,depthTest:!0,...s});T(this,"shaderOption");T(this,"clock");T(this,"time");T(this,"startTime");T(this,"regionOverlay");if(i&&i.vertices&&i.vertices.length>0){const l=i.vertices.slice(0,ao).map(c=>c.clone()),u=l.length;for(;l.length<ao;)l.push(new rt.Vector2(0,0));this.regionOverlay={color:i.color,opacity:i.opacity,vertices:l,vertexCount:u}}this.shaderOption={minY:0,maxY:100,minRate:.3,maxRate:1.5,effects:{diffusion:{enabled:!1,color:new rt.Color("#9ECDEC"),width:20,speed:1,maxDistance:100,center:void 0},flow:{enabled:!1,color:new rt.Color("#00E4FF"),range:10,speed:20},sweep:{enabled:!1,color:new rt.Color("#FFFFFF"),width:1.5,speed:10}},...n},this.clock=new rt.Clock,this.time={value:0},this.startTime={value:0},this.animate()}onBeforeCompile(e){const{minY:n,maxY:i,minRate:s,maxRate:l,effects:u}=this.shaderOption,c=i-n,d=!!this.regionOverlay;e.uniforms={...e.uniforms,time:this.time,uStartTime:this.startTime,uMinY:{value:n},uMaxY:{value:i},uHeightRange:{value:c},uMinRate:{value:s},uMaxRate:{value:l},uDiffusionEnabled:{value:u?.diffusion?.enabled?1:0},uDiffusionColor:{value:u?.diffusion?.color||new rt.Color("#9ECDEC")},uDiffusionWidth:{value:u?.diffusion?.width||20},uDiffusionSpeed:{value:u?.diffusion?.speed||1},uDiffusionMaxDistance:{value:u?.diffusion?.maxDistance||100},uDiffusionCenter:{value:u?.diffusion?.center||new rt.Vector3(0,0,0)},uFlowEnabled:{value:u?.flow?.enabled?1:0},uFlowColor:{value:u?.flow?.color||new rt.Color("#00E4FF")},uFlowRange:{value:u?.flow?.range||10},uFlowSpeed:{value:u?.flow?.speed||20},uSweepEnabled:{value:u?.sweep?.enabled?1:0},uSweepColor:{value:u?.sweep?.color||new rt.Color("#FFFFFF")},uSweepWidth:{value:u?.sweep?.width||1.5},uSweepSpeed:{value:u?.sweep?.speed||10},uRegionOverlayEnabled:{value:d?1:0},uRegionOverlayColor:{value:this.regionOverlay?.color||new rt.Color("#00FF88")},uRegionOverlayOpacity:{value:this.regionOverlay?.opacity??0},uRegionOverlayVertexCount:{value:this.regionOverlay?.vertexCount??0},uRegionOverlayVertices:{value:this.regionOverlay?.vertices||new Array(ao).fill(0).map(()=>new rt.Vector2(0,0))}},e.vertexShader=`
|
|
566
566
|
varying vec3 vWorldPosition;
|
|
567
567
|
varying vec3 vPosition;
|
|
568
568
|
varying float vHeight;
|
|
@@ -690,9 +690,9 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
690
690
|
);
|
|
691
691
|
}
|
|
692
692
|
}
|
|
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 Ap={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class kl extends ji{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 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 x=f[v],S=f[v+2],_=p.x+x,Z=p.z+S;y.push(new m.Vector2(_,Z))}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 Vp({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.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(Ap);const Fp={};class Ol extends ji{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=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(Fp);const Xp={};class Rl extends ji{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 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}`)}}}Rl.mergeOptions(Xp);const zp={};class Kl extends ji{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 ep(e.config,this._geometries,this.getMap());default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Kl.mergeOptions(zp);function Pr(a,t){if(!a||a===!0)return!0;if(!Array.isArray(a))return!!a;switch(a[0]){case"all":return a.slice(1).every(n=>Pr(n,t));case"any":return a.slice(1).some(n=>Pr(n,t));case"!":return!Pr(a[1],t);case"==":{const n=st(a[1],t),i=st(a[2],t);return Ir(n)==Ir(i)}case"!=":{const n=st(a[1],t),i=st(a[2],t);return Ir(n)!=Ir(i)}case">":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)>Tn(i)}case"<":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)<Tn(i)}case">=":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)>=Tn(i)}case"<=":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)<=Tn(i)}case"in":{const n=st(a[1],t);return a.slice(2).map(s=>st(s,t)).includes(n)}case"!in":{const n=st(a[1],t);return!a.slice(2).map(s=>st(s,t)).includes(n)}case"has":{const n=a[1];return t!=null&&Object.prototype.hasOwnProperty.call(t,n)}case"!has":{const n=a[1];return!(t!=null&&Object.prototype.hasOwnProperty.call(t,n))}default:return!0}}function st(a,t){if(Array.isArray(a))switch(a[0]){case"get":return t?t[a[1]]:void 0;default:return a}return a}function Ir(a){if(a==null)return null;if(typeof a=="string"){const t=Number(a);if(!isNaN(t)&&a.trim()!=="")return t}return typeof a=="boolean"?a?1:0:a}function Tn(a){if(a==null)return 0;if(typeof a=="number")return a;if(typeof a=="boolean")return a?1:0;if(typeof a=="string"){const t=Number(a);return isNaN(t)?0:t}return Number(a)}class lo 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 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],x=v.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(v.properties))continue;let S=null;for(const _ of d)if(this._evaluateFilter(_.filter,v.properties,p,v.geometry.type)){S=_.style;break}if(S){const _={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:x,extent:this.EXTENT,tileSize:this.TILE_SIZE},Z=this._createFeatureInstance(v.geometry,v.geometry.type,S,v.properties);Z&&(Z.userData.tileData=_,Z.style=Wt.create(S),Z.addTo(this),Z.initializeGeometry(),c.push(Z))}}}),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 so(u);case"LineString":return new oo(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 hn}dispose(){this._tileFeatureMap.forEach((e,n)=>{this._removeFeaturesByTileKey(n)}),super.dispose()}}class Yl extends Tr{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 tn,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);T(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const Xe={manager:new Ul,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(a){Xe.imgLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Ts.name},registerGeometryLoader(a){Xe.demLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Ts.name},registerMeshLoader(a){Xe.meshLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Ts.name},getMaterialLoader(a){const t=Xe.imgLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`},getGeometryLoader(a){const t=Xe.demLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`},getMeshLoader(a){const t=Xe.meshLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`}};class Dp{constructor(t){T(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 kp=4096,Bl=Math.PI;function co(a,t){const e=Math.floor(a[0]*t),n=Math.floor(a[1]*t),i=Math.floor((a[2]-a[0])*t),s=Math.floor((a[3]-a[1])*t);return{sx:e,sy:n,sw:i,sh:s}}function uo(a,t,e,n){if(n<a.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=a.maxLevel)return{url:a._getUrl(t,e,n),clipBounds:[0,0,1,1]};const i=Op(t,e,n,a.maxLevel),s=i.parentNO;return{url:a._getUrl(s.x,s.y,s.z),clipBounds:i.bounds}}function Op(a,t,e,n){const i=e-n,s={x:a>>i,y:t>>i,z:e-i},l=Math.pow(2,i),u=Math.pow(.5,i),c=a%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 ho(a,t,e,n,i=kp){const{x:s,y:l}=a,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 Rp(a,t,e,n){if(!a||!a.coordinates)throw new Error("无效的geometry数据格式");const i={type:a.type,coordinates:null};function s(l){if(typeof l=="object"&&l.x!==void 0&&l.y!==void 0)return ho(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=>ho(c,t,e,n)):l.map(c=>s(c))}return l}return i.coordinates=s(a.coordinates),i}class Cr{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 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=Xe.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=Xe.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=Xe.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(...a){const t=a,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(a,t,e,n){const i=n?Yp(n,a.position.value):Kp(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++)Up({edge:i[f],edgeIndex:f,attributes:a,skirtHeight:e,newPosition:l,newTexcoord0:u,newTriangles:c,newNormals:d});a.position.value=Ji(a.position.value,l),a.texcoord.value=Ji(a.texcoord.value,u),a.normal.value=Ji(a.normal.value,d);const p=Ji(t,c);return{attributes:a,indices:p}}function Kp(a){const t=[],e=Array.isArray(a)?a:Array.from(a);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 Yp(a,t){const e=(i,s)=>{i.sort(s)};e(a.westIndices,(i,s)=>t[3*i+1]-t[3*s+1]),e(a.eastIndices,(i,s)=>t[3*s+1]-t[3*i+1]),e(a.southIndices,(i,s)=>t[3*s]-t[3*i]),e(a.northIndices,(i,s)=>t[3*i]-t[3*s]);const n=[];return Object.values(a).forEach(i=>{if(i.length>1)for(let s=0;s<i.length-1;s++)n.push([i[s],i[s+1]])}),n}function Up({edge:a,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(a[0]*3,a[0]*3+3),d*3),i[d*3+2]=i[d*3+2]-n,i.set(e.position.value.subarray(a[1]*3,a[1]*3+3),p*3),i[p*3+2]=i[p*3+2]-n,s.set(e.texcoord.value.subarray(a[0]*2,a[0]*2+2),d*2),s.set(e.texcoord.value.subarray(a[1]*2,a[1]*2+2),p*2);const f=t*2*3;l[f]=a[0],l[f+1]=c/3+p,l[f+2]=a[1],l[f+3]=c/3+p,l[f+4]=a[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(a){if(a.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${a.length}!`);const t=Math.floor(Math.sqrt(a.length)),e=t,n=t,i=fo(n,e);return{attributes:Bp(a,n,e),indices:i}}function Bp(a,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]=a[(t-u-1)*e+c],l++}return{position:{value:i,size:3},texcoord:{value:s,size:2},normal:{value:po(i,fo(t,e)),size:3}}}function fo(a,t){const e=6*(t-1)*(a-1),n=new Uint16Array(e);let i=0;for(let s=0;s<a-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 po(a,t){const e=new Float32Array(a.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=a[i],c=a[i+1],d=a[i+2],p=a[s],f=a[s+1],y=a[s+2],v=a[l],x=a[l+1],S=a[l+2],_=p-u,Z=f-c,M=y-d,G=v-u,A=x-c,R=S-d,D=Z*R-M*A,k=M*G-_*R,C=_*A-Z*G,K=Math.sqrt(D*D+k*k+C*C),I=[0,0,1];if(K>0){const z=1/K;I[0]=D*z,I[1]=k*z,I[2]=C*z}for(let z=0;z<3;z++)e[i+z]=e[s+z]=e[l+z]=I[z]}return e}class fi extends m.PlaneGeometry{constructor(){super(...arguments);T(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){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 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 Np(t,this)}}class Np{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: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,x=p+y>>1,S=v+x-p,_=x+d-v,Z=(s[p*i+d]+s[y*i+f])/2,M=x*i+v,G=Math.abs(Z-s[M]);if(l[M]=Math.max(l[M],G),u<e){const A=(p+_>>1)*i+(d+S>>1),R=(y+_>>1)*i+(f+S>>1);l[M]=Math.max(l[M],l[A],l[R])}}}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(M,G,A,R,D,k){const C=M+A>>1,K=G+R>>1;Math.abs(M-D)+Math.abs(G-k)>1&&i[K*e+C]>t?(f(D,k,M,G,C,K),f(A,R,D,k,C,K)):(c=G*e+M,d=R*e+A,p=k*e+D,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,x=new Uint16Array(y),S=new Uint32Array(v);let _=0;function Z(M,G,A,R,D,k){const C=M+A>>1,K=G+R>>1;if(Math.abs(M-D)+Math.abs(G-k)>1&&i[K*e+C]>t)Z(D,k,M,G,C,K),Z(A,R,D,k,C,K);else{const I=n[G*e+M]-1,z=n[R*e+A]-1,N=n[k*e+D]-1;x[2*I]=M,x[2*I+1]=G,x[2*z]=A,x[2*z+1]=R,x[2*N]=D,x[2*N+1]=k,S[_++]=I,S[_++]=z,S[_++]=N}}return Z(0,0,u,u,u,0),Z(u,u,0,0,0,u),{attributes:this._getMeshAttributes(this.terrain,x,S),indices:S}}_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=po(u,n);return{position:{value:u,size:3},texcoord:{value:c,size:2},normal:{value:d,size:3}}}}class mo{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:i,z:s}=t,{url:l,clipBounds:u}=uo(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 Xe.manager.parseEnd(l),c}}class go 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=(a=>(a[a.Unknown=0]="Unknown",a[a.Point=1]="Point",a[a.Linestring=2]="Linestring",a[a.Polygon=3]="Polygon",a))(tt||{});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 tt.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 tt.Linestring:this._renderLineString(t,n,s);break;case tt.Polygon:this._renderPolygon(t,n,s);break;default:console.warn(`Unknown feature type: ${e}`)}(i.fill||e===tt.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 yo{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:i,z:s}=t,l=new go,{url:u,clipBounds:c}=uo(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,Xe.manager.parseEnd(u)}return l}}class jp{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 go({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 Jp extends yo{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 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=Qp(i,l):s.image=i,s.needsUpdate=!0,s}}function Qp(a,t){const e=a.width,n=new OffscreenCanvas(e,e),i=n.getContext("2d"),{sx:s,sy:l,sw:u,sh:c}=co(t,a.width);return i.drawImage(a,s,l,u,c,0,0,e,e),n}const Hp=`{
|
|
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 Ap={emissive:!1,emissiveIntensity:1,emissiveColor:"#ffffff"};class kl extends ji{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 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 x=f[v],S=f[v+2],_=p.x+x,Z=p.z+S;y.push(new m.Vector2(_,Z))}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 Vp({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(Ap);const Fp={};class Ol extends ji{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=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(Fp);const Xp={};class Rl extends ji{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 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}`)}}}Rl.mergeOptions(Xp);const zp={};class Kl extends ji{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 ep(e.config,this._geometries,this.getMap());default:throw new Error(`不支持的样式类型: ${e.config.type}`)}}}Kl.mergeOptions(zp);function Pr(a,t){if(!a||a===!0)return!0;if(!Array.isArray(a))return!!a;switch(a[0]){case"all":return a.slice(1).every(n=>Pr(n,t));case"any":return a.slice(1).some(n=>Pr(n,t));case"!":return!Pr(a[1],t);case"==":{const n=st(a[1],t),i=st(a[2],t);return Ir(n)==Ir(i)}case"!=":{const n=st(a[1],t),i=st(a[2],t);return Ir(n)!=Ir(i)}case">":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)>Tn(i)}case"<":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)<Tn(i)}case">=":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)>=Tn(i)}case"<=":{const n=st(a[1],t),i=st(a[2],t);return Tn(n)<=Tn(i)}case"in":{const n=st(a[1],t);return a.slice(2).map(s=>st(s,t)).includes(n)}case"!in":{const n=st(a[1],t);return!a.slice(2).map(s=>st(s,t)).includes(n)}case"has":{const n=a[1];return t!=null&&Object.prototype.hasOwnProperty.call(t,n)}case"!has":{const n=a[1];return!(t!=null&&Object.prototype.hasOwnProperty.call(t,n))}default:return!0}}function st(a,t){if(Array.isArray(a))switch(a[0]){case"get":return t?t[a[1]]:void 0;default:return a}return a}function Ir(a){if(a==null)return null;if(typeof a=="string"){const t=Number(a);if(!isNaN(t)&&a.trim()!=="")return t}return typeof a=="boolean"?a?1:0:a}function Tn(a){if(a==null)return 0;if(typeof a=="number")return a;if(typeof a=="boolean")return a?1:0;if(typeof a=="string"){const t=Number(a);return isNaN(t)?0:t}return Number(a)}class lo 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 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],x=v.geometry;if(this._activeFeatureFilter&&!this._activeFeatureFilter(v.properties))continue;let S=null;for(const _ of d)if(this._evaluateFilter(_.filter,v.properties,p,v.geometry.type)){S=_.style;break}if(S){const _={isVectorTile:!0,tileZ:e.z,tileX:e.x,tileY:e.y,rawCoordinates:x,extent:this.EXTENT,tileSize:this.TILE_SIZE},Z=this._createFeatureInstance(v.geometry,v.geometry.type,S,v.properties);Z&&(Z.userData.tileData=_,Z.style=Wt.create(S),Z.addTo(this),Z.initializeGeometry(),c.push(Z))}}}),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 so(u);case"LineString":return new oo(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 hn}dispose(){this._tileFeatureMap.forEach((e,n)=>{this._removeFeaturesByTileKey(n)}),super.dispose()}}class Yl extends Tr{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 tn,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);T(this,"onParseEnd")}parseEnd(e){this.onParseEnd&&this.onParseEnd(e)}}const Xe={manager:new Ul,demLoaderMap:new Map,meshLoaderMap:new Map,imgLoaderMap:new Map,registerMaterialLoader(a){Xe.imgLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Ts.name},registerGeometryLoader(a){Xe.demLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Ts.name},registerMeshLoader(a){Xe.meshLoaderMap.set(a.dataType,a),a.info.author=a.info.author??Ts.name},getMaterialLoader(a){const t=Xe.imgLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`},getGeometryLoader(a){const t=Xe.demLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`},getMeshLoader(a){const t=Xe.meshLoaderMap.get(a.dataType);if(t)return t;throw`Source dataType "${a.dataType}" is not support!`}};class Dp{constructor(t){T(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 kp=4096,Bl=Math.PI;function co(a,t){const e=Math.floor(a[0]*t),n=Math.floor(a[1]*t),i=Math.floor((a[2]-a[0])*t),s=Math.floor((a[3]-a[1])*t);return{sx:e,sy:n,sw:i,sh:s}}function uo(a,t,e,n){if(n<a.minLevel)return{url:void 0,clipBounds:[0,0,1,1]};if(n<=a.maxLevel)return{url:a._getUrl(t,e,n),clipBounds:[0,0,1,1]};const i=Op(t,e,n,a.maxLevel),s=i.parentNO;return{url:a._getUrl(s.x,s.y,s.z),clipBounds:i.bounds}}function Op(a,t,e,n){const i=e-n,s={x:a>>i,y:t>>i,z:e-i},l=Math.pow(2,i),u=Math.pow(.5,i),c=a%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 ho(a,t,e,n,i=kp){const{x:s,y:l}=a,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 Rp(a,t,e,n){if(!a||!a.coordinates)throw new Error("无效的geometry数据格式");const i={type:a.type,coordinates:null};function s(l){if(typeof l=="object"&&l.x!==void 0&&l.y!==void 0)return ho(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=>ho(c,t,e,n)):l.map(c=>s(c))}return l}return i.coordinates=s(a.coordinates),i}class Cr{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 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=Xe.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=Xe.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=Xe.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(...a){const t=a,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(a,t,e,n){const i=n?Yp(n,a.position.value):Kp(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++)Up({edge:i[f],edgeIndex:f,attributes:a,skirtHeight:e,newPosition:l,newTexcoord0:u,newTriangles:c,newNormals:d});a.position.value=Ji(a.position.value,l),a.texcoord.value=Ji(a.texcoord.value,u),a.normal.value=Ji(a.normal.value,d);const p=Ji(t,c);return{attributes:a,indices:p}}function Kp(a){const t=[],e=Array.isArray(a)?a:Array.from(a);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 Yp(a,t){const e=(i,s)=>{i.sort(s)};e(a.westIndices,(i,s)=>t[3*i+1]-t[3*s+1]),e(a.eastIndices,(i,s)=>t[3*s+1]-t[3*i+1]),e(a.southIndices,(i,s)=>t[3*s]-t[3*i]),e(a.northIndices,(i,s)=>t[3*i]-t[3*s]);const n=[];return Object.values(a).forEach(i=>{if(i.length>1)for(let s=0;s<i.length-1;s++)n.push([i[s],i[s+1]])}),n}function Up({edge:a,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(a[0]*3,a[0]*3+3),d*3),i[d*3+2]=i[d*3+2]-n,i.set(e.position.value.subarray(a[1]*3,a[1]*3+3),p*3),i[p*3+2]=i[p*3+2]-n,s.set(e.texcoord.value.subarray(a[0]*2,a[0]*2+2),d*2),s.set(e.texcoord.value.subarray(a[1]*2,a[1]*2+2),p*2);const f=t*2*3;l[f]=a[0],l[f+1]=c/3+p,l[f+2]=a[1],l[f+3]=c/3+p,l[f+4]=a[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(a){if(a.length<4)throw new Error(`DEM数组长度必须大于4,当前长度: ${a.length}!`);const t=Math.floor(Math.sqrt(a.length)),e=t,n=t,i=fo(n,e);return{attributes:Bp(a,n,e),indices:i}}function Bp(a,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]=a[(t-u-1)*e+c],l++}return{position:{value:i,size:3},texcoord:{value:s,size:2},normal:{value:po(i,fo(t,e)),size:3}}}function fo(a,t){const e=6*(t-1)*(a-1),n=new Uint16Array(e);let i=0;for(let s=0;s<a-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 po(a,t){const e=new Float32Array(a.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=a[i],c=a[i+1],d=a[i+2],p=a[s],f=a[s+1],y=a[s+2],v=a[l],x=a[l+1],S=a[l+2],_=p-u,Z=f-c,M=y-d,G=v-u,A=x-c,R=S-d,D=Z*R-M*A,k=M*G-_*R,C=_*A-Z*G,K=Math.sqrt(D*D+k*k+C*C),I=[0,0,1];if(K>0){const z=1/K;I[0]=D*z,I[1]=k*z,I[2]=C*z}for(let z=0;z<3;z++)e[i+z]=e[s+z]=e[l+z]=I[z]}return e}class fi extends m.PlaneGeometry{constructor(){super(...arguments);T(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){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 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 Np(t,this)}}class Np{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: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,x=p+y>>1,S=v+x-p,_=x+d-v,Z=(s[p*i+d]+s[y*i+f])/2,M=x*i+v,G=Math.abs(Z-s[M]);if(l[M]=Math.max(l[M],G),u<e){const A=(p+_>>1)*i+(d+S>>1),R=(y+_>>1)*i+(f+S>>1);l[M]=Math.max(l[M],l[A],l[R])}}}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(M,G,A,R,D,k){const C=M+A>>1,K=G+R>>1;Math.abs(M-D)+Math.abs(G-k)>1&&i[K*e+C]>t?(f(D,k,M,G,C,K),f(A,R,D,k,C,K)):(c=G*e+M,d=R*e+A,p=k*e+D,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,x=new Uint16Array(y),S=new Uint32Array(v);let _=0;function Z(M,G,A,R,D,k){const C=M+A>>1,K=G+R>>1;if(Math.abs(M-D)+Math.abs(G-k)>1&&i[K*e+C]>t)Z(D,k,M,G,C,K),Z(A,R,D,k,C,K);else{const I=n[G*e+M]-1,z=n[R*e+A]-1,N=n[k*e+D]-1;x[2*I]=M,x[2*I+1]=G,x[2*z]=A,x[2*z+1]=R,x[2*N]=D,x[2*N+1]=k,S[_++]=I,S[_++]=z,S[_++]=N}}return Z(0,0,u,u,u,0),Z(u,u,0,0,0,u),{attributes:this._getMeshAttributes(this.terrain,x,S),indices:S}}_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=po(u,n);return{position:{value:u,size:3},texcoord:{value:c,size:2},normal:{value:d,size:3}}}}class mo{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:i,z:s}=t,{url:l,clipBounds:u}=uo(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 Xe.manager.parseEnd(l),c}}class go 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=(a=>(a[a.Unknown=0]="Unknown",a[a.Point=1]="Point",a[a.Linestring=2]="Linestring",a[a.Polygon=3]="Polygon",a))(tt||{});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 tt.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 tt.Linestring:this._renderLineString(t,n,s);break;case tt.Polygon:this._renderPolygon(t,n,s);break;default:console.warn(`Unknown feature type: ${e}`)}(i.fill||e===tt.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 yo{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:i,z:s}=t,l=new go,{url:u,clipBounds:c}=uo(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,Xe.manager.parseEnd(u)}return l}}class jp{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 go({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 Jp extends yo{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 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=Qp(i,l):s.image=i,s.needsUpdate=!0,s}}function Qp(a,t){const e=a.width,n=new OffscreenCanvas(e,e),i=n.getContext("2d"),{sx:s,sy:l,sw:u,sh:c}=co(t,a.width);return i.drawImage(a,s,l,u,c,0,0,e,e),n}const Hp=`{
|
|
694
694
|
"name": "@terra.gl/core",
|
|
695
|
-
"version": "0.0.1-alpha.
|
|
695
|
+
"version": "0.0.1-alpha.21",
|
|
696
696
|
"type": "module",
|
|
697
697
|
"files": [
|
|
698
698
|
"dist"
|