1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576 |
- import Check from "../../Core/Check.js";
- import Color from "../../Core/Color.js";
- import defined from "../../Core/defined.js";
- import destroyObject from "../../Core/destroyObject.js";
- import ScreenSpaceEventHandler from "../../Core/ScreenSpaceEventHandler.js";
- import ScreenSpaceEventType from "../../Core/ScreenSpaceEventType.js";
- import Cesium3DTileColorBlendMode from "../../Scene/Cesium3DTileColorBlendMode.js";
- import Cesium3DTileFeature from "../../Scene/Cesium3DTileFeature.js";
- import Cesium3DTilePass from "../../Scene/Cesium3DTilePass.js";
- import Cesium3DTileset from "../../Scene/Cesium3DTileset.js";
- import Cesium3DTileStyle from "../../Scene/Cesium3DTileStyle.js";
- import PerformanceDisplay from "../../Scene/PerformanceDisplay.js";
- import knockout from "../../ThirdParty/knockout.js";
- function getPickTileset(viewModel) {
- return function (e) {
- var pick = viewModel._scene.pick(e.position);
- if (defined(pick) && pick.primitive instanceof Cesium3DTileset) {
- viewModel.tileset = pick.primitive;
- }
- viewModel.pickActive = false;
- };
- }
- function selectTilesetOnHover(viewModel, value) {
- if (value) {
- viewModel._eventHandler.setInputAction(function (e) {
- var pick = viewModel._scene.pick(e.endPosition);
- if (defined(pick) && pick.primitive instanceof Cesium3DTileset) {
- viewModel.tileset = pick.primitive;
- }
- }, ScreenSpaceEventType.MOUSE_MOVE);
- } else {
- viewModel._eventHandler.removeInputAction(ScreenSpaceEventType.MOUSE_MOVE);
-
-
- viewModel.picking = viewModel.picking;
- }
- }
- var stringOptions = {
- maximumFractionDigits: 3,
- };
- function formatMemoryString(memorySizeInBytes) {
- var memoryInMegabytes = memorySizeInBytes / 1048576;
- if (memoryInMegabytes < 1.0) {
- return memoryInMegabytes.toLocaleString(undefined, stringOptions);
- }
- return Math.round(memoryInMegabytes).toLocaleString();
- }
- function getStatistics(tileset, isPick) {
- if (!defined(tileset)) {
- return "";
- }
- var statistics = isPick
- ? tileset._statisticsPerPass[Cesium3DTilePass.PICK]
- : tileset._statisticsPerPass[Cesium3DTilePass.RENDER];
-
-
- var s = '<ul class="cesium-cesiumInspector-statistics">';
- s +=
-
- "<li><strong>Visited: </strong>" +
- statistics.visited.toLocaleString() +
- "</li>" +
-
-
- "<li><strong>Selected: </strong>" +
- statistics.selected.toLocaleString() +
- "</li>" +
-
-
- "<li><strong>Commands: </strong>" +
- statistics.numberOfCommands.toLocaleString() +
- "</li>";
- s += "</ul>";
- if (!isPick) {
- s += '<ul class="cesium-cesiumInspector-statistics">';
- s +=
-
- "<li><strong>Requests: </strong>" +
- statistics.numberOfPendingRequests.toLocaleString() +
- "</li>" +
- "<li><strong>Attempted: </strong>" +
- statistics.numberOfAttemptedRequests.toLocaleString() +
- "</li>" +
- "<li><strong>Processing: </strong>" +
- statistics.numberOfTilesProcessing.toLocaleString() +
- "</li>" +
- "<li><strong>Content Ready: </strong>" +
- statistics.numberOfTilesWithContentReady.toLocaleString() +
- "</li>" +
-
-
- "<li><strong>Total: </strong>" +
- statistics.numberOfTilesTotal.toLocaleString() +
- "</li>";
- s += "</ul>";
- s += '<ul class="cesium-cesiumInspector-statistics">';
- s +=
-
- "<li><strong>Features Selected: </strong>" +
- statistics.numberOfFeaturesSelected.toLocaleString() +
- "</li>" +
- "<li><strong>Features Loaded: </strong>" +
- statistics.numberOfFeaturesLoaded.toLocaleString() +
- "</li>" +
- "<li><strong>Points Selected: </strong>" +
- statistics.numberOfPointsSelected.toLocaleString() +
- "</li>" +
- "<li><strong>Points Loaded: </strong>" +
- statistics.numberOfPointsLoaded.toLocaleString() +
- "</li>" +
- "<li><strong>Triangles Selected: </strong>" +
- statistics.numberOfTrianglesSelected.toLocaleString() +
- "</li>";
- s += "</ul>";
- s += '<ul class="cesium-cesiumInspector-statistics">';
- s +=
-
- "<li><strong>Tiles styled: </strong>" +
- statistics.numberOfTilesStyled.toLocaleString() +
- "</li>" +
- "<li><strong>Features styled: </strong>" +
- statistics.numberOfFeaturesStyled.toLocaleString() +
- "</li>";
- s += "</ul>";
- s += '<ul class="cesium-cesiumInspector-statistics">';
- s +=
-
- "<li><strong>Children Union Culled: </strong>" +
- statistics.numberOfTilesCulledWithChildrenUnion.toLocaleString() +
- "</li>";
- s += "</ul>";
- s += '<ul class="cesium-cesiumInspector-statistics">';
- s +=
-
- "<li><strong>Geometry Memory (MB): </strong>" +
- formatMemoryString(statistics.geometryByteLength) +
- "</li>" +
- "<li><strong>Texture Memory (MB): </strong>" +
- formatMemoryString(statistics.texturesByteLength) +
- "</li>" +
- "<li><strong>Batch Table Memory (MB): </strong>" +
- formatMemoryString(statistics.batchTableByteLength) +
- "</li>";
- s += "</ul>";
- }
- return s;
- }
- var colorBlendModes = [
- {
- text: "Highlight",
- value: Cesium3DTileColorBlendMode.HIGHLIGHT,
- },
- {
- text: "Replace",
- value: Cesium3DTileColorBlendMode.REPLACE,
- },
- {
- text: "Mix",
- value: Cesium3DTileColorBlendMode.MIX,
- },
- ];
- var highlightColor = new Color(1.0, 1.0, 0.0, 0.4);
- var scratchColor = new Color();
- var oldColor = new Color();
- function Cesium3DTilesInspectorViewModel(scene, performanceContainer) {
-
- Check.typeOf.object("scene", scene);
- Check.typeOf.object("performanceContainer", performanceContainer);
-
- var that = this;
- var canvas = scene.canvas;
- this._eventHandler = new ScreenSpaceEventHandler(canvas);
- this._scene = scene;
- this._performanceContainer = performanceContainer;
- this._canvas = canvas;
- this._performanceDisplay = new PerformanceDisplay({
- container: performanceContainer,
- });
- this._statisticsText = "";
- this._pickStatisticsText = "";
- this._editorError = "";
-
- this.performance = false;
-
- this.showStatistics = true;
-
- this.showPickStatistics = true;
-
- this.inspectorVisible = true;
-
- this.tilesetVisible = false;
-
- this.displayVisible = false;
-
- this.updateVisible = false;
-
- this.loggingVisible = false;
-
- this.styleVisible = false;
-
- this.tileDebugLabelsVisible = false;
-
- this.optimizationVisible = false;
-
- this.styleString = "{}";
- this._tileset = undefined;
- this._feature = undefined;
- this._tile = undefined;
- knockout.track(this, [
- "performance",
- "inspectorVisible",
- "_statisticsText",
- "_pickStatisticsText",
- "_editorError",
- "showPickStatistics",
- "showStatistics",
- "tilesetVisible",
- "displayVisible",
- "updateVisible",
- "loggingVisible",
- "styleVisible",
- "optimizationVisible",
- "tileDebugLabelsVisible",
- "styleString",
- "_feature",
- "_tile",
- ]);
- this._properties = knockout.observable({});
-
- this.properties = [];
- knockout.defineProperty(this, "properties", function () {
- var names = [];
- var properties = that._properties();
- for (var prop in properties) {
- if (properties.hasOwnProperty(prop)) {
- names.push(prop);
- }
- }
- return names;
- });
- var dynamicScreenSpaceError = knockout.observable();
- knockout.defineProperty(this, "dynamicScreenSpaceError", {
- get: function () {
- return dynamicScreenSpaceError();
- },
- set: function (value) {
- dynamicScreenSpaceError(value);
- if (defined(that._tileset)) {
- that._tileset.dynamicScreenSpaceError = value;
- }
- },
- });
-
- this.dynamicScreenSpaceError = false;
- var colorBlendMode = knockout.observable();
- knockout.defineProperty(this, "colorBlendMode", {
- get: function () {
- return colorBlendMode();
- },
- set: function (value) {
- colorBlendMode(value);
- if (defined(that._tileset)) {
- that._tileset.colorBlendMode = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.colorBlendMode = Cesium3DTileColorBlendMode.HIGHLIGHT;
- var showOnlyPickedTileDebugLabel = knockout.observable();
- var picking = knockout.observable();
- knockout.defineProperty(this, "picking", {
- get: function () {
- return picking();
- },
- set: function (value) {
- picking(value);
- if (value) {
- that._eventHandler.setInputAction(function (e) {
- var picked = scene.pick(e.endPosition);
- if (picked instanceof Cesium3DTileFeature) {
-
- that.feature = picked;
- that.tile = picked.content.tile;
- } else if (defined(picked) && defined(picked.content)) {
-
- that.feature = undefined;
- that.tile = picked.content.tile;
- } else {
-
- that.feature = undefined;
- that.tile = undefined;
- }
- if (!defined(that._tileset)) {
- return;
- }
- if (
- showOnlyPickedTileDebugLabel &&
- defined(picked) &&
- defined(picked.content)
- ) {
- var position;
- if (scene.pickPositionSupported) {
- position = scene.pickPosition(e.endPosition);
- if (defined(position)) {
- that._tileset.debugPickPosition = position;
- }
- }
- that._tileset.debugPickedTile = picked.content.tile;
- } else {
- that._tileset.debugPickedTile = undefined;
- }
- that._scene.requestRender();
- }, ScreenSpaceEventType.MOUSE_MOVE);
- } else {
- that.feature = undefined;
- that.tile = undefined;
- that._eventHandler.removeInputAction(ScreenSpaceEventType.MOUSE_MOVE);
- }
- },
- });
-
- this.picking = true;
- var colorize = knockout.observable();
- knockout.defineProperty(this, "colorize", {
- get: function () {
- return colorize();
- },
- set: function (value) {
- colorize(value);
- if (defined(that._tileset)) {
- that._tileset.debugColorizeTiles = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.colorize = false;
- var wireframe = knockout.observable();
- knockout.defineProperty(this, "wireframe", {
- get: function () {
- return wireframe();
- },
- set: function (value) {
- wireframe(value);
- if (defined(that._tileset)) {
- that._tileset.debugWireframe = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.wireframe = false;
- var showBoundingVolumes = knockout.observable();
- knockout.defineProperty(this, "showBoundingVolumes", {
- get: function () {
- return showBoundingVolumes();
- },
- set: function (value) {
- showBoundingVolumes(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowBoundingVolume = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showBoundingVolumes = false;
- var showContentBoundingVolumes = knockout.observable();
- knockout.defineProperty(this, "showContentBoundingVolumes", {
- get: function () {
- return showContentBoundingVolumes();
- },
- set: function (value) {
- showContentBoundingVolumes(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowContentBoundingVolume = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showContentBoundingVolumes = false;
- var showRequestVolumes = knockout.observable();
- knockout.defineProperty(this, "showRequestVolumes", {
- get: function () {
- return showRequestVolumes();
- },
- set: function (value) {
- showRequestVolumes(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowViewerRequestVolume = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showRequestVolumes = false;
- var freezeFrame = knockout.observable();
- knockout.defineProperty(this, "freezeFrame", {
- get: function () {
- return freezeFrame();
- },
- set: function (value) {
- freezeFrame(value);
- if (defined(that._tileset)) {
- that._tileset.debugFreezeFrame = value;
- that._scene.debugShowFrustumPlanes = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.freezeFrame = false;
- knockout.defineProperty(this, "showOnlyPickedTileDebugLabel", {
- get: function () {
- return showOnlyPickedTileDebugLabel();
- },
- set: function (value) {
- showOnlyPickedTileDebugLabel(value);
- if (defined(that._tileset)) {
- that._tileset.debugPickedTileLabelOnly = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showOnlyPickedTileDebugLabel = false;
- var showGeometricError = knockout.observable();
- knockout.defineProperty(this, "showGeometricError", {
- get: function () {
- return showGeometricError();
- },
- set: function (value) {
- showGeometricError(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowGeometricError = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showGeometricError = false;
- var showRenderingStatistics = knockout.observable();
- knockout.defineProperty(this, "showRenderingStatistics", {
- get: function () {
- return showRenderingStatistics();
- },
- set: function (value) {
- showRenderingStatistics(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowRenderingStatistics = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showRenderingStatistics = false;
- var showMemoryUsage = knockout.observable();
- knockout.defineProperty(this, "showMemoryUsage", {
- get: function () {
- return showMemoryUsage();
- },
- set: function (value) {
- showMemoryUsage(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowMemoryUsage = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showMemoryUsage = false;
- var showUrl = knockout.observable();
- knockout.defineProperty(this, "showUrl", {
- get: function () {
- return showUrl();
- },
- set: function (value) {
- showUrl(value);
- if (defined(that._tileset)) {
- that._tileset.debugShowUrl = value;
- that._scene.requestRender();
- }
- },
- });
-
- this.showUrl = false;
- var maximumScreenSpaceError = knockout.observable();
- knockout.defineProperty(this, "maximumScreenSpaceError", {
- get: function () {
- return maximumScreenSpaceError();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- maximumScreenSpaceError(value);
- if (defined(that._tileset)) {
- that._tileset.maximumScreenSpaceError = value;
- }
- }
- },
- });
-
- this.maximumScreenSpaceError = 16;
- var dynamicScreenSpaceErrorDensity = knockout.observable();
- knockout.defineProperty(this, "dynamicScreenSpaceErrorDensity", {
- get: function () {
- return dynamicScreenSpaceErrorDensity();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- dynamicScreenSpaceErrorDensity(value);
- if (defined(that._tileset)) {
- that._tileset.dynamicScreenSpaceErrorDensity = value;
- }
- }
- },
- });
-
- this.dynamicScreenSpaceErrorDensity = 0.00278;
-
- this.dynamicScreenSpaceErrorDensitySliderValue = undefined;
- knockout.defineProperty(this, "dynamicScreenSpaceErrorDensitySliderValue", {
- get: function () {
- return Math.pow(dynamicScreenSpaceErrorDensity(), 1 / 6);
- },
- set: function (value) {
- dynamicScreenSpaceErrorDensity(Math.pow(value, 6));
- },
- });
- var dynamicScreenSpaceErrorFactor = knockout.observable();
- knockout.defineProperty(this, "dynamicScreenSpaceErrorFactor", {
- get: function () {
- return dynamicScreenSpaceErrorFactor();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- dynamicScreenSpaceErrorFactor(value);
- if (defined(that._tileset)) {
- that._tileset.dynamicScreenSpaceErrorFactor = value;
- }
- }
- },
- });
-
- this.dynamicScreenSpaceErrorFactor = 4.0;
- var pickTileset = getPickTileset(this);
- var pickActive = knockout.observable();
- knockout.defineProperty(this, "pickActive", {
- get: function () {
- return pickActive();
- },
- set: function (value) {
- pickActive(value);
- if (value) {
- that._eventHandler.setInputAction(
- pickTileset,
- ScreenSpaceEventType.LEFT_CLICK
- );
- } else {
- that._eventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK);
- }
- },
- });
- var pointCloudShading = knockout.observable();
- knockout.defineProperty(this, "pointCloudShading", {
- get: function () {
- return pointCloudShading();
- },
- set: function (value) {
- pointCloudShading(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.attenuation = value;
- }
- },
- });
-
- this.pointCloudShading = false;
- var geometricErrorScale = knockout.observable();
- knockout.defineProperty(this, "geometricErrorScale", {
- get: function () {
- return geometricErrorScale();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- geometricErrorScale(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.geometricErrorScale = value;
- }
- }
- },
- });
-
- this.geometricErrorScale = 1.0;
- var maximumAttenuation = knockout.observable();
- knockout.defineProperty(this, "maximumAttenuation", {
- get: function () {
- return maximumAttenuation();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- maximumAttenuation(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.maximumAttenuation =
- value === 0 ? undefined : value;
- }
- }
- },
- });
-
- this.maximumAttenuation = 0;
- var baseResolution = knockout.observable();
- knockout.defineProperty(this, "baseResolution", {
- get: function () {
- return baseResolution();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- baseResolution(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.baseResolution =
- value === 0 ? undefined : value;
- }
- }
- },
- });
-
- this.baseResolution = 0;
- var eyeDomeLighting = knockout.observable();
- knockout.defineProperty(this, "eyeDomeLighting", {
- get: function () {
- return eyeDomeLighting();
- },
- set: function (value) {
- eyeDomeLighting(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.eyeDomeLighting = value;
- }
- },
- });
-
- this.eyeDomeLighting = false;
- var eyeDomeLightingStrength = knockout.observable();
- knockout.defineProperty(this, "eyeDomeLightingStrength", {
- get: function () {
- return eyeDomeLightingStrength();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- eyeDomeLightingStrength(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.eyeDomeLightingStrength = value;
- }
- }
- },
- });
-
- this.eyeDomeLightingStrength = 1.0;
- var eyeDomeLightingRadius = knockout.observable();
- knockout.defineProperty(this, "eyeDomeLightingRadius", {
- get: function () {
- return eyeDomeLightingRadius();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- eyeDomeLightingRadius(value);
- if (defined(that._tileset)) {
- that._tileset.pointCloudShading.eyeDomeLightingRadius = value;
- }
- }
- },
- });
-
- this.eyeDomeLightingRadius = 1.0;
-
- this.pickActive = false;
- var skipLevelOfDetail = knockout.observable();
- knockout.defineProperty(this, "skipLevelOfDetail", {
- get: function () {
- return skipLevelOfDetail();
- },
- set: function (value) {
- skipLevelOfDetail(value);
- if (defined(that._tileset)) {
- that._tileset.skipLevelOfDetail = value;
- }
- },
- });
-
- this.skipLevelOfDetail = true;
- var skipScreenSpaceErrorFactor = knockout.observable();
- knockout.defineProperty(this, "skipScreenSpaceErrorFactor", {
- get: function () {
- return skipScreenSpaceErrorFactor();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- skipScreenSpaceErrorFactor(value);
- if (defined(that._tileset)) {
- that._tileset.skipScreenSpaceErrorFactor = value;
- }
- }
- },
- });
-
- this.skipScreenSpaceErrorFactor = 16;
- var baseScreenSpaceError = knockout.observable();
- knockout.defineProperty(this, "baseScreenSpaceError", {
- get: function () {
- return baseScreenSpaceError();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- baseScreenSpaceError(value);
- if (defined(that._tileset)) {
- that._tileset.baseScreenSpaceError = value;
- }
- }
- },
- });
-
- this.baseScreenSpaceError = 1024;
- var skipLevels = knockout.observable();
- knockout.defineProperty(this, "skipLevels", {
- get: function () {
- return skipLevels();
- },
- set: function (value) {
- value = Number(value);
- if (!isNaN(value)) {
- skipLevels(value);
- if (defined(that._tileset)) {
- that._tileset.skipLevels = value;
- }
- }
- },
- });
-
- this.skipLevels = 1;
- var immediatelyLoadDesiredLevelOfDetail = knockout.observable();
- knockout.defineProperty(this, "immediatelyLoadDesiredLevelOfDetail", {
- get: function () {
- return immediatelyLoadDesiredLevelOfDetail();
- },
- set: function (value) {
- immediatelyLoadDesiredLevelOfDetail(value);
- if (defined(that._tileset)) {
- that._tileset.immediatelyLoadDesiredLevelOfDetail = value;
- }
- },
- });
-
- this.immediatelyLoadDesiredLevelOfDetail = false;
- var loadSiblings = knockout.observable();
- knockout.defineProperty(this, "loadSiblings", {
- get: function () {
- return loadSiblings();
- },
- set: function (value) {
- loadSiblings(value);
- if (defined(that._tileset)) {
- that._tileset.loadSiblings = value;
- }
- },
- });
-
- this.loadSiblings = false;
- this._style = undefined;
- this._shouldStyle = false;
- this._definedProperties = [
- "properties",
- "dynamicScreenSpaceError",
- "colorBlendMode",
- "picking",
- "colorize",
- "wireframe",
- "showBoundingVolumes",
- "showContentBoundingVolumes",
- "showRequestVolumes",
- "freezeFrame",
- "maximumScreenSpaceError",
- "dynamicScreenSpaceErrorDensity",
- "baseScreenSpaceError",
- "skipScreenSpaceErrorFactor",
- "skipLevelOfDetail",
- "skipLevels",
- "immediatelyLoadDesiredLevelOfDetail",
- "loadSiblings",
- "dynamicScreenSpaceErrorDensitySliderValue",
- "dynamicScreenSpaceErrorFactor",
- "pickActive",
- "showOnlyPickedTileDebugLabel",
- "showGeometricError",
- "showRenderingStatistics",
- "showMemoryUsage",
- "showUrl",
- "pointCloudShading",
- "geometricErrorScale",
- "maximumAttenuation",
- "baseResolution",
- "eyeDomeLighting",
- "eyeDomeLightingStrength",
- "eyeDomeLightingRadius",
- ];
- this._removePostRenderEvent = scene.postRender.addEventListener(function () {
- that._update();
- });
- if (!defined(this._tileset)) {
- selectTilesetOnHover(this, true);
- }
- }
- Object.defineProperties(Cesium3DTilesInspectorViewModel.prototype, {
-
- scene: {
- get: function () {
- return this._scene;
- },
- },
-
- performanceContainer: {
- get: function () {
- return this._performanceContainer;
- },
- },
-
- statisticsText: {
- get: function () {
- return this._statisticsText;
- },
- },
-
- pickStatisticsText: {
- get: function () {
- return this._pickStatisticsText;
- },
- },
-
- colorBlendModes: {
- get: function () {
- return colorBlendModes;
- },
- },
-
- editorError: {
- get: function () {
- return this._editorError;
- },
- },
-
- tileset: {
- get: function () {
- return this._tileset;
- },
- set: function (tileset) {
- this._tileset = tileset;
- this._style = undefined;
- this.styleString = "{}";
- this.feature = undefined;
- this.tile = undefined;
- if (defined(tileset)) {
- var that = this;
- tileset.readyPromise.then(function (t) {
- if (!that.isDestroyed()) {
- that._properties(t.properties);
- }
- });
-
- var settings = [
- "colorize",
- "wireframe",
- "showBoundingVolumes",
- "showContentBoundingVolumes",
- "showRequestVolumes",
- "freezeFrame",
- "showOnlyPickedTileDebugLabel",
- "showGeometricError",
- "showRenderingStatistics",
- "showMemoryUsage",
- "showUrl",
- ];
- var length = settings.length;
- for (var i = 0; i < length; ++i) {
- var setting = settings[i];
-
- this[setting] = this[setting];
- }
-
- this.maximumScreenSpaceError = tileset.maximumScreenSpaceError;
- this.dynamicScreenSpaceError = tileset.dynamicScreenSpaceError;
- this.dynamicScreenSpaceErrorDensity =
- tileset.dynamicScreenSpaceErrorDensity;
- this.dynamicScreenSpaceErrorFactor =
- tileset.dynamicScreenSpaceErrorFactor;
- this.colorBlendMode = tileset.colorBlendMode;
- this.skipLevelOfDetail = tileset.skipLevelOfDetail;
- this.skipScreenSpaceErrorFactor = tileset.skipScreenSpaceErrorFactor;
- this.baseScreenSpaceError = tileset.baseScreenSpaceError;
- this.skipLevels = tileset.skipLevels;
- this.immediatelyLoadDesiredLevelOfDetail =
- tileset.immediatelyLoadDesiredLevelOfDetail;
- this.loadSiblings = tileset.loadSiblings;
- var pointCloudShading = tileset.pointCloudShading;
- this.pointCloudShading = pointCloudShading.attenuation;
- this.geometricErrorScale = pointCloudShading.geometricErrorScale;
- this.maximumAttenuation = pointCloudShading.maximumAttenuation
- ? pointCloudShading.maximumAttenuation
- : 0.0;
- this.baseResolution = pointCloudShading.baseResolution
- ? pointCloudShading.baseResolution
- : 0.0;
- this.eyeDomeLighting = pointCloudShading.eyeDomeLighting;
- this.eyeDomeLightingStrength =
- pointCloudShading.eyeDomeLightingStrength;
- this.eyeDomeLightingRadius = pointCloudShading.eyeDomeLightingRadius;
- this._scene.requestRender();
- } else {
- this._properties({});
- }
- this._statisticsText = getStatistics(tileset, false);
- this._pickStatisticsText = getStatistics(tileset, true);
- selectTilesetOnHover(this, false);
- },
- },
-
- feature: {
- get: function () {
- return this._feature;
- },
- set: function (feature) {
- if (this._feature === feature) {
- return;
- }
- var currentFeature = this._feature;
- if (defined(currentFeature) && !currentFeature.content.isDestroyed()) {
-
- if (!this.colorize && defined(this._style)) {
- currentFeature.color = defined(this._style.color)
- ? this._style.color.evaluateColor(currentFeature, scratchColor)
- : Color.WHITE;
- } else {
- currentFeature.color = oldColor;
- }
- this._scene.requestRender();
- }
- if (defined(feature)) {
-
- Color.clone(feature.color, oldColor);
- feature.color = highlightColor;
- this._scene.requestRender();
- }
- this._feature = feature;
- },
- },
-
- tile: {
- get: function () {
- return this._tile;
- },
- set: function (tile) {
- if (this._tile === tile) {
- return;
- }
- var currentTile = this._tile;
- if (
- defined(currentTile) &&
- !currentTile.isDestroyed() &&
- !hasFeatures(currentTile.content)
- ) {
-
- currentTile.color = oldColor;
- this._scene.requestRender();
- }
- if (defined(tile) && !hasFeatures(tile.content)) {
-
- Color.clone(tile.color, oldColor);
- tile.color = highlightColor;
- this._scene.requestRender();
- }
- this._tile = tile;
- },
- },
- });
- function hasFeatures(content) {
- if (content.featuresLength > 0) {
- return true;
- }
- var innerContents = content.innerContents;
- if (defined(innerContents)) {
- var length = innerContents.length;
- for (var i = 0; i < length; ++i) {
- if (!hasFeatures(innerContents[i])) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
- Cesium3DTilesInspectorViewModel.prototype.togglePickTileset = function () {
- this.pickActive = !this.pickActive;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleInspector = function () {
- this.inspectorVisible = !this.inspectorVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleTileset = function () {
- this.tilesetVisible = !this.tilesetVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleDisplay = function () {
- this.displayVisible = !this.displayVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleUpdate = function () {
- this.updateVisible = !this.updateVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleLogging = function () {
- this.loggingVisible = !this.loggingVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleStyle = function () {
- this.styleVisible = !this.styleVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleTileDebugLabels = function () {
- this.tileDebugLabelsVisible = !this.tileDebugLabelsVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.toggleOptimization = function () {
- this.optimizationVisible = !this.optimizationVisible;
- };
- Cesium3DTilesInspectorViewModel.prototype.trimTilesCache = function () {
- if (defined(this._tileset)) {
- this._tileset.trimLoadedTiles();
- }
- };
- Cesium3DTilesInspectorViewModel.prototype.compileStyle = function () {
- var tileset = this._tileset;
- if (!defined(tileset) || this.styleString === JSON.stringify(tileset.style)) {
- return;
- }
- this._editorError = "";
- try {
- if (this.styleString.length === 0) {
- this.styleString = "{}";
- }
- this._style = new Cesium3DTileStyle(JSON.parse(this.styleString));
- this._shouldStyle = true;
- this._scene.requestRender();
- } catch (err) {
- this._editorError = err.toString();
- }
-
- this.feature = this._feature;
- this.tile = this._tile;
- };
- Cesium3DTilesInspectorViewModel.prototype.styleEditorKeyPress = function (
- sender,
- event
- ) {
- if (event.keyCode === 9) {
-
- event.preventDefault();
- var textArea = event.target;
- var start = textArea.selectionStart;
- var end = textArea.selectionEnd;
- var newEnd = end;
- var selected = textArea.value.slice(start, end);
- var lines = selected.split("\n");
- var length = lines.length;
- var i;
- if (!event.shiftKey) {
- for (i = 0; i < length; ++i) {
- lines[i] = " " + lines[i];
- newEnd += 2;
- }
- } else {
- for (i = 0; i < length; ++i) {
- if (lines[i][0] === " ") {
- if (lines[i][1] === " ") {
- lines[i] = lines[i].substr(2);
- newEnd -= 2;
- } else {
- lines[i] = lines[i].substr(1);
- newEnd -= 1;
- }
- }
- }
- }
- var newText = lines.join("\n");
- textArea.value =
- textArea.value.slice(0, start) + newText + textArea.value.slice(end);
- textArea.selectionStart = start !== end ? start : newEnd;
- textArea.selectionEnd = newEnd;
- } else if (event.ctrlKey && (event.keyCode === 10 || event.keyCode === 13)) {
-
- this.compileStyle();
- }
- return true;
- };
- Cesium3DTilesInspectorViewModel.prototype._update = function () {
- var tileset = this._tileset;
- if (this.performance) {
- this._performanceDisplay.update();
- }
- if (defined(tileset)) {
- if (tileset.isDestroyed()) {
- this.tile = undefined;
- this.feature = undefined;
- this.tileset = undefined;
- return;
- }
- var style = tileset.style;
- if (this._style !== tileset.style) {
- if (this._shouldStyle) {
- tileset.style = this._style;
- this._shouldStyle = false;
- } else {
- this._style = style;
- this.styleString = JSON.stringify(style.style, null, " ");
- }
- }
- }
- if (this.showStatistics) {
- this._statisticsText = getStatistics(tileset, false);
- this._pickStatisticsText = getStatistics(tileset, true);
- }
- };
- Cesium3DTilesInspectorViewModel.prototype.isDestroyed = function () {
- return false;
- };
- Cesium3DTilesInspectorViewModel.prototype.destroy = function () {
- this._eventHandler.destroy();
- this._removePostRenderEvent();
- var that = this;
- this._definedProperties.forEach(function (property) {
- knockout.getObservable(that, property).dispose();
- });
- return destroyObject(this);
- };
- Cesium3DTilesInspectorViewModel.getStatistics = getStatistics;
- export default Cesium3DTilesInspectorViewModel;
|