bruce-cesium 7.7.7 → 7.7.8

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 (49) hide show
  1. package/dist/bruce-cesium.es5.js +2292 -69
  2. package/dist/bruce-cesium.es5.js.map +1 -1
  3. package/dist/bruce-cesium.umd.js +2271 -66
  4. package/dist/bruce-cesium.umd.js.map +1 -1
  5. package/dist/lib/bruce-cesium.js +6 -1
  6. package/dist/lib/bruce-cesium.js.map +1 -1
  7. package/dist/lib/rendering/entity-render-engine-model3d.js +2 -2
  8. package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -1
  9. package/dist/lib/rendering/entity-render-engine-polygon.js +5 -4
  10. package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -1
  11. package/dist/lib/rendering/entity-render-engine-polyline.js +2 -1
  12. package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -1
  13. package/dist/lib/rendering/render-managers/common/entity-simulation.js +1 -1
  14. package/dist/lib/rendering/render-managers/common/entity-simulation.js.map +1 -1
  15. package/dist/lib/rendering/tileset-render-engine.js +47 -14
  16. package/dist/lib/rendering/tileset-render-engine.js.map +1 -1
  17. package/dist/lib/rendering/view-render-engine.js +30 -24
  18. package/dist/lib/rendering/view-render-engine.js.map +1 -1
  19. package/dist/lib/rendering/visuals-register.js +93 -8
  20. package/dist/lib/rendering/visuals-register.js.map +1 -1
  21. package/dist/lib/rendering/xgrids-render-engine.js +20 -3
  22. package/dist/lib/rendering/xgrids-render-engine.js.map +1 -1
  23. package/dist/lib/utils/cesium-map-grid.js +807 -0
  24. package/dist/lib/utils/cesium-map-grid.js.map +1 -0
  25. package/dist/lib/utils/device-profile.js +302 -0
  26. package/dist/lib/utils/device-profile.js.map +1 -0
  27. package/dist/lib/utils/gltf-generator.js +307 -0
  28. package/dist/lib/utils/gltf-generator.js.map +1 -0
  29. package/dist/lib/utils/gltf-gizmo.js +136 -0
  30. package/dist/lib/utils/gltf-gizmo.js.map +1 -0
  31. package/dist/lib/utils/view-utils.js +9 -0
  32. package/dist/lib/utils/view-utils.js.map +1 -1
  33. package/dist/lib/viewer/camera-controls.js +544 -0
  34. package/dist/lib/viewer/camera-controls.js.map +1 -0
  35. package/dist/lib/viewer/viewer-utils.js +9 -1
  36. package/dist/lib/viewer/viewer-utils.js.map +1 -1
  37. package/dist/types/bruce-cesium.d.ts +6 -1
  38. package/dist/types/rendering/tileset-render-engine.d.ts +10 -2
  39. package/dist/types/rendering/view-render-engine.d.ts +4 -0
  40. package/dist/types/rendering/visuals-register.d.ts +4 -0
  41. package/dist/types/rendering/xgrids-render-engine.d.ts +2 -0
  42. package/dist/types/utils/cesium-map-grid.d.ts +23 -0
  43. package/dist/types/utils/device-profile.d.ts +84 -0
  44. package/dist/types/utils/gltf-generator.d.ts +104 -0
  45. package/dist/types/utils/gltf-gizmo.d.ts +18 -0
  46. package/dist/types/utils/view-utils.d.ts +4 -0
  47. package/dist/types/viewer/camera-controls.d.ts +19 -0
  48. package/dist/types/viewer/viewer-utils.d.ts +1 -0
  49. package/package.json +3 -2
@@ -49,7 +49,12 @@ export * from "./utils/entity-utils";
49
49
  export * from "./utils/measure-utils";
50
50
  export * from "./utils/style-utils";
51
51
  export * from "./utils/view-utils";
52
+ export * from "./utils/cesium-map-grid";
53
+ export * from "./utils/gltf-generator";
54
+ export * from "./utils/gltf-gizmo";
55
+ export * from "./utils/device-profile";
52
56
  export * from "./viewer/cesium-view-monitor";
57
+ export * from "./viewer/camera-controls";
53
58
  export * from "./viewer/view-ground-area";
54
59
  export * from "./viewer/viewer-event-tracker";
55
60
  export * from "./viewer/viewer-utils";
@@ -72,7 +77,7 @@ export * from "./widgets/widget-info-view";
72
77
  export * from "./widgets/widget-left-panel";
73
78
  export * from "./widgets/widget-nav-compass";
74
79
  export * from "./widgets/widget-view-bar";
75
- export declare const VERSION = "7.7.7";
80
+ export declare const VERSION = "7.7.8";
76
81
  /**
77
82
  * Updates the environment instance used by bruce-cesium to one specified.
78
83
  * This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
@@ -122,10 +122,17 @@ export declare namespace TilesetRenderEngine {
122
122
  function WatchDateRange(viewer: Cesium.Viewer, renderObject: IDateRangeWatchedObject, tileset: any): void;
123
123
  function UnwatchDateRange(viewer: Cesium.Viewer, renderObject: IDateRangeWatchedObject): void;
124
124
  /**
125
- * The maximum memory in MB that can be used by all tilesets.
126
- * This is distributed evenly between all loaded tilesets.
125
+ * Total MB all tilesets may use, split evenly; null leaves it to the DeviceProfile tier.
127
126
  */
128
127
  let MAX_TILESET_MEMORY: number;
128
+ /**
129
+ * Smallest MB share a tileset gets; small, since Cesium coarsens one that needs more.
130
+ */
131
+ const MIN_TILESET_MEMORY = 32;
132
+ /**
133
+ * Returns the total MB all tilesets may use, from MAX_TILESET_MEMORY or else the device tier.
134
+ */
135
+ function GetTilesetMemoryBudget(): number;
129
136
  /**
130
137
  * Watches tileset date cutoffs and toggles their primitive visibility based on the viewer clock.
131
138
  */
@@ -149,6 +156,7 @@ export declare namespace TilesetRenderEngine {
149
156
  class MemoryWatcher {
150
157
  private viewer;
151
158
  private watched;
159
+ private removeChanged;
152
160
  constructor(viewer: Cesium.Viewer);
153
161
  private distributeMemory;
154
162
  destroy(): void;
@@ -2,6 +2,10 @@ import { ApiGetters, BruceApi, ProjectView, ProjectViewBookmark } from "bruce-mo
2
2
  import * as Cesium from "cesium";
3
3
  import { MenuItemManager } from "./menu-item-manager";
4
4
  export declare namespace ViewRenderEngine {
5
+ /**
6
+ * A bookmark's own shadows, else the view's defaults unless it is model-space, which reads brighter without.
7
+ */
8
+ function ResolveShadows(bSettings: ProjectViewBookmark.IWeb3dSettings, defaults: ProjectViewBookmark.IWeb3dSettings, contentType: ProjectViewBookmark.EContentType): ProjectViewBookmark.Web3d.IShadows;
5
9
  /**
6
10
  * Returns where a model-space bookmark's camera goes, measured from the origin in effect.
7
11
  * @param viewer
@@ -127,6 +127,8 @@ export declare namespace VisualsRegister {
127
127
  private sourceOrderDirty;
128
128
  private labelGroups;
129
129
  private simulationRemoval;
130
+ private shadowsRemoval;
131
+ private entityShadows;
130
132
  private labelGroupsChanged;
131
133
  get OnLabelGroupsChanged(): BruceEvent<void>;
132
134
  private labelHover;
@@ -138,6 +140,7 @@ export declare namespace VisualsRegister {
138
140
  viewer: Cesium.Viewer;
139
141
  apiGetters?: ApiGetters;
140
142
  });
143
+ private syncEntityShadows;
141
144
  private reloadLabels;
142
145
  /**
143
146
  * Returns the collection a menu item's visuals belong in, creating its data source on first use.
@@ -480,6 +483,7 @@ export declare namespace VisualsRegister {
480
483
  keepVisual?: Visual;
481
484
  onComplete?: () => void;
482
485
  }): void;
486
+ private promoteTileSibling;
483
487
  /**
484
488
  * Removes regos matching given visuals.
485
489
  * This is used when we cannot unpack properties from the visual any longer to determine its ID.
@@ -1,5 +1,6 @@
1
1
  import { BruceApi, Cartes, Tileset } from "bruce-models";
2
2
  import * as Cesium from "cesium";
3
+ import { DeviceProfile } from "../utils/device-profile";
3
4
  /**
4
5
  * Render engine to handle LCC / XGrids data through the XGrids library.
5
6
  */
@@ -11,6 +12,7 @@ export declare namespace XGridsRenderEngine {
11
12
  tileset: Tileset.ITileset;
12
13
  flyTo?: boolean;
13
14
  }): TRenderObject | null;
15
+ function GetSplatBudget(sdkBudget: number | undefined, profile: DeviceProfile.IProfile): number;
14
16
  function Remove(viewer: Cesium.Viewer, renderObject: TRenderObject): void;
15
17
  class AdaptiveLod {
16
18
  private viewer;
@@ -0,0 +1,23 @@
1
+ import * as Cesium from "cesium";
2
+ export declare namespace CesiumMapGrid {
3
+ interface ISettings {
4
+ enabled: boolean;
5
+ spacing: number;
6
+ modelSpace?: boolean;
7
+ }
8
+ function GetCurrentSpacing(viewer: Cesium.Viewer): number;
9
+ function Remove(viewer: Cesium.Viewer): void;
10
+ function Draw(viewer: Cesium.Viewer, spacingInMeters: number, modelSpace?: boolean): void;
11
+ /**
12
+ * Draws a bookmark's grid, or removes the grid when it has none; only model-space draws one.
13
+ */
14
+ function Apply(viewer: Cesium.Viewer, grid: {
15
+ enabled?: boolean;
16
+ spacing?: number;
17
+ } | null | undefined, modelSpace: boolean): void;
18
+ function GetIsEnabled(viewer: Cesium.Viewer): boolean;
19
+ /**
20
+ * Returns the last applied grid settings.
21
+ */
22
+ function GetSettings(viewer: Cesium.Viewer): ISettings;
23
+ }
@@ -0,0 +1,84 @@
1
+ import * as Cesium from "cesium";
2
+ /**
3
+ * Picks how much the scene may hold in memory on this device, from a hardware guess and past sessions.
4
+ */
5
+ export declare namespace DeviceProfile {
6
+ enum ETier {
7
+ Low = "LOW",
8
+ Mid = "MID",
9
+ High = "HIGH"
10
+ }
11
+ type TGpuClass = "software" | "mobile" | "integrated" | "discrete" | "unknown";
12
+ interface IEnvironment {
13
+ userAgent?: string;
14
+ maxTouchPoints?: number;
15
+ deviceMemory?: number;
16
+ hardwareConcurrency?: number;
17
+ gpuRenderer?: string;
18
+ maxTextureSize?: number;
19
+ }
20
+ interface IClassification {
21
+ tier: ETier;
22
+ gpuClass: TGpuClass;
23
+ mobile: boolean;
24
+ reasons: string[];
25
+ }
26
+ interface IProfile {
27
+ tier: ETier;
28
+ detectedTier: ETier;
29
+ gpuClass: TGpuClass;
30
+ mobile: boolean;
31
+ demoted: number;
32
+ overridden: boolean;
33
+ reasons: string[];
34
+ environment: IEnvironment;
35
+ }
36
+ interface IBudget {
37
+ tilesetMb: number;
38
+ splats: number;
39
+ }
40
+ const BUDGETS: {
41
+ [key in ETier]: IBudget;
42
+ };
43
+ /**
44
+ * Raised after the override or a demotion changes the tier, so live budgets can be redistributed.
45
+ */
46
+ const Changed: Cesium.Event<(...args: any[]) => void>;
47
+ function ClassifyGpu(renderer: string | undefined): TGpuClass;
48
+ /**
49
+ * Guesses a tier from the hardware alone. Unknown hardware stays mid; only clear evidence moves it.
50
+ */
51
+ function Classify(env: IEnvironment): IClassification;
52
+ /**
53
+ * Returns this device's profile, detecting it once per page. Pass the viewer to read its GL context.
54
+ */
55
+ function Get(viewer?: Cesium.Viewer): IProfile;
56
+ /**
57
+ * Returns the memory budgets for this device's tier, or for a given tier.
58
+ */
59
+ function GetBudget(tier?: ETier): IBudget;
60
+ /**
61
+ * Forces a tier, for a user who knows better than the guess. Null returns to detection.
62
+ */
63
+ function SetOverride(tier: ETier | null): void;
64
+ /**
65
+ * Returns the forced tier, or null while detection decides.
66
+ */
67
+ function GetOverride(): ETier | null;
68
+ /**
69
+ * Records that a WebGL context was lost, so this and later sessions start a tier lower.
70
+ */
71
+ function RecordContextLost(): void;
72
+ /**
73
+ * Forgets earlier context losses, for a host that offers a reset.
74
+ */
75
+ function ClearDemotion(): void;
76
+ /**
77
+ * Reports the viewer's context losses. Safe to call repeatedly.
78
+ */
79
+ function WatchViewer(viewer: Cesium.Viewer): void;
80
+ /**
81
+ * Forgets the detected hardware and override, for tests.
82
+ */
83
+ function Reset(): void;
84
+ }
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Writes meshes as binary glTF (GLB), for models simple enough to describe in code rather than ship as files.
3
+ */
4
+ export declare namespace GltfGenerator {
5
+ type TVec3 = [number, number, number];
6
+ type TMatrix = number[];
7
+ /**
8
+ * Vertices and triangles collected by the shape functions, one material's worth.
9
+ */
10
+ class Mesh {
11
+ positions: number[];
12
+ normals: number[];
13
+ indices: number[];
14
+ AddVertex(position: TVec3, normal: TVec3): number;
15
+ /**
16
+ * Adds a triangle wound so its front faces along normal, whichever order the corners come in.
17
+ * Per corner normals smooth it; without them every corner takes the face normal.
18
+ */
19
+ AddTriangle(a: TVec3, b: TVec3, c: TVec3, normal: TVec3, corners?: [TVec3, TVec3, TVec3]): void;
20
+ /**
21
+ * Joins three added vertices into a triangle facing along normal, so shapes can share corners.
22
+ */
23
+ AddIndexedTriangle(ia: number, ib: number, ic: number, normal: TVec3): void;
24
+ get VertexCount(): number;
25
+ }
26
+ interface IMaterial {
27
+ color: [number, number, number, number];
28
+ metallic?: number;
29
+ roughness?: number;
30
+ doubleSided?: boolean;
31
+ }
32
+ function Add(a: TVec3, b: TVec3): TVec3;
33
+ function Sub(a: TVec3, b: TVec3): TVec3;
34
+ function Scale(a: TVec3, s: number): TVec3;
35
+ function Dot(a: TVec3, b: TVec3): number;
36
+ function Cross(a: TVec3, b: TVec3): TVec3;
37
+ function Normalize(a: TVec3): TVec3;
38
+ /**
39
+ * Adds a flat disc facing along normal.
40
+ */
41
+ function AddDisc(mesh: Mesh, params: {
42
+ centre: TVec3;
43
+ normal: TVec3;
44
+ radius: number;
45
+ sides: number;
46
+ start?: TVec3;
47
+ }): void;
48
+ /**
49
+ * Adds a smooth sided cylinder between two points, closed at the start by default.
50
+ */
51
+ function AddCylinder(mesh: Mesh, params: {
52
+ start: TVec3;
53
+ end: TVec3;
54
+ radius: number;
55
+ sides: number;
56
+ capStart?: boolean;
57
+ capEnd?: boolean;
58
+ }): void;
59
+ /**
60
+ * Adds a cone from a base circle to a tip, closed at the base by default.
61
+ */
62
+ function AddCone(mesh: Mesh, params: {
63
+ base: TVec3;
64
+ tip: TVec3;
65
+ radius: number;
66
+ sides: number;
67
+ faceted?: boolean;
68
+ start?: TVec3;
69
+ cap?: boolean;
70
+ }): void;
71
+ /**
72
+ * Adds a smooth ring of tube around an axis through centre.
73
+ */
74
+ function AddTorus(mesh: Mesh, params: {
75
+ centre: TVec3;
76
+ axis: TVec3;
77
+ radius: number;
78
+ tube: number;
79
+ segments: number;
80
+ sides: number;
81
+ }): void;
82
+ /**
83
+ * Adds a flat convex outline, given in a plane's own across and up coordinates, facing along normal.
84
+ */
85
+ function AddConvexOutline(mesh: Mesh, params: {
86
+ points: [number, number][];
87
+ origin: TVec3;
88
+ across: TVec3;
89
+ up: TVec3;
90
+ normal: TVec3;
91
+ }): void;
92
+ /**
93
+ * Packs a mesh into GLB bytes, under a chain of node matrices (outermost first) when given.
94
+ */
95
+ function ToGlb(params: {
96
+ mesh: Mesh;
97
+ material: IMaterial;
98
+ matrices?: TMatrix[];
99
+ }): Uint8Array;
100
+ /**
101
+ * Packs a mesh into a GLB data URI, which loads as a model url with nothing to fetch.
102
+ */
103
+ function ToDataUri(params: Parameters<typeof ToGlb>[0]): string;
104
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The transform gizmo's pieces as GLB data URIs, built on first use so there are no model files to host.
3
+ * Sizes, colours and frames match the models they replaced (Navigator's public/res/gizmo), scales included.
4
+ */
5
+ export declare namespace GltfGizmo {
6
+ enum EPiece {
7
+ X = "x",
8
+ Y = "y",
9
+ Z = "z",
10
+ XRotation = "x-rot",
11
+ YRotation = "y-rot",
12
+ ZRotation = "z-rot"
13
+ }
14
+ /**
15
+ * Returns a piece's model as a data URI, to pass wherever a model url is taken.
16
+ */
17
+ function GetUri(piece: EPiece): string;
18
+ }
@@ -135,6 +135,10 @@ export declare namespace ViewUtils {
135
135
  */
136
136
  function SetDefaultImageBasedLighting(imageBasedLighting: any): void;
137
137
  function GetDefaultImageBasedLighting(): any;
138
+ /**
139
+ * Shadow mode for the Entity graphics this library draws, following the scene's shadow switch.
140
+ */
141
+ function GetEntityShadowMode(viewer: Cesium.Viewer): Cesium.ShadowMode;
138
142
  function EngineShadesModelsDarker(): boolean;
139
143
  /**
140
144
  * Resolves the sun colour and intensity to apply for a bookmark's lighting settings.
@@ -0,0 +1,19 @@
1
+ import * as Cesium from "cesium";
2
+ /**
3
+ * Mouse navigation that keeps moving near, through and below the ground, where CesiumJS's own controller stalls.
4
+ */
5
+ export declare namespace CameraControls {
6
+ /**
7
+ * Takes over mouse drag and wheel navigation close to the ground; CesiumJS keeps planet scale, pinch and look.
8
+ */
9
+ function Attach(viewer: Cesium.Viewer): void;
10
+ /**
11
+ * Hands navigation back to CesiumJS's own camera controller, as it was before Attach.
12
+ */
13
+ function Detach(viewer: Cesium.Viewer): void;
14
+ function IsAttached(viewer: Cesium.Viewer): boolean;
15
+ /**
16
+ * Switches to navigating model-space measured from the frame getFrame returns, or back to geospatial with null.
17
+ */
18
+ function SetModelSpace(viewer: Cesium.Viewer, getFrame: (() => Cesium.Matrix4) | null): void;
19
+ }
@@ -19,6 +19,7 @@ export declare namespace ViewerUtils {
19
19
  styleContainer?: boolean;
20
20
  nextspaceWidgets?: boolean;
21
21
  widgetParams?: any;
22
+ cameraControls?: boolean;
22
23
  }): {
23
24
  widgets: IDictionary<Widget.AWidget>;
24
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bruce-cesium",
3
- "version": "7.7.7",
3
+ "version": "7.7.8",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "main": "dist/bruce-cesium.umd.js",
@@ -66,6 +66,7 @@
66
66
  "jest": "^29.7.0",
67
67
  "jest-config": "^29.7.0",
68
68
  "jest-environment-jsdom": "^29.7.0",
69
+ "jest-junit": "^16.0.0",
69
70
  "lodash.camelcase": "^4.3.0",
70
71
  "prompt": "^1.0.0",
71
72
  "replace-in-file": "^3.4.2",
@@ -84,7 +85,7 @@
84
85
  "typescript": "^5.0.4"
85
86
  },
86
87
  "dependencies": {
87
- "bruce-models": "^7.1.135",
88
+ "bruce-models": "^7.1.138",
88
89
  "tslib": "^2.4.1"
89
90
  }
90
91
  }