Skip to content

Commit

Permalink
Merge pull request #78 from mulfvik/maximum-screenspace-error
Browse files Browse the repository at this point in the history
Adds maximum screenspace error option
  • Loading branch information
Son-HNguyen authored Apr 9, 2024
2 parents c4eebdc + e444f95 commit bd54bed
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
8 changes: 7 additions & 1 deletion 3dwebclient/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@
<input type="text" data-bind="value: maxSizeOfCachedTiles">
</td>
</tr>
<tr id="maximumScreenSpaceError">
<td>MaximumScreenSpaceError</td>
<td>
<input type="text" data-bind="value: maximumScreenSpaceError">
</td>
</tr>
</tbody>
</table>
<div class="citydb_short_container">
Expand Down Expand Up @@ -644,4 +650,4 @@
</script>
<script src="script.js"></script>
</body>
</html>
</html>
10 changes: 8 additions & 2 deletions 3dwebclient/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ var addLayerViewModel = {
minLodPixels: "",
maxLodPixels: "",
maxSizeOfCachedTiles: 200,
maxCountOfVisibleTiles: 200
maxCountOfVisibleTiles: 200,
maximumScreenSpaceError: 16
};
Cesium.knockout.track(addLayerViewModel);
Cesium.knockout.applyBindings(addLayerViewModel, document.getElementById('citydb_addlayerpanel'));
Expand Down Expand Up @@ -309,6 +310,7 @@ function observeActiveLayer() {
addLayerViewModel.maxLodPixels = selectedLayer.maxLodPixels;
addLayerViewModel.maxSizeOfCachedTiles = selectedLayer.maxSizeOfCachedTiles;
addLayerViewModel.maxCountOfVisibleTiles = selectedLayer.maxCountOfVisibleTiles;
addLayerViewModel.maximumScreenSpaceError = selectedLayer.maximumScreenSpaceError;
}
}

Expand Down Expand Up @@ -470,6 +472,7 @@ function saveLayerSettings() {
applySaving('maxLodPixels', activeLayer);
applySaving('maxSizeOfCachedTiles', activeLayer);
applySaving('maxCountOfVisibleTiles', activeLayer);
applySaving('maximumScreenSpaceError', activeLayer);
console.log(activeLayer);

// Update Data Source
Expand Down Expand Up @@ -894,7 +897,8 @@ function addNewLayer() {
minLodPixels: addLayerViewModel.minLodPixels,
maxLodPixels: addLayerViewModel.maxLodPixels == -1 ? Number.MAX_VALUE : addLayerViewModel.maxLodPixels,
maxSizeOfCachedTiles: addLayerViewModel.maxSizeOfCachedTiles,
maxCountOfVisibleTiles: addLayerViewModel.maxCountOfVisibleTiles
maxCountOfVisibleTiles: addLayerViewModel.maxCountOfVisibleTiles,
maximumScreenSpaceError: addLayerViewModel.maximumScreenSpaceError
}

// since Cesium 3D Tiles also require name.json in the URL, it must be checked first
Expand Down Expand Up @@ -1173,9 +1177,11 @@ function layerDataTypeDropdownOnchange() {
if (layerDataTypeDropdown.options[layerDataTypeDropdown.selectedIndex].value !== "COLLADA/KML/glTF") {
document.getElementById("gltfVersionDropdownRow").style.display = "none";
document.getElementById("layerProxyAndClampToGround").style.display = "none";
document.getElementById("maximumScreenSpaceError").style.display = "";
} else {
document.getElementById("gltfVersionDropdownRow").style.display = "";
document.getElementById("layerProxyAndClampToGround").style.display = "";
document.getElementById("maximumScreenSpaceError").style.display = "none";
}
addLayerViewModel["layerDataType"] = layerDataTypeDropdown.options[layerDataTypeDropdown.selectedIndex].value;
}
Expand Down
3 changes: 3 additions & 0 deletions 3dwebclient/utils/UrlController.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var UrlController = /** @class */ (function () {
"maxLodPixels": "al",
"maxSizeOfCachedTiles": "ac",
"maxCountOfVisibleTiles": "av",
"maximumScreenSpaceError": "mse",
// basemap infos
"basemap": "bm",
// "name" : "n",
Expand Down Expand Up @@ -182,6 +183,7 @@ var UrlController = /** @class */ (function () {
layerConfig[this.getUrlParaForward('maxLodPixels')] = Cesium.defaultValue(layer.maxLodPixels, "");
layerConfig[this.getUrlParaForward('maxSizeOfCachedTiles')] = Cesium.defaultValue(layer.maxSizeOfCachedTiles, "");
layerConfig[this.getUrlParaForward('maxCountOfVisibleTiles')] = Cesium.defaultValue(layer.maxCountOfVisibleTiles, "");
layerConfig[this.getUrlParaForward('maximumScreenSpaceError')] = Cesium.defaultValue(layer.maximumScreenSpaceError, "");
layerGroupObject[this.getUrlParaForward('layer_') + i] = Cesium.objectToQuery(layerConfig);
}
return Cesium.objectToQuery(layerGroupObject);
Expand Down Expand Up @@ -267,6 +269,7 @@ var UrlController = /** @class */ (function () {
maxLodPixels: this.getValueFromObject('maxLodPixels', layerConfig, Number.MAX_VALUE, Cesium) === -1 ? Number.MAX_VALUE : this.getValueFromObject('maxLodPixels', layerConfig, Number.MAX_VALUE, Cesium),
maxSizeOfCachedTiles: this.getValueFromObject('maxSizeOfCachedTiles', layerConfig, 140, Cesium),
maxCountOfVisibleTiles: this.getValueFromObject('maxCountOfVisibleTiles', layerConfig, 140, Cesium),
maximumScreenSpaceError: this.getValueFromObject('maximumScreenSpaceError', layerConfig, '', Cesium),
};
if (['kml', 'kmz', 'json', 'czml'].indexOf(CitydbUtil.get_suffix_from_filename(options.url)) > -1
&& options.layerDataType === "COLLADA/KML/glTF") {
Expand Down
23 changes: 19 additions & 4 deletions js/Cesium3DTilesDataLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
this._tableType = Cesium.defaultValue(options.tableType, "");
this._cityobjectsJsonUrl = options.cityobjectsJsonUrl;
this._thematicDataProvider = Cesium.defaultValue(options.thematicDataProvider, "");
this._maximumScreenSpaceError = Cesium.defaultValue(options.maximumScreenSpaceError, "");
this._cesiumViewer = undefined;
this._tileset = undefined;

Expand All @@ -67,7 +68,8 @@
"url": this.url,
"layerDataType": this.layerDataType,
"thematicDataUrl": this.thematicDataUrl,
"thematicDataProvider": this._thematicDataProvider
"thematicDataProvider": this._thematicDataProvider,
"maximumScreenSpaceError": this._maximumScreenSpaceError,
}

/**
Expand Down Expand Up @@ -261,7 +263,18 @@
get: function () {
return this._configParameters;
}
}
},
/**
* Gets the maximumScreenSpaceError of the Cesium 3D Tiles
*/
maximumScreenSpaceError: {
get: function () {
return this._maximumScreenSpaceError;
},
set: function (value) {
this._maximumScreenSpaceError = value;
}
},
});

/**
Expand Down Expand Up @@ -290,7 +303,8 @@
var deferred = Cesium.when.defer();

this._tileset = new Cesium.Cesium3DTileset({
url: this._url
url: this._url,
maximumScreenSpaceError: this._maximumScreenSpaceError
});

this._tileset.readyPromise.then(function (tileset) {
Expand Down Expand Up @@ -462,7 +476,8 @@
this._cesiumViewer.scene.primitives.remove(this._tileset);

this._tileset = new Cesium.Cesium3DTileset({
url: this.autofillUrl(this._url)
url: this.autofillUrl(this._url),
maximumScreenSpaceError: this._maximumScreenSpaceError
});

this._tileset.readyPromise.then(function (tileset) {
Expand Down

0 comments on commit bd54bed

Please sign in to comment.