@juun-roh/cesium-utils 0.4.3 → 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,98 +0,0 @@
1
- /**
2
- * Utility for managing deprecation warnings in the cesium-utils library.
3
- * Provides runtime warnings to help developers identify deprecated API usage.
4
- */
5
- declare namespace Deprecate {
6
- /**
7
- * Configuration options for deprecation warnings.
8
- */
9
- interface Options {
10
- /**
11
- * Whether to show the warning only once per deprecation message.
12
- * @default true
13
- */
14
- once?: boolean;
15
- /**
16
- * Custom prefix for the warning message.
17
- * @default "[DEPRECATED]"
18
- */
19
- prefix?: string;
20
- /**
21
- * Whether to include a stack trace in the warning.
22
- * @default true
23
- */
24
- includeStack?: boolean;
25
- /**
26
- * Version when the feature will be removed.
27
- */
28
- removeInVersion?: string;
29
- }
30
- /**
31
- * Displays a deprecation warning message.
32
- *
33
- * @param message - The deprecation message to display
34
- * @param options - Configuration options for the warning
35
- *
36
- * @example
37
- * ```typescript
38
- * // Basic usage
39
- * deprecationWarning("oldFunction() is deprecated. Use newFunction() instead.");
40
- *
41
- * // With removal version
42
- * deprecationWarning("TerrainArea is deprecated.", {
43
- * removeInVersion: "v0.3.0"
44
- * });
45
- *
46
- * // Allow multiple warnings
47
- * deprecationWarning("Repeated warning", { once: false });
48
- * ```
49
- */
50
- function warn(message: string, options?: Options): void;
51
- /**
52
- * Creates a deprecation wrapper function that shows a warning when called.
53
- *
54
- * @param fn - The function to wrap
55
- * @param message - The deprecation message
56
- * @param options - Configuration options for the warning
57
- * @returns A wrapped function that shows a deprecation warning when called
58
- *
59
- * @example
60
- * ```typescript
61
- * const oldFunction = deprecate(
62
- * () => console.log("old implementation"),
63
- * "oldFunction() is deprecated. Use newFunction() instead."
64
- * );
65
- *
66
- * oldFunction(); // Shows warning and executes function
67
- * ```
68
- */
69
- function deprecate<T extends (...args: any[]) => any>(fn: T, message: string, options?: Options): T;
70
- /**
71
- * Clears all shown warning messages.
72
- * Useful for testing or when you want to reset the warning state.
73
- *
74
- * @example
75
- * ```typescript
76
- * clearDeprecationWarnings();
77
- * deprecationWarning("This will show again");
78
- * ```
79
- */
80
- function clear(): void;
81
- /**
82
- * Gets the count of unique deprecation warnings that have been shown.
83
- *
84
- * @returns The number of unique deprecation warnings shown
85
- */
86
- function getWarningCount(): number;
87
- /**
88
- * Checks if a specific deprecation warning has been shown.
89
- *
90
- * @param message - The deprecation message to check
91
- * @returns True if the warning has been shown, false otherwise
92
- */
93
- function hasShown(message: string): boolean;
94
- }
95
-
96
- declare const deprecate: typeof Deprecate.deprecate;
97
-
98
- export { Deprecate, deprecate };
@@ -1,105 +0,0 @@
1
- import { Viewer, Cartesian3, JulianDate, Color, Entity } from 'cesium';
2
-
3
- /**
4
- * @since Cesium 1.132.0
5
- * @experimental
6
- * Point sunlight analysis utility for shadow calculations.
7
- *
8
- * ⚠️ **Warning**: This is an experimental feature that uses Cesium's internal APIs.
9
- * The API may change or break in future versions of Cesium or cesium-utils.
10
- *
11
- * @example
12
- * ```typescript
13
- * const sunlight = new Sunlight(viewer);
14
- * sunlight.analyze(point, JulianDate.now());
15
- * ```
16
- */
17
- declare class Sunlight {
18
- private _uniformState;
19
- private _viewer;
20
- private _analyzing;
21
- private _pointEntityId?;
22
- private _objectsToExclude;
23
- private _polylines;
24
- private _points;
25
- constructor(viewer: Viewer);
26
- /** The sun position in 3D world coordinates at the current scene time. */
27
- get sunPositionWC(): Cartesian3;
28
- /** A normalized vector to the sun in 3D world coordinates at the current scene time. */
29
- get sunDirectionWC(): Cartesian3;
30
- /** Whether sunlight analysis is currently in progress. */
31
- get isAnalyzing(): boolean;
32
- /**
33
- * Gets virtual position and direction of the sun to reduce calculation overhead.
34
- *
35
- * @param from target point to start from
36
- * @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
37
- */
38
- virtualSun(from: Cartesian3, radius?: number): {
39
- position: Cartesian3;
40
- direction: Cartesian3;
41
- };
42
- /**
43
- * Analyze the sunlight acceptance from a given point at a given time.
44
- * @param from target point to analyze
45
- * @param at time to analyze
46
- * @param options {@link Sunlight.AnalyzeOptions}
47
- */
48
- analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
49
- /**
50
- * Analyze the sunlight acceptance from a given point at a given time range.
51
- * @param from target point to analyze
52
- * @param range time range to analyze
53
- * @param options {@link Sunlight.AnalyzeOptions}
54
- */
55
- analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
56
- /**
57
- * Remove all instances created for debug purpose
58
- */
59
- clear(): void;
60
- /**
61
- * Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
62
- * @param at where to create the entity
63
- * @param show whether to show point entity
64
- * @param errorBoundary size of the point entity for error tolerance
65
- */
66
- setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
67
- private _analyzeSingleTime;
68
- private _analyzeTimeRange;
69
- /**
70
- * @returns A promise tht resolves to an object containing the object and position of the first intersection.
71
- * @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
72
- */
73
- private _pick;
74
- private _getExcludedObjects;
75
- }
76
- declare namespace Sunlight {
77
- const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
78
- /** for time-range analysis */
79
- interface TimeRange {
80
- /** When to start analysis */
81
- start: JulianDate;
82
- /** When to end analysis */
83
- end: JulianDate;
84
- /** Step interval (seconds) inside the range */
85
- step: number;
86
- }
87
- interface AnalyzeOptions {
88
- /** List of objects to exclude from ray pick */
89
- objectsToExclude?: any[];
90
- /** size of the point entity for error tolerance */
91
- errorBoundary?: number;
92
- /** Whether to show sunlight paths */
93
- debugShowRays?: boolean;
94
- /** Whether to show points */
95
- debugShowPoints?: boolean;
96
- }
97
- interface AnalysisResult {
98
- /** ISO time string */
99
- timestamp: string;
100
- /** Whether the sunlight has reached */
101
- result: boolean | any;
102
- }
103
- }
104
-
105
- export { Sunlight };
@@ -1,105 +0,0 @@
1
- import { Viewer, Cartesian3, JulianDate, Color, Entity } from 'cesium';
2
-
3
- /**
4
- * @since Cesium 1.132.0
5
- * @experimental
6
- * Point sunlight analysis utility for shadow calculations.
7
- *
8
- * ⚠️ **Warning**: This is an experimental feature that uses Cesium's internal APIs.
9
- * The API may change or break in future versions of Cesium or cesium-utils.
10
- *
11
- * @example
12
- * ```typescript
13
- * const sunlight = new Sunlight(viewer);
14
- * sunlight.analyze(point, JulianDate.now());
15
- * ```
16
- */
17
- declare class Sunlight {
18
- private _uniformState;
19
- private _viewer;
20
- private _analyzing;
21
- private _pointEntityId?;
22
- private _objectsToExclude;
23
- private _polylines;
24
- private _points;
25
- constructor(viewer: Viewer);
26
- /** The sun position in 3D world coordinates at the current scene time. */
27
- get sunPositionWC(): Cartesian3;
28
- /** A normalized vector to the sun in 3D world coordinates at the current scene time. */
29
- get sunDirectionWC(): Cartesian3;
30
- /** Whether sunlight analysis is currently in progress. */
31
- get isAnalyzing(): boolean;
32
- /**
33
- * Gets virtual position and direction of the sun to reduce calculation overhead.
34
- *
35
- * @param from target point to start from
36
- * @param radius virtual distance between target point and the sun. Defaults to 10000 (10km)
37
- */
38
- virtualSun(from: Cartesian3, radius?: number): {
39
- position: Cartesian3;
40
- direction: Cartesian3;
41
- };
42
- /**
43
- * Analyze the sunlight acceptance from a given point at a given time.
44
- * @param from target point to analyze
45
- * @param at time to analyze
46
- * @param options {@link Sunlight.AnalyzeOptions}
47
- */
48
- analyze(from: Cartesian3, at: JulianDate, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult>;
49
- /**
50
- * Analyze the sunlight acceptance from a given point at a given time range.
51
- * @param from target point to analyze
52
- * @param range time range to analyze
53
- * @param options {@link Sunlight.AnalyzeOptions}
54
- */
55
- analyze(from: Cartesian3, range: Sunlight.TimeRange, options?: Sunlight.AnalyzeOptions): Promise<Sunlight.AnalysisResult[]>;
56
- /**
57
- * Remove all instances created for debug purpose
58
- */
59
- clear(): void;
60
- /**
61
- * Create an ellipsoid entity for ray collision detection to complement cesium's native click event accuracy
62
- * @param at where to create the entity
63
- * @param show whether to show point entity
64
- * @param errorBoundary size of the point entity for error tolerance
65
- */
66
- setTargetPoint(at: Cartesian3, show?: boolean, errorBoundary?: number, color?: Color): Entity;
67
- private _analyzeSingleTime;
68
- private _analyzeTimeRange;
69
- /**
70
- * @returns A promise tht resolves to an object containing the object and position of the first intersection.
71
- * @see https://github.com/CesiumGS/cesium/blob/1.136/packages/engine/Source/Scene/Scene.js#L4868
72
- */
73
- private _pick;
74
- private _getExcludedObjects;
75
- }
76
- declare namespace Sunlight {
77
- const DETECTION_ELLIPSOID_ID = "sunlight-detection-ellipsoid";
78
- /** for time-range analysis */
79
- interface TimeRange {
80
- /** When to start analysis */
81
- start: JulianDate;
82
- /** When to end analysis */
83
- end: JulianDate;
84
- /** Step interval (seconds) inside the range */
85
- step: number;
86
- }
87
- interface AnalyzeOptions {
88
- /** List of objects to exclude from ray pick */
89
- objectsToExclude?: any[];
90
- /** size of the point entity for error tolerance */
91
- errorBoundary?: number;
92
- /** Whether to show sunlight paths */
93
- debugShowRays?: boolean;
94
- /** Whether to show points */
95
- debugShowPoints?: boolean;
96
- }
97
- interface AnalysisResult {
98
- /** ISO time string */
99
- timestamp: string;
100
- /** Whether the sunlight has reached */
101
- result: boolean | any;
102
- }
103
- }
104
-
105
- export { Sunlight };
@@ -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 };