3

I created an Openlayers3 Bing map and then I converted to 3D view with Cesium. Is there a way to add a 3D Model on my 3D map?

2

Yes, Cesium has support for 3D models. It uses the glTF file format to describe the models.

At its simplest, the code looks like this:

var viewer = new Cesium.Viewer('cesiumContainer');

var entity = viewer.entities.add({
    name : 'Test model',
    position : position,
    orientation : orientation,
    model : {
        uri : 'server/path/to/model.gltf'
    }
});

(Disclaimer, I'm a Cesium and glTF contributor, but I don't know much about the OL3 integration. There may be some other recommended way to add the model via OL3, but ultimately it will need to reach the Cesium layer and execute code like I've shown here).

  • Thank for your reply emackey. Do you have any idea for this? My code for this part is here: – Apostolis Marios Trampas Dec 13 '16 at 12:20
  • var map3d = new olcs.OLCesium({map: map}); var scene = map3d.getCesiumScene(); var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( Cesium.Cartesian3.fromDegrees(24.823608, 35.234403, 200.0)); var model = scene.primitives.add(Cesium.Model.fromGltf({ url: 'Cesium_Man.gltf', modelMatrix: modelMatrix })); var terrainProvider = new Cesium.CesiumTerrainProvider({ url: '//assets.agi.com/stk-terrain/world', }); scene.terrainProvider = terrainProvider; – Apostolis Marios Trampas Dec 13 '16 at 12:21
  • You should edit your original question to add this code with proper formatting. – emackey Dec 13 '16 at 14:16
2
var map3d = new olcs.OLCesium({map: map});
var scene = map3d.getCesiumScene();
var modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame(
        Cesium.Cartesian3.fromDegrees(24.823608, 35.234403, 200.0));
var model = scene.primitives.add(Cesium.Model.fromGltf({
    url: 'Cesium_Man.gltf',
    modelMatrix: modelMatrix
}));
var terrainProvider = new Cesium.CesiumTerrainProvider({
    url: '//assets.agi.com/stk-terrain/world',
});
scene.terrainProvider = terrainProvider;
scene.globe.depthTestAgainstTerrain = true;
map3d.setEnabled(true);

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.