On Tuesday, April 14, 2015 at 3:19:45 PM UTC-4,
ssan...@gmail.com wrote:
> I'm using Cesium to create some animations using simple shapes, mostly ellipsoids. One thing I'd like to be able to do is generate a toroid/doughnut shape using czml. Toroids don't seem to be directly supported so I though I could use the polyline volume feature to achieve the same effect, however this isn't supported in CZML. Does anybody have any suggestions for how to generate and animate toroids?
I tried doing it using entities, based off the sandbox tutorial. With this I can create a polyline volume and have it move around, but I can't figure out how to animate the extruded shape. Does anybody know how to do this?
var viewer = new Cesium.Viewer('cesiumContainer');
viewer.scene.globe.depthTestAgainstTerrain = true;
viewer.scene.globe.enableLighting = true;
function computeCircle(radius) {
var positions = [];
for (var i = 0; i < 360; i=i+30) {
var radians = Cesium.Math.toRadians(i);
positions.push(new Cesium.Cartesian2(radius * Math.cos(radians), radius * Math.sin(radians)));
}
return positions;
}
var start = Cesium.JulianDate.fromDate(new Date(Date.now()));
var stop = Cesium.JulianDate.addSeconds(start, 14400, new Cesium.JulianDate());
var stop2 = Cesium.JulianDate.addSeconds(start, 28000, new Cesium.JulianDate());
var point1 = new Cesium.SampledPositionProperty();
point1.addSample(start, Cesium.Cartesian3.fromDegrees(-85, 32, 1000));
point1.addSample(stop, Cesium.Cartesian3.fromDegrees(-84, 33, 1000));
point1.addSample(stop2, Cesium.Cartesian3.fromDegrees(-83, 32, 1000));
var point2 = new Cesium.SampledPositionProperty();
point2.addSample(start, Cesium.Cartesian3.fromDegrees(-85, 36, 5000));
point2.addSample(stop, Cesium.Cartesian3.fromDegrees(-84, 35, 4000));
point2.addSample(stop2, Cesium.Cartesian3.fromDegrees(-83, 34, 2000));
var point3 = new Cesium.SampledPositionProperty();
point3.addSample(start, Cesium.Cartesian3.fromDegrees(-89, 36, 10000));
point3.addSample(stop, Cesium.Cartesian3.fromDegrees(-88, 37, 10000));
point3.addSample(stop2, Cesium.Cartesian3.fromDegrees(-87, 36, 8000));
var shape1 = new Cesium.SampledProperty(Cesium.Cartesian2);
shape1.addSample(start, computeCircle(60000) );
shape1.addSample(stop, computeCircle(6000) );
shape1.addSample(stop2, computeCircle(600) );
var entity = viewer.entities.add({
polylineVolume : {
positions : new Cesium.PositionPropertyArray([point1, point2, point3]),
shape : computeCircle(60000)
//material : Cesium.Color.RED
}
});
//entity.polylineVolume.shape = shape1;
//entity.polylineVolume.shape = new Cesium.ShapeProperty(shape1);
var color = new Cesium.SampledProperty(Cesium.Color);
color.addSample(start, Cesium.Color.RED);
color.addSample(stop2, Cesium.Color.GREEN);
entity.polylineVolume.material = new Cesium.ColorMaterialProperty(color);
viewer.zoomTo(entity);
viewer.clock.multiplier = 1;