@@ -31,7 +31,6 @@ export default class M3DLayer extends BaseLayer {
3131 * @param {Boolean } [options.loaded = function] 回调函数
3232 * @param {DefaultProxy } [options.proxy = defaultProxy] 代理
3333 * @returns m3d层对象
34- * @see {@link }
3534 * @example
3635 * function callBackfunction(layer){
3736 * console.log(layer)
@@ -119,6 +118,7 @@ export default class M3DLayer extends BaseLayer {
119118 if ( ! Cesium . defined ( url ) ) {
120119 return new Cesium . DeveloperError ( '必须指定url' ) ;
121120 }
121+ options = Cesium . defaultValue ( options , { } ) ;
122122 let synchronous = true ;
123123 let baseUrl = url ;
124124 let resource ;
@@ -157,6 +157,7 @@ export default class M3DLayer extends BaseLayer {
157157 options
158158 ) ;
159159 docLayers . push ( m3d ) ;
160+ m3d . readyPromise . then ( _callBack ) ;
160161 }
161162 }
162163 }
@@ -194,6 +195,64 @@ export default class M3DLayer extends BaseLayer {
194195 return docLayers ;
195196 }
196197
198+ /**
199+ * 添加m3d服务图层(mongodb)
200+ * @param {String } url 服务地址(发布的m3d缓存服务)
201+ * @param {Object } options
202+ * @param {Boolean } [options.autoReset = true]
203+ * @param {Boolean } [options.loaded = function]
204+ * @param {DefaultProxy } 代理
205+ * @example
206+ * let view = { viewer: window.globe.viewer };
207+ let m3d = new M3DLayer(view);
208+ function callBackfunction(layer){
209+ }
210+ m3d.appendM3dLayer('http://localhost:6163/igs/rest/g3d/cache/jg', {
211+ autoReset:false
212+ loaded:callBackfunction
213+ });
214+ */
215+ appendM3dCacheFromMangoDB ( baseUrl , options ) {
216+ options = Cesium . defaultValue ( options , { } ) ;
217+ let proxy ;
218+ let autoReset = true ;
219+ if ( Cesium . defined ( options ) ) {
220+ if ( Cesium . defined ( options . proxy ) ) {
221+ proxy = new Cesium . DefaultProxy ( options . proxy ) ; //不放在defaultValue中 new 会影响性能
222+ }
223+ Cesium . defaultValue ( options . proxy , undefined ) ;
224+ autoReset = Cesium . defaultValue ( options . autoReset , true ) ;
225+ }
226+ var resource = new Cesium . Resource ( {
227+ url : baseUrl + '/GetCacheInfo' ,
228+ proxy : proxy
229+ } ) ;
230+ var layer = [ ] ;
231+ var dataUrlCache = baseUrl + '/GetDataStreams?' ;
232+ //处理版本信息判断是否清除缓存
233+ var m3dLayrCache = new Cesium . MapGISM3DSet ( {
234+ url : dataUrlCache ,
235+ igserver : true
236+ } ) ;
237+ layer = this . viewer . scene . primitives . add ( m3dLayrCache ) ;
238+ resource . fetchJson ( ) . then ( json => {
239+ layer . readyPromise . then ( function ( layer ) {
240+ if ( autoReset ) {
241+ var boundingSphere = layer . boundingSphere ;
242+ that . viewer . camera . viewBoundingSphere ( boundingSphere , new Cesium . HeadingPitchRange ( 0.0 , - 0.5 ,
243+ boundingSphere . radius ) ) ;
244+ that . viewer . camera . lookAtTransform ( Cesium . Matrix4 . IDENTITY ) ;
245+ if ( typeof options . loaded === 'function' ) {
246+ options . loaded ( layer ) ;
247+ }
248+ }
249+
250+ } ) ;
251+ } ) ;
252+
253+ return layer ;
254+ }
255+
197256 /**
198257 * 设置模型层按方向移动
199258 * @param {param } layer m3d图层对象
@@ -205,7 +264,7 @@ export default class M3DLayer extends BaseLayer {
205264 * let dir = new Cesium.Cartesian3(0.0, 1.0, 1.0); 分别表示xyz方向
206265 * m3d.setM3dLayerMovement(tilelayer[0],dir,10.0)
207266 */
208- setM3dLayerMovement ( layer , direction , distance , option ) {
267+ setM3dLayerMovement ( layer , direction , distance , options ) {
209268 if (
210269 undefined === layer ||
211270 undefined === direction ||
0 commit comments