From 148ecd8ae80ec88fcdea65fc999d55d3e464c554 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Wed, 6 Aug 2025 19:55:47 +0200 Subject: [PATCH 1/3] Allow passing tileset options to reality data --- CHANGES.md | 4 +- packages/engine/Source/Scene/ITwinData.js | 16 ++++++- packages/engine/Specs/Scene/ITwinDataSpec.js | 48 ++++++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 292ddbea1c1..29040d0b2dd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ #### Breaking Changes :mega: - Removed the argument fallback in `ITwinData.*` functions. Please switch to the new options argument signature [#12778](https://github.com/CesiumGS/cesium/issues/12778) +- Allow passing tileset constructor options to the tileset that is created with `ITwinData.createTilesetForRealityDataId` [#12709](https://github.com/CesiumGS/cesium/issues/12709) ## 1.132 - 2025-08-01 @@ -2462,7 +2463,6 @@ _This is an npm-only release to fix a publishing issue_. tileset.boundingSphere.center, ); ``` - - This also fixes several issues with clipping planes not using the correct transform for tilesets with children. ### Additions :tada: @@ -4308,7 +4308,6 @@ _This is an npm-only release to fix a publishing issue_. isStopIncluded : true, data : data }); - - `TimeInterval.fromIso8601` now takes a single options parameter. Code that looked like: TimeInterval.fromIso8601(intervalString, true, true, data); @@ -4321,7 +4320,6 @@ _This is an npm-only release to fix a publishing issue_. isStopIncluded : true, data : data }); - - `interval.intersect(otherInterval)` -> `TimeInterval.intersect(interval, otherInterval)` - `interval.contains(date)` -> `TimeInterval.contains(interval, date)` diff --git a/packages/engine/Source/Scene/ITwinData.js b/packages/engine/Source/Scene/ITwinData.js index dd64827442e..ef49e04bec7 100644 --- a/packages/engine/Source/Scene/ITwinData.js +++ b/packages/engine/Source/Scene/ITwinData.js @@ -90,6 +90,9 @@ ITwinData.createTilesetFromIModelId = async function ({ * If the type or rootDocument are not provided this function * will first request the full metadata for the specified reality data to fill these values. * + * The maximumScreenSpaceError of the resulting tileset will default to 4, + * unless it is explicitly overridden with the given tileset options. + * * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy. * * @param {Object} options @@ -97,6 +100,8 @@ ITwinData.createTilesetFromIModelId = async function ({ * @param {string} options.realityDataId The id of the reality data to load * @param {ITwinPlatform.RealityDataType} [options.type] The type of this reality data * @param {string} [options.rootDocument] The path of the root document for this reality data + * @param {Cesium3DTileset.ConstructorOptions} [options.tilesetOptions] Object containing + * options to pass to the internally created {@link Cesium3DTileset}. * @returns {Promise} * * @throws {RuntimeError} if the type of reality data is not supported by this function @@ -106,6 +111,7 @@ ITwinData.createTilesetForRealityDataId = async function ({ realityDataId, type, rootDocument, + tilesetOptions, }) { //>>includeStart('debug', pragmas.debug); Check.typeOf.string("iTwinId", iTwinId); @@ -144,9 +150,15 @@ ITwinData.createTilesetForRealityDataId = async function ({ rootDocument, ); - return Cesium3DTileset.fromUrl(tilesetAccessUrl, { + // The maximum screen space error was defined to default to 4 for + // reality data tilesets. This will only be overridden if it was + // specified in the tilesetOptions explicitly. + const internalTilesetOptions = { maximumScreenSpaceError: 4, - }); + ...tilesetOptions, + }; + + return Cesium3DTileset.fromUrl(tilesetAccessUrl, internalTilesetOptions); }; /** diff --git a/packages/engine/Specs/Scene/ITwinDataSpec.js b/packages/engine/Specs/Scene/ITwinDataSpec.js index 8f76b8cdd4d..32f01fcfc68 100644 --- a/packages/engine/Specs/Scene/ITwinDataSpec.js +++ b/packages/engine/Specs/Scene/ITwinDataSpec.js @@ -231,6 +231,54 @@ describe("ITwinData", () => { maximumScreenSpaceError: 4, }); }); + + it("creates a tileset with the given tilesetOptions", async () => { + const tilesetUrl = + "https://example.com/root/document/path.json?auth=token"; + getUrlSpy.and.resolveTo(tilesetUrl); + + await ITwinData.createTilesetForRealityDataId({ + iTwinId: "itwin-id-1", + realityDataId: "reality-data-id-1", + type: ITwinPlatform.RealityDataType.Cesium3DTiles, + rootDocument: "root/document/path.json", + tilesetOptions: { + cacheBytes: 500000000, + }, + }); + + // The createTilesetForRealityDataId was defined to use a + // maximum screen space error of 4 by default + expect(tilesetSpy).toHaveBeenCalledOnceWith(tilesetUrl, { + maximumScreenSpaceError: 4, + cacheBytes: 500000000, + }); + }); + + it("creates a tileset with tilesetOptions overriding the defaults", async () => { + const tilesetUrl = + "https://example.com/root/document/path.json?auth=token"; + getUrlSpy.and.resolveTo(tilesetUrl); + + await ITwinData.createTilesetForRealityDataId({ + iTwinId: "itwin-id-1", + realityDataId: "reality-data-id-1", + type: ITwinPlatform.RealityDataType.Cesium3DTiles, + rootDocument: "root/document/path.json", + tilesetOptions: { + maximumScreenSpaceError: 32, + cacheBytes: 500000000, + }, + }); + + // The createTilesetForRealityDataId was defined to use a + // maximum screen space error of 4 by default, which should + // be overridden with the value from the given options + expect(tilesetSpy).toHaveBeenCalledOnceWith(tilesetUrl, { + maximumScreenSpaceError: 32, + cacheBytes: 500000000, + }); + }); }); describe("createDataSourceForRealityDataId", () => { From c68ea03d58de47d9ab182e8f917fe0e207cd659c Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Wed, 6 Aug 2025 20:10:38 +0200 Subject: [PATCH 2/3] Formatting --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 29040d0b2dd..2409a0977b3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2463,6 +2463,7 @@ _This is an npm-only release to fix a publishing issue_. tileset.boundingSphere.center, ); ``` + - This also fixes several issues with clipping planes not using the correct transform for tilesets with children. ### Additions :tada: @@ -4308,6 +4309,7 @@ _This is an npm-only release to fix a publishing issue_. isStopIncluded : true, data : data }); + - `TimeInterval.fromIso8601` now takes a single options parameter. Code that looked like: TimeInterval.fromIso8601(intervalString, true, true, data); @@ -4320,6 +4322,7 @@ _This is an npm-only release to fix a publishing issue_. isStopIncluded : true, data : data }); + - `interval.intersect(otherInterval)` -> `TimeInterval.intersect(interval, otherInterval)` - `interval.contains(date)` -> `TimeInterval.contains(interval, date)` From 95bb442e5ca8e04e6ad8cb195c92be497ac7c7c6 Mon Sep 17 00:00:00 2001 From: Marco Hutter Date: Fri, 8 Aug 2025 19:55:54 +0200 Subject: [PATCH 3/3] Minor clarification in comment --- packages/engine/Source/Scene/ITwinData.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/engine/Source/Scene/ITwinData.js b/packages/engine/Source/Scene/ITwinData.js index ef49e04bec7..ddb2338dcab 100644 --- a/packages/engine/Source/Scene/ITwinData.js +++ b/packages/engine/Source/Scene/ITwinData.js @@ -151,8 +151,9 @@ ITwinData.createTilesetForRealityDataId = async function ({ ); // The maximum screen space error was defined to default to 4 for - // reality data tilesets. This will only be overridden if it was - // specified in the tilesetOptions explicitly. + // reality data tilesets, because they did not show the expected + // amount of detail with the default value of 16. Values that are + // given in the tilesetOptions should still override that default. const internalTilesetOptions = { maximumScreenSpaceError: 4, ...tilesetOptions,