开源GIS相关

从3DTileset 对象获取Cesium3DTileFeatu

2020-09-09  本文已影响0人  panergongzi

我们加载一个3DTileset 到地图里面了,怎样获取这个3DTileset 对象的feature列表呢。比如获取某个房屋的构件窗子

1,通过点击事件获取

viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(

        movement

      ) {

        var pickedFeature= viewer.scene.pick(movement.position);

},

      Cesium.ScreenSpaceEventType.LEFT_CLICK);

2,通过对3DTileset 对象添加j监听和回调函数获取

function processContentFeatures(content, callback) {

  var featuresLength = content.featuresLength;

  for (var i = 0; i < featuresLength; ++i) {

    var feature = content.getFeature(i);

    callback(feature);

  }

}

function processTileFeatures(tile, callback) {

  var content = tile.content;

  var innerContents = content.innerContents;

  if (Cesium.defined(innerContents)) {

    var length = innerContents.length;

    for (var i = 0; i < length; ++i) {

      processContentFeatures(innerContents[i], callback);

    }

  } else {

    processContentFeatures(content, callback);

  }

}

tileset.tileLoad.addEventListener(function (tile) {

  processTileFeatures(tile, loadFeature);

});

tileset.tileUnload.addEventListener(function (tile) {

  processTileFeatures(tile, unloadFeature);

});

获取过程大致 Cesium3DTileset --------->  Cesium3DTile  -----------> Batched3DModel3DTileContent  --------->  Cesium3DTileFeature 

3,从Cesium3DTileFeature里获取Cesium3DTileset 

pickedFeature.tileset

上一篇 下一篇

猜你喜欢

热点阅读