Create a toroid using CZML

212 views
Skip to first unread message

ssan...@gmail.com

unread,
Apr 14, 2015, 3:19:45 PM4/14/15
to cesiu...@googlegroups.com
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?

Matthew Amato

unread,
Apr 15, 2015, 11:08:34 AM4/15/15
to cesiu...@googlegroups.com
I honestly thought we had polylineVolume available in CZML, but it looks like you're right, we don't. I wrote up an issue to add it: https://github.com/AnalyticalGraphicsInc/cesium/issues/2636 Adding support to CZML may actually be pretty easy, if I have a chance to look into it soon, I'll let you know; but no promises.

For now, you could probably get away with specifying polylines in CZML and then converting those lines into polyline volumes after load on the client (before anything gets drawn).  This could get a little tricky depends on your requirements, but I don't see why it wouldn't work.  We do something similar to style GeoJSON in this example (by adding heights to a polygon).  Of course if you need to send down shape information, there's no analog in polyline for it, so you would have to implement a custom CZML property.

Before the end of the year, I'm hoping to do a pass on CZML to make sure we have parity with the Entity API as well as start looking into what "CZML 2" might look like based on everything we've learned in the last few years.


On Tue, Apr 14, 2015 at 3:19 PM, <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?

--
You received this message because you are subscribed to the Google Groups "cesium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steven Sanville

unread,
Apr 16, 2015, 1:16:01 PM4/16/15
to cesiu...@googlegroups.com
If I specify the polylines in CZML, would I be able to have the extruded shape change with time as well as the polyline? The shape would always be a circle, but it's possible for the radius to change with time. 

--
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/eE925_Dz3sg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.

ssan...@gmail.com

unread,
Apr 21, 2015, 8:16:02 AM4/21/15
to cesiu...@googlegroups.com, ssan...@gmail.com
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;


ssan...@gmail.com

unread,
May 7, 2015, 11:56:11 AM5/7/15
to cesiu...@googlegroups.com, ssan...@gmail.com
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?

Sorry to bring this back up, but does anybody have any ideas on how to animate the extruded shape of a polyline volume? I'd appreciate any suggestions.
Reply all
Reply to author
Forward
0 new messages