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
|
@@ -50,708 +50,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.EntityRenderEngine = void 0;
|
|
51
51
|
var Cesium = require("cesium");
|
|
52
52
|
var bruce_models_1 = require("bruce-models");
|
|
53
|
-
var entity_utils_1 = require("../utils/entity-utils");
|
|
54
53
|
var render_manager_1 = require("./render-managers/render-manager");
|
|
55
|
-
var js_utils_1 = require("../internal/js-utils");
|
|
56
|
-
var visual_register_culler_1 = require("./visual-register-culler");
|
|
57
|
-
var limited_log_1 = require("../internal/limited-log");
|
|
58
|
-
var cesium_entity_styler_1 = require("../utils/cesium-entity-styler");
|
|
59
|
-
var cesium_animated_property_1 = require("./cesium-animated-property");
|
|
60
54
|
var simplify_geometry_1 = require("../utils/simplify-geometry");
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var extrusion = +bruce_models_1.Calculator.GetNumber(attrPath, entity, tags);
|
|
71
|
-
if (!extrusion && extrusion != 0) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
/*
|
|
75
|
-
Cesium extrudes in strange way.
|
|
76
|
-
If you want something that is 50 meters above sea, and 5 meters tall,
|
|
77
|
-
You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
|
|
78
|
-
*/
|
|
79
|
-
var height = bruce_models_1.Entity.GetValue({
|
|
80
|
-
entity: entity,
|
|
81
|
-
path: ["Bruce", "Location", "altitude"]
|
|
82
|
-
});
|
|
83
|
-
return heightRef != Cesium.HeightReference.CLAMP_TO_GROUND ? extrusion + height : extrusion;
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
console.error(e);
|
|
87
|
-
}
|
|
88
|
-
return 0;
|
|
89
|
-
}
|
|
90
|
-
function getPolygonExtrusion(entity, tags, ring, posses, heightRef, pStyle) {
|
|
91
|
-
var data = {
|
|
92
|
-
value: undefined,
|
|
93
|
-
exHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
94
|
-
posses: null
|
|
95
|
-
};
|
|
96
|
-
// Step 1. Try get using style.
|
|
97
|
-
var extrusion = getPolygonStyleExtrusion(pStyle, entity, tags, heightRef);
|
|
98
|
-
if (extrusion) {
|
|
99
|
-
if (heightRef == Cesium.HeightReference.NONE) {
|
|
100
|
-
// Let's normalize all point heights to be the same (at entity altitude).
|
|
101
|
-
// This let's us have a consistent extrusion height, and be adjustable easier by user.
|
|
102
|
-
var alt_1 = bruce_models_1.Entity.GetValue({
|
|
103
|
-
entity: entity,
|
|
104
|
-
path: ["Bruce", "Location", "altitude"]
|
|
105
|
-
});
|
|
106
|
-
if (!alt_1) {
|
|
107
|
-
alt_1 = 0;
|
|
108
|
-
}
|
|
109
|
-
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
110
|
-
points.forEach(function (point) {
|
|
111
|
-
point.height = alt_1;
|
|
112
|
-
});
|
|
113
|
-
posses = points.map(function (x) { return Cesium.Cartesian3.fromRadians((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.height)); });
|
|
114
|
-
}
|
|
115
|
-
data.value = extrusion;
|
|
116
|
-
}
|
|
117
|
-
// Step 2. Try get using geometry data.
|
|
118
|
-
else {
|
|
119
|
-
data.exHeightRef = undefined;
|
|
120
|
-
if (ring.Height && ring.Height > 0) {
|
|
121
|
-
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
122
|
-
if (points.length <= 0) {
|
|
123
|
-
data.value = ring.Height;
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
var highest = null;
|
|
127
|
-
for (var i = 0; i < points.length; i++) {
|
|
128
|
-
var pointHeight = points[i].height;
|
|
129
|
-
if (pointHeight > highest || highest === null) {
|
|
130
|
-
highest = pointHeight;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
highest = (highest === null ? 0 : highest) + ring.Height;
|
|
134
|
-
data.value = highest;
|
|
135
|
-
}
|
|
136
|
-
data.exHeightRef = Cesium.HeightReference.NONE;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
data.posses = posses;
|
|
140
|
-
if (data.value != undefined) {
|
|
141
|
-
data.value = (0, js_utils_1.EnsureNumber)(data.value);
|
|
142
|
-
}
|
|
143
|
-
return data;
|
|
144
|
-
}
|
|
145
|
-
function getCylinderStyleExtrusion(style, entity, tags, heightRef) {
|
|
146
|
-
if (!style) {
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
try {
|
|
150
|
-
var extrusion = +bruce_models_1.Calculator.GetNumber(style, entity, tags);
|
|
151
|
-
if (!extrusion && extrusion != 0) {
|
|
152
|
-
return null;
|
|
153
|
-
}
|
|
154
|
-
/*
|
|
155
|
-
Cesium extrudes in strange way.
|
|
156
|
-
If you want something that is 50 meters above sea, and 5 meters tall,
|
|
157
|
-
You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
|
|
158
|
-
*/
|
|
159
|
-
var height = (0, js_utils_1.EnsureNumber)(bruce_models_1.Entity.GetValue({
|
|
160
|
-
entity: entity,
|
|
161
|
-
path: ["Bruce", "Location", "altitude"]
|
|
162
|
-
}), 0);
|
|
163
|
-
return heightRef != Cesium.HeightReference.CLAMP_TO_GROUND ? extrusion + height : extrusion;
|
|
164
|
-
}
|
|
165
|
-
catch (e) {
|
|
166
|
-
console.error(e);
|
|
167
|
-
}
|
|
168
|
-
return 0;
|
|
169
|
-
}
|
|
170
|
-
function getCylinderExtrusion(entity, tags, heightRef, style) {
|
|
171
|
-
var data = {
|
|
172
|
-
value: undefined,
|
|
173
|
-
exHeightRef: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? Cesium.HeightReference.RELATIVE_TO_GROUND : heightRef
|
|
174
|
-
};
|
|
175
|
-
var extrusion = getCylinderStyleExtrusion(style, entity, tags, heightRef);
|
|
176
|
-
if (extrusion) {
|
|
177
|
-
data.value = extrusion;
|
|
178
|
-
}
|
|
179
|
-
if (data.value != undefined) {
|
|
180
|
-
data.value = (0, js_utils_1.EnsureNumber)(data.value);
|
|
181
|
-
}
|
|
182
|
-
return data;
|
|
183
|
-
}
|
|
184
|
-
function getHeightRef(style, defaultStyle) {
|
|
185
|
-
var _a;
|
|
186
|
-
var heightRef = defaultStyle == null ? Cesium.HeightReference.CLAMP_TO_GROUND : defaultStyle;
|
|
187
|
-
var altOptionId = (_a = style === null || style === void 0 ? void 0 : style.altitudeOption) === null || _a === void 0 ? void 0 : _a.id;
|
|
188
|
-
if (altOptionId == 0) {
|
|
189
|
-
heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
190
|
-
}
|
|
191
|
-
else if (altOptionId == 1) {
|
|
192
|
-
heightRef = Cesium.HeightReference.NONE;
|
|
193
|
-
}
|
|
194
|
-
else if (altOptionId == 2) {
|
|
195
|
-
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
196
|
-
}
|
|
197
|
-
return heightRef;
|
|
198
|
-
}
|
|
199
|
-
function getZIndex(style, entity, tags) {
|
|
200
|
-
var zIndex = (style === null || style === void 0 ? void 0 : style.zIndex) ? +bruce_models_1.Calculator.GetNumber(style === null || style === void 0 ? void 0 : style.zIndex, entity, tags) : 0;
|
|
201
|
-
if (zIndex == null) {
|
|
202
|
-
zIndex = 0;
|
|
203
|
-
}
|
|
204
|
-
return (0, js_utils_1.EnsureNumber)(zIndex);
|
|
205
|
-
}
|
|
206
|
-
function getValue(viewer, obj) {
|
|
207
|
-
if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
|
|
208
|
-
var date = viewer.scene.lastRenderTime;
|
|
209
|
-
if (!date) {
|
|
210
|
-
date = viewer.clock.currentTime;
|
|
211
|
-
}
|
|
212
|
-
return obj.getValue(date);
|
|
213
|
-
}
|
|
214
|
-
return obj;
|
|
215
|
-
}
|
|
216
|
-
function getName(api, entity) {
|
|
217
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
-
var typeId, type, name_1, e_1, hideError, error, code;
|
|
219
|
-
return __generator(this, function (_a) {
|
|
220
|
-
switch (_a.label) {
|
|
221
|
-
case 0:
|
|
222
|
-
_a.trys.push([0, 3, , 4]);
|
|
223
|
-
typeId = entity.Bruce["EntityType.ID"];
|
|
224
|
-
type = null;
|
|
225
|
-
if (!typeId) return [3 /*break*/, 2];
|
|
226
|
-
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
227
|
-
api: api,
|
|
228
|
-
entityTypeId: typeId
|
|
229
|
-
})];
|
|
230
|
-
case 1:
|
|
231
|
-
type = (_a.sent()).entityType;
|
|
232
|
-
_a.label = 2;
|
|
233
|
-
case 2:
|
|
234
|
-
if (type) {
|
|
235
|
-
name_1 = bruce_models_1.Entity.CalculateName({
|
|
236
|
-
entity: entity,
|
|
237
|
-
type: type,
|
|
238
|
-
defaultToId: false
|
|
239
|
-
});
|
|
240
|
-
return [2 /*return*/, name_1 ? name_1 : "Unnamed Entity"];
|
|
241
|
-
}
|
|
242
|
-
return [3 /*break*/, 4];
|
|
243
|
-
case 3:
|
|
244
|
-
e_1 = _a.sent();
|
|
245
|
-
hideError = false;
|
|
246
|
-
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
247
|
-
if (e_1 && typeof e_1 == "object" && e_1.ERROR) {
|
|
248
|
-
error = e_1.ERROR;
|
|
249
|
-
code = error && typeof error == "object" ? error.Code : "";
|
|
250
|
-
// Avoiding logging a common error.
|
|
251
|
-
// This happens when rendering entities that don't have records.
|
|
252
|
-
hideError = String(code).toLowerCase() == "notfound";
|
|
253
|
-
}
|
|
254
|
-
if (!hideError) {
|
|
255
|
-
console.error(e_1);
|
|
256
|
-
}
|
|
257
|
-
return [3 /*break*/, 4];
|
|
258
|
-
case 4: return [2 /*return*/, "Unknown entity"];
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
function getStyle(api, entity, styleId) {
|
|
264
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
265
|
-
var style, e_2, typeId, type, e_3, hideError, error, code;
|
|
266
|
-
return __generator(this, function (_a) {
|
|
267
|
-
switch (_a.label) {
|
|
268
|
-
case 0:
|
|
269
|
-
style = null;
|
|
270
|
-
if (!styleId) return [3 /*break*/, 4];
|
|
271
|
-
_a.label = 1;
|
|
272
|
-
case 1:
|
|
273
|
-
_a.trys.push([1, 3, , 4]);
|
|
274
|
-
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
275
|
-
api: api,
|
|
276
|
-
styleId: styleId
|
|
277
|
-
})];
|
|
278
|
-
case 2:
|
|
279
|
-
style = (_a.sent()).style;
|
|
280
|
-
return [3 /*break*/, 4];
|
|
281
|
-
case 3:
|
|
282
|
-
e_2 = _a.sent();
|
|
283
|
-
console.error(e_2);
|
|
284
|
-
return [3 /*break*/, 4];
|
|
285
|
-
case 4:
|
|
286
|
-
if (!!style) return [3 /*break*/, 9];
|
|
287
|
-
typeId = entity.Bruce["EntityType.ID"];
|
|
288
|
-
if (!typeId) return [3 /*break*/, 9];
|
|
289
|
-
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
290
|
-
api: api,
|
|
291
|
-
entityTypeId: typeId
|
|
292
|
-
})];
|
|
293
|
-
case 5:
|
|
294
|
-
type = (_a.sent()).entityType;
|
|
295
|
-
if (!type["DisplaySetting.ID"]) return [3 /*break*/, 9];
|
|
296
|
-
_a.label = 6;
|
|
297
|
-
case 6:
|
|
298
|
-
_a.trys.push([6, 8, , 9]);
|
|
299
|
-
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
300
|
-
api: api,
|
|
301
|
-
styleId: type["DisplaySetting.ID"]
|
|
302
|
-
})];
|
|
303
|
-
case 7:
|
|
304
|
-
style = (_a.sent()).style;
|
|
305
|
-
return [3 /*break*/, 9];
|
|
306
|
-
case 8:
|
|
307
|
-
e_3 = _a.sent();
|
|
308
|
-
hideError = false;
|
|
309
|
-
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
310
|
-
if (e_3 && typeof e_3 == "object" && e_3.ERROR) {
|
|
311
|
-
error = e_3.ERROR;
|
|
312
|
-
code = error && typeof error == "object" ? error.Code : "";
|
|
313
|
-
// Avoiding logging a common error.
|
|
314
|
-
// This happens when rendering entities that don't have records.
|
|
315
|
-
hideError = String(code).toLowerCase() == "notfound";
|
|
316
|
-
}
|
|
317
|
-
if (!hideError) {
|
|
318
|
-
console.error(e_3);
|
|
319
|
-
}
|
|
320
|
-
return [3 /*break*/, 9];
|
|
321
|
-
case 9: return [2 /*return*/, style];
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
function getRenderGroupId(zoomItem) {
|
|
327
|
-
if (!zoomItem) {
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
return zoomItem.MinZoom + "-" + zoomItem.MaxZoom;
|
|
331
|
-
}
|
|
332
|
-
var _fileValidationCache = {};
|
|
333
|
-
var _fileHeightCache = {};
|
|
334
|
-
// Key = url + scale.
|
|
335
|
-
var _fileRadiusCache = new bruce_models_1.LRUCache(1000);
|
|
336
|
-
/**
|
|
337
|
-
* @param min
|
|
338
|
-
* @param max
|
|
339
|
-
* @param meterSize size of "thing" in meters, eg polyline is 0.5 meters width. If size is provided we can potentially cull it earlier.
|
|
340
|
-
* @param isPolygon
|
|
341
|
-
* @returns
|
|
342
|
-
*/
|
|
343
|
-
function getDisplayCondition(min, max, meterSize, isPolygon) {
|
|
344
|
-
// Max is required.
|
|
345
|
-
if (isNaN(+max)) {
|
|
346
|
-
return undefined;
|
|
347
|
-
}
|
|
348
|
-
// Min is optional.
|
|
349
|
-
if (isNaN(+min)) {
|
|
350
|
-
min = 0;
|
|
351
|
-
}
|
|
352
|
-
// Adjusting slightly because I distrust our initial calculation vs Cesium's one.
|
|
353
|
-
max = (+max) * 1.2;
|
|
354
|
-
min = +min;
|
|
355
|
-
if (min > 0) {
|
|
356
|
-
min = (+min) * 0.8;
|
|
357
|
-
}
|
|
358
|
-
meterSize = +meterSize;
|
|
359
|
-
if (!isNaN(meterSize) && meterSize > 0) {
|
|
360
|
-
// A 1m thing at 2000m distance is barely visible, so we can cull it.
|
|
361
|
-
// So we'll multiply this magic distance by the size of the thing and determine when it'll be too small to see.
|
|
362
|
-
var METER_DISTANCE_PER_METER = isPolygon ? 100 : 2000;
|
|
363
|
-
var newMax = meterSize * METER_DISTANCE_PER_METER;
|
|
364
|
-
// Enforcing a minimum max distance in case something goes wrong we want stuff to always be visible when close.
|
|
365
|
-
var MIN_MAX = 300;
|
|
366
|
-
newMax = Math.max(newMax, MIN_MAX);
|
|
367
|
-
//console.log(`meterSize ${isPolygon ? "polygon" : "thing"} of ${meterSize}m was provided so max was changed from ${max}m to ${Math.min(newMax, max)}m`)
|
|
368
|
-
max = Math.min(newMax, max);
|
|
369
|
-
if (max < min) {
|
|
370
|
-
return undefined;
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
return new Cesium.DistanceDisplayCondition(min, max);
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* Returns an entity's "size" used for distance display condition calcs.
|
|
377
|
-
* This will return the distance in meters between the two boundary corners.
|
|
378
|
-
* @param entity
|
|
379
|
-
*/
|
|
380
|
-
function getSizeOfPolygonEntity(entity) {
|
|
381
|
-
if (!entity) {
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
var hasCalculatedBounds = false;
|
|
385
|
-
var bounds = bruce_models_1.Entity.GetValue({
|
|
386
|
-
entity: entity,
|
|
387
|
-
path: ["Bruce", "Boundaries"]
|
|
388
|
-
});
|
|
389
|
-
var calculateBounds = function () {
|
|
390
|
-
hasCalculatedBounds = true;
|
|
391
|
-
bounds = bruce_models_1.Bounds.FromEntity(entity);
|
|
392
|
-
};
|
|
393
|
-
var checkHasArea = function () {
|
|
394
|
-
return (bounds === null || bounds === void 0 ? void 0 : bounds.minLongitude) != (bounds === null || bounds === void 0 ? void 0 : bounds.maxLongitude) || (bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude) != (bounds === null || bounds === void 0 ? void 0 : bounds.maxLatitude);
|
|
395
|
-
};
|
|
396
|
-
// Create bounds if missing entirely.
|
|
397
|
-
if (!bounds) {
|
|
398
|
-
calculateBounds();
|
|
399
|
-
}
|
|
400
|
-
if (!(bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude)) {
|
|
401
|
-
return null;
|
|
402
|
-
}
|
|
403
|
-
// Check for bounds that are a single point.
|
|
404
|
-
if (!checkHasArea()) {
|
|
405
|
-
// Already tried to reconstruct, so we'll just give up.
|
|
406
|
-
if (hasCalculatedBounds) {
|
|
407
|
-
return null;
|
|
408
|
-
}
|
|
409
|
-
calculateBounds();
|
|
410
|
-
// Check after reconstruction. If still bad then give up.
|
|
411
|
-
if (!(bounds === null || bounds === void 0 ? void 0 : bounds.minLatitude) || !checkHasArea()) {
|
|
55
|
+
var entity_render_engine_point_1 = require("./entity-render-engine-point");
|
|
56
|
+
var entity_render_engine_model3d_1 = require("./entity-render-engine-model3d");
|
|
57
|
+
var entity_render_engine_polyline_1 = require("./entity-render-engine-polyline");
|
|
58
|
+
var entity_render_engine_polygon_1 = require("./entity-render-engine-polygon");
|
|
59
|
+
var cesium_utils_1 = require("../internal/cesium-utils");
|
|
60
|
+
var EntityRenderEngine;
|
|
61
|
+
(function (EntityRenderEngine) {
|
|
62
|
+
function GetRenderGroupId(zoomItem) {
|
|
63
|
+
if (!zoomItem) {
|
|
412
64
|
return null;
|
|
413
65
|
}
|
|
66
|
+
return zoomItem.MinZoom + "-" + zoomItem.MaxZoom;
|
|
414
67
|
}
|
|
415
|
-
|
|
416
|
-
var maxLat = +(bounds === null || bounds === void 0 ? void 0 : bounds.maxLatitude);
|
|
417
|
-
var minLon = +(bounds === null || bounds === void 0 ? void 0 : bounds.minLongitude);
|
|
418
|
-
var maxLon = +(bounds === null || bounds === void 0 ? void 0 : bounds.maxLongitude);
|
|
419
|
-
if (isNaN(minLat) || isNaN(maxLat) || isNaN(minLon) || isNaN(maxLon)) {
|
|
420
|
-
return null;
|
|
421
|
-
}
|
|
422
|
-
var p1 = Cesium.Cartesian3.fromDegrees(minLon, minLat);
|
|
423
|
-
var p2 = Cesium.Cartesian3.fromDegrees(maxLon, maxLat);
|
|
424
|
-
var length = Cesium.Cartesian3.distance(p1, p2);
|
|
425
|
-
if (isNaN(length) || length <= 0) {
|
|
426
|
-
return null;
|
|
427
|
-
}
|
|
428
|
-
if (hasCalculatedBounds) {
|
|
429
|
-
// Data not migrated to an internal field.
|
|
430
|
-
// We'll set the change in both places.
|
|
431
|
-
if (entity.boundaries) {
|
|
432
|
-
entity.boundaries = bounds;
|
|
433
|
-
entity.Bruce.Boundaries = bounds;
|
|
434
|
-
}
|
|
435
|
-
// Data migrated to an internal field.
|
|
436
|
-
else {
|
|
437
|
-
entity.Bruce.Boundaries = bounds;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
return length;
|
|
441
|
-
}
|
|
442
|
-
function getTranslucencyByDistance(min, max) {
|
|
443
|
-
// Max is required.
|
|
444
|
-
if (isNaN(+max)) {
|
|
445
|
-
return undefined;
|
|
446
|
-
}
|
|
447
|
-
// Min is optional.
|
|
448
|
-
if (isNaN(+min)) {
|
|
449
|
-
min = 0;
|
|
450
|
-
}
|
|
451
|
-
// Adjusting slightly because I distrust our initial calculation vs Cesium's one.
|
|
452
|
-
max = (+max) * 1.2;
|
|
453
|
-
min = +min;
|
|
454
|
-
if (min > 0) {
|
|
455
|
-
min = (+min) * 0.8;
|
|
456
|
-
}
|
|
457
|
-
return new Cesium.NearFarScalar(min, 1, max, 0);
|
|
458
|
-
}
|
|
459
|
-
var _billboardCache = new bruce_models_1.LRUCache(150);
|
|
460
|
-
var POINT_BILLBOARD_PADDING = 1;
|
|
461
|
-
var createCircleBillboard = function (size, colorCss) {
|
|
462
|
-
var key = size + "-" + colorCss;
|
|
463
|
-
var cacheData = _billboardCache.Get(key);
|
|
464
|
-
if ((cacheData === null || cacheData === void 0 ? void 0 : cacheData.canvasDataUri) && typeof (cacheData === null || cacheData === void 0 ? void 0 : cacheData.canvasDataUri) == "string") {
|
|
465
|
-
return cacheData;
|
|
466
|
-
}
|
|
467
|
-
// Slight padding to avoid corners clipping.
|
|
468
|
-
var canvasSize = size + (POINT_BILLBOARD_PADDING * 4);
|
|
469
|
-
var canvas = document.createElement("canvas");
|
|
470
|
-
canvas.width = canvasSize;
|
|
471
|
-
canvas.height = canvasSize;
|
|
472
|
-
var context = canvas.getContext("2d");
|
|
473
|
-
context.beginPath();
|
|
474
|
-
context.arc(canvasSize / 2, canvasSize / 2, size / 2, 0, 2 * Math.PI, false);
|
|
475
|
-
context.fillStyle = colorCss;
|
|
476
|
-
context.fill();
|
|
477
|
-
var data = {
|
|
478
|
-
canvasDataUri: canvas.toDataURL("image/png"),
|
|
479
|
-
colorCss: colorCss,
|
|
480
|
-
size: size,
|
|
481
|
-
height: canvasSize,
|
|
482
|
-
width: canvasSize
|
|
483
|
-
};
|
|
484
|
-
_billboardCache.Set(key, data);
|
|
485
|
-
return data;
|
|
486
|
-
};
|
|
487
|
-
var createImageBillboard = function (url) {
|
|
488
|
-
var cacheKey = "image-" + url;
|
|
489
|
-
var cacheData = _billboardCache.Get(cacheKey);
|
|
490
|
-
if (cacheData) {
|
|
491
|
-
return cacheData;
|
|
492
|
-
}
|
|
493
|
-
var prom = new Promise(function (res, rej) { return __awaiter(void 0, void 0, void 0, function () {
|
|
494
|
-
var response, blob, canvas_1, image_1, e_4;
|
|
495
|
-
return __generator(this, function (_a) {
|
|
496
|
-
switch (_a.label) {
|
|
497
|
-
case 0:
|
|
498
|
-
_a.trys.push([0, 3, , 4]);
|
|
499
|
-
return [4 /*yield*/, fetch(url)];
|
|
500
|
-
case 1:
|
|
501
|
-
response = _a.sent();
|
|
502
|
-
return [4 /*yield*/, response.blob()];
|
|
503
|
-
case 2:
|
|
504
|
-
blob = _a.sent();
|
|
505
|
-
canvas_1 = document.createElement("canvas");
|
|
506
|
-
image_1 = new Image();
|
|
507
|
-
image_1.onload = function () {
|
|
508
|
-
canvas_1.width = image_1.width;
|
|
509
|
-
canvas_1.height = image_1.height;
|
|
510
|
-
var context = canvas_1.getContext("2d");
|
|
511
|
-
context.drawImage(image_1, 0, 0);
|
|
512
|
-
var data = {
|
|
513
|
-
canvasDataUri: canvas_1.toDataURL("image/png"),
|
|
514
|
-
height: image_1.height
|
|
515
|
-
};
|
|
516
|
-
res(data);
|
|
517
|
-
};
|
|
518
|
-
image_1.onerror = function (e) {
|
|
519
|
-
rej(e);
|
|
520
|
-
};
|
|
521
|
-
image_1.src = URL.createObjectURL(blob);
|
|
522
|
-
return [3 /*break*/, 4];
|
|
523
|
-
case 3:
|
|
524
|
-
e_4 = _a.sent();
|
|
525
|
-
rej(e_4);
|
|
526
|
-
return [3 /*break*/, 4];
|
|
527
|
-
case 4: return [2 /*return*/];
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
}); });
|
|
531
|
-
_billboardCache.Set(cacheKey, prom);
|
|
532
|
-
return prom;
|
|
533
|
-
};
|
|
534
|
-
/**
|
|
535
|
-
* Removes duplicate points in a row and returns a new array.
|
|
536
|
-
* Passed array is not mutated.
|
|
537
|
-
* @param posses
|
|
538
|
-
*/
|
|
539
|
-
function cullDuplicatePoints(posses) {
|
|
540
|
-
var newPosses = [];
|
|
541
|
-
var lastPos = null;
|
|
542
|
-
for (var i = 0; i < posses.length; i++) {
|
|
543
|
-
var pos = posses[i];
|
|
544
|
-
// Avoiding 'Cesium.Cartesian3.equals' because passed data might be just a json blob in certain cases.
|
|
545
|
-
if (pos && (!lastPos || (pos.x != lastPos.x || pos.y != lastPos.y || pos.z != lastPos.z))) {
|
|
546
|
-
newPosses.push(pos);
|
|
547
|
-
lastPos = pos;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return newPosses;
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* Util to support both old and newer versions of Cesium for creating 3D model primitives.
|
|
554
|
-
* @param url
|
|
555
|
-
*/
|
|
556
|
-
function getModelEntity(url, scale) {
|
|
557
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
558
|
-
var CESIUM;
|
|
559
|
-
return __generator(this, function (_a) {
|
|
560
|
-
switch (_a.label) {
|
|
561
|
-
case 0:
|
|
562
|
-
CESIUM = Cesium;
|
|
563
|
-
if (!CESIUM.Model.hasOwnProperty("fromGltfAsync")) return [3 /*break*/, 2];
|
|
564
|
-
return [4 /*yield*/, CESIUM.Model.fromGltfAsync({
|
|
565
|
-
url: url,
|
|
566
|
-
asynchronous: true,
|
|
567
|
-
scale: scale
|
|
568
|
-
})];
|
|
569
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
570
|
-
case 2:
|
|
571
|
-
if (Cesium.Model.hasOwnProperty("fromGltf")) {
|
|
572
|
-
return [2 /*return*/, CESIUM.Model.fromGltf({
|
|
573
|
-
url: url,
|
|
574
|
-
asynchronous: true,
|
|
575
|
-
scale: scale
|
|
576
|
-
})];
|
|
577
|
-
}
|
|
578
|
-
_a.label = 3;
|
|
579
|
-
case 3: return [2 /*return*/, null];
|
|
580
|
-
}
|
|
581
|
-
});
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
/**
|
|
585
|
-
* Turns a hard-coded file url into pieces so we can properly load it using our libraries rather than directly.
|
|
586
|
-
* @param url eg: https://demoplantprocess.api.nextspace-uat.net/file/4c29bdf8-1f0b-4739-b0ee-421ea07ba4e5.png
|
|
587
|
-
*/
|
|
588
|
-
function extractMetadataFromFileUrl(url) {
|
|
589
|
-
var _a;
|
|
590
|
-
url = url.toLowerCase();
|
|
591
|
-
// Bzzt, invalid url format for our purposes.
|
|
592
|
-
if (!url.includes(".api.") || !url.includes("/file/")) {
|
|
593
|
-
return null;
|
|
594
|
-
}
|
|
595
|
-
url = url.replace("https://", "").replace("http://", "");
|
|
596
|
-
var envId = bruce_models_1.Api.EEnv.PROD;
|
|
597
|
-
if (url.includes("-dev.net")) {
|
|
598
|
-
envId = bruce_models_1.Api.EEnv.DEV;
|
|
599
|
-
}
|
|
600
|
-
else if (url.includes("-stg.net")) {
|
|
601
|
-
envId = bruce_models_1.Api.EEnv.STG;
|
|
602
|
-
}
|
|
603
|
-
else if (url.includes("-uat.net")) {
|
|
604
|
-
envId = bruce_models_1.Api.EEnv.UAT;
|
|
605
|
-
}
|
|
606
|
-
var parts = url.split("/");
|
|
607
|
-
var host = parts[0];
|
|
608
|
-
var hostParts = host.split(".");
|
|
609
|
-
var accountId = hostParts[0];
|
|
610
|
-
var fileId = (_a = parts[2]) !== null && _a !== void 0 ? _a : "";
|
|
611
|
-
if (fileId.includes("?")) {
|
|
612
|
-
fileId = fileId.split("?")[0];
|
|
613
|
-
}
|
|
614
|
-
if (fileId.includes(".")) {
|
|
615
|
-
fileId = fileId.split(".")[0];
|
|
616
|
-
}
|
|
617
|
-
if (!fileId || !accountId) {
|
|
618
|
-
return null;
|
|
619
|
-
}
|
|
620
|
-
return {
|
|
621
|
-
accountId: accountId,
|
|
622
|
-
fileId: fileId,
|
|
623
|
-
envId: envId
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
function getSeriesPossesForHistoricEntity(viewer, heightRef, historic) {
|
|
627
|
-
var series = [];
|
|
628
|
-
for (var i = 0; i < historic.length; i++) {
|
|
629
|
-
var item = historic[i];
|
|
630
|
-
var dateTime = new Date(item.dateTime);
|
|
631
|
-
if (!dateTime) {
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
var pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
635
|
-
entity: item.data,
|
|
636
|
-
viewer: viewer,
|
|
637
|
-
recordHeightRef: heightRef,
|
|
638
|
-
returnHeightRef: heightRef,
|
|
639
|
-
allowRendered: false
|
|
640
|
-
});
|
|
641
|
-
if (!pos3d || isNaN(pos3d.x) || isNaN(pos3d.y) || isNaN(pos3d.z)) {
|
|
642
|
-
continue;
|
|
643
|
-
}
|
|
644
|
-
series.push({
|
|
645
|
-
dateTime: dateTime,
|
|
646
|
-
pos3d: pos3d
|
|
647
|
-
});
|
|
648
|
-
}
|
|
649
|
-
return series;
|
|
650
|
-
}
|
|
651
|
-
/**
|
|
652
|
-
* Returns if the given positions are equal.
|
|
653
|
-
* @param a
|
|
654
|
-
* @param b
|
|
655
|
-
*/
|
|
656
|
-
function comparePositions(a, b) {
|
|
657
|
-
// Same reference.
|
|
658
|
-
if (a == b) {
|
|
659
|
-
return true;
|
|
660
|
-
}
|
|
661
|
-
// Different lengths or one is null.
|
|
662
|
-
if ((!a || !b) || (a.length != b.length)) {
|
|
663
|
-
return false;
|
|
664
|
-
}
|
|
665
|
-
for (var i = 0; i < a.length; i++) {
|
|
666
|
-
var posA = a[i];
|
|
667
|
-
var posB = b[i];
|
|
668
|
-
// Null detected.
|
|
669
|
-
if (!posA || !posB) {
|
|
670
|
-
return false;
|
|
671
|
-
}
|
|
672
|
-
// Position values don't match.
|
|
673
|
-
if (!bruce_models_1.Cartes.IsEqualCartes3(posA, posB)) {
|
|
674
|
-
return false;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
/**
|
|
680
|
-
* Returns if the given polygon hierarchies are equal.
|
|
681
|
-
* @param a
|
|
682
|
-
* @param b
|
|
683
|
-
*/
|
|
684
|
-
function comparePolygonHierarchies(a, b) {
|
|
685
|
-
// Same reference.
|
|
686
|
-
if (a == b) {
|
|
687
|
-
return true;
|
|
688
|
-
}
|
|
689
|
-
// Different lengths or one is null.
|
|
690
|
-
if ((!a || !b) || (a.positions.length != b.positions.length)) {
|
|
691
|
-
return false;
|
|
692
|
-
}
|
|
693
|
-
// Positions don't match.
|
|
694
|
-
if (!comparePositions(a.positions, b.positions)) {
|
|
695
|
-
return false;
|
|
696
|
-
}
|
|
697
|
-
var holes = a.holes;
|
|
698
|
-
var bHoles = b.holes;
|
|
699
|
-
// Number of holes don't match.
|
|
700
|
-
if (holes.length != bHoles.length) {
|
|
701
|
-
return false;
|
|
702
|
-
}
|
|
703
|
-
for (var i = 0; i < holes.length; i++) {
|
|
704
|
-
// Hole positions don't match.
|
|
705
|
-
if (!comparePositions(holes[i].positions, bHoles[i].positions)) {
|
|
706
|
-
return false;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
return true;
|
|
710
|
-
}
|
|
711
|
-
function getColor(viewer, obj) {
|
|
712
|
-
var value = null;
|
|
713
|
-
if (obj === null || obj === void 0 ? void 0 : obj.getValue) {
|
|
714
|
-
var date = viewer.scene.lastRenderTime;
|
|
715
|
-
if (!date) {
|
|
716
|
-
date = viewer.clock.currentTime;
|
|
717
|
-
}
|
|
718
|
-
value = obj.getValue(date);
|
|
719
|
-
}
|
|
720
|
-
else {
|
|
721
|
-
value = obj;
|
|
722
|
-
}
|
|
723
|
-
if (value && value instanceof Cesium.ColorMaterialProperty) {
|
|
724
|
-
value = value.color;
|
|
725
|
-
}
|
|
726
|
-
return value;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Compares two color materials.
|
|
730
|
-
* Returns if they are equal.
|
|
731
|
-
* @param viewer
|
|
732
|
-
* @param a
|
|
733
|
-
* @param b
|
|
734
|
-
* @returns
|
|
735
|
-
*/
|
|
736
|
-
function compareColorMaterials(viewer, a, b) {
|
|
737
|
-
// Same reference.
|
|
738
|
-
if (a == b) {
|
|
739
|
-
return true;
|
|
740
|
-
}
|
|
741
|
-
var colorA = getColor(viewer, a.color);
|
|
742
|
-
var colorB = getColor(viewer, b.color);
|
|
743
|
-
// One is null.
|
|
744
|
-
if (!colorA || !colorB) {
|
|
745
|
-
return false;
|
|
746
|
-
}
|
|
747
|
-
// Colors don't match.
|
|
748
|
-
if (colorA.alpha != colorB.alpha || colorA.red != colorB.red || colorA.green != colorB.green || colorA.blue != colorB.blue) {
|
|
749
|
-
return false;
|
|
750
|
-
}
|
|
751
|
-
return true;
|
|
752
|
-
}
|
|
753
|
-
var EntityRenderEngine;
|
|
754
|
-
(function (EntityRenderEngine) {
|
|
68
|
+
EntityRenderEngine.GetRenderGroupId = GetRenderGroupId;
|
|
755
69
|
function Render(params) {
|
|
756
70
|
var _a, _b, _c, _d, _e, _f;
|
|
757
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -834,7 +148,7 @@ var EntityRenderEngine;
|
|
|
834
148
|
entityId: id,
|
|
835
149
|
menuItemId: params.menuItemId
|
|
836
150
|
});
|
|
837
|
-
newRenderId =
|
|
151
|
+
newRenderId = GetRenderGroupId(zoomItem);
|
|
838
152
|
oldRenderId = (_a = existingRego === null || existingRego === void 0 ? void 0 : existingRego.visual) === null || _a === void 0 ? void 0 : _a._renderGroup;
|
|
839
153
|
if (!params.force &&
|
|
840
154
|
newRenderId == oldRenderId &&
|
|
@@ -952,12 +266,12 @@ var EntityRenderEngine;
|
|
|
952
266
|
id: bruce_models_1.ObjectUtils.UId(10)
|
|
953
267
|
});
|
|
954
268
|
rootEntity_1._siblingGraphics = [];
|
|
955
|
-
rootEntity_1._renderGroup =
|
|
269
|
+
rootEntity_1._renderGroup = GetRenderGroupId(zoomItem);
|
|
956
270
|
rootEntity_1._siblingGraphics = rootEntity_1._siblingGraphics.concat(rendered);
|
|
957
271
|
cEntities.set(entity.Bruce.ID, rootEntity_1);
|
|
958
272
|
firstEntity = rendered[0];
|
|
959
273
|
if (firstEntity) {
|
|
960
|
-
rootEntity_1.position =
|
|
274
|
+
rootEntity_1.position = (0, cesium_utils_1.GetCValue)(params.viewer, firstEntity.position);
|
|
961
275
|
}
|
|
962
276
|
rendered.forEach(function (child) {
|
|
963
277
|
child._parentEntity = rootEntity_1;
|
|
@@ -1079,1736 +393,64 @@ var EntityRenderEngine;
|
|
|
1079
393
|
EntityRenderEngine.Remove = Remove;
|
|
1080
394
|
var Point;
|
|
1081
395
|
(function (Point) {
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
Point.CreateCircleBillboard = CreateCircleBillboard;
|
|
1086
|
-
function Render(params) {
|
|
1087
|
-
var _a, _b, _c, _d;
|
|
1088
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1089
|
-
var entity, style, type, cEntity, siblings, heightRef, animatePosition, shouldShowTrack, prepareExistingGraphic, updateShouldShowTrack, iconUrlRows, icon, iconUrl, metadata, api, image, e_5, 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, animatePosition_1, pos3d, prevPos3d, animatePosition_2, lStyle, bColor, cColor, material, width, trackEntity;
|
|
1090
|
-
return __generator(this, function (_e) {
|
|
1091
|
-
switch (_e.label) {
|
|
1092
|
-
case 0:
|
|
1093
|
-
entity = params.entity;
|
|
1094
|
-
if (!params.entityHistoric) {
|
|
1095
|
-
params.entityHistoric = [];
|
|
1096
|
-
}
|
|
1097
|
-
style = params.style;
|
|
1098
|
-
type = style.Type;
|
|
1099
|
-
if (type == null) {
|
|
1100
|
-
// Very old backward compatibility.
|
|
1101
|
-
if (style.useIcon == true) {
|
|
1102
|
-
type = bruce_models_1.Style.EPointType.Icon;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
cEntity = null;
|
|
1106
|
-
siblings = [];
|
|
1107
|
-
heightRef = null;
|
|
1108
|
-
animatePosition = null;
|
|
1109
|
-
shouldShowTrack = false;
|
|
1110
|
-
prepareExistingGraphic = function (cEntity, maxSiblings) {
|
|
1111
|
-
if (maxSiblings === void 0) { maxSiblings = 0; }
|
|
1112
|
-
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
1113
|
-
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
1114
|
-
entity: cEntity,
|
|
1115
|
-
});
|
|
1116
|
-
if (parts.length > 1) {
|
|
1117
|
-
// We'll cull all except the allowed number of siblings.
|
|
1118
|
-
cEntity._siblingGraphics = cEntity._siblingGraphics.slice(0, maxSiblings);
|
|
1119
|
-
// We'll remove all that aren't in the allowed (direct) list.
|
|
1120
|
-
for (var i = 0; i < parts.length - 1; i++) {
|
|
1121
|
-
var part = parts[i];
|
|
1122
|
-
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part) && !cEntity._siblingGraphics.includes(part)) {
|
|
1123
|
-
params.viewer.entities.remove(part);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
if (cEntity._parentEntity) {
|
|
1127
|
-
console.warn("Point.Render: Parent entity was not null. This should not happen.");
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
siblings = cEntity._siblingGraphics;
|
|
1131
|
-
cEntity._siblingGraphics = [];
|
|
1132
|
-
};
|
|
1133
|
-
updateShouldShowTrack = function () {
|
|
1134
|
-
var _a, _b, _c;
|
|
1135
|
-
if (!params.entityHistoricDrawTrack) {
|
|
1136
|
-
return;
|
|
1137
|
-
}
|
|
1138
|
-
if ((_a = params.entityHistoric) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1139
|
-
var lStyle = (_c = (_b = params.fullStyle) === null || _b === void 0 ? void 0 : _b.polylineStyle) !== null && _c !== void 0 ? _c : {};
|
|
1140
|
-
var width = lStyle.width ? (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(lStyle.width, entity, params.tags)) : 2;
|
|
1141
|
-
if (width == null) {
|
|
1142
|
-
width = 2;
|
|
1143
|
-
}
|
|
1144
|
-
width = (0, js_utils_1.EnsureNumber)(width);
|
|
1145
|
-
if (width > 0.01) {
|
|
1146
|
-
var bColor = lStyle.lineColor ? bruce_models_1.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
1147
|
-
var cColor = bColor ? colorToCColor(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
1148
|
-
if (cColor.alpha > 0) {
|
|
1149
|
-
var seriesTrackPosses = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
1150
|
-
seriesTrackPosses.reverse();
|
|
1151
|
-
var posses = seriesTrackPosses.map(function (x) { return x.pos3d; });
|
|
1152
|
-
posses = cullDuplicatePoints(posses);
|
|
1153
|
-
shouldShowTrack = posses.length > 1;
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
;
|
|
1158
|
-
};
|
|
1159
|
-
if (!(type == bruce_models_1.Style.EPointType.Icon)) return [3 /*break*/, 9];
|
|
1160
|
-
iconUrlRows = style.iconUrl == null ? [] : style.iconUrl;
|
|
1161
|
-
iconUrlRows.forEach(function (row) {
|
|
1162
|
-
if (row.type == bruce_models_1.Calculator.EValueType.Color) {
|
|
1163
|
-
row.type = bruce_models_1.Calculator.EValueType.Input;
|
|
1164
|
-
}
|
|
1165
|
-
});
|
|
1166
|
-
icon = bruce_models_1.Calculator.GetString(iconUrlRows, entity, params.tags);
|
|
1167
|
-
iconUrl = null;
|
|
1168
|
-
if (!(typeof icon == "string")) return [3 /*break*/, 2];
|
|
1169
|
-
iconUrl = icon;
|
|
1170
|
-
metadata = extractMetadataFromFileUrl(iconUrl);
|
|
1171
|
-
if (!metadata) return [3 /*break*/, 2];
|
|
1172
|
-
api = params.apiGetter.getApi(metadata.accountId);
|
|
1173
|
-
return [4 /*yield*/, api.Loading];
|
|
1174
|
-
case 1:
|
|
1175
|
-
_e.sent();
|
|
1176
|
-
iconUrl = bruce_models_1.ClientFile.GetUrl({
|
|
1177
|
-
api: api,
|
|
1178
|
-
fileId: metadata.fileId,
|
|
1179
|
-
viaCdn: true
|
|
1180
|
-
});
|
|
1181
|
-
_e.label = 2;
|
|
1182
|
-
case 2:
|
|
1183
|
-
if (!(!iconUrl && style.iconId)) return [3 /*break*/, 4];
|
|
1184
|
-
return [4 /*yield*/, params.api.Loading];
|
|
1185
|
-
case 3:
|
|
1186
|
-
_e.sent();
|
|
1187
|
-
iconUrl = bruce_models_1.ClientFile.GetUrl({
|
|
1188
|
-
api: params.api,
|
|
1189
|
-
fileId: style.iconId,
|
|
1190
|
-
viaCdn: true
|
|
1191
|
-
});
|
|
1192
|
-
_e.label = 4;
|
|
1193
|
-
case 4:
|
|
1194
|
-
image = null;
|
|
1195
|
-
if (!iconUrl) return [3 /*break*/, 8];
|
|
1196
|
-
_e.label = 5;
|
|
1197
|
-
case 5:
|
|
1198
|
-
_e.trys.push([5, 7, , 8]);
|
|
1199
|
-
return [4 /*yield*/, createImageBillboard(iconUrl)];
|
|
1200
|
-
case 6:
|
|
1201
|
-
image = _e.sent();
|
|
1202
|
-
return [3 /*break*/, 8];
|
|
1203
|
-
case 7:
|
|
1204
|
-
e_5 = _e.sent();
|
|
1205
|
-
// Expanding the logging here so we can figure out why this is happening.
|
|
1206
|
-
// 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.
|
|
1207
|
-
(0, limited_log_1.OneTimeError)("ENTITY_RENDER_ENGINE_ICON_URL_ERROR_" + iconUrl, {
|
|
1208
|
-
error: e_5,
|
|
1209
|
-
iconUrl: iconUrl,
|
|
1210
|
-
apiUrl: (_a = params.api) === null || _a === void 0 ? void 0 : _a.GetBaseUrl(),
|
|
1211
|
-
apiAccountId: (_b = params.api) === null || _b === void 0 ? void 0 : _b.AccountId
|
|
1212
|
-
});
|
|
1213
|
-
return [3 /*break*/, 8];
|
|
1214
|
-
case 8:
|
|
1215
|
-
if (image) {
|
|
1216
|
-
iconScale = (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(style.iconScale, entity, params.tags));
|
|
1217
|
-
if (!iconScale && iconScale != 0) {
|
|
1218
|
-
iconScale = 1;
|
|
1219
|
-
}
|
|
1220
|
-
disableDepthTest = Boolean(style.renderOnTop);
|
|
1221
|
-
if (iconScale > 0) {
|
|
1222
|
-
updateShouldShowTrack();
|
|
1223
|
-
bColor = style.iconTintColor ? bruce_models_1.Calculator.GetColor(style.iconTintColor, entity, params.tags) : null;
|
|
1224
|
-
cColor = bColor ? colorToCColor(bColor) : Cesium.Color.WHITE.clone();
|
|
1225
|
-
heightRef = getHeightRef(style);
|
|
1226
|
-
if (!params.rendered || !params.rendered.billboard) {
|
|
1227
|
-
animateColorIn_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateColor({
|
|
1228
|
-
durationMs: 200,
|
|
1229
|
-
targetColor: cColor,
|
|
1230
|
-
startColor: cColor.withAlpha(0),
|
|
1231
|
-
viewer: params.viewer
|
|
1232
|
-
});
|
|
1233
|
-
position = null;
|
|
1234
|
-
series = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
1235
|
-
if (series.length > 1) {
|
|
1236
|
-
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
1237
|
-
posses: series,
|
|
1238
|
-
viewer: params.viewer
|
|
1239
|
-
});
|
|
1240
|
-
position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
1241
|
-
}
|
|
1242
|
-
else {
|
|
1243
|
-
position = new Cesium.CallbackProperty(function () { return entity_utils_1.EntityUtils.GetPos({
|
|
1244
|
-
viewer: params.viewer,
|
|
1245
|
-
entity: entity,
|
|
1246
|
-
recordHeightRef: heightRef,
|
|
1247
|
-
returnHeightRef: heightRef,
|
|
1248
|
-
allowRendered: false
|
|
1249
|
-
}); }, true);
|
|
1250
|
-
}
|
|
1251
|
-
cEntity = new Cesium.Entity({
|
|
1252
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
1253
|
-
billboard: {
|
|
1254
|
-
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
1255
|
-
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
1256
|
-
image: image.canvasDataUri,
|
|
1257
|
-
heightReference: getHeightRef(style),
|
|
1258
|
-
scale: iconScale,
|
|
1259
|
-
disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined,
|
|
1260
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
|
|
1261
|
-
color: new Cesium.CallbackProperty(function () {
|
|
1262
|
-
var color = animateColorIn_1.GetColor();
|
|
1263
|
-
if (animateColorIn_1.IsDone() && (cEntity === null || cEntity === void 0 ? void 0 : cEntity.billboard)) {
|
|
1264
|
-
cEntity.billboard.color = new Cesium.CallbackProperty(function () { return color; }, true);
|
|
1265
|
-
}
|
|
1266
|
-
return color;
|
|
1267
|
-
}, false),
|
|
1268
|
-
// Would be great once we have a setting for this.
|
|
1269
|
-
// translucencyByDistance: getTranslucencyByDistance(params.minDistance, params.maxDistance),
|
|
1270
|
-
},
|
|
1271
|
-
position: position,
|
|
1272
|
-
show: true
|
|
1273
|
-
});
|
|
1274
|
-
cesium_entity_styler_1.CesiumEntityStyler.BakeDefaultColor({
|
|
1275
|
-
entity: cEntity,
|
|
1276
|
-
colors: {
|
|
1277
|
-
"billboard": cColor
|
|
1278
|
-
},
|
|
1279
|
-
viewer: params.viewer,
|
|
1280
|
-
refresh: false
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
else {
|
|
1284
|
-
prepareExistingGraphic(params.rendered, shouldShowTrack ? 1 : 0);
|
|
1285
|
-
cEntity = params.rendered;
|
|
1286
|
-
currentImgKey = cEntity.billboard._billboardImgKey;
|
|
1287
|
-
if (currentImgKey != iconUrl) {
|
|
1288
|
-
cEntity.billboard.image = new Cesium.ConstantProperty(image.canvasDataUri);
|
|
1289
|
-
}
|
|
1290
|
-
cEntity.billboard.scale = new Cesium.ConstantProperty(iconScale);
|
|
1291
|
-
cEntity.billboard.heightReference = new Cesium.ConstantProperty(getHeightRef(style));
|
|
1292
|
-
cEntity.billboard.disableDepthTestDistance = new Cesium.ConstantProperty(disableDepthTest ? Number.POSITIVE_INFINITY : undefined);
|
|
1293
|
-
cEntity.billboard.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
1294
|
-
series = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
1295
|
-
if (series.length > 1) {
|
|
1296
|
-
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
1297
|
-
posses: series,
|
|
1298
|
-
viewer: params.viewer
|
|
1299
|
-
});
|
|
1300
|
-
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
1301
|
-
}
|
|
1302
|
-
else {
|
|
1303
|
-
pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
1304
|
-
viewer: params.viewer,
|
|
1305
|
-
entity: entity,
|
|
1306
|
-
recordHeightRef: heightRef,
|
|
1307
|
-
returnHeightRef: heightRef,
|
|
1308
|
-
allowRendered: false
|
|
1309
|
-
});
|
|
1310
|
-
prevPos3d = getValue(params.viewer, cEntity.position);
|
|
1311
|
-
if (!prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d)) {
|
|
1312
|
-
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePosition({
|
|
1313
|
-
durationMs: 200,
|
|
1314
|
-
targetPos3d: pos3d,
|
|
1315
|
-
viewer: params.viewer,
|
|
1316
|
-
startPos3d: prevPos3d
|
|
1317
|
-
});
|
|
1318
|
-
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
1322
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
1323
|
-
color: cColor ? cColor : new Cesium.Color(),
|
|
1324
|
-
entity: cEntity,
|
|
1325
|
-
viewer: params.viewer,
|
|
1326
|
-
override: true,
|
|
1327
|
-
requestRender: false
|
|
1328
|
-
});
|
|
1329
|
-
cEntity.show = true;
|
|
1330
|
-
}
|
|
1331
|
-
cEntity.billboard._billboardSize = image.height;
|
|
1332
|
-
cEntity.billboard._billboardImgKey = iconUrl;
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
_e.label = 9;
|
|
1336
|
-
case 9:
|
|
1337
|
-
if (type == bruce_models_1.Style.EPointType.Cylinder) {
|
|
1338
|
-
radius = (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(style.CylinderRadius, entity, params.tags));
|
|
1339
|
-
if (radius <= 0) {
|
|
1340
|
-
return [2 /*return*/, null];
|
|
1341
|
-
}
|
|
1342
|
-
bFill = style.CylinderFillColor ? bruce_models_1.Calculator.GetColor(style.CylinderFillColor, entity, params.tags) : null;
|
|
1343
|
-
cFill = bFill ? colorToCColor(bFill) : Cesium.Color.RED;
|
|
1344
|
-
outline = Boolean(style.CylinderBorderEnabled);
|
|
1345
|
-
cOutline = null;
|
|
1346
|
-
outlineWidth = 1;
|
|
1347
|
-
if (outline) {
|
|
1348
|
-
bOutline = style.CylinderBorderColor ? bruce_models_1.Calculator.GetColor(style.CylinderBorderColor, entity, params.tags) : null;
|
|
1349
|
-
cOutline = bOutline ? colorToCColor(bOutline) : Cesium.Color.BLACK;
|
|
1350
|
-
outlineWidth = (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(style.CylinderBorderWidth, entity, params.tags), 1);
|
|
1351
|
-
}
|
|
1352
|
-
heightRef = getHeightRef(style);
|
|
1353
|
-
pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
1354
|
-
viewer: params.viewer,
|
|
1355
|
-
entity: entity,
|
|
1356
|
-
recordHeightRef: heightRef,
|
|
1357
|
-
returnHeightRef: heightRef,
|
|
1358
|
-
allowRendered: false
|
|
1359
|
-
});
|
|
1360
|
-
extrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderFillExtrusion);
|
|
1361
|
-
hasOutline = outline && outlineWidth > 0;
|
|
1362
|
-
if (!params.rendered || !params.rendered.ellipse) {
|
|
1363
|
-
cEntity = new Cesium.Entity({
|
|
1364
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
1365
|
-
ellipse: {
|
|
1366
|
-
semiMajorAxis: radius,
|
|
1367
|
-
semiMinorAxis: radius,
|
|
1368
|
-
material: cFill,
|
|
1369
|
-
outlineWidth: null,
|
|
1370
|
-
extrudedHeight: extrusion.value,
|
|
1371
|
-
heightReference: heightRef,
|
|
1372
|
-
extrudedHeightReference: extrusion.exHeightRef,
|
|
1373
|
-
height: Cesium.Cartographic.fromCartesian(pos3d).height,
|
|
1374
|
-
zIndex: 1,
|
|
1375
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
1376
|
-
},
|
|
1377
|
-
position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone(),
|
|
1378
|
-
show: true
|
|
1379
|
-
});
|
|
1380
|
-
}
|
|
1381
|
-
else {
|
|
1382
|
-
prepareExistingGraphic(params.rendered, hasOutline ? 1 : 0);
|
|
1383
|
-
cEntity = params.rendered;
|
|
1384
|
-
cEntity.ellipse.semiMajorAxis = new Cesium.ConstantProperty(radius);
|
|
1385
|
-
cEntity.ellipse.semiMinorAxis = new Cesium.ConstantProperty(radius);
|
|
1386
|
-
cEntity.ellipse.outlineWidth = undefined;
|
|
1387
|
-
cEntity.ellipse.extrudedHeight = new Cesium.ConstantProperty(extrusion.value);
|
|
1388
|
-
cEntity.ellipse.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
1389
|
-
cEntity.ellipse.extrudedHeightReference = new Cesium.ConstantProperty(extrusion.exHeightRef);
|
|
1390
|
-
cEntity.ellipse.height = new Cesium.ConstantProperty(Cesium.Cartographic.fromCartesian(pos3d).height);
|
|
1391
|
-
cEntity.ellipse.zIndex = new Cesium.ConstantProperty(1);
|
|
1392
|
-
cEntity.ellipse.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
1393
|
-
cEntity.position = new Cesium.ConstantPositionProperty(pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone());
|
|
1394
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
1395
|
-
// WARNING: ellipse does not support animation (yet?).
|
|
1396
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
1397
|
-
color: cFill,
|
|
1398
|
-
entity: cEntity,
|
|
1399
|
-
viewer: params.viewer,
|
|
1400
|
-
override: true,
|
|
1401
|
-
requestRender: false
|
|
1402
|
-
});
|
|
1403
|
-
cEntity.show = true;
|
|
1404
|
-
}
|
|
1405
|
-
if (hasOutline) {
|
|
1406
|
-
outlineExtrusion = getCylinderExtrusion(entity, params.tags, heightRef, style.CylinderBorderExtrusion);
|
|
1407
|
-
// If this doesn't have its own extrusion, we must make it match the sibling.
|
|
1408
|
-
// This way they render in a uniform way.
|
|
1409
|
-
if (!outlineExtrusion.value && extrusion.value) {
|
|
1410
|
-
outlineExtrusion.exHeightRef = extrusion.exHeightRef;
|
|
1411
|
-
}
|
|
1412
|
-
outlineEntity = siblings === null || siblings === void 0 ? void 0 : siblings[0];
|
|
1413
|
-
if (outlineEntity && outlineEntity.ellipse) {
|
|
1414
|
-
outlineEntity.ellipse.semiMajorAxis = new Cesium.ConstantProperty(radius + outlineWidth);
|
|
1415
|
-
outlineEntity.ellipse.semiMinorAxis = new Cesium.ConstantProperty(radius + outlineWidth);
|
|
1416
|
-
outlineEntity.ellipse.extrudedHeight = new Cesium.ConstantProperty(outlineExtrusion.value);
|
|
1417
|
-
outlineEntity.ellipse.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
1418
|
-
outlineEntity.ellipse.extrudedHeightReference = new Cesium.ConstantProperty(outlineExtrusion.exHeightRef);
|
|
1419
|
-
outlineEntity.ellipse.height = new Cesium.ConstantProperty(Cesium.Cartographic.fromCartesian(pos3d).height);
|
|
1420
|
-
outlineEntity.ellipse.zIndex = new Cesium.ConstantProperty(2);
|
|
1421
|
-
outlineEntity.ellipse.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
1422
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
1423
|
-
// WARNING: ellipse does not support animation (yet?).
|
|
1424
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
1425
|
-
color: cOutline,
|
|
1426
|
-
entity: outlineEntity,
|
|
1427
|
-
viewer: params.viewer,
|
|
1428
|
-
override: true,
|
|
1429
|
-
requestRender: false
|
|
1430
|
-
});
|
|
1431
|
-
outlineEntity.show = true;
|
|
1432
|
-
}
|
|
1433
|
-
else {
|
|
1434
|
-
outlineEntity = new Cesium.Entity({
|
|
1435
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
1436
|
-
ellipse: {
|
|
1437
|
-
semiMajorAxis: radius + outlineWidth,
|
|
1438
|
-
semiMinorAxis: radius + outlineWidth,
|
|
1439
|
-
material: cOutline,
|
|
1440
|
-
outlineWidth: undefined,
|
|
1441
|
-
extrudedHeight: outlineExtrusion.value,
|
|
1442
|
-
heightReference: heightRef,
|
|
1443
|
-
extrudedHeightReference: outlineExtrusion.exHeightRef,
|
|
1444
|
-
height: Cesium.Cartographic.fromCartesian(pos3d).height,
|
|
1445
|
-
zIndex: 2,
|
|
1446
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
1447
|
-
},
|
|
1448
|
-
position: pos3d === null || pos3d === void 0 ? void 0 : pos3d.clone()
|
|
1449
|
-
});
|
|
1450
|
-
}
|
|
1451
|
-
siblings.push(outlineEntity);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
if (!cEntity) {
|
|
1455
|
-
bColor = style.color ? bruce_models_1.Calculator.GetColor(style.color, entity, params.tags) : null;
|
|
1456
|
-
cColor = bColor ? colorToCColor(bColor) : Cesium.Color.fromCssColorString("rgba(33, 150, 243, 0.8)");
|
|
1457
|
-
size = style.size ? bruce_models_1.Calculator.GetNumber(style.size, entity, params.tags) : null;
|
|
1458
|
-
if (size == null) {
|
|
1459
|
-
size = 20;
|
|
1460
|
-
}
|
|
1461
|
-
size = (0, js_utils_1.EnsureNumber)(size);
|
|
1462
|
-
if (size <= 0) {
|
|
1463
|
-
return [2 /*return*/, null];
|
|
1464
|
-
}
|
|
1465
|
-
heightRef = getHeightRef(style);
|
|
1466
|
-
circleBillboard = createCircleBillboard(size, cColor.toCssColorString());
|
|
1467
|
-
disableDepthTest = Boolean(style.renderOnTop);
|
|
1468
|
-
updateShouldShowTrack();
|
|
1469
|
-
if (!params.rendered || !params.rendered.billboard) {
|
|
1470
|
-
animateColorIn_2 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateColor({
|
|
1471
|
-
durationMs: 200,
|
|
1472
|
-
targetColor: cColor,
|
|
1473
|
-
startColor: cColor.withAlpha(0),
|
|
1474
|
-
viewer: params.viewer
|
|
1475
|
-
});
|
|
1476
|
-
position = null;
|
|
1477
|
-
series = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
1478
|
-
if (series.length > 1) {
|
|
1479
|
-
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
1480
|
-
posses: series,
|
|
1481
|
-
viewer: params.viewer
|
|
1482
|
-
});
|
|
1483
|
-
position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
1484
|
-
}
|
|
1485
|
-
else {
|
|
1486
|
-
position = new Cesium.CallbackProperty(function () { return entity_utils_1.EntityUtils.GetPos({
|
|
1487
|
-
viewer: params.viewer,
|
|
1488
|
-
entity: entity,
|
|
1489
|
-
recordHeightRef: heightRef,
|
|
1490
|
-
returnHeightRef: heightRef,
|
|
1491
|
-
allowRendered: false
|
|
1492
|
-
}); }, true);
|
|
1493
|
-
}
|
|
1494
|
-
cEntity = new Cesium.Entity({
|
|
1495
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
1496
|
-
// point: {
|
|
1497
|
-
// pixelSize: size,
|
|
1498
|
-
// color: cColor,
|
|
1499
|
-
// heightReference: getHeightRef(style),
|
|
1500
|
-
// distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
1501
|
-
// },
|
|
1502
|
-
// We are generating a billboard instead of using the point.
|
|
1503
|
-
// This is because points were behaving strangely where they would appear oblong shapes.
|
|
1504
|
-
// This occurred consistently when rendering many icons and points at the same time.
|
|
1505
|
-
billboard: {
|
|
1506
|
-
height: circleBillboard.height,
|
|
1507
|
-
width: circleBillboard.width,
|
|
1508
|
-
image: circleBillboard.canvasDataUri,
|
|
1509
|
-
color: new Cesium.CallbackProperty(function () {
|
|
1510
|
-
var color = animateColorIn_2.GetColor();
|
|
1511
|
-
if (animateColorIn_2.IsDone() && (cEntity === null || cEntity === void 0 ? void 0 : cEntity.billboard)) {
|
|
1512
|
-
cEntity.billboard.color = new Cesium.CallbackProperty(function () { return color; }, true);
|
|
1513
|
-
}
|
|
1514
|
-
return color;
|
|
1515
|
-
}, false),
|
|
1516
|
-
heightReference: heightRef,
|
|
1517
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance),
|
|
1518
|
-
disableDepthTestDistance: disableDepthTest ? Number.POSITIVE_INFINITY : undefined
|
|
1519
|
-
},
|
|
1520
|
-
position: position,
|
|
1521
|
-
show: true
|
|
1522
|
-
});
|
|
1523
|
-
cesium_entity_styler_1.CesiumEntityStyler.BakeDefaultColor({
|
|
1524
|
-
entity: cEntity,
|
|
1525
|
-
viewer: params.viewer,
|
|
1526
|
-
colors: {
|
|
1527
|
-
"billboard": cColor
|
|
1528
|
-
},
|
|
1529
|
-
refresh: false
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
else {
|
|
1533
|
-
prepareExistingGraphic(params.rendered, shouldShowTrack ? 1 : 0);
|
|
1534
|
-
cEntity = params.rendered;
|
|
1535
|
-
imgKey = "".concat(size, "-").concat(cColor.toCssColorString());
|
|
1536
|
-
currentImgKey = cEntity.billboard._billboardImgKey;
|
|
1537
|
-
if (currentImgKey != imgKey) {
|
|
1538
|
-
cEntity.billboard.image = new Cesium.ConstantProperty(circleBillboard.canvasDataUri);
|
|
1539
|
-
}
|
|
1540
|
-
cEntity.billboard.height = new Cesium.ConstantProperty(circleBillboard.height);
|
|
1541
|
-
cEntity.billboard.width = new Cesium.ConstantProperty(circleBillboard.width);
|
|
1542
|
-
cEntity.billboard.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
1543
|
-
cEntity.billboard.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
1544
|
-
cEntity.billboard.disableDepthTestDistance = new Cesium.ConstantProperty(disableDepthTest ? Number.POSITIVE_INFINITY : undefined);
|
|
1545
|
-
series = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
1546
|
-
if (series.length > 1) {
|
|
1547
|
-
animatePosition_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
1548
|
-
posses: series,
|
|
1549
|
-
viewer: params.viewer
|
|
1550
|
-
});
|
|
1551
|
-
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition_1.GetValue(); }, false);
|
|
1552
|
-
}
|
|
1553
|
-
else {
|
|
1554
|
-
pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
1555
|
-
viewer: params.viewer,
|
|
1556
|
-
entity: entity,
|
|
1557
|
-
recordHeightRef: heightRef,
|
|
1558
|
-
returnHeightRef: heightRef,
|
|
1559
|
-
allowRendered: false
|
|
1560
|
-
});
|
|
1561
|
-
prevPos3d = getValue(params.viewer, cEntity.position);
|
|
1562
|
-
if (!prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d)) {
|
|
1563
|
-
animatePosition_2 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePosition({
|
|
1564
|
-
durationMs: 200,
|
|
1565
|
-
targetPos3d: pos3d,
|
|
1566
|
-
viewer: params.viewer,
|
|
1567
|
-
startPos3d: prevPos3d
|
|
1568
|
-
});
|
|
1569
|
-
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition_2.GetValue(); }, false);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
1573
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
1574
|
-
color: cColor,
|
|
1575
|
-
entity: cEntity,
|
|
1576
|
-
viewer: params.viewer,
|
|
1577
|
-
override: true,
|
|
1578
|
-
requestRender: false
|
|
1579
|
-
});
|
|
1580
|
-
cEntity.show = true;
|
|
1581
|
-
cEntity.billboard._billboardImgKey = imgKey;
|
|
1582
|
-
}
|
|
1583
|
-
cEntity.billboard._billboardSize = Math.ceil(circleBillboard.height / 2);
|
|
1584
|
-
}
|
|
1585
|
-
// Generate a polyline 'track' for the historic data.
|
|
1586
|
-
// We do this for historic data that exists and is moving.
|
|
1587
|
-
if (shouldShowTrack && animatePosition && animatePosition instanceof cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetSeries) {
|
|
1588
|
-
lStyle = (_d = (_c = params.fullStyle) === null || _c === void 0 ? void 0 : _c.polylineStyle) !== null && _d !== void 0 ? _d : {};
|
|
1589
|
-
bColor = lStyle.lineColor ? bruce_models_1.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
1590
|
-
cColor = bColor ? colorToCColor(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
1591
|
-
material = new Cesium.PolylineDashMaterialProperty({
|
|
1592
|
-
color: cColor
|
|
1593
|
-
});
|
|
1594
|
-
width = lStyle.lineWidth ? (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(lStyle.lineWidth, entity, params.tags)) : 2;
|
|
1595
|
-
if (width == null) {
|
|
1596
|
-
width = 2;
|
|
1597
|
-
}
|
|
1598
|
-
width = (0, js_utils_1.EnsureNumber)(width);
|
|
1599
|
-
trackEntity = siblings === null || siblings === void 0 ? void 0 : siblings[0];
|
|
1600
|
-
if (!trackEntity) {
|
|
1601
|
-
trackEntity = new Cesium.Entity({
|
|
1602
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
1603
|
-
polyline: {
|
|
1604
|
-
positions: [],
|
|
1605
|
-
width: width,
|
|
1606
|
-
material: material,
|
|
1607
|
-
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
1608
|
-
zIndex: 0,
|
|
1609
|
-
classificationType: Cesium.ClassificationType.BOTH
|
|
1610
|
-
}
|
|
1611
|
-
});
|
|
1612
|
-
}
|
|
1613
|
-
trackEntity._noEdit = true;
|
|
1614
|
-
trackEntity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
1615
|
-
return animatePosition.GetSeries();
|
|
1616
|
-
}, false);
|
|
1617
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
1618
|
-
// WARNING: polyline does not support animation (yet?).
|
|
1619
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
1620
|
-
color: cColor,
|
|
1621
|
-
entity: trackEntity,
|
|
1622
|
-
viewer: params.viewer,
|
|
1623
|
-
override: true,
|
|
1624
|
-
requestRender: false
|
|
1625
|
-
});
|
|
1626
|
-
siblings.push(trackEntity);
|
|
1627
|
-
}
|
|
1628
|
-
cEntity._siblingGraphics = siblings;
|
|
1629
|
-
return [2 /*return*/, cEntity];
|
|
1630
|
-
}
|
|
1631
|
-
});
|
|
1632
|
-
});
|
|
1633
|
-
}
|
|
1634
|
-
Point.Render = Render;
|
|
1635
|
-
function RenderGroup(params) {
|
|
1636
|
-
var _a, _b, _c, _d;
|
|
1637
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1638
|
-
var api, cEntities, i, entity, zoomItem, style, _e, tagIds, tags, pStyle, cEntity, name_2;
|
|
1639
|
-
return __generator(this, function (_f) {
|
|
1640
|
-
switch (_f.label) {
|
|
1641
|
-
case 0:
|
|
1642
|
-
api = params.apiGetter.getApi();
|
|
1643
|
-
cEntities = new Map();
|
|
1644
|
-
i = 0;
|
|
1645
|
-
_f.label = 1;
|
|
1646
|
-
case 1:
|
|
1647
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 11];
|
|
1648
|
-
entity = params.entities[i];
|
|
1649
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
1650
|
-
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 3];
|
|
1651
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
1652
|
-
case 2:
|
|
1653
|
-
_e = (_a = (_f.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
1654
|
-
return [3 /*break*/, 4];
|
|
1655
|
-
case 3:
|
|
1656
|
-
_e = zoomItem.Style;
|
|
1657
|
-
_f.label = 4;
|
|
1658
|
-
case 4:
|
|
1659
|
-
style = _e;
|
|
1660
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
1661
|
-
tags = [];
|
|
1662
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 6];
|
|
1663
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
1664
|
-
api: api,
|
|
1665
|
-
tagIds: tagIds
|
|
1666
|
-
})];
|
|
1667
|
-
case 5:
|
|
1668
|
-
tags = (_f.sent()).tags;
|
|
1669
|
-
_f.label = 6;
|
|
1670
|
-
case 6:
|
|
1671
|
-
pStyle = (_b = style === null || style === void 0 ? void 0 : style.pointStyle) !== null && _b !== void 0 ? _b : {};
|
|
1672
|
-
return [4 /*yield*/, Render({
|
|
1673
|
-
entity: entity,
|
|
1674
|
-
style: pStyle,
|
|
1675
|
-
tags: tags,
|
|
1676
|
-
viewer: params.viewer,
|
|
1677
|
-
api: api,
|
|
1678
|
-
apiGetter: params.apiGetter,
|
|
1679
|
-
maxDistance: zoomItem.MaxZoom,
|
|
1680
|
-
minDistance: zoomItem.MinZoom,
|
|
1681
|
-
rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID),
|
|
1682
|
-
entityHistoric: (_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID],
|
|
1683
|
-
entityHistoricDrawTrack: params.entityHistoricDrawTrack,
|
|
1684
|
-
fullStyle: style
|
|
1685
|
-
})];
|
|
1686
|
-
case 7:
|
|
1687
|
-
cEntity = _f.sent();
|
|
1688
|
-
if (!cEntity) return [3 /*break*/, 9];
|
|
1689
|
-
return [4 /*yield*/, getName(api, entity)];
|
|
1690
|
-
case 8:
|
|
1691
|
-
name_2 = _f.sent();
|
|
1692
|
-
cEntity.name = name_2;
|
|
1693
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
1694
|
-
_f.label = 9;
|
|
1695
|
-
case 9:
|
|
1696
|
-
cEntities.set(entity.Bruce.ID, cEntity);
|
|
1697
|
-
_f.label = 10;
|
|
1698
|
-
case 10:
|
|
1699
|
-
i++;
|
|
1700
|
-
return [3 /*break*/, 1];
|
|
1701
|
-
case 11: return [2 /*return*/, cEntities];
|
|
1702
|
-
}
|
|
1703
|
-
});
|
|
1704
|
-
});
|
|
1705
|
-
}
|
|
1706
|
-
Point.RenderGroup = RenderGroup;
|
|
396
|
+
Point.CreateCircleBillboard = entity_render_engine_point_1.EntityRenderEnginePoint.CreateCircleBillboard;
|
|
397
|
+
Point.RenderGroup = entity_render_engine_point_1.EntityRenderEnginePoint.RenderGroup;
|
|
398
|
+
Point.Render = entity_render_engine_point_1.EntityRenderEnginePoint.Render;
|
|
1707
399
|
})(Point = EntityRenderEngine.Point || (EntityRenderEngine.Point = {}));
|
|
1708
400
|
var Polyline;
|
|
1709
401
|
(function (Polyline) {
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
var lineString = bruce_models_1.Entity.GetValue({
|
|
1713
|
-
entity: entity,
|
|
1714
|
-
path: ["Bruce", "VectorGeometry", "LineString"]
|
|
1715
|
-
});
|
|
1716
|
-
var points = lineString && typeof lineString == "string" ? bruce_models_1.Geometry.ParsePoints(lineString) : [];
|
|
1717
|
-
if (!points || points.length < 2) {
|
|
1718
|
-
return null;
|
|
1719
|
-
}
|
|
1720
|
-
var isValid = true;
|
|
1721
|
-
for (var i = 0; i < points.length; i++) {
|
|
1722
|
-
if (!bruce_models_1.Carto.ValidateCarto(points[i])) {
|
|
1723
|
-
isValid = false;
|
|
1724
|
-
break;
|
|
1725
|
-
}
|
|
1726
|
-
}
|
|
1727
|
-
if (!isValid) {
|
|
1728
|
-
return null;
|
|
1729
|
-
}
|
|
1730
|
-
var style = params.style;
|
|
1731
|
-
var heightRef = getHeightRef(style);
|
|
1732
|
-
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)); });
|
|
1733
|
-
posses = cullDuplicatePoints(posses);
|
|
1734
|
-
// 5 points should be enough to tell most bad data.
|
|
1735
|
-
var CHECK_POINTS = 5;
|
|
1736
|
-
var MIN_LEN = 0.001;
|
|
1737
|
-
var MAX_LEN = 4500000;
|
|
1738
|
-
var totalLength = 0;
|
|
1739
|
-
for (var i = 0; i < posses.length; i++) {
|
|
1740
|
-
if (i > CHECK_POINTS) {
|
|
1741
|
-
break;
|
|
1742
|
-
}
|
|
1743
|
-
var pos1 = posses[i];
|
|
1744
|
-
var pos2 = posses[i + 1];
|
|
1745
|
-
if (pos1 && pos2) {
|
|
1746
|
-
totalLength += Cesium.Cartesian3.distance(pos1, pos2);
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
if (totalLength < MIN_LEN || totalLength > MAX_LEN) {
|
|
1750
|
-
return null;
|
|
1751
|
-
}
|
|
1752
|
-
var bColor = style.lineColor ? bruce_models_1.Calculator.GetColor(style.lineColor, entity, params.tags) : null;
|
|
1753
|
-
var cColor = bColor ? colorToCColor(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
1754
|
-
if (cColor.alpha <= 0) {
|
|
1755
|
-
return null;
|
|
1756
|
-
}
|
|
1757
|
-
var width = style.lineWidth ? bruce_models_1.Calculator.GetNumber(style.lineWidth, entity, params.tags) : null;
|
|
1758
|
-
if (width == null) {
|
|
1759
|
-
width = 2;
|
|
1760
|
-
}
|
|
1761
|
-
width = (0, js_utils_1.EnsureNumber)(width);
|
|
1762
|
-
if (width < 0.01) {
|
|
1763
|
-
width = 0;
|
|
1764
|
-
}
|
|
1765
|
-
if (width <= 0) {
|
|
1766
|
-
return null;
|
|
1767
|
-
}
|
|
1768
|
-
var units = style.lineWidthUnits;
|
|
1769
|
-
// Px for backward compatibility. Meters are less prone to crashes.
|
|
1770
|
-
if (units != "px" && units != "m") {
|
|
1771
|
-
units = "px";
|
|
1772
|
-
}
|
|
1773
|
-
var classification = Cesium.ClassificationType.TERRAIN;
|
|
1774
|
-
if (style.drapeOver == "ALL") {
|
|
1775
|
-
classification = Cesium.ClassificationType.BOTH;
|
|
1776
|
-
}
|
|
1777
|
-
var cEntity = null;
|
|
1778
|
-
if (!params.rendered || ((!params.rendered.polyline && units == "px") ||
|
|
1779
|
-
(!params.rendered.corridor && units == "m"))) {
|
|
1780
|
-
cEntity = new Cesium.Entity({
|
|
1781
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
1782
|
-
polyline: units == "px" ? {
|
|
1783
|
-
positions: posses,
|
|
1784
|
-
material: cColor,
|
|
1785
|
-
width: width,
|
|
1786
|
-
classificationType: classification,
|
|
1787
|
-
arcType: Cesium.ArcType.GEODESIC,
|
|
1788
|
-
zIndex: getZIndex(style, entity, params.tags),
|
|
1789
|
-
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
1790
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
1791
|
-
} : null,
|
|
1792
|
-
corridor: units == "m" ? {
|
|
1793
|
-
positions: posses,
|
|
1794
|
-
material: cColor,
|
|
1795
|
-
width: width,
|
|
1796
|
-
classificationType: classification,
|
|
1797
|
-
heightReference: heightRef,
|
|
1798
|
-
zIndex: getZIndex(style, entity, params.tags),
|
|
1799
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
1800
|
-
cornerType: Cesium.CornerType.MITERED,
|
|
1801
|
-
shadows: Cesium.ShadowMode.ENABLED,
|
|
1802
|
-
fill: true
|
|
1803
|
-
} : null,
|
|
1804
|
-
position: entity_utils_1.EntityUtils.GetPos({
|
|
1805
|
-
viewer: params.viewer,
|
|
1806
|
-
entity: entity,
|
|
1807
|
-
recordHeightRef: heightRef,
|
|
1808
|
-
returnHeightRef: heightRef,
|
|
1809
|
-
allowRendered: false
|
|
1810
|
-
}),
|
|
1811
|
-
show: true
|
|
1812
|
-
});
|
|
1813
|
-
}
|
|
1814
|
-
else {
|
|
1815
|
-
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
1816
|
-
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
1817
|
-
entity: cEntity,
|
|
1818
|
-
});
|
|
1819
|
-
if (parts.length > 1) {
|
|
1820
|
-
// Kill all expect last part. Last one is the primary entity.
|
|
1821
|
-
for (var i = 0; i < parts.length - 1; i++) {
|
|
1822
|
-
var part = parts[i];
|
|
1823
|
-
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part)) {
|
|
1824
|
-
params.viewer.entities.remove(part);
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
cEntity._siblingGraphics = [];
|
|
1828
|
-
if (cEntity._parentEntity) {
|
|
1829
|
-
console.warn("Polyline.Render: Parent entity was not null. This should not happen.");
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
cEntity = params.rendered;
|
|
1833
|
-
if (units == "px") {
|
|
1834
|
-
var oldPosses = getValue(params.viewer, cEntity.polyline.positions);
|
|
1835
|
-
if (!comparePositions(posses, oldPosses)) {
|
|
1836
|
-
cEntity.polyline.positions = new Cesium.ConstantProperty(posses);
|
|
1837
|
-
}
|
|
1838
|
-
var oldWidth = getValue(params.viewer, cEntity.polyline.width);
|
|
1839
|
-
if (oldWidth != width) {
|
|
1840
|
-
cEntity.polyline.width = new Cesium.ConstantProperty(width);
|
|
1841
|
-
}
|
|
1842
|
-
var oldClassification = getValue(params.viewer, cEntity.polyline.classificationType);
|
|
1843
|
-
if (oldClassification != classification) {
|
|
1844
|
-
cEntity.polyline.classificationType = new Cesium.ConstantProperty(classification);
|
|
1845
|
-
}
|
|
1846
|
-
var oldZIndex = getValue(params.viewer, cEntity.polyline.zIndex);
|
|
1847
|
-
if (oldZIndex != getZIndex(style, entity, params.tags)) {
|
|
1848
|
-
cEntity.polyline.zIndex = new Cesium.ConstantProperty(getZIndex(style, entity, params.tags));
|
|
1849
|
-
}
|
|
1850
|
-
var oldClampToGround = getValue(params.viewer, cEntity.polyline.clampToGround);
|
|
1851
|
-
var newClampToGround = heightRef == Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
1852
|
-
if (oldClampToGround != newClampToGround) {
|
|
1853
|
-
cEntity.polyline.clampToGround = new Cesium.ConstantProperty(newClampToGround);
|
|
1854
|
-
}
|
|
1855
|
-
cEntity.polyline.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
1856
|
-
cEntity.corridor = undefined;
|
|
1857
|
-
}
|
|
1858
|
-
else {
|
|
1859
|
-
var oldPosses = getValue(params.viewer, cEntity.corridor.positions);
|
|
1860
|
-
if (!comparePositions(posses, oldPosses)) {
|
|
1861
|
-
cEntity.corridor.positions = new Cesium.ConstantProperty(posses);
|
|
1862
|
-
}
|
|
1863
|
-
var oldWidth = getValue(params.viewer, cEntity.corridor.width);
|
|
1864
|
-
if (oldWidth != width) {
|
|
1865
|
-
cEntity.corridor.width = new Cesium.ConstantProperty(width);
|
|
1866
|
-
}
|
|
1867
|
-
var oldClassification = getValue(params.viewer, cEntity.corridor.classificationType);
|
|
1868
|
-
if (oldClassification != classification) {
|
|
1869
|
-
cEntity.corridor.classificationType = new Cesium.ConstantProperty(classification);
|
|
1870
|
-
}
|
|
1871
|
-
var oldHeightRef = getValue(params.viewer, cEntity.corridor.heightReference);
|
|
1872
|
-
if (oldHeightRef != heightRef) {
|
|
1873
|
-
cEntity.corridor.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
1874
|
-
}
|
|
1875
|
-
var oldZIndex = getValue(params.viewer, cEntity.corridor.zIndex);
|
|
1876
|
-
if (oldZIndex != getZIndex(style, entity, params.tags)) {
|
|
1877
|
-
cEntity.corridor.zIndex = new Cesium.ConstantProperty(getZIndex(style, entity, params.tags));
|
|
1878
|
-
}
|
|
1879
|
-
cEntity.corridor.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance, width));
|
|
1880
|
-
cEntity.polyline = undefined;
|
|
1881
|
-
}
|
|
1882
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
1883
|
-
// WARNING: polyline does not support animation (yet?).
|
|
1884
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
1885
|
-
color: cColor,
|
|
1886
|
-
entity: cEntity,
|
|
1887
|
-
viewer: params.viewer,
|
|
1888
|
-
override: true,
|
|
1889
|
-
requestRender: false
|
|
1890
|
-
});
|
|
1891
|
-
var oldPos = getValue(params.viewer, cEntity.position);
|
|
1892
|
-
var newPos = entity_utils_1.EntityUtils.GetPos({
|
|
1893
|
-
viewer: params.viewer,
|
|
1894
|
-
entity: entity,
|
|
1895
|
-
recordHeightRef: heightRef,
|
|
1896
|
-
returnHeightRef: heightRef,
|
|
1897
|
-
allowRendered: false
|
|
1898
|
-
});
|
|
1899
|
-
if (newPos && (!oldPos || !bruce_models_1.Cartes.IsEqualCartes3(oldPos, newPos))) {
|
|
1900
|
-
cEntity.position = new Cesium.ConstantPositionProperty(newPos);
|
|
1901
|
-
}
|
|
1902
|
-
cEntity.show = true;
|
|
1903
|
-
}
|
|
1904
|
-
return cEntity;
|
|
1905
|
-
}
|
|
1906
|
-
Polyline.Render = Render;
|
|
1907
|
-
function RenderGroup(params) {
|
|
1908
|
-
var _a, _b, _c;
|
|
1909
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1910
|
-
var api, cEntities, i, entity, zoomItem, style, _d, tagIds, tags, lStyle, cEntity, name_3;
|
|
1911
|
-
return __generator(this, function (_e) {
|
|
1912
|
-
switch (_e.label) {
|
|
1913
|
-
case 0:
|
|
1914
|
-
api = params.apiGetter.getApi();
|
|
1915
|
-
cEntities = new Map();
|
|
1916
|
-
i = 0;
|
|
1917
|
-
_e.label = 1;
|
|
1918
|
-
case 1:
|
|
1919
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 9];
|
|
1920
|
-
entity = params.entities[i];
|
|
1921
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
1922
|
-
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 3];
|
|
1923
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
1924
|
-
case 2:
|
|
1925
|
-
_d = (_a = (_e.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
1926
|
-
return [3 /*break*/, 4];
|
|
1927
|
-
case 3:
|
|
1928
|
-
_d = zoomItem.Style;
|
|
1929
|
-
_e.label = 4;
|
|
1930
|
-
case 4:
|
|
1931
|
-
style = _d;
|
|
1932
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
1933
|
-
tags = [];
|
|
1934
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 6];
|
|
1935
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
1936
|
-
api: api,
|
|
1937
|
-
tagIds: tagIds
|
|
1938
|
-
})];
|
|
1939
|
-
case 5:
|
|
1940
|
-
tags = (_e.sent()).tags;
|
|
1941
|
-
_e.label = 6;
|
|
1942
|
-
case 6:
|
|
1943
|
-
lStyle = (_b = style === null || style === void 0 ? void 0 : style.polylineStyle) !== null && _b !== void 0 ? _b : {};
|
|
1944
|
-
cEntity = Render({
|
|
1945
|
-
entity: entity,
|
|
1946
|
-
style: lStyle,
|
|
1947
|
-
tags: tags,
|
|
1948
|
-
viewer: params.viewer,
|
|
1949
|
-
maxDistance: zoomItem.MaxZoom,
|
|
1950
|
-
minDistance: zoomItem.MinZoom,
|
|
1951
|
-
rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
|
|
1952
|
-
});
|
|
1953
|
-
if (!cEntity) return [3 /*break*/, 8];
|
|
1954
|
-
return [4 /*yield*/, getName(api, entity)];
|
|
1955
|
-
case 7:
|
|
1956
|
-
name_3 = _e.sent();
|
|
1957
|
-
cEntity.name = name_3;
|
|
1958
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
1959
|
-
cEntities.set(entity.Bruce.ID, cEntity);
|
|
1960
|
-
_e.label = 8;
|
|
1961
|
-
case 8:
|
|
1962
|
-
i++;
|
|
1963
|
-
return [3 /*break*/, 1];
|
|
1964
|
-
case 9: return [2 /*return*/, cEntities];
|
|
1965
|
-
}
|
|
1966
|
-
});
|
|
1967
|
-
});
|
|
1968
|
-
}
|
|
1969
|
-
Polyline.RenderGroup = RenderGroup;
|
|
402
|
+
Polyline.RenderGroup = entity_render_engine_polyline_1.EntityRenderEnginePolyline.RenderGroup;
|
|
403
|
+
Polyline.Render = entity_render_engine_polyline_1.EntityRenderEnginePolyline.Render;
|
|
1970
404
|
})(Polyline = EntityRenderEngine.Polyline || (EntityRenderEngine.Polyline = {}));
|
|
1971
405
|
var Polygon;
|
|
1972
406
|
(function (Polygon) {
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
var entity = params.entity;
|
|
1976
|
-
var pRings = bruce_models_1.Entity.GetValue({
|
|
1977
|
-
entity: entity,
|
|
1978
|
-
path: ["Bruce", "VectorGeometry", "Polygon"]
|
|
1979
|
-
});
|
|
1980
|
-
if (pRings == null || !Array.isArray(pRings) || pRings.length <= 0) {
|
|
1981
|
-
return null;
|
|
1982
|
-
}
|
|
1983
|
-
var style = params.style;
|
|
1984
|
-
var bFillColor = bruce_models_1.Calculator.GetColor(style.fillColor, entity, params.tags);
|
|
1985
|
-
var cFillColor = bFillColor ? colorToCColor(bFillColor) : Cesium.Color.fromCssColorString("rgba(139, 195, 74, 0.8)");
|
|
1986
|
-
var bLineColor = bruce_models_1.Calculator.GetColor(style.lineColor, entity, params.tags);
|
|
1987
|
-
var cLineColor = bLineColor ? colorToCColor(bLineColor) : Cesium.Color.fromCssColorString("rgba(80, 80, 80, 0.8)");
|
|
1988
|
-
var width = style.lineWidth ? bruce_models_1.Calculator.GetNumber(style.lineWidth, entity, params.tags) : null;
|
|
1989
|
-
if (width == null) {
|
|
1990
|
-
width = 1;
|
|
1991
|
-
}
|
|
1992
|
-
width = (0, js_utils_1.EnsureNumber)(width);
|
|
1993
|
-
if (width < 0.01) {
|
|
1994
|
-
width = 0;
|
|
1995
|
-
}
|
|
1996
|
-
var units = style.lineWidthUnits;
|
|
1997
|
-
if (units != "px" && units != "m") {
|
|
1998
|
-
units = "m";
|
|
1999
|
-
}
|
|
2000
|
-
// If both outline and fill is not available then don't render anything.
|
|
2001
|
-
if ((width <= 0 || cLineColor.alpha <= 0) &&
|
|
2002
|
-
cFillColor.alpha <= 0) {
|
|
2003
|
-
return null;
|
|
2004
|
-
}
|
|
2005
|
-
var heightRef = getHeightRef(style);
|
|
2006
|
-
var outerRing = pRings.find(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Boundaries; });
|
|
2007
|
-
var points = bruce_models_1.Geometry.ParsePoints(outerRing === null || outerRing === void 0 ? void 0 : outerRing.LinearRing);
|
|
2008
|
-
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)); });
|
|
2009
|
-
bruce_models_1.Cartes.CloseRing3(posses);
|
|
2010
|
-
var extrusion = getPolygonExtrusion(entity, params.tags, outerRing, posses, heightRef, style);
|
|
2011
|
-
posses = extrusion.posses;
|
|
2012
|
-
posses = cullDuplicatePoints(posses);
|
|
2013
|
-
if (posses.length < 4) {
|
|
2014
|
-
return null;
|
|
2015
|
-
}
|
|
2016
|
-
var holeRings = pRings.filter(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Hole; });
|
|
2017
|
-
var holePosses = holeRings.map(function (x) {
|
|
2018
|
-
var points = bruce_models_1.Geometry.ParsePoints(x.LinearRing);
|
|
2019
|
-
var holePosses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees((0, js_utils_1.EnsureNumber)(x.longitude), (0, js_utils_1.EnsureNumber)(x.latitude), (0, js_utils_1.EnsureNumber)(x.altitude)); });
|
|
2020
|
-
holePosses = cullDuplicatePoints(holePosses);
|
|
2021
|
-
bruce_models_1.Cartes.CloseRing3(holePosses);
|
|
2022
|
-
return holePosses;
|
|
2023
|
-
}).filter(function (x) { return x.length >= 4; });
|
|
2024
|
-
var zIndex = getZIndex(style, entity, params.tags);
|
|
2025
|
-
var size = getSizeOfPolygonEntity(entity);
|
|
2026
|
-
var classification = Cesium.ClassificationType.TERRAIN;
|
|
2027
|
-
if (style.drapeOver == "ALL") {
|
|
2028
|
-
classification = Cesium.ClassificationType.BOTH;
|
|
2029
|
-
}
|
|
2030
|
-
var prepareExistingGraphic = function (cEntity, siblings) {
|
|
2031
|
-
if (siblings === void 0) { siblings = 0; }
|
|
2032
|
-
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
2033
|
-
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
2034
|
-
entity: cEntity,
|
|
2035
|
-
});
|
|
2036
|
-
if (parts.length > 1) {
|
|
2037
|
-
// We'll cull all except the allowed number of siblings.
|
|
2038
|
-
cEntity._siblingGraphics = cEntity._siblingGraphics.slice(0, siblings);
|
|
2039
|
-
// We'll remove all that aren't in the allowed (direct) list.
|
|
2040
|
-
for (var i = 0; i < parts.length - 1; i++) {
|
|
2041
|
-
var part = parts[i];
|
|
2042
|
-
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part) && !cEntity._siblingGraphics.includes(part)) {
|
|
2043
|
-
params.viewer.entities.remove(part);
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
if (cEntity._parentEntity) {
|
|
2047
|
-
console.warn("Point.Render: Parent entity was not null. This should not happen.");
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
};
|
|
2051
|
-
var hasOutline = width > 0 && cLineColor;
|
|
2052
|
-
var cEntity = null;
|
|
2053
|
-
if (!params.rendered || !params.rendered.polygon) {
|
|
2054
|
-
cEntity = new Cesium.Entity({
|
|
2055
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
2056
|
-
polygon: {
|
|
2057
|
-
hierarchy: new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); })),
|
|
2058
|
-
material: cFillColor,
|
|
2059
|
-
extrudedHeight: extrusion.value,
|
|
2060
|
-
extrudedHeightReference: extrusion.exHeightRef,
|
|
2061
|
-
shadows: Cesium.ShadowMode.ENABLED,
|
|
2062
|
-
heightReference: heightRef,
|
|
2063
|
-
classificationType: classification,
|
|
2064
|
-
perPositionHeight: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true,
|
|
2065
|
-
zIndex: zIndex,
|
|
2066
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width <= 0 || !cLineColor || units == "m" ? size : null, true)
|
|
2067
|
-
},
|
|
2068
|
-
position: entity_utils_1.EntityUtils.GetPos({
|
|
2069
|
-
viewer: params.viewer,
|
|
2070
|
-
entity: entity,
|
|
2071
|
-
recordHeightRef: heightRef,
|
|
2072
|
-
returnHeightRef: heightRef,
|
|
2073
|
-
allowRendered: false
|
|
2074
|
-
}),
|
|
2075
|
-
show: true
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
else {
|
|
2079
|
-
// Polygons can have more siblings for the related hole graphics.
|
|
2080
|
-
// So this is a "good enough" way rather than perfect as it only preserves the outline.
|
|
2081
|
-
prepareExistingGraphic(params.rendered, hasOutline ? 1 : 0);
|
|
2082
|
-
cEntity = params.rendered;
|
|
2083
|
-
// We'll do a number of checks to avoid updating the entity if it's not needed.
|
|
2084
|
-
var oldHierarchy = getValue(params.viewer, cEntity.polygon.hierarchy);
|
|
2085
|
-
var newHierarchy = new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); }));
|
|
2086
|
-
if (!comparePolygonHierarchies(oldHierarchy, newHierarchy)) {
|
|
2087
|
-
cEntity.polygon.hierarchy = new Cesium.ConstantProperty(newHierarchy);
|
|
2088
|
-
}
|
|
2089
|
-
var oldExtrusion = getValue(params.viewer, cEntity.polygon.extrudedHeight);
|
|
2090
|
-
if (oldExtrusion != extrusion.value) {
|
|
2091
|
-
cEntity.polygon.extrudedHeight = new Cesium.ConstantProperty(extrusion.value);
|
|
2092
|
-
}
|
|
2093
|
-
var oldExHeightRef = getValue(params.viewer, cEntity.polygon.extrudedHeightReference);
|
|
2094
|
-
if (oldExHeightRef != extrusion.exHeightRef) {
|
|
2095
|
-
cEntity.polygon.extrudedHeightReference = new Cesium.ConstantProperty(extrusion.exHeightRef);
|
|
2096
|
-
}
|
|
2097
|
-
var oldHeightRef = getValue(params.viewer, cEntity.polygon.heightReference);
|
|
2098
|
-
if (oldHeightRef != heightRef) {
|
|
2099
|
-
cEntity.polygon.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
2100
|
-
}
|
|
2101
|
-
var oldPerPosHeight = getValue(params.viewer, cEntity.polygon.perPositionHeight);
|
|
2102
|
-
if (oldPerPosHeight != (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true)) {
|
|
2103
|
-
cEntity.polygon.perPositionHeight = new Cesium.ConstantProperty(heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true);
|
|
2104
|
-
}
|
|
2105
|
-
var oldPosition = getValue(params.viewer, cEntity.position);
|
|
2106
|
-
var newPosition = entity_utils_1.EntityUtils.GetPos({
|
|
2107
|
-
viewer: params.viewer,
|
|
2108
|
-
entity: entity,
|
|
2109
|
-
recordHeightRef: heightRef,
|
|
2110
|
-
returnHeightRef: heightRef,
|
|
2111
|
-
allowRendered: false
|
|
2112
|
-
});
|
|
2113
|
-
if (newPosition && (!oldPosition || !bruce_models_1.Cartes.IsEqualCartes3(oldPosition, newPosition))) {
|
|
2114
|
-
cEntity.position = new Cesium.ConstantPositionProperty(newPosition);
|
|
2115
|
-
}
|
|
2116
|
-
var oldZIndex = getValue(params.viewer, cEntity.polygon.zIndex);
|
|
2117
|
-
if (oldZIndex != zIndex) {
|
|
2118
|
-
cEntity.polygon.zIndex = new Cesium.ConstantProperty(zIndex);
|
|
2119
|
-
}
|
|
2120
|
-
cEntity.polygon.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance, width <= 0 || !cLineColor || units == "m" ? size : null, true));
|
|
2121
|
-
cEntity.polygon.shadows = new Cesium.ConstantProperty(Cesium.ShadowMode.ENABLED);
|
|
2122
|
-
cEntity.polygon.classificationType = new Cesium.ConstantProperty(classification);
|
|
2123
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
2124
|
-
// WARNING: polygon does not support animation (yet?).
|
|
2125
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
2126
|
-
color: cFillColor,
|
|
2127
|
-
entity: cEntity,
|
|
2128
|
-
viewer: params.viewer,
|
|
2129
|
-
override: true,
|
|
2130
|
-
requestRender: false
|
|
2131
|
-
});
|
|
2132
|
-
cEntity.show = true;
|
|
2133
|
-
}
|
|
2134
|
-
if (hasOutline) {
|
|
2135
|
-
var borderHeight = undefined;
|
|
2136
|
-
if (heightRef != Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
2137
|
-
// Set height to smallest height value from points.
|
|
2138
|
-
for (var i = 0; i < points.length; i++) {
|
|
2139
|
-
var point = points[i];
|
|
2140
|
-
if (!borderHeight || point.altitude < borderHeight) {
|
|
2141
|
-
borderHeight = point.altitude;
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
}
|
|
2145
|
-
var borderPosses = posses.map(function (x) { return x.clone ? x.clone() : __assign({}, x); });
|
|
2146
|
-
var cEntityBorder = (_b = (_a = params.rendered) === null || _a === void 0 ? void 0 : _a._siblingGraphics) === null || _b === void 0 ? void 0 : _b[0];
|
|
2147
|
-
cEntity._siblingGraphics = [];
|
|
2148
|
-
if (!cEntityBorder || ((!cEntityBorder.polyline && units == "px") ||
|
|
2149
|
-
(!cEntityBorder.corridor && units == "m"))) {
|
|
2150
|
-
cEntityBorder = new Cesium.Entity({
|
|
2151
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
2152
|
-
polyline: units == "px" ? new Cesium.PolylineGraphics({
|
|
2153
|
-
positions: borderPosses,
|
|
2154
|
-
material: cLineColor,
|
|
2155
|
-
width: width,
|
|
2156
|
-
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
2157
|
-
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
2158
|
-
arcType: Cesium.ArcType.GEODESIC,
|
|
2159
|
-
zIndex: zIndex,
|
|
2160
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
2161
|
-
}) : null,
|
|
2162
|
-
corridor: units == "m" ? {
|
|
2163
|
-
positions: borderPosses,
|
|
2164
|
-
material: cLineColor,
|
|
2165
|
-
heightReference: heightRef,
|
|
2166
|
-
height: borderHeight,
|
|
2167
|
-
width: width,
|
|
2168
|
-
fill: true,
|
|
2169
|
-
zIndex: zIndex + 1,
|
|
2170
|
-
cornerType: Cesium.CornerType.MITERED,
|
|
2171
|
-
classificationType: classification,
|
|
2172
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
2173
|
-
shadows: Cesium.ShadowMode.ENABLED
|
|
2174
|
-
} : null,
|
|
2175
|
-
show: true
|
|
2176
|
-
});
|
|
2177
|
-
}
|
|
2178
|
-
else {
|
|
2179
|
-
if (units == "px") {
|
|
2180
|
-
var oldPosses = getValue(params.viewer, cEntityBorder.polyline.positions);
|
|
2181
|
-
if (!comparePositions(oldPosses, borderPosses)) {
|
|
2182
|
-
cEntityBorder.polyline.positions = new Cesium.ConstantProperty(borderPosses);
|
|
2183
|
-
}
|
|
2184
|
-
var oldWidth = getValue(params.viewer, cEntityBorder.polyline.width);
|
|
2185
|
-
if (oldWidth != width) {
|
|
2186
|
-
cEntityBorder.polyline.width = new Cesium.ConstantProperty(width);
|
|
2187
|
-
}
|
|
2188
|
-
var oldClampToGround = getValue(params.viewer, cEntityBorder.polyline.clampToGround);
|
|
2189
|
-
var newClampToGround = heightRef == Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
2190
|
-
if (oldClampToGround != newClampToGround) {
|
|
2191
|
-
cEntityBorder.polyline.clampToGround = new Cesium.ConstantProperty(newClampToGround);
|
|
2192
|
-
}
|
|
2193
|
-
var oldZIndex = getValue(params.viewer, cEntityBorder.polyline.zIndex);
|
|
2194
|
-
if (oldZIndex != zIndex) {
|
|
2195
|
-
cEntityBorder.polyline.zIndex = new Cesium.ConstantProperty(zIndex);
|
|
2196
|
-
}
|
|
2197
|
-
var oldMaterial = getValue(params.viewer, cEntityBorder.polyline.material);
|
|
2198
|
-
var newMaterial = new Cesium.ColorMaterialProperty(cLineColor);
|
|
2199
|
-
if (compareColorMaterials(params.viewer, oldMaterial, newMaterial)) {
|
|
2200
|
-
cEntityBorder.polyline.material = newMaterial;
|
|
2201
|
-
}
|
|
2202
|
-
cEntityBorder.polyline.classificationType = new Cesium.ConstantProperty(Cesium.ClassificationType.TERRAIN);
|
|
2203
|
-
cEntityBorder.polyline.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
2204
|
-
cEntityBorder.corridor = undefined;
|
|
2205
|
-
}
|
|
2206
|
-
else {
|
|
2207
|
-
var oldPosses = getValue(params.viewer, cEntityBorder.corridor.positions);
|
|
2208
|
-
if (!comparePositions(oldPosses, borderPosses)) {
|
|
2209
|
-
cEntityBorder.corridor.positions = new Cesium.ConstantProperty(borderPosses);
|
|
2210
|
-
}
|
|
2211
|
-
var oldHeightRef = getValue(params.viewer, cEntityBorder.corridor.heightReference);
|
|
2212
|
-
if (oldHeightRef != heightRef) {
|
|
2213
|
-
cEntityBorder.corridor.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
2214
|
-
}
|
|
2215
|
-
var oldBorderHeight = getValue(params.viewer, cEntityBorder.corridor.height);
|
|
2216
|
-
if (oldBorderHeight != borderHeight) {
|
|
2217
|
-
cEntityBorder.corridor.height = new Cesium.ConstantProperty(borderHeight);
|
|
2218
|
-
}
|
|
2219
|
-
var oldWidth = getValue(params.viewer, cEntityBorder.corridor.width);
|
|
2220
|
-
if (oldWidth != width) {
|
|
2221
|
-
cEntityBorder.corridor.width = new Cesium.ConstantProperty(width);
|
|
2222
|
-
}
|
|
2223
|
-
var oldZIndex = getValue(params.viewer, cEntityBorder.corridor.zIndex);
|
|
2224
|
-
if (oldZIndex != zIndex + 1) {
|
|
2225
|
-
cEntityBorder.corridor.zIndex = new Cesium.ConstantProperty(zIndex + 1);
|
|
2226
|
-
}
|
|
2227
|
-
var oldMaterial = getValue(params.viewer, cEntityBorder.corridor.material);
|
|
2228
|
-
var newMaterial = new Cesium.ColorMaterialProperty(cLineColor);
|
|
2229
|
-
if (compareColorMaterials(params.viewer, oldMaterial, newMaterial)) {
|
|
2230
|
-
cEntityBorder.corridor.material = newMaterial;
|
|
2231
|
-
}
|
|
2232
|
-
cEntityBorder.corridor.fill = new Cesium.ConstantProperty(true);
|
|
2233
|
-
cEntityBorder.corridor.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance, width));
|
|
2234
|
-
cEntityBorder.polyline = undefined;
|
|
2235
|
-
}
|
|
2236
|
-
cEntityBorder.show = true;
|
|
2237
|
-
}
|
|
2238
|
-
cEntityBorder._parentEntity = cEntity;
|
|
2239
|
-
cEntity._siblingGraphics.push(cEntityBorder);
|
|
2240
|
-
for (var i = 0; i < holePosses.length; i++) {
|
|
2241
|
-
var posses_1 = holePosses[i];
|
|
2242
|
-
bruce_models_1.Cartes.CloseRing3(posses_1);
|
|
2243
|
-
var cEntityHole = new Cesium.Entity({
|
|
2244
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
2245
|
-
polyline: units == "px" ? new Cesium.PolylineGraphics({
|
|
2246
|
-
positions: posses_1,
|
|
2247
|
-
material: cLineColor,
|
|
2248
|
-
width: width,
|
|
2249
|
-
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
2250
|
-
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
2251
|
-
arcType: Cesium.ArcType.GEODESIC,
|
|
2252
|
-
zIndex: zIndex,
|
|
2253
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
2254
|
-
}) : null,
|
|
2255
|
-
corridor: units == "m" ? {
|
|
2256
|
-
positions: borderPosses,
|
|
2257
|
-
material: cLineColor,
|
|
2258
|
-
heightReference: heightRef,
|
|
2259
|
-
height: borderHeight,
|
|
2260
|
-
width: width,
|
|
2261
|
-
fill: true,
|
|
2262
|
-
zIndex: zIndex + 1,
|
|
2263
|
-
cornerType: Cesium.CornerType.MITERED,
|
|
2264
|
-
classificationType: classification,
|
|
2265
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance, width),
|
|
2266
|
-
shadows: Cesium.ShadowMode.ENABLED,
|
|
2267
|
-
} : null,
|
|
2268
|
-
show: true
|
|
2269
|
-
});
|
|
2270
|
-
cEntity._siblingGraphics.push(cEntityHole);
|
|
2271
|
-
cEntityHole._parentEntity = cEntity;
|
|
2272
|
-
}
|
|
2273
|
-
}
|
|
2274
|
-
else {
|
|
2275
|
-
cEntity._siblingGraphics = [];
|
|
2276
|
-
}
|
|
2277
|
-
return cEntity;
|
|
2278
|
-
}
|
|
2279
|
-
Polygon.Render = Render;
|
|
2280
|
-
function RenderGroup(params) {
|
|
2281
|
-
var _a, _b, _c;
|
|
2282
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2283
|
-
var api, cEntities, i, entity, zoomItem, style, _d, tagIds, tags, pStyle, cEntity, name_4;
|
|
2284
|
-
return __generator(this, function (_e) {
|
|
2285
|
-
switch (_e.label) {
|
|
2286
|
-
case 0:
|
|
2287
|
-
api = params.apiGetter.getApi();
|
|
2288
|
-
cEntities = new Map();
|
|
2289
|
-
i = 0;
|
|
2290
|
-
_e.label = 1;
|
|
2291
|
-
case 1:
|
|
2292
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 9];
|
|
2293
|
-
entity = params.entities[i];
|
|
2294
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
2295
|
-
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 3];
|
|
2296
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
2297
|
-
case 2:
|
|
2298
|
-
_d = (_a = (_e.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
2299
|
-
return [3 /*break*/, 4];
|
|
2300
|
-
case 3:
|
|
2301
|
-
_d = zoomItem.Style;
|
|
2302
|
-
_e.label = 4;
|
|
2303
|
-
case 4:
|
|
2304
|
-
style = _d;
|
|
2305
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
2306
|
-
tags = [];
|
|
2307
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 6];
|
|
2308
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
2309
|
-
api: api,
|
|
2310
|
-
tagIds: tagIds
|
|
2311
|
-
})];
|
|
2312
|
-
case 5:
|
|
2313
|
-
tags = (_e.sent()).tags;
|
|
2314
|
-
_e.label = 6;
|
|
2315
|
-
case 6:
|
|
2316
|
-
pStyle = (_b = style === null || style === void 0 ? void 0 : style.polygonStyle) !== null && _b !== void 0 ? _b : {};
|
|
2317
|
-
cEntity = Render({
|
|
2318
|
-
entity: entity,
|
|
2319
|
-
style: pStyle,
|
|
2320
|
-
tags: tags,
|
|
2321
|
-
viewer: params.viewer,
|
|
2322
|
-
maxDistance: zoomItem.MaxZoom,
|
|
2323
|
-
minDistance: zoomItem.MinZoom,
|
|
2324
|
-
// Temporarily disabling re-using graphics for polygons as they have some bugs, and
|
|
2325
|
-
// they don't support any animation yet.
|
|
2326
|
-
// rendered: null
|
|
2327
|
-
rendered: (_c = params.rendered) === null || _c === void 0 ? void 0 : _c.get(entity.Bruce.ID)
|
|
2328
|
-
});
|
|
2329
|
-
if (!cEntity) return [3 /*break*/, 8];
|
|
2330
|
-
return [4 /*yield*/, getName(api, entity)];
|
|
2331
|
-
case 7:
|
|
2332
|
-
name_4 = _e.sent();
|
|
2333
|
-
cEntity.name = name_4;
|
|
2334
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
2335
|
-
cEntities.set(entity.Bruce.ID, cEntity);
|
|
2336
|
-
_e.label = 8;
|
|
2337
|
-
case 8:
|
|
2338
|
-
i++;
|
|
2339
|
-
return [3 /*break*/, 1];
|
|
2340
|
-
case 9: return [2 /*return*/, cEntities];
|
|
2341
|
-
}
|
|
2342
|
-
});
|
|
2343
|
-
});
|
|
2344
|
-
}
|
|
2345
|
-
Polygon.RenderGroup = RenderGroup;
|
|
407
|
+
Polygon.RenderGroup = entity_render_engine_polygon_1.EntityRenderEnginePolygon.RenderGroup;
|
|
408
|
+
Polygon.Render = entity_render_engine_polygon_1.EntityRenderEnginePolygon.Render;
|
|
2346
409
|
})(Polygon = EntityRenderEngine.Polygon || (EntityRenderEngine.Polygon = {}));
|
|
2347
410
|
var Model3d;
|
|
2348
411
|
(function (Model3d) {
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
var scale = (0, js_utils_1.EnsureNumber)(transform === null || transform === void 0 ? void 0 : transform.scale, 1);
|
|
2364
|
-
if (scale <= 0) {
|
|
2365
|
-
scale = 1;
|
|
2366
|
-
}
|
|
2367
|
-
var style = params.style;
|
|
2368
|
-
var styleScale = (style === null || style === void 0 ? void 0 : style.scale) ? bruce_models_1.Calculator.GetNumber(style === null || style === void 0 ? void 0 : style.scale, entity, params.tags) : null;
|
|
2369
|
-
styleScale = (0, js_utils_1.EnsureNumber)(styleScale ? styleScale : 1);
|
|
2370
|
-
if (styleScale <= 0) {
|
|
2371
|
-
styleScale = 1;
|
|
2372
|
-
}
|
|
2373
|
-
var heightRef = getHeightRef(style, Cesium.HeightReference.RELATIVE_TO_GROUND);
|
|
2374
|
-
var pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
2375
|
-
viewer: params.viewer,
|
|
2376
|
-
entity: entity,
|
|
2377
|
-
recordHeightRef: heightRef,
|
|
2378
|
-
returnHeightRef: heightRef,
|
|
2379
|
-
allowRendered: false
|
|
2380
|
-
});
|
|
2381
|
-
var blendMode = null;
|
|
2382
|
-
var blendAmount = null;
|
|
2383
|
-
var color = null;
|
|
2384
|
-
if (style === null || style === void 0 ? void 0 : style.customize) {
|
|
2385
|
-
blendMode = style.fillColorBlendMode;
|
|
2386
|
-
if (!blendMode) {
|
|
2387
|
-
blendMode = Cesium.ColorBlendMode.HIGHLIGHT;
|
|
2388
|
-
}
|
|
2389
|
-
if (blendMode == Cesium.ColorBlendMode.MIX) {
|
|
2390
|
-
blendAmount = style.fillColorBlendAmount;
|
|
2391
|
-
if (!blendAmount) {
|
|
2392
|
-
blendAmount = 0.5;
|
|
2393
|
-
}
|
|
2394
|
-
}
|
|
2395
|
-
var bColor = bruce_models_1.Calculator.GetColor(style.fillColor, entity, params.tags);
|
|
2396
|
-
if (bColor) {
|
|
2397
|
-
color = colorToCColor(bColor);
|
|
2398
|
-
}
|
|
2399
|
-
}
|
|
2400
|
-
var animateScale = null;
|
|
2401
|
-
var cEntity = params.rendered;
|
|
2402
|
-
if (!cEntity || !cEntity.model) {
|
|
2403
|
-
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
2404
|
-
var orientation_1 = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
|
|
2405
|
-
if (!color) {
|
|
2406
|
-
color = Cesium.Color.WHITE.clone();
|
|
2407
|
-
}
|
|
2408
|
-
var animateColor_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateColor({
|
|
2409
|
-
durationMs: 1500,
|
|
2410
|
-
targetColor: color,
|
|
2411
|
-
startColor: color.clone().withAlpha(0.001),
|
|
2412
|
-
viewer: params.viewer
|
|
2413
|
-
});
|
|
2414
|
-
var position = null;
|
|
2415
|
-
// If we have a series of time-based positions then we'll animate as time changes.
|
|
2416
|
-
var series = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
2417
|
-
if (series.length > 1) {
|
|
2418
|
-
var animatePosition_3 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
2419
|
-
posses: series,
|
|
2420
|
-
viewer: params.viewer
|
|
2421
|
-
});
|
|
2422
|
-
position = new Cesium.CallbackProperty(function () { return animatePosition_3.GetValue(); }, false);
|
|
2423
|
-
}
|
|
2424
|
-
else {
|
|
2425
|
-
position = new Cesium.CallbackProperty(function () { return entity_utils_1.EntityUtils.GetPos({
|
|
2426
|
-
viewer: params.viewer,
|
|
2427
|
-
entity: entity,
|
|
2428
|
-
recordHeightRef: heightRef,
|
|
2429
|
-
returnHeightRef: heightRef,
|
|
2430
|
-
allowRendered: false
|
|
2431
|
-
}); }, true);
|
|
2432
|
-
}
|
|
2433
|
-
cEntity = new Cesium.Entity({
|
|
2434
|
-
id: bruce_models_1.ObjectUtils.UId(10),
|
|
2435
|
-
model: {
|
|
2436
|
-
uri: params.lodUrl,
|
|
2437
|
-
heightReference: heightRef,
|
|
2438
|
-
scale: new Cesium.CallbackProperty(function () { return scale * styleScale; }, true),
|
|
2439
|
-
shadows: Cesium.ShadowMode.ENABLED,
|
|
2440
|
-
colorBlendAmount: blendAmount,
|
|
2441
|
-
colorBlendMode: blendMode,
|
|
2442
|
-
color: new Cesium.CallbackProperty(function () {
|
|
2443
|
-
var color = animateColor_1.GetColor();
|
|
2444
|
-
if (animateColor_1.IsDone() && (cEntity === null || cEntity === void 0 ? void 0 : cEntity.model)) {
|
|
2445
|
-
cEntity.model.color = new Cesium.CallbackProperty(function () { return color; }, true);
|
|
2446
|
-
}
|
|
2447
|
-
return color;
|
|
2448
|
-
}, false),
|
|
2449
|
-
distanceDisplayCondition: getDisplayCondition(params.minDistance, params.maxDistance)
|
|
2450
|
-
},
|
|
2451
|
-
orientation: new Cesium.CallbackProperty(function () { return orientation_1; }, true),
|
|
2452
|
-
position: position,
|
|
2453
|
-
show: true
|
|
2454
|
-
});
|
|
2455
|
-
cesium_entity_styler_1.CesiumEntityStyler.BakeDefaultColor({
|
|
2456
|
-
entity: cEntity,
|
|
2457
|
-
viewer: params.viewer,
|
|
2458
|
-
override: true,
|
|
2459
|
-
colors: {
|
|
2460
|
-
"model": color
|
|
2461
|
-
},
|
|
2462
|
-
refresh: false
|
|
2463
|
-
});
|
|
2464
|
-
}
|
|
2465
|
-
else {
|
|
2466
|
-
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
2467
|
-
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
2468
|
-
entity: cEntity
|
|
2469
|
-
});
|
|
2470
|
-
if (parts.length > 1) {
|
|
2471
|
-
// Kill all expect last part. Last one is the primary entity.
|
|
2472
|
-
for (var i = 0; i < parts.length - 1; i++) {
|
|
2473
|
-
var part = parts[i];
|
|
2474
|
-
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part)) {
|
|
2475
|
-
params.viewer.entities.remove(part);
|
|
2476
|
-
}
|
|
2477
|
-
}
|
|
2478
|
-
cEntity._siblingGraphics = [];
|
|
2479
|
-
if (cEntity._parentEntity) {
|
|
2480
|
-
console.warn("Model3d.Render: Parent entity was not null. This should not happen.");
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
var currentUri = getValue(params.viewer, cEntity.model.uri);
|
|
2484
|
-
if (currentUri != params.lodUrl) {
|
|
2485
|
-
cEntity.model.uri = new Cesium.ConstantProperty(params.lodUrl);
|
|
2486
|
-
}
|
|
2487
|
-
cEntity.model.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
2488
|
-
cEntity.model.shadows = new Cesium.ConstantProperty(Cesium.ShadowMode.ENABLED);
|
|
2489
|
-
cEntity.model.colorBlendAmount = new Cesium.ConstantProperty(blendAmount);
|
|
2490
|
-
cEntity.model.colorBlendMode = new Cesium.ConstantProperty(blendMode);
|
|
2491
|
-
cEntity.model.distanceDisplayCondition = new Cesium.ConstantProperty(getDisplayCondition(params.minDistance, params.maxDistance));
|
|
2492
|
-
// If we have a series of time-based positions then we'll animate as time changes.
|
|
2493
|
-
var series = getSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
2494
|
-
if (series.length > 1) {
|
|
2495
|
-
var animatePosition_4 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
2496
|
-
posses: series,
|
|
2497
|
-
viewer: params.viewer
|
|
2498
|
-
});
|
|
2499
|
-
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition_4.GetValue(); }, false);
|
|
2500
|
-
}
|
|
2501
|
-
else {
|
|
2502
|
-
var prevPos3d = getValue(params.viewer, cEntity.position);
|
|
2503
|
-
var posChanged = !prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d);
|
|
2504
|
-
var animatePosition_5 = null;
|
|
2505
|
-
if (posChanged) {
|
|
2506
|
-
animatePosition_5 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePosition({
|
|
2507
|
-
durationMs: 200,
|
|
2508
|
-
targetPos3d: pos3d,
|
|
2509
|
-
viewer: params.viewer,
|
|
2510
|
-
startPos3d: prevPos3d
|
|
2511
|
-
});
|
|
2512
|
-
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition_5.GetValue(); }, false);
|
|
2513
|
-
}
|
|
2514
|
-
}
|
|
2515
|
-
// cEntity.orientation = new Cesium.ConstantProperty(orientation);
|
|
2516
|
-
var prevHeading = cEntity.model._heading;
|
|
2517
|
-
if (prevHeading == null || prevHeading == heading || isNaN(prevHeading)) {
|
|
2518
|
-
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
2519
|
-
var orient_1 = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
|
|
2520
|
-
cEntity.orientation = new Cesium.CallbackProperty(function () { return orient_1; }, true);
|
|
2521
|
-
}
|
|
2522
|
-
// Animate orientation. We'll calculate the heading based on movement.
|
|
2523
|
-
else {
|
|
2524
|
-
var animateHeading_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateHeading({
|
|
2525
|
-
durationMs: 200,
|
|
2526
|
-
targetHeading: heading,
|
|
2527
|
-
viewer: params.viewer,
|
|
2528
|
-
startHeading: prevHeading
|
|
2529
|
-
});
|
|
2530
|
-
cEntity.orientation = new Cesium.CallbackProperty(function () {
|
|
2531
|
-
var calcHeading = animateHeading_1.GetValue();
|
|
2532
|
-
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(calcHeading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
2533
|
-
var orient = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
|
|
2534
|
-
// We'll stop the costly animation if it's done.
|
|
2535
|
-
if (animateHeading_1.IsDone()) {
|
|
2536
|
-
cEntity.orientation = new Cesium.ConstantProperty(orient);
|
|
2537
|
-
}
|
|
2538
|
-
return orient;
|
|
2539
|
-
}, false);
|
|
2540
|
-
}
|
|
2541
|
-
// Same file but different scale. We'll animate the scale.
|
|
2542
|
-
var prevClientFileId = cEntity.model._clientFileId;
|
|
2543
|
-
if (prevClientFileId == params.lodClientFileId) {
|
|
2544
|
-
animateScale = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateNumber({
|
|
2545
|
-
durationMs: 200,
|
|
2546
|
-
targetValue: scale * styleScale,
|
|
2547
|
-
viewer: params.viewer,
|
|
2548
|
-
startValue: cEntity.model.scale,
|
|
2549
|
-
startPaused: true
|
|
2550
|
-
});
|
|
2551
|
-
cEntity.model.scale = new Cesium.CallbackProperty(function () { return animateScale.GetValue(); }, false);
|
|
2552
|
-
}
|
|
2553
|
-
else {
|
|
2554
|
-
cEntity.model.scale = new Cesium.CallbackProperty(function () { return scale * styleScale; }, true);
|
|
2555
|
-
}
|
|
2556
|
-
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
2557
|
-
// cEntity.model.color = new Cesium.CallbackProperty(() => color, true);
|
|
2558
|
-
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
2559
|
-
color: color ? color : new Cesium.Color(),
|
|
2560
|
-
entity: cEntity,
|
|
2561
|
-
viewer: params.viewer,
|
|
2562
|
-
override: true,
|
|
2563
|
-
requestRender: false
|
|
2564
|
-
});
|
|
2565
|
-
cEntity.show = true;
|
|
2566
|
-
}
|
|
2567
|
-
var fileRadiusKey = "model3d_".concat(params.lodUrl, "_").concat(scale * styleScale, "_radius");
|
|
2568
|
-
var heightProm = _fileRadiusCache.Get(fileRadiusKey);
|
|
2569
|
-
if (!heightProm) {
|
|
2570
|
-
heightProm = new Promise(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
2571
|
-
var modelPrim_1, onReady_1, readyEventRemoval_1, e_6;
|
|
2572
|
-
return __generator(this, function (_a) {
|
|
2573
|
-
switch (_a.label) {
|
|
2574
|
-
case 0:
|
|
2575
|
-
_a.trys.push([0, 2, , 3]);
|
|
2576
|
-
return [4 /*yield*/, getModelEntity(params.lodUrl, scale * styleScale)];
|
|
2577
|
-
case 1:
|
|
2578
|
-
modelPrim_1 = _a.sent();
|
|
2579
|
-
onReady_1 = function () {
|
|
2580
|
-
readyEventRemoval_1 === null || readyEventRemoval_1 === void 0 ? void 0 : readyEventRemoval_1();
|
|
2581
|
-
readyEventRemoval_1 = null;
|
|
2582
|
-
var kill = function () {
|
|
2583
|
-
if (params.viewer && !params.viewer.isDestroyed() && params.viewer.scene.primitives.contains(modelPrim_1)) {
|
|
2584
|
-
params.viewer.scene.primitives.remove(modelPrim_1);
|
|
2585
|
-
}
|
|
2586
|
-
if (!modelPrim_1.isDestroyed()) {
|
|
2587
|
-
modelPrim_1.destroy();
|
|
2588
|
-
}
|
|
2589
|
-
};
|
|
2590
|
-
if (!cEntity || !(modelPrim_1 === null || modelPrim_1 === void 0 ? void 0 : modelPrim_1.boundingSphere)) {
|
|
2591
|
-
kill();
|
|
2592
|
-
res(null);
|
|
2593
|
-
return;
|
|
2594
|
-
}
|
|
2595
|
-
var radius = modelPrim_1.boundingSphere.radius;
|
|
2596
|
-
var centerOffset = modelPrim_1.boundingSphere.center;
|
|
2597
|
-
if (centerOffset) {
|
|
2598
|
-
// Add the center offset to the radius because I am not good at math.
|
|
2599
|
-
var magnitude = Cesium.Cartesian3.magnitude(centerOffset);
|
|
2600
|
-
radius += magnitude;
|
|
2601
|
-
// Extra padding if the model is super not centered.
|
|
2602
|
-
// I saw some strange boundaries for some bad models.
|
|
2603
|
-
if (magnitude > 100) {
|
|
2604
|
-
radius += 100;
|
|
2605
|
-
}
|
|
2606
|
-
}
|
|
2607
|
-
kill();
|
|
2608
|
-
res(radius);
|
|
2609
|
-
};
|
|
2610
|
-
readyEventRemoval_1 = null;
|
|
2611
|
-
// Newer Cesium versions have readyEvent. They don't use readyPromise.
|
|
2612
|
-
if (modelPrim_1["readyEvent"]) {
|
|
2613
|
-
modelPrim_1["readyEvent"].addEventListener(onReady_1);
|
|
2614
|
-
}
|
|
2615
|
-
// Older Cesium versions don't have readyEvent, they use readyPromise.
|
|
2616
|
-
else if (modelPrim_1["readyPromise"]) {
|
|
2617
|
-
modelPrim_1["readyPromise"].then(function () {
|
|
2618
|
-
onReady_1();
|
|
2619
|
-
}).catch(function (e) {
|
|
2620
|
-
console.error(e);
|
|
2621
|
-
res(null);
|
|
2622
|
-
});
|
|
2623
|
-
}
|
|
2624
|
-
params.viewer.scene.primitives.add(modelPrim_1);
|
|
2625
|
-
return [3 /*break*/, 3];
|
|
2626
|
-
case 2:
|
|
2627
|
-
e_6 = _a.sent();
|
|
2628
|
-
console.error(e_6);
|
|
2629
|
-
res(null);
|
|
2630
|
-
return [3 /*break*/, 3];
|
|
2631
|
-
case 3: return [2 /*return*/];
|
|
2632
|
-
}
|
|
2633
|
-
});
|
|
2634
|
-
}); });
|
|
2635
|
-
_fileRadiusCache.Set(fileRadiusKey, heightProm);
|
|
2636
|
-
}
|
|
2637
|
-
heightProm.then(function (radius) {
|
|
2638
|
-
if (model) {
|
|
2639
|
-
model._radius = radius;
|
|
2640
|
-
model._radiusLoaded = true;
|
|
2641
|
-
if (params.viewer && params.viewer.scene && !params.viewer.isDestroyed()) {
|
|
2642
|
-
visual_register_culler_1.VisualRegisterCuller.MarkShouldRecheck(params.viewer);
|
|
2643
|
-
}
|
|
2644
|
-
}
|
|
2645
|
-
// Rough estimate on when the model is ready in the scene.
|
|
2646
|
-
if (animateScale) {
|
|
2647
|
-
animateScale.Play();
|
|
2648
|
-
}
|
|
2649
|
-
});
|
|
2650
|
-
var model = cEntity.model;
|
|
2651
|
-
model._radiusLoaded = false;
|
|
2652
|
-
model._clientFileId = params.lodClientFileId;
|
|
2653
|
-
model._entityScale = {
|
|
2654
|
-
record: scale,
|
|
2655
|
-
style: styleScale
|
|
2656
|
-
};
|
|
2657
|
-
model._heading = heading;
|
|
2658
|
-
return cEntity;
|
|
412
|
+
Model3d.Render = entity_render_engine_model3d_1.EntityRenderEngineModel3d.Render;
|
|
413
|
+
Model3d.RenderGroup = entity_render_engine_model3d_1.EntityRenderEngineModel3d.RenderGroup;
|
|
414
|
+
})(Model3d = EntityRenderEngine.Model3d || (EntityRenderEngine.Model3d = {}));
|
|
415
|
+
/**
|
|
416
|
+
* @param min
|
|
417
|
+
* @param max
|
|
418
|
+
* @param meterSize size of "thing" in meters, eg polyline is 0.5 meters width. If size is provided we can potentially cull it earlier.
|
|
419
|
+
* @param isPolygon
|
|
420
|
+
* @returns
|
|
421
|
+
*/
|
|
422
|
+
function GetDisplayCondition(min, max, meterSize, isPolygon) {
|
|
423
|
+
// Max is required.
|
|
424
|
+
if (isNaN(+max)) {
|
|
425
|
+
return undefined;
|
|
2659
426
|
}
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2664
|
-
var api, cEntities, reqBody, i, entity, zoomItem, style, _g, tagIds, tags, mStyle, group, level, catId, lodData, _loop_2, i;
|
|
2665
|
-
return __generator(this, function (_h) {
|
|
2666
|
-
switch (_h.label) {
|
|
2667
|
-
case 0:
|
|
2668
|
-
api = params.apiGetter.getApi();
|
|
2669
|
-
return [4 /*yield*/, api.Loading];
|
|
2670
|
-
case 1:
|
|
2671
|
-
_h.sent();
|
|
2672
|
-
cEntities = new Map();
|
|
2673
|
-
reqBody = {
|
|
2674
|
-
"strict": false,
|
|
2675
|
-
"externalSources": false,
|
|
2676
|
-
"Items": []
|
|
2677
|
-
};
|
|
2678
|
-
i = 0;
|
|
2679
|
-
_h.label = 2;
|
|
2680
|
-
case 2:
|
|
2681
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 9];
|
|
2682
|
-
entity = params.entities[i];
|
|
2683
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
2684
|
-
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 4];
|
|
2685
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
2686
|
-
case 3:
|
|
2687
|
-
_g = (_a = (_h.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
2688
|
-
return [3 /*break*/, 5];
|
|
2689
|
-
case 4:
|
|
2690
|
-
_g = zoomItem.Style;
|
|
2691
|
-
_h.label = 5;
|
|
2692
|
-
case 5:
|
|
2693
|
-
style = _g;
|
|
2694
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
2695
|
-
tags = [];
|
|
2696
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 7];
|
|
2697
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
2698
|
-
api: api,
|
|
2699
|
-
tagIds: tagIds
|
|
2700
|
-
})];
|
|
2701
|
-
case 6:
|
|
2702
|
-
tags = (_h.sent()).tags;
|
|
2703
|
-
_h.label = 7;
|
|
2704
|
-
case 7:
|
|
2705
|
-
mStyle = (_b = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _b !== void 0 ? _b : {};
|
|
2706
|
-
group = mStyle.lodGroup ? bruce_models_1.Calculator.GetString(mStyle.lodGroup, entity, tags) : null;
|
|
2707
|
-
if (!group) {
|
|
2708
|
-
group = "DEFAULT";
|
|
2709
|
-
}
|
|
2710
|
-
level = +zoomItem.LODLevel;
|
|
2711
|
-
if (!level) {
|
|
2712
|
-
level = 0;
|
|
2713
|
-
}
|
|
2714
|
-
catId = zoomItem.LODCategoryID;
|
|
2715
|
-
if (!catId) {
|
|
2716
|
-
catId = "glb";
|
|
2717
|
-
}
|
|
2718
|
-
reqBody.Items.push({
|
|
2719
|
-
"entityId": entity.Bruce.ID,
|
|
2720
|
-
"categoryId": catId,
|
|
2721
|
-
"group": group,
|
|
2722
|
-
"level": level
|
|
2723
|
-
});
|
|
2724
|
-
_h.label = 8;
|
|
2725
|
-
case 8:
|
|
2726
|
-
i++;
|
|
2727
|
-
return [3 /*break*/, 2];
|
|
2728
|
-
case 9: return [4 /*yield*/, bruce_models_1.EntityLod.GetLods({
|
|
2729
|
-
api: api,
|
|
2730
|
-
filter: reqBody
|
|
2731
|
-
})];
|
|
2732
|
-
case 10:
|
|
2733
|
-
lodData = (_h.sent()).lods;
|
|
2734
|
-
_loop_2 = function (i) {
|
|
2735
|
-
var entity, zoomItem, style, _j, tagIds, tags, lod, mStyle, cEntity, name_5;
|
|
2736
|
-
return __generator(this, function (_k) {
|
|
2737
|
-
switch (_k.label) {
|
|
2738
|
-
case 0:
|
|
2739
|
-
entity = params.entities[i];
|
|
2740
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
2741
|
-
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 2];
|
|
2742
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
2743
|
-
case 1:
|
|
2744
|
-
_j = (_c = (_k.sent())) === null || _c === void 0 ? void 0 : _c.Settings;
|
|
2745
|
-
return [3 /*break*/, 3];
|
|
2746
|
-
case 2:
|
|
2747
|
-
_j = zoomItem.Style;
|
|
2748
|
-
_k.label = 3;
|
|
2749
|
-
case 3:
|
|
2750
|
-
style = _j;
|
|
2751
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
2752
|
-
tags = [];
|
|
2753
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 5];
|
|
2754
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
2755
|
-
api: api,
|
|
2756
|
-
tagIds: tagIds
|
|
2757
|
-
})];
|
|
2758
|
-
case 4:
|
|
2759
|
-
tags = (_k.sent()).tags;
|
|
2760
|
-
_k.label = 5;
|
|
2761
|
-
case 5:
|
|
2762
|
-
lod = lodData.find(function (x) { return x.entityId == entity.Bruce.ID; });
|
|
2763
|
-
if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
|
|
2764
|
-
return [2 /*return*/, "continue"];
|
|
2765
|
-
}
|
|
2766
|
-
mStyle = (_d = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _d !== void 0 ? _d : {};
|
|
2767
|
-
cEntity = Render({
|
|
2768
|
-
rendered: (_e = params.rendered) === null || _e === void 0 ? void 0 : _e.get(entity.Bruce.ID),
|
|
2769
|
-
entity: entity,
|
|
2770
|
-
entityHistoric: (_f = params.entitiesHistoric) === null || _f === void 0 ? void 0 : _f[entity.Bruce.ID],
|
|
2771
|
-
style: mStyle,
|
|
2772
|
-
tags: tags,
|
|
2773
|
-
viewer: params.viewer,
|
|
2774
|
-
lodUrl: bruce_models_1.ClientFile.GetUrl({
|
|
2775
|
-
api: api,
|
|
2776
|
-
fileId: lod.clientFileId,
|
|
2777
|
-
viaCdn: true
|
|
2778
|
-
}),
|
|
2779
|
-
lodClientFileId: lod.clientFileId,
|
|
2780
|
-
maxDistance: zoomItem.MaxZoom,
|
|
2781
|
-
minDistance: zoomItem.MinZoom
|
|
2782
|
-
});
|
|
2783
|
-
if (!cEntity) return [3 /*break*/, 7];
|
|
2784
|
-
return [4 /*yield*/, getName(api, entity)];
|
|
2785
|
-
case 6:
|
|
2786
|
-
name_5 = _k.sent();
|
|
2787
|
-
cEntity.name = name_5;
|
|
2788
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
2789
|
-
cEntities.set(entity.Bruce.ID, cEntity);
|
|
2790
|
-
_k.label = 7;
|
|
2791
|
-
case 7: return [2 /*return*/];
|
|
2792
|
-
}
|
|
2793
|
-
});
|
|
2794
|
-
};
|
|
2795
|
-
i = 0;
|
|
2796
|
-
_h.label = 11;
|
|
2797
|
-
case 11:
|
|
2798
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 14];
|
|
2799
|
-
return [5 /*yield**/, _loop_2(i)];
|
|
2800
|
-
case 12:
|
|
2801
|
-
_h.sent();
|
|
2802
|
-
_h.label = 13;
|
|
2803
|
-
case 13:
|
|
2804
|
-
i++;
|
|
2805
|
-
return [3 /*break*/, 11];
|
|
2806
|
-
case 14: return [2 /*return*/, cEntities];
|
|
2807
|
-
}
|
|
2808
|
-
});
|
|
2809
|
-
});
|
|
427
|
+
// Min is optional.
|
|
428
|
+
if (isNaN(+min)) {
|
|
429
|
+
min = 0;
|
|
2810
430
|
}
|
|
2811
|
-
|
|
2812
|
-
|
|
431
|
+
// Adjusting slightly because I distrust our initial calculation vs Cesium's one.
|
|
432
|
+
max = (+max) * 1.2;
|
|
433
|
+
min = +min;
|
|
434
|
+
if (min > 0) {
|
|
435
|
+
min = (+min) * 0.8;
|
|
436
|
+
}
|
|
437
|
+
meterSize = +meterSize;
|
|
438
|
+
if (!isNaN(meterSize) && meterSize > 0) {
|
|
439
|
+
// A 1m thing at 2000m distance is barely visible, so we can cull it.
|
|
440
|
+
// So we'll multiply this magic distance by the size of the thing and determine when it'll be too small to see.
|
|
441
|
+
var METER_DISTANCE_PER_METER = isPolygon ? 100 : 2000;
|
|
442
|
+
var newMax = meterSize * METER_DISTANCE_PER_METER;
|
|
443
|
+
// Enforcing a minimum max distance in case something goes wrong we want stuff to always be visible when close.
|
|
444
|
+
var MIN_MAX = 300;
|
|
445
|
+
newMax = Math.max(newMax, MIN_MAX);
|
|
446
|
+
//console.log(`meterSize ${isPolygon ? "polygon" : "thing"} of ${meterSize}m was provided so max was changed from ${max}m to ${Math.min(newMax, max)}m`)
|
|
447
|
+
max = Math.min(newMax, max);
|
|
448
|
+
if (max < min) {
|
|
449
|
+
return undefined;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return new Cesium.DistanceDisplayCondition(min, max);
|
|
453
|
+
}
|
|
454
|
+
EntityRenderEngine.GetDisplayCondition = GetDisplayCondition;
|
|
2813
455
|
})(EntityRenderEngine = exports.EntityRenderEngine || (exports.EntityRenderEngine = {}));
|
|
2814
456
|
//# sourceMappingURL=entity-render-engine.js.map
|