bruce-cesium 0.4.0 → 0.4.2
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 +46 -58
- package/dist/bruce-cesium.es5.js.map +1 -1
- package/dist/bruce-cesium.umd.js +45 -57
- package/dist/bruce-cesium.umd.js.map +1 -1
- package/dist/lib/bruce-cesium.js +30 -30
- package/dist/lib/rendering/entity-render-engine.js +848 -848
- package/dist/lib/rendering/menu-item-manager.js +252 -252
- package/dist/lib/rendering/render-addons/measure-addon.js +186 -186
- package/dist/lib/rendering/render-addons/render-addon.js +2 -2
- package/dist/lib/rendering/render-helper.js +296 -296
- package/dist/lib/rendering/render-managers/common/shared-getters.js +31 -31
- package/dist/lib/rendering/render-managers/entities/entities-ids-render-manager.js +146 -146
- package/dist/lib/rendering/render-managers/entities/entities-loaded-render-manager.js +143 -143
- package/dist/lib/rendering/render-managers/entities/entities-render-manager.js +234 -234
- package/dist/lib/rendering/render-managers/entities/entity-render-manager.js +139 -139
- package/dist/lib/rendering/render-managers/render-manager.js +50 -50
- package/dist/lib/rendering/render-managers/tilesets/tileset-cad-render-manager.js +236 -236
- package/dist/lib/rendering/render-managers/tilesets/tileset-osm-render-manager.js +320 -320
- package/dist/lib/rendering/tile-render-engine.js +815 -831
- package/dist/lib/rendering/tile-render-engine.js.map +1 -1
- package/dist/lib/rendering/tileset-render-engine.js +499 -499
- package/dist/lib/rendering/view-render-engine.js +305 -309
- package/dist/lib/rendering/view-render-engine.js.map +1 -1
- package/dist/lib/rendering/visuals-register.js +402 -394
- package/dist/lib/rendering/visuals-register.js.map +1 -1
- package/dist/lib/utils/drawing-utils.js +42 -42
- package/dist/lib/utils/entity-utils.js +99 -99
- package/dist/lib/utils/measure-utils.js +34 -34
- package/dist/lib/utils/view-utils.js +72 -72
- package/dist/lib/viewer/cesium-view-monitor.js +231 -231
- package/dist/lib/viewer/viewer-utils.js +85 -85
- package/dist/types/rendering/tile-render-engine.d.ts +2 -4
- package/dist/types/rendering/visuals-register.d.ts +2 -0
- package/package.json +76 -76
|
@@ -1,849 +1,849 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.EntityRenderEngine = void 0;
|
|
51
|
-
var Cesium = require("cesium");
|
|
52
|
-
var bruce_models_1 = require("bruce-models");
|
|
53
|
-
var entity_utils_1 = require("../utils/entity-utils");
|
|
54
|
-
var render_manager_1 = require("./render-managers/render-manager");
|
|
55
|
-
function colorToCColor(color) {
|
|
56
|
-
return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
|
|
57
|
-
}
|
|
58
|
-
function getPolygonStyleExtrusion(pStyle, entity, tags, heightRef) {
|
|
59
|
-
var _a;
|
|
60
|
-
var attrPath = pStyle.extrusionPath;
|
|
61
|
-
if (!pStyle.useExtrusion || !attrPath) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
var extrusion = +bruce_models_1.Calculator.GetValue(attrPath, entity, tags);
|
|
66
|
-
if (!extrusion && extrusion != 0) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
/*
|
|
70
|
-
Cesium extrudes in strange way.
|
|
71
|
-
If you want something that is 50 meters above sea, and 5 meters tall,
|
|
72
|
-
You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
|
|
73
|
-
*/
|
|
74
|
-
var height = (_a = entity.location) === null || _a === void 0 ? void 0 : _a.altitude;
|
|
75
|
-
return heightRef == Cesium.HeightReference.RELATIVE_TO_GROUND ? extrusion + height : extrusion;
|
|
76
|
-
}
|
|
77
|
-
catch (e) {
|
|
78
|
-
console.error(e);
|
|
79
|
-
}
|
|
80
|
-
return 0;
|
|
81
|
-
}
|
|
82
|
-
function getPolygonExtrusion(entity, tags, ring, posses, heightRef, pStyle) {
|
|
83
|
-
var _a;
|
|
84
|
-
var data = {
|
|
85
|
-
value: undefined,
|
|
86
|
-
exHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
87
|
-
posses: null
|
|
88
|
-
};
|
|
89
|
-
// Step 1. Try get using style.
|
|
90
|
-
var extrusion = getPolygonStyleExtrusion(pStyle, entity, tags, heightRef);
|
|
91
|
-
if (extrusion) {
|
|
92
|
-
if (heightRef == Cesium.HeightReference.NONE) {
|
|
93
|
-
// Let's normalize all point heights to be the same (at entity altitude).
|
|
94
|
-
// This let's us have a consistent extrusion height, and be adjustable easier by user.
|
|
95
|
-
var alt_1 = (_a = entity === null || entity === void 0 ? void 0 : entity.location) === null || _a === void 0 ? void 0 : _a.altitude;
|
|
96
|
-
if (!alt_1) {
|
|
97
|
-
alt_1 = 0;
|
|
98
|
-
}
|
|
99
|
-
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
100
|
-
points.forEach(function (point) {
|
|
101
|
-
point.height = alt_1;
|
|
102
|
-
});
|
|
103
|
-
posses = points.map(function (x) { return Cesium.Cartesian3.fromRadians(x.longitude, x.latitude, x.height); });
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
// Step 2. Try get using geometry data.
|
|
107
|
-
else {
|
|
108
|
-
data.exHeightRef = undefined;
|
|
109
|
-
if (ring.Height && ring.Height > 0) {
|
|
110
|
-
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
111
|
-
if (points.length <= 0) {
|
|
112
|
-
data.value = ring.Height;
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
var highest = null;
|
|
116
|
-
for (var i = 0; i < points.length; i++) {
|
|
117
|
-
var pointHeight = points[i].height;
|
|
118
|
-
if (pointHeight > highest || highest === null) {
|
|
119
|
-
highest = pointHeight;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
highest = (highest === null ? 0 : highest) + ring.Height;
|
|
123
|
-
data.value = highest;
|
|
124
|
-
}
|
|
125
|
-
data.exHeightRef = Cesium.HeightReference.NONE;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
data.posses = posses;
|
|
129
|
-
return data;
|
|
130
|
-
}
|
|
131
|
-
function getHeightRef(style) {
|
|
132
|
-
var _a;
|
|
133
|
-
var heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
134
|
-
var altOptionId = (_a = style === null || style === void 0 ? void 0 : style.altitudeOption) === null || _a === void 0 ? void 0 : _a.id;
|
|
135
|
-
if (altOptionId == 1) {
|
|
136
|
-
heightRef = Cesium.HeightReference.NONE;
|
|
137
|
-
}
|
|
138
|
-
else if (altOptionId == 2) {
|
|
139
|
-
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
140
|
-
}
|
|
141
|
-
return heightRef;
|
|
142
|
-
}
|
|
143
|
-
function getZIndex(style, entity, tags) {
|
|
144
|
-
var zIndex = (style === null || style === void 0 ? void 0 : style.zIndex) ? +bruce_models_1.Calculator.GetValue(style === null || style === void 0 ? void 0 : style.zIndex, entity, tags) : 0;
|
|
145
|
-
if (zIndex == null) {
|
|
146
|
-
zIndex = 0;
|
|
147
|
-
}
|
|
148
|
-
return zIndex;
|
|
149
|
-
}
|
|
150
|
-
function getStyle(api, entity, styleId) {
|
|
151
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
-
var style, type;
|
|
153
|
-
return __generator(this, function (_a) {
|
|
154
|
-
switch (_a.label) {
|
|
155
|
-
case 0:
|
|
156
|
-
style = null;
|
|
157
|
-
if (!styleId) return [3 /*break*/, 2];
|
|
158
|
-
return [4 /*yield*/, bruce_models_1.Style.Get(api, styleId)];
|
|
159
|
-
case 1:
|
|
160
|
-
style = _a.sent();
|
|
161
|
-
_a.label = 2;
|
|
162
|
-
case 2:
|
|
163
|
-
if (!!style) return [3 /*break*/, 5];
|
|
164
|
-
return [4 /*yield*/, bruce_models_1.EntityType.Get(api, entity.Bruce["EntityType.ID"])];
|
|
165
|
-
case 3:
|
|
166
|
-
type = _a.sent();
|
|
167
|
-
if (!type["DisplaySetting.ID"]) return [3 /*break*/, 5];
|
|
168
|
-
return [4 /*yield*/, bruce_models_1.Style.Get(api, type["DisplaySetting.ID"])];
|
|
169
|
-
case 4:
|
|
170
|
-
style = _a.sent();
|
|
171
|
-
_a.label = 5;
|
|
172
|
-
case 5: return [2 /*return*/, style];
|
|
173
|
-
}
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function getExistingCEntity(entityId, menuItemId, item, visualRegister) {
|
|
178
|
-
var _a;
|
|
179
|
-
return (_a = visualRegister.GetRego(entityId, menuItemId)) === null || _a === void 0 ? void 0 : _a.visual;
|
|
180
|
-
}
|
|
181
|
-
function getRenderGroupId(zoomItem) {
|
|
182
|
-
if (!zoomItem) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
return zoomItem.MinZoom + "-" + zoomItem.MaxZoom;
|
|
186
|
-
}
|
|
187
|
-
var EntityRenderEngine;
|
|
188
|
-
(function (EntityRenderEngine) {
|
|
189
|
-
function Render(params) {
|
|
190
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
-
var groupRenderParams, cEntities, models, polygons, polylines, points, i, entity, id, zoomItem, displayType, newRenderId, existing, oldRenderId, mParams, mEntities, i, entity, id, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity;
|
|
192
|
-
return __generator(this, function (_a) {
|
|
193
|
-
switch (_a.label) {
|
|
194
|
-
case 0:
|
|
195
|
-
groupRenderParams = {
|
|
196
|
-
apiGetter: params.apiGetter,
|
|
197
|
-
viewer: params.viewer,
|
|
198
|
-
entities: [],
|
|
199
|
-
zoomItems: {},
|
|
200
|
-
menuItemId: params.menuItemId,
|
|
201
|
-
visualRegister: params.visualRegister
|
|
202
|
-
};
|
|
203
|
-
cEntities = {};
|
|
204
|
-
models = [];
|
|
205
|
-
polygons = [];
|
|
206
|
-
polylines = [];
|
|
207
|
-
points = [];
|
|
208
|
-
// Initial sorting.
|
|
209
|
-
for (i = 0; i < params.entities.length; i++) {
|
|
210
|
-
entity = params.entities[i];
|
|
211
|
-
id = entity.Bruce.ID;
|
|
212
|
-
zoomItem = render_manager_1.RenderManager.Utils.DetermineZoomItem(params.viewer, entity, params.zoomControl);
|
|
213
|
-
displayType = zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.DisplayType;
|
|
214
|
-
if (!displayType) {
|
|
215
|
-
displayType = bruce_models_1.ZoomControl.EDisplayType.Hidden;
|
|
216
|
-
}
|
|
217
|
-
// Backwards compatibility.
|
|
218
|
-
else if (displayType == "polygon") {
|
|
219
|
-
displayType = bruce_models_1.ZoomControl.EDisplayType.Geometry;
|
|
220
|
-
}
|
|
221
|
-
if (displayType != bruce_models_1.ZoomControl.EDisplayType.Hidden) {
|
|
222
|
-
newRenderId = getRenderGroupId(zoomItem);
|
|
223
|
-
existing = getExistingCEntity(id, params.menuItemId, zoomItem, params.visualRegister);
|
|
224
|
-
oldRenderId = existing === null || existing === void 0 ? void 0 : existing._renderGroup;
|
|
225
|
-
if (newRenderId == oldRenderId) {
|
|
226
|
-
cEntities[id] = existing;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
if (displayType == bruce_models_1.ZoomControl.EDisplayType.Model3D) {
|
|
230
|
-
models.push(entity);
|
|
231
|
-
}
|
|
232
|
-
else if (displayType == bruce_models_1.ZoomControl.EDisplayType.Geometry) {
|
|
233
|
-
polygons.push(entity);
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
points.push(entity);
|
|
237
|
-
}
|
|
238
|
-
groupRenderParams.zoomItems[id] = zoomItem;
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
if (!(models.length > 0)) return [3 /*break*/, 2];
|
|
243
|
-
mParams = __assign(__assign({}, groupRenderParams), { entities: models });
|
|
244
|
-
return [4 /*yield*/, Model3d.RenderGroup(mParams)];
|
|
245
|
-
case 1:
|
|
246
|
-
mEntities = _a.sent();
|
|
247
|
-
for (i = 0; i < mParams.entities.length; i++) {
|
|
248
|
-
entity = mParams.entities[i];
|
|
249
|
-
id = entity.Bruce.ID;
|
|
250
|
-
cEntity = mEntities[id];
|
|
251
|
-
if (cEntity) {
|
|
252
|
-
cEntities[id] = cEntity;
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
polygons.push(entity);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
_a.label = 2;
|
|
259
|
-
case 2:
|
|
260
|
-
if (!(polygons.length > 0)) return [3 /*break*/, 4];
|
|
261
|
-
pParams = __assign(__assign({}, groupRenderParams), { entities: polygons });
|
|
262
|
-
return [4 /*yield*/, Polygon.RenderGroup(pParams)];
|
|
263
|
-
case 3:
|
|
264
|
-
pEntities = _a.sent();
|
|
265
|
-
for (i = 0; i < pParams.entities.length; i++) {
|
|
266
|
-
entity = pParams.entities[i];
|
|
267
|
-
cEntity = pEntities[entity.Bruce.ID];
|
|
268
|
-
if (cEntity) {
|
|
269
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
270
|
-
}
|
|
271
|
-
else {
|
|
272
|
-
polylines.push(entity);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
_a.label = 4;
|
|
276
|
-
case 4:
|
|
277
|
-
if (!(polylines.length > 0)) return [3 /*break*/, 6];
|
|
278
|
-
pParams = __assign(__assign({}, groupRenderParams), { entities: polylines });
|
|
279
|
-
return [4 /*yield*/, Polyline.RenderGroup(pParams)];
|
|
280
|
-
case 5:
|
|
281
|
-
pEntities = _a.sent();
|
|
282
|
-
for (i = 0; i < pParams.entities.length; i++) {
|
|
283
|
-
entity = pParams.entities[i];
|
|
284
|
-
cEntity = pEntities[entity.Bruce.ID];
|
|
285
|
-
if (cEntity) {
|
|
286
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
points.push(entity);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
_a.label = 6;
|
|
293
|
-
case 6:
|
|
294
|
-
if (!(points.length > 0)) return [3 /*break*/, 8];
|
|
295
|
-
pParams = __assign(__assign({}, groupRenderParams), { entities: points });
|
|
296
|
-
return [4 /*yield*/, Point.RenderGroup(pParams)];
|
|
297
|
-
case 7:
|
|
298
|
-
pEntities = _a.sent();
|
|
299
|
-
for (i = 0; i < pParams.entities.length; i++) {
|
|
300
|
-
entity = pParams.entities[i];
|
|
301
|
-
cEntity = pEntities[entity.Bruce.ID];
|
|
302
|
-
if (cEntity) {
|
|
303
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
_a.label = 8;
|
|
307
|
-
case 8: return [2 /*return*/, cEntities];
|
|
308
|
-
}
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
EntityRenderEngine.Render = Render;
|
|
313
|
-
function Remove(viewer, entity) {
|
|
314
|
-
if (entity._parentEntity) {
|
|
315
|
-
Remove(viewer, entity._parentEntity);
|
|
316
|
-
}
|
|
317
|
-
if (entity._siblingGraphics) {
|
|
318
|
-
for (var i = 0; i < entity._siblingGraphics.length; i++) {
|
|
319
|
-
var sibling = entity._siblingGraphics[i];
|
|
320
|
-
Remove(viewer, sibling);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (viewer.entities.contains(entity)) {
|
|
324
|
-
viewer.entities.remove(entity);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
EntityRenderEngine.Remove = Remove;
|
|
328
|
-
var Point;
|
|
329
|
-
(function (Point) {
|
|
330
|
-
function Render(params) {
|
|
331
|
-
var entity = params.entity;
|
|
332
|
-
var style = params.style;
|
|
333
|
-
var type = style.Type;
|
|
334
|
-
var cEntity = null;
|
|
335
|
-
if (type == bruce_models_1.Style.EPointType.Icon) {
|
|
336
|
-
var icon = bruce_models_1.Calculator.GetValue(style.iconUrl, entity, params.tags);
|
|
337
|
-
var iconUrl = null;
|
|
338
|
-
if (typeof icon == "string") {
|
|
339
|
-
iconUrl = icon;
|
|
340
|
-
}
|
|
341
|
-
if (!iconUrl && style.iconId) {
|
|
342
|
-
iconUrl = bruce_models_1.ClientFile.GetUrl(params.api, style.iconId);
|
|
343
|
-
}
|
|
344
|
-
if (iconUrl) {
|
|
345
|
-
var iconScale = +bruce_models_1.Calculator.GetValue(style.iconScale, entity, params.tags);
|
|
346
|
-
if (!iconScale && iconScale != 0) {
|
|
347
|
-
iconScale = 1;
|
|
348
|
-
}
|
|
349
|
-
if (iconScale > 0) {
|
|
350
|
-
cEntity = new Cesium.Entity({
|
|
351
|
-
billboard: {
|
|
352
|
-
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
353
|
-
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
354
|
-
image: iconUrl,
|
|
355
|
-
heightReference: getHeightRef(style)
|
|
356
|
-
},
|
|
357
|
-
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
358
|
-
show: false
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (type == bruce_models_1.Style.EPointType.Cylinder) {
|
|
364
|
-
// TODO: Cylinder.
|
|
365
|
-
}
|
|
366
|
-
if (!cEntity) {
|
|
367
|
-
var bColor = style.color ? bruce_models_1.Calculator.GetValue(style.color, entity, params.tags) : null;
|
|
368
|
-
var cColor = bColor ? colorToCColor(bColor) : Cesium.Color.RED;
|
|
369
|
-
var size = style.size ? bruce_models_1.Calculator.GetValue(style.size, entity, params.tags) : null;
|
|
370
|
-
if (size == null) {
|
|
371
|
-
size = 30;
|
|
372
|
-
}
|
|
373
|
-
if (size <= 0) {
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
cEntity = new Cesium.Entity({
|
|
377
|
-
point: {
|
|
378
|
-
pixelSize: size,
|
|
379
|
-
color: cColor,
|
|
380
|
-
heightReference: getHeightRef(style)
|
|
381
|
-
},
|
|
382
|
-
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
383
|
-
show: false
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
|
-
if (cEntity) {
|
|
387
|
-
params.viewer.entities.add(cEntity);
|
|
388
|
-
}
|
|
389
|
-
return cEntity;
|
|
390
|
-
}
|
|
391
|
-
Point.Render = Render;
|
|
392
|
-
function RenderGroup(params) {
|
|
393
|
-
var _a, _b;
|
|
394
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
395
|
-
var api, cEntities, i, entity, zoomItem, style, tagIds, tags, pStyle, cEntity;
|
|
396
|
-
return __generator(this, function (_c) {
|
|
397
|
-
switch (_c.label) {
|
|
398
|
-
case 0:
|
|
399
|
-
api = params.apiGetter.getApi();
|
|
400
|
-
cEntities = {};
|
|
401
|
-
i = 0;
|
|
402
|
-
_c.label = 1;
|
|
403
|
-
case 1:
|
|
404
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
405
|
-
entity = params.entities[i];
|
|
406
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
407
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
408
|
-
case 2:
|
|
409
|
-
style = _c.sent();
|
|
410
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
411
|
-
tags = [];
|
|
412
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
413
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
414
|
-
case 3:
|
|
415
|
-
tags = _c.sent();
|
|
416
|
-
_c.label = 4;
|
|
417
|
-
case 4:
|
|
418
|
-
pStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.pointStyle) !== null && _b !== void 0 ? _b : {};
|
|
419
|
-
cEntity = Render({
|
|
420
|
-
entity: entity,
|
|
421
|
-
style: pStyle,
|
|
422
|
-
tags: tags,
|
|
423
|
-
viewer: params.viewer,
|
|
424
|
-
api: api
|
|
425
|
-
});
|
|
426
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
427
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
428
|
-
_c.label = 5;
|
|
429
|
-
case 5:
|
|
430
|
-
i++;
|
|
431
|
-
return [3 /*break*/, 1];
|
|
432
|
-
case 6: return [2 /*return*/, cEntities];
|
|
433
|
-
}
|
|
434
|
-
});
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
Point.RenderGroup = RenderGroup;
|
|
438
|
-
})(Point = EntityRenderEngine.Point || (EntityRenderEngine.Point = {}));
|
|
439
|
-
var Polyline;
|
|
440
|
-
(function (Polyline) {
|
|
441
|
-
function Render(params) {
|
|
442
|
-
var _a;
|
|
443
|
-
var entity = params.entity;
|
|
444
|
-
var line = (_a = entity.geometry) === null || _a === void 0 ? void 0 : _a.LineString;
|
|
445
|
-
var points = line && typeof line == "string" ? bruce_models_1.Geometry.ParsePoints(line) : [];
|
|
446
|
-
if (!points || points.length < 2) {
|
|
447
|
-
return null;
|
|
448
|
-
}
|
|
449
|
-
var isValid = true;
|
|
450
|
-
for (var i = 0; i < points.length; i++) {
|
|
451
|
-
if (!bruce_models_1.Carto.ValidateCarto(points[i])) {
|
|
452
|
-
isValid = false;
|
|
453
|
-
break;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
if (!isValid) {
|
|
457
|
-
return null;
|
|
458
|
-
}
|
|
459
|
-
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees(x.longitude, x.latitude, x.altitude); });
|
|
460
|
-
// Making sure no 0 length lines coming through.
|
|
461
|
-
// Ideally we would measure the full line but I fear that's too expensive.
|
|
462
|
-
if (posses.length == 2 || posses.length == 3) {
|
|
463
|
-
var totalDistance = 0;
|
|
464
|
-
for (var i = 0; i < posses.length; i++) {
|
|
465
|
-
var pos1 = posses[i];
|
|
466
|
-
var pos2 = posses[i + 1];
|
|
467
|
-
if (pos1 && pos2) {
|
|
468
|
-
totalDistance += Cesium.Cartesian3.distance(pos1, pos2);
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
if (totalDistance < 0.001) {
|
|
472
|
-
return null;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
var style = params.style;
|
|
476
|
-
var bColor = style.lineColor ? bruce_models_1.Calculator.GetValue(style.lineColor, entity, params.tags) : null;
|
|
477
|
-
var cColor = bColor ? colorToCColor(bColor) : Cesium.Color.RED;
|
|
478
|
-
var width = style.lineWidth ? bruce_models_1.Calculator.GetValue(style.lineWidth, entity, params.tags) : null;
|
|
479
|
-
if (width == null) {
|
|
480
|
-
width = 4;
|
|
481
|
-
}
|
|
482
|
-
if (width <= 0) {
|
|
483
|
-
return null;
|
|
484
|
-
}
|
|
485
|
-
var heightRef = getHeightRef(style);
|
|
486
|
-
var cEntity = new Cesium.Entity({
|
|
487
|
-
polyline: {
|
|
488
|
-
positions: posses,
|
|
489
|
-
material: cColor,
|
|
490
|
-
width: width,
|
|
491
|
-
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
492
|
-
arcType: Cesium.ArcType.GEODESIC,
|
|
493
|
-
zIndex: getZIndex(style, entity, params.tags),
|
|
494
|
-
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND
|
|
495
|
-
},
|
|
496
|
-
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
497
|
-
show: false
|
|
498
|
-
});
|
|
499
|
-
params.viewer.entities.add(cEntity);
|
|
500
|
-
return cEntity;
|
|
501
|
-
}
|
|
502
|
-
Polyline.Render = Render;
|
|
503
|
-
function RenderGroup(params) {
|
|
504
|
-
var _a, _b;
|
|
505
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
506
|
-
var api, cEntities, i, entity, zoomItem, style, tagIds, tags, lStyle, cEntity;
|
|
507
|
-
return __generator(this, function (_c) {
|
|
508
|
-
switch (_c.label) {
|
|
509
|
-
case 0:
|
|
510
|
-
api = params.apiGetter.getApi();
|
|
511
|
-
cEntities = {};
|
|
512
|
-
i = 0;
|
|
513
|
-
_c.label = 1;
|
|
514
|
-
case 1:
|
|
515
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
516
|
-
entity = params.entities[i];
|
|
517
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
518
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
519
|
-
case 2:
|
|
520
|
-
style = _c.sent();
|
|
521
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
522
|
-
tags = [];
|
|
523
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
524
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
525
|
-
case 3:
|
|
526
|
-
tags = _c.sent();
|
|
527
|
-
_c.label = 4;
|
|
528
|
-
case 4:
|
|
529
|
-
lStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.polylineStyle) !== null && _b !== void 0 ? _b : {};
|
|
530
|
-
cEntity = Render({
|
|
531
|
-
entity: entity,
|
|
532
|
-
style: lStyle,
|
|
533
|
-
tags: tags,
|
|
534
|
-
viewer: params.viewer
|
|
535
|
-
});
|
|
536
|
-
if (cEntity) {
|
|
537
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
538
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
539
|
-
}
|
|
540
|
-
_c.label = 5;
|
|
541
|
-
case 5:
|
|
542
|
-
i++;
|
|
543
|
-
return [3 /*break*/, 1];
|
|
544
|
-
case 6: return [2 /*return*/, cEntities];
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
}
|
|
549
|
-
Polyline.RenderGroup = RenderGroup;
|
|
550
|
-
})(Polyline = EntityRenderEngine.Polyline || (EntityRenderEngine.Polyline = {}));
|
|
551
|
-
var Polygon;
|
|
552
|
-
(function (Polygon) {
|
|
553
|
-
function Render(params) {
|
|
554
|
-
var _a;
|
|
555
|
-
var entity = params.entity;
|
|
556
|
-
var pRings = (_a = entity.geometry) === null || _a === void 0 ? void 0 : _a.Polygon;
|
|
557
|
-
if (pRings == null || pRings.length <= 0) {
|
|
558
|
-
return null;
|
|
559
|
-
}
|
|
560
|
-
var style = params.style;
|
|
561
|
-
var bFillColor = bruce_models_1.Calculator.GetValue(style.fillColor, entity, params.tags);
|
|
562
|
-
var cFillColor = bFillColor ? colorToCColor(bFillColor) : Cesium.Color.RED;
|
|
563
|
-
var bLineColor = bruce_models_1.Calculator.GetValue(style.lineColor, entity, params.tags);
|
|
564
|
-
var cLineColor = bLineColor ? colorToCColor(bLineColor) : Cesium.Color.RED;
|
|
565
|
-
var width = style.lineWidth ? bruce_models_1.Calculator.GetValue(style.lineWidth, entity, params.tags) : null;
|
|
566
|
-
if (width == null) {
|
|
567
|
-
width = 4;
|
|
568
|
-
}
|
|
569
|
-
if (width <= 0) {
|
|
570
|
-
return null;
|
|
571
|
-
}
|
|
572
|
-
var heightRef = getHeightRef(style);
|
|
573
|
-
var outerRing = pRings.find(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Boundaries; });
|
|
574
|
-
var points = bruce_models_1.Geometry.ParsePoints(outerRing === null || outerRing === void 0 ? void 0 : outerRing.LinearRing);
|
|
575
|
-
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees(x.longitude, x.latitude, x.altitude); });
|
|
576
|
-
var extrusion = getPolygonExtrusion(entity, params.tags, outerRing, posses, heightRef, style);
|
|
577
|
-
posses = extrusion.posses;
|
|
578
|
-
var holeRings = pRings.filter(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Hole; });
|
|
579
|
-
var holePosses = holeRings.map(function (x) {
|
|
580
|
-
var points = bruce_models_1.Geometry.ParsePoints(x.LinearRing);
|
|
581
|
-
return points.map(function (x) { return Cesium.Cartesian3.fromDegrees(x.longitude, x.latitude, x.altitude); });
|
|
582
|
-
});
|
|
583
|
-
var zIndex = getZIndex(style, entity, params.tags);
|
|
584
|
-
var cEntity = new Cesium.Entity({
|
|
585
|
-
polygon: {
|
|
586
|
-
hierarchy: new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); })),
|
|
587
|
-
material: cFillColor,
|
|
588
|
-
extrudedHeight: extrusion.value,
|
|
589
|
-
extrudedHeightReference: extrusion.exHeightRef,
|
|
590
|
-
shadows: Cesium.ShadowMode.ENABLED,
|
|
591
|
-
heightReference: heightRef,
|
|
592
|
-
classificationType: Cesium.ClassificationType.BOTH,
|
|
593
|
-
perPositionHeight: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true,
|
|
594
|
-
zIndex: zIndex
|
|
595
|
-
},
|
|
596
|
-
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
597
|
-
show: false
|
|
598
|
-
});
|
|
599
|
-
cEntity._siblingGraphics = [];
|
|
600
|
-
for (var i = 0; i < holePosses.length; i++) {
|
|
601
|
-
var posses_1 = holePosses[i];
|
|
602
|
-
var cEntityHole = new Cesium.Entity({
|
|
603
|
-
polyline: new Cesium.PolylineGraphics({
|
|
604
|
-
positions: posses_1,
|
|
605
|
-
material: cLineColor,
|
|
606
|
-
width: width,
|
|
607
|
-
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
608
|
-
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
609
|
-
arcType: Cesium.ArcType.GEODESIC,
|
|
610
|
-
zIndex: zIndex
|
|
611
|
-
}),
|
|
612
|
-
show: false
|
|
613
|
-
});
|
|
614
|
-
cEntity._siblingGraphics.push(cEntityHole);
|
|
615
|
-
cEntityHole._parentEntity = cEntity;
|
|
616
|
-
params.viewer.entities.add(cEntityHole);
|
|
617
|
-
}
|
|
618
|
-
params.viewer.entities.add(cEntity);
|
|
619
|
-
return cEntity;
|
|
620
|
-
}
|
|
621
|
-
Polygon.Render = Render;
|
|
622
|
-
function RenderGroup(params) {
|
|
623
|
-
var _a, _b;
|
|
624
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
625
|
-
var api, cEntities, i, entity, zoomItem, style, tagIds, tags, pStyle, cEntity;
|
|
626
|
-
return __generator(this, function (_c) {
|
|
627
|
-
switch (_c.label) {
|
|
628
|
-
case 0:
|
|
629
|
-
api = params.apiGetter.getApi();
|
|
630
|
-
cEntities = {};
|
|
631
|
-
i = 0;
|
|
632
|
-
_c.label = 1;
|
|
633
|
-
case 1:
|
|
634
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
635
|
-
entity = params.entities[i];
|
|
636
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
637
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
638
|
-
case 2:
|
|
639
|
-
style = _c.sent();
|
|
640
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
641
|
-
tags = [];
|
|
642
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
643
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
644
|
-
case 3:
|
|
645
|
-
tags = _c.sent();
|
|
646
|
-
_c.label = 4;
|
|
647
|
-
case 4:
|
|
648
|
-
pStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.polygonStyle) !== null && _b !== void 0 ? _b : {};
|
|
649
|
-
cEntity = Render({
|
|
650
|
-
entity: entity,
|
|
651
|
-
style: pStyle,
|
|
652
|
-
tags: tags,
|
|
653
|
-
viewer: params.viewer
|
|
654
|
-
});
|
|
655
|
-
if (cEntity) {
|
|
656
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
657
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
658
|
-
}
|
|
659
|
-
_c.label = 5;
|
|
660
|
-
case 5:
|
|
661
|
-
i++;
|
|
662
|
-
return [3 /*break*/, 1];
|
|
663
|
-
case 6: return [2 /*return*/, cEntities];
|
|
664
|
-
}
|
|
665
|
-
});
|
|
666
|
-
});
|
|
667
|
-
}
|
|
668
|
-
Polygon.RenderGroup = RenderGroup;
|
|
669
|
-
})(Polygon = EntityRenderEngine.Polygon || (EntityRenderEngine.Polygon = {}));
|
|
670
|
-
var Model3d;
|
|
671
|
-
(function (Model3d) {
|
|
672
|
-
function Render(params) {
|
|
673
|
-
var entity = params.entity;
|
|
674
|
-
var transform = entity === null || entity === void 0 ? void 0 : entity.transform;
|
|
675
|
-
var heading = transform ? +transform.heading : 0;
|
|
676
|
-
heading = (heading + 90) % 360;
|
|
677
|
-
var pitch = transform ? +transform.pitch : 0;
|
|
678
|
-
var roll = transform ? +transform.roll : 0;
|
|
679
|
-
var scale = transform ? +transform.scale : 1;
|
|
680
|
-
if (scale <= 0) {
|
|
681
|
-
scale = 1;
|
|
682
|
-
}
|
|
683
|
-
var style = params.style;
|
|
684
|
-
var styleScale = (style === null || style === void 0 ? void 0 : style.scale) ? +bruce_models_1.Calculator.GetValue(style === null || style === void 0 ? void 0 : style.scale, entity, params.tags) : null;
|
|
685
|
-
if (!styleScale) {
|
|
686
|
-
styleScale = 1;
|
|
687
|
-
}
|
|
688
|
-
scale *= styleScale;
|
|
689
|
-
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
|
|
690
|
-
var heightRef = getHeightRef(style);
|
|
691
|
-
var pos = entity_utils_1.EntityUtils.GetPos(params.viewer, entity);
|
|
692
|
-
if (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
693
|
-
var carto = Cesium.Cartographic.fromCartesian(pos);
|
|
694
|
-
pos = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, 0);
|
|
695
|
-
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
696
|
-
}
|
|
697
|
-
var orientation = Cesium.Transforms.headingPitchRollQuaternion(pos, hpr);
|
|
698
|
-
var blendMode = null;
|
|
699
|
-
var blendAmount = null;
|
|
700
|
-
var color = null;
|
|
701
|
-
if (style === null || style === void 0 ? void 0 : style.customize) {
|
|
702
|
-
blendMode = style.fillColorBlendMode;
|
|
703
|
-
if (!blendMode) {
|
|
704
|
-
blendMode = Cesium.ColorBlendMode.HIGHLIGHT;
|
|
705
|
-
}
|
|
706
|
-
if (blendMode == Cesium.ColorBlendMode.MIX) {
|
|
707
|
-
blendAmount = style.fillColorBlendAmount;
|
|
708
|
-
if (!blendAmount) {
|
|
709
|
-
blendAmount = 0.5;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
var bColor = bruce_models_1.Calculator.GetValue(style.fillColor, entity, params.tags);
|
|
713
|
-
if (bColor) {
|
|
714
|
-
color = colorToCColor(bColor);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
var cEntity = new Cesium.Entity({
|
|
718
|
-
model: {
|
|
719
|
-
uri: params.lodUrl,
|
|
720
|
-
heightReference: heightRef,
|
|
721
|
-
scale: scale,
|
|
722
|
-
shadows: Cesium.ShadowMode.ENABLED,
|
|
723
|
-
colorBlendAmount: blendAmount,
|
|
724
|
-
colorBlendMode: blendMode,
|
|
725
|
-
color: color
|
|
726
|
-
},
|
|
727
|
-
orientation: orientation,
|
|
728
|
-
position: pos,
|
|
729
|
-
show: false
|
|
730
|
-
});
|
|
731
|
-
params.viewer.entities.add(cEntity);
|
|
732
|
-
return cEntity;
|
|
733
|
-
}
|
|
734
|
-
Model3d.Render = Render;
|
|
735
|
-
function RenderGroup(params) {
|
|
736
|
-
var _a, _b, _c, _d;
|
|
737
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
738
|
-
var api, cEntities, reqBody, i, entity, zoomItem, style, tagIds, tags, mStyle, group, level, catId, lodData, _loop_1, i;
|
|
739
|
-
return __generator(this, function (_e) {
|
|
740
|
-
switch (_e.label) {
|
|
741
|
-
case 0:
|
|
742
|
-
api = params.apiGetter.getApi();
|
|
743
|
-
cEntities = {};
|
|
744
|
-
reqBody = {
|
|
745
|
-
"strict": false,
|
|
746
|
-
"externalSources": false,
|
|
747
|
-
"Items": []
|
|
748
|
-
};
|
|
749
|
-
i = 0;
|
|
750
|
-
_e.label = 1;
|
|
751
|
-
case 1:
|
|
752
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
753
|
-
entity = params.entities[i];
|
|
754
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
755
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
756
|
-
case 2:
|
|
757
|
-
style = _e.sent();
|
|
758
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
759
|
-
tags = [];
|
|
760
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
761
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
762
|
-
case 3:
|
|
763
|
-
tags = _e.sent();
|
|
764
|
-
_e.label = 4;
|
|
765
|
-
case 4:
|
|
766
|
-
mStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.polygonStyle) !== null && _b !== void 0 ? _b : {};
|
|
767
|
-
group = mStyle.lodGroup ? bruce_models_1.Calculator.GetValue(mStyle.lodGroup, entity, tags) : null;
|
|
768
|
-
if (!group) {
|
|
769
|
-
group = "DEFAULT";
|
|
770
|
-
}
|
|
771
|
-
level = +zoomItem.LODLevel;
|
|
772
|
-
if (!level) {
|
|
773
|
-
level = 0;
|
|
774
|
-
}
|
|
775
|
-
catId = zoomItem.LODCategoryID;
|
|
776
|
-
if (!catId) {
|
|
777
|
-
catId = "glb";
|
|
778
|
-
}
|
|
779
|
-
reqBody.Items.push({
|
|
780
|
-
"entityId": entity.Bruce.ID,
|
|
781
|
-
"categoryId": catId,
|
|
782
|
-
"group": group,
|
|
783
|
-
"level": level
|
|
784
|
-
});
|
|
785
|
-
_e.label = 5;
|
|
786
|
-
case 5:
|
|
787
|
-
i++;
|
|
788
|
-
return [3 /*break*/, 1];
|
|
789
|
-
case 6: return [4 /*yield*/, bruce_models_1.EntityLod.GetLods(api, reqBody)];
|
|
790
|
-
case 7:
|
|
791
|
-
lodData = _e.sent();
|
|
792
|
-
_loop_1 = function (i) {
|
|
793
|
-
var entity, zoomItem, style, tagIds, tags, lod, mStyle, cEntity;
|
|
794
|
-
return __generator(this, function (_a) {
|
|
795
|
-
switch (_a.label) {
|
|
796
|
-
case 0:
|
|
797
|
-
entity = params.entities[i];
|
|
798
|
-
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
799
|
-
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
800
|
-
case 1:
|
|
801
|
-
style = _a.sent();
|
|
802
|
-
tagIds = entity.Bruce["Layer.ID"];
|
|
803
|
-
tags = [];
|
|
804
|
-
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 3];
|
|
805
|
-
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
806
|
-
case 2:
|
|
807
|
-
tags = _a.sent();
|
|
808
|
-
_a.label = 3;
|
|
809
|
-
case 3:
|
|
810
|
-
lod = lodData.find(function (x) { return x.entityId == entity.Bruce.ID; });
|
|
811
|
-
if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
|
|
812
|
-
return [2 /*return*/, "continue"];
|
|
813
|
-
}
|
|
814
|
-
mStyle = (_d = (_c = style === null || style === void 0 ? void 0 : style.Settings) === null || _c === void 0 ? void 0 : _c.polygonStyle) !== null && _d !== void 0 ? _d : {};
|
|
815
|
-
cEntity = Render({
|
|
816
|
-
entity: entity,
|
|
817
|
-
style: mStyle,
|
|
818
|
-
tags: tags,
|
|
819
|
-
viewer: params.viewer,
|
|
820
|
-
lodUrl: bruce_models_1.ClientFile.GetUrl(api, lod.clientFileId)
|
|
821
|
-
});
|
|
822
|
-
if (cEntity) {
|
|
823
|
-
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
824
|
-
cEntities[entity.Bruce.ID] = cEntity;
|
|
825
|
-
}
|
|
826
|
-
return [2 /*return*/];
|
|
827
|
-
}
|
|
828
|
-
});
|
|
829
|
-
};
|
|
830
|
-
i = 0;
|
|
831
|
-
_e.label = 8;
|
|
832
|
-
case 8:
|
|
833
|
-
if (!(i < params.entities.length)) return [3 /*break*/, 11];
|
|
834
|
-
return [5 /*yield**/, _loop_1(i)];
|
|
835
|
-
case 9:
|
|
836
|
-
_e.sent();
|
|
837
|
-
_e.label = 10;
|
|
838
|
-
case 10:
|
|
839
|
-
i++;
|
|
840
|
-
return [3 /*break*/, 8];
|
|
841
|
-
case 11: return [2 /*return*/, cEntities];
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
});
|
|
845
|
-
}
|
|
846
|
-
Model3d.RenderGroup = RenderGroup;
|
|
847
|
-
})(Model3d = EntityRenderEngine.Model3d || (EntityRenderEngine.Model3d = {}));
|
|
848
|
-
})(EntityRenderEngine = exports.EntityRenderEngine || (exports.EntityRenderEngine = {}));
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.EntityRenderEngine = void 0;
|
|
51
|
+
var Cesium = require("cesium");
|
|
52
|
+
var bruce_models_1 = require("bruce-models");
|
|
53
|
+
var entity_utils_1 = require("../utils/entity-utils");
|
|
54
|
+
var render_manager_1 = require("./render-managers/render-manager");
|
|
55
|
+
function colorToCColor(color) {
|
|
56
|
+
return new Cesium.Color(color.red ? color.red / 255 : 0, color.green ? color.green / 255 : 0, color.blue ? color.blue / 255 : 0, color.alpha);
|
|
57
|
+
}
|
|
58
|
+
function getPolygonStyleExtrusion(pStyle, entity, tags, heightRef) {
|
|
59
|
+
var _a;
|
|
60
|
+
var attrPath = pStyle.extrusionPath;
|
|
61
|
+
if (!pStyle.useExtrusion || !attrPath) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
var extrusion = +bruce_models_1.Calculator.GetValue(attrPath, entity, tags);
|
|
66
|
+
if (!extrusion && extrusion != 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/*
|
|
70
|
+
Cesium extrudes in strange way.
|
|
71
|
+
If you want something that is 50 meters above sea, and 5 meters tall,
|
|
72
|
+
You need to extrude by 55 meters, if you extrude by 5 it will extrude from sea and look flat.
|
|
73
|
+
*/
|
|
74
|
+
var height = (_a = entity.location) === null || _a === void 0 ? void 0 : _a.altitude;
|
|
75
|
+
return heightRef == Cesium.HeightReference.RELATIVE_TO_GROUND ? extrusion + height : extrusion;
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.error(e);
|
|
79
|
+
}
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
function getPolygonExtrusion(entity, tags, ring, posses, heightRef, pStyle) {
|
|
83
|
+
var _a;
|
|
84
|
+
var data = {
|
|
85
|
+
value: undefined,
|
|
86
|
+
exHeightRef: Cesium.HeightReference.RELATIVE_TO_GROUND,
|
|
87
|
+
posses: null
|
|
88
|
+
};
|
|
89
|
+
// Step 1. Try get using style.
|
|
90
|
+
var extrusion = getPolygonStyleExtrusion(pStyle, entity, tags, heightRef);
|
|
91
|
+
if (extrusion) {
|
|
92
|
+
if (heightRef == Cesium.HeightReference.NONE) {
|
|
93
|
+
// Let's normalize all point heights to be the same (at entity altitude).
|
|
94
|
+
// This let's us have a consistent extrusion height, and be adjustable easier by user.
|
|
95
|
+
var alt_1 = (_a = entity === null || entity === void 0 ? void 0 : entity.location) === null || _a === void 0 ? void 0 : _a.altitude;
|
|
96
|
+
if (!alt_1) {
|
|
97
|
+
alt_1 = 0;
|
|
98
|
+
}
|
|
99
|
+
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
100
|
+
points.forEach(function (point) {
|
|
101
|
+
point.height = alt_1;
|
|
102
|
+
});
|
|
103
|
+
posses = points.map(function (x) { return Cesium.Cartesian3.fromRadians(x.longitude, x.latitude, x.height); });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// Step 2. Try get using geometry data.
|
|
107
|
+
else {
|
|
108
|
+
data.exHeightRef = undefined;
|
|
109
|
+
if (ring.Height && ring.Height > 0) {
|
|
110
|
+
var points = posses.map(function (x) { return Cesium.Cartographic.fromCartesian(x); });
|
|
111
|
+
if (points.length <= 0) {
|
|
112
|
+
data.value = ring.Height;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
var highest = null;
|
|
116
|
+
for (var i = 0; i < points.length; i++) {
|
|
117
|
+
var pointHeight = points[i].height;
|
|
118
|
+
if (pointHeight > highest || highest === null) {
|
|
119
|
+
highest = pointHeight;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
highest = (highest === null ? 0 : highest) + ring.Height;
|
|
123
|
+
data.value = highest;
|
|
124
|
+
}
|
|
125
|
+
data.exHeightRef = Cesium.HeightReference.NONE;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
data.posses = posses;
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
function getHeightRef(style) {
|
|
132
|
+
var _a;
|
|
133
|
+
var heightRef = Cesium.HeightReference.CLAMP_TO_GROUND;
|
|
134
|
+
var altOptionId = (_a = style === null || style === void 0 ? void 0 : style.altitudeOption) === null || _a === void 0 ? void 0 : _a.id;
|
|
135
|
+
if (altOptionId == 1) {
|
|
136
|
+
heightRef = Cesium.HeightReference.NONE;
|
|
137
|
+
}
|
|
138
|
+
else if (altOptionId == 2) {
|
|
139
|
+
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
140
|
+
}
|
|
141
|
+
return heightRef;
|
|
142
|
+
}
|
|
143
|
+
function getZIndex(style, entity, tags) {
|
|
144
|
+
var zIndex = (style === null || style === void 0 ? void 0 : style.zIndex) ? +bruce_models_1.Calculator.GetValue(style === null || style === void 0 ? void 0 : style.zIndex, entity, tags) : 0;
|
|
145
|
+
if (zIndex == null) {
|
|
146
|
+
zIndex = 0;
|
|
147
|
+
}
|
|
148
|
+
return zIndex;
|
|
149
|
+
}
|
|
150
|
+
function getStyle(api, entity, styleId) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
+
var style, type;
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
style = null;
|
|
157
|
+
if (!styleId) return [3 /*break*/, 2];
|
|
158
|
+
return [4 /*yield*/, bruce_models_1.Style.Get(api, styleId)];
|
|
159
|
+
case 1:
|
|
160
|
+
style = _a.sent();
|
|
161
|
+
_a.label = 2;
|
|
162
|
+
case 2:
|
|
163
|
+
if (!!style) return [3 /*break*/, 5];
|
|
164
|
+
return [4 /*yield*/, bruce_models_1.EntityType.Get(api, entity.Bruce["EntityType.ID"])];
|
|
165
|
+
case 3:
|
|
166
|
+
type = _a.sent();
|
|
167
|
+
if (!type["DisplaySetting.ID"]) return [3 /*break*/, 5];
|
|
168
|
+
return [4 /*yield*/, bruce_models_1.Style.Get(api, type["DisplaySetting.ID"])];
|
|
169
|
+
case 4:
|
|
170
|
+
style = _a.sent();
|
|
171
|
+
_a.label = 5;
|
|
172
|
+
case 5: return [2 /*return*/, style];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
function getExistingCEntity(entityId, menuItemId, item, visualRegister) {
|
|
178
|
+
var _a;
|
|
179
|
+
return (_a = visualRegister.GetRego(entityId, menuItemId)) === null || _a === void 0 ? void 0 : _a.visual;
|
|
180
|
+
}
|
|
181
|
+
function getRenderGroupId(zoomItem) {
|
|
182
|
+
if (!zoomItem) {
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
return zoomItem.MinZoom + "-" + zoomItem.MaxZoom;
|
|
186
|
+
}
|
|
187
|
+
var EntityRenderEngine;
|
|
188
|
+
(function (EntityRenderEngine) {
|
|
189
|
+
function Render(params) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
191
|
+
var groupRenderParams, cEntities, models, polygons, polylines, points, i, entity, id, zoomItem, displayType, newRenderId, existing, oldRenderId, mParams, mEntities, i, entity, id, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity, pParams, pEntities, i, entity, cEntity;
|
|
192
|
+
return __generator(this, function (_a) {
|
|
193
|
+
switch (_a.label) {
|
|
194
|
+
case 0:
|
|
195
|
+
groupRenderParams = {
|
|
196
|
+
apiGetter: params.apiGetter,
|
|
197
|
+
viewer: params.viewer,
|
|
198
|
+
entities: [],
|
|
199
|
+
zoomItems: {},
|
|
200
|
+
menuItemId: params.menuItemId,
|
|
201
|
+
visualRegister: params.visualRegister
|
|
202
|
+
};
|
|
203
|
+
cEntities = {};
|
|
204
|
+
models = [];
|
|
205
|
+
polygons = [];
|
|
206
|
+
polylines = [];
|
|
207
|
+
points = [];
|
|
208
|
+
// Initial sorting.
|
|
209
|
+
for (i = 0; i < params.entities.length; i++) {
|
|
210
|
+
entity = params.entities[i];
|
|
211
|
+
id = entity.Bruce.ID;
|
|
212
|
+
zoomItem = render_manager_1.RenderManager.Utils.DetermineZoomItem(params.viewer, entity, params.zoomControl);
|
|
213
|
+
displayType = zoomItem === null || zoomItem === void 0 ? void 0 : zoomItem.DisplayType;
|
|
214
|
+
if (!displayType) {
|
|
215
|
+
displayType = bruce_models_1.ZoomControl.EDisplayType.Hidden;
|
|
216
|
+
}
|
|
217
|
+
// Backwards compatibility.
|
|
218
|
+
else if (displayType == "polygon") {
|
|
219
|
+
displayType = bruce_models_1.ZoomControl.EDisplayType.Geometry;
|
|
220
|
+
}
|
|
221
|
+
if (displayType != bruce_models_1.ZoomControl.EDisplayType.Hidden) {
|
|
222
|
+
newRenderId = getRenderGroupId(zoomItem);
|
|
223
|
+
existing = getExistingCEntity(id, params.menuItemId, zoomItem, params.visualRegister);
|
|
224
|
+
oldRenderId = existing === null || existing === void 0 ? void 0 : existing._renderGroup;
|
|
225
|
+
if (newRenderId == oldRenderId) {
|
|
226
|
+
cEntities[id] = existing;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
if (displayType == bruce_models_1.ZoomControl.EDisplayType.Model3D) {
|
|
230
|
+
models.push(entity);
|
|
231
|
+
}
|
|
232
|
+
else if (displayType == bruce_models_1.ZoomControl.EDisplayType.Geometry) {
|
|
233
|
+
polygons.push(entity);
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
points.push(entity);
|
|
237
|
+
}
|
|
238
|
+
groupRenderParams.zoomItems[id] = zoomItem;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (!(models.length > 0)) return [3 /*break*/, 2];
|
|
243
|
+
mParams = __assign(__assign({}, groupRenderParams), { entities: models });
|
|
244
|
+
return [4 /*yield*/, Model3d.RenderGroup(mParams)];
|
|
245
|
+
case 1:
|
|
246
|
+
mEntities = _a.sent();
|
|
247
|
+
for (i = 0; i < mParams.entities.length; i++) {
|
|
248
|
+
entity = mParams.entities[i];
|
|
249
|
+
id = entity.Bruce.ID;
|
|
250
|
+
cEntity = mEntities[id];
|
|
251
|
+
if (cEntity) {
|
|
252
|
+
cEntities[id] = cEntity;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
polygons.push(entity);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
_a.label = 2;
|
|
259
|
+
case 2:
|
|
260
|
+
if (!(polygons.length > 0)) return [3 /*break*/, 4];
|
|
261
|
+
pParams = __assign(__assign({}, groupRenderParams), { entities: polygons });
|
|
262
|
+
return [4 /*yield*/, Polygon.RenderGroup(pParams)];
|
|
263
|
+
case 3:
|
|
264
|
+
pEntities = _a.sent();
|
|
265
|
+
for (i = 0; i < pParams.entities.length; i++) {
|
|
266
|
+
entity = pParams.entities[i];
|
|
267
|
+
cEntity = pEntities[entity.Bruce.ID];
|
|
268
|
+
if (cEntity) {
|
|
269
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
polylines.push(entity);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
_a.label = 4;
|
|
276
|
+
case 4:
|
|
277
|
+
if (!(polylines.length > 0)) return [3 /*break*/, 6];
|
|
278
|
+
pParams = __assign(__assign({}, groupRenderParams), { entities: polylines });
|
|
279
|
+
return [4 /*yield*/, Polyline.RenderGroup(pParams)];
|
|
280
|
+
case 5:
|
|
281
|
+
pEntities = _a.sent();
|
|
282
|
+
for (i = 0; i < pParams.entities.length; i++) {
|
|
283
|
+
entity = pParams.entities[i];
|
|
284
|
+
cEntity = pEntities[entity.Bruce.ID];
|
|
285
|
+
if (cEntity) {
|
|
286
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
points.push(entity);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
_a.label = 6;
|
|
293
|
+
case 6:
|
|
294
|
+
if (!(points.length > 0)) return [3 /*break*/, 8];
|
|
295
|
+
pParams = __assign(__assign({}, groupRenderParams), { entities: points });
|
|
296
|
+
return [4 /*yield*/, Point.RenderGroup(pParams)];
|
|
297
|
+
case 7:
|
|
298
|
+
pEntities = _a.sent();
|
|
299
|
+
for (i = 0; i < pParams.entities.length; i++) {
|
|
300
|
+
entity = pParams.entities[i];
|
|
301
|
+
cEntity = pEntities[entity.Bruce.ID];
|
|
302
|
+
if (cEntity) {
|
|
303
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
_a.label = 8;
|
|
307
|
+
case 8: return [2 /*return*/, cEntities];
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
EntityRenderEngine.Render = Render;
|
|
313
|
+
function Remove(viewer, entity) {
|
|
314
|
+
if (entity._parentEntity) {
|
|
315
|
+
Remove(viewer, entity._parentEntity);
|
|
316
|
+
}
|
|
317
|
+
if (entity._siblingGraphics) {
|
|
318
|
+
for (var i = 0; i < entity._siblingGraphics.length; i++) {
|
|
319
|
+
var sibling = entity._siblingGraphics[i];
|
|
320
|
+
Remove(viewer, sibling);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
if (viewer.entities.contains(entity)) {
|
|
324
|
+
viewer.entities.remove(entity);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
EntityRenderEngine.Remove = Remove;
|
|
328
|
+
var Point;
|
|
329
|
+
(function (Point) {
|
|
330
|
+
function Render(params) {
|
|
331
|
+
var entity = params.entity;
|
|
332
|
+
var style = params.style;
|
|
333
|
+
var type = style.Type;
|
|
334
|
+
var cEntity = null;
|
|
335
|
+
if (type == bruce_models_1.Style.EPointType.Icon) {
|
|
336
|
+
var icon = bruce_models_1.Calculator.GetValue(style.iconUrl, entity, params.tags);
|
|
337
|
+
var iconUrl = null;
|
|
338
|
+
if (typeof icon == "string") {
|
|
339
|
+
iconUrl = icon;
|
|
340
|
+
}
|
|
341
|
+
if (!iconUrl && style.iconId) {
|
|
342
|
+
iconUrl = bruce_models_1.ClientFile.GetUrl(params.api, style.iconId);
|
|
343
|
+
}
|
|
344
|
+
if (iconUrl) {
|
|
345
|
+
var iconScale = +bruce_models_1.Calculator.GetValue(style.iconScale, entity, params.tags);
|
|
346
|
+
if (!iconScale && iconScale != 0) {
|
|
347
|
+
iconScale = 1;
|
|
348
|
+
}
|
|
349
|
+
if (iconScale > 0) {
|
|
350
|
+
cEntity = new Cesium.Entity({
|
|
351
|
+
billboard: {
|
|
352
|
+
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
|
353
|
+
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
|
354
|
+
image: iconUrl,
|
|
355
|
+
heightReference: getHeightRef(style)
|
|
356
|
+
},
|
|
357
|
+
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
358
|
+
show: false
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (type == bruce_models_1.Style.EPointType.Cylinder) {
|
|
364
|
+
// TODO: Cylinder.
|
|
365
|
+
}
|
|
366
|
+
if (!cEntity) {
|
|
367
|
+
var bColor = style.color ? bruce_models_1.Calculator.GetValue(style.color, entity, params.tags) : null;
|
|
368
|
+
var cColor = bColor ? colorToCColor(bColor) : Cesium.Color.RED;
|
|
369
|
+
var size = style.size ? bruce_models_1.Calculator.GetValue(style.size, entity, params.tags) : null;
|
|
370
|
+
if (size == null) {
|
|
371
|
+
size = 30;
|
|
372
|
+
}
|
|
373
|
+
if (size <= 0) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
cEntity = new Cesium.Entity({
|
|
377
|
+
point: {
|
|
378
|
+
pixelSize: size,
|
|
379
|
+
color: cColor,
|
|
380
|
+
heightReference: getHeightRef(style)
|
|
381
|
+
},
|
|
382
|
+
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
383
|
+
show: false
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
if (cEntity) {
|
|
387
|
+
params.viewer.entities.add(cEntity);
|
|
388
|
+
}
|
|
389
|
+
return cEntity;
|
|
390
|
+
}
|
|
391
|
+
Point.Render = Render;
|
|
392
|
+
function RenderGroup(params) {
|
|
393
|
+
var _a, _b;
|
|
394
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
395
|
+
var api, cEntities, i, entity, zoomItem, style, tagIds, tags, pStyle, cEntity;
|
|
396
|
+
return __generator(this, function (_c) {
|
|
397
|
+
switch (_c.label) {
|
|
398
|
+
case 0:
|
|
399
|
+
api = params.apiGetter.getApi();
|
|
400
|
+
cEntities = {};
|
|
401
|
+
i = 0;
|
|
402
|
+
_c.label = 1;
|
|
403
|
+
case 1:
|
|
404
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
405
|
+
entity = params.entities[i];
|
|
406
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
407
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
408
|
+
case 2:
|
|
409
|
+
style = _c.sent();
|
|
410
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
411
|
+
tags = [];
|
|
412
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
413
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
414
|
+
case 3:
|
|
415
|
+
tags = _c.sent();
|
|
416
|
+
_c.label = 4;
|
|
417
|
+
case 4:
|
|
418
|
+
pStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.pointStyle) !== null && _b !== void 0 ? _b : {};
|
|
419
|
+
cEntity = Render({
|
|
420
|
+
entity: entity,
|
|
421
|
+
style: pStyle,
|
|
422
|
+
tags: tags,
|
|
423
|
+
viewer: params.viewer,
|
|
424
|
+
api: api
|
|
425
|
+
});
|
|
426
|
+
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
427
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
428
|
+
_c.label = 5;
|
|
429
|
+
case 5:
|
|
430
|
+
i++;
|
|
431
|
+
return [3 /*break*/, 1];
|
|
432
|
+
case 6: return [2 /*return*/, cEntities];
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
Point.RenderGroup = RenderGroup;
|
|
438
|
+
})(Point = EntityRenderEngine.Point || (EntityRenderEngine.Point = {}));
|
|
439
|
+
var Polyline;
|
|
440
|
+
(function (Polyline) {
|
|
441
|
+
function Render(params) {
|
|
442
|
+
var _a;
|
|
443
|
+
var entity = params.entity;
|
|
444
|
+
var line = (_a = entity.geometry) === null || _a === void 0 ? void 0 : _a.LineString;
|
|
445
|
+
var points = line && typeof line == "string" ? bruce_models_1.Geometry.ParsePoints(line) : [];
|
|
446
|
+
if (!points || points.length < 2) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
var isValid = true;
|
|
450
|
+
for (var i = 0; i < points.length; i++) {
|
|
451
|
+
if (!bruce_models_1.Carto.ValidateCarto(points[i])) {
|
|
452
|
+
isValid = false;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
if (!isValid) {
|
|
457
|
+
return null;
|
|
458
|
+
}
|
|
459
|
+
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees(x.longitude, x.latitude, x.altitude); });
|
|
460
|
+
// Making sure no 0 length lines coming through.
|
|
461
|
+
// Ideally we would measure the full line but I fear that's too expensive.
|
|
462
|
+
if (posses.length == 2 || posses.length == 3) {
|
|
463
|
+
var totalDistance = 0;
|
|
464
|
+
for (var i = 0; i < posses.length; i++) {
|
|
465
|
+
var pos1 = posses[i];
|
|
466
|
+
var pos2 = posses[i + 1];
|
|
467
|
+
if (pos1 && pos2) {
|
|
468
|
+
totalDistance += Cesium.Cartesian3.distance(pos1, pos2);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (totalDistance < 0.001) {
|
|
472
|
+
return null;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
var style = params.style;
|
|
476
|
+
var bColor = style.lineColor ? bruce_models_1.Calculator.GetValue(style.lineColor, entity, params.tags) : null;
|
|
477
|
+
var cColor = bColor ? colorToCColor(bColor) : Cesium.Color.RED;
|
|
478
|
+
var width = style.lineWidth ? bruce_models_1.Calculator.GetValue(style.lineWidth, entity, params.tags) : null;
|
|
479
|
+
if (width == null) {
|
|
480
|
+
width = 4;
|
|
481
|
+
}
|
|
482
|
+
if (width <= 0) {
|
|
483
|
+
return null;
|
|
484
|
+
}
|
|
485
|
+
var heightRef = getHeightRef(style);
|
|
486
|
+
var cEntity = new Cesium.Entity({
|
|
487
|
+
polyline: {
|
|
488
|
+
positions: posses,
|
|
489
|
+
material: cColor,
|
|
490
|
+
width: width,
|
|
491
|
+
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
492
|
+
arcType: Cesium.ArcType.GEODESIC,
|
|
493
|
+
zIndex: getZIndex(style, entity, params.tags),
|
|
494
|
+
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND
|
|
495
|
+
},
|
|
496
|
+
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
497
|
+
show: false
|
|
498
|
+
});
|
|
499
|
+
params.viewer.entities.add(cEntity);
|
|
500
|
+
return cEntity;
|
|
501
|
+
}
|
|
502
|
+
Polyline.Render = Render;
|
|
503
|
+
function RenderGroup(params) {
|
|
504
|
+
var _a, _b;
|
|
505
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
506
|
+
var api, cEntities, i, entity, zoomItem, style, tagIds, tags, lStyle, cEntity;
|
|
507
|
+
return __generator(this, function (_c) {
|
|
508
|
+
switch (_c.label) {
|
|
509
|
+
case 0:
|
|
510
|
+
api = params.apiGetter.getApi();
|
|
511
|
+
cEntities = {};
|
|
512
|
+
i = 0;
|
|
513
|
+
_c.label = 1;
|
|
514
|
+
case 1:
|
|
515
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
516
|
+
entity = params.entities[i];
|
|
517
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
518
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
519
|
+
case 2:
|
|
520
|
+
style = _c.sent();
|
|
521
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
522
|
+
tags = [];
|
|
523
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
524
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
525
|
+
case 3:
|
|
526
|
+
tags = _c.sent();
|
|
527
|
+
_c.label = 4;
|
|
528
|
+
case 4:
|
|
529
|
+
lStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.polylineStyle) !== null && _b !== void 0 ? _b : {};
|
|
530
|
+
cEntity = Render({
|
|
531
|
+
entity: entity,
|
|
532
|
+
style: lStyle,
|
|
533
|
+
tags: tags,
|
|
534
|
+
viewer: params.viewer
|
|
535
|
+
});
|
|
536
|
+
if (cEntity) {
|
|
537
|
+
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
538
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
539
|
+
}
|
|
540
|
+
_c.label = 5;
|
|
541
|
+
case 5:
|
|
542
|
+
i++;
|
|
543
|
+
return [3 /*break*/, 1];
|
|
544
|
+
case 6: return [2 /*return*/, cEntities];
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
Polyline.RenderGroup = RenderGroup;
|
|
550
|
+
})(Polyline = EntityRenderEngine.Polyline || (EntityRenderEngine.Polyline = {}));
|
|
551
|
+
var Polygon;
|
|
552
|
+
(function (Polygon) {
|
|
553
|
+
function Render(params) {
|
|
554
|
+
var _a;
|
|
555
|
+
var entity = params.entity;
|
|
556
|
+
var pRings = (_a = entity.geometry) === null || _a === void 0 ? void 0 : _a.Polygon;
|
|
557
|
+
if (pRings == null || pRings.length <= 0) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
var style = params.style;
|
|
561
|
+
var bFillColor = bruce_models_1.Calculator.GetValue(style.fillColor, entity, params.tags);
|
|
562
|
+
var cFillColor = bFillColor ? colorToCColor(bFillColor) : Cesium.Color.RED;
|
|
563
|
+
var bLineColor = bruce_models_1.Calculator.GetValue(style.lineColor, entity, params.tags);
|
|
564
|
+
var cLineColor = bLineColor ? colorToCColor(bLineColor) : Cesium.Color.RED;
|
|
565
|
+
var width = style.lineWidth ? bruce_models_1.Calculator.GetValue(style.lineWidth, entity, params.tags) : null;
|
|
566
|
+
if (width == null) {
|
|
567
|
+
width = 4;
|
|
568
|
+
}
|
|
569
|
+
if (width <= 0) {
|
|
570
|
+
return null;
|
|
571
|
+
}
|
|
572
|
+
var heightRef = getHeightRef(style);
|
|
573
|
+
var outerRing = pRings.find(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Boundaries; });
|
|
574
|
+
var points = bruce_models_1.Geometry.ParsePoints(outerRing === null || outerRing === void 0 ? void 0 : outerRing.LinearRing);
|
|
575
|
+
var posses = points.map(function (x) { return Cesium.Cartesian3.fromDegrees(x.longitude, x.latitude, x.altitude); });
|
|
576
|
+
var extrusion = getPolygonExtrusion(entity, params.tags, outerRing, posses, heightRef, style);
|
|
577
|
+
posses = extrusion.posses;
|
|
578
|
+
var holeRings = pRings.filter(function (x) { return x.Facing == bruce_models_1.Geometry.EPolygonRingType.Hole; });
|
|
579
|
+
var holePosses = holeRings.map(function (x) {
|
|
580
|
+
var points = bruce_models_1.Geometry.ParsePoints(x.LinearRing);
|
|
581
|
+
return points.map(function (x) { return Cesium.Cartesian3.fromDegrees(x.longitude, x.latitude, x.altitude); });
|
|
582
|
+
});
|
|
583
|
+
var zIndex = getZIndex(style, entity, params.tags);
|
|
584
|
+
var cEntity = new Cesium.Entity({
|
|
585
|
+
polygon: {
|
|
586
|
+
hierarchy: new Cesium.PolygonHierarchy(posses, holePosses.map(function (x) { return new Cesium.PolygonHierarchy(x); })),
|
|
587
|
+
material: cFillColor,
|
|
588
|
+
extrudedHeight: extrusion.value,
|
|
589
|
+
extrudedHeightReference: extrusion.exHeightRef,
|
|
590
|
+
shadows: Cesium.ShadowMode.ENABLED,
|
|
591
|
+
heightReference: heightRef,
|
|
592
|
+
classificationType: Cesium.ClassificationType.BOTH,
|
|
593
|
+
perPositionHeight: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND ? false : true,
|
|
594
|
+
zIndex: zIndex
|
|
595
|
+
},
|
|
596
|
+
position: entity_utils_1.EntityUtils.GetPos(params.viewer, entity),
|
|
597
|
+
show: false
|
|
598
|
+
});
|
|
599
|
+
cEntity._siblingGraphics = [];
|
|
600
|
+
for (var i = 0; i < holePosses.length; i++) {
|
|
601
|
+
var posses_1 = holePosses[i];
|
|
602
|
+
var cEntityHole = new Cesium.Entity({
|
|
603
|
+
polyline: new Cesium.PolylineGraphics({
|
|
604
|
+
positions: posses_1,
|
|
605
|
+
material: cLineColor,
|
|
606
|
+
width: width,
|
|
607
|
+
clampToGround: heightRef == Cesium.HeightReference.CLAMP_TO_GROUND,
|
|
608
|
+
classificationType: Cesium.ClassificationType.TERRAIN,
|
|
609
|
+
arcType: Cesium.ArcType.GEODESIC,
|
|
610
|
+
zIndex: zIndex
|
|
611
|
+
}),
|
|
612
|
+
show: false
|
|
613
|
+
});
|
|
614
|
+
cEntity._siblingGraphics.push(cEntityHole);
|
|
615
|
+
cEntityHole._parentEntity = cEntity;
|
|
616
|
+
params.viewer.entities.add(cEntityHole);
|
|
617
|
+
}
|
|
618
|
+
params.viewer.entities.add(cEntity);
|
|
619
|
+
return cEntity;
|
|
620
|
+
}
|
|
621
|
+
Polygon.Render = Render;
|
|
622
|
+
function RenderGroup(params) {
|
|
623
|
+
var _a, _b;
|
|
624
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
625
|
+
var api, cEntities, i, entity, zoomItem, style, tagIds, tags, pStyle, cEntity;
|
|
626
|
+
return __generator(this, function (_c) {
|
|
627
|
+
switch (_c.label) {
|
|
628
|
+
case 0:
|
|
629
|
+
api = params.apiGetter.getApi();
|
|
630
|
+
cEntities = {};
|
|
631
|
+
i = 0;
|
|
632
|
+
_c.label = 1;
|
|
633
|
+
case 1:
|
|
634
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
635
|
+
entity = params.entities[i];
|
|
636
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
637
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
638
|
+
case 2:
|
|
639
|
+
style = _c.sent();
|
|
640
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
641
|
+
tags = [];
|
|
642
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
643
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
644
|
+
case 3:
|
|
645
|
+
tags = _c.sent();
|
|
646
|
+
_c.label = 4;
|
|
647
|
+
case 4:
|
|
648
|
+
pStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.polygonStyle) !== null && _b !== void 0 ? _b : {};
|
|
649
|
+
cEntity = Render({
|
|
650
|
+
entity: entity,
|
|
651
|
+
style: pStyle,
|
|
652
|
+
tags: tags,
|
|
653
|
+
viewer: params.viewer
|
|
654
|
+
});
|
|
655
|
+
if (cEntity) {
|
|
656
|
+
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
657
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
658
|
+
}
|
|
659
|
+
_c.label = 5;
|
|
660
|
+
case 5:
|
|
661
|
+
i++;
|
|
662
|
+
return [3 /*break*/, 1];
|
|
663
|
+
case 6: return [2 /*return*/, cEntities];
|
|
664
|
+
}
|
|
665
|
+
});
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
Polygon.RenderGroup = RenderGroup;
|
|
669
|
+
})(Polygon = EntityRenderEngine.Polygon || (EntityRenderEngine.Polygon = {}));
|
|
670
|
+
var Model3d;
|
|
671
|
+
(function (Model3d) {
|
|
672
|
+
function Render(params) {
|
|
673
|
+
var entity = params.entity;
|
|
674
|
+
var transform = entity === null || entity === void 0 ? void 0 : entity.transform;
|
|
675
|
+
var heading = transform ? +transform.heading : 0;
|
|
676
|
+
heading = (heading + 90) % 360;
|
|
677
|
+
var pitch = transform ? +transform.pitch : 0;
|
|
678
|
+
var roll = transform ? +transform.roll : 0;
|
|
679
|
+
var scale = transform ? +transform.scale : 1;
|
|
680
|
+
if (scale <= 0) {
|
|
681
|
+
scale = 1;
|
|
682
|
+
}
|
|
683
|
+
var style = params.style;
|
|
684
|
+
var styleScale = (style === null || style === void 0 ? void 0 : style.scale) ? +bruce_models_1.Calculator.GetValue(style === null || style === void 0 ? void 0 : style.scale, entity, params.tags) : null;
|
|
685
|
+
if (!styleScale) {
|
|
686
|
+
styleScale = 1;
|
|
687
|
+
}
|
|
688
|
+
scale *= styleScale;
|
|
689
|
+
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
|
|
690
|
+
var heightRef = getHeightRef(style);
|
|
691
|
+
var pos = entity_utils_1.EntityUtils.GetPos(params.viewer, entity);
|
|
692
|
+
if (heightRef == Cesium.HeightReference.CLAMP_TO_GROUND) {
|
|
693
|
+
var carto = Cesium.Cartographic.fromCartesian(pos);
|
|
694
|
+
pos = Cesium.Cartesian3.fromRadians(carto.longitude, carto.latitude, 0);
|
|
695
|
+
heightRef = Cesium.HeightReference.RELATIVE_TO_GROUND;
|
|
696
|
+
}
|
|
697
|
+
var orientation = Cesium.Transforms.headingPitchRollQuaternion(pos, hpr);
|
|
698
|
+
var blendMode = null;
|
|
699
|
+
var blendAmount = null;
|
|
700
|
+
var color = null;
|
|
701
|
+
if (style === null || style === void 0 ? void 0 : style.customize) {
|
|
702
|
+
blendMode = style.fillColorBlendMode;
|
|
703
|
+
if (!blendMode) {
|
|
704
|
+
blendMode = Cesium.ColorBlendMode.HIGHLIGHT;
|
|
705
|
+
}
|
|
706
|
+
if (blendMode == Cesium.ColorBlendMode.MIX) {
|
|
707
|
+
blendAmount = style.fillColorBlendAmount;
|
|
708
|
+
if (!blendAmount) {
|
|
709
|
+
blendAmount = 0.5;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
var bColor = bruce_models_1.Calculator.GetValue(style.fillColor, entity, params.tags);
|
|
713
|
+
if (bColor) {
|
|
714
|
+
color = colorToCColor(bColor);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
var cEntity = new Cesium.Entity({
|
|
718
|
+
model: {
|
|
719
|
+
uri: params.lodUrl,
|
|
720
|
+
heightReference: heightRef,
|
|
721
|
+
scale: scale,
|
|
722
|
+
shadows: Cesium.ShadowMode.ENABLED,
|
|
723
|
+
colorBlendAmount: blendAmount,
|
|
724
|
+
colorBlendMode: blendMode,
|
|
725
|
+
color: color
|
|
726
|
+
},
|
|
727
|
+
orientation: orientation,
|
|
728
|
+
position: pos,
|
|
729
|
+
show: false
|
|
730
|
+
});
|
|
731
|
+
params.viewer.entities.add(cEntity);
|
|
732
|
+
return cEntity;
|
|
733
|
+
}
|
|
734
|
+
Model3d.Render = Render;
|
|
735
|
+
function RenderGroup(params) {
|
|
736
|
+
var _a, _b, _c, _d;
|
|
737
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
738
|
+
var api, cEntities, reqBody, i, entity, zoomItem, style, tagIds, tags, mStyle, group, level, catId, lodData, _loop_1, i;
|
|
739
|
+
return __generator(this, function (_e) {
|
|
740
|
+
switch (_e.label) {
|
|
741
|
+
case 0:
|
|
742
|
+
api = params.apiGetter.getApi();
|
|
743
|
+
cEntities = {};
|
|
744
|
+
reqBody = {
|
|
745
|
+
"strict": false,
|
|
746
|
+
"externalSources": false,
|
|
747
|
+
"Items": []
|
|
748
|
+
};
|
|
749
|
+
i = 0;
|
|
750
|
+
_e.label = 1;
|
|
751
|
+
case 1:
|
|
752
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 6];
|
|
753
|
+
entity = params.entities[i];
|
|
754
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
755
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
756
|
+
case 2:
|
|
757
|
+
style = _e.sent();
|
|
758
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
759
|
+
tags = [];
|
|
760
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 4];
|
|
761
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
762
|
+
case 3:
|
|
763
|
+
tags = _e.sent();
|
|
764
|
+
_e.label = 4;
|
|
765
|
+
case 4:
|
|
766
|
+
mStyle = (_b = (_a = style === null || style === void 0 ? void 0 : style.Settings) === null || _a === void 0 ? void 0 : _a.polygonStyle) !== null && _b !== void 0 ? _b : {};
|
|
767
|
+
group = mStyle.lodGroup ? bruce_models_1.Calculator.GetValue(mStyle.lodGroup, entity, tags) : null;
|
|
768
|
+
if (!group) {
|
|
769
|
+
group = "DEFAULT";
|
|
770
|
+
}
|
|
771
|
+
level = +zoomItem.LODLevel;
|
|
772
|
+
if (!level) {
|
|
773
|
+
level = 0;
|
|
774
|
+
}
|
|
775
|
+
catId = zoomItem.LODCategoryID;
|
|
776
|
+
if (!catId) {
|
|
777
|
+
catId = "glb";
|
|
778
|
+
}
|
|
779
|
+
reqBody.Items.push({
|
|
780
|
+
"entityId": entity.Bruce.ID,
|
|
781
|
+
"categoryId": catId,
|
|
782
|
+
"group": group,
|
|
783
|
+
"level": level
|
|
784
|
+
});
|
|
785
|
+
_e.label = 5;
|
|
786
|
+
case 5:
|
|
787
|
+
i++;
|
|
788
|
+
return [3 /*break*/, 1];
|
|
789
|
+
case 6: return [4 /*yield*/, bruce_models_1.EntityLod.GetLods(api, reqBody)];
|
|
790
|
+
case 7:
|
|
791
|
+
lodData = _e.sent();
|
|
792
|
+
_loop_1 = function (i) {
|
|
793
|
+
var entity, zoomItem, style, tagIds, tags, lod, mStyle, cEntity;
|
|
794
|
+
return __generator(this, function (_a) {
|
|
795
|
+
switch (_a.label) {
|
|
796
|
+
case 0:
|
|
797
|
+
entity = params.entities[i];
|
|
798
|
+
zoomItem = params.zoomItems[entity.Bruce.ID];
|
|
799
|
+
return [4 /*yield*/, getStyle(api, entity, zoomItem.StyleID)];
|
|
800
|
+
case 1:
|
|
801
|
+
style = _a.sent();
|
|
802
|
+
tagIds = entity.Bruce["Layer.ID"];
|
|
803
|
+
tags = [];
|
|
804
|
+
if (!(tagIds && tagIds.length > 0)) return [3 /*break*/, 3];
|
|
805
|
+
return [4 /*yield*/, bruce_models_1.EntityTag.GetListByIds(api, tagIds)];
|
|
806
|
+
case 2:
|
|
807
|
+
tags = _a.sent();
|
|
808
|
+
_a.label = 3;
|
|
809
|
+
case 3:
|
|
810
|
+
lod = lodData.find(function (x) { return x.entityId == entity.Bruce.ID; });
|
|
811
|
+
if (!(lod === null || lod === void 0 ? void 0 : lod.clientFileId)) {
|
|
812
|
+
return [2 /*return*/, "continue"];
|
|
813
|
+
}
|
|
814
|
+
mStyle = (_d = (_c = style === null || style === void 0 ? void 0 : style.Settings) === null || _c === void 0 ? void 0 : _c.polygonStyle) !== null && _d !== void 0 ? _d : {};
|
|
815
|
+
cEntity = Render({
|
|
816
|
+
entity: entity,
|
|
817
|
+
style: mStyle,
|
|
818
|
+
tags: tags,
|
|
819
|
+
viewer: params.viewer,
|
|
820
|
+
lodUrl: bruce_models_1.ClientFile.GetUrl(api, lod.clientFileId)
|
|
821
|
+
});
|
|
822
|
+
if (cEntity) {
|
|
823
|
+
cEntity._renderGroup = getRenderGroupId(zoomItem);
|
|
824
|
+
cEntities[entity.Bruce.ID] = cEntity;
|
|
825
|
+
}
|
|
826
|
+
return [2 /*return*/];
|
|
827
|
+
}
|
|
828
|
+
});
|
|
829
|
+
};
|
|
830
|
+
i = 0;
|
|
831
|
+
_e.label = 8;
|
|
832
|
+
case 8:
|
|
833
|
+
if (!(i < params.entities.length)) return [3 /*break*/, 11];
|
|
834
|
+
return [5 /*yield**/, _loop_1(i)];
|
|
835
|
+
case 9:
|
|
836
|
+
_e.sent();
|
|
837
|
+
_e.label = 10;
|
|
838
|
+
case 10:
|
|
839
|
+
i++;
|
|
840
|
+
return [3 /*break*/, 8];
|
|
841
|
+
case 11: return [2 /*return*/, cEntities];
|
|
842
|
+
}
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
Model3d.RenderGroup = RenderGroup;
|
|
847
|
+
})(Model3d = EntityRenderEngine.Model3d || (EntityRenderEngine.Model3d = {}));
|
|
848
|
+
})(EntityRenderEngine = exports.EntityRenderEngine || (exports.EntityRenderEngine = {}));
|
|
849
849
|
//# sourceMappingURL=entity-render-engine.js.map
|