Cesium 加载 gltf 模型

var viewer = new Cesium.Viewer('cesiumContainer', {
    /*帮助*/
    navigationHelpButton: true,
    baseLayerPicker: true,
    geocoder: false,
    /*时间条*/
    timeline: false,
    infoBox: false,
    /*关闭时间动画*/
    animation: false,
    selectionIndicator: false,
    clockViewModel: null,
    imageryProviderViewModels: null,
    dataSources: null
    /*creditContainer:'credit'*/
});
var scene = viewer.scene;
var model = scene.primitives.add(Cesium.Model.fromGltf({
    url: '/files/101.gltf',
    modelMatrix: modelMatrix,
    scale: 1.0
}));
viewer.camera.flyTo({
    destination: Cesium.Cartesian3.fromDegrees(-75.62898254394531, 40.02804946899414, 2.0)
});
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (click) {
    var pick = viewer.scene.pick(click.position);
    if (!pick ) {
        return;
    }
    if (pick.id === undefined) {
        return;
    }
    //选中某模型   pick选中的对象
    if (Cesium.defined(pick)) {
     
    }
}, Cesium.ScreenSpaceEventType.LEFT_DOWN);

 

你可能感兴趣的:(Cesium 加载 gltf 模型)