0

I tried using the following code in cesium sandcastle to create a spline from Philadelphia to Los Angeles.

        //catmulrom spline.
        var controlPoints = [
    {point: new Cesium.Cartesian3(1235398.0, -4810983.0, 4146266.0), time: 0.0},
    {point: new Cesium.Cartesian3(1372574.0, -5345182.0, 4606657.0), time: 1.5},
    {point: new Cesium.Cartesian3(-757983.0, -5542796.0, 4514323.0), time: 3.0},
    {point: new Cesium.Cartesian3(-2821260.0, -5248423.0, 4021290.0), time: 4.5},
    {point: new Cesium.Cartesian3(-2539788.0, -4724797.0, 3620093.0), time: 6.0}
];
var spline = new Cesium.CatmullRomSpline(controlPoints);

It is not giving me any error. And the code seems to be fine. But the spline is not being plotted. Could some one resolve this issue. You can try the code in the site below :-

http://cesium.agi.com/Cesium/Apps/Sandcastle/index.html?src=Hello%20World.html

And reference for CatmullRomSpline can be found here :- http://cesium.agi.com/Cesium/Build/Documentation/CatmullRomSpline.html

Thanks alot in advance

P.S its javascript someone please take a look at it and let me know where I am going wrong at.

user2409375
  • 115
  • 1
  • 12

1 Answers1

0

Actually your code should raise an error, because the CatmullRomSpline constructor has 1 mandatory parameter that is a JSON object of the form: {times: Array, points: Array}, whith arrays of the same length.

This being reminded, I had a look at the Cesium ref doc you gave, but actually it does not seem the Spline object is intended to be plotted at all! (Not directly, at least.) The only way to plot something in Cesium, if I am not mistaking, is with the widget.scene.primitives object, and no way to give directly to some of his methods (add, for example) a Spline as parameter.

So I think the only way is to interpolate (paradoxically!) it with a polyline, more precisely than your initial set of points of course, with a script that evaluates (pseudocode: spline.evaluate(0+i*d), i=0..max(times)/d) the curve at regular intervals d.

Good luck!

dgiugg
  • 1,294
  • 14
  • 23