@soonspacejs/plugin-tiles 2.15.1 → 2.15.4

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.
@@ -41,7 +41,7 @@ export declare class GroundDecalManager {
41
41
  * 内部使用的 `PlotOverlay` 实例。
42
42
  * 注册到 `ImageOverlayPlugin` 的 `overlays` 数组中,顺序靠后者通常绘制在上层。
43
43
  */
44
- get plotSdfPlugin(): PlotSdfPlugin;
44
+ get plotSdfPlugin(): PlotSdfPlugin | undefined;
45
45
  /**
46
46
  * 绑定 / 更换 PlotOverlayPlugin(切换地形重建插件后调用)。
47
47
  * 如果当前已有图形,会在下一帧自动重新注册 overlay。
@@ -76,16 +76,33 @@ export type PlotArrowOptions = GisPlotBaseOptions & {
76
76
  };
77
77
  /** 文本标绘 */
78
78
  export type PlotTextAlign = 'left' | 'center' | 'right';
79
+ export type PlotTextVerticalAlign = 'top' | 'middle' | 'bottom';
80
+ export type PlotTextAnchorX = 'left' | 'center' | 'right';
81
+ export type PlotTextAnchorY = 'top' | 'middle' | 'bottom';
82
+ export type PlotTextLayoutDirection = 'horizontal' | 'vertical-rl' | 'vertical-lr';
83
+ /**
84
+ * Text box plot options.
85
+ * `points[0]` is the textbox anchor point in lon / lat degrees.
86
+ * `textAlign` / `verticalAlign` control content alignment inside the box.
87
+ * `anchorX` / `anchorY` control where the box sits relative to the anchor point.
88
+ */
79
89
  export type PlotTextOptions = GisPlotBaseOptions & {
80
90
  content: string;
81
91
  fontColor: string;
82
92
  fontSize: number;
93
+ scale?: number;
83
94
  textAlign?: PlotTextAlign;
84
- showBorder?: boolean;
85
- fillColor?: string;
86
- fillOpacity?: number;
95
+ verticalAlign?: PlotTextVerticalAlign;
96
+ anchorX?: PlotTextAnchorX;
97
+ anchorY?: PlotTextAnchorY;
98
+ boxWidth?: number;
99
+ boxHeight?: number;
100
+ padding?: number;
101
+ layoutDirection?: PlotTextLayoutDirection;
102
+ rotation?: number;
87
103
  offsetX?: number;
88
104
  offsetY?: number;
105
+ showBorder?: boolean;
89
106
  };
90
107
  /** 箭头快照:在 options 外附加 `generatedCoords` */
91
108
  export type GisPlotArrowSnapshot = GisPlotSnapshot<PlotArrowOptions> & {
@@ -13,17 +13,18 @@ export declare class OverlayManager {
13
13
  private imageOverlayPlugin;
14
14
  private resourceManager?;
15
15
  /** 存储所有 overlay 实例 */
16
+ private static readonly MAX_OVERLAY_INSTANCES;
16
17
  private _instances;
17
18
  constructor(imageOverlayPlugin: ImageOverlayPlugin | undefined, resourceManager?: ResourceManager | undefined);
18
- addGeoJSON(options: IGeoJSONOverlayOptions): GeoJSONOverlay | null;
19
+ addGeoJSONOverlay(options: IGeoJSONOverlayOptions): GeoJSONOverlay | null;
19
20
  updateGeoJSONColor(id: string, color: string): boolean;
20
21
  updateGeoJSONStrokeStyle(id: string, strokeStyle: string): boolean;
21
22
  updateGeoJSONStrokeWidth(id: string, strokeWidth: number): boolean;
22
23
  updateGeoJSONFillStyle(id: string, fillStyle: string): boolean;
23
24
  updateGeoJSONMode(id: string, mode: 'overlay' | 'mask' | 'invertMask'): boolean;
24
- addCesiumIon(options: ICesiumIonOverlayOptions): CesiumIonOverlay | null;
25
- addTMS(options: ITMSTilesOverlayOptions): TMSTilesOverlay | null;
26
- addXYZ(options: IXYZTilesOverlayOptions): XYZTilesOverlay | null;
25
+ addCesiumIonOverlay(options: ICesiumIonOverlayOptions): CesiumIonOverlay | null;
26
+ addTMSOverlay(options: ITMSTilesOverlayOptions): TMSTilesOverlay | null;
27
+ addXYZOverlay(options: IXYZTilesOverlayOptions): XYZTilesOverlay | null;
27
28
  /**
28
29
  * 添加 URL 模板 Overlay
29
30
  *
@@ -55,9 +56,9 @@ export declare class OverlayManager {
55
56
  * url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}'
56
57
  * })
57
58
  */
58
- addUrlTemplate(options: IUrlTemplateOverlayOptions): UrlTemplateTilesOverlay | null;
59
- addWMS(options: IWMSTilesOverlayOptions): Promise<WMSTilesOverlay | null>;
60
- addWMTS(options: IWMTSTilesOverlayOptions): Promise<WMTSTilesOverlay | null>;
59
+ addUrlTemplateOverlay(options: IUrlTemplateOverlayOptions): UrlTemplateTilesOverlay | null;
60
+ addWMSOverlay(options: IWMSTilesOverlayOptions): Promise<WMSTilesOverlay | null>;
61
+ addWMTSOverlay(options: IWMTSTilesOverlayOptions): Promise<WMTSTilesOverlay | null>;
61
62
  /**
62
63
  * 移除 overlay
63
64
  */
@@ -110,6 +111,7 @@ export declare class OverlayManager {
110
111
  * 获取 overlay 数量
111
112
  */
112
113
  get count(): number;
114
+ private _getImageOverlayPluginForAdd;
113
115
  /**
114
116
  * 获取本地影像数量(不依赖 ResourceManager)
115
117
  */
@@ -1,4 +1,4 @@
1
- import { TilesRenderer } from 'um-3d-tiles-renderer';
1
+ import { Tile, TilesRenderer } from 'um-3d-tiles-renderer';
2
2
  import { TilesFadePlugin, UpdateOnChangePlugin, ImageOverlayPlugin, ReorientationPlugin, PlotSdfPlugin } from 'um-3d-tiles-renderer/plugins';
3
3
  import { default as SoonSpace } from 'soonspacejs';
4
4
  import { TileCustomMaterialPlugin } from './plugins';
@@ -85,6 +85,14 @@ export declare class TerrainTilesRenderer {
85
85
  * 更新所有已加载模型的 alpha 裁剪模式
86
86
  */
87
87
  private _updateAlphaClipMode;
88
+ /**
89
+ * 添加影像或倾斜加载事件监听
90
+ */
91
+ addEventLoad(callback: (options: {
92
+ tile: Tile | null;
93
+ error: Error;
94
+ url: string | URL;
95
+ }) => void): void;
88
96
  /**
89
97
  * 设置地形
90
98
  * 会创建新的 TilesRenderer 实例以避免状态残留问题
@@ -105,59 +113,12 @@ export declare class TerrainTilesRenderer {
105
113
  */
106
114
  setTerrain(config: ITerrainConfig, options?: ITerrainTilesRendererOptions | undefined): void;
107
115
  /**
108
- * 添加 GeoJSON Overlay
109
- * @example
110
- * tilesRenderer.addGeoJSON({
111
- * id: 'china-boundary',
112
- * url: './data/china.geojson',
113
- * color: '#ff0000',
114
- * opacity: 0.8
115
- * })
116
+ * 添加 Overlay
117
+ * 根据 options.type 自动识别类型并调用对应方法
118
+ * @param options Overlay 配置选项,必须包含 type 字段
119
+ * @returns Overlay 实例或 null(如果添加失败)
116
120
  */
117
- addGeoJSON(options: IGeoJSONOverlayOptions): import('um-3d-tiles-renderer/plugins').GeoJSONOverlay | null;
118
- /**
119
- * 添加 Cesium Ion Overlay
120
- */
121
- addCesiumIonOverlay(options: ICesiumIonOverlayOptions): import('um-3d-tiles-renderer/plugins').CesiumIonOverlay | null;
122
- /**
123
- * 添加 TMS Tiles Overlay
124
- */
125
- addTMSOverlay(options: ITMSTilesOverlayOptions): import('um-3d-tiles-renderer/plugins').TMSTilesOverlay | null;
126
- /**
127
- * 添加 XYZ Tiles Overlay
128
- */
129
- addXYZOverlay(options: IXYZTilesOverlayOptions): import('um-3d-tiles-renderer/plugins').XYZTilesOverlay | null;
130
- /**
131
- * 添加 URL Template Overlay
132
- *
133
- * 支持多种 URL 模板变量:
134
- * - `{z}`, `{x}`, `{y}` - 标准 XYZ 坐标
135
- * - `{s}` - 子域名轮换
136
- * - `{reverseY}` - TMS 风格的 Y 坐标
137
- * - `{westDegrees}`, `{southDegrees}`, `{eastDegrees}`, `{northDegrees}` - 地理边界框
138
- *
139
- * @example
140
- * tilesPlugin.addUrlTemplateOverlay({
141
- * id: 'osm',
142
- * url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png'
143
- * })
144
- *
145
- * @example
146
- * tilesPlugin.addUrlTemplateOverlay({
147
- * id: 'carto',
148
- * url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png',
149
- * subdomains: 'abcd'
150
- * })
151
- */
152
- addUrlTemplateOverlay(options: IUrlTemplateOverlayOptions): import('um-3d-tiles-renderer/plugins').UrlTemplateTilesOverlay | null;
153
- /**
154
- * 添加 WMS Tiles Overlay
155
- */
156
- addWMSOverlay(options: IWMSTilesOverlayOptions): Promise<import('um-3d-tiles-renderer/plugins').WMSTilesOverlay | null>;
157
- /**
158
- * 添加 WMTS Tiles Overlay
159
- */
160
- addWMTSOverlay(options: IWMTSTilesOverlayOptions): Promise<import('um-3d-tiles-renderer/plugins').WMTSTilesOverlay | null>;
121
+ addOverlay(options: IGeoJSONOverlayOptions | ICesiumIonOverlayOptions | IGeoJSONOverlayOptions | ITMSTilesOverlayOptions | IXYZTilesOverlayOptions | IWMSTilesOverlayOptions | IWMTSTilesOverlayOptions | IUrlTemplateOverlayOptions): Promise<import('um-3d-tiles-renderer/plugins').XYZTilesOverlay | import('um-3d-tiles-renderer/plugins').GeoJSONOverlay | import('um-3d-tiles-renderer/plugins').CesiumIonOverlay | import('um-3d-tiles-renderer/plugins').TMSTilesOverlay | import('um-3d-tiles-renderer/plugins').UrlTemplateTilesOverlay | import('um-3d-tiles-renderer/plugins').WMSTilesOverlay | import('um-3d-tiles-renderer/plugins').WMTSTilesOverlay | null>;
161
122
  /**
162
123
  * 移除指定 overlay
163
124
  */
@@ -185,6 +146,12 @@ export declare class TerrainTilesRenderer {
185
146
  * 更新 GeoJSON 填充样式
186
147
  */
187
148
  updateGeoJSONFillStyle(id: string, fillStyle: string): boolean;
149
+ /**
150
+ * 合并多个 GeoJSON
151
+ * @param geojsons 待合并的 GeoJSON 数组
152
+ * @returns 合并后的 GeoJSON
153
+ */
154
+ mergeGeoJSON(geojsons: any[]): import('geojson-merge-ts').GeoJSONFeatureCollection;
188
155
  /**
189
156
  * 设置 overlay 层级顺序
190
157
  * @param id overlay ID
@@ -82,6 +82,8 @@ export interface IOverlayBaseOptions {
82
82
  opacity?: number;
83
83
  /** 层级顺序(数值越大越靠上),默认按添加顺序 */
84
84
  order?: number;
85
+ /** 类型 */
86
+ type: OverlayType;
85
87
  }
86
88
  /**
87
89
  * GeoJSON Overlay 配置
@@ -1,5 +1,19 @@
1
1
  import { default as SoonSpace } from 'soonspacejs';
2
2
  import { TilesRenderer, ITilesRendererOptions, ICesiumIonOptions } from './TilesRenderer';
3
+ import { IReorientationOptions } from '../terrain-tiles-renderer/types';
4
+ export type ReferencePlacementUp = '+x' | '-x' | '+y' | '-y' | '+z' | '-z' | 'x' | 'y' | 'z';
5
+ export type IReferenceOriginOptions = IReorientationOptions;
6
+ export interface IReferencePlacementOptions extends IReorientationOptions {
7
+ /** Local up axis of the tileset. Default is +z, matching ReorientationPlugin. */
8
+ up?: ReferencePlacementUp;
9
+ }
10
+ export type IManagedTilesRendererOptions = (ITilesRendererOptions | ICesiumIonOptions) & {
11
+ /**
12
+ * Place this tileset relative to the manager reference origin.
13
+ * If omitted and reference origin is set, the existing reorientation option is used as placement.
14
+ */
15
+ placement?: IReferencePlacementOptions | false;
16
+ };
3
17
  /**
4
18
  * TilesRendererManager - 管理多个 TilesRenderer 实例
5
19
  * 参考 TilesPlugin 的设计
@@ -15,16 +29,32 @@ export declare class TilesRendererManager {
15
29
  private _lruCache;
16
30
  private _parseQueue;
17
31
  private _downloadQueue;
32
+ private _referenceOrigin;
33
+ private _referencePlacements;
34
+ private _referenceFrame;
35
+ private _targetFrame;
36
+ private _sourceFrame;
37
+ private _placementMatrix;
38
+ private _upCorrectionMatrix;
39
+ private _boundingSphere;
18
40
  constructor(ssp: SoonSpace);
19
41
  private _beforeRenderHandler;
20
42
  private _onCameraObjectChange;
43
+ get referenceOrigin(): IReferenceOriginOptions | null;
44
+ /**
45
+ * Set the shared geographic origin provided by terrain.
46
+ * Tiles with placement / reorientation are positioned relative to this origin.
47
+ */
48
+ setReferenceOrigin(origin: IReferenceOriginOptions): void;
49
+ setReferenceOrigin(lon: number, lat: number, height?: number): void;
50
+ clearReferenceOrigin(): void;
21
51
  /**
22
52
  * 加载 3D Tiles
23
53
  * @param url - tileset.json 地址
24
54
  * @param options - 配置项
25
55
  * @returns Promise<ThreeDTilesRenderer>
26
56
  */
27
- loadTiles(options: ITilesRendererOptions | ICesiumIonOptions): Promise<TilesRenderer | undefined>;
57
+ loadTiles(options: IManagedTilesRendererOptions): Promise<TilesRenderer | undefined>;
28
58
  /**
29
59
  * 移除 3D Tiles
30
60
  * @param url - tileset.json 地址
@@ -43,7 +73,13 @@ export declare class TilesRendererManager {
43
73
  * 清除所有 tiles
44
74
  */
45
75
  clear(): void;
46
- invalidate(lon: number, lat: number, alt: number): void;
76
+ invalidate(lon: number, lat: number, alt: number, targetRenderer?: TilesRenderer): void;
77
+ applyReferencePlacement(renderer: TilesRenderer, placement: IReferencePlacementOptions | null): boolean;
78
+ private _isGeoreferenced;
79
+ private _getSourceFrame;
80
+ private _getReferencePlacement;
81
+ private _getTilesRendererOptions;
82
+ private _getUpCorrectionMatrix;
47
83
  /**
48
84
  * 销毁插件
49
85
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@soonspacejs/plugin-tiles",
3
3
  "pluginName": "TilesPlugin",
4
- "version": "2.15.1",
4
+ "version": "2.15.4",
5
5
  "description": "3D Tiles plugin for SoonSpace.js",
6
6
  "main": "dist/index.esm.js",
7
7
  "module": "dist/index.esm.js",
@@ -18,8 +18,9 @@
18
18
  "license": "UNLICENSED",
19
19
  "gitHead": "4a87dd85050651088e11c3da777c49fab3db7e5d",
20
20
  "peerDependencies": {
21
- "um-3d-tiles-renderer": "^0.4.41",
21
+ "um-3d-tiles-renderer": "^0.4.46",
22
22
  "three": "^0.183.0",
23
- "soonspacejs": "2.15.1"
23
+ "@mapbox/geojson-merge": "^1.1.1",
24
+ "soonspacejs": "2.15.4"
24
25
  }
25
26
  }