bruce-cesium 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1514,7 +1514,7 @@
1514
1514
  Manager.prototype.onGetterUpdate = function (entities) {
1515
1515
  var _a;
1516
1516
  return __awaiter(this, void 0, void 0, function () {
1517
- var cEntities, i, id, cEntity, visual;
1517
+ var cEntities, i, entity, id, cEntity, visual;
1518
1518
  return __generator(this, function (_b) {
1519
1519
  switch (_b.label) {
1520
1520
  case 0:
@@ -1532,7 +1532,8 @@
1532
1532
  case 1:
1533
1533
  cEntities = _b.sent();
1534
1534
  for (i = 0; i < entities.length; i++) {
1535
- id = entities[i].Bruce.ID;
1535
+ entity = entities[i];
1536
+ id = entity.Bruce.ID;
1536
1537
  cEntity = cEntities[id];
1537
1538
  this.renderedEntities[id] = !!cEntity;
1538
1539
  if (cEntity) {
@@ -1542,7 +1543,8 @@
1542
1543
  entityId: id,
1543
1544
  menuItemId: this.item.id,
1544
1545
  visual: cEntity,
1545
- priority: 0
1546
+ priority: 0,
1547
+ entityTypeId: entity.Bruce["EntityType.ID"]
1546
1548
  });
1547
1549
  }
1548
1550
  }
@@ -1609,7 +1611,7 @@
1609
1611
  Manager.prototype.onGetterUpdate = function (entities) {
1610
1612
  var _a;
1611
1613
  return __awaiter(this, void 0, void 0, function () {
1612
- var cEntities, i, id, cEntity, visual;
1614
+ var cEntities, i, entity, id, cEntity, visual;
1613
1615
  return __generator(this, function (_b) {
1614
1616
  switch (_b.label) {
1615
1617
  case 0:
@@ -1627,7 +1629,8 @@
1627
1629
  case 1:
1628
1630
  cEntities = _b.sent();
1629
1631
  for (i = 0; i < entities.length; i++) {
1630
- id = entities[i].Bruce.ID;
1632
+ entity = entities[i];
1633
+ id = entity.Bruce.ID;
1631
1634
  cEntity = cEntities[id];
1632
1635
  this.renderedEntities[id] = !!cEntity;
1633
1636
  if (cEntity) {
@@ -1637,7 +1640,8 @@
1637
1640
  entityId: id,
1638
1641
  menuItemId: this.item.id,
1639
1642
  visual: cEntity,
1640
- priority: 0
1643
+ priority: 0,
1644
+ entityTypeId: entity.Bruce["EntityType.ID"]
1641
1645
  });
1642
1646
  }
1643
1647
  }
@@ -2083,7 +2087,7 @@
2083
2087
  Manager.prototype.onGetterUpdate = function (entityIds) {
2084
2088
  var _a;
2085
2089
  return __awaiter(this, void 0, void 0, function () {
2086
- var api, entities, cEntities, i, id, cEntity, visual;
2090
+ var api, entities, cEntities, i, entity, id, cEntity, visual;
2087
2091
  return __generator(this, function (_b) {
2088
2092
  switch (_b.label) {
2089
2093
  case 0:
@@ -2105,7 +2109,8 @@
2105
2109
  case 2:
2106
2110
  cEntities = _b.sent();
2107
2111
  for (i = 0; i < entities.length; i++) {
2108
- id = entities[i].Bruce.ID;
2112
+ entity = entities[i];
2113
+ id = entity.Bruce.ID;
2109
2114
  cEntity = cEntities[id];
2110
2115
  this.renderedEntities[id] = !!cEntity;
2111
2116
  if (cEntity) {
@@ -2115,7 +2120,8 @@
2115
2120
  entityId: id,
2116
2121
  menuItemId: this.item.id,
2117
2122
  visual: cEntity,
2118
- priority: 0
2123
+ priority: 0,
2124
+ entityTypeId: entity.Bruce["EntityType.ID"]
2119
2125
  });
2120
2126
  }
2121
2127
  }
@@ -2210,7 +2216,8 @@
2210
2216
  entityId: entity.Bruce.ID,
2211
2217
  menuItemId: this.item.id,
2212
2218
  visual: cEntity,
2213
- priority: 0
2219
+ priority: 0,
2220
+ entityTypeId: entity.Bruce["EntityType.ID"]
2214
2221
  });
2215
2222
  }
2216
2223
  }
@@ -2232,31 +2239,46 @@
2232
2239
  }
2233
2240
  var TilesetRenderEngine;
2234
2241
  (function (TilesetRenderEngine) {
2235
- function ApplySettings(cTileset, tileset) {
2242
+ function ApplyPosition(cTileset, tileset, coords) {
2236
2243
  if (tileset.type == bruceModels.Tileset.EType.Cad) {
2237
2244
  var settings = tileset.settings;
2238
- var root = cTileset.root;
2239
- var transform = settings.transform;
2240
- if (!transform) {
2241
- transform = {
2242
- heading: 0,
2243
- pitch: 0,
2244
- roll: 0,
2245
- scale: 1
2246
- };
2247
- }
2248
- var point = settings.location;
2249
- var pos = Cesium.Cartesian3.fromDegrees(point.longitude, point.latitude, point.altitude);
2245
+ var location_1;
2246
+ var transform = void 0;
2247
+ // Position using root entity + ucs.
2248
+ if (coords === null || coords === void 0 ? void 0 : coords.ucs) {
2249
+ location_1 = coords.ucs.location;
2250
+ transform = coords.transform;
2251
+ }
2252
+ // Position using tileset.
2253
+ else {
2254
+ transform = settings.transform;
2255
+ location_1 = settings.location;
2256
+ }
2257
+ if (!(location_1 === null || location_1 === void 0 ? void 0 : location_1.latitude)) {
2258
+ return;
2259
+ }
2260
+ transform = __assign({ heading: 0, pitch: 0, roll: 0, scale: 1, x: 0, y: 0, z: 0 }, transform);
2261
+ if (transform.scale <= 0) {
2262
+ transform.scale = 0.000001;
2263
+ }
2264
+ var pos = Cesium.Cartesian3.fromDegrees(location_1.longitude, location_1.latitude, location_1.altitude);
2250
2265
  var hpr = Cesium.HeadingPitchRoll.fromDegrees(transform.heading, transform.pitch, transform.roll, new Cesium.HeadingPitchRoll());
2266
+ var root = cTileset.root;
2251
2267
  root.transform = Cesium.Transforms.headingPitchRollToFixedFrame(pos, hpr);
2252
- var scale = +(transform === null || transform === void 0 ? void 0 : transform.scale);
2253
- if (!scale || scale <= 0) {
2254
- scale = 0.000001;
2255
- }
2256
- var scaleMatrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(scale, scale, scale), new Cesium.Matrix4());
2268
+ var scaleMatrix = Cesium.Matrix4.fromScale(new Cesium.Cartesian3(transform.scale, transform.scale, transform.scale), new Cesium.Matrix4());
2257
2269
  root.transform = Cesium.Matrix4.multiply(root.transform, scaleMatrix, root.transform);
2270
+ root.transform = Cesium.Matrix4.multiplyByTranslation(root.transform, new Cesium.Cartesian3(transform.x, transform.y, transform.z), root.transform);
2258
2271
  // Force matrix to update
2259
2272
  root.updateTransform();
2273
+ }
2274
+ else {
2275
+ throw ("Not implemented.");
2276
+ }
2277
+ }
2278
+ TilesetRenderEngine.ApplyPosition = ApplyPosition;
2279
+ function ApplySettings(cTileset, tileset) {
2280
+ if (tileset.type == bruceModels.Tileset.EType.Cad) {
2281
+ var settings = tileset.settings;
2260
2282
  var maxScreenSpaceError = settings.maximumScreenSpaceError;
2261
2283
  if (maxScreenSpaceError || maxScreenSpaceError == 0) {
2262
2284
  cTileset.maximumScreenSpaceError = maxScreenSpaceError;
@@ -2276,6 +2298,7 @@
2276
2298
  params.viewer.scene.primitives.add(cTileset_1);
2277
2299
  cTileset_1.readyPromise.then(function () {
2278
2300
  ApplySettings(cTileset_1, params.tileset);
2301
+ ApplyPosition(cTileset_1, params.tileset, params.coords);
2279
2302
  });
2280
2303
  return cTileset_1;
2281
2304
  }
@@ -2680,7 +2703,7 @@
2680
2703
  Manager.prototype.Init = function () {
2681
2704
  var _a;
2682
2705
  return __awaiter(this, void 0, void 0, function () {
2683
- var tilesetId, api, tileset, cTileset;
2706
+ var tilesetId, api, tileset, settings, rootId, coords, cTileset;
2684
2707
  var _this = this;
2685
2708
  return __generator(this, function (_b) {
2686
2709
  switch (_b.label) {
@@ -2696,10 +2719,16 @@
2696
2719
  if (!tileset) {
2697
2720
  return [2 /*return*/];
2698
2721
  }
2722
+ settings = tileset.settings;
2723
+ rootId = settings.rootEntityId;
2724
+ return [4 /*yield*/, bruceModels.EntityCoords.GetEntityCoords(api, rootId)];
2725
+ case 2:
2726
+ coords = _b.sent();
2699
2727
  cTileset = this.cTileset = TilesetRenderEngine.Render({
2700
2728
  apiGetter: this.apiGetter,
2701
2729
  tileset: tileset,
2702
- viewer: this.viewer
2730
+ viewer: this.viewer,
2731
+ coords: coords
2703
2732
  });
2704
2733
  cTileset.readyPromise.then(function () {
2705
2734
  _this.onCTilesetLoad();