Loading and managing models in cesium

Loaded models as advertised and it worked fine. Loaded the example dae/glb models and a few I created on blender and Cinema 4D. Going to try Maya over the next few days. A few questions to refine what i’m doing.

  1. There appear to be two different approaches. One seen in the sandbox and other in the tutorial and api docs.

var entity = cesiumViewer.entities.add({

name : hRef,

position : position,

orientation : orientation,

model : {

uri : hRef,

minimumPixelSize : 128,

maximumScale : 20000

}

});

// –

var origin = Cesium.Cartesian3.fromDegrees(-95.0 + ranLat, 40.0 + ranLat, 100.0);

var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(origin);

var model = cesiumViewer.scene.primitives.add(Cesium.Model.fromGltf({

url : hRef,

show : true, // default

modelMatrix : modelMatrix,

scale : 2.0, // double size

minimumPixelSize : 128, // never smaller than 128 pixels

maximumScale : 20000, // never larger than 20000 * model size (overrides minimumPixelSize)

allowPicking : false, // not pickable

debugShowBoundingVolume : false, // default

debugWireframe : false

}));

// –

The sandbox loads the model and animates, the second from the tutorial doesn’t. The first loads as entities the second as primitives to the scene. The second approach isn’t piackable whereas the first is. I suspect I have to add additional code to pick the second given it’s not an entity. Not clear what the fundamental differences in the two approaches is and if one is more appropriate than the other. I need the promise callback for a variety of reasons so at first blush method 2 is cleaner.

  1. I was a bit surprised models don’t load as another data source. Was there a fundamental architecture reason for this? Having to manage data sources and models separately is doable but seems unwarranted.

  2. Has anyone looked at an underlying animation engine to manage scripting and moving models? If so what?

v/r

K

Forgot one question - both approaches load glB yet the documentation of Model and ModelGraphics explicitly refer to glTF. Is there a major difference here?

Hello,

glB is just a compessed form of glTF, and Cesium can render both.

For your initial post: the first method you posted is using the Entity API. This is a higher level API that has a lot of extra functionality built in to handle things like dynamic data and positioning your primitives. It does something similar to what you posted in the second example behind the scenes. That is using the lower level primitive API. We generally recommend users use the Entity approach, since it has a lot of complex functionality baked in.

For example, you can look at this example for how to move a model by interpolating between different positions: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Interpolation.html&label=All

Let me know if you have any further questions!

-Hannah

Thank you Hannah.

Using the first approach as an entity is there a promise I can count on to trigger when the entity model is loaded and ready?

No, the promise isn’t accessible. Since the underlying model could change and go between an ready and not ready status, we didn’t think having a promise at the entity level made sense.

-Hannah