The new 1.23 release of Cesium is fantastic! We've been looking forward to clamp to ground for entities for a long time!
I do have a question though, is there an easy way to draw a line between two entities that are clamped to ground? How do you get the calculated height?
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.terrainProvider = new Cesium.CesiumTerrainProvider({
url : 'https://assets.agi.com/stk-terrain/world'
});
var ellipsoid = viewer.scene.globe.ellipsoid;
var positions = Cesium.Cartesian3.fromDegreesArray([
-115, 35,
-114, 36
]);
var flatPositions = Cesium.PolylinePipeline.generateArc({
positions: positions,
granularity: 0.000001
});
var cartographicArray = [];
for (var i = 0; i < flatPositions.length; i+=3) {
var cartesian = Cesium.Cartesian3.unpack(flatPositions, i);
cartographicArray.push(ellipsoid.cartesianToCartographic(cartesian));
}
Cesium.sampleTerrain(viewer.terrainProvider, 15, cartographicArray)
.then(function(raisedPositionsCartograhpic) {
var raisedPositions = ellipsoid.cartographicArrayToCartesianArray(raisedPositionsCartograhpic);
//console.log(raisedPositions)
viewer.entities.add({
polyline : {
positions : raisedPositions,
width : 5,
material : Cesium.Color.RED
}
});
viewer.zoomTo(viewer.entities);
});Unfortunately our lines are between entities that are temporally relative (use SampledPositionProperty as their position). We used a callback property to set either end of the line to the position of a different entity so they join them as they move. This works great until clamp to ground is enabled, and using sampleTerrain every frame for each line isn't feasible.
We don't need the lines to be on the terrain themselves, we just need to be able to set the position on both ends to take into account the entity's clamped to ground height. I imagine this may not be a variable on the entity though, and is instead stored in GPU memory?
Or is the only option what you said in regards to running Cesium.sampleTerrain every frame at both ends for each polyline?
Cesium newbie here. I see this thread is almost two years old now; I was wondering if there had been any improvements to clamping polylines? I'm trying to find the right solution for showing a hiking trail on 3D terrain. The GPS data I have does have has elevation data, but sometimes they are a bit off from the terrain provider and as such they don't appear clamped to the ground when you zoom in (they might sorta float) or use the camera to look at them at an angle. On a related polyline note, when a hiking trail wraps around a mountain and that mountain is between the camera and trail, I'd expect the terrain to block my view of the trail. Unfortunately, that doesn't seem to happen; is there a property perhaps to control that?
--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/f8twTLgPNu8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.