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 Answers 2

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).

3
  • Thank for your reply emackey. Do you have any idea for this? My code for this part is here: Commented Dec 13, 2016 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; Commented Dec 13, 2016 at 12:21
  • You should edit your original question to add this code with proper formatting.
    – emackey
    Commented Dec 13, 2016 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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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