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.75k stars 3.46k forks source link

Add clamping functionality directly in CZML and Entity API #7044

Closed lilleyse closed 7 months ago

lilleyse commented 6 years ago

The Clamp to 3D Tiles demo in https://github.com/AnalyticalGraphicsInc/cesium/pull/6934 manually clamps the entity's position to a tileset based on a scene.clampToHeight call. It would be convenient to offer this functionality from CZML and the entity API.

mramato commented 6 years ago

I imagine the most straightforward way to do this would be to extend the HeighReference enum to cover 3D Tiles (probably always terrain and 3d tiles at the same time)

ggetz commented 1 year ago

Also requested in https://github.com/CesiumGS/cesium/issues/11305.

ryanhlewis commented 1 year ago

Hi from https://github.com/CesiumGS/cesium/issues/11305.

I ended up using a Raycast for everything, which looks like:

    // Get position from lat/lon
    const position = Cesium.Cartesian3.fromDegrees(lng, lat, 10000); // Assume initial altitude of 10,000m

    // Cast a ray from position to the center of the Earth
    const ray = new Cesium.Ray(position, Cesium.Cartesian3.negate(Cesium.Cartesian3.fromDegrees(lng, lat), new Cesium.Cartesian3()));

    // Intersect the ray with the tileset
    const intersection = viewer.scene.pickFromRay(ray, [tileset]);

However, yes, I would love using a direct implementation, and not a hacky workaround.

ggetz commented 12 months ago

From Sean in https://github.com/CesiumGS/cesium/issues/8606:

I'm a little worried that scene.clampToGround won't scale super well. Terrain keeps triangle data in CPU memory, wonder if we need to do the same for 3D Tiles at some point. And then optimize ray/triangle intersection tests.

ddomit commented 6 months ago

Hello! Any news on this implementation? @ggetz

We need to get the altitude of a point from 3dTiles

Thanks!

ggetz commented 6 months ago

We need to get the altitude of a point from 3dTiles

@ddomit Are you looking to clamp a point to the surface of 3D Tiles, or sample the height directly?

ddomit commented 6 months ago

We need to get the altitude of a point from 3dTiles

@ddomit Are you looking to clamp a point to the surface of 3D Tiles, or sample the height directly?

I am looking to do both actually :) @ggetz

ddomit commented 5 months ago

We need to get the altitude of a point from 3dTiles

@ddomit Are you looking to clamp a point to the surface of 3D Tiles, or sample the height directly?

Any new features to implement this?