Skip to content

Commit 802d8fe

Browse files
authored
Merge pull request #12801 from CesiumGS/allow-reality-data-tileset-options
Allow passing tileset options to reality data
2 parents bff7b18 + 95bb442 commit 802d8fe

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#### Breaking Changes :mega:
88

99
- Removed the argument fallback in `ITwinData.*` functions. Please switch to the new options argument signature [#12778](https://github.com/CesiumGS/cesium/issues/12778)
10+
- Allow passing tileset constructor options to the tileset that is created with `ITwinData.createTilesetForRealityDataId` [#12709](https://github.com/CesiumGS/cesium/issues/12709)
1011

1112
#### Fixes :wrench:
1213

packages/engine/Source/Scene/ITwinData.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,18 @@ ITwinData.createTilesetFromIModelId = async function ({
9090
* If the <code>type</code> or <code>rootDocument</code> are not provided this function
9191
* will first request the full metadata for the specified reality data to fill these values.
9292
*
93+
* The <code>maximumScreenSpaceError</code> of the resulting tileset will default to 4,
94+
* unless it is explicitly overridden with the given tileset options.
95+
*
9396
* @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
9497
*
9598
* @param {Object} options
9699
* @param {string} options.iTwinId The id of the iTwin to load data from
97100
* @param {string} options.realityDataId The id of the reality data to load
98101
* @param {ITwinPlatform.RealityDataType} [options.type] The type of this reality data
99102
* @param {string} [options.rootDocument] The path of the root document for this reality data
103+
* @param {Cesium3DTileset.ConstructorOptions} [options.tilesetOptions] Object containing
104+
* options to pass to the internally created {@link Cesium3DTileset}.
100105
* @returns {Promise<Cesium3DTileset>}
101106
*
102107
* @throws {RuntimeError} if the type of reality data is not supported by this function
@@ -106,6 +111,7 @@ ITwinData.createTilesetForRealityDataId = async function ({
106111
realityDataId,
107112
type,
108113
rootDocument,
114+
tilesetOptions,
109115
}) {
110116
//>>includeStart('debug', pragmas.debug);
111117
Check.typeOf.string("iTwinId", iTwinId);
@@ -144,9 +150,16 @@ ITwinData.createTilesetForRealityDataId = async function ({
144150
rootDocument,
145151
);
146152

147-
return Cesium3DTileset.fromUrl(tilesetAccessUrl, {
153+
// The maximum screen space error was defined to default to 4 for
154+
// reality data tilesets, because they did not show the expected
155+
// amount of detail with the default value of 16. Values that are
156+
// given in the tilesetOptions should still override that default.
157+
const internalTilesetOptions = {
148158
maximumScreenSpaceError: 4,
149-
});
159+
...tilesetOptions,
160+
};
161+
162+
return Cesium3DTileset.fromUrl(tilesetAccessUrl, internalTilesetOptions);
150163
};
151164

152165
/**

packages/engine/Specs/Scene/ITwinDataSpec.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,54 @@ describe("ITwinData", () => {
231231
maximumScreenSpaceError: 4,
232232
});
233233
});
234+
235+
it("creates a tileset with the given tilesetOptions", async () => {
236+
const tilesetUrl =
237+
"https://example.com/root/document/path.json?auth=token";
238+
getUrlSpy.and.resolveTo(tilesetUrl);
239+
240+
await ITwinData.createTilesetForRealityDataId({
241+
iTwinId: "itwin-id-1",
242+
realityDataId: "reality-data-id-1",
243+
type: ITwinPlatform.RealityDataType.Cesium3DTiles,
244+
rootDocument: "root/document/path.json",
245+
tilesetOptions: {
246+
cacheBytes: 500000000,
247+
},
248+
});
249+
250+
// The createTilesetForRealityDataId was defined to use a
251+
// maximum screen space error of 4 by default
252+
expect(tilesetSpy).toHaveBeenCalledOnceWith(tilesetUrl, {
253+
maximumScreenSpaceError: 4,
254+
cacheBytes: 500000000,
255+
});
256+
});
257+
258+
it("creates a tileset with tilesetOptions overriding the defaults", async () => {
259+
const tilesetUrl =
260+
"https://example.com/root/document/path.json?auth=token";
261+
getUrlSpy.and.resolveTo(tilesetUrl);
262+
263+
await ITwinData.createTilesetForRealityDataId({
264+
iTwinId: "itwin-id-1",
265+
realityDataId: "reality-data-id-1",
266+
type: ITwinPlatform.RealityDataType.Cesium3DTiles,
267+
rootDocument: "root/document/path.json",
268+
tilesetOptions: {
269+
maximumScreenSpaceError: 32,
270+
cacheBytes: 500000000,
271+
},
272+
});
273+
274+
// The createTilesetForRealityDataId was defined to use a
275+
// maximum screen space error of 4 by default, which should
276+
// be overridden with the value from the given options
277+
expect(tilesetSpy).toHaveBeenCalledOnceWith(tilesetUrl, {
278+
maximumScreenSpaceError: 32,
279+
cacheBytes: 500000000,
280+
});
281+
});
234282
});
235283

236284
describe("createDataSourceForRealityDataId", () => {

0 commit comments

Comments
 (0)