var tileset = this.viewer.scene.primitives.add(new window.Cesium.Cesium3DTileset({ url: 'http://localhost:3000/tileset.json', })); // this.$http.get('http://localhost:3000/tileset.json').then(function(res){ // console.log(res.body); // },function(){ // console.log('请求失败处理'); // }); let viewer=this.viewer; let Cesium=window.Cesium; //监听模型加载事件,完成之后,执行镜头跳转函数.
//其中viewBoundingSphere(第一个参数为模型的球体边界,第二个参数是偏离距离)
//模型的回调函数回调模型本身,而模型有个属性即为球体边界,直接传入即可
tileset.readyPromise.then(function (tileset) { viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(-0.1, -0.2, tileset.boundingSphere.radius)); });