Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Building Scene Layer (BSL) OGC I3S standard #11678

Merged
merged 33 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
808fcaa
- Added support for conversion from sRGB color space profile to linea…
Tamrat-B Dec 5, 2023
0b9869b
Added Support for BSL structure, BSL statistics, generic feature attr…
Tamrat-B Dec 5, 2023
d612e7b
I3S Building Scene Layer Sandcastle app
Tamrat-B Dec 5, 2023
a4da846
I3S BSL app icon
Tamrat-B Dec 5, 2023
f469a21
Added support for conversion from sRGB color space profile to linear …
Tamrat-B Dec 5, 2023
4f92b4a
added additional payload options
Tamrat-B Dec 5, 2023
a2066b0
- Added support for binary attribute data with values stored in objec…
Tamrat-B Dec 5, 2023
562d6e5
- Added support for 3D objects transparency
Tamrat-B Dec 5, 2023
89f6dbe
- Added support for BSL hierarchy of layers
Tamrat-B Dec 5, 2023
394f823
- Added support for the generic feature attribute driven filter
Tamrat-B Dec 5, 2023
1394e4a
Added support for BSL structure per the OGC I3S standard
Tamrat-B Dec 5, 2023
5a34b60
- Added support for symbolization defined in I3S Layer data
Tamrat-B Dec 5, 2023
1054536
Added support for EXT_mesh_features and EXT_structural_metadata glTF …
Tamrat-B Dec 5, 2023
e1d55f7
Added bsl layer tests
Tamrat-B Dec 5, 2023
04f3c51
Added I3S BSL ViewModel tests
Tamrat-B Dec 5, 2023
3e75b94
Added I3S BSL explorer
Tamrat-B Dec 5, 2023
969ac49
Added I3S Explorer tests
Tamrat-B Dec 5, 2023
b4b23a6
Added I3S BSL Explorer layer widget
Tamrat-B Dec 5, 2023
e03286b
Merge branch 'CesiumGS:main' into feature/i3s_bsl_support
Tamrat-B Jan 11, 2024
21b2f4f
updates based on review feedback
Tamrat-B Jan 11, 2024
efc7db5
Added I3S support PR to additions
Tamrat-B Feb 2, 2024
03a9125
removed non necessary options
Tamrat-B Feb 2, 2024
17784df
check before updating visibility
Tamrat-B Feb 2, 2024
c815c03
additional specs changes
Tamrat-B Feb 2, 2024
4bffc64
Merge branch 'main' into feature/i3s_bsl_support
Tamrat-B Feb 2, 2024
9f02cf3
Merge branch 'CesiumGS:main' into feature/i3s_bsl_support
Tamrat-B Feb 28, 2024
9d6dc59
Removed picking result from console output
Tamrat-B Feb 28, 2024
c7570c3
Remove console out if geoid transform is not needed
Tamrat-B Feb 28, 2024
88eae59
Default to model overview if present
Tamrat-B Feb 28, 2024
1aefdc9
update tests to account for model views
Tamrat-B Feb 28, 2024
cf8d1da
Added I3S Building Scene Layer support to March 1 release
Tamrat-B Feb 28, 2024
96aca3e
Handling edge case use cases where there is no Full Model and/or Over…
Tamrat-B Feb 28, 2024
a3ea292
Rename BSL -> BuildingSceneLayer
ggetz Feb 28, 2024
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updates based on review feedback
  • Loading branch information
Tamrat-B committed Jan 11, 2024
commit 21b2f4f4fd98609fd5b7b774743a7f7934ab10a2
8 changes: 1 addition & 7 deletions Apps/Sandcastle/gallery/I3S 3D Object Layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,9 @@ <h1>Loading...</h1>
const geoidService = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/EGM2008/ImageServer"
);
// Create i3s and Cesium3DTileset options to pass optional parameters useful for debugging and visualizing
const cesium3dTilesetOptions = {
skipLevelOfDetail: false,
debugShowBoundingVolume: false,
};
// Create i3s options to pass optional parameters useful for debugging and visualizing
const i3sOptions = {
traceFetches: false, // for tracing I3S fetches
geoidTiledTerrainProvider: geoidService, // pass the geoid service
cesium3dTilesetOptions: cesium3dTilesetOptions, // options for internal Cesium3dTileset
};

// Create I3S data provider
Expand Down
29 changes: 7 additions & 22 deletions Apps/Sandcastle/gallery/I3S Building Scene Layer.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ <h1>Loading...</h1>
window.startup = async function (Cesium) {
"use strict";
//Sandcastle_Begin
// Cesium World Terrain height system doesn't match to I3S datasets height system in some locations even with geoid conversion.
// Set ArcGIS Tiled Elevation Terrain gravity related height system to get closer results.
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: new Cesium.Terrain(
Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
Expand All @@ -54,38 +56,21 @@ <h1>Loading...</h1>
animation: false,
timeline: false,
orderIndependentTranslucency: false,
msaaSamples: 4, // enables Multisample anti-aliasing for improved visual quality
msaaSamples: 4, // enables multisample antialiasing for improved visual quality
});

// More datasets to tour can be added here...
// The url passed to I3SDataProvider supports loading a single Indexed 3D Scene (I3S) layer (.<host>/SceneServer/layers/<id>) or a collection of scene layers (.<host>/SceneServer) from a SceneServer.
const resource = new Cesium.Resource(
"https://tiles.arcgis.com/tiles/cFEFS0EWrhfDeVw9/arcgis/rest/services/Turanga_Library/SceneServer"
);
// Set a query parameter for json to avoid failure on html pages
resource.setQueryParameters(
{
f: "pjson",
},
true
);
const tours = {
"Turanga Library": resource.url,
"Turanga Library":
"https://tiles.arcgis.com/tiles/cFEFS0EWrhfDeVw9/arcgis/rest/services/Turanga_Library/SceneServer",
};

try {
// Create i3s and Cesium3DTileset options to pass optional parameters useful for debugging and visualizing
const cesium3dTilesetOptions = {
skipLevelOfDetail: false,
debugShowBoundingVolume: false,
// maximumScreenSpaceError: 1, //setting to lower values will improve (quality-wise) the level of detail refinement by forcing higher lod tile descendants to 'show up sooner'.
// outlineColor: Cesium.Color.BLUE, // To replace/override the outline color defined in I3S symbology
};
// Create i3s options to pass optional parameters useful for debugging and visualizing
const i3sOptions = {
traceFetches: false, // for tracing I3S fetches
cesium3dTilesetOptions: cesium3dTilesetOptions, // options for internal Cesium3dTileset
adjustMaterialAlphaMode: true, // force the alpha mode to be set for transparent geometry
enableFeatureFiltering: true, // Enables feature filtering and allows to display (popup) feature attributes
showFeatures: true, // creates 3D object for each feature and allows to apply attributes filter
applySymbology: true, // applies outlines based on the I3S layer renderer details
calculateNormals: true, // generates flat normals if they are missing in I3S buffers
};
Expand Down
8 changes: 1 addition & 7 deletions Apps/Sandcastle/gallery/I3S Feature Picking.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,9 @@ <h1>Loading...</h1>
const geoidService = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
"https://tiles.arcgis.com/tiles/z2tnIkrLQ2BRzr6P/arcgis/rest/services/EGM2008/ImageServer"
);
// Create i3s and Cesium3DTileset options to pass optional parameters useful for debugging and visualizing
const cesium3dTilesetOptions = {
skipLevelOfDetail: false,
debugShowBoundingVolume: false,
};
// Create i3s options to pass optional parameters useful for debugging and visualizing
const i3sOptions = {
traceFetches: false, // for tracing I3S fetches
geoidTiledTerrainProvider: geoidService, // pass the geoid service
cesium3dTilesetOptions: cesium3dTilesetOptions, // options for internal Cesium3dTileset
};

// Create I3S data provider
Expand Down
6 changes: 6 additions & 0 deletions packages/engine/Source/Core/srgbToLinear.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Check from "./Check.js";

/**
* Converts the value from sRGB color space to linear color space.
*
Expand All @@ -13,6 +15,10 @@
* });
*/
function srgbToLinear(value) {
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
//>>includeStart('debug', pragmas.debug);
Check.defined("value", value);
//>>includeEnd('debug');

if (value <= 0.04045) {
// eslint-disable-next-line no-loss-of-precision
return value * 0.07739938080495356037151702786378;
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
91 changes: 47 additions & 44 deletions packages/engine/Source/Scene/I3SDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
* Co-authored-by: Anthony Mirabeau anthony.mirabeau@presagis.com
* Co-authored-by: Elizabeth Rudkin elizabeth.rudkin@presagis.com
* Co-authored-by: Tamrat Belayneh tbelayneh@esri.com
* Co-authored-by: Anton Smirnov anton.smirnov@actionengine.com
* Co-authored-by: Maxim Kuznetsov maxim.kuznetsov@actionengine.com

*
* The I3S format has been developed by Esri and is shared under an Apache 2.0 license and is maintained @ https://github.com/Esri/i3s-spec.
* This implementation supports loading, displaying, and querying an I3S layer (supported versions include Esri github I3S versions 1.6, 1.7/1.8 -
* whose OGC equivalent are I3S Community Standard Version 1.1, 1.2 & 1.3) in the CesiumJS viewer.
* whose OGC equivalent are I3S Community Standard Version 1.1 & 1.2) in the CesiumJS viewer.
* It enables the user to access an I3S layer via its URL and load it inside of the CesiumJS viewer.
*
* When a scene layer is initialized it accomplishes the following:
Expand Down Expand Up @@ -73,12 +70,30 @@ import Rectangle from "../Core/Rectangle.js";
* @property {string} [name] The name of the I3S dataset.
* @property {boolean} [show=true] Determines if the dataset will be shown.
* @property {ArcGISTiledElevationTerrainProvider|Promise<ArcGISTiledElevationTerrainProvider>} [geoidTiledTerrainProvider] Tiled elevation provider describing an Earth Gravitational Model. If defined, geometry will be shifted based on the offsets given by this provider. Required to position I3S data sets with gravity-related height at the correct location.
* @property {boolean} [traceFetches=false] Debug option. When true, log a message whenever an I3S tile is fetched.
* @property {Cesium3DTileset.ConstructorOptions} [cesium3dTilesetOptions] Object containing options to pass to an internally created {@link Cesium3DTileset}. See {@link Cesium3DTileset} for list of valid properties. All options can be used with the exception of <code>url</code> and <code>show</code> which are overridden by values from I3SDataProvider.
* @property {boolean} [enableFeatureFiltering=false] Determines if the features will be shown.
* @property {boolean} [showFeatures=false] Determines if the features will be shown.
* @property {boolean} [adjustMaterialAlphaMode=false] The option to adjust the alpha mode of the material based on the transparency of the vertex color. When <code>true</code>, the alpha mode of the material (if not defined) will be set to BLEND for geometry with any transparency in the color vertex attribute.
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
* @property {boolean} [applySymbology=false] Determines if the I3S symbology will be parsed and applied for the layers.
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
* @property {boolean} [calculateNormals=false] Determines if the flat normals will be generated for I3S geometry without normals.
*
* @example
* // Increase LOD by reducing SSE
* const cesium3dTilesetOptions = {
* maximumScreenSpaceError: 1,
* };
* const i3sOptions = {
* cesium3dTilesetOptions: cesium3dTilesetOptions,
* };
*
* @example
* // Set a custom outline color to replace the color defined in I3S symbology
* const cesium3dTilesetOptions = {
* outlineColor: Cesium.Color.BLUE,
* };
* const i3sOptions = {
* cesium3dTilesetOptions: cesium3dTilesetOptions,
* applySymbology: true,
* };
*/

/**
Expand Down Expand Up @@ -131,11 +146,7 @@ function I3SDataProvider(options) {
this._name = options.name;
this._show = defaultValue(options.show, true);
this._geoidTiledTerrainProvider = options.geoidTiledTerrainProvider;
this._traceFetches = defaultValue(options.traceFetches, false);
this._enableFeatureFiltering = defaultValue(
options.enableFeatureFiltering,
false
);
this._showFeatures = defaultValue(options.showFeatures, false);
this._adjustMaterialAlphaMode = defaultValue(
options.adjustMaterialAlphaMode,
false
Expand Down Expand Up @@ -194,24 +205,6 @@ Object.defineProperties(I3SDataProvider.prototype, {
},
},

/**
* Gets or sets debugging and tracing of I3S fetches.
* @memberof I3SDataProvider.prototype
* @type {boolean}
*/
traceFetches: {
get: function () {
return this._traceFetches;
},
set: function (value) {
//>>includeStart('debug', pragmas.debug);
Check.defined("value", value);
//>>includeEnd('debug');

this._traceFetches = value;
},
},

/**
* The terrain provider referencing the GEOID service to be used for orthometric to ellipsoidal conversion.
* @memberof I3SDataProvider.prototype
Expand Down Expand Up @@ -290,9 +283,9 @@ Object.defineProperties(I3SDataProvider.prototype, {
* @type {boolean}
* @readonly
*/
enableFeatureFiltering: {
showFeatures: {
get: function () {
return this._enableFeatureFiltering;
return this._showFeatures;
},
},

Expand Down Expand Up @@ -432,9 +425,9 @@ function buildLayerUrl(provider, layerId) {

async function addLayers(provider, data, options) {
if (data.layerType === "Building") {
if (!defined(options.enableFeatureFiltering)) {
if (!defined(options.showFeatures)) {
// The Building Scene Layer requires features to be shown to support filtering
provider._enableFeatureFiltering = true;
provider._showFeatures = true;
}
if (!defined(options.adjustMaterialAlphaMode)) {
// The Building Scene Layer enables transparency by default
Expand Down Expand Up @@ -512,7 +505,7 @@ async function addLayers(provider, data, options) {

/**
* Creates an I3SDataProvider. Currently supported I3S versions are 1.6 and
* 1.7/1.8 (OGC I3S 1.3).
* 1.7/1.8 (OGC I3S 1.2).
*
* @param {string|Resource} url The url of the I3S dataset, which should return an I3S scene object
* @param {I3SDataProvider.ConstructorOptions} options An object describing initialization options
Expand Down Expand Up @@ -550,6 +543,8 @@ I3SDataProvider.fromUrl = async function (url, options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);

const resource = Resource.createIfNeeded(url);
// Set a query parameter for json to avoid failure on html pages
resource.setQueryParameters({ f: "pjson" }, true);
const data = await I3SDataProvider.loadJson(resource);

const provider = new I3SDataProvider(options);
Expand Down Expand Up @@ -593,14 +588,9 @@ I3SDataProvider._fetchJson = function (resource) {
* @private
*
* @param {Resource} resource The JSON resource to request
* @param {boolean} [trace=false] Log the resource
* @returns {Promise<object>} The fetched data
*/
I3SDataProvider.loadJson = async function (resource, trace) {
if (trace) {
console.log("I3S FETCH:", resource.url);
}

I3SDataProvider.loadJson = async function (resource) {
const data = await I3SDataProvider._fetchJson(resource);
if (defined(data.error)) {
console.error("Failed to fetch I3S ", resource.url);
Expand All @@ -622,11 +612,20 @@ I3SDataProvider.loadJson = async function (resource, trace) {
/**
* @private
*/
I3SDataProvider.prototype._loadBinary = function (resource) {
if (this._traceFetches) {
console.log("I3S FETCH:", resource.url);
I3SDataProvider.prototype._loadBinary = async function (resource) {
const buffer = await resource.fetchArrayBuffer();
if (buffer.byteLength > 0) {
// Check if we have a JSON response with 404
const array = new Uint8Array(buffer);
if (array[0] === "{".charCodeAt(0)) {
const textContent = new TextDecoder();
const str = textContent.decode(buffer);
if (str.includes("404")) {
throw new RuntimeError(`Failed to load binary: ${resource.url}`);
}
}
}
return resource.fetchArrayBuffer();
return buffer;
};

/**
Expand Down Expand Up @@ -837,6 +836,10 @@ I3SDataProvider.prototype.getAttributeNames = function () {
* @returns {string[]} The collection of attribute values
*/
I3SDataProvider.prototype.getAttributeValues = function (name) {
Tamrat-B marked this conversation as resolved.
Show resolved Hide resolved
//>>includeStart('debug', pragmas.debug);
Check.defined("name", name);
//>>includeEnd('debug');

for (let i = 0; i < this._attributeStatistics.length; ++i) {
const values = this._attributeStatistics[i]._getValues(name);
if (defined(values)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/Source/Scene/I3SDecoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ I3SDecoder.decode = async function (
cartographicCenter: cartographicCenter,
cartesianCenter: cartesianCenter,
parentRotation: parentRotation,
enableFeatures: geometryData._dataProvider.enableFeatureFiltering,
enableFeatures: geometryData._dataProvider.showFeatures,
splitGeometryByColorTransparency:
geometryData._dataProvider.adjustMaterialAlphaMode,
symbologyData: symbologyData,
Expand Down
5 changes: 1 addition & 4 deletions packages/engine/Source/Scene/I3SFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ Object.defineProperties(I3SFeature.prototype, {
* @private
*/
I3SFeature.prototype.load = async function () {
this._data = await I3SDataProvider.loadJson(
this._resource,
this._dataProvider._traceFetches
);
this._data = await I3SDataProvider.loadJson(this._resource);
return this._data;
};

Expand Down
Loading
Loading