bruce-cesium 7.5.7 → 7.5.9

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.
Files changed (25) hide show
  1. package/dist/bruce-cesium.es5.js +1918 -330
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +1916 -328
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +1 -1
  6. package/dist/lib/rendering/displaced-surface-primitive.js +187 -36
  7. package/dist/lib/rendering/displaced-surface-primitive.js.map +1 -1
  8. package/dist/lib/rendering/entity-render-engine-polygon.js +20 -9
  9. package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
  10. package/dist/lib/rendering/render-managers/common/entity-label.js +975 -57
  11. package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
  12. package/dist/lib/rendering/texture-frame-series-animator.js +220 -20
  13. package/dist/lib/rendering/texture-frame-series-animator.js.map +1 -1
  14. package/dist/lib/rendering/texture-value-labels.js +478 -194
  15. package/dist/lib/rendering/texture-value-labels.js.map +1 -1
  16. package/dist/lib/rendering/visuals-register.js +34 -9
  17. package/dist/lib/rendering/visuals-register.js.map +1 -1
  18. package/dist/types/bruce-cesium.d.ts +1 -1
  19. package/dist/types/rendering/displaced-surface-primitive.d.ts +32 -0
  20. package/dist/types/rendering/entity-render-engine-polygon.d.ts +1 -0
  21. package/dist/types/rendering/render-managers/common/entity-label.d.ts +134 -20
  22. package/dist/types/rendering/texture-frame-series-animator.d.ts +42 -0
  23. package/dist/types/rendering/texture-value-labels.d.ts +59 -11
  24. package/dist/types/rendering/visuals-register.d.ts +7 -0
  25. package/package.json +2 -2
@@ -6,8 +6,8 @@ import { GetClusterIconPriority } from "./point-clustering-core";
6
6
  * Util for generating labels within cesium space on entities.
7
7
  */
8
8
  export declare namespace EntityLabel {
9
- const ATTACH_KEY = "nextspace-navigator-entity-label";
10
- interface IOptions {
9
+ export const ATTACH_KEY = "nextspace-navigator-entity-label";
10
+ export interface IOptions {
11
11
  presentation?: "text" | "icon" | "icon-text-above" | "icon-text-side";
12
12
  text?: string;
13
13
  icon?: string;
@@ -51,12 +51,12 @@ export declare namespace EntityLabel {
51
51
  representative?: "status" | "nearest";
52
52
  };
53
53
  }
54
- function HasIcon(options: IOptions): boolean;
55
- function IsImageUrl(value: string): boolean;
56
- function GetDefaultImageUrl(entity: Entity.IEntity, api?: BruceApi.Api): string;
57
- function WithPhoto(options: IOptions, url: string): IOptions;
58
- function PhotoShape(width: number, height: number): "circle" | "rect";
59
- interface IHoverRingState {
54
+ export function HasIcon(options: IOptions): boolean;
55
+ export function IsImageUrl(value: string): boolean;
56
+ export function GetDefaultImageUrl(entity: Entity.IEntity, api?: BruceApi.Api): string;
57
+ export function WithPhoto(options: IOptions, url: string): IOptions;
58
+ export function PhotoShape(width: number, height: number): "circle" | "rect";
59
+ export interface IHoverRingState {
60
60
  animation?: {
61
61
  target: number;
62
62
  targetInner: number;
@@ -70,7 +70,14 @@ export declare namespace EntityLabel {
70
70
  arcTime?: number;
71
71
  };
72
72
  }
73
- interface IFrame {
73
+ export interface IModelBoxFrame {
74
+ points: TPoint[];
75
+ hull: TPoint[];
76
+ outline: TPoint[];
77
+ anchor: TPoint;
78
+ group: string;
79
+ }
80
+ export interface IFrame {
74
81
  canFlip?: boolean;
75
82
  textWrapped?: boolean;
76
83
  hasLeader?: boolean;
@@ -82,6 +89,8 @@ export declare namespace EntityLabel {
82
89
  leaderSide?: "left" | "right";
83
90
  distance?: number;
84
91
  iconRadius?: number;
92
+ modelBox?: IModelBoxFrame;
93
+ boxBlend?: number;
85
94
  id: string;
86
95
  text?: string;
87
96
  clusterBounds?: {
@@ -104,8 +113,8 @@ export declare namespace EntityLabel {
104
113
  priority?: number;
105
114
  options?: IOptions;
106
115
  }
107
- type TIconLook = Pick<IOptions, "icon" | "iconUrl" | "iconClass" | "iconColor" | "iconBackground" | "iconPhoto">;
108
- interface IPlacement {
116
+ export type TIconLook = Pick<IOptions, "icon" | "iconUrl" | "iconClass" | "iconColor" | "iconBackground" | "iconPhoto">;
117
+ export interface IPlacement {
109
118
  textSide?: "left" | "right";
110
119
  icons?: TIconLook[];
111
120
  frame: IFrame;
@@ -116,7 +125,7 @@ export declare namespace EntityLabel {
116
125
  members: string[];
117
126
  entityIds: string[];
118
127
  }
119
- class PlacementMemory {
128
+ export class PlacementMemory {
120
129
  private previous;
121
130
  private nextOrder;
122
131
  Resolve(frames: IFrame[]): Map<string, {
@@ -124,11 +133,111 @@ export declare namespace EntityLabel {
124
133
  side: "left" | "right";
125
134
  }>;
126
135
  }
127
- const IconPriority: typeof GetClusterIconPriority;
128
- function Layout(input: IFrame[], memory?: PlacementMemory): IPlacement[];
129
- function compatibleMembers<T>(seed: T, nearby: T[], group: (item: T) => string, look: (item: T) => string): T[];
130
- function SetContainer(viewer: Cesium.Viewer, container?: HTMLElement | null): void;
131
- class Label {
136
+ export const IconPriority: typeof GetClusterIconPriority;
137
+ export function Layout(input: IFrame[], memory?: PlacementMemory): IPlacement[];
138
+ export function compatibleMembers<T>(seed: T, nearby: T[], group: (item: T) => string, look: (item: T) => string): T[];
139
+ interface IParticipant {
140
+ project: () => IFrame;
141
+ apply: (placement?: IPlacement) => void;
142
+ }
143
+ export function SetContainer(viewer: Cesium.Viewer, container?: HTMLElement | null): void;
144
+ class Layer {
145
+ private viewer;
146
+ readonly element: HTMLDivElement;
147
+ coordinates: {
148
+ x: number;
149
+ y: number;
150
+ scaleX: number;
151
+ scaleY: number;
152
+ };
153
+ private participants;
154
+ private failed;
155
+ private placementMemory;
156
+ readonly modelBoxes: ModelBoxes;
157
+ private remove;
158
+ private forwardingWheel;
159
+ private pendingDrag;
160
+ private horizon;
161
+ private horizonScratch;
162
+ pointer: {
163
+ x: number;
164
+ y: number;
165
+ };
166
+ private pointerClient;
167
+ constructor(viewer: Cesium.Viewer);
168
+ private TrackPointer;
169
+ private PointerOut;
170
+ private ClearPointer;
171
+ private PreventNativeDrag;
172
+ private BeginDrag;
173
+ private FinishPendingDrag;
174
+ private EndPendingDrag;
175
+ private ContinueDrag;
176
+ private ForwardWheel;
177
+ Move(): void;
178
+ private MeasureCoordinates;
179
+ Add(participant: IParticipant): () => void;
180
+ IsBeyondHorizon(position: Cesium.Cartesian3): boolean;
181
+ private UpdateHorizon;
182
+ private Update;
183
+ private logFailure;
184
+ }
185
+ type TVec3 = [number, number, number];
186
+ export interface IModelShape {
187
+ centre: TVec3;
188
+ axes: [TVec3, TVec3, TVec3];
189
+ half: TVec3;
190
+ }
191
+ export function ReadOrientedBox(entity: Entity.IEntity): IModelShape;
192
+ export function GetModelBox(entity: Entity.IEntity, shape?: IModelShape): Cesium.Cartesian3[];
193
+ type TPoint = {
194
+ x: number;
195
+ y: number;
196
+ };
197
+ export interface IModelSolid {
198
+ centre: TVec3;
199
+ axes: [TVec3, TVec3, TVec3];
200
+ half: TVec3;
201
+ }
202
+ export function ModelSolid(corners: Cesium.Cartesian3[], origin: Cesium.Cartesian3): IModelSolid;
203
+ export function ModelSolidsTouch(a: IModelSolid, b: IModelSolid): boolean;
204
+ export function ModelBoxOutline(solids: IModelSolid[]): [TVec3, TVec3][];
205
+ export function HullsNear(a: TPoint[], b: TPoint[], margin: number): boolean;
206
+ interface IModelBoxRequest {
207
+ whole: boolean;
208
+ from: TPoint;
209
+ opacity: number;
210
+ zIndex: number;
211
+ color: string;
212
+ duration: number;
213
+ }
214
+ interface IModelBoxEntry {
215
+ selected: () => boolean;
216
+ hovered: () => boolean;
217
+ near: () => boolean;
218
+ }
219
+ export class ModelBoxes {
220
+ private entries;
221
+ private groups;
222
+ private hovered;
223
+ private outlines;
224
+ private hulls;
225
+ private frames;
226
+ private drawn;
227
+ private since;
228
+ private requests;
229
+ private looks;
230
+ private memberLooks;
231
+ Set(id: string, corners: Cesium.Cartesian3[], entityId: string, inputs: IModelBoxEntry): void;
232
+ Frame(id: string): IModelBoxFrame;
233
+ Hull(id: string): TPoint[];
234
+ Request(id: string, request: IModelBoxRequest): void;
235
+ private group;
236
+ Resolve(viewer: Cesium.Viewer, pointer?: TPoint): void;
237
+ Draw(viewer: Cesium.Viewer, element: HTMLElement, coordinates: Layer["coordinates"]): void;
238
+ private drawGroup;
239
+ }
240
+ export class Label {
132
241
  private id;
133
242
  private options;
134
243
  private groupId;
@@ -139,6 +248,8 @@ export declare namespace EntityLabel {
139
248
  private retainedHoverPosition;
140
249
  private ringAnimation;
141
250
  private cursorMotion;
251
+ private modelBox;
252
+ private boxMorph;
142
253
  private hoverRingState;
143
254
  SetHoverVisible(visible: boolean): void;
144
255
  private HoverOpacity;
@@ -197,6 +308,8 @@ export declare namespace EntityLabel {
197
308
  private buildIcon;
198
309
  private buildPhoto;
199
310
  private renderFor;
311
+ private loadModelBox;
312
+ private morphToBox;
200
313
  /**
201
314
  * Removes label from the viewer and unsubscribes from events.
202
315
  */
@@ -206,7 +319,7 @@ export declare namespace EntityLabel {
206
319
  * Creates an entity label for a given rego.
207
320
  * If one exists then the action is ignored.
208
321
  */
209
- function Attach(params: {
322
+ export function Attach(params: {
210
323
  rego: VisualsRegister.IVisualRego;
211
324
  viewer: Cesium.Viewer;
212
325
  pos3d?: Cesium.Cartesian3;
@@ -223,7 +336,7 @@ export declare namespace EntityLabel {
223
336
  * Removes an entity label from a given rego.
224
337
  * If one doesn't exist then the action is ignored.
225
338
  */
226
- function Detatch(params: {
339
+ export function Detatch(params: {
227
340
  rego?: VisualsRegister.IVisualRego;
228
341
  label?: Label;
229
342
  force?: boolean;
@@ -233,7 +346,8 @@ export declare namespace EntityLabel {
233
346
  * @param params
234
347
  * @returns
235
348
  */
236
- function GetLabel(params: {
349
+ export function GetLabel(params: {
237
350
  rego: VisualsRegister.IVisualRego;
238
351
  }): Label;
352
+ export {};
239
353
  }
@@ -179,6 +179,26 @@ export declare namespace TextureFrameSeriesAnimator {
179
179
  produceValueCanvas?: boolean;
180
180
  drapeExtent?: IExtent;
181
181
  maskBaseline?: boolean;
182
+ cacheBytes?: number;
183
+ }
184
+ function DilateValues(value: Uint8ClampedArray, width: number, height: number, passes: number, packed: boolean): void;
185
+ /**
186
+ * One frame's value pixels, the shape a label reads cells out of.
187
+ */
188
+ interface IValueRaster {
189
+ data: Uint8ClampedArray;
190
+ width: number;
191
+ height: number;
192
+ }
193
+ /**
194
+ * Two value frames and how far a fade between them has got, from 0 at the first to 1 at the second.
195
+ */
196
+ interface IValueFade {
197
+ from: Uint8ClampedArray | null;
198
+ to: Uint8ClampedArray;
199
+ width: number;
200
+ height: number;
201
+ mix: number;
182
202
  }
183
203
  class Animator {
184
204
  private readonly viewer;
@@ -228,6 +248,15 @@ export declare namespace TextureFrameSeriesAnimator {
228
248
  private extremesLoad;
229
249
  private floorPixels;
230
250
  private ceilingPixels;
251
+ private readonly valueOnly;
252
+ private fadeMix;
253
+ private fadeMixStart;
254
+ private valueCanvasVersion;
255
+ private rawCache;
256
+ private rawBytes;
257
+ private cachedBytes;
258
+ private lastFrameBytes;
259
+ private readonly cacheBudget;
231
260
  constructor(options: IOptions);
232
261
  /**
233
262
  * Explicit teardown: stops driving the entity's material, abandons any in-flight/pending fetch (results are simply ignored when they land),
@@ -258,6 +287,14 @@ export declare namespace TextureFrameSeriesAnimator {
258
287
  * or null unless the instance was constructed with produceValueCanvas.
259
288
  */
260
289
  GetValueCanvas(): HTMLCanvasElement | null;
290
+ /**
291
+ * The presented frame's value pixels, or null before one. Shares the cached array, so never write to it.
292
+ */
293
+ GetValueRaster(): IValueRaster | null;
294
+ /**
295
+ * The two value frames being faded between and the mix, or null unless the material is not driven.
296
+ */
297
+ GetValueFade(): IValueFade | null;
261
298
  /**
262
299
  * Increments every time a frame is presented, so a consumer holding the value canvas can tell
263
300
  * whether it needs re-uploading without diffing pixels or subscribing to anything.
@@ -268,6 +305,9 @@ export declare namespace TextureFrameSeriesAnimator {
268
305
  private swapToFrame;
269
306
  private ensureFrame;
270
307
  private nearestUncachedFrame;
308
+ private farthestCachedDistance;
309
+ private evictDecoded;
310
+ private keepRaw;
271
311
  private pumpFetchQueue;
272
312
  private fetchAndTint;
273
313
  private shouldPresent;
@@ -310,6 +350,8 @@ export declare namespace TextureFrameSeriesAnimator {
310
350
  */
311
351
  private applyBaselineMask;
312
352
  private beginCrossfadeTo;
353
+ private beginValueFadeTo;
354
+ private requestRender;
313
355
  private tickCrossfade;
314
356
  private presentPixels;
315
357
  }
@@ -1,5 +1,6 @@
1
1
  import * as Cesium from "cesium";
2
2
  import { TextureFrameSeriesAnimator } from "./texture-frame-series-animator";
3
+ import { VisualsRegister } from "./visuals-register";
3
4
  /**
4
5
  * Prints a value texture's own numbers over the cells they belong to.
5
6
  */
@@ -35,6 +36,22 @@ export declare namespace TextureValueLabels {
35
36
  South: number;
36
37
  North: number;
37
38
  }
39
+ /**
40
+ * Value pixels, one texel per cell, value in R (and G when packed) and coverage in A.
41
+ */
42
+ interface IRaster {
43
+ data: Uint8ClampedArray;
44
+ width: number;
45
+ height: number;
46
+ }
47
+ /**
48
+ * Who the hover label is shown for, and the register that owns hover labels.
49
+ */
50
+ interface IHoverTarget {
51
+ register: VisualsRegister.Register;
52
+ entityId: string;
53
+ menuItemId?: string;
54
+ }
38
55
  interface IOptions {
39
56
  viewer: Cesium.Viewer;
40
57
  extent: IExtent;
@@ -45,6 +62,9 @@ export declare namespace TextureValueLabels {
45
62
  lon: number;
46
63
  lat: number;
47
64
  }[];
65
+ heightAt?: (lon: number, lat: number) => number | null;
66
+ heightKey?: () => unknown;
67
+ hover?: IHoverTarget;
48
68
  }
49
69
  /**
50
70
  * One cell's numbers, in the attribute's own units.
@@ -72,7 +92,7 @@ export declare namespace TextureValueLabels {
72
92
  */
73
93
  function ReadingAt(params: {
74
94
  metadata?: TextureFrameSeriesAnimator.IFrameArchiveMetadata;
75
- source: ImageData;
95
+ source: IRaster;
76
96
  floor?: ImageData | null;
77
97
  ceiling?: ImageData | null;
78
98
  at: number;
@@ -110,23 +130,44 @@ export declare namespace TextureValueLabels {
110
130
  private clipRing?;
111
131
  private source;
112
132
  private painted;
133
+ private paintedRamp;
113
134
  private floor;
114
135
  private ceiling;
136
+ private readonly heightAt?;
137
+ private readonly heightKey?;
138
+ private readonly hover?;
115
139
  private disposed;
116
- private drawn;
117
140
  private stride;
141
+ private readonly cellLabels;
142
+ private lingerTimer;
143
+ private drawnView;
144
+ private drawnInputs;
145
+ private readonly scratchWorld;
146
+ private readonly scratchWindow;
147
+ private readonly scratchClip;
148
+ private viewProjection;
149
+ private readonly viewProjectionScratch;
150
+ private hovering;
151
+ private hoverFrame;
152
+ private hoverAt;
153
+ private readonly onPointerMove;
154
+ private readonly onPointerLeave;
118
155
  constructor(options: IOptions);
119
156
  SetExtent(extent: IExtent): void;
120
157
  /**
121
- * The current frame's decoded values, as the animator's value canvas already provides them.
158
+ * The current frame's decoded values.
122
159
  * @param source value pixels, one texel per cell
123
160
  */
124
- SetSource(source: ImageData | null): void;
161
+ SetSource(source: IRaster | null): void;
125
162
  /**
126
163
  * The tinted pixels of the same frame, so the grid can skip cells the ramp painted nothing in.
127
- * @param painted RGBA of the presented frame, or null to fall back to coverage alone
164
+ * @param painted RGBA of the presented frame, or null to fall back to the ramp or coverage alone
128
165
  */
129
166
  SetPainted(painted: Uint8ClampedArray | null): void;
167
+ /**
168
+ * The surface's 256 step RGBA ramp, for telling whether a cell was painted without a tinted frame.
169
+ */
170
+ SetPaintedRamp(ramp: Uint8Array | null): void;
130
171
  /**
131
172
  * The archive's per-cell extremes, when it publishes them. Without these a label can still
132
173
  * print the current reading, just not the range behind it.
@@ -136,26 +177,33 @@ export declare namespace TextureValueLabels {
136
177
  Clear(): void;
137
178
  Dispose(): void;
138
179
  /**
139
- * Redraws every visible label. Cheap enough to call per rendered frame, because the cell
140
- * count it considers is bounded by the view rather than by the texture.
180
+ * Redraws the grid and syncs the value labels, when anything they are drawn from has changed.
141
181
  */
142
182
  Render(): void;
183
+ private labelCells;
184
+ private syncCellLabels;
185
+ private clearCellLabels;
186
+ private updateHover;
187
+ private releaseHover;
188
+ private readingUnder;
189
+ private cellUnder;
143
190
  private drawGrid;
144
191
  private applyRingClip;
145
- private tileCellOutline;
146
192
  private drawTileGrid;
147
193
  private groundAtScreenCentre;
148
194
  private coveredAt;
149
195
  private isCovered;
150
- private widestLabel;
151
- private cellOutline;
152
- private drawLabel;
196
+ private labelLines;
153
197
  private readNear;
154
198
  private paintedAt;
155
199
  private readAt;
200
+ private texelAt;
156
201
  private lonAt;
157
202
  private latAt;
158
203
  private visibleTexels;
204
+ private surfaceHeight;
205
+ private projectCell;
159
206
  private project;
207
+ private projectInto;
160
208
  }
161
209
  }
@@ -576,9 +576,16 @@ export declare namespace VisualsRegister {
576
576
  y: number;
577
577
  };
578
578
  createIfMissing?: boolean;
579
+ text?: string;
580
+ pos3d?: Cesium.Cartesian3;
579
581
  } | null): void;
580
582
  ClearLabelHover: () => void;
581
583
  private CheckLabelHoverBounds;
584
+ GetLabelHoverTarget(): Readonly<{
585
+ entityId: string;
586
+ menuItemId?: string;
587
+ }> | undefined;
588
+ IsLabelHovered(entityId: string, menuItemId?: string): boolean;
582
589
  GetLabelHoverPosition(entityId: string, menuItemId?: string): Readonly<{
583
590
  x: number;
584
591
  y: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bruce-cesium",
3
- "version": "7.5.7",
3
+ "version": "7.5.9",
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.118",
86
+ "bruce-models": "^7.1.120",
87
87
  "tslib": "^2.4.1"
88
88
  }
89
89
  }