s3m-maplibre 0.4.2 → 0.4.3

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.
@@ -52,6 +52,10 @@ export interface MapLike {
52
52
  };
53
53
  };
54
54
  getProjection?(): unknown;
55
+ /** 上下文恢复后用于把自定义图层重新加回地图(MapLibre / Mapbox 都有) */
56
+ getLayer?(id: string): unknown;
57
+ addLayer?(layer: unknown): unknown;
58
+ removeLayer?(id: string): unknown;
55
59
  }
56
60
  export interface MapMouseEventLike {
57
61
  originalEvent?: {
@@ -1 +1 @@
1
- {"version":3,"file":"MapLibreGeoAdapter.d.ts","sourceRoot":"","sources":["../src/MapLibreGeoAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAE5C,2BAA2B;AAC3B,eAAO,MAAM,WAAW,qBAAqB,CAAC;AAE9C,8DAA8D;AAC9D,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnG,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvF,kBAAkB,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnD;AAED,2CAA2C;AAC3C,MAAM,WAAW,OAAO;IACtB,SAAS,IAAI,iBAAiB,CAAC;IAC/B,cAAc,IAAI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Ae,CAAC,CAAS,EAAE,CAAS;YAClC,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACzC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;gBAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBACtE,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;YAC5B,CAAC;YACD,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAChB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -53,6 +53,17 @@ export declare class S3MLayer {
53
53
  private _orthoWarned;
54
54
  private _projection;
55
55
  private readonly _onProjectionChange;
56
+ /**
57
+ * WebGL 上下文是否处于丢失状态(丢失→恢复之间为 true)。
58
+ * 期间 render 会被 S3MViewer 内部短路,避免刷一堆 GL 错误。
59
+ */
60
+ private _contextLost;
61
+ /** 地图事件监听器是否已挂载,避免上下文恢复重加图层时重复绑定 */
62
+ private _listenersAttached;
63
+ private readonly _onContextLost;
64
+ private readonly _onContextRestored;
65
+ /** 从画布取回当前的 WebGL 上下文(恢复后已是新上下文) */
66
+ private _mapGl;
56
67
  constructor(options?: S3MLayerOptions);
57
68
  onAdd(map: MapLike, gl: WebGLRenderingContext | WebGL2RenderingContext): void;
58
69
  onRemove(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"S3MLayer.d.ts","sourceRoot":"","sources":["../src/S3MLayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV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AM,EAAE,eAAe,CAAC,CAE3C;IAED,2BAA2B;IAC3B,IAAI,WAAW,IAAI;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAExG;IAED,IAAI,WAAW,CAAC,GAAG,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,EAE1G;IAED,IAAI,cAAc,IAAI,SAAS,CAAC,gBAAgB,CAAC,CAEhD;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,IAAI,KAAK,IAAI,KAAK,CAEjB;IAED,sBAAsB;IACtB,SAAS,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,IAAI;IAIxD,OAAO,IAAI,IAAI;CAGhB;AAED,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,CAAC"}
package/dist/S3MLayer.js CHANGED
@@ -52,6 +52,52 @@ export class S3MLayer {
52
52
  this.viewer.geo = createMapLibreGeoAdapter(this.map);
53
53
  this.viewer.recomputeAnchors();
54
54
  };
55
+ /**
56
+ * WebGL 上下文是否处于丢失状态(丢失→恢复之间为 true)。
57
+ * 期间 render 会被 S3MViewer 内部短路,避免刷一堆 GL 错误。
58
+ */
59
+ _contextLost = false;
60
+ /** 地图事件监听器是否已挂载,避免上下文恢复重加图层时重复绑定 */
61
+ _listenersAttached = false;
62
+ _onContextLost = () => {
63
+ this._contextLost = true;
64
+ };
65
+ _onContextRestored = () => {
66
+ this._contextLost = false;
67
+ const map = this.map;
68
+ if (!map)
69
+ return;
70
+ // MapLibre 在 webglcontextlost 时销毁 style 并丢弃自定义图层(自定义图层
71
+ // 无法序列化进 style),恢复后不会自动加回。这里手动重新 addLayer;onAdd 会识别
72
+ // 「已挂载」并原地换新 renderer,保留已加载的瓦片,不重新拉取。
73
+ try {
74
+ const getLayer = map.getLayer;
75
+ const addLayer = map.addLayer;
76
+ const has = typeof getLayer === 'function' ? getLayer.call(map, this.id) : undefined;
77
+ if (!has) {
78
+ if (typeof addLayer === 'function')
79
+ addLayer.call(map, this);
80
+ }
81
+ else {
82
+ // 极端情况下图层仍在(理论上不会):确保 renderer 指向新上下文
83
+ const gl = this._mapGl();
84
+ if (gl)
85
+ this.viewer.restoreContext(gl);
86
+ }
87
+ }
88
+ catch (e) {
89
+ console.warn('[s3m] WebGL 上下文恢复后重加图层失败,请手动 map.addLayer(layer)', e);
90
+ }
91
+ map.triggerRepaint();
92
+ };
93
+ /** 从画布取回当前的 WebGL 上下文(恢复后已是新上下文) */
94
+ _mapGl() {
95
+ const canvas = this.map?.getCanvas?.();
96
+ if (!canvas)
97
+ return null;
98
+ return (canvas.getContext('webgl2') ??
99
+ canvas.getContext('webgl'));
100
+ }
55
101
  constructor(options = {}) {
56
102
  this.id = options.id ?? 's3m';
57
103
  this.options = options;
@@ -88,19 +134,35 @@ export class S3MLayer {
88
134
  // setter 会顺带把宿主地理坐标能力(MapLibre v5+ 任意 CRS / 自定义投影,
89
135
  // 老版本回退标准墨卡托)同步进 viewer
90
136
  this.map = map;
91
- this.viewer.mount(map.getCanvas(), gl);
92
- map.on('click', this._onClick);
93
- // 事件名必须是全称,写 'projection' 永远不会触发。v4 / v5 / Mapbox 没有这个事件,
94
- // 监听一个不存在的事件名是安全的(只是不 fire),初始投影在 onAdd 的 recomputeAnchors 里已覆盖。
95
- if (typeof map.on === 'function') {
96
- map.on('projectiontransition', this._onProjectionChange);
137
+ if (this.viewer.renderer) {
138
+ // 上下文恢复路径:onAdd 被再次触发(map.addLayer),原地换新 renderer,
139
+ // 保留已加载的场景与瓦片,不重建、不重拉。
140
+ this.viewer.restoreContext(gl);
141
+ }
142
+ else {
143
+ this.viewer.mount(map.getCanvas(), gl);
144
+ }
145
+ // 监听器只在首次挂载时绑定一次;上下文恢复重加图层时不重复绑定,
146
+ // 否则 click / projectiontransition 等会被挂多次。
147
+ if (!this._listenersAttached) {
148
+ map.on('click', this._onClick);
149
+ if (typeof map.on === 'function') {
150
+ map.on('projectiontransition', this._onProjectionChange);
151
+ map.on('webglcontextlost', this._onContextLost);
152
+ map.on('webglcontextrestored', this._onContextRestored);
153
+ }
154
+ this._listenersAttached = true;
97
155
  }
98
156
  }
99
157
  onRemove() {
100
158
  this.map?.off('click', this._onClick);
101
159
  if (typeof this.map?.off === 'function') {
102
160
  this.map.off('projectiontransition', this._onProjectionChange);
161
+ this.map.off('webglcontextlost', this._onContextLost);
162
+ this.map.off('webglcontextrestored', this._onContextRestored);
103
163
  }
164
+ this._listenersAttached = false;
165
+ this._contextLost = false;
104
166
  this.viewer.unmount();
105
167
  this.viewer.geo = null;
106
168
  this.map = null;
@@ -181,6 +243,10 @@ export class S3MLayer {
181
243
  const anchor = this.viewer.sceneAnchor;
182
244
  if (!map || !anchor)
183
245
  return;
246
+ // 上下文丢失期间(丢失→恢复之间)不要渲染:renderer 指向失效的 gl,
247
+ // 真正恢复由 _onContextRestored → restoreContext 接管。
248
+ if (this._contextLost)
249
+ return;
184
250
  const matrix = this._extractMatrix(arg);
185
251
  if (!matrix)
186
252
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"S3MLayer.js","sourceRoot":"","sources":["../src/S3MLayer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAuBtC,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,uBAAuB,GACxB,MAAM,WAAW,CAAC;AAEnB,OAAO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CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IACjC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;CACF;AAED,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,CAAC"}
@@ -582,4 +582,4 @@ var S3MMapLibre=(function(e,t){Object.defineProperties(e,{__esModule:{value:!0},
582
582
  }
583
583
  gl_FragColor = vec4(1.0);
584
584
  }
585
- `}),a=new t.Mesh(e,i);a.position.set(0,0,-.02),a.renderOrder=-1e3,a.name=`s3m-ground-depth`,a.visible=!1,this.group.add(a),this._depthMesh=a,this._depthMaterial=i,this._syncUniforms()}_applyMode(){this._mesh&&(this._mesh.visible=this.mode!==`none`),this._material&&(this._material.uniforms.uMode.value=this.mode===`excavate`?2:+(this.mode===`translucent`),this._material.depthWrite=this.mode===`excavate`),this._depthMesh&&(this._depthMesh.visible=this.occlude,this._depthMaterial&&(this._depthMaterial.uniforms.uPunchPit.value=+(this.mode===`excavate`)))}update(e){e&&this.group.position.set(e.position.x,e.position.y,this.groundHeight)}setGroundHeight(e){this.groundHeight=e,this.group.position.z=e}setMode(e){this.mode=e,this._occludeExplicit||(this.occlude=e===`excavate`),this._applyMode()}setOcclude(e){this.occlude=e,this._occludeExplicit=!0,this._applyMode()}setOpacity(e){this.opacity=Math.max(0,Math.min(1,e)),this._material&&(this._material.uniforms.uOpacity.value=this.opacity)}setColors(e,t){this.color.set(e),t&&this.gridColor.set(t),this._material&&(this._material.uniforms.uColor.value=this.color,this._material.uniforms.uGridColor.value=this.gridColor)}setExcavationBounds(e){this.excavationBounds=e,this._syncUniforms()}autoFitExcavation(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=!1;for(let o of e){let e=o.tileset?.config,s=e?.rootTiles??e?.tiles;if(Array.isArray(s))for(let e of s){let s=e.boundingBox;if(!s)continue;let c=s.center??{x:0,y:0},l=s.xExtent?.x?Math.abs(s.xExtent.x):50,u=s.yExtent?.y?Math.abs(s.yExtent.y):50,d=c.x+o.offset[0]-l,f=c.x+o.offset[0]+l,p=c.y+o.offset[1]-u,m=c.y+o.offset[1]+u;d<t&&(t=d),f>r&&(r=f),p<n&&(n=p),m>i&&(i=m),a=!0}}a&&Number.isFinite(t)&&this.setExcavationBounds([t-5,n-5,r+5,i+5])}_syncUniforms(){let e=this.excavationBounds;if(this._material){let t=this._material.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}if(this._depthMaterial){let t=this._depthMaterial.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}}dispose(){this._geom?.dispose(),this._geom=null,this._material?.dispose(),this._material=null,this._depthMaterial?.dispose(),this._depthMaterial=null,this._mesh=null,this._depthMesh=null,this.group.clear()}};Z(),Wr(),Ct();var Xi=65534;function Zi(e){let t=Array.isArray(e.material)?e.material[0]:e.material;return t?.userData?.isStyled?t:null}function Qi(e){return e.isPoints===!0}var $i=class{get datasets(){return this._datasetManager.datasets}get sceneAnchor(){return this._datasetManager.sceneAnchor}set sceneAnchor(e){this._datasetManager.sceneAnchor=e}_requestRepaint(){this._onRequestRepaint()}triggerRepaint(){this._requestRepaint()}constructor(e={}){h(this,`options`,void 0),h(this,`pickable`,void 0),h(this,`onStats`,void 0),h(this,`onReady`,void 0),h(this,`onPick`,void 0),h(this,`onError`,void 0),h(this,`geo`,null),h(this,`canvas`,null),h(this,`renderer`,null),h(this,`scene`,null),h(this,`camera`,null),h(this,`picker`,null),h(this,`uniforms`,void 0),h(this,`style`,void 0),h(this,`outlineMaterial`,void 0),h(this,`lineShared`,void 0),h(this,`edgeMaterial`,void 0),h(this,`selectionEdgeMaterial`,void 0),h(this,`groundManager`,void 0),h(this,`_datasetManager`,new Ui),h(this,`_featureStyleManager`,void 0),h(this,`_pickables`,new Map),h(this,`_pickSeq`,0),h(this,`_freePickIds`,[]),h(this,`_smidMeshes`,new Map),h(this,`_meshHeight`,new Map),h(this,`_heightMin`,1/0),h(this,`_heightMax`,-1/0),h(this,`_boxScratch`,new t.Box3),h(this,`_selection`,null),h(this,`_selectedMeshes`,[]),h(this,`_outlineMesh`,null),h(this,`_outlineMeshes`,[]),h(this,`_selectionEdges`,null),h(this,`_selectionEdgeMeshes`,[]),h(this,`_edgesEnabled`,!1),h(this,`attributeQuery`,null),h(this,`_enuMatrix`,new t.Matrix4),h(this,`_needsRepaint`,!0),h(this,`_frame`,0),h(this,`_fps`,{value:0,last:0}),h(this,`_ambientLight`,void 0),h(this,`_hemiLight`,void 0),h(this,`_keyLight`,void 0),h(this,`_fillLight`,void 0),h(this,`_lightOptions`,{ambientIntensity:.4,ambientColor:16777215,hemisphereIntensity:.8,hemisphereColor:16777215,hemisphereGroundColor:11976907,keyLightIntensity:1,keyLightColor:16777215,fillLightIntensity:.35,fillLightColor:16777215,mode:`headlamp`,azimuth:150,altitude:50}),h(this,`_datasetQueue`,void 0),h(this,`_onRequestRepaint`,()=>{}),h(this,`_getBearing`,void 0),h(this,`_lodRangeScale`,1),this.options=e,this.pickable=e.pickable!==!1,this._lodRangeScale=e.lodRangeScale??1,e.light&&Object.assign(this._lightOptions,e.light),e.totalMaxTiles&&(this._datasetManager.totalMaxTiles=e.totalMaxTiles),this._onRequestRepaint=e.onRequestRepaint??(()=>{}),this._getBearing=e.getBearing,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.groundManager=new Yi(e.ground),this.scene||(this.scene=new t.Scene,this.scene.add(this.groundManager.group),this._addLights()),this._featureStyleManager=new Ji(()=>this.style.floorHeight,()=>this._requestRepaint(),()=>{this._selection&&this._syncSelectionStyle()},()=>this.getAllMeshes(),e=>this._applyOverridesToMesh(e)),this.uniforms=Dr(),this.style={...Mr,...e.style??{}},this.outlineMaterial=kr(this.uniforms),this.lineShared=Fi(),this.edgeMaterial=Ri(this.lineShared,{color:this.style.edgeColor,opacity:this.style.edgeOpacity??.45,width:this.style.edgeWidth??1.2}),this.selectionEdgeMaterial=Ri(this.lineShared,{color:this.style.outlineColor??this.style.selectColor,opacity:1,width:this.style.outlineWidthPx??3}),this._fps.last=performance.now(),this._datasetQueue=this._normalizeDatasets(e),e.attributes&&(this.attributeQuery=new Ot(e.attributes))}mount(e,n){this.canvas=e,this.renderer=new t.WebGLRenderer({canvas:e,context:n,antialias:!0}),this.renderer.autoClear=!1,this.renderer.setPixelRatio(1),this.renderer.toneMapping=t.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1,vr(this.renderer.capabilities.getMaxAnisotropy()),this.scene=new t.Scene,this.scene.add(this.groundManager.group),this._addLights(),this.camera=new t.Camera,this.camera.matrixAutoUpdate=!1,this.picker=new Pi(this.renderer),this._applyStyleUniforms();for(let e of this._datasetQueue)this.addDataset(e).catch(e=>this.onError(e));this._recomputeAnchors()}unmount(){for(let e of[...this.datasets.keys()])this.removeDataset(e);this.groundManager.dispose(),this.picker?.dispose(),this.picker=null,this.outlineMaterial.dispose(),this.edgeMaterial.dispose(),this.selectionEdgeMaterial.dispose(),this.scene?.clear(),this._selectedMeshes=[],this._outlineMeshes=[],this._selectionEdgeMeshes=[],this._outlineMesh=null,this._selectionEdges=null,this._smidMeshes.clear(),this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0,this.renderer?.dispose(),this.renderer=null,this.canvas=null}_createLights(){this._ambientLight=new t.AmbientLight(this._lightOptions.ambientColor,this._lightOptions.ambientIntensity),this._hemiLight=new t.HemisphereLight(this._lightOptions.hemisphereColor,this._lightOptions.hemisphereGroundColor,this._lightOptions.hemisphereIntensity),this._keyLight=new t.DirectionalLight(this._lightOptions.keyLightColor,this._lightOptions.keyLightIntensity),this._fillLight=new t.DirectionalLight(this._lightOptions.fillLightColor,this._lightOptions.fillLightIntensity),this._updateLights()}_addLights(){this.scene&&(this._ambientLight||this._createLights(),this.scene.add(this._ambientLight,this._hemiLight,this._keyLight,this._fillLight))}_applyLightOptions(){this._ambientLight&&(this._ambientLight.intensity=this._lightOptions.ambientIntensity,this._ambientLight.color.set(this._lightOptions.ambientColor)),this._hemiLight&&(this._hemiLight.intensity=this._lightOptions.hemisphereIntensity,this._hemiLight.color.set(this._lightOptions.hemisphereColor),this._hemiLight.groundColor.set(this._lightOptions.hemisphereGroundColor)),this._keyLight&&(this._keyLight.intensity=this._lightOptions.keyLightIntensity,this._keyLight.color.set(this._lightOptions.keyLightColor)),this._fillLight&&(this._fillLight.intensity=this._lightOptions.fillLightIntensity,this._fillLight.color.set(this._lightOptions.fillLightColor))}setLight(e){Object.assign(this._lightOptions,e),this._applyLightOptions(),this._updateLights(),this._needsRepaint=!0,this.triggerRepaint()}getLight(){return{...this._lightOptions}}_updateLights(){if(!this._keyLight||!this._fillLight)return;let e=this._lightOptions.mode===`fixed`?0:(this._getBearing?.()??0)*Math.PI/180,t=(t,n,r)=>{if(!t)return;let i=e+n*Math.PI/180,a=r*Math.PI/180,o=Math.cos(a);t.position.set(Math.sin(i)*o,Math.cos(i)*o,Math.sin(a)).multiplyScalar(1e3)};t(this._keyLight,this._lightOptions.azimuth,this._lightOptions.altitude),t(this._fillLight,this._lightOptions.azimuth+65,Math.max(10,this._lightOptions.altitude-20))}_normalizeDatasets(e){return Array.isArray(e.datasets)?e.datasets.filter(e=>!!e?.configUrl):e.configUrl?[{id:`default`,name:`默认数据集`,configUrl:e.configUrl}]:[]}async addDataset(e){if(!this.scene)throw Error(`[s3m] 图层尚未 addLayer,不能添加数据集`);return await this._datasetManager.addDataset(e,this.scene,this.geo,this.uniforms,this._lodRangeScale,this.options.buildTile,this.options.maxTiles??64,this.options.maxConcurrent??4,{onTile:(e,t)=>{this._registerTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onTileRemoved:(e,t)=>{this._unregisterTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onStats:()=>{this.onStats(this.stats),this._requestRepaint()},onError:e=>{this.onError(e),this.onStats(this.stats)},onReady:e=>{this.onReady(e),this._refreshAllHeights(),this.groundManager.excavationBounds||this.groundManager.autoFitExcavation(this.datasets.values())},triggerRepaint:()=>{this._requestRepaint()}})}_lngLatFromWorld(e,t){return Nt(this.geo,e,t)}recomputeAnchors(){this._datasetManager.recomputeAnchors(this.geo),this._refreshAllHeights(),this._requestRepaint()}_recomputeAnchors(){this.recomputeAnchors()}getDatasetHeight(e){return this._datasetManager.getDatasetHeight(e)}setDatasetHeight(e,t){let n,r;typeof e==`number`?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??0),this._datasetManager.setDatasetHeight(n,r,this.geo),this._syncGroundHeight(),this._refreshAllHeights(),this._requestRepaint()}_syncGroundHeight(){if(!this.groundManager.trackHeight)return;let e=this.datasets.keys().next().value;if(!e)return;let t=this._datasetManager.getDatasetHeight(e);this.groundManager.setGroundHeight(t)}setDatasetAlign(e,t){let n,r;t===void 0&&(e===`origin`||e===`bottom`||e===`top`||e===`center`)?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??`origin`),this._datasetManager.setDatasetAlign(n,r,this.geo),this._refreshAllHeights(),this._requestRepaint()}_computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}setFeatureStyle(e,t){this._featureStyleManager.setFeatureStyle(e,t,this._meshesOf([e]))}setFeaturesStyle(e,t){this._featureStyleManager.setFeaturesStyle(e,t,this._meshesOf(e))}getFeatureStyle(e){return this._featureStyleManager.getFeatureStyle(e)}getFeatureStyles(){return this._featureStyleManager.getFeatureStyles()}removeFeatureStyle(e){this._featureStyleManager.removeFeatureStyle(e,this._meshesOf([e]))}clearFeatureStyles(){this._featureStyleManager.clearFeatureStyles()}setAttributeSource(e){this.attributeQuery=e?new Ot(e):null}getLoadedSmids(){return[...this._smidMeshes.keys()]}auditBatches(){let e=this._featureStyleManager.auditBatches(this._pickables.values());return e.smids=this._smidMeshes.size,e}getThematicField(){return this._featureStyleManager.thematicField}setThematicColors(e,t=`custom`){this._featureStyleManager.setThematicColors(e,t)}clearThematic(){this._featureStyleManager.clearThematicColors()}getFilterField(){return this._featureStyleManager.fieldFilter?.field??null}filterByField(e){return this._featureStyleManager.filterByField(e,this.attributeQuery,this.getLoadedSmids())}clearFieldFilter(){this._featureStyleManager.clearFieldFilter()}getElevationField(){return this._featureStyleManager.elevationField}elevateByField(e){return this._featureStyleManager.elevateByField(e,this.attributeQuery,this.getLoadedSmids())}setThematicElevation(e,t=`custom`){this._featureStyleManager.setThematicElevation(e,t)}clearThematicElevation(){this._featureStyleManager.clearThematicElevation()}colorByField(e){return this._featureStyleManager.colorByField(e,this.attributeQuery,this.getLoadedSmids())}setFilter(e){this._featureStyleManager.setFilter(e,this.uniforms)}getFilter(){return this._featureStyleManager.filter}clearFilter(){this._featureStyleManager.clearFilter(this.uniforms)}setGroundMode(e){this.groundManager.setMode(e),this._requestRepaint()}setGroundOpacity(e){this.groundManager.setOpacity(e),this._requestRepaint()}setExcavationBounds(e){this.groundManager.setExcavationBounds(e),this._requestRepaint()}setGroundOcclude(e){this.groundManager.setOcclude(e),this._requestRepaint()}_isFeatureHidden(e,t){if(e==null)return!1;let n=this._featureStyleManager.fieldFilter;if(n){let t=n.matched.has(e);if(n.mode===`keep`?!t:t)return!0}let r=this._featureStyleManager.filter;return!!(r&&(r.include&&r.include.length>0&&!r.include.includes(e)||r.exclude&&r.exclude.length>0&&r.exclude.includes(e))||this._featureStyleManager.featureStyles.get(e)?.hidden)}getAllMeshes(){let e=[];for(let t of this._pickables.values())e.push(t.mesh);return e}_meshesOf(e){let t=new Set;for(let n of e){let e=this._smidMeshes.get(n);if(e)for(let n of e)t.add(n)}return t}_markOverridesDirty(e=`all`){e===`all`?this._featureStyleManager.markOverridesDirty(void 0,this.getAllMeshes()):this._featureStyleManager.markOverridesDirty(e)}flushOverrides(){this._featureStyleManager.flushOverrides()}_applyOverridesToMesh(e){this._featureStyleManager.applyOverridesToMesh(e)}removeDataset(e){if(this.datasets.get(e)){this._selection?.datasetId===e&&this.select(null),this._datasetManager.removeDataset(e,this.scene,this.geo,e=>{e.root.traverse(e=>{let t=e,n=t.userData;n.pickId!=null&&(this._pickables.delete(n.pickId),this._releasePickId(n.pickId),n.pickId=void 0),this._unindexMeshSmids(t),this._removeMeshHeight(t),t.geometry?.dispose?.();let r=Zi(t);r&&r.dispose(),Oi(t.material)&&t.material.dispose(),this._featureStyleManager.disposeMesh(t)})});for(let[t,n]of this._pickables)n.datasetId===e&&this._pickables.delete(t);this.onStats(this.stats),this._requestRepaint()}}clearDatasets(){for(let e of[...this.datasets.keys()])this.removeDataset(e)}setDatasetVisible(e,t){this._datasetManager.setDatasetVisible(e,t),!t&&this._selection?.datasetId===e&&this.select(null),this._requestRepaint()}_registerTile(e,t){t.root.add(e.group),e.group.updateMatrixWorld(!0);let n=e.group.userData.hasNativeEdges===!0;for(let r of e.group.children){if(r.isLineSegments&&r.userData.isEdgeLines){r.visible=this._edgesEnabled,this._styleEdgeLine(r);continue}let i=Qi(r),a=r;if(!a.isMesh&&!i)continue;let o=a.userData;if(o.pickId=this._allocPickId(),o.datasetId=t.id,o.nativeEdges=n,this._pickables.set(o.pickId,{datasetId:t.id,mesh:a,tile:e.tile,skeletonName:o.skeletonName??``}),this._indexMeshSmids(a),this._addMeshHeight(a),this._edgesEnabled&&!n&&!i&&this._ensureEdges(a),i)this._applyPointCloudStyle(r);else{let e=Zi(a);if(e){let t=Math.min(1,Math.max(.05,this.style.opacity??1));e.opacity=t,e.transparent=t<.999,e.depthWrite=t>=.999,e.flatShading=this.style.shading!==`smooth`,e.needsUpdate=!0,this._featureStyleManager.applyOverridesToMesh(a)}}this._replaySelectionOnto(a)}}_isMeshCoveringSelection(e,n){if(!n.point)return!1;let r=e.geometry;if(!r||(r.boundingBox||r.computeBoundingBox(),!r.boundingBox))return!1;let i=new t.Vector3(n.point[0],n.point[1],n.point[2]);e.updateWorldMatrix(!0,!1);let a=e.matrixWorld.clone().invert(),o=i.applyMatrix4(a);return r.boundingBox.clone().expandByScalar(.5).containsPoint(o)}_replaySelectionOnto(e){let t=this._selection;if(!t)return;let n=Zi(e);if(!n)return;let r=e.userData,i=-1;if(t.smid!=null){let e=r.geoRef?.pickInfo,n=e?.[t.smid]??e?.[String(t.smid)];i=n?B(n):-1}if(e===t.mesh&&(i=t.batchId),i<0&&e!==t.mesh){if(t.smid==null&&r.datasetId===t.datasetId&&this._isMeshCoveringSelection(e,t))i=-1;else return}n.userData.uSelBatch.value=i,n.userData.uSelWhole.value=+(i<0),this._selectedMeshes.includes(e)||this._selectedMeshes.push(e),Qi(e)&&this._applyPointCloudStyle(e,!0),this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers}_unregisterTile(e,t){e.group.traverse(e=>{let t=e;if(t.userData?.pickId!=null&&(this._pickables.delete(t.userData.pickId),this._releasePickId(t.userData.pickId),t.userData.pickId=void 0),t.isMesh){this._selectedMeshes.includes(t)&&(this._selectedMeshes=this._selectedMeshes.filter(e=>e!==t));let e=this._selection;if(e&&e.mesh===t){let n=e.smid,r=n==null?this._selectedMeshes.find(e=>e!==t&&e.parent&&e.parent.visible)??this._selectedMeshes.find(e=>e!==t&&e.parent):[...this._smidMeshes.get(n)??[]].find(e=>e!==t&&e.parent);r?(this._selection={...e,mesh:r},this._replaySelectionOnto(r)):this.select(null)}this._unindexMeshSmids(t),this._removeMeshHeight(t),this._featureStyleManager.disposeMesh(t),Zi(t)?.dispose?.()}Oi(t.material)?t.material.dispose():t.material&&(Array.isArray(t.material)?t.material.forEach(e=>e?.dispose?.()):t.material.dispose?.()),t.geometry?.dispose?.()}),t.root.remove(e.group)}_allocPickId(){let e=this._freePickIds.pop();if(e!==void 0)return e;if(this._pickSeq>Xi){for(let e=0;e<=Xi;e++)if(!this._pickables.has(e))return e;throw Error(`[s3m] 可拾取网格超过 65535 个,2 字节 ID 编码不够用`)}return this._pickSeq++}_releasePickId(e){this._freePickIds.push(e)}setOpacity(e){this.setStyle({opacity:e})}setStyle(e={}){this.style={...this.style,...e},this._applyStyleUniforms(),(`opacity`in e||`depthWrite`in e)&&this._applyOpacity(),`mode`in e&&this._applyPointCloudStyles(),`shading`in e&&this._applyShading(),`edges`in e?this.setEdges(!!this.style.edges):(`edgeColor`in e||`edgeWidth`in e||`opacity`in e||`edgeOpacity`in e)&&this._refreshEdgeLines(),this._selection&&(`outline`in e||`outlineStyle`in e?this.select(this._selection,{silent:!0}):this._syncSelectionStyle()),this._requestRepaint()}getStyle(){return{...this.style,modeLabel:Ar[this.style.mode]}}_applyStyleUniforms(){let e=this.uniforms,t=this.style;e.uMode.value=t.mode,e.uColorA.value.set(t.colorA),e.uColorB.value.set(t.colorB),e.uColorC.value.set(t.colorC),e.uSelColor.value.set(t.selectColor),e.uFloorHeight.value=t.floorHeight;let n=t.selectMode??$.OVERLAY;e.uSelMode&&(e.uSelMode.value=n===$.REPLACE?0:n===$.MULTIPLY?2:n===$.GLOW_ONLY?3:1),e.uSelOpacity&&t.selectOpacity!=null&&(e.uSelOpacity.value=t.selectOpacity),e.uSelEmissive&&t.selectEmissive!=null&&(e.uSelEmissive.value=t.selectEmissive),e.uSelElevation&&t.selectElevation!=null&&(e.uSelElevation.value=t.selectElevation),e.uDimFactor&&t.dimFactor!=null&&(e.uDimFactor.value=t.dimFactor),e.uRoofThreshold&&t.roofThreshold!=null&&(e.uRoofThreshold.value=t.roofThreshold),e.uTexMix&&t.texMix!=null&&(e.uTexMix.value=t.texMix),this.outlineMaterial&&(this.outlineMaterial.uniforms.uElevation&&t.selectElevation!=null&&(this.outlineMaterial.uniforms.uElevation.value=t.selectElevation),t.outlineWidth!=null&&(this.outlineMaterial.uniforms.uWidth.value=t.outlineWidth),t.outlineColor==null?this.outlineMaterial.uniforms.uColor.value.set(t.selectColor):this.outlineMaterial.uniforms.uColor.value.set(t.outlineColor))}_applyOpacity(){let e=Math.min(1,Math.max(.05,this.style.opacity??1)),t=e<.999,n=this.style.depthWrite!==!1;for(let r of this._pickables.values()){if(Qi(r.mesh)){this._applyPointCloudStyle(r.mesh);continue}let i=Zi(r.mesh);i&&(i.opacity=e,i.transparent=t,i.depthWrite=!t||n)}this._requestRepaint()}_applyPointCloudStyle(e,t=this._selectedMeshes.includes(e)){Di(e,this.style,this.uniforms,t)}_applyPointCloudStyles(){for(let e of this._pickables.values())Qi(e.mesh)&&this._applyPointCloudStyle(e.mesh);this._requestRepaint()}_applyShading(){let e=this.style.shading!==`smooth`;for(let t of this._pickables.values()){let n=Zi(t.mesh);n&&n.flatShading!==e&&(n.flatShading=e,n.needsUpdate=!0)}this._requestRepaint()}_addMeshHeight(e){let t=e.geometry?.boundingBox;if(!t)return;this._boxScratch.copy(t).applyMatrix4(e.matrixWorld);let n=this._boxScratch.min.z,r=this._boxScratch.max.z;Number.isFinite(n)&&Number.isFinite(r)&&(this._meshHeight.set(e,{min:n,max:r}),n<this._heightMin&&(this._heightMin=n),r>this._heightMax&&(this._heightMax=r),this._pushHeightRange())}_removeMeshHeight(e){let t=this._meshHeight.get(e);t&&(this._meshHeight.delete(e),t.min===this._heightMin||t.max===this._heightMax?this._recomputeHeightRange():this._pushHeightRange())}_refreshAllHeights(){if(this._meshHeight.size===0)return;let e=[...this._meshHeight.keys()];this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0;for(let t of e)this._addMeshHeight(t);this._pushHeightRange()}_recomputeHeightRange(){let e=1/0,t=-1/0;for(let n of this._meshHeight.values())n.min<e&&(e=n.min),n.max>t&&(t=n.max);this._heightMin=e,this._heightMax=t,this._pushHeightRange()}_pushHeightRange(){let e=this._heightMin,t=this._heightMax;(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)&&(e=0,t=100),this.uniforms.uHeightMin.value=e,this.uniforms.uHeightMax.value=t}_indexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n);if(!Number.isFinite(t)||t<0)continue;let r=this._smidMeshes.get(t);r||this._smidMeshes.set(t,r=new Set),r.add(e)}}_unindexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n),r=this._smidMeshes.get(t);r&&(r.delete(e),r.size===0&&this._smidMeshes.delete(t))}}setEdges(e){this._edgesEnabled=e,this.style.edges=e;for(let t of this.datasets.values())t.root.traverse(t=>{t.userData.isEdgeLines&&(t.visible=e,this._styleEdgeLine(t))});if(this._syncEdgeStyle(),!e){for(let e of this._pickables.values())this._removeEdges(e.mesh);this._requestRepaint();return}let t=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e.userData;return!t.edges&&!t.nativeEdges&&!Qi(e)}),n=0,r=()=>{let e=performance.now();for(;n<t.length&&performance.now()-e<8;)this._ensureEdges(t[n++]);n<t.length?setTimeout(r,0):this._requestRepaint()};r()}_syncEdgeStyle(){let e=this.style,t=this.edgeMaterial.uniforms;t.uColor.value.set(e.edgeColor),t.uWidth.value=Math.max(.1,e.edgeWidth??1.2),t.uOpacity.value=Math.min(1,Math.max(0,e.edgeOpacity??.45))*Math.min(1,Math.max(.05,e.opacity??1))}_styleEdgeLine(e){let t=e.material;t&&t.color&&(t.color.set(this.style.edgeColor),t.opacity=(this.style.edgeOpacity??.45)*Math.min(1,Math.max(.05,this.style.opacity??1)),t.transparent=!0,t.polygonOffset=!0,t.polygonOffsetFactor=-1,t.polygonOffsetUnits=-1,t.needsUpdate=!0)}_refreshEdgeLines(){this._syncEdgeStyle();for(let e of this.datasets.values())e.root.traverse(e=>{e.userData.isEdgeLines&&this._styleEdgeLine(e)})}_ensureEdges(e){let n=e.userData;if(n.edges||n.nativeEdges||!e.geometry||(e.geometry.index?.count??0)>12e4)return;let r=new t.EdgesGeometry(e.geometry,40),i=r.getAttribute(`position`),a=i?i.array:null;if(r.dispose(),!a||a.length<6)return;let o=new t.Mesh(zi(a),this.edgeMaterial);o.renderOrder=2,o.frustumCulled=!1,o.raycast=()=>{},o.userData.isThickEdge=!0,n.edges=o,e.add(o)}_removeEdges(e){let t=e.userData,n=t.edges;n&&(e.remove(n),n.geometry?.dispose(),t.edges=null)}getRayAt(e,n){if(!this.camera||!this.canvas)return null;let r=this.canvas,i=r.clientWidth||r.width,a=r.clientHeight||r.height;if(!i||!a)return null;let o=e/i*2-1,s=-(n/a)*2+1,c=new t.Vector3(o,s,-1).unproject(this.camera),l=new t.Vector3(o,s,1).unproject(this.camera).clone().sub(c).normalize();return new t.Ray(c,l)}_intersectMeshAtRay(e,n,r){let i=new t.Raycaster;i.ray.copy(n);let a=i.intersectObject(e,!1);if(!a.length)return null;if(r!=null){let e=a.find(e=>e.instanceId===r);return e?e.point:a[0].point}return a[0].point}_buildPickResult(e,n,r,i){let a=n.mesh.userData,o=null,s=e.batchId,c=e.instanceIndex,l=a.geoRef,u=[];if(c!=null){let e=this._instanceFeature(n.mesh,l,c);if(!e)return null;o=e.smid,s=e.batchId}else{l=a.geoByBatchId?.get(e.batchId)??a.geoRef;let t=V(l,e.batchId);o=t.smid,u=t.segments}if(this._isFeatureHidden(o,s))return null;let d=null,f=0;if(c!=null)d=this._instanceBox(n.mesh,c),f=n.mesh.geometry.index?Math.round(n.mesh.geometry.index.count/3):0;else if(o!=null&&this._smidMeshes.has(o)){let e=this._smidMeshes.get(o),t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,s=-1/0,c=0;for(let l of e){let e=l.userData,u=e.geoRef?.pickInfo,d=u?.[o]??u?.[String(o)],p=d?B(d):-1,m=d?.segments??(p>=0?V(e.geoRef,p).segments:[]),h=bt(l.geometry,m);h&&(h.minX<t&&(t=h.minX),h.minY<n&&(n=h.minY),h.minZ<r&&(r=h.minZ),h.maxX>i&&(i=h.maxX),h.maxY>a&&(a=h.maxY),h.maxZ>s&&(s=h.maxZ),c+=h.count,f+=h.triangles)}c>0&&(d={minX:t,minY:n,minZ:r,maxX:i,maxY:a,maxZ:s,count:c,triangles:f})}if(!d&&(d=bt(n.mesh.geometry,u),!d&&n.mesh.geometry)){n.mesh.geometry.boundingBox||n.mesh.geometry.computeBoundingBox();let e=n.mesh.geometry.boundingBox;e&&(d={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}let p=n.mesh.geometry,m=f>0?f:p.index?Math.round(p.index.count/3):0,h=xt({smid:o,box:d,triangles:m,floorHeight:this.style.floorHeight}),g=null;if(d&&this.sceneAnchor){let e=new t.Vector3((d.minX+d.maxX)/2,(d.minY+d.maxY)/2,(d.minZ+d.maxZ)/2);e.applyMatrix4(n.mesh.matrixWorld);let r=this.sceneAnchor.meterInMercator;g=this._lngLatFromWorld(e.x*r+this.sceneAnchor.x,-e.y*r+this.sceneAnchor.y)}let _=r??null;!_&&i&&(_=this._intersectMeshAtRay(n.mesh,i,c));let v=null,y=null,b=null;if(_&&this.sceneAnchor){let e=o==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(o),n=e.translation,r=e.elevation,i=_.clone();n?i.add(new t.Vector3(n[0],n[1],n[2])):r&&(i.z+=r),v=[i.x,i.y,i.z];let a=this.sceneAnchor.meterInMercator;y=this._lngLatFromWorld(i.x*a+this.sceneAnchor.x,-i.y*a+this.sceneAnchor.y),b=i.z+(this.sceneAnchor.altitude??0)}else g&&d&&this.sceneAnchor&&(y=g,b=(d.minZ+d.maxZ)/2+(this.sceneAnchor.altitude??0));return{datasetId:n.datasetId,datasetName:this.datasets.get(n.datasetId)?.name??n.datasetId,objectId:e.objectId,batchId:s,instanceIndex:c,skeletonName:n.skeletonName,centerLngLat:g,point:v,lngLat:y,altitude:b,...h,mesh:n.mesh}}pick(e,t){if(!this.picker||!this.scene||!this.camera||!this.sceneAnchor)return null;let n=this.picker.pick(this.scene,this.camera,e,t);if(!n)return null;let r=this._pickables.get(n.objectId);if(!r)return null;let i=this.getRayAt(e,t);return this._buildPickResult(n,r,void 0,i??void 0)}pickPosition(e,n){if(!this.camera||!this.sceneAnchor)return null;let r=this.pick(e,n);if(r?.point&&r?.lngLat&&r.altitude!=null)return{lngLat:r.lngLat,altitude:r.altitude,point:r.point};let i=this.getRayAt(e,n);if(!i)return null;let a=new t.Plane(new t.Vector3(0,0,1),0),o=new t.Vector3,s=i.intersectPlane(a,o);if(s){let e=this.sceneAnchor.meterInMercator;return{lngLat:this._lngLatFromWorld(s.x*e+this.sceneAnchor.x,-s.y*e+this.sceneAnchor.y),altitude:s.z+(this.sceneAnchor.altitude??0),point:[s.x,s.y,s.z]}}return null}drillPick(e,n,r=10){if(!this.sceneAnchor||!this.camera)return[];let i=this.getRayAt(e,n);if(!i)return[];let a=new t.Raycaster;a.ray.copy(i);let o=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}),s=a.intersectObjects(o,!1);if(!s.length)return[];let c=[],l=new Set,u=new Set;for(let e of s){if(c.length>=r)break;let t=e.object,n=t.userData;if(n.pickId==null)continue;let i=this._pickables.get(n.pickId);if(!i)continue;let a=null,o=-1,s=e.instanceId;if(s!=null){let e=this._instanceFeature(t,n.geoRef,s);if(!e)continue;a=e.smid,o=e.batchId}else if(e.faceIndex!=null){let r=t.geometry.attributes.aBatchId;if(r){let i=t.geometry.index?t.geometry.index.getX(e.faceIndex*3):e.faceIndex*3;o=Math.round(r.getX(i)),a=V(n.geoByBatchId?.get(o)??n.geoRef,o).smid}}if(a!=null){if(l.has(a))continue;l.add(a)}else{let e=`${n.pickId}:${o}:${s??-1}`;if(u.has(e))continue;u.add(e)}if(this._isFeatureHidden(a,o))continue;let d={objectId:n.pickId,batchId:o,instanceIndex:s},f=this._buildPickResult(d,i,e.point);f&&c.push(f)}return c}getFeatureBounds(e){if(!this.sceneAnchor)return null;let n=1/0,r=-1/0,i=1/0,a=-1/0,o=!1;for(let s of this._pickables.values()){let c=s.mesh,l=c.userData,u=l.geoRef,d=u?.pickInfo;if(!d)continue;let f=null;if(c.isInstancedMesh){let t=l.instanceLookup;t||(t=yt(d),l.instanceLookup=t);for(let[n,r]of t)if(r.smid===e){f=this._instanceBox(c,n);break}}else{let t=d,n=t[e]??t[String(e)];if(n){let e=V(u,B(n));if(f=bt(c.geometry,e.segments),!f&&c.geometry){c.geometry.boundingBox||c.geometry.computeBoundingBox();let e=c.geometry.boundingBox;e&&(f={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}}}if(f){o=!0;let s=[new t.Vector3(f.minX,f.minY,f.minZ),new t.Vector3(f.maxX,f.minY,f.minZ),new t.Vector3(f.minX,f.maxY,f.minZ),new t.Vector3(f.maxX,f.maxY,f.minZ),new t.Vector3(f.minX,f.minY,f.maxZ),new t.Vector3(f.maxX,f.minY,f.maxZ),new t.Vector3(f.minX,f.maxY,f.maxZ),new t.Vector3(f.maxX,f.maxY,f.maxZ)],l=e==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(e),u=l.translation,d=l.elevation;for(let e of s){u?e.add(new t.Vector3(u[0],u[1],u[2])):d&&(e.z+=d),e.applyMatrix4(c.matrixWorld);let o=this.sceneAnchor.meterInMercator,[s,l]=this._lngLatFromWorld(e.x*o+this.sceneAnchor.x,-e.y*o+this.sceneAnchor.y);s<n&&(n=s),s>r&&(r=s),l<i&&(i=l),l>a&&(a=l)}}}return o?[[n,i],[r,a]]:null}_instanceFeature(e,t,n){let r=e.userData;return r.instanceLookup||(r.instanceLookup=yt(t?.pickInfo)),r.instanceLookup.get(n)??null}_instanceBox(e,n){let r=e;if(!r.isInstancedMesh)return null;let i=e.geometry;i.boundingBox||i.computeBoundingBox();let a=i.boundingBox;if(!a)return null;let o=new t.Matrix4;r.getMatrixAt(n,o);let s=a.clone().applyMatrix4(o);return{minX:s.min.x,minY:s.min.y,minZ:s.min.z,maxX:s.max.x,maxY:s.max.y,maxZ:s.max.z,count:i.getAttribute(`position`)?.count??0,triangles:i.index?Math.round(i.index.count/3):0}}select(e,{silent:t=!1}={}){if(this._selection){for(let e of this._selectedMeshes){if(Qi(e)){this._applyPointCloudStyle(e,!1);continue}let t=Zi(e);t&&(t.userData.uSelBatch.value=-1,t.userData.uSelWhole.value=0)}this._selectedMeshes=[],this._clearSelectionDecoration(),this._selection=null}if(!e){this.uniforms.uSelMix.value=0,this.uniforms.uDim.value=0,this.outlineMaterial.uniforms.uSelBatch.value=-1,this.outlineMaterial.uniforms.uSelWhole.value=0,this.outlineMaterial.uniforms.uElevation.value=0,this._requestRepaint(),t||this.onPick(null);return}this._selection=e;let n=new Set;if(e.smid!=null){let t=this._smidMeshes.get(e.smid);if(t)for(let e of t)n.add(e)}n.add(e.mesh);for(let t of n){let n=Zi(t);if(!n)continue;let r=e.batchId;if(e.instanceIndex!=null&&t===e.mesh)r=e.batchId;else if(e.smid!=null){let n=t.userData.geoRef?.pickInfo,i=n?.[e.smid]??n?.[String(e.smid)],a=i?B(i):-1;r=a>=0?a:t===e.mesh?e.batchId:-1}n.userData.uSelBatch.value=r,n.userData.uSelWhole.value=+(r<0),this._selectedMeshes.push(t)}for(let e of this._selectedMeshes)Qi(e)&&this._applyPointCloudStyle(e,!0);if(this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers,this.style.outline){let t=[...n].filter(e=>!Qi(e));t.length&&((this.style.outlineStyle??`edges`)===`edges`?this._addSelectionEdges(e,t):this._addSelectionHull(e,t))}this._requestRepaint()}_addSelectionEdges(e,n){this._syncSelectionStyle();for(let r of n){let n=r.userData,i=n.geoRef,a=[];if(r===e.mesh&&e.instanceIndex!=null)a=[{vertexOffset:0,vertexCount:r.geometry.getAttribute(`position`)?.count??0}];else if(e.smid!=null){let t=i?.pickInfo,n=t?.[e.smid]??t?.[String(e.smid)],r=n?B(n):-1;a=n?.segments??(r>=0?V(i,r).segments:[])}else r===e.mesh&&(a=V(n.geoByBatchId?.get(e.batchId)??i,e.batchId).segments);let o=Hi(r.geometry,a);if(o&&o.length>0){let n=new t.Mesh(zi(o),this.selectionEdgeMaterial);n.renderOrder=4,n.frustumCulled=!1,n.raycast=()=>{},n.userData.isSelectionEdge=!0,r===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(n,e),r.add(n),this._selectionEdgeMeshes.push(n)}}this._selectionEdgeMeshes.length===0?this._addSelectionHull(e,n):this._selectionEdges=this._selectionEdgeMeshes[0]??null}_applyInstanceTransform(e,n){let r=n.mesh;if(n.instanceIndex==null||!r.isInstancedMesh)return;let i=new t.Matrix4;r.getMatrixAt(n.instanceIndex,i),i.decompose(e.position,e.quaternion,e.scale)}_addSelectionHull(e,n){let r=e.instanceIndex!=null;this.outlineMaterial.uniforms.uSelBatch.value=r?-1:e.batchId,this.outlineMaterial.uniforms.uSelWhole.value=r||e.batchId<0?1:0,this.outlineMaterial.uniforms.uElevation.value=r?this._selectionElevation(e):this.style.selectElevation??0;for(let r of n){let n=Zi(r);n?.userData?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=n.userData.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=n.userData.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=n.userData.uBatchTexActive.value);let i=new t.Mesh(r.geometry,this.outlineMaterial);i.renderOrder=3,i.frustumCulled=!1,i.raycast=()=>{},r===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(i,e),r.add(i),this._outlineMeshes.push(i)}this._outlineMesh=this._outlineMeshes[0]??null}_syncSelectionStyle(){let e=this.style,t=this.selectionEdgeMaterial.uniforms;t.uColor.value.set(e.outlineColor??e.selectColor),t.uWidth.value=Math.max(.1,e.outlineWidthPx??3),t.uOpacity.value=Math.min(1,Math.max(.05,e.opacity??1)),t.uElevation.value=this._selection?this._selectionElevation(this._selection):0;for(let e of this._outlineMeshes){let t=e.parent,n=t?Zi(t)?.userData:null;n?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=n.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=n.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=n.uBatchTexActive.value)}}_selectionElevation(e){let t=this.style.selectElevation??0;if(e.smid!=null){let n=this._featureStyleManager.getFeatureEffectiveOffset(e.smid);n.elevation&&(t+=n.elevation)}return t}_clearSelectionDecoration(){for(let e of this._outlineMeshes)e.parent?.remove(e);this._outlineMeshes=[],this._outlineMesh=null;for(let e of this._selectionEdgeMeshes)e.parent?.remove(e),e.geometry.dispose();this._selectionEdgeMeshes=[],this._selectionEdges=null}_updateLineResolution(e){let t=e.width||1,n=e.height||1,r=e.clientWidth||t;this.lineShared.uResolution.value.set(t,n),this.lineShared.uDpr.value=Math.max(1,t/r)}get lodRangeScale(){return this._lodRangeScale}setLodRangeScale(e,t){if(!(e<=0)){if(t){let n=this.datasets.get(t);n?.tileset&&(n.tileset.lodRangeScale=e)}else{this._lodRangeScale=e;for(let t of this.datasets.values())t.tileset&&(t.tileset.lodRangeScale=e)}this._requestRepaint()}}renderFrame(e){if(!this.renderer||!this.scene||!this.camera||!this.sceneAnchor||!this.canvas)return!1;this.flushOverrides();let n=this.canvas,r=this.sceneAnchor.meterInMercator;this._enuMatrix.set(r,0,0,this.sceneAnchor.x,0,-r,0,this.sceneAnchor.y,0,0,r,this.sceneAnchor.z,0,0,0,1);let i=new t.Matrix4().fromArray(e.mvp);i.multiply(this._enuMatrix),this.camera.projectionMatrix.copy(i),this.camera.projectionMatrixInverse.copy(i).invert();let a=e.cameraEnu;this.camera.position.set(a[0],a[1],a[2]),this.camera.matrixWorld.setPosition(a[0],a[1],a[2]),this.camera.matrixWorldInverse.copy(this.camera.matrixWorld).invert(),this.groundManager.update(this.camera);let o=!1;for(let t of this.datasets.values()){if(!t.visible||!t.tileset)continue;let n=[a[0]-t.offset[0],a[1]-t.offset[1],a[2]-t.offset[2]];t.tileset.update(n,e.fovRad,e.canvasHeight)&&(o=!0)}this.style.mode===Q.DYNAMIC&&(this.uniforms.uTime.value+=.016*(this.style.speed??1)),this._updateLights(),this._updateLineResolution(n),this.renderer.setViewport(0,0,n.width,n.height),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this._frame++;let s=performance.now();return s-this._fps.last>500&&(this._fps.value=Math.round(this._frame*1e3/(s-this._fps.last)),this._frame=0,this._fps.last=s),this.style.mode===Q.DYNAMIC||this.stats.loading>0||o}get fps(){return this._fps.value}get stats(){let e={tiles:0,loading:0,failed:0,meshes:0,vertices:0,triangles:0,datasets:this.datasets.size};for(let t of this.datasets.values()){let n=t.tileset?.stats;n&&(e.tiles+=n.tiles,e.loading+=n.loading,e.failed+=n.failed,e.meshes+=n.meshes,e.vertices+=n.vertices,e.triangles+=n.triangles)}return e}getBounds(){let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of this.datasets.values()){let a=_i(i.tileset?.config?.geoBounds);a&&(e=Math.min(e,a.left),n=Math.max(n,a.right),t=Math.min(t,a.bottom),r=Math.max(r,a.top))}return isFinite(e)?[[e,t],[n,r]]:null}dispose(){this.unmount()}},ea=1e-4;function ta(e,t){let n=e.elements;for(let e=0;e<16;e++){let r=Math.max(1,Math.abs(n[e]),Math.abs(t[e]));if(Math.abs(n[e]-t[e])>ea*r)return!1}return!0}function na(e){let t=e.elements,n=1;for(let e=0;e<16;e++){let r=Math.abs(t[e]);r>n&&(n=r)}let r=1e-6*n;return Math.abs(t[3])<r&&Math.abs(t[7])<r&&Math.abs(t[11])<r&&Math.abs(t[15]-1)<r}function ra(e,t){return t>0&&Math.abs(e.elements[5]*Math.tan(t/2)-1)<.001}function ia(e){if(!e||typeof e!=`object`)return null;let t=e;return t.defaultProjectionData?.projectionMatrix??t.projectionMatrix??null}function aa(e){let t={nearZ:null,farZ:null};if(!e||typeof e!=`object`)return t;let n=e,r=n.defaultProjectionData,i=e=>{let t=n[e];if(typeof t==`number`&&Number.isFinite(t))return t;let i=r?.[e];return typeof i==`number`&&Number.isFinite(i)?i:null};return{nearZ:i(`nearZ`),farZ:i(`farZ`)}}function oa(e,t){if(e&&typeof e==`object`){let t=e.fov;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return t}return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function sa(e,n){let r=e.projectionMatrix;if(!r||r.length<16)return null;let i=new t.Matrix4().fromArray(Array.from(r)),a=new t.Matrix4().fromArray(Array.from(e.mvp));if(i.determinant()===0||!ra(i,n.fov))return null;let o=i.clone().invert().multiply(a);if(!ta(i.clone().multiply(o),Array.from(e.mvp))||!na(o)||!ra(i,n.fov))return null;let{distance:s,fov:c,aspect:l}=n;if(!(s>0)||!(c>0)||!(l>0))return null;let u=s*Math.tan(c/2),d=u*l,f=e.nearZ!=null&&e.nearZ>0?e.nearZ:1,p=e.farZ!=null&&e.farZ>f?e.farZ:s*4+1e3;p>f||(p=f+1e3);let m=new t.OrthographicCamera(-d,d,u,-u,f,p);return m.updateProjectionMatrix(),{matrix:m.projectionMatrix.clone().multiply(o),view:o}}var ca=.6435011087932844;function la(e){let t=e,n=t?.transform?.worldCoordinateHelper??t?.transform?.projection?.worldCoordinateHelper??t?.painter?.transform?.worldCoordinateHelper??(typeof t?.getProjection==`function`?t.getProjection()?.worldCoordinateHelper:null)??null;return n&&typeof n.worldFromLngLat==`function`&&typeof n.lngLatFromWorld==`function`?n:null}function ua(e){let t=la(e);return t?{worldFromLngLat(e,n,r=0){let i=t.worldFromLngLat(e,n,r),a=0;if(typeof t.metersPerWorldUnit==`function`){let e=t.metersPerWorldUnit(i.x,i.y);Number.isFinite(e)&&e>0&&(a=1/e)}if(a===0){let o=t.worldFromLngLat(e,n,r+1),s=Math.abs((o.z??0)-(i.z??0));Math.sin(n*Math.PI/180),a=s>0?s:1/(2*Math.PI*6378137)/Math.cos(n*Math.PI/180)}return{x:i.x,y:i.y,z:i.z??r*a,meterInMercator:a,altitude:r}},lngLatFromWorld(e,n){let r=t.lngLatFromWorld(e,n);return Array.isArray(r)?[r[0],r[1]]:r&&typeof r.lng==`number`&&typeof r.lat==`number`?[r.lng,r.lat]:[0,0]}}:null}var da=class{get map(){return this._map}set map(e){this._map=e,this.viewer.geo=e?ua(e):null}constructor(e={}){h(this,`id`,void 0),h(this,`type`,`custom`),h(this,`renderingMode`,`3d`),h(this,`options`,void 0),h(this,`pickable`,void 0),h(this,`onStats`,void 0),h(this,`onReady`,void 0),h(this,`onPick`,void 0),h(this,`onError`,void 0),h(this,`_map`,null),h(this,`viewer`,void 0),h(this,`_orthoWarned`,!1),h(this,`_projection`,`perspective`),h(this,`_onProjectionChange`,()=>{this.map&&(this.viewer.geo=ua(this.map)),this.viewer.recomputeAnchors()}),h(this,`_onClick`,e=>{if(!this.pickable)return;let t=this.pickFromEvent(e);t?(this.select(t),this.onPick(t)):this.select(null)}),this.id=e.id??`s3m`,this.options=e,this.pickable=e.pickable!==!1,this._projection=e.projection===`orthographic`?`orthographic`:`perspective`,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.viewer=new $i({configUrl:e.configUrl,datasets:e.datasets,style:e.style,ground:e.ground,pickable:e.pickable,maxTiles:e.maxTiles,maxConcurrent:e.maxConcurrent,lodRangeScale:e.lodRangeScale,buildTile:e.buildTile,light:e.light,totalMaxTiles:e.totalMaxTiles,attributes:e.attributes,onRequestRepaint:()=>this.map?.triggerRepaint(),getBearing:()=>this.map?.getBearing?.()??0,onStats:e=>this.onStats(e),onReady:e=>this.onReady(e),onPick:e=>this.onPick(e),onError:e=>this.onError(e)})}onAdd(e,t){this.map=e,this.viewer.mount(e.getCanvas(),t),e.on(`click`,this._onClick),typeof e.on==`function`&&e.on(`projectiontransition`,this._onProjectionChange)}onRemove(){this.map?.off(`click`,this._onClick),typeof this.map?.off==`function`&&this.map.off(`projectiontransition`,this._onProjectionChange),this.viewer.unmount(),this.viewer.geo=null,this.map=null}_extractMatrix(e){if(Array.isArray(e)||e instanceof Float64Array||e instanceof Float32Array)return e;let t=e;return t?.defaultProjectionData?.mainMatrix??t?.modelViewProjectionMatrix??null}_applyOrtho(e,t){let{nearZ:n,farZ:r}=aa(e),i=ia(e);if(!i)return this._warnOrtho(`render() 输入里没有独立的投影矩阵(需要 MapLibre ≥ 5)`),null;let a=sa({projectionMatrix:i,mvp:t.elements,nearZ:n,farZ:r},{distance:this.map?.transform?.cameraToCenterDistance??0,fov:this._frameFov(e),aspect:this._canvasAspect()});return a?a.matrix:(this._warnOrtho(`拿到的投影矩阵与 MVP 不同源(反推结果不是仿射变换)`),null)}_warnOrtho(e){this._orthoWarned||(this._orthoWarned=!0,console.warn(`[s3m] 正交模式不可用:${e},本帧保持透视`))}_frameFov(e){return oa(e,this.map?.transform?.fovInRadians)??.6435011087932844}_canvasAspect(){let e=this.map?.getCanvas?.();return!e||!e.height?1:e.width/e.height}setProjection(e){let t=e===`orthographic`?`orthographic`:`perspective`;this._projection!==t&&(this._projection=t,this._orthoWarned=!1,this.map?.triggerRepaint())}get projection(){return this._projection}render(e,n){let r=this.map,i=this.viewer.sceneAnchor;if(!r||!i)return;let a=this._extractMatrix(n);if(!a)return;let o=new t.Matrix4().fromArray(a);this._projection===`orthographic`&&(o=this._applyOrtho(n,o)??o);let s=r.getCanvas(),c=i.meterInMercator,l=[0,0,0];try{let e=r.getFreeCameraOptions?.()?.position;e&&(l=[(e.x-i.x)/c,-(e.y-i.y)/c,(e.z-i.z)/c])}catch{}this.viewer.renderFrame({mvp:o.elements,cameraEnu:l,fovRad:this._frameFov(n),canvasHeight:s.height})&&r.triggerRepaint()}pickFromEvent(e){let t=this.map?.getCanvas();if(!t)return null;let n=t.getBoundingClientRect(),r=e.originalEvent??e;return this.viewer.pick(r.clientX-n.left,r.clientY-n.top)}pick(e,t){return this.viewer.pick(e,t)}pickPosition(e,t){return this.viewer.pickPosition(e,t)}drillPick(e,t,n=10){return this.viewer.drillPick(e,t,n)}getRayAt(e,t){return this.viewer.getRayAt(e,t)}select(e,t={}){this.viewer.select(e,t)}getFeatureBounds(e){return this.viewer.getFeatureBounds(e)}flyToFeature(e,t){let n=this.viewer.getFeatureBounds(e);if(!n||!this.map)return!1;let r=this.map;return typeof r.fitBounds==`function`&&(r.fitBounds(n,{padding:50,maxZoom:19,duration:1200,...t}),!0)}addDataset(e){return this.viewer.addDataset(e)}removeDataset(e){this.viewer.removeDataset(e)}clearDatasets(){this.viewer.clearDatasets()}setDatasetVisible(e,t){this.viewer.setDatasetVisible(e,t)}getDatasetHeight(e){return this.viewer.getDatasetHeight(e)}setDatasetHeight(e,t){this.viewer.setDatasetHeight(e,t)}setDatasetAlign(e,t){this.viewer.setDatasetAlign(e,t)}_computeAlignOffset(e,t){return this.viewer.computeAlignOffset(e,t)}setLight(e){this.viewer.setLight(e)}getLight(){return this.viewer.getLight()}setOpacity(e){this.viewer.setOpacity(e)}setStyle(e={}){this.viewer.setStyle(e)}getStyle(){return this.viewer.getStyle()}setEdges(e){this.viewer.setEdges(e)}setFeatureStyle(e,t){this.viewer.setFeatureStyle(e,t)}setFeaturesStyle(e,t){this.viewer.setFeaturesStyle(e,t)}getFeatureStyle(e){return this.viewer.getFeatureStyle(e)}getFeatureStyles(){return this.viewer.getFeatureStyles()}removeFeatureStyle(e){this.viewer.removeFeatureStyle(e)}clearFeatureStyles(){this.viewer.clearFeatureStyles()}setAttributeSource(e){this.viewer.setAttributeSource(e)}getLoadedSmids(){return this.viewer.getLoadedSmids()}auditBatches(){return this.viewer.auditBatches()}getThematicField(){return this.viewer.getThematicField()}setThematicColors(e,t=`custom`){this.viewer.setThematicColors(e,t)}clearThematic(){this.viewer.clearThematic()}getFilterField(){return this.viewer.getFilterField()}filterByField(e){return this.viewer.filterByField(e)}clearFieldFilter(){this.viewer.clearFieldFilter()}getElevationField(){return this.viewer.getElevationField()}elevateByField(e){return this.viewer.elevateByField(e)}setThematicElevation(e,t=`custom`){this.viewer.setThematicElevation(e,t)}clearThematicElevation(){this.viewer.clearThematicElevation()}colorByField(e){return this.viewer.colorByField(e)}setFilter(e){this.viewer.setFilter(e)}getFilter(){return this.viewer.getFilter()}clearFilter(){this.viewer.clearFilter()}setGroundMode(e){this.viewer.setGroundMode(e)}setGroundOpacity(e){this.viewer.setGroundOpacity(e)}setExcavationBounds(e){this.viewer.setExcavationBounds(e)}setGroundOcclude(e){this.viewer.setGroundOcclude(e)}get groundManager(){return this.viewer.groundManager}getAllMeshes(){return this.viewer.getAllMeshes()}flushOverrides(){this.viewer.flushOverrides()}_applyOverridesToMesh(e){this.viewer._applyOverridesToMesh(e)}get lodRangeScale(){return this.viewer.lodRangeScale}setLodRangeScale(e,t){this.viewer.setLodRangeScale(e,t)}get renderer(){return this.viewer.renderer}get scene(){return this.viewer.scene}get camera(){return this.viewer.camera}get picker(){return this.viewer.picker}get uniforms(){return this.viewer.uniforms}get style(){return this.viewer.style}get outlineMaterial(){return this.viewer.outlineMaterial}get lineShared(){return this.viewer.lineShared}get edgeMaterial(){return this.viewer.edgeMaterial}get selectionEdgeMaterial(){return this.viewer.selectionEdgeMaterial}get datasets(){return this.viewer.datasets}get sceneAnchor(){return this.viewer.sceneAnchor}set sceneAnchor(e){this.viewer.sceneAnchor=e}get attributeQuery(){return this.viewer.attributeQuery}get fps(){return this.viewer.fps}get stats(){return this.viewer.stats}getBounds(){return this.viewer.getBounds()}dispose(){this.onRemove()}},fa=u({AttributeQuery:()=>Ot,BinaryReader:()=>g,DEFAULT_FLOOR_HEIGHT:()=>St,DEFAULT_FOV:()=>ca,DEFAULT_STYLE:()=>Mr,DatasetManager:()=>Ui,EARTH_RADIUS:()=>kt,FeatureStyleManager:()=>Ji,GroundManager:()=>Yi,Picker:()=>Pi,PixelFormat:()=>X,S3MFormatError:()=>_t,S3MLayer:()=>da,S3MTileset:()=>bi,S3MViewer:()=>$i,S3M_VERSION:()=>Ve,SELECT_MODE:()=>$,SELECT_MODE_LABELS:()=>jr,STYLE:()=>Q,STYLE_LABELS:()=>Ar,TextureCompress:()=>U,VertexTag:()=>R,VertexTagV3:()=>He,buildAttributes:()=>xt,buildFeatureEdgeSegments:()=>Hi,buildOrthoMVP:()=>sa,buildThickLineGeometry:()=>zi,buildTileObjects:()=>si,createLineSharedUniforms:()=>Fi,createMapLibreGeoAdapter:()=>ua,createOutlineMaterial:()=>kr,createSharedUniforms:()=>Dr,createStyledMaterial:()=>Or,createTexture:()=>Tr,createThickLineMaterial:()=>Ri,default:()=>da,dxtPixelFormatOf:()=>gn,extractFovRadians:()=>oa,extractNearFar:()=>aa,extractProjectionMatrix:()=>ia,extractWorldCoordinateHelper:()=>la,isS3M1Buffer:()=>je,lngLatFromMercator:()=>jt,lngLatFromWorld:()=>Nt,measureSegments:()=>bt,mercatorFromLngLat:()=>At,parseS3M1:()=>Be,parseS3MB:()=>vt,resolveFeature:()=>V,resolveTextureKind:()=>hn,setMaxAnisotropy:()=>vr,worldFromLngLat:()=>Mt});Ct(),yn(),Z(),Wr(),ui();var pa=globalThis;return pa.THREE||(pa.THREE=t),pa.S3MMapLibre=fa,e.AttributeQuery=Ot,e.BinaryReader=g,e.DEFAULT_FLOOR_HEIGHT=St,e.DEFAULT_FOV=ca,e.DEFAULT_STYLE=Mr,e.DatasetManager=Ui,e.EARTH_RADIUS=kt,e.FeatureStyleManager=Ji,e.GroundManager=Yi,e.Picker=Pi,e.PixelFormat=X,e.S3MFormatError=_t,e.S3MLayer=da,e.default=da,e.S3MTileset=bi,e.S3MViewer=$i,e.S3M_VERSION=Ve,e.SELECT_MODE=$,e.SELECT_MODE_LABELS=jr,e.STYLE=Q,e.STYLE_LABELS=Ar,e.TextureCompress=U,e.VertexTag=R,e.VertexTagV3=He,e.buildAttributes=xt,e.buildFeatureEdgeSegments=Hi,e.buildOrthoMVP=sa,e.buildThickLineGeometry=zi,e.buildTileObjects=si,e.createLineSharedUniforms=Fi,e.createMapLibreGeoAdapter=ua,e.createOutlineMaterial=kr,e.createSharedUniforms=Dr,e.createStyledMaterial=Or,e.createTexture=Tr,e.createThickLineMaterial=Ri,e.dxtPixelFormatOf=gn,e.extractFovRadians=oa,e.extractNearFar=aa,e.extractProjectionMatrix=ia,e.extractWorldCoordinateHelper=la,e.isS3M1Buffer=je,e.lngLatFromMercator=jt,e.lngLatFromWorld=Nt,e.measureSegments=bt,e.mercatorFromLngLat=At,e.parseS3M1=Be,e.parseS3MB=vt,e.resolveFeature=V,e.resolveTextureKind=hn,e.setMaxAnisotropy=vr,e.worldFromLngLat=Mt,e})({},THREE);
585
+ `}),a=new t.Mesh(e,i);a.position.set(0,0,-.02),a.renderOrder=-1e3,a.name=`s3m-ground-depth`,a.visible=!1,this.group.add(a),this._depthMesh=a,this._depthMaterial=i,this._syncUniforms()}_applyMode(){this._mesh&&(this._mesh.visible=this.mode!==`none`),this._material&&(this._material.uniforms.uMode.value=this.mode===`excavate`?2:+(this.mode===`translucent`),this._material.depthWrite=this.mode===`excavate`),this._depthMesh&&(this._depthMesh.visible=this.occlude,this._depthMaterial&&(this._depthMaterial.uniforms.uPunchPit.value=+(this.mode===`excavate`)))}update(e){e&&this.group.position.set(e.position.x,e.position.y,this.groundHeight)}setGroundHeight(e){this.groundHeight=e,this.group.position.z=e}setMode(e){this.mode=e,this._occludeExplicit||(this.occlude=e===`excavate`),this._applyMode()}setOcclude(e){this.occlude=e,this._occludeExplicit=!0,this._applyMode()}setOpacity(e){this.opacity=Math.max(0,Math.min(1,e)),this._material&&(this._material.uniforms.uOpacity.value=this.opacity)}setColors(e,t){this.color.set(e),t&&this.gridColor.set(t),this._material&&(this._material.uniforms.uColor.value=this.color,this._material.uniforms.uGridColor.value=this.gridColor)}setExcavationBounds(e){this.excavationBounds=e,this._syncUniforms()}autoFitExcavation(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=!1;for(let o of e){let e=o.tileset?.config,s=e?.rootTiles??e?.tiles;if(Array.isArray(s))for(let e of s){let s=e.boundingBox;if(!s)continue;let c=s.center??{x:0,y:0},l=s.xExtent?.x?Math.abs(s.xExtent.x):50,u=s.yExtent?.y?Math.abs(s.yExtent.y):50,d=c.x+o.offset[0]-l,f=c.x+o.offset[0]+l,p=c.y+o.offset[1]-u,m=c.y+o.offset[1]+u;d<t&&(t=d),f>r&&(r=f),p<n&&(n=p),m>i&&(i=m),a=!0}}a&&Number.isFinite(t)&&this.setExcavationBounds([t-5,n-5,r+5,i+5])}_syncUniforms(){let e=this.excavationBounds;if(this._material){let t=this._material.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}if(this._depthMaterial){let t=this._depthMaterial.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}}dispose(){this._geom?.dispose(),this._geom=null,this._material?.dispose(),this._material=null,this._depthMaterial?.dispose(),this._depthMaterial=null,this._mesh=null,this._depthMesh=null,this.group.clear()}};Z(),Wr(),Ct();var Xi=65534;function Zi(e){let t=Array.isArray(e.material)?e.material[0]:e.material;return t?.userData?.isStyled?t:null}function Qi(e){return e.isPoints===!0}var $i=class{get datasets(){return this._datasetManager.datasets}get sceneAnchor(){return this._datasetManager.sceneAnchor}set sceneAnchor(e){this._datasetManager.sceneAnchor=e}_requestRepaint(){this._onRequestRepaint()}triggerRepaint(){this._requestRepaint()}constructor(e={}){h(this,`options`,void 0),h(this,`pickable`,void 0),h(this,`onStats`,void 0),h(this,`onReady`,void 0),h(this,`onPick`,void 0),h(this,`onError`,void 0),h(this,`geo`,null),h(this,`canvas`,null),h(this,`renderer`,null),h(this,`scene`,null),h(this,`camera`,null),h(this,`picker`,null),h(this,`uniforms`,void 0),h(this,`style`,void 0),h(this,`outlineMaterial`,void 0),h(this,`lineShared`,void 0),h(this,`edgeMaterial`,void 0),h(this,`selectionEdgeMaterial`,void 0),h(this,`groundManager`,void 0),h(this,`_datasetManager`,new Ui),h(this,`_featureStyleManager`,void 0),h(this,`_pickables`,new Map),h(this,`_pickSeq`,0),h(this,`_freePickIds`,[]),h(this,`_smidMeshes`,new Map),h(this,`_meshHeight`,new Map),h(this,`_heightMin`,1/0),h(this,`_heightMax`,-1/0),h(this,`_boxScratch`,new t.Box3),h(this,`_selection`,null),h(this,`_selectedMeshes`,[]),h(this,`_outlineMesh`,null),h(this,`_outlineMeshes`,[]),h(this,`_selectionEdges`,null),h(this,`_selectionEdgeMeshes`,[]),h(this,`_edgesEnabled`,!1),h(this,`attributeQuery`,null),h(this,`_enuMatrix`,new t.Matrix4),h(this,`_needsRepaint`,!0),h(this,`_frame`,0),h(this,`_fps`,{value:0,last:0}),h(this,`_ambientLight`,void 0),h(this,`_hemiLight`,void 0),h(this,`_keyLight`,void 0),h(this,`_fillLight`,void 0),h(this,`_lightOptions`,{ambientIntensity:.4,ambientColor:16777215,hemisphereIntensity:.8,hemisphereColor:16777215,hemisphereGroundColor:11976907,keyLightIntensity:1,keyLightColor:16777215,fillLightIntensity:.35,fillLightColor:16777215,mode:`headlamp`,azimuth:150,altitude:50}),h(this,`_datasetQueue`,void 0),h(this,`_onRequestRepaint`,()=>{}),h(this,`_getBearing`,void 0),h(this,`_lodRangeScale`,1),this.options=e,this.pickable=e.pickable!==!1,this._lodRangeScale=e.lodRangeScale??1,e.light&&Object.assign(this._lightOptions,e.light),e.totalMaxTiles&&(this._datasetManager.totalMaxTiles=e.totalMaxTiles),this._onRequestRepaint=e.onRequestRepaint??(()=>{}),this._getBearing=e.getBearing,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.groundManager=new Yi(e.ground),this.scene||(this.scene=new t.Scene,this.scene.add(this.groundManager.group),this._addLights()),this._featureStyleManager=new Ji(()=>this.style.floorHeight,()=>this._requestRepaint(),()=>{this._selection&&this._syncSelectionStyle()},()=>this.getAllMeshes(),e=>this._applyOverridesToMesh(e)),this.uniforms=Dr(),this.style={...Mr,...e.style??{}},this.outlineMaterial=kr(this.uniforms),this.lineShared=Fi(),this.edgeMaterial=Ri(this.lineShared,{color:this.style.edgeColor,opacity:this.style.edgeOpacity??.45,width:this.style.edgeWidth??1.2}),this.selectionEdgeMaterial=Ri(this.lineShared,{color:this.style.outlineColor??this.style.selectColor,opacity:1,width:this.style.outlineWidthPx??3}),this._fps.last=performance.now(),this._datasetQueue=this._normalizeDatasets(e),e.attributes&&(this.attributeQuery=new Ot(e.attributes))}_createRenderer(e,n){let r=new t.WebGLRenderer({canvas:e,context:n,antialias:!0});return r.autoClear=!1,r.setPixelRatio(1),r.toneMapping=t.ACESFilmicToneMapping,r.toneMappingExposure=1,r}mount(e,n){this.canvas=e,this.renderer=this._createRenderer(e,n),vr(this.renderer.capabilities.getMaxAnisotropy()),this.scene=new t.Scene,this.scene.add(this.groundManager.group),this._addLights(),this.camera=new t.Camera,this.camera.matrixAutoUpdate=!1,this.picker=new Pi(this.renderer),this._applyStyleUniforms();for(let e of this._datasetQueue)this.addDataset(e).catch(e=>this.onError(e));this._recomputeAnchors()}restoreContext(e){if(!this.canvas)console.warn(`[s3m] restoreContext 调用过早(尚未 mount),按首次挂载处理`);else{try{this.renderer?.dispose()}catch{}this.renderer=this._createRenderer(this.canvas,e),vr(this.renderer.capabilities.getMaxAnisotropy()),this.picker?.dispose(),this.picker=new Pi(this.renderer),this._requestRepaint()}}unmount(){for(let e of[...this.datasets.keys()])this.removeDataset(e);this.groundManager.dispose(),this.picker?.dispose(),this.picker=null,this.outlineMaterial.dispose(),this.edgeMaterial.dispose(),this.selectionEdgeMaterial.dispose(),this.scene?.clear(),this._selectedMeshes=[],this._outlineMeshes=[],this._selectionEdgeMeshes=[],this._outlineMesh=null,this._selectionEdges=null,this._smidMeshes.clear(),this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0,this.renderer?.dispose(),this.renderer=null,this.canvas=null}_createLights(){this._ambientLight=new t.AmbientLight(this._lightOptions.ambientColor,this._lightOptions.ambientIntensity),this._hemiLight=new t.HemisphereLight(this._lightOptions.hemisphereColor,this._lightOptions.hemisphereGroundColor,this._lightOptions.hemisphereIntensity),this._keyLight=new t.DirectionalLight(this._lightOptions.keyLightColor,this._lightOptions.keyLightIntensity),this._fillLight=new t.DirectionalLight(this._lightOptions.fillLightColor,this._lightOptions.fillLightIntensity),this._updateLights()}_addLights(){this.scene&&(this._ambientLight||this._createLights(),this.scene.add(this._ambientLight,this._hemiLight,this._keyLight,this._fillLight))}_applyLightOptions(){this._ambientLight&&(this._ambientLight.intensity=this._lightOptions.ambientIntensity,this._ambientLight.color.set(this._lightOptions.ambientColor)),this._hemiLight&&(this._hemiLight.intensity=this._lightOptions.hemisphereIntensity,this._hemiLight.color.set(this._lightOptions.hemisphereColor),this._hemiLight.groundColor.set(this._lightOptions.hemisphereGroundColor)),this._keyLight&&(this._keyLight.intensity=this._lightOptions.keyLightIntensity,this._keyLight.color.set(this._lightOptions.keyLightColor)),this._fillLight&&(this._fillLight.intensity=this._lightOptions.fillLightIntensity,this._fillLight.color.set(this._lightOptions.fillLightColor))}setLight(e){Object.assign(this._lightOptions,e),this._applyLightOptions(),this._updateLights(),this._needsRepaint=!0,this.triggerRepaint()}getLight(){return{...this._lightOptions}}_updateLights(){if(!this._keyLight||!this._fillLight)return;let e=this._lightOptions.mode===`fixed`?0:(this._getBearing?.()??0)*Math.PI/180,t=(t,n,r)=>{if(!t)return;let i=e+n*Math.PI/180,a=r*Math.PI/180,o=Math.cos(a);t.position.set(Math.sin(i)*o,Math.cos(i)*o,Math.sin(a)).multiplyScalar(1e3)};t(this._keyLight,this._lightOptions.azimuth,this._lightOptions.altitude),t(this._fillLight,this._lightOptions.azimuth+65,Math.max(10,this._lightOptions.altitude-20))}_normalizeDatasets(e){return Array.isArray(e.datasets)?e.datasets.filter(e=>!!e?.configUrl):e.configUrl?[{id:`default`,name:`默认数据集`,configUrl:e.configUrl}]:[]}async addDataset(e){if(!this.scene)throw Error(`[s3m] 图层尚未 addLayer,不能添加数据集`);return await this._datasetManager.addDataset(e,this.scene,this.geo,this.uniforms,this._lodRangeScale,this.options.buildTile,this.options.maxTiles??64,this.options.maxConcurrent??4,{onTile:(e,t)=>{this._registerTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onTileRemoved:(e,t)=>{this._unregisterTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onStats:()=>{this.onStats(this.stats),this._requestRepaint()},onError:e=>{this.onError(e),this.onStats(this.stats)},onReady:e=>{this.onReady(e),this._refreshAllHeights(),this.groundManager.excavationBounds||this.groundManager.autoFitExcavation(this.datasets.values())},triggerRepaint:()=>{this._requestRepaint()}})}_lngLatFromWorld(e,t){return Nt(this.geo,e,t)}recomputeAnchors(){this._datasetManager.recomputeAnchors(this.geo),this._refreshAllHeights(),this._requestRepaint()}_recomputeAnchors(){this.recomputeAnchors()}getDatasetHeight(e){return this._datasetManager.getDatasetHeight(e)}setDatasetHeight(e,t){let n,r;typeof e==`number`?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??0),this._datasetManager.setDatasetHeight(n,r,this.geo),this._syncGroundHeight(),this._refreshAllHeights(),this._requestRepaint()}_syncGroundHeight(){if(!this.groundManager.trackHeight)return;let e=this.datasets.keys().next().value;if(!e)return;let t=this._datasetManager.getDatasetHeight(e);this.groundManager.setGroundHeight(t)}setDatasetAlign(e,t){let n,r;t===void 0&&(e===`origin`||e===`bottom`||e===`top`||e===`center`)?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??`origin`),this._datasetManager.setDatasetAlign(n,r,this.geo),this._refreshAllHeights(),this._requestRepaint()}_computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}setFeatureStyle(e,t){this._featureStyleManager.setFeatureStyle(e,t,this._meshesOf([e]))}setFeaturesStyle(e,t){this._featureStyleManager.setFeaturesStyle(e,t,this._meshesOf(e))}getFeatureStyle(e){return this._featureStyleManager.getFeatureStyle(e)}getFeatureStyles(){return this._featureStyleManager.getFeatureStyles()}removeFeatureStyle(e){this._featureStyleManager.removeFeatureStyle(e,this._meshesOf([e]))}clearFeatureStyles(){this._featureStyleManager.clearFeatureStyles()}setAttributeSource(e){this.attributeQuery=e?new Ot(e):null}getLoadedSmids(){return[...this._smidMeshes.keys()]}auditBatches(){let e=this._featureStyleManager.auditBatches(this._pickables.values());return e.smids=this._smidMeshes.size,e}getThematicField(){return this._featureStyleManager.thematicField}setThematicColors(e,t=`custom`){this._featureStyleManager.setThematicColors(e,t)}clearThematic(){this._featureStyleManager.clearThematicColors()}getFilterField(){return this._featureStyleManager.fieldFilter?.field??null}filterByField(e){return this._featureStyleManager.filterByField(e,this.attributeQuery,this.getLoadedSmids())}clearFieldFilter(){this._featureStyleManager.clearFieldFilter()}getElevationField(){return this._featureStyleManager.elevationField}elevateByField(e){return this._featureStyleManager.elevateByField(e,this.attributeQuery,this.getLoadedSmids())}setThematicElevation(e,t=`custom`){this._featureStyleManager.setThematicElevation(e,t)}clearThematicElevation(){this._featureStyleManager.clearThematicElevation()}colorByField(e){return this._featureStyleManager.colorByField(e,this.attributeQuery,this.getLoadedSmids())}setFilter(e){this._featureStyleManager.setFilter(e,this.uniforms)}getFilter(){return this._featureStyleManager.filter}clearFilter(){this._featureStyleManager.clearFilter(this.uniforms)}setGroundMode(e){this.groundManager.setMode(e),this._requestRepaint()}setGroundOpacity(e){this.groundManager.setOpacity(e),this._requestRepaint()}setExcavationBounds(e){this.groundManager.setExcavationBounds(e),this._requestRepaint()}setGroundOcclude(e){this.groundManager.setOcclude(e),this._requestRepaint()}_isFeatureHidden(e,t){if(e==null)return!1;let n=this._featureStyleManager.fieldFilter;if(n){let t=n.matched.has(e);if(n.mode===`keep`?!t:t)return!0}let r=this._featureStyleManager.filter;return!!(r&&(r.include&&r.include.length>0&&!r.include.includes(e)||r.exclude&&r.exclude.length>0&&r.exclude.includes(e))||this._featureStyleManager.featureStyles.get(e)?.hidden)}getAllMeshes(){let e=[];for(let t of this._pickables.values())e.push(t.mesh);return e}_meshesOf(e){let t=new Set;for(let n of e){let e=this._smidMeshes.get(n);if(e)for(let n of e)t.add(n)}return t}_markOverridesDirty(e=`all`){e===`all`?this._featureStyleManager.markOverridesDirty(void 0,this.getAllMeshes()):this._featureStyleManager.markOverridesDirty(e)}flushOverrides(){this._featureStyleManager.flushOverrides()}_applyOverridesToMesh(e){this._featureStyleManager.applyOverridesToMesh(e)}removeDataset(e){if(this.datasets.get(e)){this._selection?.datasetId===e&&this.select(null),this._datasetManager.removeDataset(e,this.scene,this.geo,e=>{e.root.traverse(e=>{let t=e,n=t.userData;n.pickId!=null&&(this._pickables.delete(n.pickId),this._releasePickId(n.pickId),n.pickId=void 0),this._unindexMeshSmids(t),this._removeMeshHeight(t),t.geometry?.dispose?.();let r=Zi(t);r&&r.dispose(),Oi(t.material)&&t.material.dispose(),this._featureStyleManager.disposeMesh(t)})});for(let[t,n]of this._pickables)n.datasetId===e&&this._pickables.delete(t);this.onStats(this.stats),this._requestRepaint()}}clearDatasets(){for(let e of[...this.datasets.keys()])this.removeDataset(e)}setDatasetVisible(e,t){this._datasetManager.setDatasetVisible(e,t),!t&&this._selection?.datasetId===e&&this.select(null),this._requestRepaint()}_registerTile(e,t){t.root.add(e.group),e.group.updateMatrixWorld(!0);let n=e.group.userData.hasNativeEdges===!0;for(let r of e.group.children){if(r.isLineSegments&&r.userData.isEdgeLines){r.visible=this._edgesEnabled,this._styleEdgeLine(r);continue}let i=Qi(r),a=r;if(!a.isMesh&&!i)continue;let o=a.userData;if(o.pickId=this._allocPickId(),o.datasetId=t.id,o.nativeEdges=n,this._pickables.set(o.pickId,{datasetId:t.id,mesh:a,tile:e.tile,skeletonName:o.skeletonName??``}),this._indexMeshSmids(a),this._addMeshHeight(a),this._edgesEnabled&&!n&&!i&&this._ensureEdges(a),i)this._applyPointCloudStyle(r);else{let e=Zi(a);if(e){let t=Math.min(1,Math.max(.05,this.style.opacity??1));e.opacity=t,e.transparent=t<.999,e.depthWrite=t>=.999,e.flatShading=this.style.shading!==`smooth`,e.needsUpdate=!0,this._featureStyleManager.applyOverridesToMesh(a)}}this._replaySelectionOnto(a)}}_isMeshCoveringSelection(e,n){if(!n.point)return!1;let r=e.geometry;if(!r||(r.boundingBox||r.computeBoundingBox(),!r.boundingBox))return!1;let i=new t.Vector3(n.point[0],n.point[1],n.point[2]);e.updateWorldMatrix(!0,!1);let a=e.matrixWorld.clone().invert(),o=i.applyMatrix4(a);return r.boundingBox.clone().expandByScalar(.5).containsPoint(o)}_replaySelectionOnto(e){let t=this._selection;if(!t)return;let n=Zi(e);if(!n)return;let r=e.userData,i=-1;if(t.smid!=null){let e=r.geoRef?.pickInfo,n=e?.[t.smid]??e?.[String(t.smid)];i=n?B(n):-1}if(e===t.mesh&&(i=t.batchId),i<0&&e!==t.mesh){if(t.smid==null&&r.datasetId===t.datasetId&&this._isMeshCoveringSelection(e,t))i=-1;else return}n.userData.uSelBatch.value=i,n.userData.uSelWhole.value=+(i<0),this._selectedMeshes.includes(e)||this._selectedMeshes.push(e),Qi(e)&&this._applyPointCloudStyle(e,!0),this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers}_unregisterTile(e,t){e.group.traverse(e=>{let t=e;if(t.userData?.pickId!=null&&(this._pickables.delete(t.userData.pickId),this._releasePickId(t.userData.pickId),t.userData.pickId=void 0),t.isMesh){this._selectedMeshes.includes(t)&&(this._selectedMeshes=this._selectedMeshes.filter(e=>e!==t));let e=this._selection;if(e&&e.mesh===t){let n=e.smid,r=n==null?this._selectedMeshes.find(e=>e!==t&&e.parent&&e.parent.visible)??this._selectedMeshes.find(e=>e!==t&&e.parent):[...this._smidMeshes.get(n)??[]].find(e=>e!==t&&e.parent);r?(this._selection={...e,mesh:r},this._replaySelectionOnto(r)):this.select(null)}this._unindexMeshSmids(t),this._removeMeshHeight(t),this._featureStyleManager.disposeMesh(t),Zi(t)?.dispose?.()}Oi(t.material)?t.material.dispose():t.material&&(Array.isArray(t.material)?t.material.forEach(e=>e?.dispose?.()):t.material.dispose?.()),t.geometry?.dispose?.()}),t.root.remove(e.group)}_allocPickId(){let e=this._freePickIds.pop();if(e!==void 0)return e;if(this._pickSeq>Xi){for(let e=0;e<=Xi;e++)if(!this._pickables.has(e))return e;throw Error(`[s3m] 可拾取网格超过 65535 个,2 字节 ID 编码不够用`)}return this._pickSeq++}_releasePickId(e){this._freePickIds.push(e)}setOpacity(e){this.setStyle({opacity:e})}setStyle(e={}){this.style={...this.style,...e},this._applyStyleUniforms(),(`opacity`in e||`depthWrite`in e)&&this._applyOpacity(),`mode`in e&&this._applyPointCloudStyles(),`shading`in e&&this._applyShading(),`edges`in e?this.setEdges(!!this.style.edges):(`edgeColor`in e||`edgeWidth`in e||`opacity`in e||`edgeOpacity`in e)&&this._refreshEdgeLines(),this._selection&&(`outline`in e||`outlineStyle`in e?this.select(this._selection,{silent:!0}):this._syncSelectionStyle()),this._requestRepaint()}getStyle(){return{...this.style,modeLabel:Ar[this.style.mode]}}_applyStyleUniforms(){let e=this.uniforms,t=this.style;e.uMode.value=t.mode,e.uColorA.value.set(t.colorA),e.uColorB.value.set(t.colorB),e.uColorC.value.set(t.colorC),e.uSelColor.value.set(t.selectColor),e.uFloorHeight.value=t.floorHeight;let n=t.selectMode??$.OVERLAY;e.uSelMode&&(e.uSelMode.value=n===$.REPLACE?0:n===$.MULTIPLY?2:n===$.GLOW_ONLY?3:1),e.uSelOpacity&&t.selectOpacity!=null&&(e.uSelOpacity.value=t.selectOpacity),e.uSelEmissive&&t.selectEmissive!=null&&(e.uSelEmissive.value=t.selectEmissive),e.uSelElevation&&t.selectElevation!=null&&(e.uSelElevation.value=t.selectElevation),e.uDimFactor&&t.dimFactor!=null&&(e.uDimFactor.value=t.dimFactor),e.uRoofThreshold&&t.roofThreshold!=null&&(e.uRoofThreshold.value=t.roofThreshold),e.uTexMix&&t.texMix!=null&&(e.uTexMix.value=t.texMix),this.outlineMaterial&&(this.outlineMaterial.uniforms.uElevation&&t.selectElevation!=null&&(this.outlineMaterial.uniforms.uElevation.value=t.selectElevation),t.outlineWidth!=null&&(this.outlineMaterial.uniforms.uWidth.value=t.outlineWidth),t.outlineColor==null?this.outlineMaterial.uniforms.uColor.value.set(t.selectColor):this.outlineMaterial.uniforms.uColor.value.set(t.outlineColor))}_applyOpacity(){let e=Math.min(1,Math.max(.05,this.style.opacity??1)),t=e<.999,n=this.style.depthWrite!==!1;for(let r of this._pickables.values()){if(Qi(r.mesh)){this._applyPointCloudStyle(r.mesh);continue}let i=Zi(r.mesh);i&&(i.opacity=e,i.transparent=t,i.depthWrite=!t||n)}this._requestRepaint()}_applyPointCloudStyle(e,t=this._selectedMeshes.includes(e)){Di(e,this.style,this.uniforms,t)}_applyPointCloudStyles(){for(let e of this._pickables.values())Qi(e.mesh)&&this._applyPointCloudStyle(e.mesh);this._requestRepaint()}_applyShading(){let e=this.style.shading!==`smooth`;for(let t of this._pickables.values()){let n=Zi(t.mesh);n&&n.flatShading!==e&&(n.flatShading=e,n.needsUpdate=!0)}this._requestRepaint()}_addMeshHeight(e){let t=e.geometry?.boundingBox;if(!t)return;this._boxScratch.copy(t).applyMatrix4(e.matrixWorld);let n=this._boxScratch.min.z,r=this._boxScratch.max.z;Number.isFinite(n)&&Number.isFinite(r)&&(this._meshHeight.set(e,{min:n,max:r}),n<this._heightMin&&(this._heightMin=n),r>this._heightMax&&(this._heightMax=r),this._pushHeightRange())}_removeMeshHeight(e){let t=this._meshHeight.get(e);t&&(this._meshHeight.delete(e),t.min===this._heightMin||t.max===this._heightMax?this._recomputeHeightRange():this._pushHeightRange())}_refreshAllHeights(){if(this._meshHeight.size===0)return;let e=[...this._meshHeight.keys()];this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0;for(let t of e)this._addMeshHeight(t);this._pushHeightRange()}_recomputeHeightRange(){let e=1/0,t=-1/0;for(let n of this._meshHeight.values())n.min<e&&(e=n.min),n.max>t&&(t=n.max);this._heightMin=e,this._heightMax=t,this._pushHeightRange()}_pushHeightRange(){let e=this._heightMin,t=this._heightMax;(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)&&(e=0,t=100),this.uniforms.uHeightMin.value=e,this.uniforms.uHeightMax.value=t}_indexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n);if(!Number.isFinite(t)||t<0)continue;let r=this._smidMeshes.get(t);r||this._smidMeshes.set(t,r=new Set),r.add(e)}}_unindexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n),r=this._smidMeshes.get(t);r&&(r.delete(e),r.size===0&&this._smidMeshes.delete(t))}}setEdges(e){this._edgesEnabled=e,this.style.edges=e;for(let t of this.datasets.values())t.root.traverse(t=>{t.userData.isEdgeLines&&(t.visible=e,this._styleEdgeLine(t))});if(this._syncEdgeStyle(),!e){for(let e of this._pickables.values())this._removeEdges(e.mesh);this._requestRepaint();return}let t=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e.userData;return!t.edges&&!t.nativeEdges&&!Qi(e)}),n=0,r=()=>{let e=performance.now();for(;n<t.length&&performance.now()-e<8;)this._ensureEdges(t[n++]);n<t.length?setTimeout(r,0):this._requestRepaint()};r()}_syncEdgeStyle(){let e=this.style,t=this.edgeMaterial.uniforms;t.uColor.value.set(e.edgeColor),t.uWidth.value=Math.max(.1,e.edgeWidth??1.2),t.uOpacity.value=Math.min(1,Math.max(0,e.edgeOpacity??.45))*Math.min(1,Math.max(.05,e.opacity??1))}_styleEdgeLine(e){let t=e.material;t&&t.color&&(t.color.set(this.style.edgeColor),t.opacity=(this.style.edgeOpacity??.45)*Math.min(1,Math.max(.05,this.style.opacity??1)),t.transparent=!0,t.polygonOffset=!0,t.polygonOffsetFactor=-1,t.polygonOffsetUnits=-1,t.needsUpdate=!0)}_refreshEdgeLines(){this._syncEdgeStyle();for(let e of this.datasets.values())e.root.traverse(e=>{e.userData.isEdgeLines&&this._styleEdgeLine(e)})}_ensureEdges(e){let n=e.userData;if(n.edges||n.nativeEdges||!e.geometry||(e.geometry.index?.count??0)>12e4)return;let r=new t.EdgesGeometry(e.geometry,40),i=r.getAttribute(`position`),a=i?i.array:null;if(r.dispose(),!a||a.length<6)return;let o=new t.Mesh(zi(a),this.edgeMaterial);o.renderOrder=2,o.frustumCulled=!1,o.raycast=()=>{},o.userData.isThickEdge=!0,n.edges=o,e.add(o)}_removeEdges(e){let t=e.userData,n=t.edges;n&&(e.remove(n),n.geometry?.dispose(),t.edges=null)}getRayAt(e,n){if(!this.camera||!this.canvas)return null;let r=this.canvas,i=r.clientWidth||r.width,a=r.clientHeight||r.height;if(!i||!a)return null;let o=e/i*2-1,s=-(n/a)*2+1,c=new t.Vector3(o,s,-1).unproject(this.camera),l=new t.Vector3(o,s,1).unproject(this.camera).clone().sub(c).normalize();return new t.Ray(c,l)}_intersectMeshAtRay(e,n,r){let i=new t.Raycaster;i.ray.copy(n);let a=i.intersectObject(e,!1);if(!a.length)return null;if(r!=null){let e=a.find(e=>e.instanceId===r);return e?e.point:a[0].point}return a[0].point}_buildPickResult(e,n,r,i){let a=n.mesh.userData,o=null,s=e.batchId,c=e.instanceIndex,l=a.geoRef,u=[];if(c!=null){let e=this._instanceFeature(n.mesh,l,c);if(!e)return null;o=e.smid,s=e.batchId}else{l=a.geoByBatchId?.get(e.batchId)??a.geoRef;let t=V(l,e.batchId);o=t.smid,u=t.segments}if(this._isFeatureHidden(o,s))return null;let d=null,f=0;if(c!=null)d=this._instanceBox(n.mesh,c),f=n.mesh.geometry.index?Math.round(n.mesh.geometry.index.count/3):0;else if(o!=null&&this._smidMeshes.has(o)){let e=this._smidMeshes.get(o),t=1/0,n=1/0,r=1/0,i=-1/0,a=-1/0,s=-1/0,c=0;for(let l of e){let e=l.userData,u=e.geoRef?.pickInfo,d=u?.[o]??u?.[String(o)],p=d?B(d):-1,m=d?.segments??(p>=0?V(e.geoRef,p).segments:[]),h=bt(l.geometry,m);h&&(h.minX<t&&(t=h.minX),h.minY<n&&(n=h.minY),h.minZ<r&&(r=h.minZ),h.maxX>i&&(i=h.maxX),h.maxY>a&&(a=h.maxY),h.maxZ>s&&(s=h.maxZ),c+=h.count,f+=h.triangles)}c>0&&(d={minX:t,minY:n,minZ:r,maxX:i,maxY:a,maxZ:s,count:c,triangles:f})}if(!d&&(d=bt(n.mesh.geometry,u),!d&&n.mesh.geometry)){n.mesh.geometry.boundingBox||n.mesh.geometry.computeBoundingBox();let e=n.mesh.geometry.boundingBox;e&&(d={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}let p=n.mesh.geometry,m=f>0?f:p.index?Math.round(p.index.count/3):0,h=xt({smid:o,box:d,triangles:m,floorHeight:this.style.floorHeight}),g=null;if(d&&this.sceneAnchor){let e=new t.Vector3((d.minX+d.maxX)/2,(d.minY+d.maxY)/2,(d.minZ+d.maxZ)/2);e.applyMatrix4(n.mesh.matrixWorld);let r=this.sceneAnchor.meterInMercator;g=this._lngLatFromWorld(e.x*r+this.sceneAnchor.x,-e.y*r+this.sceneAnchor.y)}let _=r??null;!_&&i&&(_=this._intersectMeshAtRay(n.mesh,i,c));let v=null,y=null,b=null;if(_&&this.sceneAnchor){let e=o==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(o),n=e.translation,r=e.elevation,i=_.clone();n?i.add(new t.Vector3(n[0],n[1],n[2])):r&&(i.z+=r),v=[i.x,i.y,i.z];let a=this.sceneAnchor.meterInMercator;y=this._lngLatFromWorld(i.x*a+this.sceneAnchor.x,-i.y*a+this.sceneAnchor.y),b=i.z+(this.sceneAnchor.altitude??0)}else g&&d&&this.sceneAnchor&&(y=g,b=(d.minZ+d.maxZ)/2+(this.sceneAnchor.altitude??0));return{datasetId:n.datasetId,datasetName:this.datasets.get(n.datasetId)?.name??n.datasetId,objectId:e.objectId,batchId:s,instanceIndex:c,skeletonName:n.skeletonName,centerLngLat:g,point:v,lngLat:y,altitude:b,...h,mesh:n.mesh}}pick(e,t){if(!this.picker||!this.scene||!this.camera||!this.sceneAnchor)return null;let n=this.picker.pick(this.scene,this.camera,e,t);if(!n)return null;let r=this._pickables.get(n.objectId);if(!r)return null;let i=this.getRayAt(e,t);return this._buildPickResult(n,r,void 0,i??void 0)}pickPosition(e,n){if(!this.camera||!this.sceneAnchor)return null;let r=this.pick(e,n);if(r?.point&&r?.lngLat&&r.altitude!=null)return{lngLat:r.lngLat,altitude:r.altitude,point:r.point};let i=this.getRayAt(e,n);if(!i)return null;let a=new t.Plane(new t.Vector3(0,0,1),0),o=new t.Vector3,s=i.intersectPlane(a,o);if(s){let e=this.sceneAnchor.meterInMercator;return{lngLat:this._lngLatFromWorld(s.x*e+this.sceneAnchor.x,-s.y*e+this.sceneAnchor.y),altitude:s.z+(this.sceneAnchor.altitude??0),point:[s.x,s.y,s.z]}}return null}drillPick(e,n,r=10){if(!this.sceneAnchor||!this.camera)return[];let i=this.getRayAt(e,n);if(!i)return[];let a=new t.Raycaster;a.ray.copy(i);let o=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}),s=a.intersectObjects(o,!1);if(!s.length)return[];let c=[],l=new Set,u=new Set;for(let e of s){if(c.length>=r)break;let t=e.object,n=t.userData;if(n.pickId==null)continue;let i=this._pickables.get(n.pickId);if(!i)continue;let a=null,o=-1,s=e.instanceId;if(s!=null){let e=this._instanceFeature(t,n.geoRef,s);if(!e)continue;a=e.smid,o=e.batchId}else if(e.faceIndex!=null){let r=t.geometry.attributes.aBatchId;if(r){let i=t.geometry.index?t.geometry.index.getX(e.faceIndex*3):e.faceIndex*3;o=Math.round(r.getX(i)),a=V(n.geoByBatchId?.get(o)??n.geoRef,o).smid}}if(a!=null){if(l.has(a))continue;l.add(a)}else{let e=`${n.pickId}:${o}:${s??-1}`;if(u.has(e))continue;u.add(e)}if(this._isFeatureHidden(a,o))continue;let d={objectId:n.pickId,batchId:o,instanceIndex:s},f=this._buildPickResult(d,i,e.point);f&&c.push(f)}return c}getFeatureBounds(e){if(!this.sceneAnchor)return null;let n=1/0,r=-1/0,i=1/0,a=-1/0,o=!1;for(let s of this._pickables.values()){let c=s.mesh,l=c.userData,u=l.geoRef,d=u?.pickInfo;if(!d)continue;let f=null;if(c.isInstancedMesh){let t=l.instanceLookup;t||(t=yt(d),l.instanceLookup=t);for(let[n,r]of t)if(r.smid===e){f=this._instanceBox(c,n);break}}else{let t=d,n=t[e]??t[String(e)];if(n){let e=V(u,B(n));if(f=bt(c.geometry,e.segments),!f&&c.geometry){c.geometry.boundingBox||c.geometry.computeBoundingBox();let e=c.geometry.boundingBox;e&&(f={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}}}if(f){o=!0;let s=[new t.Vector3(f.minX,f.minY,f.minZ),new t.Vector3(f.maxX,f.minY,f.minZ),new t.Vector3(f.minX,f.maxY,f.minZ),new t.Vector3(f.maxX,f.maxY,f.minZ),new t.Vector3(f.minX,f.minY,f.maxZ),new t.Vector3(f.maxX,f.minY,f.maxZ),new t.Vector3(f.minX,f.maxY,f.maxZ),new t.Vector3(f.maxX,f.maxY,f.maxZ)],l=e==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(e),u=l.translation,d=l.elevation;for(let e of s){u?e.add(new t.Vector3(u[0],u[1],u[2])):d&&(e.z+=d),e.applyMatrix4(c.matrixWorld);let o=this.sceneAnchor.meterInMercator,[s,l]=this._lngLatFromWorld(e.x*o+this.sceneAnchor.x,-e.y*o+this.sceneAnchor.y);s<n&&(n=s),s>r&&(r=s),l<i&&(i=l),l>a&&(a=l)}}}return o?[[n,i],[r,a]]:null}_instanceFeature(e,t,n){let r=e.userData;return r.instanceLookup||(r.instanceLookup=yt(t?.pickInfo)),r.instanceLookup.get(n)??null}_instanceBox(e,n){let r=e;if(!r.isInstancedMesh)return null;let i=e.geometry;i.boundingBox||i.computeBoundingBox();let a=i.boundingBox;if(!a)return null;let o=new t.Matrix4;r.getMatrixAt(n,o);let s=a.clone().applyMatrix4(o);return{minX:s.min.x,minY:s.min.y,minZ:s.min.z,maxX:s.max.x,maxY:s.max.y,maxZ:s.max.z,count:i.getAttribute(`position`)?.count??0,triangles:i.index?Math.round(i.index.count/3):0}}select(e,{silent:t=!1}={}){if(this._selection){for(let e of this._selectedMeshes){if(Qi(e)){this._applyPointCloudStyle(e,!1);continue}let t=Zi(e);t&&(t.userData.uSelBatch.value=-1,t.userData.uSelWhole.value=0)}this._selectedMeshes=[],this._clearSelectionDecoration(),this._selection=null}if(!e){this.uniforms.uSelMix.value=0,this.uniforms.uDim.value=0,this.outlineMaterial.uniforms.uSelBatch.value=-1,this.outlineMaterial.uniforms.uSelWhole.value=0,this.outlineMaterial.uniforms.uElevation.value=0,this._requestRepaint(),t||this.onPick(null);return}this._selection=e;let n=new Set;if(e.smid!=null){let t=this._smidMeshes.get(e.smid);if(t)for(let e of t)n.add(e)}n.add(e.mesh);for(let t of n){let n=Zi(t);if(!n)continue;let r=e.batchId;if(e.instanceIndex!=null&&t===e.mesh)r=e.batchId;else if(e.smid!=null){let n=t.userData.geoRef?.pickInfo,i=n?.[e.smid]??n?.[String(e.smid)],a=i?B(i):-1;r=a>=0?a:t===e.mesh?e.batchId:-1}n.userData.uSelBatch.value=r,n.userData.uSelWhole.value=+(r<0),this._selectedMeshes.push(t)}for(let e of this._selectedMeshes)Qi(e)&&this._applyPointCloudStyle(e,!0);if(this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers,this.style.outline){let t=[...n].filter(e=>!Qi(e));t.length&&((this.style.outlineStyle??`edges`)===`edges`?this._addSelectionEdges(e,t):this._addSelectionHull(e,t))}this._requestRepaint()}_addSelectionEdges(e,n){this._syncSelectionStyle();for(let r of n){let n=r.userData,i=n.geoRef,a=[];if(r===e.mesh&&e.instanceIndex!=null)a=[{vertexOffset:0,vertexCount:r.geometry.getAttribute(`position`)?.count??0}];else if(e.smid!=null){let t=i?.pickInfo,n=t?.[e.smid]??t?.[String(e.smid)],r=n?B(n):-1;a=n?.segments??(r>=0?V(i,r).segments:[])}else r===e.mesh&&(a=V(n.geoByBatchId?.get(e.batchId)??i,e.batchId).segments);let o=Hi(r.geometry,a);if(o&&o.length>0){let n=new t.Mesh(zi(o),this.selectionEdgeMaterial);n.renderOrder=4,n.frustumCulled=!1,n.raycast=()=>{},n.userData.isSelectionEdge=!0,r===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(n,e),r.add(n),this._selectionEdgeMeshes.push(n)}}this._selectionEdgeMeshes.length===0?this._addSelectionHull(e,n):this._selectionEdges=this._selectionEdgeMeshes[0]??null}_applyInstanceTransform(e,n){let r=n.mesh;if(n.instanceIndex==null||!r.isInstancedMesh)return;let i=new t.Matrix4;r.getMatrixAt(n.instanceIndex,i),i.decompose(e.position,e.quaternion,e.scale)}_addSelectionHull(e,n){let r=e.instanceIndex!=null;this.outlineMaterial.uniforms.uSelBatch.value=r?-1:e.batchId,this.outlineMaterial.uniforms.uSelWhole.value=r||e.batchId<0?1:0,this.outlineMaterial.uniforms.uElevation.value=r?this._selectionElevation(e):this.style.selectElevation??0;for(let r of n){let n=Zi(r);n?.userData?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=n.userData.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=n.userData.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=n.userData.uBatchTexActive.value);let i=new t.Mesh(r.geometry,this.outlineMaterial);i.renderOrder=3,i.frustumCulled=!1,i.raycast=()=>{},r===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(i,e),r.add(i),this._outlineMeshes.push(i)}this._outlineMesh=this._outlineMeshes[0]??null}_syncSelectionStyle(){let e=this.style,t=this.selectionEdgeMaterial.uniforms;t.uColor.value.set(e.outlineColor??e.selectColor),t.uWidth.value=Math.max(.1,e.outlineWidthPx??3),t.uOpacity.value=Math.min(1,Math.max(.05,e.opacity??1)),t.uElevation.value=this._selection?this._selectionElevation(this._selection):0;for(let e of this._outlineMeshes){let t=e.parent,n=t?Zi(t)?.userData:null;n?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=n.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=n.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=n.uBatchTexActive.value)}}_selectionElevation(e){let t=this.style.selectElevation??0;if(e.smid!=null){let n=this._featureStyleManager.getFeatureEffectiveOffset(e.smid);n.elevation&&(t+=n.elevation)}return t}_clearSelectionDecoration(){for(let e of this._outlineMeshes)e.parent?.remove(e);this._outlineMeshes=[],this._outlineMesh=null;for(let e of this._selectionEdgeMeshes)e.parent?.remove(e),e.geometry.dispose();this._selectionEdgeMeshes=[],this._selectionEdges=null}_updateLineResolution(e){let t=e.width||1,n=e.height||1,r=e.clientWidth||t;this.lineShared.uResolution.value.set(t,n),this.lineShared.uDpr.value=Math.max(1,t/r)}get lodRangeScale(){return this._lodRangeScale}setLodRangeScale(e,t){if(!(e<=0)){if(t){let n=this.datasets.get(t);n?.tileset&&(n.tileset.lodRangeScale=e)}else{this._lodRangeScale=e;for(let t of this.datasets.values())t.tileset&&(t.tileset.lodRangeScale=e)}this._requestRepaint()}}renderFrame(e){if(!this.renderer||!this.scene||!this.camera||!this.sceneAnchor||!this.canvas)return!1;let n=this.renderer.getContext();if(n&&typeof n.isContextLost==`function`&&n.isContextLost())return!1;this.flushOverrides();let r=this.canvas,i=this.sceneAnchor.meterInMercator;this._enuMatrix.set(i,0,0,this.sceneAnchor.x,0,-i,0,this.sceneAnchor.y,0,0,i,this.sceneAnchor.z,0,0,0,1);let a=new t.Matrix4().fromArray(e.mvp);a.multiply(this._enuMatrix),this.camera.projectionMatrix.copy(a),this.camera.projectionMatrixInverse.copy(a).invert();let o=e.cameraEnu;this.camera.position.set(o[0],o[1],o[2]),this.camera.matrixWorld.setPosition(o[0],o[1],o[2]),this.camera.matrixWorldInverse.copy(this.camera.matrixWorld).invert(),this.groundManager.update(this.camera);let s=!1;for(let t of this.datasets.values()){if(!t.visible||!t.tileset)continue;let n=[o[0]-t.offset[0],o[1]-t.offset[1],o[2]-t.offset[2]];t.tileset.update(n,e.fovRad,e.canvasHeight)&&(s=!0)}this.style.mode===Q.DYNAMIC&&(this.uniforms.uTime.value+=.016*(this.style.speed??1)),this._updateLights(),this._updateLineResolution(r),this.renderer.setViewport(0,0,r.width,r.height),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this._frame++;let c=performance.now();return c-this._fps.last>500&&(this._fps.value=Math.round(this._frame*1e3/(c-this._fps.last)),this._frame=0,this._fps.last=c),this.style.mode===Q.DYNAMIC||this.stats.loading>0||s}get fps(){return this._fps.value}get stats(){let e={tiles:0,loading:0,failed:0,meshes:0,vertices:0,triangles:0,datasets:this.datasets.size};for(let t of this.datasets.values()){let n=t.tileset?.stats;n&&(e.tiles+=n.tiles,e.loading+=n.loading,e.failed+=n.failed,e.meshes+=n.meshes,e.vertices+=n.vertices,e.triangles+=n.triangles)}return e}getBounds(){let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of this.datasets.values()){let a=_i(i.tileset?.config?.geoBounds);a&&(e=Math.min(e,a.left),n=Math.max(n,a.right),t=Math.min(t,a.bottom),r=Math.max(r,a.top))}return isFinite(e)?[[e,t],[n,r]]:null}dispose(){this.unmount()}},ea=1e-4;function ta(e,t){let n=e.elements;for(let e=0;e<16;e++){let r=Math.max(1,Math.abs(n[e]),Math.abs(t[e]));if(Math.abs(n[e]-t[e])>ea*r)return!1}return!0}function na(e){let t=e.elements,n=1;for(let e=0;e<16;e++){let r=Math.abs(t[e]);r>n&&(n=r)}let r=1e-6*n;return Math.abs(t[3])<r&&Math.abs(t[7])<r&&Math.abs(t[11])<r&&Math.abs(t[15]-1)<r}function ra(e,t){return t>0&&Math.abs(e.elements[5]*Math.tan(t/2)-1)<.001}function ia(e){if(!e||typeof e!=`object`)return null;let t=e;return t.defaultProjectionData?.projectionMatrix??t.projectionMatrix??null}function aa(e){let t={nearZ:null,farZ:null};if(!e||typeof e!=`object`)return t;let n=e,r=n.defaultProjectionData,i=e=>{let t=n[e];if(typeof t==`number`&&Number.isFinite(t))return t;let i=r?.[e];return typeof i==`number`&&Number.isFinite(i)?i:null};return{nearZ:i(`nearZ`),farZ:i(`farZ`)}}function oa(e,t){if(e&&typeof e==`object`){let t=e.fov;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return t}return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function sa(e,n){let r=e.projectionMatrix;if(!r||r.length<16)return null;let i=new t.Matrix4().fromArray(Array.from(r)),a=new t.Matrix4().fromArray(Array.from(e.mvp));if(i.determinant()===0||!ra(i,n.fov))return null;let o=i.clone().invert().multiply(a);if(!ta(i.clone().multiply(o),Array.from(e.mvp))||!na(o)||!ra(i,n.fov))return null;let{distance:s,fov:c,aspect:l}=n;if(!(s>0)||!(c>0)||!(l>0))return null;let u=s*Math.tan(c/2),d=u*l,f=e.nearZ!=null&&e.nearZ>0?e.nearZ:1,p=e.farZ!=null&&e.farZ>f?e.farZ:s*4+1e3;p>f||(p=f+1e3);let m=new t.OrthographicCamera(-d,d,u,-u,f,p);return m.updateProjectionMatrix(),{matrix:m.projectionMatrix.clone().multiply(o),view:o}}var ca=.6435011087932844;function la(e){let t=e,n=t?.transform?.worldCoordinateHelper??t?.transform?.projection?.worldCoordinateHelper??t?.painter?.transform?.worldCoordinateHelper??(typeof t?.getProjection==`function`?t.getProjection()?.worldCoordinateHelper:null)??null;return n&&typeof n.worldFromLngLat==`function`&&typeof n.lngLatFromWorld==`function`?n:null}function ua(e){let t=la(e);return t?{worldFromLngLat(e,n,r=0){let i=t.worldFromLngLat(e,n,r),a=0;if(typeof t.metersPerWorldUnit==`function`){let e=t.metersPerWorldUnit(i.x,i.y);Number.isFinite(e)&&e>0&&(a=1/e)}if(a===0){let o=t.worldFromLngLat(e,n,r+1),s=Math.abs((o.z??0)-(i.z??0));Math.sin(n*Math.PI/180),a=s>0?s:1/(2*Math.PI*6378137)/Math.cos(n*Math.PI/180)}return{x:i.x,y:i.y,z:i.z??r*a,meterInMercator:a,altitude:r}},lngLatFromWorld(e,n){let r=t.lngLatFromWorld(e,n);return Array.isArray(r)?[r[0],r[1]]:r&&typeof r.lng==`number`&&typeof r.lat==`number`?[r.lng,r.lat]:[0,0]}}:null}var da=class{get map(){return this._map}set map(e){this._map=e,this.viewer.geo=e?ua(e):null}_mapGl(){let e=this.map?.getCanvas?.();return e?e.getContext(`webgl2`)??e.getContext(`webgl`):null}constructor(e={}){h(this,`id`,void 0),h(this,`type`,`custom`),h(this,`renderingMode`,`3d`),h(this,`options`,void 0),h(this,`pickable`,void 0),h(this,`onStats`,void 0),h(this,`onReady`,void 0),h(this,`onPick`,void 0),h(this,`onError`,void 0),h(this,`_map`,null),h(this,`viewer`,void 0),h(this,`_orthoWarned`,!1),h(this,`_projection`,`perspective`),h(this,`_onProjectionChange`,()=>{this.map&&(this.viewer.geo=ua(this.map)),this.viewer.recomputeAnchors()}),h(this,`_contextLost`,!1),h(this,`_listenersAttached`,!1),h(this,`_onContextLost`,()=>{this._contextLost=!0}),h(this,`_onContextRestored`,()=>{this._contextLost=!1;let e=this.map;if(e){try{let t=e.getLayer,n=e.addLayer;if(!(typeof t==`function`&&t.call(e,this.id)))typeof n==`function`&&n.call(e,this);else{let e=this._mapGl();e&&this.viewer.restoreContext(e)}}catch(e){console.warn(`[s3m] WebGL 上下文恢复后重加图层失败,请手动 map.addLayer(layer)`,e)}e.triggerRepaint()}}),h(this,`_onClick`,e=>{if(!this.pickable)return;let t=this.pickFromEvent(e);t?(this.select(t),this.onPick(t)):this.select(null)}),this.id=e.id??`s3m`,this.options=e,this.pickable=e.pickable!==!1,this._projection=e.projection===`orthographic`?`orthographic`:`perspective`,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.viewer=new $i({configUrl:e.configUrl,datasets:e.datasets,style:e.style,ground:e.ground,pickable:e.pickable,maxTiles:e.maxTiles,maxConcurrent:e.maxConcurrent,lodRangeScale:e.lodRangeScale,buildTile:e.buildTile,light:e.light,totalMaxTiles:e.totalMaxTiles,attributes:e.attributes,onRequestRepaint:()=>this.map?.triggerRepaint(),getBearing:()=>this.map?.getBearing?.()??0,onStats:e=>this.onStats(e),onReady:e=>this.onReady(e),onPick:e=>this.onPick(e),onError:e=>this.onError(e)})}onAdd(e,t){this.map=e,this.viewer.renderer?this.viewer.restoreContext(t):this.viewer.mount(e.getCanvas(),t),this._listenersAttached||(e.on(`click`,this._onClick),typeof e.on==`function`&&(e.on(`projectiontransition`,this._onProjectionChange),e.on(`webglcontextlost`,this._onContextLost),e.on(`webglcontextrestored`,this._onContextRestored)),this._listenersAttached=!0)}onRemove(){this.map?.off(`click`,this._onClick),typeof this.map?.off==`function`&&(this.map.off(`projectiontransition`,this._onProjectionChange),this.map.off(`webglcontextlost`,this._onContextLost),this.map.off(`webglcontextrestored`,this._onContextRestored)),this._listenersAttached=!1,this._contextLost=!1,this.viewer.unmount(),this.viewer.geo=null,this.map=null}_extractMatrix(e){if(Array.isArray(e)||e instanceof Float64Array||e instanceof Float32Array)return e;let t=e;return t?.defaultProjectionData?.mainMatrix??t?.modelViewProjectionMatrix??null}_applyOrtho(e,t){let{nearZ:n,farZ:r}=aa(e),i=ia(e);if(!i)return this._warnOrtho(`render() 输入里没有独立的投影矩阵(需要 MapLibre ≥ 5)`),null;let a=sa({projectionMatrix:i,mvp:t.elements,nearZ:n,farZ:r},{distance:this.map?.transform?.cameraToCenterDistance??0,fov:this._frameFov(e),aspect:this._canvasAspect()});return a?a.matrix:(this._warnOrtho(`拿到的投影矩阵与 MVP 不同源(反推结果不是仿射变换)`),null)}_warnOrtho(e){this._orthoWarned||(this._orthoWarned=!0,console.warn(`[s3m] 正交模式不可用:${e},本帧保持透视`))}_frameFov(e){return oa(e,this.map?.transform?.fovInRadians)??.6435011087932844}_canvasAspect(){let e=this.map?.getCanvas?.();return!e||!e.height?1:e.width/e.height}setProjection(e){let t=e===`orthographic`?`orthographic`:`perspective`;this._projection!==t&&(this._projection=t,this._orthoWarned=!1,this.map?.triggerRepaint())}get projection(){return this._projection}render(e,n){let r=this.map,i=this.viewer.sceneAnchor;if(!r||!i||this._contextLost)return;let a=this._extractMatrix(n);if(!a)return;let o=new t.Matrix4().fromArray(a);this._projection===`orthographic`&&(o=this._applyOrtho(n,o)??o);let s=r.getCanvas(),c=i.meterInMercator,l=[0,0,0];try{let e=r.getFreeCameraOptions?.()?.position;e&&(l=[(e.x-i.x)/c,-(e.y-i.y)/c,(e.z-i.z)/c])}catch{}this.viewer.renderFrame({mvp:o.elements,cameraEnu:l,fovRad:this._frameFov(n),canvasHeight:s.height})&&r.triggerRepaint()}pickFromEvent(e){let t=this.map?.getCanvas();if(!t)return null;let n=t.getBoundingClientRect(),r=e.originalEvent??e;return this.viewer.pick(r.clientX-n.left,r.clientY-n.top)}pick(e,t){return this.viewer.pick(e,t)}pickPosition(e,t){return this.viewer.pickPosition(e,t)}drillPick(e,t,n=10){return this.viewer.drillPick(e,t,n)}getRayAt(e,t){return this.viewer.getRayAt(e,t)}select(e,t={}){this.viewer.select(e,t)}getFeatureBounds(e){return this.viewer.getFeatureBounds(e)}flyToFeature(e,t){let n=this.viewer.getFeatureBounds(e);if(!n||!this.map)return!1;let r=this.map;return typeof r.fitBounds==`function`&&(r.fitBounds(n,{padding:50,maxZoom:19,duration:1200,...t}),!0)}addDataset(e){return this.viewer.addDataset(e)}removeDataset(e){this.viewer.removeDataset(e)}clearDatasets(){this.viewer.clearDatasets()}setDatasetVisible(e,t){this.viewer.setDatasetVisible(e,t)}getDatasetHeight(e){return this.viewer.getDatasetHeight(e)}setDatasetHeight(e,t){this.viewer.setDatasetHeight(e,t)}setDatasetAlign(e,t){this.viewer.setDatasetAlign(e,t)}_computeAlignOffset(e,t){return this.viewer.computeAlignOffset(e,t)}setLight(e){this.viewer.setLight(e)}getLight(){return this.viewer.getLight()}setOpacity(e){this.viewer.setOpacity(e)}setStyle(e={}){this.viewer.setStyle(e)}getStyle(){return this.viewer.getStyle()}setEdges(e){this.viewer.setEdges(e)}setFeatureStyle(e,t){this.viewer.setFeatureStyle(e,t)}setFeaturesStyle(e,t){this.viewer.setFeaturesStyle(e,t)}getFeatureStyle(e){return this.viewer.getFeatureStyle(e)}getFeatureStyles(){return this.viewer.getFeatureStyles()}removeFeatureStyle(e){this.viewer.removeFeatureStyle(e)}clearFeatureStyles(){this.viewer.clearFeatureStyles()}setAttributeSource(e){this.viewer.setAttributeSource(e)}getLoadedSmids(){return this.viewer.getLoadedSmids()}auditBatches(){return this.viewer.auditBatches()}getThematicField(){return this.viewer.getThematicField()}setThematicColors(e,t=`custom`){this.viewer.setThematicColors(e,t)}clearThematic(){this.viewer.clearThematic()}getFilterField(){return this.viewer.getFilterField()}filterByField(e){return this.viewer.filterByField(e)}clearFieldFilter(){this.viewer.clearFieldFilter()}getElevationField(){return this.viewer.getElevationField()}elevateByField(e){return this.viewer.elevateByField(e)}setThematicElevation(e,t=`custom`){this.viewer.setThematicElevation(e,t)}clearThematicElevation(){this.viewer.clearThematicElevation()}colorByField(e){return this.viewer.colorByField(e)}setFilter(e){this.viewer.setFilter(e)}getFilter(){return this.viewer.getFilter()}clearFilter(){this.viewer.clearFilter()}setGroundMode(e){this.viewer.setGroundMode(e)}setGroundOpacity(e){this.viewer.setGroundOpacity(e)}setExcavationBounds(e){this.viewer.setExcavationBounds(e)}setGroundOcclude(e){this.viewer.setGroundOcclude(e)}get groundManager(){return this.viewer.groundManager}getAllMeshes(){return this.viewer.getAllMeshes()}flushOverrides(){this.viewer.flushOverrides()}_applyOverridesToMesh(e){this.viewer._applyOverridesToMesh(e)}get lodRangeScale(){return this.viewer.lodRangeScale}setLodRangeScale(e,t){this.viewer.setLodRangeScale(e,t)}get renderer(){return this.viewer.renderer}get scene(){return this.viewer.scene}get camera(){return this.viewer.camera}get picker(){return this.viewer.picker}get uniforms(){return this.viewer.uniforms}get style(){return this.viewer.style}get outlineMaterial(){return this.viewer.outlineMaterial}get lineShared(){return this.viewer.lineShared}get edgeMaterial(){return this.viewer.edgeMaterial}get selectionEdgeMaterial(){return this.viewer.selectionEdgeMaterial}get datasets(){return this.viewer.datasets}get sceneAnchor(){return this.viewer.sceneAnchor}set sceneAnchor(e){this.viewer.sceneAnchor=e}get attributeQuery(){return this.viewer.attributeQuery}get fps(){return this.viewer.fps}get stats(){return this.viewer.stats}getBounds(){return this.viewer.getBounds()}dispose(){this.onRemove()}},fa=u({AttributeQuery:()=>Ot,BinaryReader:()=>g,DEFAULT_FLOOR_HEIGHT:()=>St,DEFAULT_FOV:()=>ca,DEFAULT_STYLE:()=>Mr,DatasetManager:()=>Ui,EARTH_RADIUS:()=>kt,FeatureStyleManager:()=>Ji,GroundManager:()=>Yi,Picker:()=>Pi,PixelFormat:()=>X,S3MFormatError:()=>_t,S3MLayer:()=>da,S3MTileset:()=>bi,S3MViewer:()=>$i,S3M_VERSION:()=>Ve,SELECT_MODE:()=>$,SELECT_MODE_LABELS:()=>jr,STYLE:()=>Q,STYLE_LABELS:()=>Ar,TextureCompress:()=>U,VertexTag:()=>R,VertexTagV3:()=>He,buildAttributes:()=>xt,buildFeatureEdgeSegments:()=>Hi,buildOrthoMVP:()=>sa,buildThickLineGeometry:()=>zi,buildTileObjects:()=>si,createLineSharedUniforms:()=>Fi,createMapLibreGeoAdapter:()=>ua,createOutlineMaterial:()=>kr,createSharedUniforms:()=>Dr,createStyledMaterial:()=>Or,createTexture:()=>Tr,createThickLineMaterial:()=>Ri,default:()=>da,dxtPixelFormatOf:()=>gn,extractFovRadians:()=>oa,extractNearFar:()=>aa,extractProjectionMatrix:()=>ia,extractWorldCoordinateHelper:()=>la,isS3M1Buffer:()=>je,lngLatFromMercator:()=>jt,lngLatFromWorld:()=>Nt,measureSegments:()=>bt,mercatorFromLngLat:()=>At,parseS3M1:()=>Be,parseS3MB:()=>vt,resolveFeature:()=>V,resolveTextureKind:()=>hn,setMaxAnisotropy:()=>vr,worldFromLngLat:()=>Mt});Ct(),yn(),Z(),Wr(),ui();var pa=globalThis;return pa.THREE||(pa.THREE=t),pa.S3MMapLibre=fa,e.AttributeQuery=Ot,e.BinaryReader=g,e.DEFAULT_FLOOR_HEIGHT=St,e.DEFAULT_FOV=ca,e.DEFAULT_STYLE=Mr,e.DatasetManager=Ui,e.EARTH_RADIUS=kt,e.FeatureStyleManager=Ji,e.GroundManager=Yi,e.Picker=Pi,e.PixelFormat=X,e.S3MFormatError=_t,e.S3MLayer=da,e.default=da,e.S3MTileset=bi,e.S3MViewer=$i,e.S3M_VERSION=Ve,e.SELECT_MODE=$,e.SELECT_MODE_LABELS=jr,e.STYLE=Q,e.STYLE_LABELS=Ar,e.TextureCompress=U,e.VertexTag=R,e.VertexTagV3=He,e.buildAttributes=xt,e.buildFeatureEdgeSegments=Hi,e.buildOrthoMVP=sa,e.buildThickLineGeometry=zi,e.buildTileObjects=si,e.createLineSharedUniforms=Fi,e.createMapLibreGeoAdapter=ua,e.createOutlineMaterial=kr,e.createSharedUniforms=Dr,e.createStyledMaterial=Or,e.createTexture=Tr,e.createThickLineMaterial=Ri,e.dxtPixelFormatOf=gn,e.extractFovRadians=oa,e.extractNearFar=aa,e.extractProjectionMatrix=ia,e.extractWorldCoordinateHelper=la,e.isS3M1Buffer=je,e.lngLatFromMercator=jt,e.lngLatFromWorld=Nt,e.measureSegments=bt,e.mercatorFromLngLat=At,e.parseS3M1=Be,e.parseS3MB=vt,e.resolveFeature=V,e.resolveTextureKind=hn,e.setMaxAnisotropy=vr,e.worldFromLngLat=Mt,e})({},THREE);
@@ -4416,4 +4416,4 @@ void main() {
4416
4416
  }
4417
4417
  gl_FragColor = vec4(1.0);
4418
4418
  }
4419
- `}),i=new dc(e,r);i.position.set(0,0,-.02),i.renderOrder=-1e3,i.name=`s3m-ground-depth`,i.visible=!1,this.group.add(i),this._depthMesh=i,this._depthMaterial=r,this._syncUniforms()}_applyMode(){this._mesh&&(this._mesh.visible=this.mode!==`none`),this._material&&(this._material.uniforms.uMode.value=this.mode===`excavate`?2:+(this.mode===`translucent`),this._material.depthWrite=this.mode===`excavate`),this._depthMesh&&(this._depthMesh.visible=this.occlude,this._depthMaterial&&(this._depthMaterial.uniforms.uPunchPit.value=+(this.mode===`excavate`)))}update(e){e&&this.group.position.set(e.position.x,e.position.y,this.groundHeight)}setGroundHeight(e){this.groundHeight=e,this.group.position.z=e}setMode(e){this.mode=e,this._occludeExplicit||(this.occlude=e===`excavate`),this._applyMode()}setOcclude(e){this.occlude=e,this._occludeExplicit=!0,this._applyMode()}setOpacity(e){this.opacity=Math.max(0,Math.min(1,e)),this._material&&(this._material.uniforms.uOpacity.value=this.opacity)}setColors(e,t){this.color.set(e),t&&this.gridColor.set(t),this._material&&(this._material.uniforms.uColor.value=this.color,this._material.uniforms.uGridColor.value=this.gridColor)}setExcavationBounds(e){this.excavationBounds=e,this._syncUniforms()}autoFitExcavation(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=!1;for(let o of e){let e=o.tileset?.config,s=e?.rootTiles??e?.tiles;if(Array.isArray(s))for(let e of s){let s=e.boundingBox;if(!s)continue;let c=s.center??{x:0,y:0},l=s.xExtent?.x?Math.abs(s.xExtent.x):50,u=s.yExtent?.y?Math.abs(s.yExtent.y):50,d=c.x+o.offset[0]-l,f=c.x+o.offset[0]+l,p=c.y+o.offset[1]-u,m=c.y+o.offset[1]+u;d<t&&(t=d),f>r&&(r=f),p<n&&(n=p),m>i&&(i=m),a=!0}}a&&Number.isFinite(t)&&this.setExcavationBounds([t-5,n-5,r+5,i+5])}_syncUniforms(){let e=this.excavationBounds;if(this._material){let t=this._material.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}if(this._depthMaterial){let t=this._depthMaterial.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}}dispose(){this._geom?.dispose(),this._geom=null,this._material?.dispose(),this._material=null,this._depthMaterial?.dispose(),this._depthMaterial=null,this._mesh=null,this._depthMesh=null,this.group.clear()}};rh(),dy(),jy(),t_();var Lb=65534;function Rb(e){let t=Array.isArray(e.material)?e.material[0]:e.material;return t?.userData?.isStyled?t:null}function zb(e){return e.isPoints===!0}var Bb=class{get datasets(){return this._datasetManager.datasets}get sceneAnchor(){return this._datasetManager.sceneAnchor}set sceneAnchor(e){this._datasetManager.sceneAnchor=e}_requestRepaint(){this._onRequestRepaint()}triggerRepaint(){this._requestRepaint()}constructor(e={}){X(this,`options`,void 0),X(this,`pickable`,void 0),X(this,`onStats`,void 0),X(this,`onReady`,void 0),X(this,`onPick`,void 0),X(this,`onError`,void 0),X(this,`geo`,null),X(this,`canvas`,null),X(this,`renderer`,null),X(this,`scene`,null),X(this,`camera`,null),X(this,`picker`,null),X(this,`uniforms`,void 0),X(this,`style`,void 0),X(this,`outlineMaterial`,void 0),X(this,`lineShared`,void 0),X(this,`edgeMaterial`,void 0),X(this,`selectionEdgeMaterial`,void 0),X(this,`groundManager`,void 0),X(this,`_datasetManager`,new Ab),X(this,`_featureStyleManager`,void 0),X(this,`_pickables`,new Map),X(this,`_pickSeq`,0),X(this,`_freePickIds`,[]),X(this,`_smidMeshes`,new Map),X(this,`_meshHeight`,new Map),X(this,`_heightMin`,1/0),X(this,`_heightMax`,-1/0),X(this,`_boxScratch`,new ho),X(this,`_selection`,null),X(this,`_selectedMeshes`,[]),X(this,`_outlineMesh`,null),X(this,`_outlineMeshes`,[]),X(this,`_selectionEdges`,null),X(this,`_selectionEdgeMeshes`,[]),X(this,`_edgesEnabled`,!1),X(this,`attributeQuery`,null),X(this,`_enuMatrix`,new U),X(this,`_needsRepaint`,!0),X(this,`_frame`,0),X(this,`_fps`,{value:0,last:0}),X(this,`_ambientLight`,void 0),X(this,`_hemiLight`,void 0),X(this,`_keyLight`,void 0),X(this,`_fillLight`,void 0),X(this,`_lightOptions`,{ambientIntensity:.4,ambientColor:16777215,hemisphereIntensity:.8,hemisphereColor:16777215,hemisphereGroundColor:11976907,keyLightIntensity:1,keyLightColor:16777215,fillLightIntensity:.35,fillLightColor:16777215,mode:`headlamp`,azimuth:150,altitude:50}),X(this,`_datasetQueue`,void 0),X(this,`_onRequestRepaint`,()=>{}),X(this,`_getBearing`,void 0),X(this,`_lodRangeScale`,1),this.options=e,this.pickable=e.pickable!==!1,this._lodRangeScale=e.lodRangeScale??1,e.light&&Object.assign(this._lightOptions,e.light),e.totalMaxTiles&&(this._datasetManager.totalMaxTiles=e.totalMaxTiles),this._onRequestRepaint=e.onRequestRepaint??(()=>{}),this._getBearing=e.getBearing,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.groundManager=new Ib(e.ground),this.scene||(this.scene=new Wl,this.scene.add(this.groundManager.group),this._addLights()),this._featureStyleManager=new Fb(()=>this.style.floorHeight,()=>this._requestRepaint(),()=>{this._selection&&this._syncSelectionStyle()},()=>this.getAllMeshes(),e=>this._applyOverridesToMesh(e)),this.uniforms=fy(),this.style={...yy,...e.style??{}},this.outlineMaterial=my(this.uniforms),this.lineShared=Sb(),this.edgeMaterial=Tb(this.lineShared,{color:this.style.edgeColor,opacity:this.style.edgeOpacity??.45,width:this.style.edgeWidth??1.2}),this.selectionEdgeMaterial=Tb(this.lineShared,{color:this.style.outlineColor??this.style.selectColor,opacity:1,width:this.style.outlineWidthPx??3}),this._fps.last=performance.now(),this._datasetQueue=this._normalizeDatasets(e),e.attributes&&(this.attributeQuery=new o_(e.attributes))}mount(e,t){this.canvas=e,this.renderer=new Vl({canvas:e,context:t,antialias:!0}),this.renderer.autoClear=!1,this.renderer.setPixelRatio(1),this.renderer.toneMapping=4,this.renderer.toneMappingExposure=1,ty(this.renderer.capabilities.getMaxAnisotropy()),this.scene=new Wl,this.scene.add(this.groundManager.group),this._addLights(),this.camera=new _c,this.camera.matrixAutoUpdate=!1,this.picker=new xb(this.renderer),this._applyStyleUniforms();for(let e of this._datasetQueue)this.addDataset(e).catch(e=>this.onError(e));this._recomputeAnchors()}unmount(){for(let e of[...this.datasets.keys()])this.removeDataset(e);this.groundManager.dispose(),this.picker?.dispose(),this.picker=null,this.outlineMaterial.dispose(),this.edgeMaterial.dispose(),this.selectionEdgeMaterial.dispose(),this.scene?.clear(),this._selectedMeshes=[],this._outlineMeshes=[],this._selectionEdgeMeshes=[],this._outlineMesh=null,this._selectionEdges=null,this._smidMeshes.clear(),this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0,this.renderer?.dispose(),this.renderer=null,this.canvas=null}_createLights(){this._ambientLight=new mp(this._lightOptions.ambientColor,this._lightOptions.ambientIntensity),this._hemiLight=new ep(this._lightOptions.hemisphereColor,this._lightOptions.hemisphereGroundColor,this._lightOptions.hemisphereIntensity),this._keyLight=new pp(this._lightOptions.keyLightColor,this._lightOptions.keyLightIntensity),this._fillLight=new pp(this._lightOptions.fillLightColor,this._lightOptions.fillLightIntensity),this._updateLights()}_addLights(){this.scene&&(this._ambientLight||this._createLights(),this.scene.add(this._ambientLight,this._hemiLight,this._keyLight,this._fillLight))}_applyLightOptions(){this._ambientLight&&(this._ambientLight.intensity=this._lightOptions.ambientIntensity,this._ambientLight.color.set(this._lightOptions.ambientColor)),this._hemiLight&&(this._hemiLight.intensity=this._lightOptions.hemisphereIntensity,this._hemiLight.color.set(this._lightOptions.hemisphereColor),this._hemiLight.groundColor.set(this._lightOptions.hemisphereGroundColor)),this._keyLight&&(this._keyLight.intensity=this._lightOptions.keyLightIntensity,this._keyLight.color.set(this._lightOptions.keyLightColor)),this._fillLight&&(this._fillLight.intensity=this._lightOptions.fillLightIntensity,this._fillLight.color.set(this._lightOptions.fillLightColor))}setLight(e){Object.assign(this._lightOptions,e),this._applyLightOptions(),this._updateLights(),this._needsRepaint=!0,this.triggerRepaint()}getLight(){return{...this._lightOptions}}_updateLights(){if(!this._keyLight||!this._fillLight)return;let e=this._lightOptions.mode===`fixed`?0:(this._getBearing?.()??0)*Math.PI/180,t=(t,n,r)=>{if(!t)return;let i=e+n*Math.PI/180,a=r*Math.PI/180,o=Math.cos(a);t.position.set(Math.sin(i)*o,Math.cos(i)*o,Math.sin(a)).multiplyScalar(1e3)};t(this._keyLight,this._lightOptions.azimuth,this._lightOptions.altitude),t(this._fillLight,this._lightOptions.azimuth+65,Math.max(10,this._lightOptions.altitude-20))}_normalizeDatasets(e){return Array.isArray(e.datasets)?e.datasets.filter(e=>!!e?.configUrl):e.configUrl?[{id:`default`,name:`默认数据集`,configUrl:e.configUrl}]:[]}async addDataset(e){if(!this.scene)throw Error(`[s3m] 图层尚未 addLayer,不能添加数据集`);return await this._datasetManager.addDataset(e,this.scene,this.geo,this.uniforms,this._lodRangeScale,this.options.buildTile,this.options.maxTiles??64,this.options.maxConcurrent??4,{onTile:(e,t)=>{this._registerTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onTileRemoved:(e,t)=>{this._unregisterTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onStats:()=>{this.onStats(this.stats),this._requestRepaint()},onError:e=>{this.onError(e),this.onStats(this.stats)},onReady:e=>{this.onReady(e),this._refreshAllHeights(),this.groundManager.excavationBounds||this.groundManager.autoFitExcavation(this.datasets.values())},triggerRepaint:()=>{this._requestRepaint()}})}_lngLatFromWorld(e,t){return d_(this.geo,e,t)}recomputeAnchors(){this._datasetManager.recomputeAnchors(this.geo),this._refreshAllHeights(),this._requestRepaint()}_recomputeAnchors(){this.recomputeAnchors()}getDatasetHeight(e){return this._datasetManager.getDatasetHeight(e)}setDatasetHeight(e,t){let n,r;typeof e==`number`?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??0),this._datasetManager.setDatasetHeight(n,r,this.geo),this._syncGroundHeight(),this._refreshAllHeights(),this._requestRepaint()}_syncGroundHeight(){if(!this.groundManager.trackHeight)return;let e=this.datasets.keys().next().value;if(!e)return;let t=this._datasetManager.getDatasetHeight(e);this.groundManager.setGroundHeight(t)}setDatasetAlign(e,t){let n,r;t===void 0&&(e===`origin`||e===`bottom`||e===`top`||e===`center`)?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??`origin`),this._datasetManager.setDatasetAlign(n,r,this.geo),this._refreshAllHeights(),this._requestRepaint()}_computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}setFeatureStyle(e,t){this._featureStyleManager.setFeatureStyle(e,t,this._meshesOf([e]))}setFeaturesStyle(e,t){this._featureStyleManager.setFeaturesStyle(e,t,this._meshesOf(e))}getFeatureStyle(e){return this._featureStyleManager.getFeatureStyle(e)}getFeatureStyles(){return this._featureStyleManager.getFeatureStyles()}removeFeatureStyle(e){this._featureStyleManager.removeFeatureStyle(e,this._meshesOf([e]))}clearFeatureStyles(){this._featureStyleManager.clearFeatureStyles()}setAttributeSource(e){this.attributeQuery=e?new o_(e):null}getLoadedSmids(){return[...this._smidMeshes.keys()]}auditBatches(){let e=this._featureStyleManager.auditBatches(this._pickables.values());return e.smids=this._smidMeshes.size,e}getThematicField(){return this._featureStyleManager.thematicField}setThematicColors(e,t=`custom`){this._featureStyleManager.setThematicColors(e,t)}clearThematic(){this._featureStyleManager.clearThematicColors()}getFilterField(){return this._featureStyleManager.fieldFilter?.field??null}filterByField(e){return this._featureStyleManager.filterByField(e,this.attributeQuery,this.getLoadedSmids())}clearFieldFilter(){this._featureStyleManager.clearFieldFilter()}getElevationField(){return this._featureStyleManager.elevationField}elevateByField(e){return this._featureStyleManager.elevateByField(e,this.attributeQuery,this.getLoadedSmids())}setThematicElevation(e,t=`custom`){this._featureStyleManager.setThematicElevation(e,t)}clearThematicElevation(){this._featureStyleManager.clearThematicElevation()}colorByField(e){return this._featureStyleManager.colorByField(e,this.attributeQuery,this.getLoadedSmids())}setFilter(e){this._featureStyleManager.setFilter(e,this.uniforms)}getFilter(){return this._featureStyleManager.filter}clearFilter(){this._featureStyleManager.clearFilter(this.uniforms)}setGroundMode(e){this.groundManager.setMode(e),this._requestRepaint()}setGroundOpacity(e){this.groundManager.setOpacity(e),this._requestRepaint()}setExcavationBounds(e){this.groundManager.setExcavationBounds(e),this._requestRepaint()}setGroundOcclude(e){this.groundManager.setOcclude(e),this._requestRepaint()}_isFeatureHidden(e,t){if(e==null)return!1;let n=this._featureStyleManager.fieldFilter;if(n){let t=n.matched.has(e);if(n.mode===`keep`?!t:t)return!0}let r=this._featureStyleManager.filter;return!!(r&&(r.include&&r.include.length>0&&!r.include.includes(e)||r.exclude&&r.exclude.length>0&&r.exclude.includes(e))||this._featureStyleManager.featureStyles.get(e)?.hidden)}getAllMeshes(){let e=[];for(let t of this._pickables.values())e.push(t.mesh);return e}_meshesOf(e){let t=new Set;for(let n of e){let e=this._smidMeshes.get(n);if(e)for(let n of e)t.add(n)}return t}_markOverridesDirty(e=`all`){e===`all`?this._featureStyleManager.markOverridesDirty(void 0,this.getAllMeshes()):this._featureStyleManager.markOverridesDirty(e)}flushOverrides(){this._featureStyleManager.flushOverrides()}_applyOverridesToMesh(e){this._featureStyleManager.applyOverridesToMesh(e)}removeDataset(e){if(this.datasets.get(e)){this._selection?.datasetId===e&&this.select(null),this._datasetManager.removeDataset(e,this.scene,this.geo,e=>{e.root.traverse(e=>{let t=e,n=t.userData;n.pickId!=null&&(this._pickables.delete(n.pickId),this._releasePickId(n.pickId),n.pickId=void 0),this._unindexMeshSmids(t),this._removeMeshHeight(t),t.geometry?.dispose?.();let r=Rb(t);r&&r.dispose(),hb(t.material)&&t.material.dispose(),this._featureStyleManager.disposeMesh(t)})});for(let[t,n]of this._pickables)n.datasetId===e&&this._pickables.delete(t);this.onStats(this.stats),this._requestRepaint()}}clearDatasets(){for(let e of[...this.datasets.keys()])this.removeDataset(e)}setDatasetVisible(e,t){this._datasetManager.setDatasetVisible(e,t),!t&&this._selection?.datasetId===e&&this.select(null),this._requestRepaint()}_registerTile(e,t){t.root.add(e.group),e.group.updateMatrixWorld(!0);let n=e.group.userData.hasNativeEdges===!0;for(let r of e.group.children){if(r.isLineSegments&&r.userData.isEdgeLines){r.visible=this._edgesEnabled,this._styleEdgeLine(r);continue}let i=zb(r),a=r;if(!a.isMesh&&!i)continue;let o=a.userData;if(o.pickId=this._allocPickId(),o.datasetId=t.id,o.nativeEdges=n,this._pickables.set(o.pickId,{datasetId:t.id,mesh:a,tile:e.tile,skeletonName:o.skeletonName??``}),this._indexMeshSmids(a),this._addMeshHeight(a),this._edgesEnabled&&!n&&!i&&this._ensureEdges(a),i)this._applyPointCloudStyle(r);else{let e=Rb(a);if(e){let t=Math.min(1,Math.max(.05,this.style.opacity??1));e.opacity=t,e.transparent=t<.999,e.depthWrite=t>=.999,e.flatShading=this.style.shading!==`smooth`,e.needsUpdate=!0,this._featureStyleManager.applyOverridesToMesh(a)}}this._replaySelectionOnto(a)}}_isMeshCoveringSelection(e,t){if(!t.point)return!1;let n=e.geometry;if(!n||(n.boundingBox||n.computeBoundingBox(),!n.boundingBox))return!1;let r=new H(t.point[0],t.point[1],t.point[2]);e.updateWorldMatrix(!0,!1);let i=e.matrixWorld.clone().invert(),a=r.applyMatrix4(i);return n.boundingBox.clone().expandByScalar(.5).containsPoint(a)}_replaySelectionOnto(e){let t=this._selection;if(!t)return;let n=Rb(e);if(!n)return;let r=e.userData,i=-1;if(t.smid!=null){let e=r.geoRef?.pickInfo,n=e?.[t.smid]??e?.[String(t.smid)];i=n?Jg(n):-1}if(e===t.mesh&&(i=t.batchId),i<0&&e!==t.mesh){if(t.smid==null&&r.datasetId===t.datasetId&&this._isMeshCoveringSelection(e,t))i=-1;else return}n.userData.uSelBatch.value=i,n.userData.uSelWhole.value=+(i<0),this._selectedMeshes.includes(e)||this._selectedMeshes.push(e),zb(e)&&this._applyPointCloudStyle(e,!0),this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers}_unregisterTile(e,t){e.group.traverse(e=>{let t=e;if(t.userData?.pickId!=null&&(this._pickables.delete(t.userData.pickId),this._releasePickId(t.userData.pickId),t.userData.pickId=void 0),t.isMesh){this._selectedMeshes.includes(t)&&(this._selectedMeshes=this._selectedMeshes.filter(e=>e!==t));let e=this._selection;if(e&&e.mesh===t){let n=e.smid,r=n==null?this._selectedMeshes.find(e=>e!==t&&e.parent&&e.parent.visible)??this._selectedMeshes.find(e=>e!==t&&e.parent):[...this._smidMeshes.get(n)??[]].find(e=>e!==t&&e.parent);r?(this._selection={...e,mesh:r},this._replaySelectionOnto(r)):this.select(null)}this._unindexMeshSmids(t),this._removeMeshHeight(t),this._featureStyleManager.disposeMesh(t),Rb(t)?.dispose?.()}hb(t.material)?t.material.dispose():t.material&&(Array.isArray(t.material)?t.material.forEach(e=>e?.dispose?.()):t.material.dispose?.()),t.geometry?.dispose?.()}),t.root.remove(e.group)}_allocPickId(){let e=this._freePickIds.pop();if(e!==void 0)return e;if(this._pickSeq>Lb){for(let e=0;e<=Lb;e++)if(!this._pickables.has(e))return e;throw Error(`[s3m] 可拾取网格超过 65535 个,2 字节 ID 编码不够用`)}return this._pickSeq++}_releasePickId(e){this._freePickIds.push(e)}setOpacity(e){this.setStyle({opacity:e})}setStyle(e={}){this.style={...this.style,...e},this._applyStyleUniforms(),(`opacity`in e||`depthWrite`in e)&&this._applyOpacity(),`mode`in e&&this._applyPointCloudStyles(),`shading`in e&&this._applyShading(),`edges`in e?this.setEdges(!!this.style.edges):(`edgeColor`in e||`edgeWidth`in e||`opacity`in e||`edgeOpacity`in e)&&this._refreshEdgeLines(),this._selection&&(`outline`in e||`outlineStyle`in e?this.select(this._selection,{silent:!0}):this._syncSelectionStyle()),this._requestRepaint()}getStyle(){return{...this.style,modeLabel:gy[this.style.mode]}}_applyStyleUniforms(){let e=this.uniforms,t=this.style;e.uMode.value=t.mode,e.uColorA.value.set(t.colorA),e.uColorB.value.set(t.colorB),e.uColorC.value.set(t.colorC),e.uSelColor.value.set(t.selectColor),e.uFloorHeight.value=t.floorHeight;let n=t.selectMode??_y.OVERLAY;e.uSelMode&&(e.uSelMode.value=n===_y.REPLACE?0:n===_y.MULTIPLY?2:n===_y.GLOW_ONLY?3:1),e.uSelOpacity&&t.selectOpacity!=null&&(e.uSelOpacity.value=t.selectOpacity),e.uSelEmissive&&t.selectEmissive!=null&&(e.uSelEmissive.value=t.selectEmissive),e.uSelElevation&&t.selectElevation!=null&&(e.uSelElevation.value=t.selectElevation),e.uDimFactor&&t.dimFactor!=null&&(e.uDimFactor.value=t.dimFactor),e.uRoofThreshold&&t.roofThreshold!=null&&(e.uRoofThreshold.value=t.roofThreshold),e.uTexMix&&t.texMix!=null&&(e.uTexMix.value=t.texMix),this.outlineMaterial&&(this.outlineMaterial.uniforms.uElevation&&t.selectElevation!=null&&(this.outlineMaterial.uniforms.uElevation.value=t.selectElevation),t.outlineWidth!=null&&(this.outlineMaterial.uniforms.uWidth.value=t.outlineWidth),t.outlineColor==null?this.outlineMaterial.uniforms.uColor.value.set(t.selectColor):this.outlineMaterial.uniforms.uColor.value.set(t.outlineColor))}_applyOpacity(){let e=Math.min(1,Math.max(.05,this.style.opacity??1)),t=e<.999,n=this.style.depthWrite!==!1;for(let r of this._pickables.values()){if(zb(r.mesh)){this._applyPointCloudStyle(r.mesh);continue}let i=Rb(r.mesh);i&&(i.opacity=e,i.transparent=t,i.depthWrite=!t||n)}this._requestRepaint()}_applyPointCloudStyle(e,t=this._selectedMeshes.includes(e)){mb(e,this.style,this.uniforms,t)}_applyPointCloudStyles(){for(let e of this._pickables.values())zb(e.mesh)&&this._applyPointCloudStyle(e.mesh);this._requestRepaint()}_applyShading(){let e=this.style.shading!==`smooth`;for(let t of this._pickables.values()){let n=Rb(t.mesh);n&&n.flatShading!==e&&(n.flatShading=e,n.needsUpdate=!0)}this._requestRepaint()}_addMeshHeight(e){let t=e.geometry?.boundingBox;if(!t)return;this._boxScratch.copy(t).applyMatrix4(e.matrixWorld);let n=this._boxScratch.min.z,r=this._boxScratch.max.z;Number.isFinite(n)&&Number.isFinite(r)&&(this._meshHeight.set(e,{min:n,max:r}),n<this._heightMin&&(this._heightMin=n),r>this._heightMax&&(this._heightMax=r),this._pushHeightRange())}_removeMeshHeight(e){let t=this._meshHeight.get(e);t&&(this._meshHeight.delete(e),t.min===this._heightMin||t.max===this._heightMax?this._recomputeHeightRange():this._pushHeightRange())}_refreshAllHeights(){if(this._meshHeight.size===0)return;let e=[...this._meshHeight.keys()];this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0;for(let t of e)this._addMeshHeight(t);this._pushHeightRange()}_recomputeHeightRange(){let e=1/0,t=-1/0;for(let n of this._meshHeight.values())n.min<e&&(e=n.min),n.max>t&&(t=n.max);this._heightMin=e,this._heightMax=t,this._pushHeightRange()}_pushHeightRange(){let e=this._heightMin,t=this._heightMax;(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)&&(e=0,t=100),this.uniforms.uHeightMin.value=e,this.uniforms.uHeightMax.value=t}_indexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n);if(!Number.isFinite(t)||t<0)continue;let r=this._smidMeshes.get(t);r||this._smidMeshes.set(t,r=new Set),r.add(e)}}_unindexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n),r=this._smidMeshes.get(t);r&&(r.delete(e),r.size===0&&this._smidMeshes.delete(t))}}setEdges(e){this._edgesEnabled=e,this.style.edges=e;for(let t of this.datasets.values())t.root.traverse(t=>{t.userData.isEdgeLines&&(t.visible=e,this._styleEdgeLine(t))});if(this._syncEdgeStyle(),!e){for(let e of this._pickables.values())this._removeEdges(e.mesh);this._requestRepaint();return}let t=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e.userData;return!t.edges&&!t.nativeEdges&&!zb(e)}),n=0,r=()=>{let e=performance.now();for(;n<t.length&&performance.now()-e<8;)this._ensureEdges(t[n++]);n<t.length?setTimeout(r,0):this._requestRepaint()};r()}_syncEdgeStyle(){let e=this.style,t=this.edgeMaterial.uniforms;t.uColor.value.set(e.edgeColor),t.uWidth.value=Math.max(.1,e.edgeWidth??1.2),t.uOpacity.value=Math.min(1,Math.max(0,e.edgeOpacity??.45))*Math.min(1,Math.max(.05,e.opacity??1))}_styleEdgeLine(e){let t=e.material;t&&t.color&&(t.color.set(this.style.edgeColor),t.opacity=(this.style.edgeOpacity??.45)*Math.min(1,Math.max(.05,this.style.opacity??1)),t.transparent=!0,t.polygonOffset=!0,t.polygonOffsetFactor=-1,t.polygonOffsetUnits=-1,t.needsUpdate=!0)}_refreshEdgeLines(){this._syncEdgeStyle();for(let e of this.datasets.values())e.root.traverse(e=>{e.userData.isEdgeLines&&this._styleEdgeLine(e)})}_ensureEdges(e){let t=e.userData;if(t.edges||t.nativeEdges||!e.geometry||(e.geometry.index?.count??0)>12e4)return;let n=new Qd(e.geometry,40),r=n.getAttribute(`position`),i=r?r.array:null;if(n.dispose(),!i||i.length<6)return;let a=new dc(Eb(i),this.edgeMaterial);a.renderOrder=2,a.frustumCulled=!1,a.raycast=()=>{},a.userData.isThickEdge=!0,t.edges=a,e.add(a)}_removeEdges(e){let t=e.userData,n=t.edges;n&&(e.remove(n),n.geometry?.dispose(),t.edges=null)}getRayAt(e,t){if(!this.camera||!this.canvas)return null;let n=this.canvas,r=n.clientWidth||n.width,i=n.clientHeight||n.height;if(!r||!i)return null;let a=e/r*2-1,o=-(t/i)*2+1,s=new H(a,o,-1).unproject(this.camera),c=new H(a,o,1).unproject(this.camera).clone().sub(s).normalize();return new Bo(s,c)}_intersectMeshAtRay(e,t,n){let r=new gm;r.ray.copy(t);let i=r.intersectObject(e,!1);if(!i.length)return null;if(n!=null){let e=i.find(e=>e.instanceId===n);return e?e.point:i[0].point}return i[0].point}_buildPickResult(e,t,n,r){let i=t.mesh.userData,a=null,o=e.batchId,s=e.instanceIndex,c=i.geoRef,l=[];if(s!=null){let e=this._instanceFeature(t.mesh,c,s);if(!e)return null;a=e.smid,o=e.batchId}else{c=i.geoByBatchId?.get(e.batchId)??i.geoRef;let t=Xg(c,e.batchId);a=t.smid,l=t.segments}if(this._isFeatureHidden(a,o))return null;let u=null,d=0;if(s!=null)u=this._instanceBox(t.mesh,s),d=t.mesh.geometry.index?Math.round(t.mesh.geometry.index.count/3):0;else if(a!=null&&this._smidMeshes.has(a)){let e=this._smidMeshes.get(a),t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,s=-1/0,c=0;for(let l of e){let e=l.userData,u=e.geoRef?.pickInfo,f=u?.[a]??u?.[String(a)],p=f?Jg(f):-1,m=f?.segments??(p>=0?Xg(e.geoRef,p).segments:[]),h=Zg(l.geometry,m);h&&(h.minX<t&&(t=h.minX),h.minY<n&&(n=h.minY),h.minZ<r&&(r=h.minZ),h.maxX>i&&(i=h.maxX),h.maxY>o&&(o=h.maxY),h.maxZ>s&&(s=h.maxZ),c+=h.count,d+=h.triangles)}c>0&&(u={minX:t,minY:n,minZ:r,maxX:i,maxY:o,maxZ:s,count:c,triangles:d})}if(!u&&(u=Zg(t.mesh.geometry,l),!u&&t.mesh.geometry)){t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let e=t.mesh.geometry.boundingBox;e&&(u={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}let f=t.mesh.geometry,p=d>0?d:f.index?Math.round(f.index.count/3):0,m=Qg({smid:a,box:u,triangles:p,floorHeight:this.style.floorHeight}),h=null;if(u&&this.sceneAnchor){let e=new H((u.minX+u.maxX)/2,(u.minY+u.maxY)/2,(u.minZ+u.maxZ)/2);e.applyMatrix4(t.mesh.matrixWorld);let n=this.sceneAnchor.meterInMercator;h=this._lngLatFromWorld(e.x*n+this.sceneAnchor.x,-e.y*n+this.sceneAnchor.y)}let g=n??null;!g&&r&&(g=this._intersectMeshAtRay(t.mesh,r,s));let _=null,v=null,y=null;if(g&&this.sceneAnchor){let e=a==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(a),t=e.translation,n=e.elevation,r=g.clone();t?r.add(new H(t[0],t[1],t[2])):n&&(r.z+=n),_=[r.x,r.y,r.z];let i=this.sceneAnchor.meterInMercator;v=this._lngLatFromWorld(r.x*i+this.sceneAnchor.x,-r.y*i+this.sceneAnchor.y),y=r.z+(this.sceneAnchor.altitude??0)}else h&&u&&this.sceneAnchor&&(v=h,y=(u.minZ+u.maxZ)/2+(this.sceneAnchor.altitude??0));return{datasetId:t.datasetId,datasetName:this.datasets.get(t.datasetId)?.name??t.datasetId,objectId:e.objectId,batchId:o,instanceIndex:s,skeletonName:t.skeletonName,centerLngLat:h,point:_,lngLat:v,altitude:y,...m,mesh:t.mesh}}pick(e,t){if(!this.picker||!this.scene||!this.camera||!this.sceneAnchor)return null;let n=this.picker.pick(this.scene,this.camera,e,t);if(!n)return null;let r=this._pickables.get(n.objectId);if(!r)return null;let i=this.getRayAt(e,t);return this._buildPickResult(n,r,void 0,i??void 0)}pickPosition(e,t){if(!this.camera||!this.sceneAnchor)return null;let n=this.pick(e,t);if(n?.point&&n?.lngLat&&n.altitude!=null)return{lngLat:n.lngLat,altitude:n.altitude,point:n.point};let r=this.getRayAt(e,t);if(!r)return null;let i=new Ac(new H(0,0,1),0),a=new H,o=r.intersectPlane(i,a);if(o){let e=this.sceneAnchor.meterInMercator;return{lngLat:this._lngLatFromWorld(o.x*e+this.sceneAnchor.x,-o.y*e+this.sceneAnchor.y),altitude:o.z+(this.sceneAnchor.altitude??0),point:[o.x,o.y,o.z]}}return null}drillPick(e,t,n=10){if(!this.sceneAnchor||!this.camera)return[];let r=this.getRayAt(e,t);if(!r)return[];let i=new gm;i.ray.copy(r);let a=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}),o=i.intersectObjects(a,!1);if(!o.length)return[];let s=[],c=new Set,l=new Set;for(let e of o){if(s.length>=n)break;let t=e.object,r=t.userData;if(r.pickId==null)continue;let i=this._pickables.get(r.pickId);if(!i)continue;let a=null,o=-1,u=e.instanceId;if(u!=null){let e=this._instanceFeature(t,r.geoRef,u);if(!e)continue;a=e.smid,o=e.batchId}else if(e.faceIndex!=null){let n=t.geometry.attributes.aBatchId;if(n){let i=t.geometry.index?t.geometry.index.getX(e.faceIndex*3):e.faceIndex*3;o=Math.round(n.getX(i)),a=Xg(r.geoByBatchId?.get(o)??r.geoRef,o).smid}}if(a!=null){if(c.has(a))continue;c.add(a)}else{let e=`${r.pickId}:${o}:${u??-1}`;if(l.has(e))continue;l.add(e)}if(this._isFeatureHidden(a,o))continue;let d={objectId:r.pickId,batchId:o,instanceIndex:u},f=this._buildPickResult(d,i,e.point);f&&s.push(f)}return s}getFeatureBounds(e){if(!this.sceneAnchor)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0,a=!1;for(let o of this._pickables.values()){let s=o.mesh,c=s.userData,l=c.geoRef,u=l?.pickInfo;if(!u)continue;let d=null;if(s.isInstancedMesh){let t=c.instanceLookup;t||(t=Yg(u),c.instanceLookup=t);for(let[n,r]of t)if(r.smid===e){d=this._instanceBox(s,n);break}}else{let t=u,n=t[e]??t[String(e)];if(n){let e=Xg(l,Jg(n));if(d=Zg(s.geometry,e.segments),!d&&s.geometry){s.geometry.boundingBox||s.geometry.computeBoundingBox();let e=s.geometry.boundingBox;e&&(d={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}}}if(d){a=!0;let o=[new H(d.minX,d.minY,d.minZ),new H(d.maxX,d.minY,d.minZ),new H(d.minX,d.maxY,d.minZ),new H(d.maxX,d.maxY,d.minZ),new H(d.minX,d.minY,d.maxZ),new H(d.maxX,d.minY,d.maxZ),new H(d.minX,d.maxY,d.maxZ),new H(d.maxX,d.maxY,d.maxZ)],c=e==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(e),l=c.translation,u=c.elevation;for(let e of o){l?e.add(new H(l[0],l[1],l[2])):u&&(e.z+=u),e.applyMatrix4(s.matrixWorld);let a=this.sceneAnchor.meterInMercator,[o,c]=this._lngLatFromWorld(e.x*a+this.sceneAnchor.x,-e.y*a+this.sceneAnchor.y);o<t&&(t=o),o>n&&(n=o),c<r&&(r=c),c>i&&(i=c)}}}return a?[[t,r],[n,i]]:null}_instanceFeature(e,t,n){let r=e.userData;return r.instanceLookup||(r.instanceLookup=Yg(t?.pickInfo)),r.instanceLookup.get(n)??null}_instanceBox(e,t){let n=e;if(!n.isInstancedMesh)return null;let r=e.geometry;r.boundingBox||r.computeBoundingBox();let i=r.boundingBox;if(!i)return null;let a=new U;n.getMatrixAt(t,a);let o=i.clone().applyMatrix4(a);return{minX:o.min.x,minY:o.min.y,minZ:o.min.z,maxX:o.max.x,maxY:o.max.y,maxZ:o.max.z,count:r.getAttribute(`position`)?.count??0,triangles:r.index?Math.round(r.index.count/3):0}}select(e,{silent:t=!1}={}){if(this._selection){for(let e of this._selectedMeshes){if(zb(e)){this._applyPointCloudStyle(e,!1);continue}let t=Rb(e);t&&(t.userData.uSelBatch.value=-1,t.userData.uSelWhole.value=0)}this._selectedMeshes=[],this._clearSelectionDecoration(),this._selection=null}if(!e){this.uniforms.uSelMix.value=0,this.uniforms.uDim.value=0,this.outlineMaterial.uniforms.uSelBatch.value=-1,this.outlineMaterial.uniforms.uSelWhole.value=0,this.outlineMaterial.uniforms.uElevation.value=0,this._requestRepaint(),t||this.onPick(null);return}this._selection=e;let n=new Set;if(e.smid!=null){let t=this._smidMeshes.get(e.smid);if(t)for(let e of t)n.add(e)}n.add(e.mesh);for(let t of n){let n=Rb(t);if(!n)continue;let r=e.batchId;if(e.instanceIndex!=null&&t===e.mesh)r=e.batchId;else if(e.smid!=null){let n=t.userData.geoRef?.pickInfo,i=n?.[e.smid]??n?.[String(e.smid)],a=i?Jg(i):-1;r=a>=0?a:t===e.mesh?e.batchId:-1}n.userData.uSelBatch.value=r,n.userData.uSelWhole.value=+(r<0),this._selectedMeshes.push(t)}for(let e of this._selectedMeshes)zb(e)&&this._applyPointCloudStyle(e,!0);if(this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers,this.style.outline){let t=[...n].filter(e=>!zb(e));t.length&&((this.style.outlineStyle??`edges`)===`edges`?this._addSelectionEdges(e,t):this._addSelectionHull(e,t))}this._requestRepaint()}_addSelectionEdges(e,t){this._syncSelectionStyle();for(let n of t){let t=n.userData,r=t.geoRef,i=[];if(n===e.mesh&&e.instanceIndex!=null)i=[{vertexOffset:0,vertexCount:n.geometry.getAttribute(`position`)?.count??0}];else if(e.smid!=null){let t=r?.pickInfo,n=t?.[e.smid]??t?.[String(e.smid)],a=n?Jg(n):-1;i=n?.segments??(a>=0?Xg(r,a).segments:[])}else n===e.mesh&&(i=Xg(t.geoByBatchId?.get(e.batchId)??r,e.batchId).segments);let a=kb(n.geometry,i);if(a&&a.length>0){let t=new dc(Eb(a),this.selectionEdgeMaterial);t.renderOrder=4,t.frustumCulled=!1,t.raycast=()=>{},t.userData.isSelectionEdge=!0,n===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(t,e),n.add(t),this._selectionEdgeMeshes.push(t)}}this._selectionEdgeMeshes.length===0?this._addSelectionHull(e,t):this._selectionEdges=this._selectionEdgeMeshes[0]??null}_applyInstanceTransform(e,t){let n=t.mesh;if(t.instanceIndex==null||!n.isInstancedMesh)return;let r=new U;n.getMatrixAt(t.instanceIndex,r),r.decompose(e.position,e.quaternion,e.scale)}_addSelectionHull(e,t){let n=e.instanceIndex!=null;this.outlineMaterial.uniforms.uSelBatch.value=n?-1:e.batchId,this.outlineMaterial.uniforms.uSelWhole.value=n||e.batchId<0?1:0,this.outlineMaterial.uniforms.uElevation.value=n?this._selectionElevation(e):this.style.selectElevation??0;for(let n of t){let t=Rb(n);t?.userData?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=t.userData.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=t.userData.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=t.userData.uBatchTexActive.value);let r=new dc(n.geometry,this.outlineMaterial);r.renderOrder=3,r.frustumCulled=!1,r.raycast=()=>{},n===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(r,e),n.add(r),this._outlineMeshes.push(r)}this._outlineMesh=this._outlineMeshes[0]??null}_syncSelectionStyle(){let e=this.style,t=this.selectionEdgeMaterial.uniforms;t.uColor.value.set(e.outlineColor??e.selectColor),t.uWidth.value=Math.max(.1,e.outlineWidthPx??3),t.uOpacity.value=Math.min(1,Math.max(.05,e.opacity??1)),t.uElevation.value=this._selection?this._selectionElevation(this._selection):0;for(let e of this._outlineMeshes){let t=e.parent,n=t?Rb(t)?.userData:null;n?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=n.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=n.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=n.uBatchTexActive.value)}}_selectionElevation(e){let t=this.style.selectElevation??0;if(e.smid!=null){let n=this._featureStyleManager.getFeatureEffectiveOffset(e.smid);n.elevation&&(t+=n.elevation)}return t}_clearSelectionDecoration(){for(let e of this._outlineMeshes)e.parent?.remove(e);this._outlineMeshes=[],this._outlineMesh=null;for(let e of this._selectionEdgeMeshes)e.parent?.remove(e),e.geometry.dispose();this._selectionEdgeMeshes=[],this._selectionEdges=null}_updateLineResolution(e){let t=e.width||1,n=e.height||1,r=e.clientWidth||t;this.lineShared.uResolution.value.set(t,n),this.lineShared.uDpr.value=Math.max(1,t/r)}get lodRangeScale(){return this._lodRangeScale}setLodRangeScale(e,t){if(!(e<=0)){if(t){let n=this.datasets.get(t);n?.tileset&&(n.tileset.lodRangeScale=e)}else{this._lodRangeScale=e;for(let t of this.datasets.values())t.tileset&&(t.tileset.lodRangeScale=e)}this._requestRepaint()}}renderFrame(e){if(!this.renderer||!this.scene||!this.camera||!this.sceneAnchor||!this.canvas)return!1;this.flushOverrides();let t=this.canvas,n=this.sceneAnchor.meterInMercator;this._enuMatrix.set(n,0,0,this.sceneAnchor.x,0,-n,0,this.sceneAnchor.y,0,0,n,this.sceneAnchor.z,0,0,0,1);let r=new U().fromArray(e.mvp);r.multiply(this._enuMatrix),this.camera.projectionMatrix.copy(r),this.camera.projectionMatrixInverse.copy(r).invert();let i=e.cameraEnu;this.camera.position.set(i[0],i[1],i[2]),this.camera.matrixWorld.setPosition(i[0],i[1],i[2]),this.camera.matrixWorldInverse.copy(this.camera.matrixWorld).invert(),this.groundManager.update(this.camera);let a=!1;for(let t of this.datasets.values()){if(!t.visible||!t.tileset)continue;let n=[i[0]-t.offset[0],i[1]-t.offset[1],i[2]-t.offset[2]];t.tileset.update(n,e.fovRad,e.canvasHeight)&&(a=!0)}this.style.mode===hy.DYNAMIC&&(this.uniforms.uTime.value+=.016*(this.style.speed??1)),this._updateLights(),this._updateLineResolution(t),this.renderer.setViewport(0,0,t.width,t.height),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this._frame++;let o=performance.now();return o-this._fps.last>500&&(this._fps.value=Math.round(this._frame*1e3/(o-this._fps.last)),this._frame=0,this._fps.last=o),this.style.mode===hy.DYNAMIC||this.stats.loading>0||a}get fps(){return this._fps.value}get stats(){let e={tiles:0,loading:0,failed:0,meshes:0,vertices:0,triangles:0,datasets:this.datasets.size};for(let t of this.datasets.values()){let n=t.tileset?.stats;n&&(e.tiles+=n.tiles,e.loading+=n.loading,e.failed+=n.failed,e.meshes+=n.meshes,e.vertices+=n.vertices,e.triangles+=n.triangles)}return e}getBounds(){let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of this.datasets.values()){let a=ib(i.tileset?.config?.geoBounds);a&&(e=Math.min(e,a.left),n=Math.max(n,a.right),t=Math.min(t,a.bottom),r=Math.max(r,a.top))}return isFinite(e)?[[e,t],[n,r]]:null}dispose(){this.unmount()}};rh();var Vb=1e-4;function Hb(e,t){let n=e.elements;for(let e=0;e<16;e++){let r=Math.max(1,Math.abs(n[e]),Math.abs(t[e]));if(Math.abs(n[e]-t[e])>Vb*r)return!1}return!0}function Ub(e){let t=e.elements,n=1;for(let e=0;e<16;e++){let r=Math.abs(t[e]);r>n&&(n=r)}let r=1e-6*n;return Math.abs(t[3])<r&&Math.abs(t[7])<r&&Math.abs(t[11])<r&&Math.abs(t[15]-1)<r}function Wb(e,t){return t>0&&Math.abs(e.elements[5]*Math.tan(t/2)-1)<.001}function Gb(e){if(!e||typeof e!=`object`)return null;let t=e;return t.defaultProjectionData?.projectionMatrix??t.projectionMatrix??null}function Kb(e){let t={nearZ:null,farZ:null};if(!e||typeof e!=`object`)return t;let n=e,r=n.defaultProjectionData,i=e=>{let t=n[e];if(typeof t==`number`&&Number.isFinite(t))return t;let i=r?.[e];return typeof i==`number`&&Number.isFinite(i)?i:null};return{nearZ:i(`nearZ`),farZ:i(`farZ`)}}function qb(e,t){if(e&&typeof e==`object`){let t=e.fov;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return t}return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function Jb(e,t){let n=e.projectionMatrix;if(!n||n.length<16)return null;let r=new U().fromArray(Array.from(n)),i=new U().fromArray(Array.from(e.mvp));if(r.determinant()===0||!Wb(r,t.fov))return null;let a=r.clone().invert().multiply(i);if(!Hb(r.clone().multiply(a),Array.from(e.mvp))||!Ub(a)||!Wb(r,t.fov))return null;let{distance:o,fov:s,aspect:c}=t;if(!(o>0)||!(s>0)||!(c>0))return null;let l=o*Math.tan(s/2),u=l*c,d=e.nearZ!=null&&e.nearZ>0?e.nearZ:1,f=e.farZ!=null&&e.farZ>d?e.farZ:o*4+1e3;f>d||(f=d+1e3);let p=new zc(-u,u,l,-l,d,f);return p.updateProjectionMatrix(),{matrix:p.projectionMatrix.clone().multiply(a),view:a}}var Yb=.6435011087932844;function Xb(e){let t=e,n=t?.transform?.worldCoordinateHelper??t?.transform?.projection?.worldCoordinateHelper??t?.painter?.transform?.worldCoordinateHelper??(typeof t?.getProjection==`function`?t.getProjection()?.worldCoordinateHelper:null)??null;return n&&typeof n.worldFromLngLat==`function`&&typeof n.lngLatFromWorld==`function`?n:null}function Zb(e){let t=Xb(e);return t?{worldFromLngLat(e,n,r=0){let i=t.worldFromLngLat(e,n,r),a=0;if(typeof t.metersPerWorldUnit==`function`){let e=t.metersPerWorldUnit(i.x,i.y);Number.isFinite(e)&&e>0&&(a=1/e)}if(a===0){let o=t.worldFromLngLat(e,n,r+1),s=Math.abs((o.z??0)-(i.z??0));Math.sin(n*Math.PI/180),a=s>0?s:1/(2*Math.PI*6378137)/Math.cos(n*Math.PI/180)}return{x:i.x,y:i.y,z:i.z??r*a,meterInMercator:a,altitude:r}},lngLatFromWorld(e,n){let r=t.lngLatFromWorld(e,n);return Array.isArray(r)?[r[0],r[1]]:r&&typeof r.lng==`number`&&typeof r.lat==`number`?[r.lng,r.lat]:[0,0]}}:null}rh();var Qb=class{get map(){return this._map}set map(e){this._map=e,this.viewer.geo=e?Zb(e):null}constructor(e={}){X(this,`id`,void 0),X(this,`type`,`custom`),X(this,`renderingMode`,`3d`),X(this,`options`,void 0),X(this,`pickable`,void 0),X(this,`onStats`,void 0),X(this,`onReady`,void 0),X(this,`onPick`,void 0),X(this,`onError`,void 0),X(this,`_map`,null),X(this,`viewer`,void 0),X(this,`_orthoWarned`,!1),X(this,`_projection`,`perspective`),X(this,`_onProjectionChange`,()=>{this.map&&(this.viewer.geo=Zb(this.map)),this.viewer.recomputeAnchors()}),X(this,`_onClick`,e=>{if(!this.pickable)return;let t=this.pickFromEvent(e);t?(this.select(t),this.onPick(t)):this.select(null)}),this.id=e.id??`s3m`,this.options=e,this.pickable=e.pickable!==!1,this._projection=e.projection===`orthographic`?`orthographic`:`perspective`,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.viewer=new Bb({configUrl:e.configUrl,datasets:e.datasets,style:e.style,ground:e.ground,pickable:e.pickable,maxTiles:e.maxTiles,maxConcurrent:e.maxConcurrent,lodRangeScale:e.lodRangeScale,buildTile:e.buildTile,light:e.light,totalMaxTiles:e.totalMaxTiles,attributes:e.attributes,onRequestRepaint:()=>this.map?.triggerRepaint(),getBearing:()=>this.map?.getBearing?.()??0,onStats:e=>this.onStats(e),onReady:e=>this.onReady(e),onPick:e=>this.onPick(e),onError:e=>this.onError(e)})}onAdd(e,t){this.map=e,this.viewer.mount(e.getCanvas(),t),e.on(`click`,this._onClick),typeof e.on==`function`&&e.on(`projectiontransition`,this._onProjectionChange)}onRemove(){this.map?.off(`click`,this._onClick),typeof this.map?.off==`function`&&this.map.off(`projectiontransition`,this._onProjectionChange),this.viewer.unmount(),this.viewer.geo=null,this.map=null}_extractMatrix(e){if(Array.isArray(e)||e instanceof Float64Array||e instanceof Float32Array)return e;let t=e;return t?.defaultProjectionData?.mainMatrix??t?.modelViewProjectionMatrix??null}_applyOrtho(e,t){let{nearZ:n,farZ:r}=Kb(e),i=Gb(e);if(!i)return this._warnOrtho(`render() 输入里没有独立的投影矩阵(需要 MapLibre ≥ 5)`),null;let a=Jb({projectionMatrix:i,mvp:t.elements,nearZ:n,farZ:r},{distance:this.map?.transform?.cameraToCenterDistance??0,fov:this._frameFov(e),aspect:this._canvasAspect()});return a?a.matrix:(this._warnOrtho(`拿到的投影矩阵与 MVP 不同源(反推结果不是仿射变换)`),null)}_warnOrtho(e){this._orthoWarned||(this._orthoWarned=!0,console.warn(`[s3m] 正交模式不可用:${e},本帧保持透视`))}_frameFov(e){return qb(e,this.map?.transform?.fovInRadians)??.6435011087932844}_canvasAspect(){let e=this.map?.getCanvas?.();return!e||!e.height?1:e.width/e.height}setProjection(e){let t=e===`orthographic`?`orthographic`:`perspective`;this._projection!==t&&(this._projection=t,this._orthoWarned=!1,this.map?.triggerRepaint())}get projection(){return this._projection}render(e,t){let n=this.map,r=this.viewer.sceneAnchor;if(!n||!r)return;let i=this._extractMatrix(t);if(!i)return;let a=new U().fromArray(i);this._projection===`orthographic`&&(a=this._applyOrtho(t,a)??a);let o=n.getCanvas(),s=r.meterInMercator,c=[0,0,0];try{let e=n.getFreeCameraOptions?.()?.position;e&&(c=[(e.x-r.x)/s,-(e.y-r.y)/s,(e.z-r.z)/s])}catch{}this.viewer.renderFrame({mvp:a.elements,cameraEnu:c,fovRad:this._frameFov(t),canvasHeight:o.height})&&n.triggerRepaint()}pickFromEvent(e){let t=this.map?.getCanvas();if(!t)return null;let n=t.getBoundingClientRect(),r=e.originalEvent??e;return this.viewer.pick(r.clientX-n.left,r.clientY-n.top)}pick(e,t){return this.viewer.pick(e,t)}pickPosition(e,t){return this.viewer.pickPosition(e,t)}drillPick(e,t,n=10){return this.viewer.drillPick(e,t,n)}getRayAt(e,t){return this.viewer.getRayAt(e,t)}select(e,t={}){this.viewer.select(e,t)}getFeatureBounds(e){return this.viewer.getFeatureBounds(e)}flyToFeature(e,t){let n=this.viewer.getFeatureBounds(e);if(!n||!this.map)return!1;let r=this.map;return typeof r.fitBounds==`function`&&(r.fitBounds(n,{padding:50,maxZoom:19,duration:1200,...t}),!0)}addDataset(e){return this.viewer.addDataset(e)}removeDataset(e){this.viewer.removeDataset(e)}clearDatasets(){this.viewer.clearDatasets()}setDatasetVisible(e,t){this.viewer.setDatasetVisible(e,t)}getDatasetHeight(e){return this.viewer.getDatasetHeight(e)}setDatasetHeight(e,t){this.viewer.setDatasetHeight(e,t)}setDatasetAlign(e,t){this.viewer.setDatasetAlign(e,t)}_computeAlignOffset(e,t){return this.viewer.computeAlignOffset(e,t)}setLight(e){this.viewer.setLight(e)}getLight(){return this.viewer.getLight()}setOpacity(e){this.viewer.setOpacity(e)}setStyle(e={}){this.viewer.setStyle(e)}getStyle(){return this.viewer.getStyle()}setEdges(e){this.viewer.setEdges(e)}setFeatureStyle(e,t){this.viewer.setFeatureStyle(e,t)}setFeaturesStyle(e,t){this.viewer.setFeaturesStyle(e,t)}getFeatureStyle(e){return this.viewer.getFeatureStyle(e)}getFeatureStyles(){return this.viewer.getFeatureStyles()}removeFeatureStyle(e){this.viewer.removeFeatureStyle(e)}clearFeatureStyles(){this.viewer.clearFeatureStyles()}setAttributeSource(e){this.viewer.setAttributeSource(e)}getLoadedSmids(){return this.viewer.getLoadedSmids()}auditBatches(){return this.viewer.auditBatches()}getThematicField(){return this.viewer.getThematicField()}setThematicColors(e,t=`custom`){this.viewer.setThematicColors(e,t)}clearThematic(){this.viewer.clearThematic()}getFilterField(){return this.viewer.getFilterField()}filterByField(e){return this.viewer.filterByField(e)}clearFieldFilter(){this.viewer.clearFieldFilter()}getElevationField(){return this.viewer.getElevationField()}elevateByField(e){return this.viewer.elevateByField(e)}setThematicElevation(e,t=`custom`){this.viewer.setThematicElevation(e,t)}clearThematicElevation(){this.viewer.clearThematicElevation()}colorByField(e){return this.viewer.colorByField(e)}setFilter(e){this.viewer.setFilter(e)}getFilter(){return this.viewer.getFilter()}clearFilter(){this.viewer.clearFilter()}setGroundMode(e){this.viewer.setGroundMode(e)}setGroundOpacity(e){this.viewer.setGroundOpacity(e)}setExcavationBounds(e){this.viewer.setExcavationBounds(e)}setGroundOcclude(e){this.viewer.setGroundOcclude(e)}get groundManager(){return this.viewer.groundManager}getAllMeshes(){return this.viewer.getAllMeshes()}flushOverrides(){this.viewer.flushOverrides()}_applyOverridesToMesh(e){this.viewer._applyOverridesToMesh(e)}get lodRangeScale(){return this.viewer.lodRangeScale}setLodRangeScale(e,t){this.viewer.setLodRangeScale(e,t)}get renderer(){return this.viewer.renderer}get scene(){return this.viewer.scene}get camera(){return this.viewer.camera}get picker(){return this.viewer.picker}get uniforms(){return this.viewer.uniforms}get style(){return this.viewer.style}get outlineMaterial(){return this.viewer.outlineMaterial}get lineShared(){return this.viewer.lineShared}get edgeMaterial(){return this.viewer.edgeMaterial}get selectionEdgeMaterial(){return this.viewer.selectionEdgeMaterial}get datasets(){return this.viewer.datasets}get sceneAnchor(){return this.viewer.sceneAnchor}set sceneAnchor(e){this.viewer.sceneAnchor=e}get attributeQuery(){return this.viewer.attributeQuery}get fps(){return this.viewer.fps}get stats(){return this.viewer.stats}getBounds(){return this.viewer.getBounds()}dispose(){this.onRemove()}},$b=i({AttributeQuery:()=>o_,BinaryReader:()=>sh,DEFAULT_FLOOR_HEIGHT:()=>e_,DEFAULT_FOV:()=>Yb,DEFAULT_STYLE:()=>yy,DatasetManager:()=>Ab,EARTH_RADIUS:()=>s_,FeatureStyleManager:()=>Fb,GroundManager:()=>Ib,Picker:()=>xb,PixelFormat:()=>ly,S3MFormatError:()=>Kg,S3MLayer:()=>Qb,S3MTileset:()=>sb,S3MViewer:()=>Bb,S3M_VERSION:()=>mg,SELECT_MODE:()=>_y,SELECT_MODE_LABELS:()=>vy,STYLE:()=>hy,STYLE_LABELS:()=>gy,TextureCompress:()=>J_,VertexTag:()=>hg,VertexTagV3:()=>gg,buildAttributes:()=>Qg,buildFeatureEdgeSegments:()=>kb,buildOrthoMVP:()=>Jb,buildThickLineGeometry:()=>Eb,buildTileObjects:()=>Jy,createLineSharedUniforms:()=>Sb,createMapLibreGeoAdapter:()=>Zb,createOutlineMaterial:()=>my,createSharedUniforms:()=>fy,createStyledMaterial:()=>py,createTexture:()=>cy,createThickLineMaterial:()=>Tb,default:()=>Qb,dxtPixelFormatOf:()=>q_,extractFovRadians:()=>qb,extractNearFar:()=>Kb,extractProjectionMatrix:()=>Gb,extractWorldCoordinateHelper:()=>Xb,isS3M1Buffer:()=>tg,lngLatFromMercator:()=>l_,lngLatFromWorld:()=>d_,measureSegments:()=>Zg,mercatorFromLngLat:()=>c_,parseS3M1:()=>pg,parseS3MB:()=>qg,resolveFeature:()=>Xg,resolveTextureKind:()=>K_,setMaxAnisotropy:()=>ty,worldFromLngLat:()=>u_});rh(),t_(),Z_(),dy(),jy(),Zy();var ex=globalThis;return ex.THREE||(ex.THREE=a),ex.S3MMapLibre=$b,e.AttributeQuery=o_,e.BinaryReader=sh,e.DEFAULT_FLOOR_HEIGHT=e_,e.DEFAULT_FOV=Yb,e.DEFAULT_STYLE=yy,e.DatasetManager=Ab,e.EARTH_RADIUS=s_,e.FeatureStyleManager=Fb,e.GroundManager=Ib,e.Picker=xb,e.PixelFormat=ly,e.S3MFormatError=Kg,e.S3MLayer=Qb,e.default=Qb,e.S3MTileset=sb,e.S3MViewer=Bb,e.S3M_VERSION=mg,e.SELECT_MODE=_y,e.SELECT_MODE_LABELS=vy,e.STYLE=hy,e.STYLE_LABELS=gy,e.TextureCompress=J_,e.VertexTag=hg,e.VertexTagV3=gg,e.buildAttributes=Qg,e.buildFeatureEdgeSegments=kb,e.buildOrthoMVP=Jb,e.buildThickLineGeometry=Eb,e.buildTileObjects=Jy,e.createLineSharedUniforms=Sb,e.createMapLibreGeoAdapter=Zb,e.createOutlineMaterial=my,e.createSharedUniforms=fy,e.createStyledMaterial=py,e.createTexture=cy,e.createThickLineMaterial=Tb,e.dxtPixelFormatOf=q_,e.extractFovRadians=qb,e.extractNearFar=Kb,e.extractProjectionMatrix=Gb,e.extractWorldCoordinateHelper=Xb,e.isS3M1Buffer=tg,e.lngLatFromMercator=l_,e.lngLatFromWorld=d_,e.measureSegments=Zg,e.mercatorFromLngLat=c_,e.parseS3M1=pg,e.parseS3MB=qg,e.resolveFeature=Xg,e.resolveTextureKind=K_,e.setMaxAnisotropy=ty,e.worldFromLngLat=u_,e})({});
4419
+ `}),i=new dc(e,r);i.position.set(0,0,-.02),i.renderOrder=-1e3,i.name=`s3m-ground-depth`,i.visible=!1,this.group.add(i),this._depthMesh=i,this._depthMaterial=r,this._syncUniforms()}_applyMode(){this._mesh&&(this._mesh.visible=this.mode!==`none`),this._material&&(this._material.uniforms.uMode.value=this.mode===`excavate`?2:+(this.mode===`translucent`),this._material.depthWrite=this.mode===`excavate`),this._depthMesh&&(this._depthMesh.visible=this.occlude,this._depthMaterial&&(this._depthMaterial.uniforms.uPunchPit.value=+(this.mode===`excavate`)))}update(e){e&&this.group.position.set(e.position.x,e.position.y,this.groundHeight)}setGroundHeight(e){this.groundHeight=e,this.group.position.z=e}setMode(e){this.mode=e,this._occludeExplicit||(this.occlude=e===`excavate`),this._applyMode()}setOcclude(e){this.occlude=e,this._occludeExplicit=!0,this._applyMode()}setOpacity(e){this.opacity=Math.max(0,Math.min(1,e)),this._material&&(this._material.uniforms.uOpacity.value=this.opacity)}setColors(e,t){this.color.set(e),t&&this.gridColor.set(t),this._material&&(this._material.uniforms.uColor.value=this.color,this._material.uniforms.uGridColor.value=this.gridColor)}setExcavationBounds(e){this.excavationBounds=e,this._syncUniforms()}autoFitExcavation(e){let t=1/0,n=1/0,r=-1/0,i=-1/0,a=!1;for(let o of e){let e=o.tileset?.config,s=e?.rootTiles??e?.tiles;if(Array.isArray(s))for(let e of s){let s=e.boundingBox;if(!s)continue;let c=s.center??{x:0,y:0},l=s.xExtent?.x?Math.abs(s.xExtent.x):50,u=s.yExtent?.y?Math.abs(s.yExtent.y):50,d=c.x+o.offset[0]-l,f=c.x+o.offset[0]+l,p=c.y+o.offset[1]-u,m=c.y+o.offset[1]+u;d<t&&(t=d),f>r&&(r=f),p<n&&(n=p),m>i&&(i=m),a=!0}}a&&Number.isFinite(t)&&this.setExcavationBounds([t-5,n-5,r+5,i+5])}_syncUniforms(){let e=this.excavationBounds;if(this._material){let t=this._material.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}if(this._depthMaterial){let t=this._depthMaterial.uniforms;e?(t.uHasExcavation.value=1,t.uExcavationMin.value.set(e[0],e[1]),t.uExcavationMax.value.set(e[2],e[3])):t.uHasExcavation.value=0}}dispose(){this._geom?.dispose(),this._geom=null,this._material?.dispose(),this._material=null,this._depthMaterial?.dispose(),this._depthMaterial=null,this._mesh=null,this._depthMesh=null,this.group.clear()}};rh(),dy(),jy(),t_();var Lb=65534;function Rb(e){let t=Array.isArray(e.material)?e.material[0]:e.material;return t?.userData?.isStyled?t:null}function zb(e){return e.isPoints===!0}var Bb=class{get datasets(){return this._datasetManager.datasets}get sceneAnchor(){return this._datasetManager.sceneAnchor}set sceneAnchor(e){this._datasetManager.sceneAnchor=e}_requestRepaint(){this._onRequestRepaint()}triggerRepaint(){this._requestRepaint()}constructor(e={}){X(this,`options`,void 0),X(this,`pickable`,void 0),X(this,`onStats`,void 0),X(this,`onReady`,void 0),X(this,`onPick`,void 0),X(this,`onError`,void 0),X(this,`geo`,null),X(this,`canvas`,null),X(this,`renderer`,null),X(this,`scene`,null),X(this,`camera`,null),X(this,`picker`,null),X(this,`uniforms`,void 0),X(this,`style`,void 0),X(this,`outlineMaterial`,void 0),X(this,`lineShared`,void 0),X(this,`edgeMaterial`,void 0),X(this,`selectionEdgeMaterial`,void 0),X(this,`groundManager`,void 0),X(this,`_datasetManager`,new Ab),X(this,`_featureStyleManager`,void 0),X(this,`_pickables`,new Map),X(this,`_pickSeq`,0),X(this,`_freePickIds`,[]),X(this,`_smidMeshes`,new Map),X(this,`_meshHeight`,new Map),X(this,`_heightMin`,1/0),X(this,`_heightMax`,-1/0),X(this,`_boxScratch`,new ho),X(this,`_selection`,null),X(this,`_selectedMeshes`,[]),X(this,`_outlineMesh`,null),X(this,`_outlineMeshes`,[]),X(this,`_selectionEdges`,null),X(this,`_selectionEdgeMeshes`,[]),X(this,`_edgesEnabled`,!1),X(this,`attributeQuery`,null),X(this,`_enuMatrix`,new U),X(this,`_needsRepaint`,!0),X(this,`_frame`,0),X(this,`_fps`,{value:0,last:0}),X(this,`_ambientLight`,void 0),X(this,`_hemiLight`,void 0),X(this,`_keyLight`,void 0),X(this,`_fillLight`,void 0),X(this,`_lightOptions`,{ambientIntensity:.4,ambientColor:16777215,hemisphereIntensity:.8,hemisphereColor:16777215,hemisphereGroundColor:11976907,keyLightIntensity:1,keyLightColor:16777215,fillLightIntensity:.35,fillLightColor:16777215,mode:`headlamp`,azimuth:150,altitude:50}),X(this,`_datasetQueue`,void 0),X(this,`_onRequestRepaint`,()=>{}),X(this,`_getBearing`,void 0),X(this,`_lodRangeScale`,1),this.options=e,this.pickable=e.pickable!==!1,this._lodRangeScale=e.lodRangeScale??1,e.light&&Object.assign(this._lightOptions,e.light),e.totalMaxTiles&&(this._datasetManager.totalMaxTiles=e.totalMaxTiles),this._onRequestRepaint=e.onRequestRepaint??(()=>{}),this._getBearing=e.getBearing,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.groundManager=new Ib(e.ground),this.scene||(this.scene=new Wl,this.scene.add(this.groundManager.group),this._addLights()),this._featureStyleManager=new Fb(()=>this.style.floorHeight,()=>this._requestRepaint(),()=>{this._selection&&this._syncSelectionStyle()},()=>this.getAllMeshes(),e=>this._applyOverridesToMesh(e)),this.uniforms=fy(),this.style={...yy,...e.style??{}},this.outlineMaterial=my(this.uniforms),this.lineShared=Sb(),this.edgeMaterial=Tb(this.lineShared,{color:this.style.edgeColor,opacity:this.style.edgeOpacity??.45,width:this.style.edgeWidth??1.2}),this.selectionEdgeMaterial=Tb(this.lineShared,{color:this.style.outlineColor??this.style.selectColor,opacity:1,width:this.style.outlineWidthPx??3}),this._fps.last=performance.now(),this._datasetQueue=this._normalizeDatasets(e),e.attributes&&(this.attributeQuery=new o_(e.attributes))}_createRenderer(e,t){let n=new Vl({canvas:e,context:t,antialias:!0});return n.autoClear=!1,n.setPixelRatio(1),n.toneMapping=4,n.toneMappingExposure=1,n}mount(e,t){this.canvas=e,this.renderer=this._createRenderer(e,t),ty(this.renderer.capabilities.getMaxAnisotropy()),this.scene=new Wl,this.scene.add(this.groundManager.group),this._addLights(),this.camera=new _c,this.camera.matrixAutoUpdate=!1,this.picker=new xb(this.renderer),this._applyStyleUniforms();for(let e of this._datasetQueue)this.addDataset(e).catch(e=>this.onError(e));this._recomputeAnchors()}restoreContext(e){if(!this.canvas)console.warn(`[s3m] restoreContext 调用过早(尚未 mount),按首次挂载处理`);else{try{this.renderer?.dispose()}catch{}this.renderer=this._createRenderer(this.canvas,e),ty(this.renderer.capabilities.getMaxAnisotropy()),this.picker?.dispose(),this.picker=new xb(this.renderer),this._requestRepaint()}}unmount(){for(let e of[...this.datasets.keys()])this.removeDataset(e);this.groundManager.dispose(),this.picker?.dispose(),this.picker=null,this.outlineMaterial.dispose(),this.edgeMaterial.dispose(),this.selectionEdgeMaterial.dispose(),this.scene?.clear(),this._selectedMeshes=[],this._outlineMeshes=[],this._selectionEdgeMeshes=[],this._outlineMesh=null,this._selectionEdges=null,this._smidMeshes.clear(),this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0,this.renderer?.dispose(),this.renderer=null,this.canvas=null}_createLights(){this._ambientLight=new mp(this._lightOptions.ambientColor,this._lightOptions.ambientIntensity),this._hemiLight=new ep(this._lightOptions.hemisphereColor,this._lightOptions.hemisphereGroundColor,this._lightOptions.hemisphereIntensity),this._keyLight=new pp(this._lightOptions.keyLightColor,this._lightOptions.keyLightIntensity),this._fillLight=new pp(this._lightOptions.fillLightColor,this._lightOptions.fillLightIntensity),this._updateLights()}_addLights(){this.scene&&(this._ambientLight||this._createLights(),this.scene.add(this._ambientLight,this._hemiLight,this._keyLight,this._fillLight))}_applyLightOptions(){this._ambientLight&&(this._ambientLight.intensity=this._lightOptions.ambientIntensity,this._ambientLight.color.set(this._lightOptions.ambientColor)),this._hemiLight&&(this._hemiLight.intensity=this._lightOptions.hemisphereIntensity,this._hemiLight.color.set(this._lightOptions.hemisphereColor),this._hemiLight.groundColor.set(this._lightOptions.hemisphereGroundColor)),this._keyLight&&(this._keyLight.intensity=this._lightOptions.keyLightIntensity,this._keyLight.color.set(this._lightOptions.keyLightColor)),this._fillLight&&(this._fillLight.intensity=this._lightOptions.fillLightIntensity,this._fillLight.color.set(this._lightOptions.fillLightColor))}setLight(e){Object.assign(this._lightOptions,e),this._applyLightOptions(),this._updateLights(),this._needsRepaint=!0,this.triggerRepaint()}getLight(){return{...this._lightOptions}}_updateLights(){if(!this._keyLight||!this._fillLight)return;let e=this._lightOptions.mode===`fixed`?0:(this._getBearing?.()??0)*Math.PI/180,t=(t,n,r)=>{if(!t)return;let i=e+n*Math.PI/180,a=r*Math.PI/180,o=Math.cos(a);t.position.set(Math.sin(i)*o,Math.cos(i)*o,Math.sin(a)).multiplyScalar(1e3)};t(this._keyLight,this._lightOptions.azimuth,this._lightOptions.altitude),t(this._fillLight,this._lightOptions.azimuth+65,Math.max(10,this._lightOptions.altitude-20))}_normalizeDatasets(e){return Array.isArray(e.datasets)?e.datasets.filter(e=>!!e?.configUrl):e.configUrl?[{id:`default`,name:`默认数据集`,configUrl:e.configUrl}]:[]}async addDataset(e){if(!this.scene)throw Error(`[s3m] 图层尚未 addLayer,不能添加数据集`);return await this._datasetManager.addDataset(e,this.scene,this.geo,this.uniforms,this._lodRangeScale,this.options.buildTile,this.options.maxTiles??64,this.options.maxConcurrent??4,{onTile:(e,t)=>{this._registerTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onTileRemoved:(e,t)=>{this._unregisterTile(e,t),this.onStats(this.stats),this._needsRepaint=!0,this._requestRepaint()},onStats:()=>{this.onStats(this.stats),this._requestRepaint()},onError:e=>{this.onError(e),this.onStats(this.stats)},onReady:e=>{this.onReady(e),this._refreshAllHeights(),this.groundManager.excavationBounds||this.groundManager.autoFitExcavation(this.datasets.values())},triggerRepaint:()=>{this._requestRepaint()}})}_lngLatFromWorld(e,t){return d_(this.geo,e,t)}recomputeAnchors(){this._datasetManager.recomputeAnchors(this.geo),this._refreshAllHeights(),this._requestRepaint()}_recomputeAnchors(){this.recomputeAnchors()}getDatasetHeight(e){return this._datasetManager.getDatasetHeight(e)}setDatasetHeight(e,t){let n,r;typeof e==`number`?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??0),this._datasetManager.setDatasetHeight(n,r,this.geo),this._syncGroundHeight(),this._refreshAllHeights(),this._requestRepaint()}_syncGroundHeight(){if(!this.groundManager.trackHeight)return;let e=this.datasets.keys().next().value;if(!e)return;let t=this._datasetManager.getDatasetHeight(e);this.groundManager.setGroundHeight(t)}setDatasetAlign(e,t){let n,r;t===void 0&&(e===`origin`||e===`bottom`||e===`top`||e===`center`)?(n=this.datasets.keys().next().value??``,r=e):(n=e,r=t??`origin`),this._datasetManager.setDatasetAlign(n,r,this.geo),this._refreshAllHeights(),this._requestRepaint()}_computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}computeAlignOffset(e,t){return this._datasetManager.computeAlignOffset(e,t)}setFeatureStyle(e,t){this._featureStyleManager.setFeatureStyle(e,t,this._meshesOf([e]))}setFeaturesStyle(e,t){this._featureStyleManager.setFeaturesStyle(e,t,this._meshesOf(e))}getFeatureStyle(e){return this._featureStyleManager.getFeatureStyle(e)}getFeatureStyles(){return this._featureStyleManager.getFeatureStyles()}removeFeatureStyle(e){this._featureStyleManager.removeFeatureStyle(e,this._meshesOf([e]))}clearFeatureStyles(){this._featureStyleManager.clearFeatureStyles()}setAttributeSource(e){this.attributeQuery=e?new o_(e):null}getLoadedSmids(){return[...this._smidMeshes.keys()]}auditBatches(){let e=this._featureStyleManager.auditBatches(this._pickables.values());return e.smids=this._smidMeshes.size,e}getThematicField(){return this._featureStyleManager.thematicField}setThematicColors(e,t=`custom`){this._featureStyleManager.setThematicColors(e,t)}clearThematic(){this._featureStyleManager.clearThematicColors()}getFilterField(){return this._featureStyleManager.fieldFilter?.field??null}filterByField(e){return this._featureStyleManager.filterByField(e,this.attributeQuery,this.getLoadedSmids())}clearFieldFilter(){this._featureStyleManager.clearFieldFilter()}getElevationField(){return this._featureStyleManager.elevationField}elevateByField(e){return this._featureStyleManager.elevateByField(e,this.attributeQuery,this.getLoadedSmids())}setThematicElevation(e,t=`custom`){this._featureStyleManager.setThematicElevation(e,t)}clearThematicElevation(){this._featureStyleManager.clearThematicElevation()}colorByField(e){return this._featureStyleManager.colorByField(e,this.attributeQuery,this.getLoadedSmids())}setFilter(e){this._featureStyleManager.setFilter(e,this.uniforms)}getFilter(){return this._featureStyleManager.filter}clearFilter(){this._featureStyleManager.clearFilter(this.uniforms)}setGroundMode(e){this.groundManager.setMode(e),this._requestRepaint()}setGroundOpacity(e){this.groundManager.setOpacity(e),this._requestRepaint()}setExcavationBounds(e){this.groundManager.setExcavationBounds(e),this._requestRepaint()}setGroundOcclude(e){this.groundManager.setOcclude(e),this._requestRepaint()}_isFeatureHidden(e,t){if(e==null)return!1;let n=this._featureStyleManager.fieldFilter;if(n){let t=n.matched.has(e);if(n.mode===`keep`?!t:t)return!0}let r=this._featureStyleManager.filter;return!!(r&&(r.include&&r.include.length>0&&!r.include.includes(e)||r.exclude&&r.exclude.length>0&&r.exclude.includes(e))||this._featureStyleManager.featureStyles.get(e)?.hidden)}getAllMeshes(){let e=[];for(let t of this._pickables.values())e.push(t.mesh);return e}_meshesOf(e){let t=new Set;for(let n of e){let e=this._smidMeshes.get(n);if(e)for(let n of e)t.add(n)}return t}_markOverridesDirty(e=`all`){e===`all`?this._featureStyleManager.markOverridesDirty(void 0,this.getAllMeshes()):this._featureStyleManager.markOverridesDirty(e)}flushOverrides(){this._featureStyleManager.flushOverrides()}_applyOverridesToMesh(e){this._featureStyleManager.applyOverridesToMesh(e)}removeDataset(e){if(this.datasets.get(e)){this._selection?.datasetId===e&&this.select(null),this._datasetManager.removeDataset(e,this.scene,this.geo,e=>{e.root.traverse(e=>{let t=e,n=t.userData;n.pickId!=null&&(this._pickables.delete(n.pickId),this._releasePickId(n.pickId),n.pickId=void 0),this._unindexMeshSmids(t),this._removeMeshHeight(t),t.geometry?.dispose?.();let r=Rb(t);r&&r.dispose(),hb(t.material)&&t.material.dispose(),this._featureStyleManager.disposeMesh(t)})});for(let[t,n]of this._pickables)n.datasetId===e&&this._pickables.delete(t);this.onStats(this.stats),this._requestRepaint()}}clearDatasets(){for(let e of[...this.datasets.keys()])this.removeDataset(e)}setDatasetVisible(e,t){this._datasetManager.setDatasetVisible(e,t),!t&&this._selection?.datasetId===e&&this.select(null),this._requestRepaint()}_registerTile(e,t){t.root.add(e.group),e.group.updateMatrixWorld(!0);let n=e.group.userData.hasNativeEdges===!0;for(let r of e.group.children){if(r.isLineSegments&&r.userData.isEdgeLines){r.visible=this._edgesEnabled,this._styleEdgeLine(r);continue}let i=zb(r),a=r;if(!a.isMesh&&!i)continue;let o=a.userData;if(o.pickId=this._allocPickId(),o.datasetId=t.id,o.nativeEdges=n,this._pickables.set(o.pickId,{datasetId:t.id,mesh:a,tile:e.tile,skeletonName:o.skeletonName??``}),this._indexMeshSmids(a),this._addMeshHeight(a),this._edgesEnabled&&!n&&!i&&this._ensureEdges(a),i)this._applyPointCloudStyle(r);else{let e=Rb(a);if(e){let t=Math.min(1,Math.max(.05,this.style.opacity??1));e.opacity=t,e.transparent=t<.999,e.depthWrite=t>=.999,e.flatShading=this.style.shading!==`smooth`,e.needsUpdate=!0,this._featureStyleManager.applyOverridesToMesh(a)}}this._replaySelectionOnto(a)}}_isMeshCoveringSelection(e,t){if(!t.point)return!1;let n=e.geometry;if(!n||(n.boundingBox||n.computeBoundingBox(),!n.boundingBox))return!1;let r=new H(t.point[0],t.point[1],t.point[2]);e.updateWorldMatrix(!0,!1);let i=e.matrixWorld.clone().invert(),a=r.applyMatrix4(i);return n.boundingBox.clone().expandByScalar(.5).containsPoint(a)}_replaySelectionOnto(e){let t=this._selection;if(!t)return;let n=Rb(e);if(!n)return;let r=e.userData,i=-1;if(t.smid!=null){let e=r.geoRef?.pickInfo,n=e?.[t.smid]??e?.[String(t.smid)];i=n?Jg(n):-1}if(e===t.mesh&&(i=t.batchId),i<0&&e!==t.mesh){if(t.smid==null&&r.datasetId===t.datasetId&&this._isMeshCoveringSelection(e,t))i=-1;else return}n.userData.uSelBatch.value=i,n.userData.uSelWhole.value=+(i<0),this._selectedMeshes.includes(e)||this._selectedMeshes.push(e),zb(e)&&this._applyPointCloudStyle(e,!0),this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers}_unregisterTile(e,t){e.group.traverse(e=>{let t=e;if(t.userData?.pickId!=null&&(this._pickables.delete(t.userData.pickId),this._releasePickId(t.userData.pickId),t.userData.pickId=void 0),t.isMesh){this._selectedMeshes.includes(t)&&(this._selectedMeshes=this._selectedMeshes.filter(e=>e!==t));let e=this._selection;if(e&&e.mesh===t){let n=e.smid,r=n==null?this._selectedMeshes.find(e=>e!==t&&e.parent&&e.parent.visible)??this._selectedMeshes.find(e=>e!==t&&e.parent):[...this._smidMeshes.get(n)??[]].find(e=>e!==t&&e.parent);r?(this._selection={...e,mesh:r},this._replaySelectionOnto(r)):this.select(null)}this._unindexMeshSmids(t),this._removeMeshHeight(t),this._featureStyleManager.disposeMesh(t),Rb(t)?.dispose?.()}hb(t.material)?t.material.dispose():t.material&&(Array.isArray(t.material)?t.material.forEach(e=>e?.dispose?.()):t.material.dispose?.()),t.geometry?.dispose?.()}),t.root.remove(e.group)}_allocPickId(){let e=this._freePickIds.pop();if(e!==void 0)return e;if(this._pickSeq>Lb){for(let e=0;e<=Lb;e++)if(!this._pickables.has(e))return e;throw Error(`[s3m] 可拾取网格超过 65535 个,2 字节 ID 编码不够用`)}return this._pickSeq++}_releasePickId(e){this._freePickIds.push(e)}setOpacity(e){this.setStyle({opacity:e})}setStyle(e={}){this.style={...this.style,...e},this._applyStyleUniforms(),(`opacity`in e||`depthWrite`in e)&&this._applyOpacity(),`mode`in e&&this._applyPointCloudStyles(),`shading`in e&&this._applyShading(),`edges`in e?this.setEdges(!!this.style.edges):(`edgeColor`in e||`edgeWidth`in e||`opacity`in e||`edgeOpacity`in e)&&this._refreshEdgeLines(),this._selection&&(`outline`in e||`outlineStyle`in e?this.select(this._selection,{silent:!0}):this._syncSelectionStyle()),this._requestRepaint()}getStyle(){return{...this.style,modeLabel:gy[this.style.mode]}}_applyStyleUniforms(){let e=this.uniforms,t=this.style;e.uMode.value=t.mode,e.uColorA.value.set(t.colorA),e.uColorB.value.set(t.colorB),e.uColorC.value.set(t.colorC),e.uSelColor.value.set(t.selectColor),e.uFloorHeight.value=t.floorHeight;let n=t.selectMode??_y.OVERLAY;e.uSelMode&&(e.uSelMode.value=n===_y.REPLACE?0:n===_y.MULTIPLY?2:n===_y.GLOW_ONLY?3:1),e.uSelOpacity&&t.selectOpacity!=null&&(e.uSelOpacity.value=t.selectOpacity),e.uSelEmissive&&t.selectEmissive!=null&&(e.uSelEmissive.value=t.selectEmissive),e.uSelElevation&&t.selectElevation!=null&&(e.uSelElevation.value=t.selectElevation),e.uDimFactor&&t.dimFactor!=null&&(e.uDimFactor.value=t.dimFactor),e.uRoofThreshold&&t.roofThreshold!=null&&(e.uRoofThreshold.value=t.roofThreshold),e.uTexMix&&t.texMix!=null&&(e.uTexMix.value=t.texMix),this.outlineMaterial&&(this.outlineMaterial.uniforms.uElevation&&t.selectElevation!=null&&(this.outlineMaterial.uniforms.uElevation.value=t.selectElevation),t.outlineWidth!=null&&(this.outlineMaterial.uniforms.uWidth.value=t.outlineWidth),t.outlineColor==null?this.outlineMaterial.uniforms.uColor.value.set(t.selectColor):this.outlineMaterial.uniforms.uColor.value.set(t.outlineColor))}_applyOpacity(){let e=Math.min(1,Math.max(.05,this.style.opacity??1)),t=e<.999,n=this.style.depthWrite!==!1;for(let r of this._pickables.values()){if(zb(r.mesh)){this._applyPointCloudStyle(r.mesh);continue}let i=Rb(r.mesh);i&&(i.opacity=e,i.transparent=t,i.depthWrite=!t||n)}this._requestRepaint()}_applyPointCloudStyle(e,t=this._selectedMeshes.includes(e)){mb(e,this.style,this.uniforms,t)}_applyPointCloudStyles(){for(let e of this._pickables.values())zb(e.mesh)&&this._applyPointCloudStyle(e.mesh);this._requestRepaint()}_applyShading(){let e=this.style.shading!==`smooth`;for(let t of this._pickables.values()){let n=Rb(t.mesh);n&&n.flatShading!==e&&(n.flatShading=e,n.needsUpdate=!0)}this._requestRepaint()}_addMeshHeight(e){let t=e.geometry?.boundingBox;if(!t)return;this._boxScratch.copy(t).applyMatrix4(e.matrixWorld);let n=this._boxScratch.min.z,r=this._boxScratch.max.z;Number.isFinite(n)&&Number.isFinite(r)&&(this._meshHeight.set(e,{min:n,max:r}),n<this._heightMin&&(this._heightMin=n),r>this._heightMax&&(this._heightMax=r),this._pushHeightRange())}_removeMeshHeight(e){let t=this._meshHeight.get(e);t&&(this._meshHeight.delete(e),t.min===this._heightMin||t.max===this._heightMax?this._recomputeHeightRange():this._pushHeightRange())}_refreshAllHeights(){if(this._meshHeight.size===0)return;let e=[...this._meshHeight.keys()];this._meshHeight.clear(),this._heightMin=1/0,this._heightMax=-1/0;for(let t of e)this._addMeshHeight(t);this._pushHeightRange()}_recomputeHeightRange(){let e=1/0,t=-1/0;for(let n of this._meshHeight.values())n.min<e&&(e=n.min),n.max>t&&(t=n.max);this._heightMin=e,this._heightMax=t,this._pushHeightRange()}_pushHeightRange(){let e=this._heightMin,t=this._heightMax;(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)&&(e=0,t=100),this.uniforms.uHeightMin.value=e,this.uniforms.uHeightMax.value=t}_indexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n);if(!Number.isFinite(t)||t<0)continue;let r=this._smidMeshes.get(t);r||this._smidMeshes.set(t,r=new Set),r.add(e)}}_unindexMeshSmids(e){let t=e.userData.geoRef?.pickInfo;if(t)for(let n of Object.keys(t)){let t=Number(n),r=this._smidMeshes.get(t);r&&(r.delete(e),r.size===0&&this._smidMeshes.delete(t))}}setEdges(e){this._edgesEnabled=e,this.style.edges=e;for(let t of this.datasets.values())t.root.traverse(t=>{t.userData.isEdgeLines&&(t.visible=e,this._styleEdgeLine(t))});if(this._syncEdgeStyle(),!e){for(let e of this._pickables.values())this._removeEdges(e.mesh);this._requestRepaint();return}let t=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e.userData;return!t.edges&&!t.nativeEdges&&!zb(e)}),n=0,r=()=>{let e=performance.now();for(;n<t.length&&performance.now()-e<8;)this._ensureEdges(t[n++]);n<t.length?setTimeout(r,0):this._requestRepaint()};r()}_syncEdgeStyle(){let e=this.style,t=this.edgeMaterial.uniforms;t.uColor.value.set(e.edgeColor),t.uWidth.value=Math.max(.1,e.edgeWidth??1.2),t.uOpacity.value=Math.min(1,Math.max(0,e.edgeOpacity??.45))*Math.min(1,Math.max(.05,e.opacity??1))}_styleEdgeLine(e){let t=e.material;t&&t.color&&(t.color.set(this.style.edgeColor),t.opacity=(this.style.edgeOpacity??.45)*Math.min(1,Math.max(.05,this.style.opacity??1)),t.transparent=!0,t.polygonOffset=!0,t.polygonOffsetFactor=-1,t.polygonOffsetUnits=-1,t.needsUpdate=!0)}_refreshEdgeLines(){this._syncEdgeStyle();for(let e of this.datasets.values())e.root.traverse(e=>{e.userData.isEdgeLines&&this._styleEdgeLine(e)})}_ensureEdges(e){let t=e.userData;if(t.edges||t.nativeEdges||!e.geometry||(e.geometry.index?.count??0)>12e4)return;let n=new Qd(e.geometry,40),r=n.getAttribute(`position`),i=r?r.array:null;if(n.dispose(),!i||i.length<6)return;let a=new dc(Eb(i),this.edgeMaterial);a.renderOrder=2,a.frustumCulled=!1,a.raycast=()=>{},a.userData.isThickEdge=!0,t.edges=a,e.add(a)}_removeEdges(e){let t=e.userData,n=t.edges;n&&(e.remove(n),n.geometry?.dispose(),t.edges=null)}getRayAt(e,t){if(!this.camera||!this.canvas)return null;let n=this.canvas,r=n.clientWidth||n.width,i=n.clientHeight||n.height;if(!r||!i)return null;let a=e/r*2-1,o=-(t/i)*2+1,s=new H(a,o,-1).unproject(this.camera),c=new H(a,o,1).unproject(this.camera).clone().sub(s).normalize();return new Bo(s,c)}_intersectMeshAtRay(e,t,n){let r=new gm;r.ray.copy(t);let i=r.intersectObject(e,!1);if(!i.length)return null;if(n!=null){let e=i.find(e=>e.instanceId===n);return e?e.point:i[0].point}return i[0].point}_buildPickResult(e,t,n,r){let i=t.mesh.userData,a=null,o=e.batchId,s=e.instanceIndex,c=i.geoRef,l=[];if(s!=null){let e=this._instanceFeature(t.mesh,c,s);if(!e)return null;a=e.smid,o=e.batchId}else{c=i.geoByBatchId?.get(e.batchId)??i.geoRef;let t=Xg(c,e.batchId);a=t.smid,l=t.segments}if(this._isFeatureHidden(a,o))return null;let u=null,d=0;if(s!=null)u=this._instanceBox(t.mesh,s),d=t.mesh.geometry.index?Math.round(t.mesh.geometry.index.count/3):0;else if(a!=null&&this._smidMeshes.has(a)){let e=this._smidMeshes.get(a),t=1/0,n=1/0,r=1/0,i=-1/0,o=-1/0,s=-1/0,c=0;for(let l of e){let e=l.userData,u=e.geoRef?.pickInfo,f=u?.[a]??u?.[String(a)],p=f?Jg(f):-1,m=f?.segments??(p>=0?Xg(e.geoRef,p).segments:[]),h=Zg(l.geometry,m);h&&(h.minX<t&&(t=h.minX),h.minY<n&&(n=h.minY),h.minZ<r&&(r=h.minZ),h.maxX>i&&(i=h.maxX),h.maxY>o&&(o=h.maxY),h.maxZ>s&&(s=h.maxZ),c+=h.count,d+=h.triangles)}c>0&&(u={minX:t,minY:n,minZ:r,maxX:i,maxY:o,maxZ:s,count:c,triangles:d})}if(!u&&(u=Zg(t.mesh.geometry,l),!u&&t.mesh.geometry)){t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let e=t.mesh.geometry.boundingBox;e&&(u={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}let f=t.mesh.geometry,p=d>0?d:f.index?Math.round(f.index.count/3):0,m=Qg({smid:a,box:u,triangles:p,floorHeight:this.style.floorHeight}),h=null;if(u&&this.sceneAnchor){let e=new H((u.minX+u.maxX)/2,(u.minY+u.maxY)/2,(u.minZ+u.maxZ)/2);e.applyMatrix4(t.mesh.matrixWorld);let n=this.sceneAnchor.meterInMercator;h=this._lngLatFromWorld(e.x*n+this.sceneAnchor.x,-e.y*n+this.sceneAnchor.y)}let g=n??null;!g&&r&&(g=this._intersectMeshAtRay(t.mesh,r,s));let _=null,v=null,y=null;if(g&&this.sceneAnchor){let e=a==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(a),t=e.translation,n=e.elevation,r=g.clone();t?r.add(new H(t[0],t[1],t[2])):n&&(r.z+=n),_=[r.x,r.y,r.z];let i=this.sceneAnchor.meterInMercator;v=this._lngLatFromWorld(r.x*i+this.sceneAnchor.x,-r.y*i+this.sceneAnchor.y),y=r.z+(this.sceneAnchor.altitude??0)}else h&&u&&this.sceneAnchor&&(v=h,y=(u.minZ+u.maxZ)/2+(this.sceneAnchor.altitude??0));return{datasetId:t.datasetId,datasetName:this.datasets.get(t.datasetId)?.name??t.datasetId,objectId:e.objectId,batchId:o,instanceIndex:s,skeletonName:t.skeletonName,centerLngLat:h,point:_,lngLat:v,altitude:y,...m,mesh:t.mesh}}pick(e,t){if(!this.picker||!this.scene||!this.camera||!this.sceneAnchor)return null;let n=this.picker.pick(this.scene,this.camera,e,t);if(!n)return null;let r=this._pickables.get(n.objectId);if(!r)return null;let i=this.getRayAt(e,t);return this._buildPickResult(n,r,void 0,i??void 0)}pickPosition(e,t){if(!this.camera||!this.sceneAnchor)return null;let n=this.pick(e,t);if(n?.point&&n?.lngLat&&n.altitude!=null)return{lngLat:n.lngLat,altitude:n.altitude,point:n.point};let r=this.getRayAt(e,t);if(!r)return null;let i=new Ac(new H(0,0,1),0),a=new H,o=r.intersectPlane(i,a);if(o){let e=this.sceneAnchor.meterInMercator;return{lngLat:this._lngLatFromWorld(o.x*e+this.sceneAnchor.x,-o.y*e+this.sceneAnchor.y),altitude:o.z+(this.sceneAnchor.altitude??0),point:[o.x,o.y,o.z]}}return null}drillPick(e,t,n=10){if(!this.sceneAnchor||!this.camera)return[];let r=this.getRayAt(e,t);if(!r)return[];let i=new gm;i.ray.copy(r);let a=[...this._pickables.values()].map(e=>e.mesh).filter(e=>{let t=e;for(;t;){if(!t.visible)return!1;t=t.parent}return!0}),o=i.intersectObjects(a,!1);if(!o.length)return[];let s=[],c=new Set,l=new Set;for(let e of o){if(s.length>=n)break;let t=e.object,r=t.userData;if(r.pickId==null)continue;let i=this._pickables.get(r.pickId);if(!i)continue;let a=null,o=-1,u=e.instanceId;if(u!=null){let e=this._instanceFeature(t,r.geoRef,u);if(!e)continue;a=e.smid,o=e.batchId}else if(e.faceIndex!=null){let n=t.geometry.attributes.aBatchId;if(n){let i=t.geometry.index?t.geometry.index.getX(e.faceIndex*3):e.faceIndex*3;o=Math.round(n.getX(i)),a=Xg(r.geoByBatchId?.get(o)??r.geoRef,o).smid}}if(a!=null){if(c.has(a))continue;c.add(a)}else{let e=`${r.pickId}:${o}:${u??-1}`;if(l.has(e))continue;l.add(e)}if(this._isFeatureHidden(a,o))continue;let d={objectId:r.pickId,batchId:o,instanceIndex:u},f=this._buildPickResult(d,i,e.point);f&&s.push(f)}return s}getFeatureBounds(e){if(!this.sceneAnchor)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0,a=!1;for(let o of this._pickables.values()){let s=o.mesh,c=s.userData,l=c.geoRef,u=l?.pickInfo;if(!u)continue;let d=null;if(s.isInstancedMesh){let t=c.instanceLookup;t||(t=Yg(u),c.instanceLookup=t);for(let[n,r]of t)if(r.smid===e){d=this._instanceBox(s,n);break}}else{let t=u,n=t[e]??t[String(e)];if(n){let e=Xg(l,Jg(n));if(d=Zg(s.geometry,e.segments),!d&&s.geometry){s.geometry.boundingBox||s.geometry.computeBoundingBox();let e=s.geometry.boundingBox;e&&(d={minX:e.min.x,maxX:e.max.x,minY:e.min.y,maxY:e.max.y,minZ:e.min.z,maxZ:e.max.z,count:0,triangles:0})}}}if(d){a=!0;let o=[new H(d.minX,d.minY,d.minZ),new H(d.maxX,d.minY,d.minZ),new H(d.minX,d.maxY,d.minZ),new H(d.maxX,d.maxY,d.minZ),new H(d.minX,d.minY,d.maxZ),new H(d.maxX,d.minY,d.maxZ),new H(d.minX,d.maxY,d.maxZ),new H(d.maxX,d.maxY,d.maxZ)],c=e==null?{}:this._featureStyleManager.getFeatureEffectiveOffset(e),l=c.translation,u=c.elevation;for(let e of o){l?e.add(new H(l[0],l[1],l[2])):u&&(e.z+=u),e.applyMatrix4(s.matrixWorld);let a=this.sceneAnchor.meterInMercator,[o,c]=this._lngLatFromWorld(e.x*a+this.sceneAnchor.x,-e.y*a+this.sceneAnchor.y);o<t&&(t=o),o>n&&(n=o),c<r&&(r=c),c>i&&(i=c)}}}return a?[[t,r],[n,i]]:null}_instanceFeature(e,t,n){let r=e.userData;return r.instanceLookup||(r.instanceLookup=Yg(t?.pickInfo)),r.instanceLookup.get(n)??null}_instanceBox(e,t){let n=e;if(!n.isInstancedMesh)return null;let r=e.geometry;r.boundingBox||r.computeBoundingBox();let i=r.boundingBox;if(!i)return null;let a=new U;n.getMatrixAt(t,a);let o=i.clone().applyMatrix4(a);return{minX:o.min.x,minY:o.min.y,minZ:o.min.z,maxX:o.max.x,maxY:o.max.y,maxZ:o.max.z,count:r.getAttribute(`position`)?.count??0,triangles:r.index?Math.round(r.index.count/3):0}}select(e,{silent:t=!1}={}){if(this._selection){for(let e of this._selectedMeshes){if(zb(e)){this._applyPointCloudStyle(e,!1);continue}let t=Rb(e);t&&(t.userData.uSelBatch.value=-1,t.userData.uSelWhole.value=0)}this._selectedMeshes=[],this._clearSelectionDecoration(),this._selection=null}if(!e){this.uniforms.uSelMix.value=0,this.uniforms.uDim.value=0,this.outlineMaterial.uniforms.uSelBatch.value=-1,this.outlineMaterial.uniforms.uSelWhole.value=0,this.outlineMaterial.uniforms.uElevation.value=0,this._requestRepaint(),t||this.onPick(null);return}this._selection=e;let n=new Set;if(e.smid!=null){let t=this._smidMeshes.get(e.smid);if(t)for(let e of t)n.add(e)}n.add(e.mesh);for(let t of n){let n=Rb(t);if(!n)continue;let r=e.batchId;if(e.instanceIndex!=null&&t===e.mesh)r=e.batchId;else if(e.smid!=null){let n=t.userData.geoRef?.pickInfo,i=n?.[e.smid]??n?.[String(e.smid)],a=i?Jg(i):-1;r=a>=0?a:t===e.mesh?e.batchId:-1}n.userData.uSelBatch.value=r,n.userData.uSelWhole.value=+(r<0),this._selectedMeshes.push(t)}for(let e of this._selectedMeshes)zb(e)&&this._applyPointCloudStyle(e,!0);if(this.uniforms.uSelMix.value=1,this.uniforms.uDim.value=+!!this.style.dimOthers,this.style.outline){let t=[...n].filter(e=>!zb(e));t.length&&((this.style.outlineStyle??`edges`)===`edges`?this._addSelectionEdges(e,t):this._addSelectionHull(e,t))}this._requestRepaint()}_addSelectionEdges(e,t){this._syncSelectionStyle();for(let n of t){let t=n.userData,r=t.geoRef,i=[];if(n===e.mesh&&e.instanceIndex!=null)i=[{vertexOffset:0,vertexCount:n.geometry.getAttribute(`position`)?.count??0}];else if(e.smid!=null){let t=r?.pickInfo,n=t?.[e.smid]??t?.[String(e.smid)],a=n?Jg(n):-1;i=n?.segments??(a>=0?Xg(r,a).segments:[])}else n===e.mesh&&(i=Xg(t.geoByBatchId?.get(e.batchId)??r,e.batchId).segments);let a=kb(n.geometry,i);if(a&&a.length>0){let t=new dc(Eb(a),this.selectionEdgeMaterial);t.renderOrder=4,t.frustumCulled=!1,t.raycast=()=>{},t.userData.isSelectionEdge=!0,n===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(t,e),n.add(t),this._selectionEdgeMeshes.push(t)}}this._selectionEdgeMeshes.length===0?this._addSelectionHull(e,t):this._selectionEdges=this._selectionEdgeMeshes[0]??null}_applyInstanceTransform(e,t){let n=t.mesh;if(t.instanceIndex==null||!n.isInstancedMesh)return;let r=new U;n.getMatrixAt(t.instanceIndex,r),r.decompose(e.position,e.quaternion,e.scale)}_addSelectionHull(e,t){let n=e.instanceIndex!=null;this.outlineMaterial.uniforms.uSelBatch.value=n?-1:e.batchId,this.outlineMaterial.uniforms.uSelWhole.value=n||e.batchId<0?1:0,this.outlineMaterial.uniforms.uElevation.value=n?this._selectionElevation(e):this.style.selectElevation??0;for(let n of t){let t=Rb(n);t?.userData?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=t.userData.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=t.userData.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=t.userData.uBatchTexActive.value);let r=new dc(n.geometry,this.outlineMaterial);r.renderOrder=3,r.frustumCulled=!1,r.raycast=()=>{},n===e.mesh&&e.instanceIndex!=null&&this._applyInstanceTransform(r,e),n.add(r),this._outlineMeshes.push(r)}this._outlineMesh=this._outlineMeshes[0]??null}_syncSelectionStyle(){let e=this.style,t=this.selectionEdgeMaterial.uniforms;t.uColor.value.set(e.outlineColor??e.selectColor),t.uWidth.value=Math.max(.1,e.outlineWidthPx??3),t.uOpacity.value=Math.min(1,Math.max(.05,e.opacity??1)),t.uElevation.value=this._selection?this._selectionElevation(this._selection):0;for(let e of this._outlineMeshes){let t=e.parent,n=t?Rb(t)?.userData:null;n?.uBatchTex&&(this.outlineMaterial.uniforms.uBatchTex.value=n.uBatchTex.value,this.outlineMaterial.uniforms.uBatchTexWidth.value=n.uBatchTexWidth.value,this.outlineMaterial.uniforms.uBatchTexActive.value=n.uBatchTexActive.value)}}_selectionElevation(e){let t=this.style.selectElevation??0;if(e.smid!=null){let n=this._featureStyleManager.getFeatureEffectiveOffset(e.smid);n.elevation&&(t+=n.elevation)}return t}_clearSelectionDecoration(){for(let e of this._outlineMeshes)e.parent?.remove(e);this._outlineMeshes=[],this._outlineMesh=null;for(let e of this._selectionEdgeMeshes)e.parent?.remove(e),e.geometry.dispose();this._selectionEdgeMeshes=[],this._selectionEdges=null}_updateLineResolution(e){let t=e.width||1,n=e.height||1,r=e.clientWidth||t;this.lineShared.uResolution.value.set(t,n),this.lineShared.uDpr.value=Math.max(1,t/r)}get lodRangeScale(){return this._lodRangeScale}setLodRangeScale(e,t){if(!(e<=0)){if(t){let n=this.datasets.get(t);n?.tileset&&(n.tileset.lodRangeScale=e)}else{this._lodRangeScale=e;for(let t of this.datasets.values())t.tileset&&(t.tileset.lodRangeScale=e)}this._requestRepaint()}}renderFrame(e){if(!this.renderer||!this.scene||!this.camera||!this.sceneAnchor||!this.canvas)return!1;let t=this.renderer.getContext();if(t&&typeof t.isContextLost==`function`&&t.isContextLost())return!1;this.flushOverrides();let n=this.canvas,r=this.sceneAnchor.meterInMercator;this._enuMatrix.set(r,0,0,this.sceneAnchor.x,0,-r,0,this.sceneAnchor.y,0,0,r,this.sceneAnchor.z,0,0,0,1);let i=new U().fromArray(e.mvp);i.multiply(this._enuMatrix),this.camera.projectionMatrix.copy(i),this.camera.projectionMatrixInverse.copy(i).invert();let a=e.cameraEnu;this.camera.position.set(a[0],a[1],a[2]),this.camera.matrixWorld.setPosition(a[0],a[1],a[2]),this.camera.matrixWorldInverse.copy(this.camera.matrixWorld).invert(),this.groundManager.update(this.camera);let o=!1;for(let t of this.datasets.values()){if(!t.visible||!t.tileset)continue;let n=[a[0]-t.offset[0],a[1]-t.offset[1],a[2]-t.offset[2]];t.tileset.update(n,e.fovRad,e.canvasHeight)&&(o=!0)}this.style.mode===hy.DYNAMIC&&(this.uniforms.uTime.value+=.016*(this.style.speed??1)),this._updateLights(),this._updateLineResolution(n),this.renderer.setViewport(0,0,n.width,n.height),this.renderer.resetState(),this.renderer.render(this.scene,this.camera),this._frame++;let s=performance.now();return s-this._fps.last>500&&(this._fps.value=Math.round(this._frame*1e3/(s-this._fps.last)),this._frame=0,this._fps.last=s),this.style.mode===hy.DYNAMIC||this.stats.loading>0||o}get fps(){return this._fps.value}get stats(){let e={tiles:0,loading:0,failed:0,meshes:0,vertices:0,triangles:0,datasets:this.datasets.size};for(let t of this.datasets.values()){let n=t.tileset?.stats;n&&(e.tiles+=n.tiles,e.loading+=n.loading,e.failed+=n.failed,e.meshes+=n.meshes,e.vertices+=n.vertices,e.triangles+=n.triangles)}return e}getBounds(){let e=1/0,t=1/0,n=-1/0,r=-1/0;for(let i of this.datasets.values()){let a=ib(i.tileset?.config?.geoBounds);a&&(e=Math.min(e,a.left),n=Math.max(n,a.right),t=Math.min(t,a.bottom),r=Math.max(r,a.top))}return isFinite(e)?[[e,t],[n,r]]:null}dispose(){this.unmount()}};rh();var Vb=1e-4;function Hb(e,t){let n=e.elements;for(let e=0;e<16;e++){let r=Math.max(1,Math.abs(n[e]),Math.abs(t[e]));if(Math.abs(n[e]-t[e])>Vb*r)return!1}return!0}function Ub(e){let t=e.elements,n=1;for(let e=0;e<16;e++){let r=Math.abs(t[e]);r>n&&(n=r)}let r=1e-6*n;return Math.abs(t[3])<r&&Math.abs(t[7])<r&&Math.abs(t[11])<r&&Math.abs(t[15]-1)<r}function Wb(e,t){return t>0&&Math.abs(e.elements[5]*Math.tan(t/2)-1)<.001}function Gb(e){if(!e||typeof e!=`object`)return null;let t=e;return t.defaultProjectionData?.projectionMatrix??t.projectionMatrix??null}function Kb(e){let t={nearZ:null,farZ:null};if(!e||typeof e!=`object`)return t;let n=e,r=n.defaultProjectionData,i=e=>{let t=n[e];if(typeof t==`number`&&Number.isFinite(t))return t;let i=r?.[e];return typeof i==`number`&&Number.isFinite(i)?i:null};return{nearZ:i(`nearZ`),farZ:i(`farZ`)}}function qb(e,t){if(e&&typeof e==`object`){let t=e.fov;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return t}return typeof t==`number`&&Number.isFinite(t)&&t>0?t:null}function Jb(e,t){let n=e.projectionMatrix;if(!n||n.length<16)return null;let r=new U().fromArray(Array.from(n)),i=new U().fromArray(Array.from(e.mvp));if(r.determinant()===0||!Wb(r,t.fov))return null;let a=r.clone().invert().multiply(i);if(!Hb(r.clone().multiply(a),Array.from(e.mvp))||!Ub(a)||!Wb(r,t.fov))return null;let{distance:o,fov:s,aspect:c}=t;if(!(o>0)||!(s>0)||!(c>0))return null;let l=o*Math.tan(s/2),u=l*c,d=e.nearZ!=null&&e.nearZ>0?e.nearZ:1,f=e.farZ!=null&&e.farZ>d?e.farZ:o*4+1e3;f>d||(f=d+1e3);let p=new zc(-u,u,l,-l,d,f);return p.updateProjectionMatrix(),{matrix:p.projectionMatrix.clone().multiply(a),view:a}}var Yb=.6435011087932844;function Xb(e){let t=e,n=t?.transform?.worldCoordinateHelper??t?.transform?.projection?.worldCoordinateHelper??t?.painter?.transform?.worldCoordinateHelper??(typeof t?.getProjection==`function`?t.getProjection()?.worldCoordinateHelper:null)??null;return n&&typeof n.worldFromLngLat==`function`&&typeof n.lngLatFromWorld==`function`?n:null}function Zb(e){let t=Xb(e);return t?{worldFromLngLat(e,n,r=0){let i=t.worldFromLngLat(e,n,r),a=0;if(typeof t.metersPerWorldUnit==`function`){let e=t.metersPerWorldUnit(i.x,i.y);Number.isFinite(e)&&e>0&&(a=1/e)}if(a===0){let o=t.worldFromLngLat(e,n,r+1),s=Math.abs((o.z??0)-(i.z??0));Math.sin(n*Math.PI/180),a=s>0?s:1/(2*Math.PI*6378137)/Math.cos(n*Math.PI/180)}return{x:i.x,y:i.y,z:i.z??r*a,meterInMercator:a,altitude:r}},lngLatFromWorld(e,n){let r=t.lngLatFromWorld(e,n);return Array.isArray(r)?[r[0],r[1]]:r&&typeof r.lng==`number`&&typeof r.lat==`number`?[r.lng,r.lat]:[0,0]}}:null}rh();var Qb=class{get map(){return this._map}set map(e){this._map=e,this.viewer.geo=e?Zb(e):null}_mapGl(){let e=this.map?.getCanvas?.();return e?e.getContext(`webgl2`)??e.getContext(`webgl`):null}constructor(e={}){X(this,`id`,void 0),X(this,`type`,`custom`),X(this,`renderingMode`,`3d`),X(this,`options`,void 0),X(this,`pickable`,void 0),X(this,`onStats`,void 0),X(this,`onReady`,void 0),X(this,`onPick`,void 0),X(this,`onError`,void 0),X(this,`_map`,null),X(this,`viewer`,void 0),X(this,`_orthoWarned`,!1),X(this,`_projection`,`perspective`),X(this,`_onProjectionChange`,()=>{this.map&&(this.viewer.geo=Zb(this.map)),this.viewer.recomputeAnchors()}),X(this,`_contextLost`,!1),X(this,`_listenersAttached`,!1),X(this,`_onContextLost`,()=>{this._contextLost=!0}),X(this,`_onContextRestored`,()=>{this._contextLost=!1;let e=this.map;if(e){try{let t=e.getLayer,n=e.addLayer;if(!(typeof t==`function`&&t.call(e,this.id)))typeof n==`function`&&n.call(e,this);else{let e=this._mapGl();e&&this.viewer.restoreContext(e)}}catch(e){console.warn(`[s3m] WebGL 上下文恢复后重加图层失败,请手动 map.addLayer(layer)`,e)}e.triggerRepaint()}}),X(this,`_onClick`,e=>{if(!this.pickable)return;let t=this.pickFromEvent(e);t?(this.select(t),this.onPick(t)):this.select(null)}),this.id=e.id??`s3m`,this.options=e,this.pickable=e.pickable!==!1,this._projection=e.projection===`orthographic`?`orthographic`:`perspective`,this.onStats=e.onStats??(()=>{}),this.onReady=e.onReady??(()=>{}),this.onPick=e.onPick??(()=>{}),this.onError=e.onError??(e=>console.warn(`[s3m]`,e)),this.viewer=new Bb({configUrl:e.configUrl,datasets:e.datasets,style:e.style,ground:e.ground,pickable:e.pickable,maxTiles:e.maxTiles,maxConcurrent:e.maxConcurrent,lodRangeScale:e.lodRangeScale,buildTile:e.buildTile,light:e.light,totalMaxTiles:e.totalMaxTiles,attributes:e.attributes,onRequestRepaint:()=>this.map?.triggerRepaint(),getBearing:()=>this.map?.getBearing?.()??0,onStats:e=>this.onStats(e),onReady:e=>this.onReady(e),onPick:e=>this.onPick(e),onError:e=>this.onError(e)})}onAdd(e,t){this.map=e,this.viewer.renderer?this.viewer.restoreContext(t):this.viewer.mount(e.getCanvas(),t),this._listenersAttached||(e.on(`click`,this._onClick),typeof e.on==`function`&&(e.on(`projectiontransition`,this._onProjectionChange),e.on(`webglcontextlost`,this._onContextLost),e.on(`webglcontextrestored`,this._onContextRestored)),this._listenersAttached=!0)}onRemove(){this.map?.off(`click`,this._onClick),typeof this.map?.off==`function`&&(this.map.off(`projectiontransition`,this._onProjectionChange),this.map.off(`webglcontextlost`,this._onContextLost),this.map.off(`webglcontextrestored`,this._onContextRestored)),this._listenersAttached=!1,this._contextLost=!1,this.viewer.unmount(),this.viewer.geo=null,this.map=null}_extractMatrix(e){if(Array.isArray(e)||e instanceof Float64Array||e instanceof Float32Array)return e;let t=e;return t?.defaultProjectionData?.mainMatrix??t?.modelViewProjectionMatrix??null}_applyOrtho(e,t){let{nearZ:n,farZ:r}=Kb(e),i=Gb(e);if(!i)return this._warnOrtho(`render() 输入里没有独立的投影矩阵(需要 MapLibre ≥ 5)`),null;let a=Jb({projectionMatrix:i,mvp:t.elements,nearZ:n,farZ:r},{distance:this.map?.transform?.cameraToCenterDistance??0,fov:this._frameFov(e),aspect:this._canvasAspect()});return a?a.matrix:(this._warnOrtho(`拿到的投影矩阵与 MVP 不同源(反推结果不是仿射变换)`),null)}_warnOrtho(e){this._orthoWarned||(this._orthoWarned=!0,console.warn(`[s3m] 正交模式不可用:${e},本帧保持透视`))}_frameFov(e){return qb(e,this.map?.transform?.fovInRadians)??.6435011087932844}_canvasAspect(){let e=this.map?.getCanvas?.();return!e||!e.height?1:e.width/e.height}setProjection(e){let t=e===`orthographic`?`orthographic`:`perspective`;this._projection!==t&&(this._projection=t,this._orthoWarned=!1,this.map?.triggerRepaint())}get projection(){return this._projection}render(e,t){let n=this.map,r=this.viewer.sceneAnchor;if(!n||!r||this._contextLost)return;let i=this._extractMatrix(t);if(!i)return;let a=new U().fromArray(i);this._projection===`orthographic`&&(a=this._applyOrtho(t,a)??a);let o=n.getCanvas(),s=r.meterInMercator,c=[0,0,0];try{let e=n.getFreeCameraOptions?.()?.position;e&&(c=[(e.x-r.x)/s,-(e.y-r.y)/s,(e.z-r.z)/s])}catch{}this.viewer.renderFrame({mvp:a.elements,cameraEnu:c,fovRad:this._frameFov(t),canvasHeight:o.height})&&n.triggerRepaint()}pickFromEvent(e){let t=this.map?.getCanvas();if(!t)return null;let n=t.getBoundingClientRect(),r=e.originalEvent??e;return this.viewer.pick(r.clientX-n.left,r.clientY-n.top)}pick(e,t){return this.viewer.pick(e,t)}pickPosition(e,t){return this.viewer.pickPosition(e,t)}drillPick(e,t,n=10){return this.viewer.drillPick(e,t,n)}getRayAt(e,t){return this.viewer.getRayAt(e,t)}select(e,t={}){this.viewer.select(e,t)}getFeatureBounds(e){return this.viewer.getFeatureBounds(e)}flyToFeature(e,t){let n=this.viewer.getFeatureBounds(e);if(!n||!this.map)return!1;let r=this.map;return typeof r.fitBounds==`function`&&(r.fitBounds(n,{padding:50,maxZoom:19,duration:1200,...t}),!0)}addDataset(e){return this.viewer.addDataset(e)}removeDataset(e){this.viewer.removeDataset(e)}clearDatasets(){this.viewer.clearDatasets()}setDatasetVisible(e,t){this.viewer.setDatasetVisible(e,t)}getDatasetHeight(e){return this.viewer.getDatasetHeight(e)}setDatasetHeight(e,t){this.viewer.setDatasetHeight(e,t)}setDatasetAlign(e,t){this.viewer.setDatasetAlign(e,t)}_computeAlignOffset(e,t){return this.viewer.computeAlignOffset(e,t)}setLight(e){this.viewer.setLight(e)}getLight(){return this.viewer.getLight()}setOpacity(e){this.viewer.setOpacity(e)}setStyle(e={}){this.viewer.setStyle(e)}getStyle(){return this.viewer.getStyle()}setEdges(e){this.viewer.setEdges(e)}setFeatureStyle(e,t){this.viewer.setFeatureStyle(e,t)}setFeaturesStyle(e,t){this.viewer.setFeaturesStyle(e,t)}getFeatureStyle(e){return this.viewer.getFeatureStyle(e)}getFeatureStyles(){return this.viewer.getFeatureStyles()}removeFeatureStyle(e){this.viewer.removeFeatureStyle(e)}clearFeatureStyles(){this.viewer.clearFeatureStyles()}setAttributeSource(e){this.viewer.setAttributeSource(e)}getLoadedSmids(){return this.viewer.getLoadedSmids()}auditBatches(){return this.viewer.auditBatches()}getThematicField(){return this.viewer.getThematicField()}setThematicColors(e,t=`custom`){this.viewer.setThematicColors(e,t)}clearThematic(){this.viewer.clearThematic()}getFilterField(){return this.viewer.getFilterField()}filterByField(e){return this.viewer.filterByField(e)}clearFieldFilter(){this.viewer.clearFieldFilter()}getElevationField(){return this.viewer.getElevationField()}elevateByField(e){return this.viewer.elevateByField(e)}setThematicElevation(e,t=`custom`){this.viewer.setThematicElevation(e,t)}clearThematicElevation(){this.viewer.clearThematicElevation()}colorByField(e){return this.viewer.colorByField(e)}setFilter(e){this.viewer.setFilter(e)}getFilter(){return this.viewer.getFilter()}clearFilter(){this.viewer.clearFilter()}setGroundMode(e){this.viewer.setGroundMode(e)}setGroundOpacity(e){this.viewer.setGroundOpacity(e)}setExcavationBounds(e){this.viewer.setExcavationBounds(e)}setGroundOcclude(e){this.viewer.setGroundOcclude(e)}get groundManager(){return this.viewer.groundManager}getAllMeshes(){return this.viewer.getAllMeshes()}flushOverrides(){this.viewer.flushOverrides()}_applyOverridesToMesh(e){this.viewer._applyOverridesToMesh(e)}get lodRangeScale(){return this.viewer.lodRangeScale}setLodRangeScale(e,t){this.viewer.setLodRangeScale(e,t)}get renderer(){return this.viewer.renderer}get scene(){return this.viewer.scene}get camera(){return this.viewer.camera}get picker(){return this.viewer.picker}get uniforms(){return this.viewer.uniforms}get style(){return this.viewer.style}get outlineMaterial(){return this.viewer.outlineMaterial}get lineShared(){return this.viewer.lineShared}get edgeMaterial(){return this.viewer.edgeMaterial}get selectionEdgeMaterial(){return this.viewer.selectionEdgeMaterial}get datasets(){return this.viewer.datasets}get sceneAnchor(){return this.viewer.sceneAnchor}set sceneAnchor(e){this.viewer.sceneAnchor=e}get attributeQuery(){return this.viewer.attributeQuery}get fps(){return this.viewer.fps}get stats(){return this.viewer.stats}getBounds(){return this.viewer.getBounds()}dispose(){this.onRemove()}},$b=i({AttributeQuery:()=>o_,BinaryReader:()=>sh,DEFAULT_FLOOR_HEIGHT:()=>e_,DEFAULT_FOV:()=>Yb,DEFAULT_STYLE:()=>yy,DatasetManager:()=>Ab,EARTH_RADIUS:()=>s_,FeatureStyleManager:()=>Fb,GroundManager:()=>Ib,Picker:()=>xb,PixelFormat:()=>ly,S3MFormatError:()=>Kg,S3MLayer:()=>Qb,S3MTileset:()=>sb,S3MViewer:()=>Bb,S3M_VERSION:()=>mg,SELECT_MODE:()=>_y,SELECT_MODE_LABELS:()=>vy,STYLE:()=>hy,STYLE_LABELS:()=>gy,TextureCompress:()=>J_,VertexTag:()=>hg,VertexTagV3:()=>gg,buildAttributes:()=>Qg,buildFeatureEdgeSegments:()=>kb,buildOrthoMVP:()=>Jb,buildThickLineGeometry:()=>Eb,buildTileObjects:()=>Jy,createLineSharedUniforms:()=>Sb,createMapLibreGeoAdapter:()=>Zb,createOutlineMaterial:()=>my,createSharedUniforms:()=>fy,createStyledMaterial:()=>py,createTexture:()=>cy,createThickLineMaterial:()=>Tb,default:()=>Qb,dxtPixelFormatOf:()=>q_,extractFovRadians:()=>qb,extractNearFar:()=>Kb,extractProjectionMatrix:()=>Gb,extractWorldCoordinateHelper:()=>Xb,isS3M1Buffer:()=>tg,lngLatFromMercator:()=>l_,lngLatFromWorld:()=>d_,measureSegments:()=>Zg,mercatorFromLngLat:()=>c_,parseS3M1:()=>pg,parseS3MB:()=>qg,resolveFeature:()=>Xg,resolveTextureKind:()=>K_,setMaxAnisotropy:()=>ty,worldFromLngLat:()=>u_});rh(),t_(),Z_(),dy(),jy(),Zy();var ex=globalThis;return ex.THREE||(ex.THREE=a),ex.S3MMapLibre=$b,e.AttributeQuery=o_,e.BinaryReader=sh,e.DEFAULT_FLOOR_HEIGHT=e_,e.DEFAULT_FOV=Yb,e.DEFAULT_STYLE=yy,e.DatasetManager=Ab,e.EARTH_RADIUS=s_,e.FeatureStyleManager=Fb,e.GroundManager=Ib,e.Picker=xb,e.PixelFormat=ly,e.S3MFormatError=Kg,e.S3MLayer=Qb,e.default=Qb,e.S3MTileset=sb,e.S3MViewer=Bb,e.S3M_VERSION=mg,e.SELECT_MODE=_y,e.SELECT_MODE_LABELS=vy,e.STYLE=hy,e.STYLE_LABELS=gy,e.TextureCompress=J_,e.VertexTag=hg,e.VertexTagV3=gg,e.buildAttributes=Qg,e.buildFeatureEdgeSegments=kb,e.buildOrthoMVP=Jb,e.buildThickLineGeometry=Eb,e.buildTileObjects=Jy,e.createLineSharedUniforms=Sb,e.createMapLibreGeoAdapter=Zb,e.createOutlineMaterial=my,e.createSharedUniforms=fy,e.createStyledMaterial=py,e.createTexture=cy,e.createThickLineMaterial=Tb,e.dxtPixelFormatOf=q_,e.extractFovRadians=qb,e.extractNearFar=Kb,e.extractProjectionMatrix=Gb,e.extractWorldCoordinateHelper=Xb,e.isS3M1Buffer=tg,e.lngLatFromMercator=l_,e.lngLatFromWorld=d_,e.measureSegments=Zg,e.mercatorFromLngLat=c_,e.parseS3M1=pg,e.parseS3MB=qg,e.resolveFeature=Xg,e.resolveTextureKind=K_,e.setMaxAnisotropy=ty,e.worldFromLngLat=u_,e})({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s3m-maplibre",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "SuperMap S3M 三维模型格式的 MapLibre / Mapbox 原生渲染图层:浏览器内直接解析 .s3mb 瓦片,无需转 3D Tiles,支持多数据集叠加、白膜/按高度/按单体/动态扫描着色、单体级 GPU 拾取与属性查询。基于 s3m-three 渲染内核。",
5
5
  "type": "module",
6
6
  "repository": {
@@ -60,7 +60,7 @@
60
60
  "author": "",
61
61
  "license": "Apache-2.0",
62
62
  "dependencies": {
63
- "s3m-three": "^0.3.2"
63
+ "s3m-three": "^0.3.3"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "three": ">=0.155.0"
@@ -40,6 +40,10 @@ export interface MapLike {
40
40
  projection?: { worldCoordinateHelper?: unknown };
41
41
  };
42
42
  getProjection?(): unknown;
43
+ /** 上下文恢复后用于把自定义图层重新加回地图(MapLibre / Mapbox 都有) */
44
+ getLayer?(id: string): unknown;
45
+ addLayer?(layer: unknown): unknown;
46
+ removeLayer?(id: string): unknown;
43
47
  }
44
48
 
45
49
  export interface MapMouseEventLike {
package/src/S3MLayer.ts CHANGED
@@ -109,6 +109,53 @@ export class S3MLayer {
109
109
  this.viewer.recomputeAnchors();
110
110
  };
111
111
 
112
+ /**
113
+ * WebGL 上下文是否处于丢失状态(丢失→恢复之间为 true)。
114
+ * 期间 render 会被 S3MViewer 内部短路,避免刷一堆 GL 错误。
115
+ */
116
+ private _contextLost = false;
117
+
118
+ /** 地图事件监听器是否已挂载,避免上下文恢复重加图层时重复绑定 */
119
+ private _listenersAttached = false;
120
+
121
+ private readonly _onContextLost = (): void => {
122
+ this._contextLost = true;
123
+ };
124
+
125
+ private readonly _onContextRestored = (): void => {
126
+ this._contextLost = false;
127
+ const map = this.map;
128
+ if (!map) return;
129
+ // MapLibre 在 webglcontextlost 时销毁 style 并丢弃自定义图层(自定义图层
130
+ // 无法序列化进 style),恢复后不会自动加回。这里手动重新 addLayer;onAdd 会识别
131
+ // 「已挂载」并原地换新 renderer,保留已加载的瓦片,不重新拉取。
132
+ try {
133
+ const getLayer = map.getLayer;
134
+ const addLayer = map.addLayer;
135
+ const has = typeof getLayer === 'function' ? getLayer.call(map, this.id) : undefined;
136
+ if (!has) {
137
+ if (typeof addLayer === 'function') addLayer.call(map, this);
138
+ } else {
139
+ // 极端情况下图层仍在(理论上不会):确保 renderer 指向新上下文
140
+ const gl = this._mapGl();
141
+ if (gl) this.viewer.restoreContext(gl);
142
+ }
143
+ } catch (e) {
144
+ console.warn('[s3m] WebGL 上下文恢复后重加图层失败,请手动 map.addLayer(layer)', e);
145
+ }
146
+ map.triggerRepaint();
147
+ };
148
+
149
+ /** 从画布取回当前的 WebGL 上下文(恢复后已是新上下文) */
150
+ private _mapGl(): WebGLRenderingContext | WebGL2RenderingContext | null {
151
+ const canvas = this.map?.getCanvas?.();
152
+ if (!canvas) return null;
153
+ return (
154
+ (canvas.getContext('webgl2') as WebGL2RenderingContext | null) ??
155
+ (canvas.getContext('webgl') as WebGLRenderingContext | null)
156
+ );
157
+ }
158
+
112
159
  constructor(options: S3MLayerOptions = {}) {
113
160
  this.id = options.id ?? 's3m';
114
161
  this.options = options;
@@ -149,13 +196,24 @@ export class S3MLayer {
149
196
  // 老版本回退标准墨卡托)同步进 viewer
150
197
  this.map = map;
151
198
 
152
- this.viewer.mount(map.getCanvas(), gl);
199
+ if (this.viewer.renderer) {
200
+ // 上下文恢复路径:onAdd 被再次触发(map.addLayer),原地换新 renderer,
201
+ // 保留已加载的场景与瓦片,不重建、不重拉。
202
+ this.viewer.restoreContext(gl);
203
+ } else {
204
+ this.viewer.mount(map.getCanvas(), gl);
205
+ }
153
206
 
154
- map.on('click', this._onClick);
155
- // 事件名必须是全称,写 'projection' 永远不会触发。v4 / v5 / Mapbox 没有这个事件,
156
- // 监听一个不存在的事件名是安全的(只是不 fire),初始投影在 onAdd 的 recomputeAnchors 里已覆盖。
157
- if (typeof map.on === 'function') {
158
- map.on('projectiontransition', this._onProjectionChange);
207
+ // 监听器只在首次挂载时绑定一次;上下文恢复重加图层时不重复绑定,
208
+ // 否则 click / projectiontransition 等会被挂多次。
209
+ if (!this._listenersAttached) {
210
+ map.on('click', this._onClick);
211
+ if (typeof map.on === 'function') {
212
+ map.on('projectiontransition', this._onProjectionChange);
213
+ map.on('webglcontextlost', this._onContextLost);
214
+ map.on('webglcontextrestored', this._onContextRestored);
215
+ }
216
+ this._listenersAttached = true;
159
217
  }
160
218
  }
161
219
 
@@ -163,7 +221,11 @@ export class S3MLayer {
163
221
  this.map?.off('click', this._onClick);
164
222
  if (typeof this.map?.off === 'function') {
165
223
  this.map.off('projectiontransition', this._onProjectionChange);
224
+ this.map.off('webglcontextlost', this._onContextLost);
225
+ this.map.off('webglcontextrestored', this._onContextRestored);
166
226
  }
227
+ this._listenersAttached = false;
228
+ this._contextLost = false;
167
229
  this.viewer.unmount();
168
230
  this.viewer.geo = null;
169
231
  this.map = null;
@@ -253,6 +315,9 @@ export class S3MLayer {
253
315
  const map = this.map;
254
316
  const anchor = this.viewer.sceneAnchor;
255
317
  if (!map || !anchor) return;
318
+ // 上下文丢失期间(丢失→恢复之间)不要渲染:renderer 指向失效的 gl,
319
+ // 真正恢复由 _onContextRestored → restoreContext 接管。
320
+ if (this._contextLost) return;
256
321
 
257
322
  const matrix = this._extractMatrix(arg);
258
323
  if (!matrix) return;