bruce-cesium 4.4.4 → 4.4.7
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/dist/bruce-cesium.es5.js +4510 -3712
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +4485 -3699
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +5 -1
- package/dist/lib/bruce-cesium.js.map +1 -1
- package/dist/lib/internal/cesium-utils.js +92 -5
- package/dist/lib/internal/cesium-utils.js.map +1 -1
- package/dist/lib/rendering/cesium-animated-property.js +149 -0
- package/dist/lib/rendering/cesium-animated-property.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-model3d.js +809 -0
- package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-point.js +995 -0
- package/dist/lib/rendering/entity-render-engine-point.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js +756 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polyline.js +516 -0
- package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine.js +62 -2420
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/render-managers/data-source/data-source-static-csv-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +15 -0
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js +18 -0
- package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js.map +1 -1
- package/dist/lib/utils/view-utils.js +2 -2
- package/dist/lib/utils/view-utils.js.map +1 -1
- package/dist/lib/widgets/common/draw-3d-polyline.js +0 -8
- package/dist/lib/widgets/common/draw-3d-polyline.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +5 -1
- package/dist/types/internal/cesium-utils.d.ts +22 -2
- package/dist/types/rendering/cesium-animated-property.d.ts +21 -0
- package/dist/types/rendering/entity-render-engine-model3d.d.ts +56 -0
- package/dist/types/rendering/entity-render-engine-point.d.ts +73 -0
- package/dist/types/rendering/entity-render-engine-polygon.d.ts +26 -0
- package/dist/types/rendering/entity-render-engine-polyline.d.ts +48 -0
- package/dist/types/rendering/entity-render-engine.d.ts +31 -98
- package/package.json +2 -2
|
@@ -0,0 +1,995 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.EntityRenderEnginePoint = void 0;
|
|
40
|
+
var bruce_models_1 = require("bruce-models");
|
|
41
|
+
var cesium_animated_property_1 = require("./cesium-animated-property");
|
|
42
|
+
var Cesium = require("cesium");
|
|
43
|
+
var entity_render_engine_1 = require("./entity-render-engine");
|
|
44
|
+
var entity_utils_1 = require("../utils/entity-utils");
|
|
45
|
+
var js_utils_1 = require("../internal/js-utils");
|
|
46
|
+
var cesium_utils_1 = require("../internal/cesium-utils");
|
|
47
|
+
var limited_log_1 = require("../internal/limited-log");
|
|
48
|
+
var cesium_entity_styler_1 = require("../utils/cesium-entity-styler");
|
|
49
|
+
/**
|
|
50
|
+
* Handles point rendering.
|
|
51
|
+
*/
|
|
52
|
+
var EntityRenderEnginePoint;
|
|
53
|
+
(function (EntityRenderEnginePoint) {
|
|
54
|
+
/**
|
|
55
|
+
* Creates a circle billboard (canvas) for a point.
|
|
56
|
+
* @param params
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
function CreateCircleBillboard(params) {
|
|
60
|
+
return createCircleBillboard(params.size, params.colorCss);
|
|
61
|
+
}
|
|
62
|
+
EntityRenderEnginePoint.CreateCircleBillboard = CreateCircleBillboard;
|
|
63
|
+
/**
|
|
64
|
+
* Renders a single point Entity.
|
|
65
|
+
* This takes an optional prior Cesium Entity to update rather than create from scratch.
|
|
66
|
+
* @param params
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
function Render(params) {
|
|
70
|
+
var _a, _b, _c, _d;
|
|
71
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
+
var entity, style, type, cEntity, siblings, heightRef, animatePosition, shouldShowTrack, prepareExistingGraphic, updateShouldShowTrack, iconUrlRows, icon, iconUrl, metadata, api, image, e_1, iconScale, disableDepthTest, bColor, cColor, animateColorIn_1, position, series, currentImgKey, series, pos3d, prevPos3d, radius, bFill, cFill, outline, cOutline, outlineWidth, bOutline, pos3d, extrusion, hasOutline, outlineExtrusion, outlineEntity, bColor, cColor, size, circleBillboard, disableDepthTest, animateColorIn_2, position, series, imgKey, currentImgKey, series, pos3d, prevPos3d, lStyle, bColor, cColor, width, lHeightRef, trackEntity;
|
|
73
|
+
return __generator(this, function (_e) {
|
|
74
|
+
switch (_e.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
entity = params.entity;
|
|
77
|
+
if (!params.entityHistoric) {
|
|
78
|
+
params.entityHistoric = [];
|
|
79
|
+
}
|
|
80
|
+
style = params.style;
|
|
81
|
+
type = style.Type;
|
|
82
|
+
if (type == null) {
|
|
83
|
+
// Very old backward compatibility.
|
|
84
|
+
if (style.useIcon == true) {
|
|
85
|
+
type = bruce_models_1.Style.EPointType.Icon;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
cEntity = null;
|
|
89
|
+
siblings = [];
|
|
90
|
+
heightRef = null;
|
|
91
|
+
animatePosition = null;
|
|
92
|
+
shouldShowTrack = false;
|
|
93
|
+
prepareExistingGraphic = function (cEntity, maxSiblings) {
|
|
94
|
+
if (maxSiblings === void 0) { maxSiblings = 0; }
|
|
95
|
+
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
96
|
+
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
97
|
+
entity: cEntity,
|
|
98
|
+
});
|
|
99
|
+
if (parts.length > 1) {
|
|
100
|
+
// We'll cull all except the allowed number of siblings.
|
|
101
|
+
cEntity._siblingGraphics = cEntity._siblingGraphics.slice(0, maxSiblings);
|
|
102
|
+
// We'll remove all that aren't in the allowed (direct) list.
|
|
103
|
+
for (var i = 0; i < parts.length - 1; i++) {
|
|
104
|
+
var part = parts[i];
|
|
105
|
+
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part) && !cEntity._siblingGraphics.includes(part)) {
|
|
106
|
+
params.viewer.entities.remove(part);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (cEntity._parentEntity) {
|
|
110
|
+
console.warn("Point.Render: Parent entity was not null. This should not happen.");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
siblings = cEntity._siblingGraphics;
|
|
114
|
+
cEntity._siblingGraphics = [];
|
|
115
|
+
};
|
|
116
|
+
updateShouldShowTrack = function () {
|
|
117
|
+
var _a, _b, _c;
|
|
118
|
+
if (!params.entityHistoricDrawTrack) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if ((_a = params.entityHistoric) === null || _a === void 0 ? void 0 : _a.length) {
|
|
122
|
+
var lStyle = (_c = (_b = params.fullStyle) === null || _b === void 0 ? void 0 : _b.polylineStyle) !== null && _c !== void 0 ? _c : {};
|
|
123
|
+
var width = lStyle.width ? (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(lStyle.width, entity, params.tags)) : 2;
|
|
124
|
+
if (width == null) {
|
|
125
|
+
width = 2;
|
|
126
|
+
}
|
|
127
|
+
width = (0, js_utils_1.EnsureNumber)(width);
|
|
128
|
+
if (width > 0.01) {
|
|
129
|
+
var bColor = lStyle.lineColor ? bruce_models_1.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
130
|
+
var cColor = bColor ? (0, cesium_utils_1.ColorToCColor)(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
131
|
+
if (cColor.alpha > 0) {
|
|
132
|
+
var seriesTrackPosses = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
133
|
+
seriesTrackPosses.reverse();
|
|
134
|
+
var posses = seriesTrackPosses.map(function (x) { return x.pos3d; });
|
|
135
|
+
posses = (0, cesium_utils_1.CullDuplicateCPosses)(posses);
|
|
136
|
+
shouldShowTrack = posses.length > 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
;
|
|
141
|
+
};
|
|
142
|
+
if (!(type == bruce_models_1.Style.EPointType.Icon)) return [3 /*break*/, 9];
|
|
143
|
+
iconUrlRows = style.iconUrl == null ? [] : style.iconUrl;
|
|
144
|
+
iconUrlRows.forEach(function (row) {
|
|
145
|
+
if (row.type == bruce_models_1.Calculator.EValueType.Color) {
|
|
146
|
+
row.type = bruce_models_1.Calculator.EValueType.Input;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
icon = bruce_models_1.Calculator.GetString(iconUrlRows, entity, params.tags);
|
|
150
|
+
iconUrl = null;
|
|
151
|
+
if (!(typeof icon == "string")) return [3 /*break*/, 2];
|
|
152
|
+
iconUrl = icon;
|
|
153
|
+
metadata = extractMetadataFromFileUrl(iconUrl);
|
|
154
|
+
if (!metadata) return [3 /*break*/, 2];
|
|
155
|
+
api = params.apiGetter.getApi(metadata.accountId);
|
|
156
|
+
return [4 /*yield*/, api.Loading];
|
|
157
|
+
case 1:
|
|
158
|
+
_e.sent();
|
|
159
|
+
iconUrl = bruce_models_1.ClientFile.GetUrl({
|
|
160
|
+
api: api,
|
|
161
|
+
fileId: metadata.fileId,
|
|
162
|
+
viaCdn: true
|
|
163
|
+
});
|
|
164
|
+
_e.label = 2;
|
|
165
|
+
case 2:
|
|
166
|
+
if (!(!iconUrl && style.iconId)) return [3 /*break*/, 4];
|
|
167
|
+
return [4 /*yield*/, params.api.Loading];
|
|
168
|
+
case 3:
|
|
169
|
+
_e.sent();
|
|
170
|
+
iconUrl = bruce_models_1.ClientFile.GetUrl({
|
|
171
|
+
api: params.api,
|
|
172
|
+
fileId: style.iconId,
|
|
173
|
+
viaCdn: true
|
|
174
|
+
});
|
|
175
|
+
_e.label = 4;
|
|
176
|
+
case 4:
|
|
177
|
+
image = null;
|
|
178
|
+
if (!iconUrl) return [3 /*break*/, 8];
|
|
179
|
+
_e.label = 5;
|
|
180
|
+
case 5:
|
|
181
|
+
_e.trys.push([5, 7, , 8]);
|
|
182
|
+
return [4 /*yield*/, createImageBillboard(iconUrl)];
|
|
183
|
+
case 6:
|
|
184
|
+
image = _e.sent();
|
|
185
|
+
return [3 /*break*/, 8];
|
|
186
|
+
case 7:
|
|
187
|
+
e_1 = _e.sent();
|
|
188
|
+
// Expanding the logging here so we can figure out why this is happening.
|
|
189
|
+
// Most of the time the file is missing but we're getting some strange errors so I am including logging on the API settings as well.
|
|
190
|
+
(0, limited_log_1.OneTimeError)("ENTITY_RENDER_ENGINE_ICON_URL_ERROR_" + iconUrl, {
|
|
191
|
+
error: e_1,
|
|
192
|
+
iconUrl: iconUrl,
|
|
193
|
+
apiUrl: (_a = params.api) === null || _a === void 0 ? void 0 : _a.GetBaseUrl(),
|
|
194
|
+
apiAccountId: (_b = params.api) === null || _b === void 0 ? void 0 : _b.AccountId
|
|
195
|
+
});
|
|
196
|
+
return [3 /*break*/, 8];
|
|
197
|
+
case 8:
|
|
198
|
+
if (image) {
|
|
199
|
+
iconScale = (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(style.iconScale, entity, params.tags));
|
|
200
|
+
if (!iconScale && iconScale != 0) {
|
|
201
|
+
iconScale = 1;
|
|
202
|
+
}
|
|
203
|
+
disableDepthTest = Boolean(style.renderOnTop);
|
|
204
|
+
if (iconScale > 0) {
|
|
205
|
+
updateShouldShowTrack();
|
|
206
|
+
bColor = style.iconTintColor ? bruce_models_1.Calculator.GetColor(style.iconTintColor, entity, params.tags) : null;
|
|
207
|
+
cColor = bColor ? (0, cesium_utils_1.ColorToCColor)(bColor) : Cesium.Color.WHITE.clone();
|
|
208
|
+
heightRef = getHeightRef(style);
|
|
209
|
+
if (!params.rendered || !params.rendered.billboard) {
|
|
210
|
+
animateColorIn_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateColor({
|
|
211
|
+
durationMs: 200,
|
|
212
|
+
targetColor: cColor,
|
|
213
|
+
startColor: cColor.withAlpha(0),
|
|
214
|
+
viewer: params.viewer
|
|
215
|
+
});
|
|
216
|
+
position = null;
|
|
217
|
+
series = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
218
|
+
if (series.length > 1) {
|
|
219
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
220
|
+
posses: series,
|
|
221
|
+
viewer: params.viewer
|
|
222
|
+
});
|
|
223
|
+
position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
position = new Cesium.CallbackProperty(function () { return entity_utils_1.EntityUtils.GetPos({
|
|
227
|
+
viewer: params.viewer,
|
|
228
|
+
entity: entity,
|
|
229
|
+
recordHeightRef: heightRef,
|
|
230
|
+
returnHeightRef: heightRef,
|
|
231
|
+
allowRendered: false
|
|
232
|
+
}); }, true);
|
|
233
|
+
}
|
|
234
|
+
cEntity = new Cesium.Entity({
|
|
235
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
236
|
+
billboard: {
|
|
237
|
+
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
238
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
239
|
+
image: image.canvasDataUri,
|
|
240
|
+
heightReference: getHeightRef(style),
|
|
241
|
+
scale: iconScale,
|
|
242
|
+
disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined,
|
|
243
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance),
|
|
244
|
+
color: new Cesium.CallbackProperty(function () {
|
|
245
|
+
var color = animateColorIn_1.GetColor();
|
|
246
|
+
if (animateColorIn_1.IsDone() && (cEntity === null || cEntity === void 0 ? void 0 : cEntity.billboard)) {
|
|
247
|
+
cEntity.billboard.color = new Cesium.CallbackProperty(function () { return color; }, true);
|
|
248
|
+
}
|
|
249
|
+
return color;
|
|
250
|
+
}, false),
|
|
251
|
+
// Would be great once we have a setting for this.
|
|
252
|
+
// translucencyByDistance: getTranslucencyByDistance(params.minDistance, params.maxDistance),
|
|
253
|
+
},
|
|
254
|
+
position: position,
|
|
255
|
+
show: true
|
|
256
|
+
});
|
|
257
|
+
cesium_entity_styler_1.CesiumEntityStyler.BakeDefaultColor({
|
|
258
|
+
entity: cEntity,
|
|
259
|
+
colors: {
|
|
260
|
+
"billboard": cColor
|
|
261
|
+
},
|
|
262
|
+
viewer: params.viewer,
|
|
263
|
+
refresh: false
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
prepareExistingGraphic(params.rendered, shouldShowTrack ? 1 : 0);
|
|
268
|
+
cEntity = params.rendered;
|
|
269
|
+
currentImgKey = cEntity.billboard._billboardImgKey;
|
|
270
|
+
if (currentImgKey != iconUrl) {
|
|
271
|
+
cEntity.billboard.image = new Cesium.ConstantProperty(image.canvasDataUri);
|
|
272
|
+
}
|
|
273
|
+
cEntity.billboard.scale = new Cesium.ConstantProperty(iconScale);
|
|
274
|
+
cEntity.billboard.heightReference = new Cesium.ConstantProperty(getHeightRef(style));
|
|
275
|
+
cEntity.billboard.disableDepthTestDistance = new Cesium.ConstantProperty(disableDepthTest ? Number.POSITIVE_INFINITY : undefined);
|
|
276
|
+
cEntity.billboard.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
277
|
+
series = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
278
|
+
if (series.length > 1) {
|
|
279
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
280
|
+
posses: series,
|
|
281
|
+
viewer: params.viewer
|
|
282
|
+
});
|
|
283
|
+
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
287
|
+
viewer: params.viewer,
|
|
288
|
+
entity: entity,
|
|
289
|
+
recordHeightRef: heightRef,
|
|
290
|
+
returnHeightRef: heightRef,
|
|
291
|
+
allowRendered: false
|
|
292
|
+
});
|
|
293
|
+
prevPos3d = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.position);
|
|
294
|
+
if (!prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d)) {
|
|
295
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePosition({
|
|
296
|
+
durationMs: 200,
|
|
297
|
+
targetPos3d: pos3d,
|
|
298
|
+
viewer: params.viewer,
|
|
299
|
+
startPos3d: prevPos3d
|
|
300
|
+
});
|
|
301
|
+
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
305
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
306
|
+
color: cColor ? cColor : new Cesium.Color(),
|
|
307
|
+
entity: cEntity,
|
|
308
|
+
viewer: params.viewer,
|
|
309
|
+
override: true,
|
|
310
|
+
requestRender: false
|
|
311
|
+
});
|
|
312
|
+
cEntity.show = true;
|
|
313
|
+
}
|
|
314
|
+
cEntity.billboard._billboardSize = image.height;
|
|
315
|
+
cEntity.billboard._billboardImgKey = iconUrl;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
_e.label = 9;
|
|
319
|
+
case 9:
|
|
320
|
+
if (type == bruce_models_1.Style.EPointType.Cylinder) {
|
|
321
|
+
radius = (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(style.CylinderRadius, entity, params.tags));
|
|
322
|
+
if (radius <= 0) {
|
|
323
|
+
return [2 /*return*/, null];
|
|
324
|
+
}
|
|
325
|
+
bFill = style.CylinderFillColor ? bruce_models_1.Calculator.GetColor(style.CylinderFillColor, entity, params.tags) : null;
|
|
326
|
+
cFill = bFill ? (0, cesium_utils_1.ColorToCColor)(bFill) : Cesium.Color.RED;
|
|
327
|
+
outline = Boolean(style.CylinderBorderEnabled);
|
|
328
|
+
cOutline = null;
|
|
329
|
+
outlineWidth = 1;
|
|
330
|
+
if (outline) {
|
|
331
|
+
bOutline = style.CylinderBorderColor ? bruce_models_1.Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
|
|
332
|
+
cOutline = bOutline ? (0, cesium_utils_1.ColorToCColor)(bOutline) : Cesium.Color.BLACK;
|
|
333
|
+
outlineWidth = (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
|
|
334
|
+
}
|
|
335
|
+
heightRef = getHeightRef(style);
|
|
336
|
+
pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
337
|
+
viewer: params.viewer,
|
|
338
|
+
entity: entity,
|
|
339
|
+
recordHeightRef: heightRef,
|
|
340
|
+
returnHeightRef: heightRef,
|
|
341
|
+
allowRendered: false
|
|
342
|
+
});
|
|
343
|
+
extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
|
|
344
|
+
hasOutline = outline && outlineWidth > 0;
|
|
345
|
+
if (!params.rendered || !params.rendered.ellipse) {
|
|
346
|
+
cEntity = new Cesium.Entity({
|
|
347
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
348
|
+
ellipse: {
|
|
349
|
+
semiMajorAxis: radius,
|
|
350
|
+
semiMinorAxis: radius,
|
|
351
|
+
material: cFill,
|
|
352
|
+
outlineWidth: null,
|
|
353
|
+
extrudedHeight: extrusion.value,
|
|
354
|
+
heightReference: heightRef,
|
|
355
|
+
extrudedHeightReference: extrusion.exHeightRef,
|
|
356
|
+
height: Cesium.Cartographic.fromCartesian(pos3d).height,
|
|
357
|
+
zIndex: 1,
|
|
358
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance)
|
|
359
|
+
},
|
|
360
|
+
position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone(),
|
|
361
|
+
show: true
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
prepareExistingGraphic(params.rendered, hasOutline ? 1 : 0);
|
|
366
|
+
cEntity = params.rendered;
|
|
367
|
+
cEntity.ellipse.semiMajorAxis = new Cesium.ConstantProperty(radius);
|
|
368
|
+
cEntity.ellipse.semiMinorAxis = new Cesium.ConstantProperty(radius);
|
|
369
|
+
cEntity.ellipse.outlineWidth = undefined;
|
|
370
|
+
cEntity.ellipse.extrudedHeight = new Cesium.ConstantProperty(extrusion.value);
|
|
371
|
+
cEntity.ellipse.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
372
|
+
cEntity.ellipse.extrudedHeightReference = new Cesium.ConstantProperty(extrusion.exHeightRef);
|
|
373
|
+
cEntity.ellipse.height = new Cesium.ConstantProperty(Cesium.Cartographic.fromCartesian(pos3d).height);
|
|
374
|
+
cEntity.ellipse.zIndex = new Cesium.ConstantProperty(1);
|
|
375
|
+
cEntity.ellipse.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
376
|
+
cEntity.position = new Cesium.ConstantPositionProperty(pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone());
|
|
377
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
378
|
+
// WARNING: ellipse does not support animation (yet?).
|
|
379
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
380
|
+
color: cFill,
|
|
381
|
+
entity: cEntity,
|
|
382
|
+
viewer: params.viewer,
|
|
383
|
+
override: true,
|
|
384
|
+
requestRender: false
|
|
385
|
+
});
|
|
386
|
+
cEntity.show = true;
|
|
387
|
+
}
|
|
388
|
+
if (hasOutline) {
|
|
389
|
+
outlineExtrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderBorderExtrusion);
|
|
390
|
+
// If this doesn't have its own extrusion, we must make it match the sibling.
|
|
391
|
+
// This way they render in a uniform way.
|
|
392
|
+
if (!outlineExtrusion.value && extrusion.value) {
|
|
393
|
+
outlineExtrusion.exHeightRef = extrusion.exHeightRef;
|
|
394
|
+
}
|
|
395
|
+
outlineEntity = siblings === null || siblings === void 0 ? void 0 : siblings[0];
|
|
396
|
+
if (outlineEntity && outlineEntity.ellipse) {
|
|
397
|
+
outlineEntity.ellipse.semiMajorAxis = new Cesium.ConstantProperty(radius + outlineWidth);
|
|
398
|
+
outlineEntity.ellipse.semiMinorAxis = new Cesium.ConstantProperty(radius + outlineWidth);
|
|
399
|
+
outlineEntity.ellipse.extrudedHeight = new Cesium.ConstantProperty(outlineExtrusion.value);
|
|
400
|
+
outlineEntity.ellipse.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
401
|
+
outlineEntity.ellipse.extrudedHeightReference = new Cesium.ConstantProperty(outlineExtrusion.exHeightRef);
|
|
402
|
+
outlineEntity.ellipse.height = new Cesium.ConstantProperty(Cesium.Cartographic.fromCartesian(pos3d).height);
|
|
403
|
+
outlineEntity.ellipse.zIndex = new Cesium.ConstantProperty(2);
|
|
404
|
+
outlineEntity.ellipse.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
405
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
406
|
+
// WARNING: ellipse does not support animation (yet?).
|
|
407
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
408
|
+
color: cOutline,
|
|
409
|
+
entity: outlineEntity,
|
|
410
|
+
viewer: params.viewer,
|
|
411
|
+
override: true,
|
|
412
|
+
requestRender: false
|
|
413
|
+
});
|
|
414
|
+
outlineEntity.show = true;
|
|
415
|
+
}
|
|
416
|
+
else {
|
|
417
|
+
outlineEntity = new Cesium.Entity({
|
|
418
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
419
|
+
ellipse: {
|
|
420
|
+
semiMajorAxis: radius + outlineWidth,
|
|
421
|
+
semiMinorAxis: radius + outlineWidth,
|
|
422
|
+
material: cOutline,
|
|
423
|
+
outlineWidth: undefined,
|
|
424
|
+
extrudedHeight: outlineExtrusion.value,
|
|
425
|
+
heightReference: heightRef,
|
|
426
|
+
extrudedHeightReference: outlineExtrusion.exHeightRef,
|
|
427
|
+
height: Cesium.Cartographic.fromCartesian(pos3d).height,
|
|
428
|
+
zIndex: 2,
|
|
429
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance)
|
|
430
|
+
},
|
|
431
|
+
position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone()
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
siblings.push(outlineEntity);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
if (!cEntity) {
|
|
438
|
+
bColor = style.color ? bruce_models_1.Calculator.GetColor(style.color, entity, params.tags) : null;
|
|
439
|
+
cColor = bColor ? (0, cesium_utils_1.ColorToCColor)(bColor) : Cesium.Color.fromCssColorString("rgba(33, 150, 243, 0.8)");
|
|
440
|
+
size = style.size ? bruce_models_1.Calculator.GetNumber(style.size, entity, params.tags) : null;
|
|
441
|
+
if (size == null) {
|
|
442
|
+
size = 20;
|
|
443
|
+
}
|
|
444
|
+
size = (0, js_utils_1.EnsureNumber)(size);
|
|
445
|
+
if (size <= 0) {
|
|
446
|
+
return [2 /*return*/, null];
|
|
447
|
+
}
|
|
448
|
+
heightRef = getHeightRef(style);
|
|
449
|
+
circleBillboard = createCircleBillboard(size, cColor.toCssColorString());
|
|
450
|
+
disableDepthTest = Boolean(style.renderOnTop);
|
|
451
|
+
updateShouldShowTrack();
|
|
452
|
+
if (!params.rendered || !params.rendered.billboard) {
|
|
453
|
+
animateColorIn_2 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateColor({
|
|
454
|
+
durationMs: 200,
|
|
455
|
+
targetColor: cColor,
|
|
456
|
+
startColor: cColor.withAlpha(0),
|
|
457
|
+
viewer: params.viewer
|
|
458
|
+
});
|
|
459
|
+
position = null;
|
|
460
|
+
series = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
461
|
+
if (series.length > 1) {
|
|
462
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
463
|
+
posses: series,
|
|
464
|
+
viewer: params.viewer
|
|
465
|
+
});
|
|
466
|
+
position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
position = new Cesium.CallbackProperty(function () { return entity_utils_1.EntityUtils.GetPos({
|
|
470
|
+
viewer: params.viewer,
|
|
471
|
+
entity: entity,
|
|
472
|
+
recordHeightRef: heightRef,
|
|
473
|
+
returnHeightRef: heightRef,
|
|
474
|
+
allowRendered: false
|
|
475
|
+
}); }, true);
|
|
476
|
+
}
|
|
477
|
+
cEntity = new Cesium.Entity({
|
|
478
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
479
|
+
// point: {
|
|
480
|
+
// pixelSize: size,
|
|
481
|
+
// color: cColor,
|
|
482
|
+
// heightReference: getHeightRef(style),
|
|
483
|
+
// distanceDisplayCondition: EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance)
|
|
484
|
+
// },
|
|
485
|
+
// We are generating a billboard instead of using the point.
|
|
486
|
+
// This is because points were behaving strangely where they would appear oblong shapes.
|
|
487
|
+
// This occurred consistently when rendering many icons and points at the same time.
|
|
488
|
+
billboard: {
|
|
489
|
+
height: circleBillboard.height,
|
|
490
|
+
width: circleBillboard.width,
|
|
491
|
+
image: circleBillboard.canvasDataUri,
|
|
492
|
+
color: new Cesium.CallbackProperty(function () {
|
|
493
|
+
var color = animateColorIn_2.GetColor();
|
|
494
|
+
if (animateColorIn_2.IsDone() && (cEntity === null || cEntity === void 0 ? void 0 : cEntity.billboard)) {
|
|
495
|
+
cEntity.billboard.color = new Cesium.CallbackProperty(function () { return color; }, true);
|
|
496
|
+
}
|
|
497
|
+
return color;
|
|
498
|
+
}, false),
|
|
499
|
+
heightReference: heightRef,
|
|
500
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance),
|
|
501
|
+
disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined
|
|
502
|
+
},
|
|
503
|
+
position: position,
|
|
504
|
+
show: true
|
|
505
|
+
});
|
|
506
|
+
cesium_entity_styler_1.CesiumEntityStyler.BakeDefaultColor({
|
|
507
|
+
entity: cEntity,
|
|
508
|
+
viewer: params.viewer,
|
|
509
|
+
colors: {
|
|
510
|
+
"billboard": cColor
|
|
511
|
+
},
|
|
512
|
+
refresh: false
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
else {
|
|
516
|
+
prepareExistingGraphic(params.rendered, shouldShowTrack ? 1 : 0);
|
|
517
|
+
cEntity = params.rendered;
|
|
518
|
+
imgKey = "".concat(size, "-").concat(cColor.toCssColorString());
|
|
519
|
+
currentImgKey = cEntity.billboard._billboardImgKey;
|
|
520
|
+
if (currentImgKey != imgKey) {
|
|
521
|
+
cEntity.billboard.image = new Cesium.ConstantProperty(circleBillboard.canvasDataUri);
|
|
522
|
+
}
|
|
523
|
+
cEntity.billboard.height = new Cesium.ConstantProperty(circleBillboard.height);
|
|
524
|
+
cEntity.billboard.width = new Cesium.ConstantProperty(circleBillboard.width);
|
|
525
|
+
cEntity.billboard.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
526
|
+
cEntity.billboard.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
527
|
+
cEntity.billboard.disableDepthTestDistance = new Cesium.ConstantProperty(disableDepthTest ? Number.POSITIVE_INFINITY : undefined);
|
|
528
|
+
series = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
529
|
+
if (series.length > 1) {
|
|
530
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
531
|
+
posses: series,
|
|
532
|
+
viewer: params.viewer
|
|
533
|
+
});
|
|
534
|
+
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
535
|
+
}
|
|
536
|
+
else {
|
|
537
|
+
pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
538
|
+
viewer: params.viewer,
|
|
539
|
+
entity: entity,
|
|
540
|
+
recordHeightRef: heightRef,
|
|
541
|
+
returnHeightRef: heightRef,
|
|
542
|
+
allowRendered: false
|
|
543
|
+
});
|
|
544
|
+
prevPos3d = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.position);
|
|
545
|
+
if (!prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d)) {
|
|
546
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePosition({
|
|
547
|
+
durationMs: 200,
|
|
548
|
+
targetPos3d: pos3d,
|
|
549
|
+
viewer: params.viewer,
|
|
550
|
+
startPos3d: prevPos3d
|
|
551
|
+
});
|
|
552
|
+
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
556
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
557
|
+
color: cColor,
|
|
558
|
+
entity: cEntity,
|
|
559
|
+
viewer: params.viewer,
|
|
560
|
+
override: true,
|
|
561
|
+
requestRender: false
|
|
562
|
+
});
|
|
563
|
+
cEntity.show = true;
|
|
564
|
+
cEntity.billboard._billboardImgKey = imgKey;
|
|
565
|
+
}
|
|
566
|
+
cEntity.billboard._billboardSize = Math.ceil(circleBillboard.height / 2);
|
|
567
|
+
}
|
|
568
|
+
// Generate a polyline 'track' for the historic data.
|
|
569
|
+
// We do this for historic data that exists and is moving.
|
|
570
|
+
if (shouldShowTrack && animatePosition && animatePosition instanceof cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetSeries) {
|
|
571
|
+
lStyle = (_d = (_c = params.fullStyle) === null || _c === void 0 ? void 0 : _c.polylineStyle) !== null && _d !== void 0 ? _d : {};
|
|
572
|
+
bColor = lStyle.lineColor ? bruce_models_1.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
573
|
+
cColor = bColor ? (0, cesium_utils_1.ColorToCColor)(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
574
|
+
width = lStyle.lineWidth ? (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(lStyle.lineWidth, entity, params.tags)) : 2;
|
|
575
|
+
if (width == null) {
|
|
576
|
+
width = 2;
|
|
577
|
+
}
|
|
578
|
+
width = (0, js_utils_1.EnsureNumber)(width);
|
|
579
|
+
lHeightRef = getHeightRef(lStyle, heightRef);
|
|
580
|
+
trackEntity = siblings === null || siblings === void 0 ? void 0 : siblings[0];
|
|
581
|
+
if (!trackEntity || !trackEntity.polyline) {
|
|
582
|
+
trackEntity = new Cesium.Entity({
|
|
583
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
584
|
+
polyline: {
|
|
585
|
+
positions: [],
|
|
586
|
+
width: width,
|
|
587
|
+
material: cColor,
|
|
588
|
+
clampToGround: lHeightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
589
|
+
zIndex: 0,
|
|
590
|
+
classificationType: Cesium.ClassificationType.BOTH,
|
|
591
|
+
show: true
|
|
592
|
+
},
|
|
593
|
+
position: (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.position),
|
|
594
|
+
});
|
|
595
|
+
// Visual was updated in a way that needs a full refresh.
|
|
596
|
+
if (params.rego) {
|
|
597
|
+
params.rego.stale = true;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
trackEntity._parentEntity = null;
|
|
601
|
+
trackEntity._noEdit = true;
|
|
602
|
+
trackEntity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
603
|
+
return animatePosition.GetSeries();
|
|
604
|
+
}, false);
|
|
605
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
606
|
+
// WARNING: polyline does not support animation (yet?).
|
|
607
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
608
|
+
color: cColor,
|
|
609
|
+
entity: trackEntity,
|
|
610
|
+
viewer: params.viewer,
|
|
611
|
+
override: true,
|
|
612
|
+
requestRender: false
|
|
613
|
+
});
|
|
614
|
+
siblings.push(trackEntity);
|
|
615
|
+
trackEntity._parentEntity = cEntity;
|
|
616
|
+
}
|
|
617
|
+
cEntity._siblingGraphics = siblings;
|
|
618
|
+
return [2 /*return*/, cEntity];
|
|
619
|
+
}
|
|
620
|
+
});
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
EntityRenderEnginePoint.Render = Render;
|
|
624
|
+
/**
|
|
625
|
+
* Renders a group of point Entities.
|
|
626
|
+
* This will take an optional set of prior rendered Cesium Entities to update rather than create from scratch.
|
|
627
|
+
* @param params
|
|
628
|
+
* @returns
|
|
629
|
+
*/
|
|
630
|
+
function RenderGroup(params) {
|
|
631
|
+
var _a, _b, _c, _d, _e;
|
|
632
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
633
|
+
var api, cEntities, i, entity, zoomItem, style, _f, tagIds, tags, pStyle, rego, cEntity, name_1;
|
|
634
|
+
return __generator(this, function (_g) {
|
|
635
|
+
switch (_g.label) {
|
|
636
|
+
case 0:
|
|
637
|
+
api = params.apiGetter.getApi();
|
|
638
|
+
cEntities = new Map();
|
|
639
|
+
i = 0;
|
|
640
|
+
_g.label = 1;
|
|
641
|
+
case 1:
|
|
642
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 11];
|
|
643
|
+
entity = params.entities[i];
|
|
644
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
645
|
+
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 3];
|
|
646
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
647
|
+
case 2:
|
|
648
|
+
_f = (_a = (_g.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
649
|
+
return [3 /*break*/, 4];
|
|
650
|
+
case 3:
|
|
651
|
+
_f = zoomItem.Style;
|
|
652
|
+
_g.label = 4;
|
|
653
|
+
case 4:
|
|
654
|
+
style = _f;
|
|
655
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
656
|
+
tags = [];
|
|
657
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 6];
|
|
658
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
659
|
+
api: api,
|
|
660
|
+
tagIds: tagIds
|
|
661
|
+
})];
|
|
662
|
+
case 5:
|
|
663
|
+
tags = (_g.sent()).tags;
|
|
664
|
+
_g.label = 6;
|
|
665
|
+
case 6:
|
|
666
|
+
pStyle = (_b = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _b !== void 0 ? _b : {};
|
|
667
|
+
rego = null;
|
|
668
|
+
// Only used for historic tracks right now.
|
|
669
|
+
// So won't bother getting it if we don't have historic data.
|
|
670
|
+
if ((_c = params.entitiesHistoric) === null || _c === void 0 ? void 0 : _c[entity.Bruce.ID]) {
|
|
671
|
+
rego = params.visualRegister.GetRego({
|
|
672
|
+
entityId: entity.Bruce.ID,
|
|
673
|
+
menuItemId: params.menuItemId
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
return [4 /*yield*/, Render({
|
|
677
|
+
entity: entity,
|
|
678
|
+
style: pStyle,
|
|
679
|
+
tags: tags,
|
|
680
|
+
viewer: params.viewer,
|
|
681
|
+
api: api,
|
|
682
|
+
apiGetter: params.apiGetter,
|
|
683
|
+
maxDistance: zoomItem.MaxZoom,
|
|
684
|
+
minDistance: zoomItem.MinZoom,
|
|
685
|
+
rendered: (_d = params.rendered) === null || _d === void 0 ? void 0 : _d.get(entity.Bruce.ID),
|
|
686
|
+
entityHistoric: (_e = params.entitiesHistoric) === null || _e === void 0 ? void 0 : _e[entity.Bruce.ID],
|
|
687
|
+
entityHistoricDrawTrack: params.entityHistoricDrawTrack,
|
|
688
|
+
fullStyle: style,
|
|
689
|
+
rego: rego
|
|
690
|
+
})];
|
|
691
|
+
case 7:
|
|
692
|
+
cEntity = _g.sent();
|
|
693
|
+
if (!cEntity) return [3 /*break*/, 9];
|
|
694
|
+
return [4 /*yield*/, getName(api, entity)];
|
|
695
|
+
case 8:
|
|
696
|
+
name_1 = _g.sent();
|
|
697
|
+
cEntity.name = name_1;
|
|
698
|
+
cEntity._renderGroup = entity_render_engine_1.EntityRenderEngine.GetRenderGroupId(zoomItem);
|
|
699
|
+
_g.label = 9;
|
|
700
|
+
case 9:
|
|
701
|
+
cEntities.set(entity.Bruce.ID, cEntity);
|
|
702
|
+
_g.label = 10;
|
|
703
|
+
case 10:
|
|
704
|
+
i++;
|
|
705
|
+
return [3 /*break*/, 1];
|
|
706
|
+
case 11: return [2 /*return*/, cEntities];
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
EntityRenderEnginePoint.RenderGroup = RenderGroup;
|
|
712
|
+
})(EntityRenderEnginePoint = exports.EntityRenderEnginePoint || (exports.EntityRenderEnginePoint = {}));
|
|
713
|
+
// Cache of billboards to avoid regenerating them for the same size and color.
|
|
714
|
+
var _billboardCache = new bruce_models_1.LRUCache(150);
|
|
715
|
+
var POINT_BILLBOARD_PADDING = 1;
|
|
716
|
+
var createCircleBillboard = function (size, colorCss) {
|
|
717
|
+
var key = size + "-" + colorCss;
|
|
718
|
+
var cacheData = _billboardCache.Get(key);
|
|
719
|
+
if ((cacheData === null || cacheData === void 0 ? void 0 : cacheData.canvasDataUri) && typeof (cacheData === null || cacheData === void 0 ? void 0 : cacheData.canvasDataUri) == "string") {
|
|
720
|
+
return cacheData;
|
|
721
|
+
}
|
|
722
|
+
// Slight padding to avoid corners clipping.
|
|
723
|
+
var canvasSize = size + (POINT_BILLBOARD_PADDING * 4);
|
|
724
|
+
var canvas = document.createElement("canvas");
|
|
725
|
+
canvas.width = canvasSize;
|
|
726
|
+
canvas.height = canvasSize;
|
|
727
|
+
var context = canvas.getContext("2d");
|
|
728
|
+
context.beginPath();
|
|
729
|
+
context.arc(canvasSize / 2, canvasSize / 2, size / 2, 0, 2 * Math.PI, false);
|
|
730
|
+
context.fillStyle = colorCss;
|
|
731
|
+
context.fill();
|
|
732
|
+
var data = {
|
|
733
|
+
canvasDataUri: canvas.toDataURL("image/png"),
|
|
734
|
+
colorCss: colorCss,
|
|
735
|
+
size: size,
|
|
736
|
+
height: canvasSize,
|
|
737
|
+
width: canvasSize
|
|
738
|
+
};
|
|
739
|
+
_billboardCache.Set(key, data);
|
|
740
|
+
return data;
|
|
741
|
+
};
|
|
742
|
+
var createImageBillboard = function (url) {
|
|
743
|
+
var cacheKey = "image-" + url;
|
|
744
|
+
var cacheData = _billboardCache.Get(cacheKey);
|
|
745
|
+
if (cacheData) {
|
|
746
|
+
return cacheData;
|
|
747
|
+
}
|
|
748
|
+
var prom = new Promise(function (res, rej) { return __awaiter(void 0, void 0, void 0, function () {
|
|
749
|
+
var response, blob, canvas_1, image_1, e_2;
|
|
750
|
+
return __generator(this, function (_a) {
|
|
751
|
+
switch (_a.label) {
|
|
752
|
+
case 0:
|
|
753
|
+
_a.trys.push([0, 3, , 4]);
|
|
754
|
+
return [4 /*yield*/, fetch(url)];
|
|
755
|
+
case 1:
|
|
756
|
+
response = _a.sent();
|
|
757
|
+
return [4 /*yield*/, response.blob()];
|
|
758
|
+
case 2:
|
|
759
|
+
blob = _a.sent();
|
|
760
|
+
canvas_1 = document.createElement("canvas");
|
|
761
|
+
image_1 = new Image();
|
|
762
|
+
image_1.onload = function () {
|
|
763
|
+
canvas_1.width = image_1.width;
|
|
764
|
+
canvas_1.height = image_1.height;
|
|
765
|
+
var context = canvas_1.getContext("2d");
|
|
766
|
+
context.drawImage(image_1, 0, 0);
|
|
767
|
+
var data = {
|
|
768
|
+
canvasDataUri: canvas_1.toDataURL("image/png"),
|
|
769
|
+
height: image_1.height
|
|
770
|
+
};
|
|
771
|
+
res(data);
|
|
772
|
+
};
|
|
773
|
+
image_1.onerror = function (e) {
|
|
774
|
+
rej(e);
|
|
775
|
+
};
|
|
776
|
+
image_1.src = URL.createObjectURL(blob);
|
|
777
|
+
return [3 /*break*/, 4];
|
|
778
|
+
case 3:
|
|
779
|
+
e_2 = _a.sent();
|
|
780
|
+
rej(e_2);
|
|
781
|
+
return [3 /*break*/, 4];
|
|
782
|
+
case 4: return [2 /*return*/];
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
}); });
|
|
786
|
+
_billboardCache.Set(cacheKey, prom);
|
|
787
|
+
return prom;
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* Turns a hard-coded file url into pieces so we can properly load it using our libraries rather than directly.
|
|
791
|
+
* @param url eg: https://demoplantprocess.api.nextspace-uat.net/file/4c29bdf8-1f0b-4739-b0ee-421ea07ba4e5.png
|
|
792
|
+
*/
|
|
793
|
+
function extractMetadataFromFileUrl(url) {
|
|
794
|
+
var _a;
|
|
795
|
+
url = url.toLowerCase();
|
|
796
|
+
// Bzzt, invalid url format for our purposes.
|
|
797
|
+
if (!url.includes(".api.") || !url.includes("/file/")) {
|
|
798
|
+
return null;
|
|
799
|
+
}
|
|
800
|
+
url = url.replace("https://", "").replace("http://", "");
|
|
801
|
+
var envId = bruce_models_1.Api.EEnv.PROD;
|
|
802
|
+
if (url.includes("-dev.net")) {
|
|
803
|
+
envId = bruce_models_1.Api.EEnv.DEV;
|
|
804
|
+
}
|
|
805
|
+
else if (url.includes("-stg.net")) {
|
|
806
|
+
envId = bruce_models_1.Api.EEnv.STG;
|
|
807
|
+
}
|
|
808
|
+
else if (url.includes("-uat.net")) {
|
|
809
|
+
envId = bruce_models_1.Api.EEnv.UAT;
|
|
810
|
+
}
|
|
811
|
+
var parts = url.split("/");
|
|
812
|
+
var host = parts[0];
|
|
813
|
+
var hostParts = host.split(".");
|
|
814
|
+
var accountId = hostParts[0];
|
|
815
|
+
var fileId = (_a = parts[2]) !== null && _a !== void 0 ? _a : "";
|
|
816
|
+
if (fileId.includes("?")) {
|
|
817
|
+
fileId = fileId.split("?")[0];
|
|
818
|
+
}
|
|
819
|
+
if (fileId.includes(".")) {
|
|
820
|
+
fileId = fileId.split(".")[0];
|
|
821
|
+
}
|
|
822
|
+
if (!fileId || !accountId) {
|
|
823
|
+
return null;
|
|
824
|
+
}
|
|
825
|
+
return {
|
|
826
|
+
accountId: accountId,
|
|
827
|
+
fileId: fileId,
|
|
828
|
+
envId: envId
|
|
829
|
+
};
|
|
830
|
+
}
|
|
831
|
+
function getHeightRef(style, defaultStyle) {
|
|
832
|
+
var _a;
|
|
833
|
+
var heightRef = defaultStyle == null ? Cesium.HeightReference.CLAMP_TO_GROUND : defaultStyle;
|
|
834
|
+
var altOptionId = (_a = style === null || style === void 0 ? void 0 : style.altitudeOption) === null || _a === void 0 ? void 0 : _a.id;
|
|
835
|
+
if (altOptionId == 0) {
|
|
836
|
+
heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
837
|
+
}
|
|
838
|
+
else if (altOptionId == 1) {
|
|
839
|
+
heightRef = Cesium.HeightReference.NONE;
|
|
840
|
+
}
|
|
841
|
+
else if (altOptionId == 2) {
|
|
842
|
+
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
843
|
+
}
|
|
844
|
+
return heightRef;
|
|
845
|
+
}
|
|
846
|
+
function getCylinderStyleExtrusion(style, entity, tags, heightRef) {
|
|
847
|
+
if (!style) {
|
|
848
|
+
return null;
|
|
849
|
+
}
|
|
850
|
+
try {
|
|
851
|
+
var extrusion = +bruce_models_1.Calculator.GetNumber(style, entity, tags);
|
|
852
|
+
if (!extrusion && extrusion != 0) {
|
|
853
|
+
return null;
|
|
854
|
+
}
|
|
855
|
+
/*
|
|
856
|
+
Cesium extrudes in strange way.
|
|
857
|
+
If you want something that is 50 meters above sea, and 5 meters tall,
|
|
858
|
+
You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
|
|
859
|
+
*/
|
|
860
|
+
var height = (0, js_utils_1.EnsureNumber)(bruce_models_1.Entity.GetValue({
|
|
861
|
+
entity: entity,
|
|
862
|
+
path: ["Bruce", "Location", "altitude"]
|
|
863
|
+
}), 0);
|
|
864
|
+
return heightRef != Cesium.HeightReference.CLAMP_TO_GROUND ? extrusion + height : extrusion;
|
|
865
|
+
}
|
|
866
|
+
catch (e) {
|
|
867
|
+
console.error(e);
|
|
868
|
+
}
|
|
869
|
+
return 0;
|
|
870
|
+
}
|
|
871
|
+
function getCylinderExtrusion(entity, tags, heightRef, style) {
|
|
872
|
+
var data = {
|
|
873
|
+
value: undefined,
|
|
874
|
+
exHeightRef: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? Cesium.HeightReference.RELATIVE_TO_GROUND : heightRef
|
|
875
|
+
};
|
|
876
|
+
var extrusion = getCylinderStyleExtrusion(style, entity, tags, heightRef);
|
|
877
|
+
if (extrusion) {
|
|
878
|
+
data.value = extrusion;
|
|
879
|
+
}
|
|
880
|
+
if (data.value != undefined) {
|
|
881
|
+
data.value = (0, js_utils_1.EnsureNumber)(data.value);
|
|
882
|
+
}
|
|
883
|
+
return data;
|
|
884
|
+
}
|
|
885
|
+
function getName(api, entity) {
|
|
886
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
887
|
+
var typeId, type, name_2, e_3, hideError, error, code;
|
|
888
|
+
return __generator(this, function (_a) {
|
|
889
|
+
switch (_a.label) {
|
|
890
|
+
case 0:
|
|
891
|
+
_a.trys.push([0, 3, , 4]);
|
|
892
|
+
typeId = entity.Bruce["EntityType.ID"];
|
|
893
|
+
type = null;
|
|
894
|
+
if (!typeId) return [3 /*break*/, 2];
|
|
895
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
896
|
+
api: api,
|
|
897
|
+
entityTypeId: typeId
|
|
898
|
+
})];
|
|
899
|
+
case 1:
|
|
900
|
+
type = (_a.sent()).entityType;
|
|
901
|
+
_a.label = 2;
|
|
902
|
+
case 2:
|
|
903
|
+
if (type) {
|
|
904
|
+
name_2 = bruce_models_1.Entity.CalculateName({
|
|
905
|
+
entity: entity,
|
|
906
|
+
type: type,
|
|
907
|
+
defaultToId: false
|
|
908
|
+
});
|
|
909
|
+
return [2 /*return*/, name_2 ? name_2 : "Unnamed Entity"];
|
|
910
|
+
}
|
|
911
|
+
return [3 /*break*/, 4];
|
|
912
|
+
case 3:
|
|
913
|
+
e_3 = _a.sent();
|
|
914
|
+
hideError = false;
|
|
915
|
+
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
916
|
+
if (e_3 && typeof e_3 == "object" && e_3.ERROR) {
|
|
917
|
+
error = e_3.ERROR;
|
|
918
|
+
code = error && typeof error == "object" ? error.Code : "";
|
|
919
|
+
// Avoiding logging a common error.
|
|
920
|
+
// This happens when rendering entities that don't have records.
|
|
921
|
+
hideError = String(code).toLowerCase() == "notfound";
|
|
922
|
+
}
|
|
923
|
+
if (!hideError) {
|
|
924
|
+
console.error(e_3);
|
|
925
|
+
}
|
|
926
|
+
return [3 /*break*/, 4];
|
|
927
|
+
case 4: return [2 /*return*/, "Unknown entity"];
|
|
928
|
+
}
|
|
929
|
+
});
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
function getStyle(api, entity, styleId) {
|
|
933
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
934
|
+
var style, e_4, typeId, type, e_5, hideError, error, code;
|
|
935
|
+
return __generator(this, function (_a) {
|
|
936
|
+
switch (_a.label) {
|
|
937
|
+
case 0:
|
|
938
|
+
style = null;
|
|
939
|
+
if (!styleId) return [3 /*break*/, 4];
|
|
940
|
+
_a.label = 1;
|
|
941
|
+
case 1:
|
|
942
|
+
_a.trys.push([1, 3, , 4]);
|
|
943
|
+
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
944
|
+
api: api,
|
|
945
|
+
styleId: styleId
|
|
946
|
+
})];
|
|
947
|
+
case 2:
|
|
948
|
+
style = (_a.sent()).style;
|
|
949
|
+
return [3 /*break*/, 4];
|
|
950
|
+
case 3:
|
|
951
|
+
e_4 = _a.sent();
|
|
952
|
+
console.error(e_4);
|
|
953
|
+
return [3 /*break*/, 4];
|
|
954
|
+
case 4:
|
|
955
|
+
if (!!style) return [3 /*break*/, 9];
|
|
956
|
+
typeId = entity.Bruce["EntityType.ID"];
|
|
957
|
+
if (!typeId) return [3 /*break*/, 9];
|
|
958
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
959
|
+
api: api,
|
|
960
|
+
entityTypeId: typeId
|
|
961
|
+
})];
|
|
962
|
+
case 5:
|
|
963
|
+
type = (_a.sent()).entityType;
|
|
964
|
+
if (!type["DisplaySetting.ID"]) return [3 /*break*/, 9];
|
|
965
|
+
_a.label = 6;
|
|
966
|
+
case 6:
|
|
967
|
+
_a.trys.push([6, 8, , 9]);
|
|
968
|
+
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
969
|
+
api: api,
|
|
970
|
+
styleId: type["DisplaySetting.ID"]
|
|
971
|
+
})];
|
|
972
|
+
case 7:
|
|
973
|
+
style = (_a.sent()).style;
|
|
974
|
+
return [3 /*break*/, 9];
|
|
975
|
+
case 8:
|
|
976
|
+
e_5 = _a.sent();
|
|
977
|
+
hideError = false;
|
|
978
|
+
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
979
|
+
if (e_5 && typeof e_5 == "object" && e_5.ERROR) {
|
|
980
|
+
error = e_5.ERROR;
|
|
981
|
+
code = error && typeof error == "object" ? error.Code : "";
|
|
982
|
+
// Avoiding logging a common error.
|
|
983
|
+
// This happens when rendering entities that don't have records.
|
|
984
|
+
hideError = String(code).toLowerCase() == "notfound";
|
|
985
|
+
}
|
|
986
|
+
if (!hideError) {
|
|
987
|
+
console.error(e_5);
|
|
988
|
+
}
|
|
989
|
+
return [3 /*break*/, 9];
|
|
990
|
+
case 9: return [2 /*return*/, style];
|
|
991
|
+
}
|
|
992
|
+
});
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
//# sourceMappingURL=entity-render-engine-point.js.map
|