bruce-cesium 7.2.1 → 7.2.2

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,4 +1,4 @@
1
- import { Style } from "bruce-models";
1
+ import { Calculator, Style } from "bruce-models";
2
2
  import * as Cesium from "cesium";
3
3
  export declare namespace TextureFrameSeriesAnimator {
4
4
  /**
@@ -30,7 +30,102 @@ export declare namespace TextureFrameSeriesAnimator {
30
30
  };
31
31
  BaselineValueMin?: number;
32
32
  BaselineValueMax?: number;
33
+ Measure?: string;
34
+ AnomalyMax?: number;
35
+ Floor?: {
36
+ ByteOffset: number;
37
+ ByteLength: number;
38
+ };
39
+ Ceiling?: {
40
+ ByteOffset: number;
41
+ ByteLength: number;
42
+ };
43
+ ExtremesValueMin?: number;
44
+ ExtremesValueMax?: number;
45
+ Layout?: string;
46
+ TileTexels?: number;
47
+ Times?: string[];
48
+ Tiles?: ITileEntry[];
49
+ GeneratorVersion?: number;
50
+ Quantity?: string;
33
51
  }
52
+ const QUANTITY_THICKNESS = "thickness";
53
+ const QUANTITY_ELEVATION = "elevation";
54
+ /**
55
+ * One tile of an adaptive pyramid.
56
+ *
57
+ * TexelMetres is the ground size of one of its texels, which is what lets a viewer see where the
58
+ * model actually has detail rather than presenting one resolution as if it were uniform.
59
+ */
60
+ interface ITileEntry {
61
+ Level: number;
62
+ X: number;
63
+ Y: number;
64
+ West: number;
65
+ East: number;
66
+ South: number;
67
+ North: number;
68
+ TexelMetres: number;
69
+ ResolutionX: number;
70
+ ResolutionY: number;
71
+ Frames: {
72
+ ByteOffset: number;
73
+ ByteLength: number;
74
+ }[];
75
+ Floor?: {
76
+ ByteOffset: number;
77
+ ByteLength: number;
78
+ };
79
+ Ceiling?: {
80
+ ByteOffset: number;
81
+ ByteLength: number;
82
+ };
83
+ BaselineMask?: {
84
+ ByteOffset: number;
85
+ ByteLength: number;
86
+ };
87
+ }
88
+ const LAYOUT_TILES = "tiles";
89
+ /**
90
+ * The generator that produced an archive, for telling a stale one from a current one.
91
+ *
92
+ * Read the version rather than sniffing for fields: an archive can legitimately omit Tiles or
93
+ * GeoidSeparation and still be current, so their absence says nothing about its age.
94
+ * @param metadata the archive's Data.generation
95
+ */
96
+ function GeneratorVersion(metadata: IFrameArchiveMetadata | undefined): number;
97
+ /**
98
+ * Whether an archive is an adaptive pyramid rather than one raster.
99
+ * @param metadata the archive's Data.generation
100
+ */
101
+ function IsTiledLayout(metadata: IFrameArchiveMetadata | undefined): boolean;
102
+ const MEASURE_ABSOLUTE = "absolute";
103
+ const MEASURE_ANOMALY = "anomaly";
104
+ /**
105
+ * Turns a value in the attribute's own units into the 0 to 1 position the ramp is indexed by.
106
+ *
107
+ * Stops are authored in real units, since "hide anything under 0.1 m" is the sentence a user
108
+ * actually has, and the archive's own published range is what makes that expressible.
109
+ * @param metadata the archive's Data.generation
110
+ * @param value in the attribute's units
111
+ */
112
+ function NormalisePosition(metadata: IFrameArchiveMetadata | undefined, value: number): number;
113
+ /**
114
+ * Whether the frames are a departure from each cell's own normal rather than a raw reading.
115
+ *
116
+ * Worth asking before labelling anything: the two measures need different words for the same
117
+ * number, and calling an anomaly "water depth" is a worse error than the coarse ramp it replaced.
118
+ * @param metadata the archive's Data.generation
119
+ */
120
+ function IsAnomalyMeasure(metadata: IFrameArchiveMetadata | undefined): boolean;
121
+ /**
122
+ * How much the value moves anywhere in the series, in source units.
123
+ *
124
+ * Falls back to the published range, which is the right answer for an anomaly archive (its range
125
+ * IS the movement) and the only available one for an archive predating AnomalyMax.
126
+ * @param metadata the archive's Data.generation
127
+ */
128
+ function MovingRange(metadata: IFrameArchiveMetadata | undefined): number | undefined;
34
129
  /**
35
130
  * Detects whether a ClientFile's `Data.generation` metadata describes a frame archive rather than a single static image,
36
131
  * so a caller can decide whether to construct an Animator or fall back to the existing static-texture path.
@@ -39,15 +134,44 @@ export declare namespace TextureFrameSeriesAnimator {
39
134
  function IsFrameArchiveMetadata(data: any): data is {
40
135
  generation: IFrameArchiveMetadata;
41
136
  };
137
+ /**
138
+ * Structural copies of the style shapes this consumes.
139
+ */
140
+ interface IExtent {
141
+ West: number;
142
+ East: number;
143
+ South: number;
144
+ North: number;
145
+ }
146
+ interface ICellBorder {
147
+ color: Calculator.IField[];
148
+ width: Calculator.IField[];
149
+ }
150
+ interface IRampPoint {
151
+ position: number;
152
+ color: string;
153
+ }
154
+ function AppearanceSignature(options: {
155
+ valueCanvas?: boolean;
156
+ drape?: IExtent;
157
+ textureColorMask?: Style.ITextureColorMask;
158
+ cellBorder?: ICellBorder;
159
+ cellTexels?: number;
160
+ maskBaseline?: boolean;
161
+ }): string;
42
162
  interface IOptions {
43
163
  viewer: Cesium.Viewer;
44
164
  entity: Cesium.Entity;
45
165
  archiveUrl: string;
46
166
  frames: IFrameEntry[];
47
167
  textureColorMask?: Style.ITextureColorMask;
168
+ cellBorder?: ICellBorder;
169
+ cellTexels?: number;
170
+ metadata?: IFrameArchiveMetadata;
48
171
  crossfadeMs?: number;
49
172
  driveMaterial?: boolean;
50
173
  produceValueCanvas?: boolean;
174
+ drapeExtent?: IExtent;
51
175
  baselineMask?: {
52
176
  ByteOffset: number;
53
177
  ByteLength: number;
@@ -88,11 +212,21 @@ export declare namespace TextureFrameSeriesAnimator {
88
212
  private readonly pool;
89
213
  private poolIdx;
90
214
  private readonly imageProperty;
215
+ private readonly appearance;
216
+ private readonly rampStops;
217
+ private readonly cellBorder;
91
218
  private readonly driveMaterial;
92
219
  private readonly produceValueCanvas;
220
+ private readonly metadata?;
221
+ private readonly drapeExtent?;
222
+ private readonly tiles?;
223
+ private scratch;
93
224
  private readonly valueCanvas;
94
225
  private valueDims;
95
226
  private presentVersion;
227
+ private extremesLoad;
228
+ private floorPixels;
229
+ private ceilingPixels;
96
230
  constructor(options: IOptions);
97
231
  /**
98
232
  * Explicit teardown: stops driving the entity's material, abandons any in-flight/pending fetch (results are simply ignored when they land),
@@ -100,6 +234,7 @@ export declare namespace TextureFrameSeriesAnimator {
100
234
  */
101
235
  Dispose(): void;
102
236
  IsDisposed(): boolean;
237
+ GetAppearanceSignature(): string;
103
238
  /**
104
239
  * The archive URL this instance was constructed with,
105
240
  * lets a caller re-rendering the same entity tell whether an existing instance is already correct, without reaching into private state.
@@ -110,6 +245,13 @@ export declare namespace TextureFrameSeriesAnimator {
110
245
  * material (eg: re-tinting for opacity/selection) without detaching the animation.
111
246
  */
112
247
  GetImageProperty(): Cesium.CallbackProperty;
248
+ /**
249
+ * The presented frame's TINTED pixels, where alpha is what the ramp actually painted.
250
+ *
251
+ * Distinct from the value canvas, whose alpha only says a texel has data. A cell can hold a
252
+ * reading and still be painted nothing, which is exactly what a hidden floor band does.
253
+ */
254
+ GetDisplayedPixels(): Uint8ClampedArray | null;
113
255
  /**
114
256
  * The untinted canvas carrying the presented frame's value in RGB and its coverage in alpha,
115
257
  * or null unless the instance was constructed with produceValueCanvas.
@@ -136,6 +278,35 @@ export declare namespace TextureFrameSeriesAnimator {
136
278
  height: number;
137
279
  valuePixels?: Uint8ClampedArray;
138
280
  }>;
281
+ private composeTiles;
282
+ private compositeExtent;
283
+ private compositeSize;
284
+ protected tint(imageData: ImageData): {
285
+ pixels: Uint8ClampedArray;
286
+ width: number;
287
+ height: number;
288
+ valuePixels?: Uint8ClampedArray;
289
+ };
290
+ private writeInto;
291
+ private sourceRect;
292
+ /**
293
+ * The archive's per-cell floor and ceiling rasters, once EnsureExtremes has resolved.
294
+ */
295
+ GetExtremes(): {
296
+ floor: ImageData | null;
297
+ ceiling: ImageData | null;
298
+ };
299
+ /**
300
+ * Fetches and decodes the floor and ceiling rasters, at most once.
301
+ */
302
+ EnsureExtremes(): Promise<void>;
303
+ private loadTiledBaselineMask;
304
+ private loadTiledExtremes;
305
+ private tileRect;
306
+ private decodeSlices;
307
+ private loadImageAt;
308
+ private remap;
309
+ private loadImageDataAt;
139
310
  /**
140
311
  * Fetches and decodes the archive's static baseline mask, at most once.
141
312
  */
@@ -0,0 +1,139 @@
1
+ import * as Cesium from "cesium";
2
+ import { TextureFrameSeriesAnimator } from "./texture-frame-series-animator";
3
+ /**
4
+ * Prints a value texture's own numbers over the cells they belong to.
5
+ */
6
+ export declare namespace TextureValueLabels {
7
+ /**
8
+ * A structural copy of the style shape, for the same reason the animator keeps one: a host app
9
+ * may be on an older published bruce-models than the one that introduced it.
10
+ */
11
+ interface ISettings {
12
+ minCellPixels?: number;
13
+ minSpacingPixels?: number;
14
+ maxLabels?: number;
15
+ decimals?: number;
16
+ parts?: ("value" | "floor" | "ceiling")[];
17
+ gridColor?: string;
18
+ gridWidthPixels?: number;
19
+ minGridCellPixels?: number;
20
+ }
21
+ /**
22
+ * One tile's footprint and cell count, for drawing a grid at the tile's own resolution.
23
+ */
24
+ interface ITileGrid {
25
+ West: number;
26
+ East: number;
27
+ South: number;
28
+ North: number;
29
+ ResolutionX: number;
30
+ ResolutionY: number;
31
+ }
32
+ interface IExtent {
33
+ West: number;
34
+ East: number;
35
+ South: number;
36
+ North: number;
37
+ }
38
+ interface IOptions {
39
+ viewer: Cesium.Viewer;
40
+ extent: IExtent;
41
+ settings?: ISettings;
42
+ metadata?: TextureFrameSeriesAnimator.IFrameArchiveMetadata;
43
+ tiles?: ITileGrid[];
44
+ clipRing?: {
45
+ lon: number;
46
+ lat: number;
47
+ }[];
48
+ }
49
+ /**
50
+ * One cell's numbers, in the attribute's own units.
51
+ */
52
+ interface IReading {
53
+ value: number;
54
+ floor?: number;
55
+ ceiling?: number;
56
+ }
57
+ /**
58
+ * A clip outline from a projected ring, or null when the ring cannot be drawn.
59
+ * @param projected one entry per ring vertex, null where the vertex has no window coordinate
60
+ */
61
+ function ClipOutline(projected: ({
62
+ x: number;
63
+ y: number;
64
+ } | null)[]): {
65
+ x: number;
66
+ y: number;
67
+ }[] | null;
68
+ /**
69
+ * How many cells apart labels should sit, as a power of two.
70
+ * @param options cellPixels is one cell's size on screen, held is the stride already in use
71
+ */
72
+ function ChooseLabelStride(options: {
73
+ cellPixels: number;
74
+ visibleCols: number;
75
+ visibleRows: number;
76
+ maxLabels: number;
77
+ minSpacingPixels: number;
78
+ held?: number;
79
+ }): number;
80
+ class Labels {
81
+ private readonly viewer;
82
+ private readonly canvas;
83
+ private readonly ctx;
84
+ private readonly settings;
85
+ private extent;
86
+ private metadata?;
87
+ private tiles?;
88
+ private clipRing?;
89
+ private source;
90
+ private painted;
91
+ private floor;
92
+ private ceiling;
93
+ private disposed;
94
+ private drawn;
95
+ private stride;
96
+ constructor(options: IOptions);
97
+ SetExtent(extent: IExtent): void;
98
+ /**
99
+ * The current frame's decoded values, as the animator's value canvas already provides them.
100
+ * @param source value pixels, one texel per cell
101
+ */
102
+ SetSource(source: ImageData | null): void;
103
+ /**
104
+ * The tinted pixels of the same frame, so the grid can skip cells the ramp painted nothing in.
105
+ * @param painted RGBA of the presented frame, or null to fall back to coverage alone
106
+ */
107
+ SetPainted(painted: Uint8ClampedArray | null): void;
108
+ /**
109
+ * The archive's per-cell extremes, when it publishes them. Without these a label can still
110
+ * print the current reading, just not the range behind it.
111
+ */
112
+ SetExtremes(floor: ImageData | null, ceiling: ImageData | null): void;
113
+ GetDrawnCount(): number;
114
+ Clear(): void;
115
+ Dispose(): void;
116
+ /**
117
+ * Redraws every visible label. Cheap enough to call per rendered frame, because the cell
118
+ * count it considers is bounded by the view rather than by the texture.
119
+ */
120
+ Render(): void;
121
+ private drawGrid;
122
+ private applyRingClip;
123
+ private tileCellOutline;
124
+ private drawTileGrid;
125
+ private groundAtScreenCentre;
126
+ private coveredAt;
127
+ private isCovered;
128
+ private widestLabel;
129
+ private cellOutline;
130
+ private drawLabel;
131
+ private readNear;
132
+ private paintedAt;
133
+ private readAt;
134
+ private lonAt;
135
+ private latAt;
136
+ private visibleTexels;
137
+ private project;
138
+ }
139
+ }
@@ -438,6 +438,7 @@ export declare namespace VisualsRegister {
438
438
  requestRender?: boolean;
439
439
  source?: EUpdateSource;
440
440
  lazy?: boolean;
441
+ keepVisual?: Visual;
441
442
  onComplete?: () => void;
442
443
  }): void;
443
444
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bruce-cesium",
3
- "version": "7.2.1",
3
+ "version": "7.2.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/bruce-cesium.umd.js",
@@ -83,7 +83,7 @@
83
83
  "typescript": "^5.0.4"
84
84
  },
85
85
  "dependencies": {
86
- "bruce-models": "^7.1.75",
86
+ "bruce-models": "^7.1.78",
87
87
  "tslib": "^2.4.1"
88
88
  }
89
89
  }