bruce-cesium 1.0.6 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
  import { BruceEvent, Cartes, Carto, Geometry, ZoomControl, Style, EntityTag, Calculator, EntityLod, EntityType, ClientFile, DelayQueue, Entity as Entity$1, BatchedDataGetter, EntityRelationType, ObjectUtils, Tileset, EntityCoords, EntityFilterGetter, EntitySource, EntityRelation, MenuItem, ProjectView, ProjectViewBookmark, ProjectViewTile, ProjectViewLegacyTile, ProgramKey, Camera } from 'bruce-models';
2
- import { Cartesian2, Cartographic, Math as Math$1, Entity, Primitive, Cesium3DTileFeature, Color, HeightReference, Cartesian3, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, OrthographicFrustum, JulianDate, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Cesium3DTileColorBlendMode, HeadingPitchRange, Matrix4, Cesium3DTileStyle, Cesium3DTileset, IonResource, PolygonPipeline, EllipsoidGeodesic, sampleTerrainMostDetailed, CallbackProperty, ColorMaterialProperty, Rectangle, Matrix3, EasingFunction, GeometryInstance, createOsmBuildings, KmlDataSource } from 'cesium';
2
+ import { Cartesian2, Cartographic, Math as Math$1, Color, HeightReference, Cartesian3, Entity, HorizontalOrigin, VerticalOrigin, ClassificationType, ArcType, PolygonHierarchy, ShadowMode, PolylineGraphics, HeadingPitchRoll, Transforms, ColorBlendMode, Primitive, Cesium3DTileFeature, Cesium3DTileColorBlendMode, HeadingPitchRange, OrthographicFrustum, JulianDate, createWorldTerrain, EllipsoidTerrainProvider, CesiumTerrainProvider, BingMapsImageryProvider, BingMapsStyle, MapboxImageryProvider, MapboxStyleImageryProvider, ArcGisMapServerImageryProvider, OpenStreetMapImageryProvider, GridImageryProvider, GeographicTilingScheme, ImageryLayer, UrlTemplateImageryProvider, TileMapServiceImageryProvider, IonImageryProvider, Matrix4, Cesium3DTileStyle, Cesium3DTileset, IonResource, EllipsoidGeodesic, sampleTerrainMostDetailed, PolygonPipeline, ColorMaterialProperty, Rectangle, Matrix3, EasingFunction, GeometryInstance, CallbackProperty, KmlDataSource, createOsmBuildings } from 'cesium';
3
3
 
4
4
  var TIME_LAG = 300;
5
5
  var POSITION_CHECK_TIMER = 950;
@@ -355,6 +355,74 @@ function __generator(thisArg, body) {
355
355
  }
356
356
  }
357
357
 
358
+ var MeasureUtils;
359
+ (function (MeasureUtils) {
360
+ /**
361
+ * Returns the total distance in meters between an array of points.
362
+ * This distance is NOT following the terrain.
363
+ * @param posses
364
+ * @returns
365
+ */
366
+ function MeasurePolyline(params) {
367
+ var posses = params.posses;
368
+ if (posses.length < 2) {
369
+ return {
370
+ totalLength: 0
371
+ };
372
+ }
373
+ var totalLength = 0;
374
+ var pos1 = null;
375
+ var pos2 = null;
376
+ for (var i = 0; i < posses.length; i++) {
377
+ if (pos1 == null) {
378
+ pos1 = posses[i];
379
+ }
380
+ else if (pos2 == null) {
381
+ pos2 = posses[i];
382
+ totalLength += Cartesian3.distance(pos1, pos2);
383
+ pos1 = pos2;
384
+ pos2 = null;
385
+ }
386
+ }
387
+ return {
388
+ totalLength: totalLength
389
+ };
390
+ }
391
+ MeasureUtils.MeasurePolyline = MeasurePolyline;
392
+ function MeasurePolygon(params) {
393
+ var posses = params.posses;
394
+ posses = [].concat(posses);
395
+ if (!Cartes.IsRing3Closed(posses)) {
396
+ posses.push(posses[0].clone());
397
+ }
398
+ if (posses.length < 3) {
399
+ return {
400
+ area: 0,
401
+ perimeter: 0
402
+ };
403
+ }
404
+ var area = 0;
405
+ var indices = PolygonPipeline.triangulate(posses, []);
406
+ for (var i = 0; i < indices.length; i += 3) {
407
+ var vector1 = posses[indices[i]];
408
+ var vector2 = posses[indices[i + 1]];
409
+ var vector3 = posses[indices[i + 2]];
410
+ var vectorC = Cartesian3.subtract(vector2, vector1, new Cartesian3());
411
+ var vectorD = Cartesian3.subtract(vector3, vector1, new Cartesian3());
412
+ var areaVector = Cartesian3.cross(vectorC, vectorD, new Cartesian3());
413
+ area += Cartesian3.magnitude(areaVector) / 2.0;
414
+ }
415
+ var perimeter = MeasurePolyline({
416
+ posses: posses
417
+ }).totalLength;
418
+ return {
419
+ area: area,
420
+ perimeter: perimeter
421
+ };
422
+ }
423
+ MeasureUtils.MeasurePolygon = MeasurePolygon;
424
+ })(MeasureUtils || (MeasureUtils = {}));
425
+
358
426
  var DrawingUtils;
359
427
  (function (DrawingUtils) {
360
428
  /**
@@ -367,15 +435,29 @@ var DrawingUtils;
367
435
  */
368
436
  function PointAcrossPolyline(params) {
369
437
  var viewer = params.viewer, positions = params.posses, distance = params.distance;
370
- if (positions.length > 1) {
438
+ if (distance <= 0 && positions.length > 0) {
439
+ return {
440
+ point: positions[0]
441
+ };
442
+ }
443
+ else if (positions.length > 1) {
371
444
  var currentDistance = 0;
445
+ var totalLength = MeasureUtils.MeasurePolyline({
446
+ posses: positions,
447
+ }).totalLength;
448
+ if (distance > totalLength) {
449
+ return {
450
+ point: positions[positions.length - 1]
451
+ };
452
+ }
372
453
  for (var i = 0; i < positions.length - 1; i++) {
373
454
  var length_1 = Cartesian3.distance(positions[i], positions[i + 1]);
374
455
  if (length_1 + currentDistance >= distance) {
375
456
  var carto1 = Cartographic.fromCartesian(positions[i]);
376
457
  var carto2 = Cartographic.fromCartesian(positions[i + 1]);
377
458
  var geodesic = new EllipsoidGeodesic(carto1, carto2, viewer.scene.globe.ellipsoid);
378
- var position = geodesic.interpolateUsingSurfaceDistance(distance - currentDistance);
459
+ //const position = geodesic.interpolateUsingSurfaceDistance(distance - currentDistance);
460
+ var position = geodesic.interpolateUsingFraction((distance - currentDistance) / length_1);
379
461
  var height = (carto1.height + carto2.height) / 2;
380
462
  return {
381
463
  point: Cartesian3.fromRadians(position.longitude, position.latitude, height)
@@ -386,18 +468,8 @@ var DrawingUtils;
386
468
  }
387
469
  }
388
470
  }
389
- else if (positions.length > 0) {
390
- return {
391
- point: positions[0]
392
- };
393
- }
394
- else {
395
- return {
396
- point: null
397
- };
398
- }
399
471
  return {
400
- point: positions[positions.length - 1]
472
+ point: positions.length ? positions[positions.length - 1] : null
401
473
  };
402
474
  }
403
475
  DrawingUtils.PointAcrossPolyline = PointAcrossPolyline;
@@ -451,74 +523,6 @@ var DrawingUtils;
451
523
  DrawingUtils.GetTerrainHeight = GetTerrainHeight;
452
524
  })(DrawingUtils || (DrawingUtils = {}));
453
525
 
454
- var MeasureUtils;
455
- (function (MeasureUtils) {
456
- /**
457
- * Returns the total distance in meters between an array of points.
458
- * This distance is NOT following the terrain.
459
- * @param posses
460
- * @returns
461
- */
462
- function MeasurePolyline(params) {
463
- var posses = params.posses;
464
- if (posses.length < 2) {
465
- return {
466
- totalLength: 0
467
- };
468
- }
469
- var totalLength = 0;
470
- var pos1 = null;
471
- var pos2 = null;
472
- for (var i = 0; i < posses.length; i++) {
473
- if (pos1 == null) {
474
- pos1 = posses[i];
475
- }
476
- else if (pos2 == null) {
477
- pos2 = posses[i];
478
- totalLength += Cartesian3.distance(pos1, pos2);
479
- pos1 = pos2;
480
- pos2 = null;
481
- }
482
- }
483
- return {
484
- totalLength: totalLength
485
- };
486
- }
487
- MeasureUtils.MeasurePolyline = MeasurePolyline;
488
- function MeasurePolygon(params) {
489
- var posses = params.posses;
490
- posses = [].concat(posses);
491
- if (!Cartes.IsRing3Closed(posses)) {
492
- posses.push(posses[0].clone());
493
- }
494
- if (posses.length < 3) {
495
- return {
496
- area: 0,
497
- perimeter: 0
498
- };
499
- }
500
- var area = 0;
501
- var indices = PolygonPipeline.triangulate(posses, []);
502
- for (var i = 0; i < indices.length; i += 3) {
503
- var vector1 = posses[indices[i]];
504
- var vector2 = posses[indices[i + 1]];
505
- var vector3 = posses[indices[i + 2]];
506
- var vectorC = Cartesian3.subtract(vector2, vector1, new Cartesian3());
507
- var vectorD = Cartesian3.subtract(vector3, vector1, new Cartesian3());
508
- var areaVector = Cartesian3.cross(vectorC, vectorD, new Cartesian3());
509
- area += Cartesian3.magnitude(areaVector) / 2.0;
510
- }
511
- var perimeter = MeasurePolyline({
512
- posses: posses
513
- }).totalLength;
514
- return {
515
- area: area,
516
- perimeter: perimeter
517
- };
518
- }
519
- MeasureUtils.MeasurePolygon = MeasurePolygon;
520
- })(MeasureUtils || (MeasureUtils = {}));
521
-
522
526
  /**
523
527
  * Ensures a number is returned from a given value.
524
528
  * If given value cannot be parsed it will return defaultNum.
@@ -656,6 +660,13 @@ function applyOpacityToEntity(viewer, opacity, entity) {
656
660
  function findOpacity(entity) {
657
661
  return entity[NEW_OPACITY_KEY];
658
662
  }
663
+ function GetValue(viewer, obj) {
664
+ var _a;
665
+ if ((_a = obj) === null || _a === void 0 ? void 0 : _a.getValue) {
666
+ return obj.getValue(viewer.scene.lastRenderTime);
667
+ }
668
+ return obj;
669
+ }
659
670
  var EntityUtils;
660
671
  (function (EntityUtils) {
661
672
  /**
@@ -673,10 +684,61 @@ var EntityUtils;
673
684
  if ((rego === null || rego === void 0 ? void 0 : rego.visual) instanceof Entity) {
674
685
  var visual = rego.visual;
675
686
  if (visual.position) {
676
- if (visual.position.getValue) {
677
- return visual.position.getValue(viewer.scene.lastRenderTime);
687
+ var pos3d_1 = GetValue(viewer, visual.position);
688
+ // Fix height reference.
689
+ if (pos3d_1 === null || pos3d_1 === void 0 ? void 0 : pos3d_1.x) {
690
+ var visualHeightRef = HeightReference.RELATIVE_TO_GROUND;
691
+ if (visual.model) {
692
+ visualHeightRef = GetValue(viewer, visual.model.heightReference);
693
+ }
694
+ else if (visual.polygon) {
695
+ visualHeightRef = GetValue(viewer, visual.polygon.heightReference);
696
+ }
697
+ else if (visual.polyline) {
698
+ visualHeightRef = GetValue(viewer, visual.polyline.clampToGround) ?
699
+ HeightReference.RELATIVE_TO_GROUND : HeightReference.NONE;
700
+ }
701
+ else if (visual.billboard) {
702
+ visualHeightRef = GetValue(viewer, visual.billboard.heightReference);
703
+ }
704
+ else if (visual.ellipse) {
705
+ visualHeightRef = GetValue(viewer, visual.ellipse.heightReference);
706
+ }
707
+ else if (visual.point) {
708
+ visualHeightRef = GetValue(viewer, visual.point.heightReference);
709
+ }
710
+ if (visualHeightRef == params.heightReference) {
711
+ return pos3d_1;
712
+ }
713
+ var carto_1 = Cartographic.fromCartesian(pos3d_1);
714
+ if (visualHeightRef == HeightReference.NONE) {
715
+ // Turn absolute into clamped.
716
+ if (params.heightReference == HeightReference.CLAMP_TO_GROUND) {
717
+ return Cartesian3.fromRadians(carto_1.longitude, carto_1.latitude, 0);
718
+ }
719
+ // Turn absolute into relative (remove terrain height).
720
+ else if (params.heightReference == HeightReference.RELATIVE_TO_GROUND) {
721
+ var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto_1), 0);
722
+ return Cartesian3.fromRadians(carto_1.longitude, carto_1.latitude, carto_1.height - terrainHeight);
723
+ }
724
+ }
725
+ else if (visualHeightRef == HeightReference.CLAMP_TO_GROUND) {
726
+ var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto_1), 0);
727
+ return Cartesian3.fromRadians(carto_1.longitude, carto_1.latitude, terrainHeight);
728
+ }
729
+ else if (visualHeightRef == HeightReference.RELATIVE_TO_GROUND) {
730
+ // Turn relative into absolute (add terrain height).
731
+ if (params.heightReference == HeightReference.NONE) {
732
+ var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto_1), 0);
733
+ return Cartesian3.fromRadians(carto_1.longitude, carto_1.latitude, carto_1.height + terrainHeight);
734
+ }
735
+ // Turn relative into clamped.
736
+ else if (params.heightReference == HeightReference.CLAMP_TO_GROUND) {
737
+ return Cartesian3.fromRadians(carto_1.longitude, carto_1.latitude, 0);
738
+ }
739
+ }
740
+ return pos3d_1;
678
741
  }
679
- return visual.position;
680
742
  }
681
743
  }
682
744
  return null;
@@ -746,7 +808,14 @@ var EntityUtils;
746
808
  return pos3d;
747
809
  }
748
810
  pos3d = evaluateRecord();
749
- return Cartes.ValidateCartes3(pos3d) ? pos3d : null;
811
+ var carto = Cartes.ValidateCartes3(pos3d) ? Cartographic.fromCartesian(pos3d) : null;
812
+ if (carto) {
813
+ // Since we don't know height reference, we can't convert it.
814
+ // We will just clamp it to ground.
815
+ var terrainHeight = EnsureNumber(viewer.scene.globe.getHeight(carto), 0);
816
+ pos3d = Cartesian3.fromRadians(carto.longitude, carto.latitude, terrainHeight);
817
+ }
818
+ return pos3d;
750
819
  }
751
820
  EntityUtils.GetPos = GetPos;
752
821
  /**
@@ -2311,13 +2380,11 @@ var CesiumParabola = /** @class */ (function () {
2311
2380
  CesiumParabola.prototype.Animate = function () {
2312
2381
  var _this = this;
2313
2382
  this.Dispose();
2314
- var p1 = this.curPos1;
2315
- var p2 = this.curPos2;
2316
2383
  var retry = false;
2317
- if (!p1 || !p2 || !Cartes.ValidateCartes3(p1) || !Cartes.ValidateCartes3(p2)) {
2384
+ if (!this.curPos1 || !this.curPos2 || !Cartes.ValidateCartes3(this.curPos1) || !Cartes.ValidateCartes3(this.curPos2)) {
2318
2385
  retry = true;
2319
2386
  }
2320
- var TOTAL_LENGTH = retry ? 0 : Cartesian3.distance(p1, p2);
2387
+ var TOTAL_LENGTH = retry ? 0 : Cartesian3.distance(this.curPos1, this.curPos2);
2321
2388
  if (TOTAL_LENGTH <= 0) {
2322
2389
  retry = true;
2323
2390
  }
@@ -2330,11 +2397,11 @@ var CesiumParabola = /** @class */ (function () {
2330
2397
  };
2331
2398
  return;
2332
2399
  }
2333
- var TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
2334
- var POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
2335
2400
  var RATE_PER_SECOND = 1000 / 40;
2336
2401
  var SEC_DURATION = this.duration;
2337
2402
  var HEIGHT_DISTANCE_RATIO = this.heightDistanceRatio;
2403
+ var TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
2404
+ var POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
2338
2405
  var TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
2339
2406
  var curPoints = [];
2340
2407
  var curPoint = 0;
@@ -2366,7 +2433,7 @@ var CesiumParabola = /** @class */ (function () {
2366
2433
  }, false),
2367
2434
  point: {
2368
2435
  heightReference: HeightReference.NONE,
2369
- pixelSize: this.width * 1.3,
2436
+ pixelSize: this.width * 1.8,
2370
2437
  color: Color.fromCssColorString(this.color),
2371
2438
  outlineColor: Color.WHITE,
2372
2439
  outlineWidth: 2
@@ -2376,107 +2443,125 @@ var CesiumParabola = /** @class */ (function () {
2376
2443
  this.viewer.entities.add(p2Entity);
2377
2444
  p1Entity.parent = parabola;
2378
2445
  p2Entity.parent = parabola;
2446
+ var siblings = [p1Entity, p2Entity];
2379
2447
  var quadraticKey = null;
2380
2448
  var quadratic = null;
2381
- var prepareQuadratic = function () {
2382
- var p1 = _this.curPos1;
2383
- var p2 = _this.curPos2;
2384
- if (!p1 || !p2 || !Cartes.ValidateCartes3(p1) || !Cartes.ValidateCartes3(p2)) {
2385
- return;
2386
- }
2387
- var height1 = Cartographic.fromCartesian(p1).height;
2388
- var height2 = Cartographic.fromCartesian(p2).height;
2389
- if (isNaN(height1) || isNaN(height2)) {
2390
- return;
2391
- }
2392
- var totalHeight = height2 + height1;
2393
- var curQuadraticKey = height1 + "-" + height2;
2394
- if (quadraticKey == curQuadraticKey) {
2395
- return;
2396
- }
2397
- var points2d = [
2398
- new Cartesian2(0, height1),
2399
- new Cartesian2(TOTAL_LENGTH, height2)
2400
- ];
2401
- var vertexHeight = 0;
2402
- // Flat line.
2403
- if (HEIGHT_DISTANCE_RATIO == 0) {
2404
- vertexHeight = totalHeight * 0.5;
2405
- }
2406
- else {
2407
- var largestHeight = Math.max(height1, height2);
2408
- vertexHeight = largestHeight + (TOTAL_LENGTH * HEIGHT_DISTANCE_RATIO);
2409
- }
2410
- points2d.push(new Cartesian2(TOTAL_LENGTH * 0.5, vertexHeight));
2411
- var calcQuadratic = function (points) {
2412
- // Swaps position of two rows in matrix.
2413
- function swapRows(matrix, rowAIndex, rowBIndex) {
2414
- var rowAVal = matrix[rowAIndex];
2415
- matrix[rowAIndex] = matrix[rowBIndex];
2416
- matrix[rowBIndex] = rowAVal;
2417
- return matrix;
2449
+ var quadraticPreparing = false;
2450
+ var prepareQuadratic = function () { return __awaiter(_this, void 0, void 0, function () {
2451
+ var p1, p2, height1, height2, totalHeight, curQuadraticKey, points2d, vertexHeight, largestHeight, calcQuadratic;
2452
+ return __generator(this, function (_a) {
2453
+ if (quadraticPreparing) {
2454
+ return [2 /*return*/];
2418
2455
  }
2419
- // Zeros rowA at colIndex by subtracting a multiplied rowB from it.
2420
- function reduceMatrixRowByRow(matrix, zeroingIndex, parentIndex, colIndex) {
2421
- var zeroRow = matrix[zeroingIndex];
2422
- var parentRow = matrix[parentIndex];
2423
- if (zeroRow[colIndex] == 0) {
2424
- return matrix;
2456
+ quadraticPreparing = true;
2457
+ try {
2458
+ p1 = this.curPos1;
2459
+ p2 = this.curPos2;
2460
+ if (!p1 || !p2 || !Cartes.ValidateCartes3(p1) || !Cartes.ValidateCartes3(p2)) {
2461
+ return [2 /*return*/];
2425
2462
  }
2426
- else if (parentRow[colIndex] == 0) {
2427
- matrix = swapRows(matrix, parentIndex, zeroingIndex);
2428
- return divideMatrixRow(matrix, parentIndex, colIndex);
2463
+ height1 = Cartographic.fromCartesian(p1).height;
2464
+ height2 = Cartographic.fromCartesian(p2).height;
2465
+ if (isNaN(height1) || isNaN(height2)) {
2466
+ return [2 /*return*/];
2429
2467
  }
2430
- // rowAIndex colIndex / rowBIndex colIndex = factor;
2431
- var factor = zeroRow[colIndex] / parentRow[colIndex];
2432
- for (var i = 0; i < zeroRow.length; i++) {
2433
- if (i >= colIndex) {
2434
- zeroRow[i] -= parentRow[i] * factor;
2435
- }
2468
+ totalHeight = height2 + height1;
2469
+ curQuadraticKey = height1 + "-" + height2 + "-" + TOTAL_LENGTH;
2470
+ if (quadraticKey == curQuadraticKey) {
2471
+ return [2 /*return*/];
2436
2472
  }
2437
- return matrix;
2438
- }
2439
- // Makes a given row column equal 1 by diving while row by that column.
2440
- function divideMatrixRow(matrix, rowIndex, colIndex) {
2441
- var row = matrix[rowIndex];
2442
- var colValue = row[colIndex];
2443
- for (var i = 0; i < row.length; i++) {
2444
- if (i >= colIndex) {
2445
- row[i] /= colValue;
2446
- }
2473
+ points2d = [
2474
+ new Cartesian2(0, height1),
2475
+ new Cartesian2(TOTAL_LENGTH, height2)
2476
+ ];
2477
+ vertexHeight = 0;
2478
+ // Flat line.
2479
+ if (HEIGHT_DISTANCE_RATIO == 0) {
2480
+ vertexHeight = totalHeight * 0.5;
2447
2481
  }
2448
- return matrix;
2449
- }
2450
- // Returns initial matrix for calculating a, b and c for quadratic formula from given points.
2451
- function matrixFromPoints(points) {
2452
- var rows = [];
2453
- var constructRow = function (point) {
2454
- rows.push([
2455
- -Math.pow(point.x, 2),
2456
- point.x,
2457
- 1,
2458
- point.y
2459
- ]);
2460
- };
2461
- for (var i = 0; i < points.length; i++) {
2462
- constructRow(points[i]);
2482
+ else {
2483
+ largestHeight = Math.max(height1, height2);
2484
+ vertexHeight = largestHeight + (TOTAL_LENGTH * HEIGHT_DISTANCE_RATIO);
2463
2485
  }
2464
- return rows;
2486
+ points2d.push(new Cartesian2(TOTAL_LENGTH * 0.5, vertexHeight));
2487
+ calcQuadratic = function (points) {
2488
+ // Swaps position of two rows in matrix.
2489
+ function swapRows(matrix, rowAIndex, rowBIndex) {
2490
+ var rowAVal = matrix[rowAIndex];
2491
+ matrix[rowAIndex] = matrix[rowBIndex];
2492
+ matrix[rowBIndex] = rowAVal;
2493
+ return matrix;
2494
+ }
2495
+ // Zeros rowA at colIndex by subtracting a multiplied rowB from it.
2496
+ function reduceMatrixRowByRow(matrix, zeroingIndex, parentIndex, colIndex) {
2497
+ var zeroRow = matrix[zeroingIndex];
2498
+ var parentRow = matrix[parentIndex];
2499
+ if (zeroRow[colIndex] == 0) {
2500
+ return matrix;
2501
+ }
2502
+ else if (parentRow[colIndex] == 0) {
2503
+ matrix = swapRows(matrix, parentIndex, zeroingIndex);
2504
+ return divideMatrixRow(matrix, parentIndex, colIndex);
2505
+ }
2506
+ // rowAIndex colIndex / rowBIndex colIndex = factor;
2507
+ var factor = zeroRow[colIndex] / parentRow[colIndex];
2508
+ for (var i = 0; i < zeroRow.length; i++) {
2509
+ if (i >= colIndex) {
2510
+ zeroRow[i] -= parentRow[i] * factor;
2511
+ }
2512
+ }
2513
+ return matrix;
2514
+ }
2515
+ // Makes a given row column equal 1 by diving while row by that column.
2516
+ function divideMatrixRow(matrix, rowIndex, colIndex) {
2517
+ var row = matrix[rowIndex];
2518
+ var colValue = row[colIndex];
2519
+ for (var i = 0; i < row.length; i++) {
2520
+ if (i >= colIndex) {
2521
+ row[i] /= colValue;
2522
+ }
2523
+ }
2524
+ return matrix;
2525
+ }
2526
+ // Returns initial matrix for calculating a, b and c for quadratic formula from given points.
2527
+ function matrixFromPoints(points) {
2528
+ var rows = [];
2529
+ var constructRow = function (point) {
2530
+ rows.push([
2531
+ -Math.pow(point.x, 2),
2532
+ point.x,
2533
+ 1,
2534
+ point.y
2535
+ ]);
2536
+ };
2537
+ for (var i = 0; i < points.length; i++) {
2538
+ constructRow(points[i]);
2539
+ }
2540
+ return rows;
2541
+ }
2542
+ var initialMatrix = matrixFromPoints(points);
2543
+ var step1Matrix = reduceMatrixRowByRow(initialMatrix, 1, 0, 0);
2544
+ var step2Matrix = reduceMatrixRowByRow(step1Matrix, 2, 0, 0);
2545
+ var step3Matrix = reduceMatrixRowByRow(step2Matrix, 2, 1, 1);
2546
+ var step4Matrix = reduceMatrixRowByRow(step3Matrix, 0, 1, 1);
2547
+ var step5Matrix = reduceMatrixRowByRow(step4Matrix, 0, 2, 2);
2548
+ var step6Matrix = reduceMatrixRowByRow(step5Matrix, 1, 2, 2);
2549
+ var a = step6Matrix[0][3];
2550
+ var b = step6Matrix[1][3];
2551
+ var c = step6Matrix[2][3];
2552
+ return { a: a, b: b, c: c };
2553
+ };
2554
+ quadratic = calcQuadratic(points2d);
2465
2555
  }
2466
- var initialMatrix = matrixFromPoints(points);
2467
- var step1Matrix = reduceMatrixRowByRow(initialMatrix, 1, 0, 0);
2468
- var step2Matrix = reduceMatrixRowByRow(step1Matrix, 2, 0, 0);
2469
- var step3Matrix = reduceMatrixRowByRow(step2Matrix, 2, 1, 1);
2470
- var step4Matrix = reduceMatrixRowByRow(step3Matrix, 0, 1, 1);
2471
- var step5Matrix = reduceMatrixRowByRow(step4Matrix, 0, 2, 2);
2472
- var step6Matrix = reduceMatrixRowByRow(step5Matrix, 1, 2, 2);
2473
- var a = step6Matrix[0][3];
2474
- var b = step6Matrix[1][3];
2475
- var c = step6Matrix[2][3];
2476
- return { a: a, b: b, c: c };
2477
- };
2478
- quadratic = calcQuadratic(points2d);
2479
- };
2556
+ catch (e) {
2557
+ console.error(e);
2558
+ }
2559
+ finally {
2560
+ quadraticPreparing = false;
2561
+ }
2562
+ return [2 /*return*/];
2563
+ });
2564
+ }); };
2480
2565
  var getPosition = function (increment) {
2481
2566
  if (!quadratic) {
2482
2567
  return null;
@@ -2494,13 +2579,16 @@ var CesiumParabola = /** @class */ (function () {
2494
2579
  var pos3d = DrawingUtils.PointAcrossPolyline({
2495
2580
  viewer: _this.viewer,
2496
2581
  distance: lengthAcross,
2497
- posses: [p1, p2]
2582
+ posses: [_this.curPos1, _this.curPos2]
2498
2583
  }).point;
2499
2584
  var point = Cartographic.fromCartesian(pos3d);
2500
2585
  var posHeight = getParabolaYFromX(lengthAcross, quadratic);
2501
2586
  return Cartesian3.fromRadians(point.longitude, point.latitude, posHeight);
2502
2587
  };
2503
2588
  var updatePoints = function () {
2589
+ if (!quadratic) {
2590
+ return;
2591
+ }
2504
2592
  var increment = Math.floor(curPoint);
2505
2593
  var chips = curPoint - Math.floor(curPoint);
2506
2594
  var posses = [];
@@ -2517,13 +2605,22 @@ var CesiumParabola = /** @class */ (function () {
2517
2605
  curPoints = posses;
2518
2606
  };
2519
2607
  var doTick = function () {
2520
- if (curPoint >= TOTAL_POINTS) {
2521
- clearInterval(animateInterval);
2522
- return;
2608
+ var p1 = _this.curPos1;
2609
+ var p2 = _this.curPos2;
2610
+ var newLength = p1 && p2 ? Cartesian3.distance(p1, p2) : -1;
2611
+ if (newLength > 0 && newLength != TOTAL_LENGTH) {
2612
+ TOTAL_LENGTH = newLength;
2613
+ TOTAL_POINTS = Math.max(50, Math.min(1000, TOTAL_LENGTH * 0.1));
2614
+ POINT_LENGTH = TOTAL_LENGTH / TOTAL_POINTS;
2615
+ TICK_LENGTH_INC = SEC_DURATION == 0 ? TOTAL_LENGTH : TOTAL_POINTS / (RATE_PER_SECOND * SEC_DURATION);
2523
2616
  }
2524
- curPoint += TICK_LENGTH_INC;
2525
2617
  prepareQuadratic();
2526
- updatePoints();
2618
+ if (quadratic) {
2619
+ if (curPoint < TOTAL_POINTS) {
2620
+ curPoint += TICK_LENGTH_INC;
2621
+ }
2622
+ updatePoints();
2623
+ }
2527
2624
  };
2528
2625
  var animateInterval = setInterval(doTick, RATE_PER_SECOND);
2529
2626
  this.dispose = function () {
@@ -2540,10 +2637,7 @@ var CesiumParabola = /** @class */ (function () {
2540
2637
  };
2541
2638
  return {
2542
2639
  parabola: parabola,
2543
- siblings: [
2544
- p1Entity,
2545
- p2Entity
2546
- ]
2640
+ siblings: siblings
2547
2641
  };
2548
2642
  };
2549
2643
  CesiumParabola.prototype.Dispose = function () {
@@ -2565,7 +2659,7 @@ var RelationRenderEngine;
2565
2659
  RelationRenderEngine.GetRenderGroupId = GetRenderGroupId;
2566
2660
  function Render(params) {
2567
2661
  return __awaiter(this, void 0, void 0, function () {
2568
- var apiGetter, viewer, visualRegister, menuItemId, relations, api, rendered, i, relation, fromEntity, toEntity, dataEntity, _a, relationType, style, _b, cEntity;
2662
+ var apiGetter, viewer, visualRegister, menuItemId, relations, api, rendered, i, relation, fromEntity, toEntity, dataEntity, _a, relationType, styleId, entityType, style, _b, cEntity;
2569
2663
  return __generator(this, function (_c) {
2570
2664
  switch (_c.label) {
2571
2665
  case 0:
@@ -2575,7 +2669,7 @@ var RelationRenderEngine;
2575
2669
  i = 0;
2576
2670
  _c.label = 1;
2577
2671
  case 1:
2578
- if (!(i < relations.length)) return [3 /*break*/, 12];
2672
+ if (!(i < relations.length)) return [3 /*break*/, 14];
2579
2673
  relation = relations[i];
2580
2674
  return [4 /*yield*/, Entity$1.Get({
2581
2675
  api: api,
@@ -2608,18 +2702,29 @@ var RelationRenderEngine;
2608
2702
  })];
2609
2703
  case 7:
2610
2704
  relationType = (_c.sent()).relationType;
2611
- if (!relationType.EntityDisplaySettingID) return [3 /*break*/, 9];
2612
- return [4 /*yield*/, Style.Get({
2705
+ styleId = Number(relationType === null || relationType === void 0 ? void 0 : relationType["Relation.EntityType.ID"]);
2706
+ if (!!styleId) return [3 /*break*/, 9];
2707
+ return [4 /*yield*/, EntityType.Get({
2613
2708
  api: api,
2614
- styleId: Number(relationType.EntityDisplaySettingID)
2709
+ entityTypeId: relationType === null || relationType === void 0 ? void 0 : relationType["Relation.EntityType.ID"]
2615
2710
  })];
2616
2711
  case 8:
2617
- _b = (_c.sent()).style;
2618
- return [3 /*break*/, 10];
2712
+ entityType = (_c.sent()).entityType;
2713
+ styleId = entityType === null || entityType === void 0 ? void 0 : entityType["DisplaySetting.ID"];
2714
+ _c.label = 9;
2619
2715
  case 9:
2620
- _b = null;
2621
- _c.label = 10;
2716
+ if (!styleId) return [3 /*break*/, 11];
2717
+ return [4 /*yield*/, Style.Get({
2718
+ api: api,
2719
+ styleId: styleId
2720
+ })];
2622
2721
  case 10:
2722
+ _b = (_c.sent()).style;
2723
+ return [3 /*break*/, 12];
2724
+ case 11:
2725
+ _b = null;
2726
+ _c.label = 12;
2727
+ case 12:
2623
2728
  style = _b;
2624
2729
  cEntity = Parabola.Render({
2625
2730
  dataEntity: dataEntity,
@@ -2632,11 +2737,11 @@ var RelationRenderEngine;
2632
2737
  });
2633
2738
  cEntity._renderGroup = GetRenderGroupId(relation);
2634
2739
  rendered[GetRenderGroupId(relation)] = cEntity;
2635
- _c.label = 11;
2636
- case 11:
2740
+ _c.label = 13;
2741
+ case 13:
2637
2742
  i++;
2638
2743
  return [3 /*break*/, 1];
2639
- case 12: return [2 /*return*/, rendered];
2744
+ case 14: return [2 /*return*/, rendered];
2640
2745
  }
2641
2746
  });
2642
2747
  });
@@ -2658,29 +2763,37 @@ var RelationRenderEngine;
2658
2763
  var hDistanceRatio = EnsureNumber((style === null || style === void 0 ? void 0 : style.heightDistanceRatio) ? Calculator.GetValue(style === null || style === void 0 ? void 0 : style.heightDistanceRatio, entity, []) : 0.25, 0.25);
2659
2764
  var fromPos = null;
2660
2765
  var toPos = null;
2766
+ var updatingPosses = false;
2661
2767
  var updatePosses = function () {
2768
+ if (updatingPosses) {
2769
+ return;
2770
+ }
2771
+ updatingPosses = true;
2662
2772
  try {
2663
2773
  fromPos = EntityUtils.GetPos({
2664
2774
  entity: params.fromEntity,
2665
2775
  viewer: params.viewer,
2666
- visualRegister: params.visualRegister
2776
+ visualRegister: params.visualRegister,
2777
+ heightReference: HeightReference.NONE
2667
2778
  });
2668
2779
  toPos = EntityUtils.GetPos({
2669
2780
  entity: params.toEntity,
2670
2781
  viewer: params.viewer,
2671
- visualRegister: params.visualRegister
2782
+ visualRegister: params.visualRegister,
2783
+ heightReference: HeightReference.NONE
2672
2784
  });
2673
2785
  }
2674
2786
  catch (e) {
2675
2787
  console.error(e);
2676
2788
  }
2789
+ updatingPosses = false;
2677
2790
  };
2678
2791
  updatePosses();
2679
2792
  var parabola = new CesiumParabola({
2680
2793
  viewer: params.viewer,
2681
2794
  pos1: function () { return fromPos; },
2682
2795
  pos2: function () { return toPos; },
2683
- color: cColor.toString(),
2796
+ color: cColor.toCssColorString(),
2684
2797
  width: width,
2685
2798
  duration: duration,
2686
2799
  heightDistanceRatio: hDistanceRatio