CesiumGS / cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:
https://cesium.com/cesiumjs/
Apache License 2.0
12.86k stars 3.47k forks source link

Scene.sampleHeightMostDetailed does not work correctly when a tileset is not directly added into Scene.primitives #11498

Open 3DGISKing opened 1 year ago

3DGISKing commented 1 year ago

Sandcastle example: here

Browser: Google Chrome Version 116.0.5845.112 (Official Build) (64-bit)

Operating System: Windows 10 Pro 22H2

If I add a tileset like the below, Scene.sampleHeightMostDetailed works

viewer.scene.primitives.add(tileset);

But if I add a tileset like the below, Scene.sampleHeightMostDetailed does not work

const primitiveCollection = new Cesium.PrimitiveCollection();

viewer.scene.primitives.add(primitiveCollection);

primitiveCollection.add(tileset);
ggetz commented 1 year ago

Thanks for the report @3DGISKing. This is a limitation of sampleHeightMostDetailed as it samples height from the rendered tiles.

The approach for this would be to add a function for 3D Tiles which works more like sampleTerrainMostDetailed.

3DGISKing commented 1 year ago

Even if I use the below code, the tileset is normally rendered.

const primitiveCollection = new Cesium.PrimitiveCollection();

viewer.scene.primitives.add(primitiveCollection);

primitiveCollection.add(tileset);