@juun-roh/cesium-utils 0.4.2 → 0.4.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.
@@ -1,245 +0,0 @@
1
- import { Color, Viewer, Entity, Primitive, GroundPrimitive, Model, Cesium3DTileset, Cesium3DTileFeature } from 'cesium';
2
-
3
- /**
4
- * @class
5
- * Lightweight multiton highlight manager for Cesium using flyweight pattern.
6
- *
7
- * @example
8
- * ```
9
- * // Setup
10
- * const viewer1 = new Viewer('cesiumContainer1');
11
- * const viewer2 = new Viewer('cesiumContainer2');
12
- *
13
- * const highlighter1 = Highlight.getInstance(viewer1);
14
- * const highlighter2 = Highlight.getInstance(viewer2);
15
- *
16
- * // This highlight only affects viewer1
17
- * highlighter1.show(someEntity, { color: Color.RED });
18
- *
19
- * // This highlight only affects viewer2
20
- * highlighter2.show(someEntity, { color: Color.BLUE });
21
- *
22
- * // When done with viewers
23
- * Highlight.releaseInstance(viewer1);
24
- * Highlight.releaseInstance(viewer2);
25
- * viewer1.destroy();
26
- * viewer2.destroy();
27
- * ```
28
- */
29
- declare class Highlight {
30
- private static instances;
31
- private _surface;
32
- private _silhouette;
33
- private _color;
34
- /**
35
- * Creates a new `Highlight` instance.
36
- * @private Use {@link getInstance `Highlight.getInstance()`}
37
- * @param viewer A viewer to create highlight entity in
38
- */
39
- private constructor();
40
- /** Gets the highlight color. */
41
- get color(): Color;
42
- /**
43
- * Sets the highlight color.
44
- * @param color The new color for highlights
45
- */
46
- set color(color: Color);
47
- /**
48
- * Gets or creates highlight instance from a viewer.
49
- * @param viewer The viewer to get or create a new instance from.
50
- */
51
- static getInstance(viewer: Viewer): Highlight;
52
- /**
53
- * Releases the highlight instance associated with a viewer.
54
- * @param viewer The viewer whose highlight instance should be released.
55
- */
56
- static releaseInstance(viewer: Viewer): void;
57
- /**
58
- * Highlights a picked object or a direct instance.
59
- * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
60
- * @param options Optional style for the highlight.
61
- * @see {@link Highlight.Options}
62
- */
63
- show(picked: Highlight.Picked, options?: Highlight.Options): void | Entity;
64
- private _getObject;
65
- /**
66
- * Clears the current highlight effects.
67
- */
68
- hide(): void;
69
- }
70
- declare namespace Highlight {
71
- export interface Base {
72
- show(object: any, options?: Highlight.Options): void;
73
- hide(): void;
74
- destroy(): void;
75
- color: Color;
76
- }
77
- export interface Options {
78
- /** Color of the highlight */
79
- color?: Color;
80
- /** To apply outline style for the highlight */
81
- outline?: boolean;
82
- /** Outline width */
83
- width?: number;
84
- }
85
- type PickedObject = {
86
- id?: Entity;
87
- primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
88
- tileset?: Cesium3DTileset;
89
- detail?: {
90
- model?: Model;
91
- };
92
- };
93
- export type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
94
- export { };
95
- }
96
-
97
- /**
98
- * @class
99
- * An implementation for highlighting 3D objects in Cesium.
100
- *
101
- * **Supported Object Types:**
102
- * - `Entity` with model graphics. (adjustable outline width)
103
- * - `Cesium3DTileset` instances. (fixed outline width)
104
- *
105
- * Currently supports outline style only.
106
- *
107
- * @example
108
- * ```typescript
109
- * const viewer = new Viewer("cesiumContainer");
110
- * const silhouetteHighlight = new SilhouetteHighlight(viewer);
111
- *
112
- * // Highlight an object
113
- * const entity = viewer.entities.add(new Entity({
114
- * model: new ModelGraphics(),
115
- * }));
116
- * silhouetteHighlight.show(entity);
117
- * ```
118
- */
119
- declare class SilhouetteHighlight implements Highlight.Base {
120
- private _color;
121
- private _silhouette;
122
- private _composite;
123
- private _stages;
124
- private _entity?;
125
- private _currentObject;
126
- private _currentOptions;
127
- /**
128
- * Creates a new `Silhouette` instance.
129
- * @param viewer A viewer to create highlight silhouette in
130
- */
131
- constructor(viewer: Viewer);
132
- /** Gets the highlight color. */
133
- get color(): Color;
134
- /** Sets the highlight color. */
135
- set color(color: Color);
136
- /** Gets the currently highlighted object */
137
- get currentObject(): Cesium3DTileFeature | Entity | undefined;
138
- /**
139
- * Highlights a picked `Cesium3DTileset` by updating silhouette composite.
140
- * @param object The object to be highlighted.
141
- * @param options Optional style for the highlight.
142
- */
143
- show(object: Cesium3DTileFeature, options?: Highlight.Options): void;
144
- /**
145
- * Highlights a picked `Entity` by updating the model properties.
146
- * @param object The object to be highlighted.
147
- * @param options Optional style for the highlight.
148
- */
149
- show(object: Entity, options?: Highlight.Options): void;
150
- /** Clears the current highlight */
151
- hide(): void;
152
- /** Clean up the instances */
153
- destroy(): void;
154
- /**
155
- * Compares two Highlight.Options objects for equality
156
- * @private
157
- */
158
- private _optionsEqual;
159
- /**
160
- * Clears all current highlights
161
- * @private
162
- */
163
- private _clearHighlights;
164
- }
165
-
166
- /**
167
- * @class
168
- * A flyweight implementation for highlighting 2D surface objects in Cesium.
169
- *
170
- * This class provides highlighting for ground-clamped geometries (polygons, polylines, rectangles)
171
- *
172
- * **Supported Geometry Types:**
173
- * - `Entity` with polygon, polyline, or rectangle graphics
174
- * - `GroundPrimitive` instances
175
- *
176
- * **Highlighting Modes:**
177
- * - **Fill mode** (default): Creates a filled geometry using the original shape
178
- * - **Outline mode**: Creates a polyline outline of the original geometry
179
- *
180
- * @example
181
- * ```typescript
182
- * // Basic usage
183
- * const viewer = new Viewer('cesiumContainer');
184
- * const surfaceHighlight = new SurfaceHighlight(viewer);
185
- *
186
- * // Highlight an entity with default red fill
187
- * const entity = viewer.entities.add(new Entity({
188
- * polygon: {
189
- * hierarchy: Cartesian3.fromDegreesArray([-75, 35, -74, 35, -74, 36, -75, 36]),
190
- * material: Color.BLUE
191
- * }
192
- * }));
193
- * surfaceHighlight.show(entity);
194
- * ```
195
- */
196
- declare class SurfaceHighlight implements Highlight.Base {
197
- private _color;
198
- private _entity;
199
- private _entities;
200
- private _currentObject;
201
- private _currentOptions;
202
- /**
203
- * Creates a new `SurfaceHighlight` instance.
204
- * @param viewer A viewer to create highlight entity in
205
- */
206
- constructor(viewer: Viewer);
207
- /** Gets the highlight color. */
208
- get color(): Color;
209
- /** Sets the highlight color. */
210
- set color(color: Color);
211
- /** Gets the highlight entity */
212
- get entity(): Entity;
213
- /** Gets the currently highlighted object */
214
- get currentObject(): Entity | GroundPrimitive | undefined;
215
- /**
216
- * Highlights a picked object by updating the reusable entity
217
- * @param object The object to be highlighted.
218
- * @param options Optional style for the highlight.
219
- * @see {@link Highlight.Options}
220
- */
221
- show(object: Entity | GroundPrimitive, options?: Highlight.Options): Entity | undefined;
222
- /**
223
- * Clears the current highlight
224
- */
225
- hide(): void;
226
- /** Clean up the instances */
227
- destroy(): void;
228
- /**
229
- * Compares two Highlight.Options objects for equality
230
- * @private
231
- */
232
- private _optionsEqual;
233
- /**
234
- * Removes all geometry properties from the highlight entity
235
- * @private
236
- */
237
- private _clearGeometries;
238
- /**
239
- * Updates the highlight entity from an Entity object
240
- * @private
241
- */
242
- private _update;
243
- }
244
-
245
- export { Highlight, SilhouetteHighlight, SurfaceHighlight };
@@ -1,245 +0,0 @@
1
- import { Color, Viewer, Entity, Primitive, GroundPrimitive, Model, Cesium3DTileset, Cesium3DTileFeature } from 'cesium';
2
-
3
- /**
4
- * @class
5
- * Lightweight multiton highlight manager for Cesium using flyweight pattern.
6
- *
7
- * @example
8
- * ```
9
- * // Setup
10
- * const viewer1 = new Viewer('cesiumContainer1');
11
- * const viewer2 = new Viewer('cesiumContainer2');
12
- *
13
- * const highlighter1 = Highlight.getInstance(viewer1);
14
- * const highlighter2 = Highlight.getInstance(viewer2);
15
- *
16
- * // This highlight only affects viewer1
17
- * highlighter1.show(someEntity, { color: Color.RED });
18
- *
19
- * // This highlight only affects viewer2
20
- * highlighter2.show(someEntity, { color: Color.BLUE });
21
- *
22
- * // When done with viewers
23
- * Highlight.releaseInstance(viewer1);
24
- * Highlight.releaseInstance(viewer2);
25
- * viewer1.destroy();
26
- * viewer2.destroy();
27
- * ```
28
- */
29
- declare class Highlight {
30
- private static instances;
31
- private _surface;
32
- private _silhouette;
33
- private _color;
34
- /**
35
- * Creates a new `Highlight` instance.
36
- * @private Use {@link getInstance `Highlight.getInstance()`}
37
- * @param viewer A viewer to create highlight entity in
38
- */
39
- private constructor();
40
- /** Gets the highlight color. */
41
- get color(): Color;
42
- /**
43
- * Sets the highlight color.
44
- * @param color The new color for highlights
45
- */
46
- set color(color: Color);
47
- /**
48
- * Gets or creates highlight instance from a viewer.
49
- * @param viewer The viewer to get or create a new instance from.
50
- */
51
- static getInstance(viewer: Viewer): Highlight;
52
- /**
53
- * Releases the highlight instance associated with a viewer.
54
- * @param viewer The viewer whose highlight instance should be released.
55
- */
56
- static releaseInstance(viewer: Viewer): void;
57
- /**
58
- * Highlights a picked object or a direct instance.
59
- * @param picked The result of `Scene.pick()` or direct instance to be highlighted.
60
- * @param options Optional style for the highlight.
61
- * @see {@link Highlight.Options}
62
- */
63
- show(picked: Highlight.Picked, options?: Highlight.Options): void | Entity;
64
- private _getObject;
65
- /**
66
- * Clears the current highlight effects.
67
- */
68
- hide(): void;
69
- }
70
- declare namespace Highlight {
71
- export interface Base {
72
- show(object: any, options?: Highlight.Options): void;
73
- hide(): void;
74
- destroy(): void;
75
- color: Color;
76
- }
77
- export interface Options {
78
- /** Color of the highlight */
79
- color?: Color;
80
- /** To apply outline style for the highlight */
81
- outline?: boolean;
82
- /** Outline width */
83
- width?: number;
84
- }
85
- type PickedObject = {
86
- id?: Entity;
87
- primitive?: Primitive | GroundPrimitive | Model | Cesium3DTileset;
88
- tileset?: Cesium3DTileset;
89
- detail?: {
90
- model?: Model;
91
- };
92
- };
93
- export type Picked = Entity | Cesium3DTileFeature | GroundPrimitive | PickedObject;
94
- export { };
95
- }
96
-
97
- /**
98
- * @class
99
- * An implementation for highlighting 3D objects in Cesium.
100
- *
101
- * **Supported Object Types:**
102
- * - `Entity` with model graphics. (adjustable outline width)
103
- * - `Cesium3DTileset` instances. (fixed outline width)
104
- *
105
- * Currently supports outline style only.
106
- *
107
- * @example
108
- * ```typescript
109
- * const viewer = new Viewer("cesiumContainer");
110
- * const silhouetteHighlight = new SilhouetteHighlight(viewer);
111
- *
112
- * // Highlight an object
113
- * const entity = viewer.entities.add(new Entity({
114
- * model: new ModelGraphics(),
115
- * }));
116
- * silhouetteHighlight.show(entity);
117
- * ```
118
- */
119
- declare class SilhouetteHighlight implements Highlight.Base {
120
- private _color;
121
- private _silhouette;
122
- private _composite;
123
- private _stages;
124
- private _entity?;
125
- private _currentObject;
126
- private _currentOptions;
127
- /**
128
- * Creates a new `Silhouette` instance.
129
- * @param viewer A viewer to create highlight silhouette in
130
- */
131
- constructor(viewer: Viewer);
132
- /** Gets the highlight color. */
133
- get color(): Color;
134
- /** Sets the highlight color. */
135
- set color(color: Color);
136
- /** Gets the currently highlighted object */
137
- get currentObject(): Cesium3DTileFeature | Entity | undefined;
138
- /**
139
- * Highlights a picked `Cesium3DTileset` by updating silhouette composite.
140
- * @param object The object to be highlighted.
141
- * @param options Optional style for the highlight.
142
- */
143
- show(object: Cesium3DTileFeature, options?: Highlight.Options): void;
144
- /**
145
- * Highlights a picked `Entity` by updating the model properties.
146
- * @param object The object to be highlighted.
147
- * @param options Optional style for the highlight.
148
- */
149
- show(object: Entity, options?: Highlight.Options): void;
150
- /** Clears the current highlight */
151
- hide(): void;
152
- /** Clean up the instances */
153
- destroy(): void;
154
- /**
155
- * Compares two Highlight.Options objects for equality
156
- * @private
157
- */
158
- private _optionsEqual;
159
- /**
160
- * Clears all current highlights
161
- * @private
162
- */
163
- private _clearHighlights;
164
- }
165
-
166
- /**
167
- * @class
168
- * A flyweight implementation for highlighting 2D surface objects in Cesium.
169
- *
170
- * This class provides highlighting for ground-clamped geometries (polygons, polylines, rectangles)
171
- *
172
- * **Supported Geometry Types:**
173
- * - `Entity` with polygon, polyline, or rectangle graphics
174
- * - `GroundPrimitive` instances
175
- *
176
- * **Highlighting Modes:**
177
- * - **Fill mode** (default): Creates a filled geometry using the original shape
178
- * - **Outline mode**: Creates a polyline outline of the original geometry
179
- *
180
- * @example
181
- * ```typescript
182
- * // Basic usage
183
- * const viewer = new Viewer('cesiumContainer');
184
- * const surfaceHighlight = new SurfaceHighlight(viewer);
185
- *
186
- * // Highlight an entity with default red fill
187
- * const entity = viewer.entities.add(new Entity({
188
- * polygon: {
189
- * hierarchy: Cartesian3.fromDegreesArray([-75, 35, -74, 35, -74, 36, -75, 36]),
190
- * material: Color.BLUE
191
- * }
192
- * }));
193
- * surfaceHighlight.show(entity);
194
- * ```
195
- */
196
- declare class SurfaceHighlight implements Highlight.Base {
197
- private _color;
198
- private _entity;
199
- private _entities;
200
- private _currentObject;
201
- private _currentOptions;
202
- /**
203
- * Creates a new `SurfaceHighlight` instance.
204
- * @param viewer A viewer to create highlight entity in
205
- */
206
- constructor(viewer: Viewer);
207
- /** Gets the highlight color. */
208
- get color(): Color;
209
- /** Sets the highlight color. */
210
- set color(color: Color);
211
- /** Gets the highlight entity */
212
- get entity(): Entity;
213
- /** Gets the currently highlighted object */
214
- get currentObject(): Entity | GroundPrimitive | undefined;
215
- /**
216
- * Highlights a picked object by updating the reusable entity
217
- * @param object The object to be highlighted.
218
- * @param options Optional style for the highlight.
219
- * @see {@link Highlight.Options}
220
- */
221
- show(object: Entity | GroundPrimitive, options?: Highlight.Options): Entity | undefined;
222
- /**
223
- * Clears the current highlight
224
- */
225
- hide(): void;
226
- /** Clean up the instances */
227
- destroy(): void;
228
- /**
229
- * Compares two Highlight.Options objects for equality
230
- * @private
231
- */
232
- private _optionsEqual;
233
- /**
234
- * Removes all geometry properties from the highlight entity
235
- * @private
236
- */
237
- private _clearGeometries;
238
- /**
239
- * Updates the highlight entity from an Entity object
240
- * @private
241
- */
242
- private _update;
243
- }
244
-
245
- export { Highlight, SilhouetteHighlight, SurfaceHighlight };
@@ -1,180 +0,0 @@
1
- import { TerrainProvider, TilingScheme, TileAvailability, Credit, Request, TerrainData } from 'cesium';
2
-
3
- /**
4
- * @class
5
- * Provides terrain by delegating requests to different terrain providers
6
- * based on geographic regions and zoom levels. This allows combining
7
- * multiple terrain sources into a single seamless terrain.
8
- *
9
- * @example
10
- * ``` typescript
11
- * // Tile-coordinate based for precise control (multiple levels)
12
- * const customTiles: TerrainTiles = new Map();
13
- * customTiles.set(15, { x: [55852, 55871], y: [9556, 9575] });
14
- * customTiles.set(16, { x: [111704, 111742], y: [19112, 19150] });
15
- *
16
- * const hybridTerrain = new HybridTerrainProvider({
17
- * regions: [
18
- * {
19
- * provider: customProvider,
20
- * tiles: customTiles,
21
- * }
22
- * ],
23
- * defaultProvider: worldTerrain
24
- * });
25
- *
26
- * viewer.terrainProvider = hybridTerrain;
27
- * ```
28
- */
29
- declare class HybridTerrainProvider implements TerrainProvider {
30
- private _regions;
31
- private _defaultProvider;
32
- private _fallbackProvider;
33
- private _tilingScheme;
34
- private _ready;
35
- private _availability?;
36
- /**
37
- * Creates a new `HybridTerrainProvider` instance.
38
- * @param options {@link HybridTerrainProvider.ConstructorOptions}
39
- * @returns A new `HybridTerrainProvider` instance.
40
- */
41
- constructor(options: HybridTerrainProvider.ConstructorOptions);
42
- /**
43
- * Gets a value indicating whether or not the provider is ready for use,
44
- * or a promise that resolves when the provider becomes ready.
45
- */
46
- get ready(): boolean;
47
- /**
48
- * Gets the tiling scheme used by this provider.
49
- */
50
- get tilingScheme(): TilingScheme;
51
- /**
52
- * Gets an object that can be used to determine availability of terrain from this provider.
53
- */
54
- get availability(): TileAvailability | undefined;
55
- /**
56
- * Gets the list of terrain regions managed by this provider.
57
- */
58
- get regions(): readonly HybridTerrainProvider.TerrainRegion[];
59
- /**
60
- * Gets the default terrain provider.
61
- */
62
- get defaultProvider(): TerrainProvider;
63
- /**
64
- * Gets the fallback terrain provider.
65
- */
66
- get fallbackProvider(): TerrainProvider;
67
- /**
68
- * Gets the credit to display when this terrain provider is active. Typically this is used to credit
69
- * the source of the terrain.
70
- */
71
- get credit(): Credit;
72
- /**
73
- * Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
74
- * to the event, you will be notified of the error and can potentially recover from it. Event listeners
75
- * are passed an instance of `TileProviderError`.
76
- */
77
- get errorEvent(): any;
78
- /**
79
- * Gets a value indicating whether or not the provider includes a water mask. The water mask
80
- * indicates which areas of the globe are water rather than land, so they can be rendered
81
- * as a reflective surface with animated waves.
82
- */
83
- get hasWaterMask(): boolean;
84
- /** Gets a value indicating whether or not the requested tiles include vertex normals. */
85
- get hasVertexNormals(): boolean;
86
- /**
87
- * Makes sure we load availability data for a tile
88
- * @param x - The X coordinate of the tile for which to request geometry.
89
- * @param y - The Y coordinate of the tile for which to request geometry.
90
- * @param level - The level of the tile for which to request geometry.
91
- * @returns Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
92
- */
93
- loadTileDataAvailability(x: number, y: number, level: number): Promise<void> | undefined;
94
- /**
95
- * Gets the maximum geometric error allowed in a tile at a given level.
96
- * @param level - The tile level for which to get the maximum geometric error.
97
- * @returns The maximum geometric error.
98
- */
99
- getLevelMaximumGeometricError(level: number): number;
100
- /**
101
- * Requests the terrain for a given tile coordinate.
102
- * @param x The X coordinate of the tile.
103
- * @param y The Y coordinate of the tile.
104
- * @param level The zoom level of the tile.
105
- * @param request The request.
106
- * @returns A promise for the requested terrain.
107
- */
108
- requestTileGeometry(x: number, y: number, level: number, request?: Request): Promise<TerrainData> | undefined;
109
- /**
110
- * Determines whether data for a tile is available to be loaded. Checks the specified terrain regions first.
111
- * @param x - The X coordinate of the tile for which to request geometry.
112
- * @param y - The Y coordinate of the tile for which to request geometry.
113
- * @param level - The level of the tile for which to request geometry.
114
- * @returns Undefined if not supported by the terrain provider, otherwise true or false.
115
- */
116
- getTileDataAvailable(x: number, y: number, level: number): boolean | undefined;
117
- }
118
- /**
119
- * @namespace
120
- * Contains types and factory methods for `HybridTerrainProvider` instance.
121
- */
122
- declare namespace HybridTerrainProvider {
123
- /** Initialization options for `HybridTerrainProvider` constructor. */
124
- interface ConstructorOptions {
125
- /** An array of terrain regions to include in the hybrid terrain. */
126
- regions?: TerrainRegion[];
127
- /** Default provider to use outside of specified terrain regions. */
128
- defaultProvider: TerrainProvider;
129
- /** Optional fallback provider when data is not available from default provider. @default EllipsoidTerrainProvider */
130
- fallbackProvider?: TerrainProvider;
131
- }
132
- /**
133
- * A factory function which creates a HybridTerrainProvider from tile-coordinate based regions.
134
- * @param regions Array of regions with tile-coordinate bounds
135
- * @param defaultProvider Default terrain provider
136
- * @param fallbackProvider Optional fallback provider
137
- */
138
- function fromTileRanges(regions: Array<{
139
- provider: TerrainProvider;
140
- tiles: Map<number, {
141
- x: number | [number, number];
142
- y: number | [number, number];
143
- }>;
144
- levels?: number[];
145
- }>, defaultProvider: TerrainProvider, fallbackProvider?: TerrainProvider): HybridTerrainProvider;
146
- /** Represents a terrain region with provider and geographic bounds. */
147
- interface TerrainRegion {
148
- /** The terrain provider for this region. */
149
- provider: TerrainProvider;
150
- /**
151
- * Tile-coordinate based bounds (precise control).
152
- * Map of level to tile coordinate ranges for that level.
153
- */
154
- tiles?: Map<number, {
155
- /** X tile coordinate range [min, max] or single value. */
156
- x: number | [number, number];
157
- /** Y tile coordinate range [min, max] or single value. */
158
- y: number | [number, number];
159
- }>;
160
- /** Optional level constraints. If specified, region only applies to these levels. */
161
- levels?: number[];
162
- }
163
- /**
164
- * @namespace
165
- * Utility functions for working with TerrainRegion objects.
166
- */
167
- namespace TerrainRegion {
168
- /**
169
- * Checks if a terrain region contains the specified tile.
170
- * @param region The terrain region to check
171
- * @param x The X coordinate of the tile
172
- * @param y The Y coordinate of the tile
173
- * @param level The zoom level of the tile
174
- * @returns True if the region contains the tile, false otherwise
175
- */
176
- function contains(region: HybridTerrainProvider.TerrainRegion, x: number, y: number, level: number): boolean;
177
- }
178
- }
179
-
180
- export { HybridTerrainProvider as H };