Displaying 3D models

Thanks! I was hoping to see the two planets, although I think I posted the wrong sandcastle. The sandcastle linked above involved another ellipsoid, although I meant to show the same Mars ellipsoid with the 3d model shown in the sandcastle with the Earth ellipsoid. I tried using the default code from the complete code example to show the model and track it, but that didn’t work. I attempted other methods such as flyto or zoomto to see if I could see it, but I couldn’t. Here is the code I used unsuccessfully:

var ellipsoidMars = new Cesium.Ellipsoid(3396000,3396000,3396000);
var mapProjectionMars = new Cesium.GeographicProjection(ellipsoidMars);
var globeMars = new Cesium.Globe(ellipsoidMars);



globeMars.showGroundAtmosphere = false;

var optsMars = {
    mapProjection: mapProjectionMars,
    globe: globeMars,
    baseLayerPicker: false
};
var viewer = new Cesium.Viewer('cesiumContainer', optsMars);

var imageryLayers = viewer.imageryLayers;
imageryLayers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
    url : 'https://planetarymaps.usgs.gov/cgi-bin/mapserv?map=/maps/mars/mars_simp_cyl.map&service=WMS',
    layers : 'MDIM21_color',
    parameters : {
        transparent : true,
        format : 'image/png'
    },
    tilingScheme: new Cesium.GeographicTilingScheme({ ellipsoid: ellipsoidMars }),
    tileWidth: 512,
    tileHeight: 512
}));
var center = Cesium.Cartesian3.fromDegrees(-95.0, 34.0);


//trying to display this model of one of Mar's moons with default code
var promise = Cesium.IonResource.fromAssetId(519049)
  .then(function (resource) {
    var entity = viewer.entities.add({
      position: Cesium.Cartesian3.fromDegrees(0, 0, 100),
      model: {
        uri: resource,
      },
    });
    viewer.trackedEntity = entity;
  })
  .otherwise(function (error) {
    console.log(error);
  });

Important note: most of the Mars code was adapted from the sandcastle linked in the original post, from this other thread: https://community.cesium.com/t/solar-system-planets/2009

The end goal was very close to as you mentioned, attempting to recreate the Mars system in Cesium. The main reason I was trying to avoid CZML was because as far as I previusly knew, it was only possible to write it with paid services. Thanks for the extra resources! I will look into them.

1 Like