We’re loading our terrain via a Cesium3DTileset via: var tileset = new Cesium.Cesium3DTileset({ url: “…/Scene/Production_1.json” });
ref: Cesium3DTileset - Cesium Documentation
But it doesn’t do collision on that Tileset. For example, if we place a unit using a czml file and use a heightReference of CLAMP_TO_GROUND, it won’t clamp to the ground because the data has no ‘ground’.
#1 - Can we load a Cesium3DTileset that has collision data, so that we can use things like CLAMP_TO_GROUND and other capabilities similar to that?
or
#2 - Can we convert a Cesium3DTileset to a TerrainProvider so that it can be treated as terrain and do collision correctly?
ref: TerrainProvider - Cesium Documentation
or
Some other method to get a user supplied dataset loaded into the Cesium viewer and have it handle collision correctly?
Hi @Edwin_Sookiassian, thanks for posting and welcome to the Cesium community!
For some context, using 3D Tiles as the terrain for your scene is fairly new to the CesiumJS library. And therefor is not as fully featured or robust as TerrainProviders. That being said, we still think this is the general direction we would like to see things move.
Our clamp to ground option for 3D Tiles is not as optimized as the one for TerrainProviders, so it is not enabled by default. Use the enableCollison
option in order to turn this on.
// Turn on camera collisions with the tileset.
try {
const tileset = await Cesium.Cesium3DTileset.fromUrl(
"http://localhost:8002/tilesets/Seattle/tileset.json",
{ enableCollision: true }
);
scene.primitives.add(tileset);
} catch (error) {
console.error(`Error creating tileset: ${error}`);
}
https://cesium.com/learn/cesiumjs/ref-doc/Cesium3DTileset.html
Hopefully that works for you. If you have any questions please let us know and we can follow up if we need to take an alternative approach.
Hi @Luke_McKinstry! Thank you for the welcome and reply!
I have enabled the collision as you suggested but it still doesn’t seem to be working with the CLAMP_TO_GROUND entities. To be clear, the expectation is that a CZML entity that has heightReference: CLAMP_TO_GROUND will snap to the 3DTileset.
I have tried overwriting the height of the entity as it moves along its path by using getHeight on the 3DTileset, but I haven’t managed to smoothly adjust the height while allowing for the entity to continue on its path horizontally
Do you have any thoughts/suggestions on how to proceed?
Hi @Edwin_Sookiassian ,
Have you tried consulting this sandcastle example, which features a Cesium3DTileset with enableCollision: true
and a CZML model using CLAMP_TO_GROUND (and other options you can toggle)? Cesium Sandcastle
You can also share a sandcastle example of your use case for us to look at and try to help with.