add a 3D building model with certain coordinate on the Cesium

Hello,

I have two problems:

1- I want to add a 3d building to cesium without define the coordinate to cesium but i don't know how to do it. and i want to display description the model(building information) by click on it, I can to display the model by this code:

var scene = viewer.scene;
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
    Cesium.Cartesian3.fromDegrees(51.319385, 35.768353, 0.0));
var model = scene.primitives.add(Cesium.Model.fromGltf({
    url : '../../SampleData/models/CesiumGround/Institute-obj2.glb',
    modelMatrix : modelMatrix,
    scale : 0.5
}));

But i want to display the model with default coordinate it.I don't want to use this code line:" Cesium.Cartesian3.fromDegrees(51.319385, 35.768353, 0.0));"

2 my problem: I want to automatic zoom in on the model and i use this code:"viewer.zoomTo(model);"

but don't zoom on the model in home page of Cesium. how to zoom in on the model?

Please help me.

Sabah,

Hello Sabah,

I’m not sure what you mean by a default coordinate. Can you elaborate?

Right now you’re adding the model using the Primitive API. I would recommend switching to the Entity API, it will make positioning and zooming to your model easier. viewer.zoomTo only works with entities.

You can see an example for how to do this here: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=3D%20Models.html&label=Showcases

Best,

Hannah