Displaying 3D models

I’m pretty new to Cesium. I am unsuccessfully trying to display a gITF model from my Cesium Ion account on a ellipsoid textured as mars. The model I am trying to display is a model of Phobos, one of Mar’s moons. The model properly showed up with the complete code example in cesium sandcastle, but I was unable to get it to show up when I copy pasted the same code onto the sandcastle with Mars. I have a feeling that it may be because the Mars ellipsoid is smaller than the default Earth, although trying to fly or zoom to the object isn’t working.

Complete code example sandcastle:
https://sandcastle.cesium.com/?src=Hello%20World.html&label=Showcases&code=eyJjb2RlIjoiLy8gR3JhbnQgQ2VzaXVtSlMgYWNjZXNzIHRvIHlvdXIgaW9uIGFzc2V0c1xuQ2VzaXVtLklvbi5kZWZhdWx0QWNjZXNzVG9rZW4gPSBcImV5SmhiR2NpT2lKSVV6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpxZEdraU9pSXpNVFkwWlRoa01TMDRNVEF6TFRSaE5HVXRPRGt5TmkwNFpEVXhNVEptT0RWa1pqSWlMQ0pwWkNJNk5EVTBPVElzSW1saGRDSTZNVFl4TlRFM01qRXlNMzAueVY2WjVfT2J0dDdsQU8zWnRjTVAwcXdRNF9iTk92c09wbzh1VzZyWUxRVVwiO1xuXG52YXIgdmlld2VyID0gbmV3IENlc2l1bS5WaWV3ZXIoXCJjZXNpdW1Db250YWluZXJcIik7XG5cbnZhciBwcm9taXNlID0gQ2VzaXVtLklvblJlc291cmNlLmZyb21Bc3NldElkKDUxOTA0OSlcbiAgLnRoZW4oZnVuY3Rpb24gKHJlc291cmNlKSB7XG4gICAgdmFyIGVudGl0eSA9IHZpZXdlci5lbnRpdGllcy5hZGQoe1xuICAgICAgcG9zaXRpb246IENlc2l1bS5DYXJ0ZXNpYW4zLmZyb21EZWdyZWVzKDAsIDAsIDEwMCksXG4gICAgICBtb2RlbDoge1xuICAgICAgICB1cmk6IHJlc291cmNlLFxuICAgICAgfSxcbiAgICB9KTtcbiAgICB2aWV3ZXIudHJhY2tlZEVudGl0eSA9IGVudGl0eTtcbiAgfSlcbiAgLm90aGVyd2lzZShmdW5jdGlvbiAoZXJyb3IpIHtcbiAgICBjb25zb2xlLmxvZyhlcnJvcik7XG4gIH0pO1xuIiwiaHRtbCI6IjxzdHlsZT5cbiAgQGltcG9ydCB1cmwoLi4vdGVtcGxhdGVzL2J1Y2tldC5jc3MpO1xuPC9zdHlsZT5cbjxkaXYgaWQ9XCJjZXNpdW1Db250YWluZXJcIiBjbGFzcz1cImZ1bGxTaXplXCI+PC9kaXY+XG48ZGl2IGlkPVwibG9hZGluZ092ZXJsYXlcIj5cbiAgPGgxPkxvYWRpbmcuLi48L2gxPlxuPC9kaXY+XG48ZGl2IGlkPVwidG9vbGJhclwiPjwvZGl2PlxuIn0=

Mars with example code:
https://sandcastle.cesium.com/#c=lVR/b9owEP0qEX+MVAp2KKNdU+iGaNVVK1s1plWTkCqTHIk3J45sE0YrvvscOykE2KQFKY7vx7vzu2cKIhxgjOaS02hChHSGTgYrZwySLlN0U7vcXu/izPd9b289uZxlhcZISf4g+E8IFeXZIc4t8FiQPKHhNspt1K2BYsbncASgNB9mzDKMbXkFghJ2mDipPO5LGevQlMQQOOX3xgIUuwzcEKGSv1Fw1jt/133re9u1f3beNxRg/L8ZB6QdKf1v1kxCg7ZjEE3eXnPKX9OKag6bAGPOuEDXo6+fxj9Gn9GKqmTE8oS4PurVQBib8kgmfHUr+DKLRirlMk9AgEZbECbhlWueK1mNSY/E0U+DhuBQSp4NMzWCrUAq85xIuCdrEA80/AUisOVm2aZipqCwAtE81Hdjc9uh2Y55pgjNQLS91+622jCKEWtTomza4qGGWQc39ohE0Z016KMUNNLFdso/wnxC8imIgoawH1eRshTMCZx2olQuA4xzRjJQRKw1OxItZSxRzAscxrQzpxkurRruvV6HZqNfwr6eJE3zp3DN9IDzN9IWHT5Opu2KQGZPpotNru8mp92nsBx57c2JICkoG1H1Vj5KkExqJ2RKO5RYgrd1LrjQaiohDS04z+K29W6qKEUZzeJpmECqZ3pU8992QtyX7R0N9v6wNidbTHikkUoCp9893TF+BBonyli1Lk7qOxPq3o0yaqnra6C/SNZDC8HTa4gFgHQ7F33ke07vLfJrwVca0PlUUTDjtnPLSHmcWeu1w1nL9JFzSa26X34Hna5vH89ZBx39fg58y8uxM5rL6ZV9X7a81kCqNYMre7YPerJcqFIrLkJYQaploo+A50t9FRQKpdHxANdJg4gWDo2Gs9ae8mctJ2RESu1ZLBmb0meYta4GWMc30hgnkR7KlwKElk0ZknSv7q0RITTAenuYpThncyJ2EP8A

The end goal is to make the Phobos model, and another Deimos model orbit the Mars ellipsoid. Is it possible to do that without CZML?

@HelloWebWorld

Thank you for the thoughtful forum post and the sandcastle demos. The size of the Mars ellipsoid may very well be the issue. In the second sandcastle demo that you sent, I see two planets floating in space. Is this the desired result? What is your use case/application? What do you envision the end result to look like?

While making a planetary system without CZML is possible, CZML is the best tool for this application. This sandcastle demo showcases how CZML can be used to create a mini solar system.

This guide gives an overview of CZML.

https://cesium.com/presentations/files/CZML_WebGL_Camp_07-03-2012.pdf

It is a great reference for learning more about the capabilities of CZML. Let me know if you have any other questions or concerns.

-Sam

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

Welp… Dumb issue, there was no access token. At least it works now! I still am a bit puzzled about CZML though so this thread is still important.

Sorry about the bother,

1 Like

@HelloWebWorld

No worries! I am glad to hear that the issue is resolved. Let me know if anything else comes up.

-Sam