If I'm using scene.pick(clicked.position) to access entities loaded via a (currently) single CzmlDataSource, how can I then access the properties of the entity? More precisely, how can I access the positions property if the clicked entity is a polyline? I know that I can update/change the properties, but I want to know what the actual data is instead of returning [object Object] for all of the properties.
Hello,
Here is an example of how to get the positions of the polyline from a pick. This prints out the current positions to the console:
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function(click) {
var pickedObject = viewer.scene.pick(click.position);
if (Cesium.defined(pickedObject) && (pickedObject.id)) {
console.log(pickedObject.id.polyline.positions.getValue(viewer.clock.currentTime));
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
``
To set the positions to a new value, you can do
pickedObjects.id.polyline.positions = Cesium.Cartesain3.fromDegreesArray([lat, lon, lat, lon,…);
``
Best,
Hannah
Thank you, I had forgotten about the getValue() function!
I do have another question, how do I get the id of the picked entity if I have the following?
{
"id":"Polyline_1",
"name":"Polyline 1",
"polyline": {
"width":3,
"material": {
"solidColor": {
"color": {
"rgba": [255,255,255,255]
}
}
},
"positions": {
"cartographicDegrees": [-75, 37,0,-125, 37,0]
}
}
}
You can get this using pickedObject.id.id.
pickedObject.id is the entity, so pickedObject.id.id will be equal to the entity id provided in the CZML
-Hannah