Hello,
I’m trying to create 3D polygon on cesium globe with providing list of long, lat, and alt. But some how its not accepting altitude. It always stick to ground. If I put extrudedHeight in viewer.entities code it will just create 3d 3ffect. I wanted to take height according to the alt which I’m providing in list of long, lat, alt.
Here is the code:
let arreNew = ;
// Check if positions is an array and has a length that's a multiple of 3
if (Array.isArray(positions) && positions.length % 3 === 0) {
for (let i = 0; i < positions.length; i += 3) {
let lon = positions[i];
let lat = positions[i + 1];
let alt = positions[i + 2];
if (typeof lon === 'number' && typeof lat === 'number' && typeof alt === 'number') {
arreNew.push(Cesium.Cartesian3.fromDegrees(lon, lat, alt));
} else {
console.error('Invalid coordinate values:', lon, lat, alt);
}
}
} else {
console.error('Positions array is not valid:', positions);
}
// Log the resulting arreNew array to debug
console.log('arreNew:', arreNew);
// Create entity in Cesium
return this.viewer.entities.add({
id: entityDataID,
name: entityName,
description: '', // Replace with actual description if available
polygon: {
hierarchy: new Cesium.PolygonHierarchy(arreNew),
material: Cesium.Color.RED.withAlpha(0.5),
outline: true,
outlineColor: Cesium.Color.RED.withAlpha(0.5),
extrudedHeight: 20000, // Adjust this value to create the 3D effect
heightReference: Cesium.HeightReference.NONE,
outlineWidth: width,
fill: fill === '1',
}
});
Here is the attachment when I remove extrudedHeight
NOTE: I want to use the list of altitude which I’m providing in the list of long lat and alt.
I’ don’t want to use static height like extrudedHeight
Please guide me.