Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 | 1x 1x 1x 1x 1x 1x 25x 25x 25x 1x 1x 15x 1x 14x 1x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 2x 2x 13x 13x 2x 1x 1x 13x 5x 5x 5x 13x 2x 13x 5x 1x 1x 1x 4x 1x 1x 5x 5x 13x 2x 13x 5x 1x 2x 2x 2x 4x 5x 13x 2x 2x 13x 2x 2x 13x 13x 13x 13x 6x 6x 3x 13x 2x 1x 1x 1x 1x 2x 13x 2x 2x 13x 2x 2x 13x 5x 1x 4x 5x 5x 13x 7x 5x 2x 2x 2x 1x 7x 13x 4x 4x 13x 13x 13x 13x 13x 25x 1x 15x 1x 1x 3x 3x 3x 1x 1x 3x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 25x 1x 25x 25x 25x 25x 25x 1x 25x 25x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import {
Cartesian3,
defined,
destroyObject,
DebugModelMatrixPrimitive,
DeveloperError,
PerformanceDisplay,
Ray,
Rectangle,
ScreenSpaceEventHandler,
ScreenSpaceEventType,
TileCoordinatesImageryProvider,
} from "@cesium/engine";
import knockout from "../ThirdParty/knockout.js";
import createCommand from "../createCommand.js";
function frustumStatisticsToString(statistics) {
let str;
Eif (defined(statistics)) {
str = "Command Statistics";
const com = statistics.commandsInFrustums;
for (const n in com) {
if (com.hasOwnProperty(n)) {
let num = parseInt(n, 10);
let s;
if (num === 7) {
s = "1, 2 and 3";
} else {
const f = [];
for (let i = 2; i >= 0; i--) {
const p = Math.pow(2, i);
if (num >= p) {
f.push(i + 1);
num -= p;
}
}
s = f.reverse().join(" and ");
}
str += `<br> ${com[n]} in frustum ${s}`;
}
}
str += `<br>Total: ${statistics.totalCommands}`;
}
return str;
}
function boundDepthFrustum(lower, upper, proposed) {
let bounded = Math.min(proposed, upper);
bounded = Math.max(bounded, lower);
return bounded;
}
const scratchPickRay = new Ray();
const scratchPickCartesian = new Cartesian3();
/**
* The view model for {@link CesiumInspector}.
* @alias CesiumInspectorViewModel
* @constructor
*
* @param {Scene} scene The scene instance to use.
* @param {Element} performanceContainer The instance to use for performance container.
*/
function CesiumInspectorViewModel(scene, performanceContainer) {
//>>includeStart('debug', pragmas.debug);
if (!defined(scene)) {
throw new DeveloperError("scene is required");
}
if (!defined(performanceContainer)) {
throw new DeveloperError("performanceContainer is required");
}
//>>includeEnd('debug');
const that = this;
const canvas = scene.canvas;
const eventHandler = new ScreenSpaceEventHandler(canvas);
this._eventHandler = eventHandler;
this._scene = scene;
this._canvas = canvas;
this._primitive = undefined;
this._tile = undefined;
this._modelMatrixPrimitive = undefined;
this._performanceDisplay = undefined;
this._performanceContainer = performanceContainer;
const globe = this._scene.globe;
globe.depthTestAgainstTerrain = true;
/**
* Gets or sets the show frustums state. This property is observable.
* @type {boolean}
* @default false
*/
this.frustums = false;
/**
* Gets or sets the show frustum planes state. This property is observable.
* @type {boolean}
* @default false
*/
this.frustumPlanes = false;
/**
* Gets or sets the show performance display state. This property is observable.
* @type {boolean}
* @default false
*/
this.performance = false;
/**
* Gets or sets the shader cache text. This property is observable.
* @type {string}
* @default ''
*/
this.shaderCacheText = "";
/**
* Gets or sets the show primitive bounding sphere state. This property is observable.
* @type {boolean}
* @default false
*/
this.primitiveBoundingSphere = false;
/**
* Gets or sets the show primitive reference frame state. This property is observable.
* @type {boolean}
* @default false
*/
this.primitiveReferenceFrame = false;
/**
* Gets or sets the filter primitive state. This property is observable.
* @type {boolean}
* @default false
*/
this.filterPrimitive = false;
/**
* Gets or sets the show tile bounding sphere state. This property is observable.
* @type {boolean}
* @default false
*/
this.tileBoundingSphere = false;
/**
* Gets or sets the filter tile state. This property is observable.
* @type {boolean}
* @default false
*/
this.filterTile = false;
/**
* Gets or sets the show wireframe state. This property is observable.
* @type {boolean}
* @default false
*/
this.wireframe = false;
/**
* Gets or sets the index of the depth frustum to display. This property is observable.
* @type {number}
* @default 1
*/
this.depthFrustum = 1;
this._numberOfFrustums = 1;
/**
* Gets or sets the suspend updates state. This property is observable.
* @type {boolean}
* @default false
*/
this.suspendUpdates = false;
/**
* Gets or sets the show tile coordinates state. This property is observable.
* @type {boolean}
* @default false
*/
this.tileCoordinates = false;
/**
* Gets or sets the frustum statistic text. This property is observable.
* @type {string}
* @default ''
*/
this.frustumStatisticText = false;
/**
* Gets or sets the selected tile information text. This property is observable.
* @type {string}
* @default ''
*/
this.tileText = "";
/**
* Gets if a primitive has been selected. This property is observable.
* @type {boolean}
* @default false
*/
this.hasPickedPrimitive = false;
/**
* Gets if a tile has been selected. This property is observable
* @type {boolean}
* @default false
*/
this.hasPickedTile = false;
/**
* Gets if the picking primitive command is active. This property is observable.
* @type {boolean}
* @default false
*/
this.pickPrimitiveActive = false;
/**
* Gets if the picking tile command is active. This property is observable.
* @type {boolean}
* @default false
*/
this.pickTileActive = false;
/**
* Gets or sets if the cesium inspector drop down is visible. This property is observable.
* @type {boolean}
* @default true
*/
this.dropDownVisible = true;
/**
* Gets or sets if the general section is visible. This property is observable.
* @type {boolean}
* @default true
*/
this.generalVisible = true;
/**
* Gets or sets if the primitive section is visible. This property is observable.
* @type {boolean}
* @default false
*/
this.primitivesVisible = false;
/**
* Gets or sets if the terrain section is visible. This property is observable.
* @type {boolean}
* @default false
*/
this.terrainVisible = false;
/**
* Gets or sets the index of the depth frustum text. This property is observable.
* @type {string}
* @default ''
*/
this.depthFrustumText = "";
knockout.track(this, [
"frustums",
"frustumPlanes",
"performance",
"shaderCacheText",
"primitiveBoundingSphere",
"primitiveReferenceFrame",
"filterPrimitive",
"tileBoundingSphere",
"filterTile",
"wireframe",
"depthFrustum",
"suspendUpdates",
"tileCoordinates",
"frustumStatisticText",
"tileText",
"hasPickedPrimitive",
"hasPickedTile",
"pickPrimitiveActive",
"pickTileActive",
"dropDownVisible",
"generalVisible",
"primitivesVisible",
"terrainVisible",
"depthFrustumText",
]);
this._toggleDropDown = createCommand(function () {
that.dropDownVisible = !that.dropDownVisible;
});
this._toggleGeneral = createCommand(function () {
that.generalVisible = !that.generalVisible;
});
this._togglePrimitives = createCommand(function () {
that.primitivesVisible = !that.primitivesVisible;
});
this._toggleTerrain = createCommand(function () {
that.terrainVisible = !that.terrainVisible;
});
this._frustumsSubscription = knockout
.getObservable(this, "frustums")
.subscribe(function (val) {
that._scene.debugShowFrustums = val;
that._scene.requestRender();
});
this._frustumPlanesSubscription = knockout
.getObservable(this, "frustumPlanes")
.subscribe(function (val) {
that._scene.debugShowFrustumPlanes = val;
that._scene.requestRender();
});
this._performanceSubscription = knockout
.getObservable(this, "performance")
.subscribe(function (val) {
if (val) {
that._performanceDisplay = new PerformanceDisplay({
container: that._performanceContainer,
});
} else {
that._performanceContainer.innerHTML = "";
}
});
this._showPrimitiveBoundingSphere = createCommand(function () {
that._primitive.debugShowBoundingVolume = that.primitiveBoundingSphere;
that._scene.requestRender();
return true;
});
this._primitiveBoundingSphereSubscription = knockout
.getObservable(this, "primitiveBoundingSphere")
.subscribe(function () {
that._showPrimitiveBoundingSphere();
});
this._showPrimitiveReferenceFrame = createCommand(function () {
if (that.primitiveReferenceFrame) {
const modelMatrix = that._primitive.modelMatrix;
that._modelMatrixPrimitive = new DebugModelMatrixPrimitive({
modelMatrix: modelMatrix,
});
that._scene.primitives.add(that._modelMatrixPrimitive);
} else if (defined(that._modelMatrixPrimitive)) {
that._scene.primitives.remove(that._modelMatrixPrimitive);
that._modelMatrixPrimitive = undefined;
}
that._scene.requestRender();
return true;
});
this._primitiveReferenceFrameSubscription = knockout
.getObservable(this, "primitiveReferenceFrame")
.subscribe(function () {
that._showPrimitiveReferenceFrame();
});
this._doFilterPrimitive = createCommand(function () {
if (that.filterPrimitive) {
that._scene.debugCommandFilter = function (command) {
Iif (
defined(that._modelMatrixPrimitive) &&
command.owner === that._modelMatrixPrimitive._primitive
) {
return true;
} else Eif (defined(that._primitive)) {
return (
command.owner === that._primitive ||
command.owner === that._primitive._billboardCollection ||
command.owner.primitive === that._primitive
);
}
return false;
};
} else {
that._scene.debugCommandFilter = undefined;
}
return true;
});
this._filterPrimitiveSubscription = knockout
.getObservable(this, "filterPrimitive")
.subscribe(function () {
that._doFilterPrimitive();
that._scene.requestRender();
});
this._wireframeSubscription = knockout
.getObservable(this, "wireframe")
.subscribe(function (val) {
globe._surface.tileProvider._debug.wireframe = val;
that._scene.requestRender();
});
this._depthFrustumSubscription = knockout
.getObservable(this, "depthFrustum")
.subscribe(function (val) {
that._scene.debugShowDepthFrustum = val;
that._scene.requestRender();
});
this._incrementDepthFrustum = createCommand(function () {
const next = that.depthFrustum + 1;
that.depthFrustum = boundDepthFrustum(1, that._numberOfFrustums, next);
that._scene.requestRender();
return true;
});
this._decrementDepthFrustum = createCommand(function () {
const next = that.depthFrustum - 1;
that.depthFrustum = boundDepthFrustum(1, that._numberOfFrustums, next);
that._scene.requestRender();
return true;
});
this._suspendUpdatesSubscription = knockout
.getObservable(this, "suspendUpdates")
.subscribe(function (val) {
globe._surface._debug.suspendLodUpdate = val;
if (!val) {
that.filterTile = false;
}
});
let tileBoundariesLayer;
this._showTileCoordinates = createCommand(function () {
if (that.tileCoordinates && !defined(tileBoundariesLayer)) {
tileBoundariesLayer = scene.imageryLayers.addImageryProvider(
new TileCoordinatesImageryProvider({
tilingScheme: scene.terrainProvider.tilingScheme,
}),
);
} else Eif (!that.tileCoordinates && defined(tileBoundariesLayer)) {
scene.imageryLayers.remove(tileBoundariesLayer);
tileBoundariesLayer = undefined;
}
return true;
});
this._tileCoordinatesSubscription = knockout
.getObservable(this, "tileCoordinates")
.subscribe(function () {
that._showTileCoordinates();
that._scene.requestRender();
});
this._tileBoundingSphereSubscription = knockout
.getObservable(this, "tileBoundingSphere")
.subscribe(function () {
that._showTileBoundingSphere();
that._scene.requestRender();
});
this._showTileBoundingSphere = createCommand(function () {
if (that.tileBoundingSphere) {
globe._surface.tileProvider._debug.boundingSphereTile = that._tile;
} else {
globe._surface.tileProvider._debug.boundingSphereTile = undefined;
}
that._scene.requestRender();
return true;
});
this._doFilterTile = createCommand(function () {
if (!that.filterTile) {
that.suspendUpdates = false;
} else {
that.suspendUpdates = true;
globe._surface._tilesToRender = [];
if (defined(that._tile) && that._tile.renderable) {
globe._surface._tilesToRender.push(that._tile);
}
}
return true;
});
this._filterTileSubscription = knockout
.getObservable(this, "filterTile")
.subscribe(function () {
that.doFilterTile();
that._scene.requestRender();
});
function pickPrimitive(e) {
const newPick = that._scene.pick({
x: e.position.x,
y: e.position.y,
});
if (defined(newPick)) {
that.primitive = defined(newPick.collection)
? newPick.collection
: newPick.primitive;
}
that._scene.requestRender();
that.pickPrimitiveActive = false;
}
this._pickPrimitive = createCommand(function () {
that.pickPrimitiveActive = !that.pickPrimitiveActive;
});
this._pickPrimitiveActiveSubscription = knockout
.getObservable(this, "pickPrimitiveActive")
.subscribe(function (val) {
if (val) {
eventHandler.setInputAction(
pickPrimitive,
ScreenSpaceEventType.LEFT_CLICK,
);
} else {
eventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK);
}
});
function selectTile(e) {
let selectedTile;
const ellipsoid = globe.ellipsoid;
const ray = that._scene.camera.getPickRay(e.position, scratchPickRay);
const cartesian = globe.pick(ray, that._scene, scratchPickCartesian);
if (defined(cartesian)) {
const cartographic = ellipsoid.cartesianToCartographic(cartesian);
const tilesRendered =
globe._surface.tileProvider._tilesToRenderByTextureCount;
for (
let textureCount = 0;
!selectedTile && textureCount < tilesRendered.length;
++textureCount
) {
const tilesRenderedByTextureCount = tilesRendered[textureCount];
if (!defined(tilesRenderedByTextureCount)) {
continue;
}
for (
let tileIndex = 0;
!selectedTile && tileIndex < tilesRenderedByTextureCount.length;
++tileIndex
) {
const tile = tilesRenderedByTextureCount[tileIndex];
if (Rectangle.contains(tile.rectangle, cartographic)) {
selectedTile = tile;
}
}
}
}
that.tile = selectedTile;
that.pickTileActive = false;
}
this._pickTile = createCommand(function () {
that.pickTileActive = !that.pickTileActive;
});
this._pickTileActiveSubscription = knockout
.getObservable(this, "pickTileActive")
.subscribe(function (val) {
if (val) {
eventHandler.setInputAction(
selectTile,
ScreenSpaceEventType.LEFT_CLICK,
);
} else {
eventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK);
}
});
this._removePostRenderEvent = scene.postRender.addEventListener(function () {
that._update();
});
}
Object.defineProperties(CesiumInspectorViewModel.prototype, {
/**
* Gets the scene to control.
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Scene}
*/
scene: {
get: function () {
return this._scene;
},
},
/**
* Gets the container of the PerformanceDisplay
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Element}
*/
performanceContainer: {
get: function () {
return this._performanceContainer;
},
},
/**
* Gets the command to toggle the visibility of the drop down.
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
toggleDropDown: {
get: function () {
return this._toggleDropDown;
},
},
/**
* Gets the command to toggle the visibility of a BoundingSphere for a primitive
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
showPrimitiveBoundingSphere: {
get: function () {
return this._showPrimitiveBoundingSphere;
},
},
/**
* Gets the command to toggle the visibility of a {@link DebugModelMatrixPrimitive} for the model matrix of a primitive
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
showPrimitiveReferenceFrame: {
get: function () {
return this._showPrimitiveReferenceFrame;
},
},
/**
* Gets the command to toggle a filter that renders only a selected primitive
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
doFilterPrimitive: {
get: function () {
return this._doFilterPrimitive;
},
},
/**
* Gets the command to increment the depth frustum index to be shown
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
incrementDepthFrustum: {
get: function () {
return this._incrementDepthFrustum;
},
},
/**
* Gets the command to decrement the depth frustum index to be shown
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
decrementDepthFrustum: {
get: function () {
return this._decrementDepthFrustum;
},
},
/**
* Gets the command to toggle the visibility of tile coordinates
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
showTileCoordinates: {
get: function () {
return this._showTileCoordinates;
},
},
/**
* Gets the command to toggle the visibility of a BoundingSphere for a selected tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
showTileBoundingSphere: {
get: function () {
return this._showTileBoundingSphere;
},
},
/**
* Gets the command to toggle a filter that renders only a selected tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
doFilterTile: {
get: function () {
return this._doFilterTile;
},
},
/**
* Gets the command to expand and collapse the general section
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
toggleGeneral: {
get: function () {
return this._toggleGeneral;
},
},
/**
* Gets the command to expand and collapse the primitives section
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
togglePrimitives: {
get: function () {
return this._togglePrimitives;
},
},
/**
* Gets the command to expand and collapse the terrain section
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
toggleTerrain: {
get: function () {
return this._toggleTerrain;
},
},
/**
* Gets the command to pick a primitive
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
pickPrimitive: {
get: function () {
return this._pickPrimitive;
},
},
/**
* Gets the command to pick a tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
pickTile: {
get: function () {
return this._pickTile;
},
},
/**
* Gets the command to pick a tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
selectParent: {
get: function () {
const that = this;
return createCommand(function () {
that.tile = that.tile.parent;
});
},
},
/**
* Gets the command to pick a tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
selectNW: {
get: function () {
const that = this;
return createCommand(function () {
that.tile = that.tile.northwestChild;
});
},
},
/**
* Gets the command to pick a tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
selectNE: {
get: function () {
const that = this;
return createCommand(function () {
that.tile = that.tile.northeastChild;
});
},
},
/**
* Gets the command to pick a tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
selectSW: {
get: function () {
const that = this;
return createCommand(function () {
that.tile = that.tile.southwestChild;
});
},
},
/**
* Gets the command to pick a tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
selectSE: {
get: function () {
const that = this;
return createCommand(function () {
that.tile = that.tile.southeastChild;
});
},
},
/**
* Gets or sets the current selected primitive
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
primitive: {
get: function () {
return this._primitive;
},
set: function (newPrimitive) {
const oldPrimitive = this._primitive;
Eif (newPrimitive !== oldPrimitive) {
this.hasPickedPrimitive = true;
Iif (defined(oldPrimitive)) {
oldPrimitive.debugShowBoundingVolume = false;
}
this._scene.debugCommandFilter = undefined;
Iif (defined(this._modelMatrixPrimitive)) {
this._scene.primitives.remove(this._modelMatrixPrimitive);
this._modelMatrixPrimitive = undefined;
}
this._primitive = newPrimitive;
newPrimitive.show = false;
setTimeout(function () {
newPrimitive.show = true;
}, 50);
this.showPrimitiveBoundingSphere();
this.showPrimitiveReferenceFrame();
this.doFilterPrimitive();
}
},
},
/**
* Gets or sets the current selected tile
* @memberof CesiumInspectorViewModel.prototype
*
* @type {Command}
*/
tile: {
get: function () {
return this._tile;
},
set: function (newTile) {
if (defined(newTile)) {
this.hasPickedTile = true;
const oldTile = this._tile;
Eif (newTile !== oldTile) {
this.tileText = `L: ${newTile.level} X: ${newTile.x} Y: ${newTile.y}`;
this.tileText += `<br>SW corner: ${newTile.rectangle.west}, ${newTile.rectangle.south}`;
this.tileText += `<br>NE corner: ${newTile.rectangle.east}, ${newTile.rectangle.north}`;
const data = newTile.data;
Iif (defined(data) && defined(data.tileBoundingRegion)) {
this.tileText += `<br>Min: ${data.tileBoundingRegion.minimumHeight} Max: ${data.tileBoundingRegion.maximumHeight}`;
} else {
this.tileText += "<br>(Tile is not loaded)";
}
}
this._tile = newTile;
this.showTileBoundingSphere();
this.doFilterTile();
} else E{
this.hasPickedTile = false;
this._tile = undefined;
}
},
},
});
/**
* Updates the view model
* @private
*/
CesiumInspectorViewModel.prototype._update = function () {
if (this.frustums) {
this.frustumStatisticText = frustumStatisticsToString(
this._scene.debugFrustumStatistics,
);
}
// Determine the number of frustums being used.
const numberOfFrustums = this._scene.numberOfFrustums;
this._numberOfFrustums = numberOfFrustums;
// Bound the frustum to be displayed.
this.depthFrustum = boundDepthFrustum(1, numberOfFrustums, this.depthFrustum);
// Update the displayed text.
this.depthFrustumText = `${this.depthFrustum} of ${numberOfFrustums}`;
if (this.performance) {
this._performanceDisplay.update();
}
Iif (this.primitiveReferenceFrame) {
this._modelMatrixPrimitive.modelMatrix = this._primitive.modelMatrix;
}
this.shaderCacheText = `Cached shaders: ${this._scene.context.shaderCache.numberOfShaders}`;
};
/**
* @returns {boolean} true if the object has been destroyed, false otherwise.
*/
CesiumInspectorViewModel.prototype.isDestroyed = function () {
return false;
};
/**
* Destroys the widget. Should be called if permanently
* removing the widget from layout.
*/
CesiumInspectorViewModel.prototype.destroy = function () {
this._eventHandler.destroy();
this._removePostRenderEvent();
this._frustumsSubscription.dispose();
this._frustumPlanesSubscription.dispose();
this._performanceSubscription.dispose();
this._primitiveBoundingSphereSubscription.dispose();
this._primitiveReferenceFrameSubscription.dispose();
this._filterPrimitiveSubscription.dispose();
this._wireframeSubscription.dispose();
this._depthFrustumSubscription.dispose();
this._suspendUpdatesSubscription.dispose();
this._tileCoordinatesSubscription.dispose();
this._tileBoundingSphereSubscription.dispose();
this._filterTileSubscription.dispose();
this._pickPrimitiveActiveSubscription.dispose();
this._pickTileActiveSubscription.dispose();
return destroyObject(this);
};
export default CesiumInspectorViewModel;
|