bruce-cesium 7.6.4 → 7.6.6
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.
- package/README.md +2 -27
- package/dist/bruce-cesium.es5.js +670 -30
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +668 -28
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +1 -1
- package/dist/lib/rendering/entity-render-engine-point-orientation.js +422 -0
- package/dist/lib/rendering/entity-render-engine-point-orientation.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-point.js +43 -3
- package/dist/lib/rendering/entity-render-engine-point.js.map +1 -1
- package/dist/lib/rendering/getters/entity-filter-getter.js +9 -1
- package/dist/lib/rendering/getters/entity-filter-getter.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/entity-label-group.js +53 -17
- package/dist/lib/rendering/render-managers/common/entity-label-group.js.map +1 -1
- package/dist/lib/rendering/render-managers/common/entity-label.js +51 -3
- package/dist/lib/rendering/render-managers/common/entity-label.js.map +1 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js +3 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js.map +1 -1
- package/dist/lib/rendering/view-render-engine.js +2 -2
- package/dist/lib/rendering/view-render-engine.js.map +1 -1
- package/dist/lib/utils/entity-utils.js +96 -0
- package/dist/lib/utils/entity-utils.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +1 -1
- package/dist/types/rendering/entity-render-engine-point-orientation.d.ts +59 -0
- package/dist/types/rendering/getters/entity-filter-getter.d.ts +1 -0
- package/dist/types/rendering/render-managers/common/entity-label-group.d.ts +2 -0
- package/dist/types/rendering/render-managers/common/entity-label.d.ts +3 -0
- package/dist/types/utils/entity-utils.d.ts +29 -0
- package/package.json +2 -2
package/dist/bruce-cesium.es5.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Cesium from 'cesium';
|
|
2
|
-
import { Cartographic, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass,
|
|
3
|
-
import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, UrlUtils,
|
|
2
|
+
import { Cartographic, ColorMaterialProperty, Entity, Color, ConstantProperty, CallbackProperty, Primitive, Cesium3DTileFeature, ShaderSource, Cartesian3, Math as Math$1, Ellipsoid, Transforms, Matrix4, Geometry, GeometryAttribute, ComponentDatatype, PrimitiveType, BoundingSphere, GeometryPipeline, Cartesian2, Cartesian4, sampleTerrain, Texture, PixelFormat, Sampler, TextureWrap, TextureMinificationFilter, TextureMagnificationFilter, PixelDatatype, VertexArray, BufferUsage, ShaderProgram, RenderState, BlendingState, DrawCommand, Pass, JulianDate, Quaternion, HeadingPitchRoll, HeightReference, ConstantPositionProperty, DistanceDisplayCondition, ColorBlendMode, ShadowMode, ClassificationType, Model, HorizontalOrigin, VerticalOrigin, ImageMaterialProperty, PolygonHierarchy, PolylineGraphics, ArcType, CornerType, Rectangle, SceneMode, IntersectionTests, Ray, SceneTransforms, FeatureDetection, Matrix3, NearFarScalar, KmlDataSource, GeoJsonDataSource, Cesium3DTileStyle, HeadingPitchRange, Cesium3DTileColorBlendMode, Ion, IonResource, EllipsoidTerrainProvider, IonImageryProvider, createWorldImagery, createWorldImageryAsync, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, UrlTemplateImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, TileMapServiceImageryProvider, CesiumTerrainProvider, Cesium3DTileset, OrthographicFrustum, EasingFunction, Intersect, CustomDataSource, ModelGraphics, PolygonGraphics, CorridorGraphics, PointGraphics, BillboardGraphics, EllipseGraphics, PolylineDashMaterialProperty, EllipsoidGeodesic, sampleTerrainMostDetailed, defined, GeometryInstance, CesiumInspector, ClockRange, DynamicEnvironmentMapManager, PolygonPipeline, ScreenSpaceEventHandler, ScreenSpaceEventType, Fullscreen, CzmlDataSource } from 'cesium';
|
|
3
|
+
import { Cartes, LRUCache, ProjectViewTile, ENVIRONMENT, Calculator, ClientFile, Entity as Entity$1, EntityLod, EntityTag, EntityType, ObjectUtils, Style, UrlUtils, Api, Bounds, ClientFileValueMap, Color as Color$1, Geometry as Geometry$1, Carto, MenuItem, ProjectView, ProjectViewBookmark, Tileset, ZoomControl, BruceEvent, EntityCoords, DataLab, DelayQueue, AccountConcept, RecordChangeFeed, BruceApi, EntityRelation, EntitySource, ProgramKey, ProjectViewLegacyTile, Camera, Account, AccountLimits, Session, EntityAttachment, EntityAttachmentType, EntityAttribute, MathUtils, ProjectViewBookmarkGroup, EntityRelationType, EntityHistoricData } from 'bruce-models';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Ensures a number is returned from a given value.
|
|
@@ -7688,6 +7688,8 @@ var EntityLabel;
|
|
|
7688
7688
|
this.modelBox = null;
|
|
7689
7689
|
this.boxMorph = { value: 0, from: 0, target: 0, start: 0, anchor: undefined, group: undefined,
|
|
7690
7690
|
shift: { x: 0, y: 0, start: 0 } };
|
|
7691
|
+
// A CAD part's record and its tileset, so the label stays on the part wherever the tileset is drawn now.
|
|
7692
|
+
this.tilesetPart = null;
|
|
7691
7693
|
// Counter to help differentiate between createLabel calls.
|
|
7692
7694
|
this.counter = 0;
|
|
7693
7695
|
// Whether this label has asked its group for a default image, which it does once on screen.
|
|
@@ -7997,6 +7999,9 @@ var EntityLabel;
|
|
|
7997
7999
|
return;
|
|
7998
8000
|
}
|
|
7999
8001
|
this._pos3d = pos3d;
|
|
8002
|
+
if (!this.prePositioned && visual instanceof Cesium3DTileFeature) {
|
|
8003
|
+
this.followTilesetPart(visual, counter);
|
|
8004
|
+
}
|
|
8000
8005
|
let text = "Unknown Entity";
|
|
8001
8006
|
const additionalTexts = this.additionalTexts ? this.additionalTexts : [];
|
|
8002
8007
|
if (this.rego) {
|
|
@@ -8458,13 +8463,12 @@ var EntityLabel;
|
|
|
8458
8463
|
// Past the wait a slow record no longer holds the label back; a box that comes later eases in.
|
|
8459
8464
|
setTimeout(settle, MODEL_BOX_WAIT);
|
|
8460
8465
|
this.modelBox.load.then(corners => {
|
|
8461
|
-
var _a, _b;
|
|
8462
8466
|
if (!corners || this.disposed || this.counter !== counter) {
|
|
8463
8467
|
return;
|
|
8464
8468
|
}
|
|
8465
8469
|
// A record that disagrees with where the model was found describes another placement, such as a moved tileset.
|
|
8466
8470
|
// A part known to have moved from its record, eg. a joint turning, is judged where it has moved to.
|
|
8467
|
-
const motion =
|
|
8471
|
+
const motion = this.motionAt(this.viewer.clock.currentTime);
|
|
8468
8472
|
const centre = Cartesian3.midpoint(corners[0], corners[7], new Cartesian3());
|
|
8469
8473
|
if (motion) {
|
|
8470
8474
|
Matrix4.multiplyByPoint(motion, centre, centre);
|
|
@@ -8476,7 +8480,8 @@ var EntityLabel;
|
|
|
8476
8480
|
// Let go a little further out than it is taken, so a camera resting at the limit does not flip it.
|
|
8477
8481
|
let near = false;
|
|
8478
8482
|
layer.modelBoxes.Set(this.id, corners, rego.entityId, {
|
|
8479
|
-
|
|
8483
|
+
// Asked each frame, since a CAD part's tileset may only be known once its record is read.
|
|
8484
|
+
motion: () => this.motionAt(this.viewer.clock.currentTime),
|
|
8480
8485
|
selected: () => { var _a, _b; return Boolean((_b = (_a = this.visualRegister) === null || _a === void 0 ? void 0 : _a.GetState({ entityId: rego.entityId, menuItemId: rego.menuItemId })) === null || _b === void 0 ? void 0 : _b.selected); },
|
|
8481
8486
|
hovered: () => { var _a, _b; return Boolean((_b = (_a = this.visualRegister) === null || _a === void 0 ? void 0 : _a.IsLabelHovered) === null || _b === void 0 ? void 0 : _b.call(_a, rego.entityId, rego.menuItemId)); },
|
|
8482
8487
|
near: () => {
|
|
@@ -8510,6 +8515,12 @@ var EntityLabel;
|
|
|
8510
8515
|
desiredHeightRef: HeightReference.NONE, heightRef, pos3d: position, viewer: this.viewer
|
|
8511
8516
|
});
|
|
8512
8517
|
}
|
|
8518
|
+
// A CAD part sits where its tileset is drawn this frame.
|
|
8519
|
+
else if (!this.prePositioned && this.tilesetPart) {
|
|
8520
|
+
const { tileset, entity } = this.tilesetPart;
|
|
8521
|
+
const rootFrame = EntityUtils.GetTilesetRootFrame(tileset);
|
|
8522
|
+
this._pos3d = (rootFrame && EntityUtils.GetAssemblyPartPos3d({ viewer: this.viewer, entity, rootFrame })) || this._pos3d;
|
|
8523
|
+
}
|
|
8513
8524
|
if (!Number.isFinite((_b = this._pos3d) === null || _b === void 0 ? void 0 : _b.x)) {
|
|
8514
8525
|
return null;
|
|
8515
8526
|
}
|
|
@@ -9243,6 +9254,43 @@ var EntityLabel;
|
|
|
9243
9254
|
};
|
|
9244
9255
|
step();
|
|
9245
9256
|
}
|
|
9257
|
+
/*
|
|
9258
|
+
* Keeps a label on a CAD Assembly part where its tileset is drawn, which a record cannot know as it moves.
|
|
9259
|
+
*/
|
|
9260
|
+
async followTilesetPart(feature, counter) {
|
|
9261
|
+
var _a, _b, _c;
|
|
9262
|
+
const known = (_c = (_b = (_a = this.visualRegister) === null || _a === void 0 ? void 0 : _a.GetLabelGroupFor(this.rego.entityId, this.rego.menuItemId)) === null || _b === void 0 ? void 0 : _b.item) === null || _c === void 0 ? void 0 : _c.entity;
|
|
9263
|
+
let entity = EntityUtils.IsAssemblyPart(known) ? known : null;
|
|
9264
|
+
if (!entity && this.api) {
|
|
9265
|
+
try {
|
|
9266
|
+
entity = (await Entity$1.Get({ api: this.api, entityId: this.rego.entityId, expandLocation: true, migrated: true })).entity;
|
|
9267
|
+
}
|
|
9268
|
+
// Expanding location fails for entities outside an assembly, which keep the position already found.
|
|
9269
|
+
catch {
|
|
9270
|
+
return;
|
|
9271
|
+
}
|
|
9272
|
+
}
|
|
9273
|
+
const record = EntityUtils.GetAssemblyRecordFrame(entity);
|
|
9274
|
+
if (!record || this.disposed || this.counter !== counter || !feature.tileset) {
|
|
9275
|
+
return;
|
|
9276
|
+
}
|
|
9277
|
+
this.tilesetPart = { tileset: feature.tileset, entity, record };
|
|
9278
|
+
this.viewer.scene.requestRender();
|
|
9279
|
+
}
|
|
9280
|
+
/*
|
|
9281
|
+
* Rigid motion from where the record places this Entity to where it is drawn, see IVisualRego.motion.
|
|
9282
|
+
* A CAD part has none of its own, so it moves with its tileset.
|
|
9283
|
+
*/
|
|
9284
|
+
motionAt(time) {
|
|
9285
|
+
var _a, _b;
|
|
9286
|
+
const own = (_b = (_a = this.rego) === null || _a === void 0 ? void 0 : _a.motion) === null || _b === void 0 ? void 0 : _b.call(_a, time);
|
|
9287
|
+
if (own || !this.tilesetPart) {
|
|
9288
|
+
return own !== null && own !== void 0 ? own : null;
|
|
9289
|
+
}
|
|
9290
|
+
const drawn = EntityUtils.GetTilesetRootFrame(this.tilesetPart.tileset);
|
|
9291
|
+
const inverse = Matrix4.inverseTransformation(this.tilesetPart.record, new Matrix4());
|
|
9292
|
+
return drawn ? Matrix4.multiply(drawn, inverse, inverse) : null;
|
|
9293
|
+
}
|
|
9246
9294
|
/*
|
|
9247
9295
|
* Reads the record's geometry box, preferring an entity a label group already hydrated.
|
|
9248
9296
|
*/
|
|
@@ -9416,21 +9464,17 @@ var EntityLabelGroup;
|
|
|
9416
9464
|
(function (EntityLabelGroup) {
|
|
9417
9465
|
/*
|
|
9418
9466
|
* Keeps the query response useful even when the Entity has no loaded visual yet.
|
|
9467
|
+
* An Assembly part is placed from its record when shown (Manager.RefreshEntity); Location is its fallback.
|
|
9419
9468
|
*/
|
|
9420
9469
|
function FromEntity(entity) {
|
|
9421
|
-
var _a, _b, _c
|
|
9470
|
+
var _a, _b, _c;
|
|
9422
9471
|
const location = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.Location;
|
|
9423
|
-
const pivot = (_b = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _b === void 0 ? void 0 : _b.GeometryWorldPivot;
|
|
9424
|
-
let cartographic;
|
|
9425
|
-
if ((pivot === null || pivot === void 0 ? void 0 : pivot.length) >= 3 && pivot.every(Number.isFinite)) {
|
|
9426
|
-
cartographic = Cartographic.fromCartesian(Cartesian3.fromArray(pivot));
|
|
9427
|
-
}
|
|
9428
9472
|
return {
|
|
9429
|
-
entityId: (
|
|
9430
|
-
text: (
|
|
9431
|
-
longitude:
|
|
9432
|
-
latitude:
|
|
9433
|
-
altitude:
|
|
9473
|
+
entityId: (_b = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _b === void 0 ? void 0 : _b.ID,
|
|
9474
|
+
text: (_c = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _c === void 0 ? void 0 : _c.Name,
|
|
9475
|
+
longitude: location === null || location === void 0 ? void 0 : location.longitude,
|
|
9476
|
+
latitude: location === null || location === void 0 ? void 0 : location.latitude,
|
|
9477
|
+
altitude: location === null || location === void 0 ? void 0 : location.altitude,
|
|
9434
9478
|
entity
|
|
9435
9479
|
};
|
|
9436
9480
|
}
|
|
@@ -9543,7 +9587,8 @@ var EntityLabelGroup;
|
|
|
9543
9587
|
const response = await DataLab.Run({ api, query, skip: offset, load: limit, migrated: true, req: { noCache: true, abortSignal: signal } });
|
|
9544
9588
|
const entities = response.entities || response.items || [];
|
|
9545
9589
|
return {
|
|
9546
|
-
|
|
9590
|
+
// A simulated stand-in or patch wins over what the query read, as it does for hand-picked groups.
|
|
9591
|
+
items: entities.map(entity => { var _a, _b; return FromEntity((_b = simulation === null || simulation === void 0 ? void 0 : simulation.Resolve((_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.ID, entity)) !== null && _b !== void 0 ? _b : entity); }),
|
|
9547
9592
|
hasMore: response.totalCount != null ? offset + entities.length < response.totalCount : entities.length === limit
|
|
9548
9593
|
};
|
|
9549
9594
|
};
|
|
@@ -9896,7 +9941,7 @@ var EntityLabelGroup;
|
|
|
9896
9941
|
}
|
|
9897
9942
|
}
|
|
9898
9943
|
RefreshEntity(entityId) {
|
|
9899
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
9944
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
9900
9945
|
const match = this.Resolve(entityId);
|
|
9901
9946
|
const registered = this.register.GetRego({ entityId });
|
|
9902
9947
|
if (!registered && match && this.standalone.has(entityId) && this.standaloneItems.get(entityId) === match.item) {
|
|
@@ -9913,19 +9958,22 @@ var EntityLabelGroup;
|
|
|
9913
9958
|
return;
|
|
9914
9959
|
}
|
|
9915
9960
|
const item = match.item;
|
|
9916
|
-
|
|
9961
|
+
const position = (_d = this.assemblyPosition(item.entity)) !== null && _d !== void 0 ? _d : ([item.longitude, item.latitude, (_e = item.altitude) !== null && _e !== void 0 ? _e : 0].every(Number.isFinite) && Math.abs(item.latitude) <= 90
|
|
9962
|
+
? Cartesian3.fromDegrees(item.longitude, item.latitude, item.altitude || 0)
|
|
9963
|
+
: null);
|
|
9964
|
+
if (!position) {
|
|
9917
9965
|
return;
|
|
9918
9966
|
}
|
|
9919
9967
|
const visual = new Entity({
|
|
9920
|
-
position:
|
|
9968
|
+
position: position,
|
|
9921
9969
|
point: { heightReference: HeightReference.NONE, pixelSize: 0 }
|
|
9922
9970
|
});
|
|
9923
9971
|
this.standalone.set(entityId, new EntityLabel.Label({
|
|
9924
9972
|
viewer: this.register.Viewer,
|
|
9925
9973
|
visualRegister: this.register,
|
|
9926
|
-
api: (
|
|
9974
|
+
api: (_f = this.register.ApiGetters) === null || _f === void 0 ? void 0 : _f.GetBruceApi(),
|
|
9927
9975
|
rego: { entityId, visual, name: item.text || entityId, priority: 0 },
|
|
9928
|
-
options: { ...match.options, text: (
|
|
9976
|
+
options: { ...match.options, text: (_h = (_g = match.options.text) !== null && _g !== void 0 ? _g : item.text) !== null && _h !== void 0 ? _h : entityId },
|
|
9929
9977
|
groupId: match.groupId,
|
|
9930
9978
|
visible: () => {
|
|
9931
9979
|
const state = this.register.GetState({ entityId });
|
|
@@ -9934,6 +9982,41 @@ var EntityLabelGroup;
|
|
|
9934
9982
|
}));
|
|
9935
9983
|
this.standaloneItems.set(entityId, item);
|
|
9936
9984
|
}
|
|
9985
|
+
/*
|
|
9986
|
+
* Places an undrawn Assembly part where its Assembly is now: model-space, history and simulation included.
|
|
9987
|
+
* Returns null for anything else, which keeps its record's Location.
|
|
9988
|
+
*/
|
|
9989
|
+
assemblyPosition(entity) {
|
|
9990
|
+
const viewer = this.register.Viewer;
|
|
9991
|
+
if (!EntityUtils.GetAssemblyPartPos3d({ viewer, entity })) {
|
|
9992
|
+
return null;
|
|
9993
|
+
}
|
|
9994
|
+
let last = null;
|
|
9995
|
+
return new CallbackProperty((time) => {
|
|
9996
|
+
var _a, _b, _c;
|
|
9997
|
+
const at = JulianDate.toDate(time !== null && time !== void 0 ? time : viewer.clock.currentTime).getTime();
|
|
9998
|
+
const simulated = (_b = (_a = EntitySimulation.Get(viewer)) === null || _a === void 0 ? void 0 : _a.ApplyAt(entity, at)) !== null && _b !== void 0 ? _b : entity;
|
|
9999
|
+
last = (_c = EntityUtils.GetAssemblyPartPos3d({ viewer, entity: simulated, rootFrame: this.drawnFrame(entity) })) !== null && _c !== void 0 ? _c : last;
|
|
10000
|
+
return last;
|
|
10001
|
+
}, false);
|
|
10002
|
+
}
|
|
10003
|
+
/*
|
|
10004
|
+
* The frame of a CAD tileset drawn at this Assembly's root, which moves with its history and simulation.
|
|
10005
|
+
*/
|
|
10006
|
+
drawnFrame(entity) {
|
|
10007
|
+
var _a, _b;
|
|
10008
|
+
const root = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.AssemblyRootLocation;
|
|
10009
|
+
for (const { tileset } of this.register.GetTilesets()) {
|
|
10010
|
+
const at = (_b = tileset._bruceCoords) === null || _b === void 0 ? void 0 : _b.location;
|
|
10011
|
+
if (at && root &&
|
|
10012
|
+
Math.abs(+at.latitude - +root.latitude) < 1e-7 &&
|
|
10013
|
+
Math.abs(+at.longitude - +root.longitude) < 1e-7 &&
|
|
10014
|
+
Math.abs((+at.altitude || 0) - (+root.altitude || 0)) < 0.01) {
|
|
10015
|
+
return EntityUtils.GetTilesetRootFrame(tileset);
|
|
10016
|
+
}
|
|
10017
|
+
}
|
|
10018
|
+
return null;
|
|
10019
|
+
}
|
|
9937
10020
|
Remove(id) {
|
|
9938
10021
|
var _a;
|
|
9939
10022
|
const known = this.definitions.delete(id);
|
|
@@ -23523,7 +23606,9 @@ var TilesetCadRenderManager;
|
|
|
23523
23606
|
ucs: coords === null || coords === void 0 ? void 0 : coords.ucs,
|
|
23524
23607
|
location: (coords === null || coords === void 0 ? void 0 : coords.location) == null ? settings.location : coords.location,
|
|
23525
23608
|
transform: (coords === null || coords === void 0 ? void 0 : coords.transform) == null ? settings.transform : coords.transform
|
|
23526
|
-
}
|
|
23609
|
+
},
|
|
23610
|
+
// Placed as first drawn, or a model-space tileset jumps to its site on a history or simulation update.
|
|
23611
|
+
modelSpace: this.modelSpace
|
|
23527
23612
|
});
|
|
23528
23613
|
this.viewer.scene.requestRender();
|
|
23529
23614
|
}
|
|
@@ -24107,6 +24192,13 @@ var EntityFilterGetter;
|
|
|
24107
24192
|
this.historicAttrDateTime = newDateTime.toISOString();
|
|
24108
24193
|
}
|
|
24109
24194
|
}
|
|
24195
|
+
/*
|
|
24196
|
+
* Returns the viewer clock's current time as ISO, or null without a viewer.
|
|
24197
|
+
*/
|
|
24198
|
+
sceneDateTime() {
|
|
24199
|
+
var _a;
|
|
24200
|
+
return ((_a = this.viewer) === null || _a === void 0 ? void 0 : _a.clock) ? JulianDate.toDate(this.viewer.clock.currentTime).toISOString() : null;
|
|
24201
|
+
}
|
|
24110
24202
|
viewerDateTimeDispose() {
|
|
24111
24203
|
var _a;
|
|
24112
24204
|
(_a = this.viewerDateTimeChangeRemoval) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -24390,7 +24482,8 @@ var EntityFilterGetter;
|
|
|
24390
24482
|
api: this.api,
|
|
24391
24483
|
scenario: this.scenario,
|
|
24392
24484
|
historicKey: this.historicAttrKey,
|
|
24393
|
-
|
|
24485
|
+
// Non-historic items still read as at the scene's time, matching the info view.
|
|
24486
|
+
historicPoint: (this.historicAttrKey || this.historic) ? this.historicAttrDateTime : this.sceneDateTime(),
|
|
24394
24487
|
expandSources: true,
|
|
24395
24488
|
expandLocation: true,
|
|
24396
24489
|
schemaId: this.schemaId,
|
|
@@ -38270,7 +38363,7 @@ var ViewRenderEngine;
|
|
|
38270
38363
|
if (!bookmark) {
|
|
38271
38364
|
let bookmarkId = params.bookmarkId;
|
|
38272
38365
|
if (!bookmarkId) {
|
|
38273
|
-
bookmarkId = view.
|
|
38366
|
+
bookmarkId = view["Default.UISlide.ID"];
|
|
38274
38367
|
}
|
|
38275
38368
|
bookmark = bookmarkId ? (await ProjectViewBookmark.Get({
|
|
38276
38369
|
api,
|
|
@@ -38331,7 +38424,7 @@ var ViewRenderEngine;
|
|
|
38331
38424
|
if (!bookmark) {
|
|
38332
38425
|
let bookmarkId = params.bookmarkId;
|
|
38333
38426
|
if (!bookmarkId) {
|
|
38334
|
-
bookmarkId = view.
|
|
38427
|
+
bookmarkId = view["Default.UISlide.ID"];
|
|
38335
38428
|
}
|
|
38336
38429
|
bookmark = bookmarkId ? (await ProjectViewBookmark.Get({
|
|
38337
38430
|
api,
|
|
@@ -44552,6 +44645,47 @@ function calcEntityLocation(entity, modelSpace) {
|
|
|
44552
44645
|
}
|
|
44553
44646
|
return Matrix4.multiplyByPoint(enuFrame, new Cartesian3(tx, ty, tz), new Cartesian3());
|
|
44554
44647
|
}
|
|
44648
|
+
/*
|
|
44649
|
+
* Reads a row-major 4x4 from a record, or null when it is missing or malformed.
|
|
44650
|
+
*/
|
|
44651
|
+
function matrixFromRows(rows) {
|
|
44652
|
+
if (!Array.isArray(rows) || rows.length !== 4) {
|
|
44653
|
+
return null;
|
|
44654
|
+
}
|
|
44655
|
+
const values = [].concat(...rows).map(Number);
|
|
44656
|
+
return values.length === 16 && values.every(Number.isFinite) ? Matrix4.fromRowMajorArray(values) : null;
|
|
44657
|
+
}
|
|
44658
|
+
/*
|
|
44659
|
+
* An Assembly part's geometry centre in its root's frame, via its parent so a simulated AssemblyPosition counts.
|
|
44660
|
+
*/
|
|
44661
|
+
function calcAssemblyPartOffset(entity) {
|
|
44662
|
+
const bruce = entity === null || entity === void 0 ? void 0 : entity.Bruce;
|
|
44663
|
+
const pivot = Array.isArray(bruce === null || bruce === void 0 ? void 0 : bruce.GeometryPivot) && bruce.GeometryPivot.length >= 3 ? bruce.GeometryPivot.slice(0, 3).map(Number) : null;
|
|
44664
|
+
const parent = matrixFromRows(bruce === null || bruce === void 0 ? void 0 : bruce.AssemblyParentWorldPosition);
|
|
44665
|
+
const local = matrixFromRows(bruce === null || bruce === void 0 ? void 0 : bruce.AssemblyPosition);
|
|
44666
|
+
const world = parent && local ? Matrix4.multiply(parent, local, new Matrix4()) : matrixFromRows(bruce === null || bruce === void 0 ? void 0 : bruce.AssemblyWorldPosition);
|
|
44667
|
+
if (world && (!pivot || pivot.every(Number.isFinite))) {
|
|
44668
|
+
return Matrix4.multiplyByPoint(world, pivot ? Cartesian3.fromArray(pivot) : Cartesian3.ZERO, new Cartesian3());
|
|
44669
|
+
}
|
|
44670
|
+
const worldPivot = Array.isArray(bruce === null || bruce === void 0 ? void 0 : bruce.GeometryWorldPivot) ? bruce.GeometryWorldPivot.slice(0, 3).map(Number) : [];
|
|
44671
|
+
return worldPivot.length === 3 && worldPivot.every(Number.isFinite) ? Cartesian3.fromArray(worldPivot) : null;
|
|
44672
|
+
}
|
|
44673
|
+
/*
|
|
44674
|
+
* The frame a part's record places it in, as the API's Location: the root (0,0 in model-space), then its transform.
|
|
44675
|
+
*/
|
|
44676
|
+
function calcAssemblyRootFrame(entity, modelSpace) {
|
|
44677
|
+
var _a, _b, _c;
|
|
44678
|
+
const root = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.AssemblyRootLocation;
|
|
44679
|
+
if (!root && !modelSpace) {
|
|
44680
|
+
return null;
|
|
44681
|
+
}
|
|
44682
|
+
const origin = modelSpace ? Cartesian3.fromDegrees(0, 0, 0) : Cartesian3.fromDegrees(EnsureNumber(root.longitude), EnsureNumber(root.latitude), EnsureNumber(root.altitude));
|
|
44683
|
+
const transform = (_c = (_b = entity.Bruce) === null || _b === void 0 ? void 0 : _b.AssemblyWorldTransform) !== null && _c !== void 0 ? _c : {};
|
|
44684
|
+
const frame = Transforms.eastNorthUpToFixedFrame(origin);
|
|
44685
|
+
Matrix4.multiply(frame, Matrix4.fromTranslation(new Cartesian3(EnsureNumber(transform.x), EnsureNumber(transform.y), EnsureNumber(transform.z))), frame);
|
|
44686
|
+
const hpr = HeadingPitchRoll.fromDegrees(EnsureNumber(transform.heading), EnsureNumber(transform.pitch), EnsureNumber(transform.roll));
|
|
44687
|
+
return Matrix4.multiply(frame, Matrix4.fromRotation(Matrix3.fromHeadingPitchRoll(hpr)), frame);
|
|
44688
|
+
}
|
|
44555
44689
|
// Records created within about this long ago are the ones the oversized GeometryRadius bug could have written.
|
|
44556
44690
|
const GEOMETRY_RADIUS_SUSPECT_AGE_MS = 1000 * 60 * 60 * 24 * 183;
|
|
44557
44691
|
// Above this a recent record's radius is treated as that bug rather than a real size.
|
|
@@ -44597,6 +44731,61 @@ function getModelBoundsCenter(viewer, part, pos3d, bounds) {
|
|
|
44597
44731
|
const _assemblyAxisShift = new Quaternion(0, 0, -Math.SQRT1_2, Math.SQRT1_2);
|
|
44598
44732
|
var EntityUtils;
|
|
44599
44733
|
(function (EntityUtils) {
|
|
44734
|
+
/**
|
|
44735
|
+
* Returns where an Assembly part's geometry centre is, without asking the API or the scene.
|
|
44736
|
+
* Bruce.Location only holds where the API last placed it, so this composes from the root's frame instead.
|
|
44737
|
+
* @param params.rootFrame the frame its Assembly is drawn in now, eg. GetTilesetRootFrame of its CAD tileset.
|
|
44738
|
+
* Default: the frame its record describes, at 0,0 in model-space.
|
|
44739
|
+
* @returns null when the record is not an Assembly part or lacks its matrices.
|
|
44740
|
+
*/
|
|
44741
|
+
function GetAssemblyPartPos3d(params) {
|
|
44742
|
+
var _a;
|
|
44743
|
+
const { viewer, entity } = params;
|
|
44744
|
+
if (!IsAssemblyPart(entity)) {
|
|
44745
|
+
return null;
|
|
44746
|
+
}
|
|
44747
|
+
const offset = calcAssemblyPartOffset(entity);
|
|
44748
|
+
const frame = (_a = params.rootFrame) !== null && _a !== void 0 ? _a : calcAssemblyRootFrame(entity, ViewUtils.GetModelSpace(viewer));
|
|
44749
|
+
return offset && frame ? Matrix4.multiplyByPoint(frame, offset, new Cartesian3()) : null;
|
|
44750
|
+
}
|
|
44751
|
+
EntityUtils.GetAssemblyPartPos3d = GetAssemblyPartPos3d;
|
|
44752
|
+
/**
|
|
44753
|
+
* Returns the geospatial frame a part's record assumes for its root, the one the API works Location out in.
|
|
44754
|
+
* Comparing it with where the Assembly is drawn gives how far the drawing has moved from the record.
|
|
44755
|
+
* @param entity
|
|
44756
|
+
*/
|
|
44757
|
+
function GetAssemblyRecordFrame(entity) {
|
|
44758
|
+
return IsAssemblyPart(entity) ? calcAssemblyRootFrame(entity, false) : null;
|
|
44759
|
+
}
|
|
44760
|
+
EntityUtils.GetAssemblyRecordFrame = GetAssemblyRecordFrame;
|
|
44761
|
+
/**
|
|
44762
|
+
* Returns whether a record is an Assembly part, ie. placed through its root rather than its own Location.
|
|
44763
|
+
* @param entity
|
|
44764
|
+
*/
|
|
44765
|
+
function IsAssemblyPart(entity) {
|
|
44766
|
+
const bruce = entity === null || entity === void 0 ? void 0 : entity.Bruce;
|
|
44767
|
+
return ((bruce === null || bruce === void 0 ? void 0 : bruce.AssemblyRootLocation) != null &&
|
|
44768
|
+
(bruce.AssemblyWorldPosition != null || bruce.AssemblyPosition != null || bruce.GeometryWorldPivot != null));
|
|
44769
|
+
}
|
|
44770
|
+
EntityUtils.IsAssemblyPart = IsAssemblyPart;
|
|
44771
|
+
/**
|
|
44772
|
+
* Returns the frame a tileset is drawn in now, without its scale, so Assembly offsets in metres apply to it.
|
|
44773
|
+
* It follows whatever moved the tileset: history, a simulated root, or model-space.
|
|
44774
|
+
* @param tileset
|
|
44775
|
+
*/
|
|
44776
|
+
function GetTilesetRootFrame(tileset) {
|
|
44777
|
+
var _a, _b;
|
|
44778
|
+
const transform = (_a = tileset === null || tileset === void 0 ? void 0 : tileset.root) === null || _a === void 0 ? void 0 : _a.transform;
|
|
44779
|
+
if (!transform || ((_b = tileset.isDestroyed) === null || _b === void 0 ? void 0 : _b.call(tileset))) {
|
|
44780
|
+
return null;
|
|
44781
|
+
}
|
|
44782
|
+
const scale = Matrix4.getScale(transform, new Cartesian3());
|
|
44783
|
+
if (!(scale.x > 0)) {
|
|
44784
|
+
return null;
|
|
44785
|
+
}
|
|
44786
|
+
return Matrix4.multiplyByUniformScale(transform, 1 / scale.x, new Matrix4());
|
|
44787
|
+
}
|
|
44788
|
+
EntityUtils.GetTilesetRootFrame = GetTilesetRootFrame;
|
|
44600
44789
|
/**
|
|
44601
44790
|
* Returns the location for given entity or entities.
|
|
44602
44791
|
* If available it will also compute a rectangle.
|
|
@@ -46459,6 +46648,418 @@ function OneTimeError(key, message) {
|
|
|
46459
46648
|
}
|
|
46460
46649
|
}
|
|
46461
46650
|
|
|
46651
|
+
/**
|
|
46652
|
+
* Draws the orientation effect a point style can ask for, an open ring whose pointer shows which way the Entity faces.
|
|
46653
|
+
*/
|
|
46654
|
+
var EntityRenderEnginePointOrientation;
|
|
46655
|
+
(function (EntityRenderEnginePointOrientation) {
|
|
46656
|
+
// Compared as the wire string, since an older bruce-models in the host has no EPointEffectType at runtime.
|
|
46657
|
+
EntityRenderEnginePointOrientation.ORIENTATION_EFFECT = "ORIENTATION";
|
|
46658
|
+
// Clearance between the glyph and the ring, and the smallest ring, matching entity-label.ts's icon ring.
|
|
46659
|
+
EntityRenderEnginePointOrientation.RING_PADDING = 4;
|
|
46660
|
+
EntityRenderEnginePointOrientation.RING_MIN = 10;
|
|
46661
|
+
const RING_STROKE = 2;
|
|
46662
|
+
const RING_CSS = "rgba(255, 255, 255, 0.8)";
|
|
46663
|
+
const RING_GLOW_CSS = "rgba(0, 0, 0, 0.3)";
|
|
46664
|
+
const RING_GLOW_BLUR = 5;
|
|
46665
|
+
// The pointer reaches TIP_BASE + TIP_GROWTH * sqrt(radius) px past the ring, so it grows slower than the ring.
|
|
46666
|
+
const TIP_BASE = 3;
|
|
46667
|
+
const TIP_GROWTH = 2.2;
|
|
46668
|
+
// Share of the circle kept around the heading. Label rings keep 0.35, but the pointer uses most of it.
|
|
46669
|
+
const ARC_FRACTION = 0.5;
|
|
46670
|
+
// The arc always runs at least this far past where the pointer leaves it, so it still reads as a ring.
|
|
46671
|
+
const ARC_TAIL = Math.PI / 30;
|
|
46672
|
+
const ARC_STEPS = 12;
|
|
46673
|
+
// Copies of the cap outline nested toward its centre, enough for 2 px strokes to read as a fill.
|
|
46674
|
+
const CAP_FILL_LOOPS = 4;
|
|
46675
|
+
// Canvas oversampling so the stroke stays crisp on high density screens.
|
|
46676
|
+
const RING_DPR = 2;
|
|
46677
|
+
const _ringCache = new LRUCache(50);
|
|
46678
|
+
/*
|
|
46679
|
+
* Whether a point style asks for the orientation effect.
|
|
46680
|
+
*/
|
|
46681
|
+
function IsEnabled(style) {
|
|
46682
|
+
var _a;
|
|
46683
|
+
return ((_a = style === null || style === void 0 ? void 0 : style.effect) === null || _a === void 0 ? void 0 : _a.type) === EntityRenderEnginePointOrientation.ORIENTATION_EFFECT;
|
|
46684
|
+
}
|
|
46685
|
+
EntityRenderEnginePointOrientation.IsEnabled = IsEnabled;
|
|
46686
|
+
/*
|
|
46687
|
+
* The Entity's orientation from Bruce.Transform, or null when it has no usable heading to show.
|
|
46688
|
+
*/
|
|
46689
|
+
function GetOrientation(entity) {
|
|
46690
|
+
var _a;
|
|
46691
|
+
const transform = (_a = entity === null || entity === void 0 ? void 0 : entity.Bruce) === null || _a === void 0 ? void 0 : _a.Transform;
|
|
46692
|
+
const raw = transform === null || transform === void 0 ? void 0 : transform.heading;
|
|
46693
|
+
if (raw == null ||
|
|
46694
|
+
(typeof raw == "string" && !raw.trim())) {
|
|
46695
|
+
return null;
|
|
46696
|
+
}
|
|
46697
|
+
const heading = Number(raw);
|
|
46698
|
+
if (!isFinite(heading)) {
|
|
46699
|
+
return null;
|
|
46700
|
+
}
|
|
46701
|
+
const pitch = Number(transform.pitch);
|
|
46702
|
+
const roll = Number(transform.roll);
|
|
46703
|
+
return {
|
|
46704
|
+
heading,
|
|
46705
|
+
pitch: isFinite(pitch) ? pitch : 0,
|
|
46706
|
+
roll: isFinite(roll) ? roll : 0
|
|
46707
|
+
};
|
|
46708
|
+
}
|
|
46709
|
+
EntityRenderEnginePointOrientation.GetOrientation = GetOrientation;
|
|
46710
|
+
/*
|
|
46711
|
+
* Ring radius in px for a glyph of the given radius.
|
|
46712
|
+
*/
|
|
46713
|
+
function GetRingRadius(glyphRadius) {
|
|
46714
|
+
const radius = Number(glyphRadius);
|
|
46715
|
+
return Math.max(EntityRenderEnginePointOrientation.RING_MIN, (isFinite(radius) ? radius : 0) + EntityRenderEnginePointOrientation.RING_PADDING);
|
|
46716
|
+
}
|
|
46717
|
+
EntityRenderEnginePointOrientation.GetRingRadius = GetRingRadius;
|
|
46718
|
+
/*
|
|
46719
|
+
* How far the pointer's tip sits from the centre, as a multiple of the ring radius.
|
|
46720
|
+
*/
|
|
46721
|
+
function GetTipRatio(ringRadius) {
|
|
46722
|
+
return 1 + (TIP_BASE + TIP_GROWTH * Math.sqrt(ringRadius)) / ringRadius;
|
|
46723
|
+
}
|
|
46724
|
+
EntityRenderEnginePointOrientation.GetTipRatio = GetTipRatio;
|
|
46725
|
+
/*
|
|
46726
|
+
* The open ring in a unit frame, u forward and v right: arc tail, tangent to the tip, tangent back, arc tail.
|
|
46727
|
+
* The pointer's sides are tangents to the circle, so the arc runs into the tip with no visible joint.
|
|
46728
|
+
*/
|
|
46729
|
+
function GetOutline(tipRatio) {
|
|
46730
|
+
const touch = Math.acos(1 / tipRatio);
|
|
46731
|
+
const half = Math.max(Math.PI * ARC_FRACTION, touch + ARC_TAIL);
|
|
46732
|
+
const points = [];
|
|
46733
|
+
for (let i = 0; i <= ARC_STEPS; i++) {
|
|
46734
|
+
const phi = -half + (half - touch) * i / ARC_STEPS;
|
|
46735
|
+
points.push([Math.cos(phi), Math.sin(phi)]);
|
|
46736
|
+
}
|
|
46737
|
+
points.push([tipRatio, 0]);
|
|
46738
|
+
for (let i = 0; i <= ARC_STEPS; i++) {
|
|
46739
|
+
const phi = touch + (half - touch) * i / ARC_STEPS;
|
|
46740
|
+
points.push([Math.cos(phi), Math.sin(phi)]);
|
|
46741
|
+
}
|
|
46742
|
+
return points;
|
|
46743
|
+
}
|
|
46744
|
+
EntityRenderEnginePointOrientation.GetOutline = GetOutline;
|
|
46745
|
+
/*
|
|
46746
|
+
* The filled cap between the pointer's sides and the circle, in the same unit frame as GetOutline.
|
|
46747
|
+
*/
|
|
46748
|
+
function GetCap(tipRatio) {
|
|
46749
|
+
const touch = Math.acos(1 / tipRatio);
|
|
46750
|
+
const points = [[tipRatio, 0]];
|
|
46751
|
+
for (let i = 0; i <= ARC_STEPS; i++) {
|
|
46752
|
+
const phi = touch - 2 * touch * i / ARC_STEPS;
|
|
46753
|
+
points.push([Math.cos(phi), Math.sin(phi)]);
|
|
46754
|
+
}
|
|
46755
|
+
return points;
|
|
46756
|
+
}
|
|
46757
|
+
EntityRenderEnginePointOrientation.GetCap = GetCap;
|
|
46758
|
+
/*
|
|
46759
|
+
* The outline as one path with its cap filled by nested copies of the cap's outline, for a polyline that cannot fill.
|
|
46760
|
+
* Back and forth strokes would need sharp reversals, which Cesium mitres into spikes; nested loops only turn at the
|
|
46761
|
+
* cap's own corners. Like GetOutline it starts and ends on the arc tails.
|
|
46762
|
+
*/
|
|
46763
|
+
function GetFilledOutline(tipRatio) {
|
|
46764
|
+
const outline = GetOutline(tipRatio);
|
|
46765
|
+
const tipIndex = outline.findIndex(([u, v]) => u === tipRatio && v === 0);
|
|
46766
|
+
const cap = GetCap(tipRatio);
|
|
46767
|
+
const cu = cap.reduce((sum, [u]) => sum + u, 0) / cap.length;
|
|
46768
|
+
const cv = cap.reduce((sum, [, v]) => sum + v, 0) / cap.length;
|
|
46769
|
+
const loops = [];
|
|
46770
|
+
for (let i = 0; i < CAP_FILL_LOOPS; i++) {
|
|
46771
|
+
const k = 1 - i / CAP_FILL_LOOPS;
|
|
46772
|
+
for (const [u, v] of cap) {
|
|
46773
|
+
loops.push([cu + (u - cu) * k, cv + (v - cv) * k]);
|
|
46774
|
+
}
|
|
46775
|
+
}
|
|
46776
|
+
loops.push([tipRatio, 0]);
|
|
46777
|
+
return [...outline.slice(0, tipIndex + 1), ...loops, ...outline.slice(tipIndex + 1)];
|
|
46778
|
+
}
|
|
46779
|
+
EntityRenderEnginePointOrientation.GetFilledOutline = GetFilledOutline;
|
|
46780
|
+
/*
|
|
46781
|
+
* Draws the ring for a glyph as a billboard image pointing up, or null where there is no canvas to draw on.
|
|
46782
|
+
*/
|
|
46783
|
+
function CreateRingBillboard(glyphRadius) {
|
|
46784
|
+
var _a;
|
|
46785
|
+
const radius = GetRingRadius(glyphRadius);
|
|
46786
|
+
const key = radius.toFixed(1);
|
|
46787
|
+
const cached = _ringCache.Get(key);
|
|
46788
|
+
if (cached) {
|
|
46789
|
+
return cached;
|
|
46790
|
+
}
|
|
46791
|
+
const tipRatio = GetTipRatio(radius);
|
|
46792
|
+
const size = Math.ceil((radius * tipRatio + RING_STROKE + RING_GLOW_BLUR) * 2);
|
|
46793
|
+
const canvas = document.createElement("canvas");
|
|
46794
|
+
canvas.width = size * RING_DPR;
|
|
46795
|
+
canvas.height = size * RING_DPR;
|
|
46796
|
+
const context = (_a = canvas.getContext) === null || _a === void 0 ? void 0 : _a.call(canvas, "2d");
|
|
46797
|
+
if (!context) {
|
|
46798
|
+
return null;
|
|
46799
|
+
}
|
|
46800
|
+
context.scale(RING_DPR, RING_DPR);
|
|
46801
|
+
// Forward is up the image, right is to the right.
|
|
46802
|
+
const toCanvas = ([u, v]) => [size / 2 + v * radius, size / 2 - u * radius];
|
|
46803
|
+
const trace = (points, close) => {
|
|
46804
|
+
context.beginPath();
|
|
46805
|
+
points.map(toCanvas).forEach(([x, y], i) => i ? context.lineTo(x, y) : context.moveTo(x, y));
|
|
46806
|
+
if (close) {
|
|
46807
|
+
context.closePath();
|
|
46808
|
+
}
|
|
46809
|
+
};
|
|
46810
|
+
context.shadowColor = RING_GLOW_CSS;
|
|
46811
|
+
context.shadowBlur = RING_GLOW_BLUR;
|
|
46812
|
+
context.fillStyle = RING_CSS;
|
|
46813
|
+
trace(GetCap(tipRatio), true);
|
|
46814
|
+
context.fill();
|
|
46815
|
+
context.strokeStyle = RING_CSS;
|
|
46816
|
+
context.lineWidth = RING_STROKE;
|
|
46817
|
+
context.lineJoin = "round";
|
|
46818
|
+
context.lineCap = "round";
|
|
46819
|
+
trace(GetOutline(tipRatio), false);
|
|
46820
|
+
context.stroke();
|
|
46821
|
+
const ring = {
|
|
46822
|
+
canvasDataUri: canvas.toDataURL("image/png"),
|
|
46823
|
+
size
|
|
46824
|
+
};
|
|
46825
|
+
_ringCache.Set(key, ring);
|
|
46826
|
+
return ring;
|
|
46827
|
+
}
|
|
46828
|
+
EntityRenderEnginePointOrientation.CreateRingBillboard = CreateRingBillboard;
|
|
46829
|
+
/*
|
|
46830
|
+
* World space unit vector along the local horizon at a heading in degrees clockwise from north.
|
|
46831
|
+
*/
|
|
46832
|
+
function GetHeadingAxis(pos3d, heading) {
|
|
46833
|
+
const enu = Transforms.eastNorthUpToFixedFrame(pos3d);
|
|
46834
|
+
const rad = Math$1.toRadians(heading);
|
|
46835
|
+
const local = new Cartesian3(Math.sin(rad), Math.cos(rad), 0);
|
|
46836
|
+
const world = Matrix4.multiplyByPointAsVector(enu, local, new Cartesian3());
|
|
46837
|
+
return Cartesian3.normalize(world, world);
|
|
46838
|
+
}
|
|
46839
|
+
EntityRenderEnginePointOrientation.GetHeadingAxis = GetHeadingAxis;
|
|
46840
|
+
/*
|
|
46841
|
+
* World space forward and right unit vectors for a full orientation, which span the plane the 3D ring lies in.
|
|
46842
|
+
*/
|
|
46843
|
+
function GetBasis(pos3d, orientation) {
|
|
46844
|
+
const h = Math$1.toRadians(orientation.heading);
|
|
46845
|
+
const p = Math$1.toRadians(orientation.pitch);
|
|
46846
|
+
const r = Math$1.toRadians(orientation.roll);
|
|
46847
|
+
const forward = new Cartesian3(Math.sin(h) * Math.cos(p), Math.cos(h) * Math.cos(p), Math.sin(p));
|
|
46848
|
+
const level = new Cartesian3(Math.cos(h), -Math.sin(h), 0);
|
|
46849
|
+
const up = Cartesian3.cross(level, forward, new Cartesian3());
|
|
46850
|
+
// Positive roll lowers the right side.
|
|
46851
|
+
const right = Cartesian3.add(Cartesian3.multiplyByScalar(level, Math.cos(r), new Cartesian3()), Cartesian3.multiplyByScalar(up, -Math.sin(r), new Cartesian3()), new Cartesian3());
|
|
46852
|
+
const enu = Transforms.eastNorthUpToFixedFrame(pos3d);
|
|
46853
|
+
const toWorld = (local) => {
|
|
46854
|
+
const world = Matrix4.multiplyByPointAsVector(enu, local, new Cartesian3());
|
|
46855
|
+
return Cartesian3.normalize(world, world);
|
|
46856
|
+
};
|
|
46857
|
+
return { forward: toWorld(forward), right: toWorld(right) };
|
|
46858
|
+
}
|
|
46859
|
+
EntityRenderEnginePointOrientation.GetBasis = GetBasis;
|
|
46860
|
+
/*
|
|
46861
|
+
* Counter-clockwise billboard rotation that turns its up edge along a world direction as the camera sees it.
|
|
46862
|
+
* Cesium's alignedAxis squares its angle and drops perspective, up to 160 degrees out when side on.
|
|
46863
|
+
*/
|
|
46864
|
+
function GetScreenRotation(viewer, pos3d, axis) {
|
|
46865
|
+
const transforms = SceneTransforms;
|
|
46866
|
+
const project = transforms.wgs84ToWindowCoordinates || transforms.worldToWindowCoordinates;
|
|
46867
|
+
const camera = viewer.camera.positionWC || viewer.camera.position;
|
|
46868
|
+
// A step proportional to distance keeps the two projections a few pixels apart at any zoom.
|
|
46869
|
+
const step = Math.max(0.01, Cartesian3.distance(camera, pos3d) * 0.01);
|
|
46870
|
+
const ahead = Cartesian3.add(pos3d, Cartesian3.multiplyByScalar(axis, step, new Cartesian3()), new Cartesian3());
|
|
46871
|
+
const from = project(viewer.scene, pos3d, new Cartesian2());
|
|
46872
|
+
const to = project(viewer.scene, ahead, new Cartesian2());
|
|
46873
|
+
if (!from || !to) {
|
|
46874
|
+
return null;
|
|
46875
|
+
}
|
|
46876
|
+
const dx = to.x - from.x;
|
|
46877
|
+
const dy = to.y - from.y;
|
|
46878
|
+
if (Math.abs(dx) + Math.abs(dy) < 1e-6) {
|
|
46879
|
+
return null;
|
|
46880
|
+
}
|
|
46881
|
+
return Math.atan2(-dx, -dy);
|
|
46882
|
+
}
|
|
46883
|
+
EntityRenderEnginePointOrientation.GetScreenRotation = GetScreenRotation;
|
|
46884
|
+
/*
|
|
46885
|
+
* Metres one CSS pixel covers at a position, since billboard sizes and polyline widths are CSS pixels.
|
|
46886
|
+
*/
|
|
46887
|
+
function getMetresPerPixel(viewer, pos3d) {
|
|
46888
|
+
const scene = viewer.scene;
|
|
46889
|
+
const sphere = new BoundingSphere(pos3d, 0);
|
|
46890
|
+
const perBufferPixel = viewer.camera.getPixelSize(sphere, scene.drawingBufferWidth, scene.drawingBufferHeight);
|
|
46891
|
+
return perBufferPixel * (scene.pixelRatio || 1);
|
|
46892
|
+
}
|
|
46893
|
+
/*
|
|
46894
|
+
* Where the parent is drawn this frame, as an absolute position, or null while its ground is not known yet.
|
|
46895
|
+
*/
|
|
46896
|
+
function getDrawnPos3d(viewer, parent, heightRef) {
|
|
46897
|
+
const pos3d = GetCValue(viewer, parent.position);
|
|
46898
|
+
if (!pos3d) {
|
|
46899
|
+
return null;
|
|
46900
|
+
}
|
|
46901
|
+
return DrawingUtils.GetDrawnPos3d({
|
|
46902
|
+
viewer,
|
|
46903
|
+
heightRef,
|
|
46904
|
+
pos3d,
|
|
46905
|
+
terrainId: ViewUtils.GetTerrainCacheId(viewer)
|
|
46906
|
+
});
|
|
46907
|
+
}
|
|
46908
|
+
/*
|
|
46909
|
+
* Creates or updates the ring for a point, or returns null when it cannot be drawn.
|
|
46910
|
+
* Clamped to ground it shows only the heading as a billboard, otherwise the full 3D orientation.
|
|
46911
|
+
*/
|
|
46912
|
+
function Render(params) {
|
|
46913
|
+
const { viewer, parent, orientation, heightRef } = params;
|
|
46914
|
+
if (!viewer || !parent || !orientation) {
|
|
46915
|
+
return null;
|
|
46916
|
+
}
|
|
46917
|
+
const clamped = heightRef == HeightReference.CLAMP_TO_GROUND;
|
|
46918
|
+
const ring = clamped ? renderBillboard(params) : renderPolyline(params);
|
|
46919
|
+
if (ring) {
|
|
46920
|
+
ring._orientationRing = true;
|
|
46921
|
+
ring._noEdit = true;
|
|
46922
|
+
ring._parentEntity = parent;
|
|
46923
|
+
}
|
|
46924
|
+
return ring;
|
|
46925
|
+
}
|
|
46926
|
+
EntityRenderEnginePointOrientation.Render = Render;
|
|
46927
|
+
/*
|
|
46928
|
+
* The ring among a point's sibling graphics, if it has one.
|
|
46929
|
+
*/
|
|
46930
|
+
function FindRing(siblings) {
|
|
46931
|
+
return (siblings === null || siblings === void 0 ? void 0 : siblings.find(x => x === null || x === void 0 ? void 0 : x._orientationRing)) || null;
|
|
46932
|
+
}
|
|
46933
|
+
EntityRenderEnginePointOrientation.FindRing = FindRing;
|
|
46934
|
+
/*
|
|
46935
|
+
* The heading only ring, a billboard turned every frame to point along the ground.
|
|
46936
|
+
*/
|
|
46937
|
+
function renderBillboard(params) {
|
|
46938
|
+
var _a;
|
|
46939
|
+
const { viewer, parent, orientation, heightRef } = params;
|
|
46940
|
+
const image = CreateRingBillboard(params.glyphRadius);
|
|
46941
|
+
if (!image) {
|
|
46942
|
+
return null;
|
|
46943
|
+
}
|
|
46944
|
+
let rotation = 0;
|
|
46945
|
+
const rotationProp = new CallbackProperty(() => {
|
|
46946
|
+
const drawn = getDrawnPos3d(viewer, parent, heightRef);
|
|
46947
|
+
if (drawn) {
|
|
46948
|
+
const next = GetScreenRotation(viewer, drawn, GetHeadingAxis(drawn, orientation.heading));
|
|
46949
|
+
if (next != null) {
|
|
46950
|
+
rotation = next;
|
|
46951
|
+
}
|
|
46952
|
+
}
|
|
46953
|
+
return rotation;
|
|
46954
|
+
}, false);
|
|
46955
|
+
const position = new CallbackProperty(() => GetCValue(viewer, parent.position), false);
|
|
46956
|
+
const displayCondition = EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance);
|
|
46957
|
+
const pixelOffset = new Cartesian2(0, -(params.glyphOffsetY || 0));
|
|
46958
|
+
let ring = ((_a = params.existing) === null || _a === void 0 ? void 0 : _a.billboard) ? params.existing : null;
|
|
46959
|
+
if (!ring) {
|
|
46960
|
+
ring = new Entity({
|
|
46961
|
+
id: ObjectUtils.UId(15),
|
|
46962
|
+
billboard: {
|
|
46963
|
+
image: image.canvasDataUri,
|
|
46964
|
+
width: image.size,
|
|
46965
|
+
height: image.size,
|
|
46966
|
+
rotation: rotationProp,
|
|
46967
|
+
heightReference: heightRef,
|
|
46968
|
+
pixelOffset,
|
|
46969
|
+
distanceDisplayCondition: displayCondition
|
|
46970
|
+
},
|
|
46971
|
+
position,
|
|
46972
|
+
show: true
|
|
46973
|
+
});
|
|
46974
|
+
}
|
|
46975
|
+
else {
|
|
46976
|
+
ring.billboard.image = new ConstantProperty(image.canvasDataUri);
|
|
46977
|
+
ring.billboard.width = new ConstantProperty(image.size);
|
|
46978
|
+
ring.billboard.height = new ConstantProperty(image.size);
|
|
46979
|
+
ring.billboard.rotation = rotationProp;
|
|
46980
|
+
ring.billboard.heightReference = new ConstantProperty(heightRef);
|
|
46981
|
+
ring.billboard.pixelOffset = new ConstantProperty(pixelOffset);
|
|
46982
|
+
ring.billboard.distanceDisplayCondition = new ConstantProperty(displayCondition);
|
|
46983
|
+
ring.position = position;
|
|
46984
|
+
ring.show = true;
|
|
46985
|
+
}
|
|
46986
|
+
CesiumEntityStyler.BakeDefaultColor({
|
|
46987
|
+
entity: ring,
|
|
46988
|
+
viewer,
|
|
46989
|
+
colors: {
|
|
46990
|
+
"billboard": Color.WHITE
|
|
46991
|
+
},
|
|
46992
|
+
refresh: false
|
|
46993
|
+
});
|
|
46994
|
+
return ring;
|
|
46995
|
+
}
|
|
46996
|
+
/*
|
|
46997
|
+
* The full orientation ring, a polyline in the orientation's plane, resized each frame to hold its screen size.
|
|
46998
|
+
*/
|
|
46999
|
+
function renderPolyline(params) {
|
|
47000
|
+
var _a;
|
|
47001
|
+
const { viewer, parent, orientation, heightRef } = params;
|
|
47002
|
+
const radiusPx = GetRingRadius(params.glyphRadius);
|
|
47003
|
+
const outline = GetFilledOutline(GetTipRatio(radiusPx));
|
|
47004
|
+
const color = Color.fromCssColorString(RING_CSS);
|
|
47005
|
+
let last = [];
|
|
47006
|
+
let basisAt = null;
|
|
47007
|
+
let basis = null;
|
|
47008
|
+
const positions = new CallbackProperty(() => {
|
|
47009
|
+
const drawn = getDrawnPos3d(viewer, parent, heightRef);
|
|
47010
|
+
if (!drawn) {
|
|
47011
|
+
return last;
|
|
47012
|
+
}
|
|
47013
|
+
// The local frame only changes when the point moves.
|
|
47014
|
+
if (!basisAt || !Cartesian3.equals(basisAt, drawn)) {
|
|
47015
|
+
basis = GetBasis(drawn, orientation);
|
|
47016
|
+
basisAt = Cartesian3.clone(drawn);
|
|
47017
|
+
}
|
|
47018
|
+
const scale = radiusPx * getMetresPerPixel(viewer, drawn);
|
|
47019
|
+
if (!isFinite(scale) || scale <= 0) {
|
|
47020
|
+
return last;
|
|
47021
|
+
}
|
|
47022
|
+
last = outline.map(([u, v]) => {
|
|
47023
|
+
const point = Cartesian3.multiplyByScalar(basis.forward, u * scale, new Cartesian3());
|
|
47024
|
+
Cartesian3.add(point, Cartesian3.multiplyByScalar(basis.right, v * scale, new Cartesian3()), point);
|
|
47025
|
+
return Cartesian3.add(point, drawn, point);
|
|
47026
|
+
});
|
|
47027
|
+
return last;
|
|
47028
|
+
}, false);
|
|
47029
|
+
const displayCondition = EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance);
|
|
47030
|
+
let ring = ((_a = params.existing) === null || _a === void 0 ? void 0 : _a.polyline) ? params.existing : null;
|
|
47031
|
+
if (!ring) {
|
|
47032
|
+
ring = new Entity({
|
|
47033
|
+
id: ObjectUtils.UId(15),
|
|
47034
|
+
polyline: {
|
|
47035
|
+
positions,
|
|
47036
|
+
width: RING_STROKE,
|
|
47037
|
+
material: color,
|
|
47038
|
+
arcType: ArcType.NONE,
|
|
47039
|
+
// The positions are already absolute. Unset reads as clamped to the culler, which then grounds the ring.
|
|
47040
|
+
clampToGround: false,
|
|
47041
|
+
distanceDisplayCondition: displayCondition
|
|
47042
|
+
},
|
|
47043
|
+
position: new CallbackProperty(() => GetCValue(viewer, parent.position), false),
|
|
47044
|
+
show: true
|
|
47045
|
+
});
|
|
47046
|
+
}
|
|
47047
|
+
else {
|
|
47048
|
+
ring.polyline.positions = positions;
|
|
47049
|
+
ring.polyline.distanceDisplayCondition = new ConstantProperty(displayCondition);
|
|
47050
|
+
ring.show = true;
|
|
47051
|
+
}
|
|
47052
|
+
CesiumEntityStyler.SetDefaultColor({
|
|
47053
|
+
color,
|
|
47054
|
+
entity: ring,
|
|
47055
|
+
viewer,
|
|
47056
|
+
override: true,
|
|
47057
|
+
requestRender: false
|
|
47058
|
+
});
|
|
47059
|
+
return ring;
|
|
47060
|
+
}
|
|
47061
|
+
})(EntityRenderEnginePointOrientation || (EntityRenderEnginePointOrientation = {}));
|
|
47062
|
+
|
|
46462
47063
|
/**
|
|
46463
47064
|
* Handles point rendering.
|
|
46464
47065
|
*/
|
|
@@ -46500,14 +47101,21 @@ var EntityRenderEnginePoint;
|
|
|
46500
47101
|
let animatePosition = null;
|
|
46501
47102
|
let shouldShowTrack = false;
|
|
46502
47103
|
let trackStyle = null;
|
|
47104
|
+
// The drawn glyph's half size and how far its centre sits above the anchor, for sizing the orientation ring.
|
|
47105
|
+
let glyph = null;
|
|
47106
|
+
// The orientation ring a previous render left, which the effect decides to keep or remove at the end.
|
|
47107
|
+
let existingRing = null;
|
|
46503
47108
|
const prepareExistingGraphic = (cEntity, maxSiblings = 0) => {
|
|
46504
47109
|
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
46505
47110
|
const parts = EntityUtils.GatherEntity({
|
|
46506
47111
|
entity: cEntity,
|
|
46507
47112
|
});
|
|
46508
47113
|
if (parts.length > 1) {
|
|
47114
|
+
// The ring is held apart so the sibling count below only ever trims the track.
|
|
47115
|
+
existingRing = EntityRenderEnginePointOrientation.FindRing(cEntity._siblingGraphics);
|
|
47116
|
+
const others = (cEntity._siblingGraphics || []).filter(x => x !== existingRing);
|
|
46509
47117
|
// We'll cull all except the allowed number of siblings.
|
|
46510
|
-
cEntity._siblingGraphics =
|
|
47118
|
+
cEntity._siblingGraphics = others.slice(0, maxSiblings).concat(existingRing ? [existingRing] : []);
|
|
46511
47119
|
// We'll remove all that aren't in the allowed (direct) list.
|
|
46512
47120
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
46513
47121
|
const part = parts[i];
|
|
@@ -46519,7 +47127,7 @@ var EntityRenderEnginePoint;
|
|
|
46519
47127
|
console.warn("Point.Render: Parent entity was not null. This should not happen.");
|
|
46520
47128
|
}
|
|
46521
47129
|
}
|
|
46522
|
-
siblings = cEntity._siblingGraphics;
|
|
47130
|
+
siblings = (cEntity._siblingGraphics || []).filter(x => x !== existingRing);
|
|
46523
47131
|
cEntity._siblingGraphics = [];
|
|
46524
47132
|
};
|
|
46525
47133
|
const updateShouldShowTrack = () => {
|
|
@@ -46772,6 +47380,11 @@ var EntityRenderEnginePoint;
|
|
|
46772
47380
|
}
|
|
46773
47381
|
cEntity.billboard._billboardSize = image.height;
|
|
46774
47382
|
cEntity.billboard._billboardImgKey = imageKey;
|
|
47383
|
+
// Icons hang from their bottom edge, so the glyph's centre sits half its height up.
|
|
47384
|
+
glyph = {
|
|
47385
|
+
radius: Math.max(image.width || image.height, image.height) * iconScale / 2,
|
|
47386
|
+
offsetY: image.height * iconScale / 2
|
|
47387
|
+
};
|
|
46775
47388
|
}
|
|
46776
47389
|
}
|
|
46777
47390
|
}
|
|
@@ -47145,6 +47758,7 @@ var EntityRenderEnginePoint;
|
|
|
47145
47758
|
cEntity.billboard._billboardImgKey = imgKey;
|
|
47146
47759
|
}
|
|
47147
47760
|
cEntity.billboard._billboardSize = Math.ceil(circleBillboard.height / 2);
|
|
47761
|
+
glyph = { radius: size / 2, offsetY: 0 };
|
|
47148
47762
|
}
|
|
47149
47763
|
// Generate a polyline 'track' for the historic data.
|
|
47150
47764
|
// We do this for historic data that exists and is moving.
|
|
@@ -47194,6 +47808,31 @@ var EntityRenderEnginePoint;
|
|
|
47194
47808
|
}
|
|
47195
47809
|
trackEntity._parentEntity = cEntity;
|
|
47196
47810
|
}
|
|
47811
|
+
// Cylinders set no glyph, so a style switching to one drops its ring.
|
|
47812
|
+
const orientation = glyph && cEntity && EntityRenderEnginePointOrientation.IsEnabled(style)
|
|
47813
|
+
? EntityRenderEnginePointOrientation.GetOrientation(entity)
|
|
47814
|
+
: null;
|
|
47815
|
+
const ring = orientation ? EntityRenderEnginePointOrientation.Render({
|
|
47816
|
+
viewer: params.viewer,
|
|
47817
|
+
parent: cEntity,
|
|
47818
|
+
existing: existingRing,
|
|
47819
|
+
orientation,
|
|
47820
|
+
heightRef,
|
|
47821
|
+
glyphRadius: glyph.radius,
|
|
47822
|
+
glyphOffsetY: glyph.offsetY,
|
|
47823
|
+
minDistance: params.minDistance,
|
|
47824
|
+
maxDistance: params.maxDistance
|
|
47825
|
+
}) : null;
|
|
47826
|
+
if (existingRing && existingRing !== ring) {
|
|
47827
|
+
RemoveCEntityFromScene(params.viewer, existingRing);
|
|
47828
|
+
}
|
|
47829
|
+
if (ring) {
|
|
47830
|
+
siblings.push(ring);
|
|
47831
|
+
// A new graphic on an existing visual needs a full refresh to be added, as the track does.
|
|
47832
|
+
if (ring !== existingRing && params.rego) {
|
|
47833
|
+
params.rego.stale = true;
|
|
47834
|
+
}
|
|
47835
|
+
}
|
|
47197
47836
|
cEntity._siblingGraphics = siblings;
|
|
47198
47837
|
cEntity.styleEffective = StyleEffective.Combine(styleTraceParts);
|
|
47199
47838
|
return cEntity;
|
|
@@ -47328,7 +47967,8 @@ const createImageBillboard = (url) => {
|
|
|
47328
47967
|
canvas.getContext("2d").drawImage(image, 0, 0);
|
|
47329
47968
|
return {
|
|
47330
47969
|
canvasDataUri: canvas.toDataURL("image/png"),
|
|
47331
|
-
height: image.height
|
|
47970
|
+
height: image.height,
|
|
47971
|
+
width: image.width
|
|
47332
47972
|
};
|
|
47333
47973
|
});
|
|
47334
47974
|
_billboardCache$1.Set(cacheKey, prom);
|
|
@@ -55593,7 +56233,7 @@ var StyleUtils;
|
|
|
55593
56233
|
StyleUtils.ApplyTypeStyle = ApplyTypeStyle;
|
|
55594
56234
|
})(StyleUtils || (StyleUtils = {}));
|
|
55595
56235
|
|
|
55596
|
-
const VERSION = "7.6.
|
|
56236
|
+
const VERSION = "7.6.6";
|
|
55597
56237
|
/**
|
|
55598
56238
|
* Updates the environment instance used by bruce-cesium to one specified.
|
|
55599
56239
|
* This can be used to ensure that the instance a parent is referencing is shared between bruce-cesium, bruce-models, and the parent app.
|