bruce-cesium 4.4.4 → 4.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bruce-cesium.es5.js +4510 -3712
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +4485 -3699
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +5 -1
- package/dist/lib/bruce-cesium.js.map +1 -1
- package/dist/lib/internal/cesium-utils.js +92 -5
- package/dist/lib/internal/cesium-utils.js.map +1 -1
- package/dist/lib/rendering/cesium-animated-property.js +149 -0
- package/dist/lib/rendering/cesium-animated-property.js.map +1 -1
- package/dist/lib/rendering/entity-render-engine-model3d.js +809 -0
- package/dist/lib/rendering/entity-render-engine-model3d.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-point.js +995 -0
- package/dist/lib/rendering/entity-render-engine-point.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js +756 -0
- package/dist/lib/rendering/entity-render-engine-polygon.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine-polyline.js +516 -0
- package/dist/lib/rendering/entity-render-engine-polyline.js.map +1 -0
- package/dist/lib/rendering/entity-render-engine.js +62 -2420
- package/dist/lib/rendering/entity-render-engine.js.map +1 -1
- package/dist/lib/rendering/render-managers/data-source/data-source-static-csv-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +15 -0
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js.map +1 -1
- package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js +18 -0
- package/dist/lib/rendering/render-managers/tilesets/tileset-arb-render-manager.js.map +1 -1
- package/dist/lib/utils/view-utils.js +2 -2
- package/dist/lib/utils/view-utils.js.map +1 -1
- package/dist/lib/widgets/common/draw-3d-polyline.js +0 -8
- package/dist/lib/widgets/common/draw-3d-polyline.js.map +1 -1
- package/dist/types/bruce-cesium.d.ts +5 -1
- package/dist/types/internal/cesium-utils.d.ts +22 -2
- package/dist/types/rendering/cesium-animated-property.d.ts +21 -0
- package/dist/types/rendering/entity-render-engine-model3d.d.ts +56 -0
- package/dist/types/rendering/entity-render-engine-point.d.ts +73 -0
- package/dist/types/rendering/entity-render-engine-polygon.d.ts +26 -0
- package/dist/types/rendering/entity-render-engine-polyline.d.ts +48 -0
- package/dist/types/rendering/entity-render-engine.d.ts +31 -98
- package/package.json +2 -2
|
@@ -0,0 +1,809 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.EntityRenderEngineModel3d = void 0;
|
|
40
|
+
var bruce_models_1 = require("bruce-models");
|
|
41
|
+
var cesium_animated_property_1 = require("./cesium-animated-property");
|
|
42
|
+
var Cesium = require("cesium");
|
|
43
|
+
var entity_render_engine_1 = require("./entity-render-engine");
|
|
44
|
+
var entity_utils_1 = require("../utils/entity-utils");
|
|
45
|
+
var js_utils_1 = require("../internal/js-utils");
|
|
46
|
+
var cesium_utils_1 = require("../internal/cesium-utils");
|
|
47
|
+
var cesium_entity_styler_1 = require("../utils/cesium-entity-styler");
|
|
48
|
+
var visual_register_culler_1 = require("./visual-register-culler");
|
|
49
|
+
/**
|
|
50
|
+
* Handles 3D model rendering.
|
|
51
|
+
*/
|
|
52
|
+
var EntityRenderEngineModel3d;
|
|
53
|
+
(function (EntityRenderEngineModel3d) {
|
|
54
|
+
/**
|
|
55
|
+
* Renders a single 3D model entity.
|
|
56
|
+
* This takes an optional prior Cesium Entity to update rather than create from scratch.
|
|
57
|
+
* @param params
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
function Render(params) {
|
|
61
|
+
var _this = this;
|
|
62
|
+
var _a, _b;
|
|
63
|
+
var entity = params.entity;
|
|
64
|
+
if (!params.entityHistoric) {
|
|
65
|
+
params.entityHistoric = [];
|
|
66
|
+
}
|
|
67
|
+
var transform = bruce_models_1.Entity.GetValue({
|
|
68
|
+
entity: entity,
|
|
69
|
+
path: ["Bruce", "Transform"]
|
|
70
|
+
});
|
|
71
|
+
var heading = (0, js_utils_1.EnsureNumber)(transform === null || transform === void 0 ? void 0 : transform.heading);
|
|
72
|
+
heading = (heading + 90) % 360;
|
|
73
|
+
var pitch = (0, js_utils_1.EnsureNumber)(transform === null || transform === void 0 ? void 0 : transform.pitch);
|
|
74
|
+
var roll = (0, js_utils_1.EnsureNumber)(transform === null || transform === void 0 ? void 0 : transform.roll);
|
|
75
|
+
var scale = (0, js_utils_1.EnsureNumber)(transform === null || transform === void 0 ? void 0 : transform.scale, 1);
|
|
76
|
+
if (scale <= 0) {
|
|
77
|
+
scale = 1;
|
|
78
|
+
}
|
|
79
|
+
var style = params.style;
|
|
80
|
+
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;
|
|
81
|
+
styleScale = (0, js_utils_1.EnsureNumber)(styleScale ? styleScale : 1);
|
|
82
|
+
if (styleScale <= 0) {
|
|
83
|
+
styleScale = 1;
|
|
84
|
+
}
|
|
85
|
+
var heightRef = getHeightRef(style, Cesium.HeightReference.RELATIVE_TO_GROUND);
|
|
86
|
+
var pos3d = entity_utils_1.EntityUtils.GetPos({
|
|
87
|
+
viewer: params.viewer,
|
|
88
|
+
entity: entity,
|
|
89
|
+
recordHeightRef: heightRef,
|
|
90
|
+
returnHeightRef: heightRef,
|
|
91
|
+
allowRendered: false
|
|
92
|
+
});
|
|
93
|
+
var blendMode = null;
|
|
94
|
+
var blendAmount = null;
|
|
95
|
+
var color = null;
|
|
96
|
+
if (style === null || style === void 0 ? void 0 : style.customize) {
|
|
97
|
+
blendMode = style.fillColorBlendMode;
|
|
98
|
+
if (!blendMode) {
|
|
99
|
+
blendMode = Cesium.ColorBlendMode.HIGHLIGHT;
|
|
100
|
+
}
|
|
101
|
+
if (blendMode == Cesium.ColorBlendMode.MIX) {
|
|
102
|
+
blendAmount = style.fillColorBlendAmount;
|
|
103
|
+
if (!blendAmount) {
|
|
104
|
+
blendAmount = 0.5;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
var bColor = bruce_models_1.Calculator.GetColor(style.fillColor, entity, params.tags);
|
|
108
|
+
if (bColor) {
|
|
109
|
+
color = (0, cesium_utils_1.ColorToCColor)(bColor);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
var siblings = [];
|
|
113
|
+
var animateScale = null;
|
|
114
|
+
var animatePosition = null;
|
|
115
|
+
var shouldShowTrack = false;
|
|
116
|
+
var prepareExistingGraphic = function (cEntity, maxSiblings) {
|
|
117
|
+
if (maxSiblings === void 0) { maxSiblings = 0; }
|
|
118
|
+
// Gather entity in case previous version had sibling graphics we no longer need.
|
|
119
|
+
var parts = entity_utils_1.EntityUtils.GatherEntity({
|
|
120
|
+
entity: cEntity,
|
|
121
|
+
});
|
|
122
|
+
if (parts.length > 1) {
|
|
123
|
+
// We'll cull all except the allowed number of siblings.
|
|
124
|
+
cEntity._siblingGraphics = cEntity._siblingGraphics.slice(0, maxSiblings);
|
|
125
|
+
// We'll remove all that aren't in the allowed (direct) list.
|
|
126
|
+
for (var i = 0; i < parts.length - 1; i++) {
|
|
127
|
+
var part = parts[i];
|
|
128
|
+
if (part && part instanceof Cesium.Entity && params.viewer.entities.contains(part) && !cEntity._siblingGraphics.includes(part)) {
|
|
129
|
+
params.viewer.entities.remove(part);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (cEntity._parentEntity) {
|
|
133
|
+
console.warn("Point.Render: Parent entity was not null. This should not happen.");
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
siblings = cEntity._siblingGraphics;
|
|
137
|
+
cEntity._siblingGraphics = [];
|
|
138
|
+
};
|
|
139
|
+
var updateShouldShowTrack = function () {
|
|
140
|
+
var _a, _b, _c;
|
|
141
|
+
if (!params.entityHistoricDrawTrack) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if ((_a = params.entityHistoric) === null || _a === void 0 ? void 0 : _a.length) {
|
|
145
|
+
var lStyle = (_c = (_b = params.fullStyle) === null || _b === void 0 ? void 0 : _b.polylineStyle) !== null && _c !== void 0 ? _c : {};
|
|
146
|
+
var width = lStyle.width ? (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(lStyle.width, entity, params.tags)) : 2;
|
|
147
|
+
if (width == null) {
|
|
148
|
+
width = 2;
|
|
149
|
+
}
|
|
150
|
+
width = (0, js_utils_1.EnsureNumber)(width);
|
|
151
|
+
if (width > 0.01) {
|
|
152
|
+
var bColor = lStyle.lineColor ? bruce_models_1.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
153
|
+
var cColor = bColor ? (0, cesium_utils_1.ColorToCColor)(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
154
|
+
if (cColor.alpha > 0) {
|
|
155
|
+
var seriesTrackPosses = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
156
|
+
seriesTrackPosses.reverse();
|
|
157
|
+
var posses = seriesTrackPosses.map(function (x) { return x.pos3d; });
|
|
158
|
+
posses = (0, cesium_utils_1.CullDuplicateCPosses)(posses);
|
|
159
|
+
shouldShowTrack = posses.length > 1;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
;
|
|
164
|
+
};
|
|
165
|
+
var cEntity = params.rendered;
|
|
166
|
+
if (!cEntity || !cEntity.model) {
|
|
167
|
+
updateShouldShowTrack();
|
|
168
|
+
if (!color) {
|
|
169
|
+
color = Cesium.Color.WHITE.clone();
|
|
170
|
+
}
|
|
171
|
+
var animateColor_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateColor({
|
|
172
|
+
durationMs: 1500,
|
|
173
|
+
targetColor: color,
|
|
174
|
+
startColor: color.clone().withAlpha(0.001),
|
|
175
|
+
viewer: params.viewer
|
|
176
|
+
});
|
|
177
|
+
var position = null;
|
|
178
|
+
// If we have a series of time-based positions then we'll animate as time changes.
|
|
179
|
+
var series = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
180
|
+
if (series.length > 1) {
|
|
181
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
182
|
+
posses: series,
|
|
183
|
+
viewer: params.viewer,
|
|
184
|
+
pitch: pitch,
|
|
185
|
+
roll: roll
|
|
186
|
+
});
|
|
187
|
+
position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
position = new Cesium.CallbackProperty(function () { return entity_utils_1.EntityUtils.GetPos({
|
|
191
|
+
viewer: params.viewer,
|
|
192
|
+
entity: entity,
|
|
193
|
+
recordHeightRef: heightRef,
|
|
194
|
+
returnHeightRef: heightRef,
|
|
195
|
+
allowRendered: false
|
|
196
|
+
}); }, true);
|
|
197
|
+
}
|
|
198
|
+
var getOrient = void 0;
|
|
199
|
+
if (animatePosition && animatePosition instanceof cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetOrient) {
|
|
200
|
+
getOrient = new Cesium.CallbackProperty(function () {
|
|
201
|
+
return animatePosition.GetOrient();
|
|
202
|
+
}, false);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
var hpr_1 = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
206
|
+
getOrient = new Cesium.CallbackProperty(function () {
|
|
207
|
+
return Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr_1);
|
|
208
|
+
}, false);
|
|
209
|
+
}
|
|
210
|
+
cEntity = new Cesium.Entity({
|
|
211
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
212
|
+
model: {
|
|
213
|
+
uri: params.lodUrl,
|
|
214
|
+
heightReference: heightRef,
|
|
215
|
+
scale: new Cesium.CallbackProperty(function () { return scale * styleScale; }, true),
|
|
216
|
+
shadows: Cesium.ShadowMode.ENABLED,
|
|
217
|
+
colorBlendAmount: blendAmount,
|
|
218
|
+
colorBlendMode: blendMode,
|
|
219
|
+
color: new Cesium.CallbackProperty(function () {
|
|
220
|
+
var color = animateColor_1.GetColor();
|
|
221
|
+
if (animateColor_1.IsDone() && (cEntity === null || cEntity === void 0 ? void 0 : cEntity.model)) {
|
|
222
|
+
cEntity.model.color = new Cesium.CallbackProperty(function () { return color; }, true);
|
|
223
|
+
}
|
|
224
|
+
return color;
|
|
225
|
+
}, false),
|
|
226
|
+
distanceDisplayCondition: entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance)
|
|
227
|
+
},
|
|
228
|
+
orientation: getOrient,
|
|
229
|
+
position: position,
|
|
230
|
+
show: true
|
|
231
|
+
});
|
|
232
|
+
cesium_entity_styler_1.CesiumEntityStyler.BakeDefaultColor({
|
|
233
|
+
entity: cEntity,
|
|
234
|
+
viewer: params.viewer,
|
|
235
|
+
override: true,
|
|
236
|
+
colors: {
|
|
237
|
+
"model": color
|
|
238
|
+
},
|
|
239
|
+
refresh: false
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
updateShouldShowTrack();
|
|
244
|
+
prepareExistingGraphic(cEntity, shouldShowTrack ? 1 : 0);
|
|
245
|
+
var currentUri = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.model.uri);
|
|
246
|
+
if (currentUri != params.lodUrl) {
|
|
247
|
+
cEntity.model.uri = new Cesium.ConstantProperty(params.lodUrl);
|
|
248
|
+
}
|
|
249
|
+
cEntity.model.heightReference = new Cesium.ConstantProperty(heightRef);
|
|
250
|
+
cEntity.model.shadows = new Cesium.ConstantProperty(Cesium.ShadowMode.ENABLED);
|
|
251
|
+
cEntity.model.colorBlendAmount = new Cesium.ConstantProperty(blendAmount);
|
|
252
|
+
cEntity.model.colorBlendMode = new Cesium.ConstantProperty(blendMode);
|
|
253
|
+
cEntity.model.distanceDisplayCondition = new Cesium.ConstantProperty(entity_render_engine_1.EntityRenderEngine.GetDisplayCondition(params.minDistance, params.maxDistance));
|
|
254
|
+
// If we have a series of time-based positions then we'll animate as time changes.
|
|
255
|
+
var series = cesium_animated_property_1.CesiumAnimatedProperty.GetSeriesPossesForHistoricEntity(params.viewer, heightRef, params.entityHistoric);
|
|
256
|
+
if (series.length > 1) {
|
|
257
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries({
|
|
258
|
+
posses: series,
|
|
259
|
+
viewer: params.viewer,
|
|
260
|
+
pitch: pitch,
|
|
261
|
+
roll: roll
|
|
262
|
+
});
|
|
263
|
+
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
var prevPos3d = (0, cesium_utils_1.GetCValue)(params.viewer, cEntity.position);
|
|
267
|
+
var posChanged = !prevPos3d || !Cesium.Cartesian3.equals(prevPos3d, pos3d);
|
|
268
|
+
if (posChanged) {
|
|
269
|
+
animatePosition = new cesium_animated_property_1.CesiumAnimatedProperty.AnimatePosition({
|
|
270
|
+
durationMs: 200,
|
|
271
|
+
targetPos3d: pos3d,
|
|
272
|
+
viewer: params.viewer,
|
|
273
|
+
startPos3d: prevPos3d
|
|
274
|
+
});
|
|
275
|
+
cEntity.position = new Cesium.CallbackProperty(function () { return animatePosition.GetValue(); }, false);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (animatePosition && animatePosition instanceof cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetOrient) {
|
|
279
|
+
cEntity.orientation = new Cesium.CallbackProperty(function () {
|
|
280
|
+
return animatePosition.GetOrient();
|
|
281
|
+
}, false);
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
var prevHeading = cEntity.model._heading;
|
|
285
|
+
if (prevHeading == null || prevHeading == heading || isNaN(prevHeading)) {
|
|
286
|
+
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(heading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
287
|
+
var orient_1 = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
|
|
288
|
+
cEntity.orientation = new Cesium.CallbackProperty(function () { return orient_1; }, true);
|
|
289
|
+
}
|
|
290
|
+
// Animate orientation. We'll calculate the heading based on movement.
|
|
291
|
+
else {
|
|
292
|
+
var animateHeading_1 = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateHeading({
|
|
293
|
+
durationMs: 200,
|
|
294
|
+
targetHeading: heading,
|
|
295
|
+
viewer: params.viewer,
|
|
296
|
+
startHeading: prevHeading
|
|
297
|
+
});
|
|
298
|
+
cEntity.orientation = new Cesium.CallbackProperty(function () {
|
|
299
|
+
var calcHeading = animateHeading_1.GetValue();
|
|
300
|
+
var hpr = new Cesium.HeadingPitchRoll(Cesium.Math.toRadians(calcHeading), Cesium.Math.toRadians(pitch), Cesium.Math.toRadians(roll));
|
|
301
|
+
var orient = Cesium.Transforms.headingPitchRollQuaternion(pos3d, hpr);
|
|
302
|
+
// We'll stop the costly animation if it's done.
|
|
303
|
+
if (animateHeading_1.IsDone()) {
|
|
304
|
+
cEntity.orientation = new Cesium.ConstantProperty(orient);
|
|
305
|
+
}
|
|
306
|
+
return orient;
|
|
307
|
+
}, false);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
// Same file but different scale. We'll animate the scale.
|
|
311
|
+
var prevClientFileId = cEntity.model._clientFileId;
|
|
312
|
+
if (prevClientFileId == params.lodClientFileId) {
|
|
313
|
+
animateScale = new cesium_animated_property_1.CesiumAnimatedProperty.AnimateNumber({
|
|
314
|
+
durationMs: 200,
|
|
315
|
+
targetValue: scale * styleScale,
|
|
316
|
+
viewer: params.viewer,
|
|
317
|
+
startValue: cEntity.model.scale,
|
|
318
|
+
startPaused: true
|
|
319
|
+
});
|
|
320
|
+
cEntity.model.scale = new Cesium.CallbackProperty(function () { return animateScale.GetValue(); }, false);
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
cEntity.model.scale = new Cesium.CallbackProperty(function () { return scale * styleScale; }, true);
|
|
324
|
+
}
|
|
325
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
326
|
+
// cEntity.model.color = new Cesium.CallbackProperty(() => color, true);
|
|
327
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
328
|
+
color: color ? color : new Cesium.Color(),
|
|
329
|
+
entity: cEntity,
|
|
330
|
+
viewer: params.viewer,
|
|
331
|
+
override: true,
|
|
332
|
+
requestRender: false
|
|
333
|
+
});
|
|
334
|
+
cEntity.show = true;
|
|
335
|
+
}
|
|
336
|
+
var fileRadiusKey = "model3d_".concat(params.lodUrl, "_").concat(scale * styleScale, "_radius");
|
|
337
|
+
var heightProm = _fileRadiusCache.Get(fileRadiusKey);
|
|
338
|
+
if (!heightProm) {
|
|
339
|
+
heightProm = new Promise(function (res) { return __awaiter(_this, void 0, void 0, function () {
|
|
340
|
+
var modelPrim_1, onReady_1, readyEventRemoval_1, e_1;
|
|
341
|
+
return __generator(this, function (_a) {
|
|
342
|
+
switch (_a.label) {
|
|
343
|
+
case 0:
|
|
344
|
+
_a.trys.push([0, 2, , 3]);
|
|
345
|
+
return [4 /*yield*/, getModelEntity(params.lodUrl, scale * styleScale)];
|
|
346
|
+
case 1:
|
|
347
|
+
modelPrim_1 = _a.sent();
|
|
348
|
+
onReady_1 = function () {
|
|
349
|
+
readyEventRemoval_1 === null || readyEventRemoval_1 === void 0 ? void 0 : readyEventRemoval_1();
|
|
350
|
+
readyEventRemoval_1 = null;
|
|
351
|
+
var kill = function () {
|
|
352
|
+
if (params.viewer && !params.viewer.isDestroyed() && params.viewer.scene.primitives.contains(modelPrim_1)) {
|
|
353
|
+
params.viewer.scene.primitives.remove(modelPrim_1);
|
|
354
|
+
}
|
|
355
|
+
if (!modelPrim_1.isDestroyed()) {
|
|
356
|
+
modelPrim_1.destroy();
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
if (!cEntity || !(modelPrim_1 === null || modelPrim_1 === void 0 ? void 0 : modelPrim_1.boundingSphere)) {
|
|
360
|
+
kill();
|
|
361
|
+
res(null);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
var radius = modelPrim_1.boundingSphere.radius;
|
|
365
|
+
var centerOffset = modelPrim_1.boundingSphere.center;
|
|
366
|
+
if (centerOffset) {
|
|
367
|
+
// Add the center offset to the radius because I am not good at math.
|
|
368
|
+
var magnitude = Cesium.Cartesian3.magnitude(centerOffset);
|
|
369
|
+
radius += magnitude;
|
|
370
|
+
// Extra padding if the model is super not centered.
|
|
371
|
+
// I saw some strange boundaries for some bad models.
|
|
372
|
+
if (magnitude > 100) {
|
|
373
|
+
radius += 100;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
kill();
|
|
377
|
+
res(radius);
|
|
378
|
+
};
|
|
379
|
+
readyEventRemoval_1 = null;
|
|
380
|
+
// Newer Cesium versions have readyEvent. They don't use readyPromise.
|
|
381
|
+
if (modelPrim_1["readyEvent"]) {
|
|
382
|
+
modelPrim_1["readyEvent"].addEventListener(onReady_1);
|
|
383
|
+
}
|
|
384
|
+
// Older Cesium versions don't have readyEvent, they use readyPromise.
|
|
385
|
+
else if (modelPrim_1["readyPromise"]) {
|
|
386
|
+
modelPrim_1["readyPromise"].then(function () {
|
|
387
|
+
onReady_1();
|
|
388
|
+
}).catch(function (e) {
|
|
389
|
+
console.error(e);
|
|
390
|
+
res(null);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
params.viewer.scene.primitives.add(modelPrim_1);
|
|
394
|
+
return [3 /*break*/, 3];
|
|
395
|
+
case 2:
|
|
396
|
+
e_1 = _a.sent();
|
|
397
|
+
console.error(e_1);
|
|
398
|
+
res(null);
|
|
399
|
+
return [3 /*break*/, 3];
|
|
400
|
+
case 3: return [2 /*return*/];
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
}); });
|
|
404
|
+
_fileRadiusCache.Set(fileRadiusKey, heightProm);
|
|
405
|
+
}
|
|
406
|
+
heightProm.then(function (radius) {
|
|
407
|
+
if (model) {
|
|
408
|
+
model._radius = radius;
|
|
409
|
+
model._radiusLoaded = true;
|
|
410
|
+
if (params.viewer && params.viewer.scene && !params.viewer.isDestroyed()) {
|
|
411
|
+
visual_register_culler_1.VisualRegisterCuller.MarkShouldRecheck(params.viewer);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
// Rough estimate on when the model is ready in the scene.
|
|
415
|
+
if (animateScale) {
|
|
416
|
+
animateScale.Play();
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
var model = cEntity.model;
|
|
420
|
+
model._radiusLoaded = false;
|
|
421
|
+
model._clientFileId = params.lodClientFileId;
|
|
422
|
+
model._entityScale = {
|
|
423
|
+
record: scale,
|
|
424
|
+
style: styleScale
|
|
425
|
+
};
|
|
426
|
+
model._heading = heading;
|
|
427
|
+
// Generate a polyline 'track' for the historic data.
|
|
428
|
+
// We do this for historic data that exists and is moving.
|
|
429
|
+
if (shouldShowTrack && animatePosition && animatePosition instanceof cesium_animated_property_1.CesiumAnimatedProperty.AnimatePositionSeries && animatePosition.GetSeries) {
|
|
430
|
+
var lStyle = (_b = (_a = params.fullStyle) === null || _a === void 0 ? void 0 : _a.polylineStyle) !== null && _b !== void 0 ? _b : {};
|
|
431
|
+
var bColor = lStyle.lineColor ? bruce_models_1.Calculator.GetColor(lStyle.lineColor, entity, params.tags) : null;
|
|
432
|
+
var cColor = bColor ? (0, cesium_utils_1.ColorToCColor)(bColor) : Cesium.Color.fromCssColorString("rgba(255, 193, 7, 0.8)");
|
|
433
|
+
var width = lStyle.lineWidth ? (0, js_utils_1.EnsureNumber)(bruce_models_1.Calculator.GetNumber(lStyle.lineWidth, entity, params.tags)) : 2;
|
|
434
|
+
if (width == null) {
|
|
435
|
+
width = 2;
|
|
436
|
+
}
|
|
437
|
+
width = (0, js_utils_1.EnsureNumber)(width);
|
|
438
|
+
var lHeightRef = getHeightRef(lStyle, heightRef);
|
|
439
|
+
var trackEntity = siblings === null || siblings === void 0 ? void 0 : siblings[0];
|
|
440
|
+
if (!trackEntity || !trackEntity.polyline) {
|
|
441
|
+
trackEntity = new Cesium.Entity({
|
|
442
|
+
id: bruce_models_1.ObjectUtils.UId(10),
|
|
443
|
+
polyline: {
|
|
444
|
+
positions: [],
|
|
445
|
+
width: width,
|
|
446
|
+
material: cColor,
|
|
447
|
+
clampToGround: lHeightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
448
|
+
zIndex: 0,
|
|
449
|
+
classificationType: Cesium.ClassificationType.BOTH
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
// Visual was updated in a way that needs a full refresh.
|
|
453
|
+
if (params.rego) {
|
|
454
|
+
params.rego.stale = true;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
trackEntity._parentEntity = null;
|
|
458
|
+
trackEntity._noEdit = true;
|
|
459
|
+
trackEntity.polyline.positions = new Cesium.CallbackProperty(function () {
|
|
460
|
+
return animatePosition.GetSeries();
|
|
461
|
+
}, false);
|
|
462
|
+
// We'll use "SetDefaultColor" to updating the internal reference and to allow for an animation.
|
|
463
|
+
// WARNING: polyline does not support animation (yet?).
|
|
464
|
+
cesium_entity_styler_1.CesiumEntityStyler.SetDefaultColor({
|
|
465
|
+
color: cColor,
|
|
466
|
+
entity: trackEntity,
|
|
467
|
+
viewer: params.viewer,
|
|
468
|
+
override: true,
|
|
469
|
+
requestRender: false
|
|
470
|
+
});
|
|
471
|
+
siblings.push(trackEntity);
|
|
472
|
+
trackEntity._parentEntity = cEntity;
|
|
473
|
+
}
|
|
474
|
+
cEntity._siblingGraphics = siblings;
|
|
475
|
+
return cEntity;
|
|
476
|
+
}
|
|
477
|
+
EntityRenderEngineModel3d.Render = Render;
|
|
478
|
+
/**
|
|
479
|
+
* Renders a group of 3D model Entities.
|
|
480
|
+
* This will take an optional set of prior rendered Cesium Entities to update rather than create from scratch.
|
|
481
|
+
* @param params
|
|
482
|
+
* @returns
|
|
483
|
+
*/
|
|
484
|
+
function RenderGroup(params) {
|
|
485
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
486
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
487
|
+
var api, cEntities, reqBody, i, entity, zoomItem, style, _h, tagIds, tags, mStyle, group, level, catId, lodData, _loop_1, i;
|
|
488
|
+
return __generator(this, function (_j) {
|
|
489
|
+
switch (_j.label) {
|
|
490
|
+
case 0:
|
|
491
|
+
api = params.apiGetter.getApi();
|
|
492
|
+
return [4 /*yield*/, api.Loading];
|
|
493
|
+
case 1:
|
|
494
|
+
_j.sent();
|
|
495
|
+
cEntities = new Map();
|
|
496
|
+
reqBody = {
|
|
497
|
+
"strict": false,
|
|
498
|
+
"externalSources": false,
|
|
499
|
+
"Items": []
|
|
500
|
+
};
|
|
501
|
+
i = 0;
|
|
502
|
+
_j.label = 2;
|
|
503
|
+
case 2:
|
|
504
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 9];
|
|
505
|
+
entity = params.entities[i];
|
|
506
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
507
|
+
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 4];
|
|
508
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
509
|
+
case 3:
|
|
510
|
+
_h = (_a = (_j.sent())) === null || _a === void 0 ? void 0 : _a.Settings;
|
|
511
|
+
return [3 /*break*/, 5];
|
|
512
|
+
case 4:
|
|
513
|
+
_h = zoomItem.Style;
|
|
514
|
+
_j.label = 5;
|
|
515
|
+
case 5:
|
|
516
|
+
style = _h;
|
|
517
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
518
|
+
tags = [];
|
|
519
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 7];
|
|
520
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
521
|
+
api: api,
|
|
522
|
+
tagIds: tagIds
|
|
523
|
+
})];
|
|
524
|
+
case 6:
|
|
525
|
+
tags = (_j.sent()).tags;
|
|
526
|
+
_j.label = 7;
|
|
527
|
+
case 7:
|
|
528
|
+
mStyle = (_b = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _b !== void 0 ? _b : {};
|
|
529
|
+
group = mStyle.lodGroup ? bruce_models_1.Calculator.GetString(mStyle.lodGroup, entity, tags) : null;
|
|
530
|
+
if (!group) {
|
|
531
|
+
group = "DEFAULT";
|
|
532
|
+
}
|
|
533
|
+
level = +zoomItem.LODLevel;
|
|
534
|
+
if (!level) {
|
|
535
|
+
level = 0;
|
|
536
|
+
}
|
|
537
|
+
catId = zoomItem.LODCategoryID;
|
|
538
|
+
if (!catId) {
|
|
539
|
+
catId = "glb";
|
|
540
|
+
}
|
|
541
|
+
reqBody.Items.push({
|
|
542
|
+
"entityId": entity.Bruce.ID,
|
|
543
|
+
"categoryId": catId,
|
|
544
|
+
"group": group,
|
|
545
|
+
"level": level
|
|
546
|
+
});
|
|
547
|
+
_j.label = 8;
|
|
548
|
+
case 8:
|
|
549
|
+
i++;
|
|
550
|
+
return [3 /*break*/, 2];
|
|
551
|
+
case 9: return [4 /*yield*/, bruce_models_1.EntityLod.GetLods({
|
|
552
|
+
api: api,
|
|
553
|
+
filter: reqBody
|
|
554
|
+
})];
|
|
555
|
+
case 10:
|
|
556
|
+
lodData = (_j.sent()).lods;
|
|
557
|
+
_loop_1 = function (i) {
|
|
558
|
+
var entity, zoomItem, style, _k, tagIds, tags, lod, rego, mStyle, cEntity, name_1;
|
|
559
|
+
return __generator(this, function (_l) {
|
|
560
|
+
switch (_l.label) {
|
|
561
|
+
case 0:
|
|
562
|
+
entity = params.entities[i];
|
|
563
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
564
|
+
if (!(zoomItem.StyleID != -1)) return [3 /*break*/, 2];
|
|
565
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
566
|
+
case 1:
|
|
567
|
+
_k = (_c = (_l.sent())) === null || _c === void 0 ? void 0 : _c.Settings;
|
|
568
|
+
return [3 /*break*/, 3];
|
|
569
|
+
case 2:
|
|
570
|
+
_k = zoomItem.Style;
|
|
571
|
+
_l.label = 3;
|
|
572
|
+
case 3:
|
|
573
|
+
style = _k;
|
|
574
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
575
|
+
tags = [];
|
|
576
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 5];
|
|
577
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds({
|
|
578
|
+
api: api,
|
|
579
|
+
tagIds: tagIds
|
|
580
|
+
})];
|
|
581
|
+
case 4:
|
|
582
|
+
tags = (_l.sent()).tags;
|
|
583
|
+
_l.label = 5;
|
|
584
|
+
case 5:
|
|
585
|
+
lod = lodData.find(function (x) { return x.entityId == entity.Bruce.ID; });
|
|
586
|
+
if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
|
|
587
|
+
return [2 /*return*/, "continue"];
|
|
588
|
+
}
|
|
589
|
+
rego = null;
|
|
590
|
+
// Only used for historic tracks right now.
|
|
591
|
+
// So won't bother getting it if we don't have historic data.
|
|
592
|
+
if ((_d = params.entitiesHistoric) === null || _d === void 0 ? void 0 : _d[entity.Bruce.ID]) {
|
|
593
|
+
rego = params.visualRegister.GetRego({
|
|
594
|
+
entityId: entity.Bruce.ID,
|
|
595
|
+
menuItemId: params.menuItemId
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
mStyle = (_e = style === null || style === void 0 ? void 0 : style.modelStyle) !== null && _e !== void 0 ? _e : {};
|
|
599
|
+
cEntity = Render({
|
|
600
|
+
rendered: (_f = params.rendered) === null || _f === void 0 ? void 0 : _f.get(entity.Bruce.ID),
|
|
601
|
+
entity: entity,
|
|
602
|
+
entityHistoric: (_g = params.entitiesHistoric) === null || _g === void 0 ? void 0 : _g[entity.Bruce.ID],
|
|
603
|
+
style: mStyle,
|
|
604
|
+
tags: tags,
|
|
605
|
+
viewer: params.viewer,
|
|
606
|
+
lodUrl: bruce_models_1.ClientFile.GetUrl({
|
|
607
|
+
api: api,
|
|
608
|
+
fileId: lod.clientFileId,
|
|
609
|
+
viaCdn: true
|
|
610
|
+
}),
|
|
611
|
+
lodClientFileId: lod.clientFileId,
|
|
612
|
+
maxDistance: zoomItem.MaxZoom,
|
|
613
|
+
minDistance: zoomItem.MinZoom,
|
|
614
|
+
fullStyle: style,
|
|
615
|
+
entityHistoricDrawTrack: params.entityHistoricDrawTrack,
|
|
616
|
+
rego: rego
|
|
617
|
+
});
|
|
618
|
+
if (!cEntity) return [3 /*break*/, 7];
|
|
619
|
+
return [4 /*yield*/, getName(api, entity)];
|
|
620
|
+
case 6:
|
|
621
|
+
name_1 = _l.sent();
|
|
622
|
+
cEntity.name = name_1;
|
|
623
|
+
cEntity._renderGroup = entity_render_engine_1.EntityRenderEngine.GetRenderGroupId(zoomItem);
|
|
624
|
+
cEntities.set(entity.Bruce.ID, cEntity);
|
|
625
|
+
_l.label = 7;
|
|
626
|
+
case 7: return [2 /*return*/];
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
};
|
|
630
|
+
i = 0;
|
|
631
|
+
_j.label = 11;
|
|
632
|
+
case 11:
|
|
633
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 14];
|
|
634
|
+
return [5 /*yield**/, _loop_1(i)];
|
|
635
|
+
case 12:
|
|
636
|
+
_j.sent();
|
|
637
|
+
_j.label = 13;
|
|
638
|
+
case 13:
|
|
639
|
+
i++;
|
|
640
|
+
return [3 /*break*/, 11];
|
|
641
|
+
case 14: return [2 /*return*/, cEntities];
|
|
642
|
+
}
|
|
643
|
+
});
|
|
644
|
+
});
|
|
645
|
+
}
|
|
646
|
+
EntityRenderEngineModel3d.RenderGroup = RenderGroup;
|
|
647
|
+
})(EntityRenderEngineModel3d = exports.EntityRenderEngineModel3d || (exports.EntityRenderEngineModel3d = {}));
|
|
648
|
+
function getHeightRef(style, defaultStyle) {
|
|
649
|
+
var _a;
|
|
650
|
+
var heightRef = defaultStyle == null ? Cesium.HeightReference.CLAMP_TO_GROUND : defaultStyle;
|
|
651
|
+
var altOptionId = (_a = style === null || style === void 0 ? void 0 : style.altitudeOption) === null || _a === void 0 ? void 0 : _a.id;
|
|
652
|
+
if (altOptionId == 0) {
|
|
653
|
+
heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
654
|
+
}
|
|
655
|
+
else if (altOptionId == 1) {
|
|
656
|
+
heightRef = Cesium.HeightReference.NONE;
|
|
657
|
+
}
|
|
658
|
+
else if (altOptionId == 2) {
|
|
659
|
+
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
660
|
+
}
|
|
661
|
+
return heightRef;
|
|
662
|
+
}
|
|
663
|
+
function getName(api, entity) {
|
|
664
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
665
|
+
var typeId, type, name_2, e_2, hideError, error, code;
|
|
666
|
+
return __generator(this, function (_a) {
|
|
667
|
+
switch (_a.label) {
|
|
668
|
+
case 0:
|
|
669
|
+
_a.trys.push([0, 3, , 4]);
|
|
670
|
+
typeId = entity.Bruce["EntityType.ID"];
|
|
671
|
+
type = null;
|
|
672
|
+
if (!typeId) return [3 /*break*/, 2];
|
|
673
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
674
|
+
api: api,
|
|
675
|
+
entityTypeId: typeId
|
|
676
|
+
})];
|
|
677
|
+
case 1:
|
|
678
|
+
type = (_a.sent()).entityType;
|
|
679
|
+
_a.label = 2;
|
|
680
|
+
case 2:
|
|
681
|
+
if (type) {
|
|
682
|
+
name_2 = bruce_models_1.Entity.CalculateName({
|
|
683
|
+
entity: entity,
|
|
684
|
+
type: type,
|
|
685
|
+
defaultToId: false
|
|
686
|
+
});
|
|
687
|
+
return [2 /*return*/, name_2 ? name_2 : "Unnamed Entity"];
|
|
688
|
+
}
|
|
689
|
+
return [3 /*break*/, 4];
|
|
690
|
+
case 3:
|
|
691
|
+
e_2 = _a.sent();
|
|
692
|
+
hideError = false;
|
|
693
|
+
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
694
|
+
if (e_2 && typeof e_2 == "object" && e_2.ERROR) {
|
|
695
|
+
error = e_2.ERROR;
|
|
696
|
+
code = error && typeof error == "object" ? error.Code : "";
|
|
697
|
+
// Avoiding logging a common error.
|
|
698
|
+
// This happens when rendering entities that don't have records.
|
|
699
|
+
hideError = String(code).toLowerCase() == "notfound";
|
|
700
|
+
}
|
|
701
|
+
if (!hideError) {
|
|
702
|
+
console.error(e_2);
|
|
703
|
+
}
|
|
704
|
+
return [3 /*break*/, 4];
|
|
705
|
+
case 4: return [2 /*return*/, "Unknown entity"];
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
function getStyle(api, entity, styleId) {
|
|
711
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
712
|
+
var style, e_3, typeId, type, e_4, hideError, error, code;
|
|
713
|
+
return __generator(this, function (_a) {
|
|
714
|
+
switch (_a.label) {
|
|
715
|
+
case 0:
|
|
716
|
+
style = null;
|
|
717
|
+
if (!styleId) return [3 /*break*/, 4];
|
|
718
|
+
_a.label = 1;
|
|
719
|
+
case 1:
|
|
720
|
+
_a.trys.push([1, 3, , 4]);
|
|
721
|
+
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
722
|
+
api: api,
|
|
723
|
+
styleId: styleId
|
|
724
|
+
})];
|
|
725
|
+
case 2:
|
|
726
|
+
style = (_a.sent()).style;
|
|
727
|
+
return [3 /*break*/, 4];
|
|
728
|
+
case 3:
|
|
729
|
+
e_3 = _a.sent();
|
|
730
|
+
console.error(e_3);
|
|
731
|
+
return [3 /*break*/, 4];
|
|
732
|
+
case 4:
|
|
733
|
+
if (!!style) return [3 /*break*/, 9];
|
|
734
|
+
typeId = entity.Bruce["EntityType.ID"];
|
|
735
|
+
if (!typeId) return [3 /*break*/, 9];
|
|
736
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get({
|
|
737
|
+
api: api,
|
|
738
|
+
entityTypeId: typeId
|
|
739
|
+
})];
|
|
740
|
+
case 5:
|
|
741
|
+
type = (_a.sent()).entityType;
|
|
742
|
+
if (!type["DisplaySetting.ID"]) return [3 /*break*/, 9];
|
|
743
|
+
_a.label = 6;
|
|
744
|
+
case 6:
|
|
745
|
+
_a.trys.push([6, 8, , 9]);
|
|
746
|
+
return [4 /*yield*/, bruce_models_1.Style.Get({
|
|
747
|
+
api: api,
|
|
748
|
+
styleId: type["DisplaySetting.ID"]
|
|
749
|
+
})];
|
|
750
|
+
case 7:
|
|
751
|
+
style = (_a.sent()).style;
|
|
752
|
+
return [3 /*break*/, 9];
|
|
753
|
+
case 8:
|
|
754
|
+
e_4 = _a.sent();
|
|
755
|
+
hideError = false;
|
|
756
|
+
// TODO: we need a util for extracting code + message rather than writing all this every time.
|
|
757
|
+
if (e_4 && typeof e_4 == "object" && e_4.ERROR) {
|
|
758
|
+
error = e_4.ERROR;
|
|
759
|
+
code = error && typeof error == "object" ? error.Code : "";
|
|
760
|
+
// Avoiding logging a common error.
|
|
761
|
+
// This happens when rendering entities that don't have records.
|
|
762
|
+
hideError = String(code).toLowerCase() == "notfound";
|
|
763
|
+
}
|
|
764
|
+
if (!hideError) {
|
|
765
|
+
console.error(e_4);
|
|
766
|
+
}
|
|
767
|
+
return [3 /*break*/, 9];
|
|
768
|
+
case 9: return [2 /*return*/, style];
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
var _fileValidationCache = {};
|
|
774
|
+
var _fileHeightCache = {};
|
|
775
|
+
// Key = url + scale.
|
|
776
|
+
var _fileRadiusCache = new bruce_models_1.LRUCache(1000);
|
|
777
|
+
/**
|
|
778
|
+
* Util to support both old and newer versions of Cesium for creating 3D model primitives.
|
|
779
|
+
* @param url
|
|
780
|
+
*/
|
|
781
|
+
function getModelEntity(url, scale) {
|
|
782
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
783
|
+
var CESIUM;
|
|
784
|
+
return __generator(this, function (_a) {
|
|
785
|
+
switch (_a.label) {
|
|
786
|
+
case 0:
|
|
787
|
+
CESIUM = Cesium;
|
|
788
|
+
if (!CESIUM.Model.hasOwnProperty("fromGltfAsync")) return [3 /*break*/, 2];
|
|
789
|
+
return [4 /*yield*/, CESIUM.Model.fromGltfAsync({
|
|
790
|
+
url: url,
|
|
791
|
+
asynchronous: true,
|
|
792
|
+
scale: scale
|
|
793
|
+
})];
|
|
794
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
795
|
+
case 2:
|
|
796
|
+
if (Cesium.Model.hasOwnProperty("fromGltf")) {
|
|
797
|
+
return [2 /*return*/, CESIUM.Model.fromGltf({
|
|
798
|
+
url: url,
|
|
799
|
+
asynchronous: true,
|
|
800
|
+
scale: scale
|
|
801
|
+
})];
|
|
802
|
+
}
|
|
803
|
+
_a.label = 3;
|
|
804
|
+
case 3: return [2 /*return*/, null];
|
|
805
|
+
}
|
|
806
|
+
});
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
//# sourceMappingURL=entity-render-engine-model3d.js.map
|