CZML: Paths that "followSurface"

I'm working on an app that will plot out WWII submarine patrol reports. So far, Cesium's been an absolute pleasure to work with, but I've run into a bit of a problem that I'm hoping someone could give me a hand with.

I've plotted out the routes with a polyline that offers the awesome "followSurface" property. This is really useful, because the patrols go back and forth across the Pacific Ocean, and there is sometimes about a month between points.

I've got a 3D submarine model rendered on the map that I'd like to have following the path. I've got it working almost perfectly, except there doesn't seem to be a followSurface property for the CZML path, causing the model to take a straight line through the center of the ocean (While going underwater is a thing subs tend to do, this isn't ideal for showing the position.)

I can interpolate points myself, but then I have to balance between processing power/bandwidth/Database storage and resolution: 100/1000 intermediate points vs. 2 points... I was hoping there would be a way to make the path an arc instead of a straight line.

Thanks in advance for any help!

What I've got now:

...

var builtInCzml = [{
    "id" : "document",
    "version" : "1.0",
    "clock" : {
      "interval" : "1942-02-03T16:00:00Z/1942-02-03T16:04:00Z",
      "currentTime" : "1942-02-03T16:00:00Z",
      "multiplier" : 1,
      "range" : "LOOP_STOP",
      "step" : "SYSTEM_CLOCK_MULTIPLIER"
    }
}, {
    "id" : "Vehicle",
    "availability" : "1942-02-03T16:00:00Z/1942-02-03T16:04:00Z",
    "model" : {
        "show" : true,
        "gltf" : 'js/cesium/models/sub.glb',
    },

    "label" : {
        "fillColor" : {
            "rgba" : [255, 255, 0, 255]
        },
        "font" : "bold 10pt Segoe UI Semibold",
        "horizontalOrigin" : "LEFT",
        "outlineColor" : {
            "rgba" : [0, 0, 0, 255]
        },
        "pixelOffset" : {
            "cartesian2" : [10.0, 0.0]
        },
        "scale" : 1.0,
        "show" : true,
        "style" : "FILL",
        "text" : "USS Narwhal",
        "verticalOrigin" : "CENTER"
    },
    "position" : {
        "interpolationAlgorithm" : "LAGRANGE",
        "interpolationDegree" : 1,
        "epoch" : "2012-08-04T16:00:00Z",
        "cartesian" : [
          0, -5509722.586460211, -2151844.221882823, -2378299.9406736423,
           18, -5684531.161035097, -2744542.9854255156, -910990.3759759372,
           100, -4396545.545638362, -2437044.991071697, 3912790.1338688354,
           108, -4171451.1216227254, -2304348.5076655983, 4224994.521149366,
           108, -4171451.1216227254, -2304348.5076655983, 4224994.521149366,
           132, -3557603.9416444204, -1978781.4385709134, 4893709.012974627,
           132, -3543403.8974256907, -1933264.1334437176, 4921932.675781873,
           136, -3462736.6795682968, -1899722.395552415, 4991443.492328856,
           140, -3532251.61244064, -1853162.7889278433, 4960349.8138794955,
           154, -3821779.853707643, -2093808.8053225805, 4641837.924190534,
           154, -3821779.853707643, -2093808.8053225805, 4641837.924190534,
           226, -5723826.264925561, -2669064.021283511, -889095.0157719625,
           236, -5669540.596844369, -2304083.4451725963, -1791032.530913303,
           240, -5510109.516997012, -2151995.3391535785, -2377273.4826697796
                ]

    }
}];

var czmlDataSource = new Cesium.CzmlDataSource();
czmlDataSource.load(builtInCzml, 'Sample CZML with 3D model');
viewer.dataSources.add(czmlDataSource);

What you’re looking for is a great arc interpolation algorithm. (see InterpolationAlgorithm interface: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Core/InterpolationAlgorithm.js)

Unfortunately this does not currently exist in Cesium. You could do the subsampling on the client using PolylinePipeline.generateCartesianArc but you would still be increasing memory to store the sampled ephemeris.

Does this capability exist in cesium yet ?

1 Like

@alexvizgard

Does this sandcastle demo showcase what you are looking for?

This sandcastle uses a CZML data source and demonstrates how the path can be clamped to 3D Tiles.

-Sam

1 Like

Nice that looks good. My use case will be a submarine model that would be half submerged or fully submerged. Will the example you provided support this?

1 Like

@alexvizgard

Thank you, and yes! Please keep me in the loop - I would love to see the final result :smiley:

-Sam