使用了铯1.37。
我用下面的代码将两组3D-Tiles添加到场景中:
viewer.scene.primitives.add(new Cesium.Cesium3DTileset({url : 'data/3DTiles/example_1'}));
viewer.scene.primitives.add(new Cesium.Cesium3DTileset({url : 'data/3DTiles/example_2'}));这工作如预期,3D-Tiles被正确地显示。
现在我实现了"3D Tiles Feature Picking“Sandcastle示例中的代码(/Apps/Sandcastle/gallery/3D Tiles Feature Picking.html),启用基于鼠标事件的功能高亮显示。这也像预期的那样工作。
我的问题:我想禁用第二个3D-Tiles集合的拾取事件。
在In文档中,我看到了一个构造函数选项"allowPicking“。遗憾的是,这似乎只是Primitive对象的一个属性,而不是Cesium3DTileset。
我错过了什么吗?
发布于 2020-03-10 17:53:28
我使用了两个嵌套的3D平铺,其中一个是透明可视化的。我也注意到了这个问题,但找不到任何直接的解决方案。我使用cesiumjs中的drillPick函数从拾取的位置获取所有tileset候选特征,然后使用请求的tileset过滤特征。
var scene = viewer.scene;
if (!scene.pickPositionSupported) {
console.log('This browser does not support pickPosition.');
}
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
handler.setInputAction(function (result) {
var pickedObjects = viewer.scene.drillPick(result.position);
if (pickedObjects.length >= 1) {
for (var j = 0; j < pickedObjects.length; j++) {
//Code below removes picked features from array which are not belongs to tileset1.
if (pickedObjects[j].tileset !== tileset1) {
pickedObjects.splice(j, 1);
}
}
var feature = pickedObjects[0];
if (feature instanceof Cesium.Cesium3DTileFeature) {
var propertyNames = feature.getPropertyNames();
var length = propertyNames.length;
for (var i = 0; i < length; ++i) {
var propertyName = propertyNames[i];
console.log(propertyName + ': ' + feature.getProperty(propertyName));
}
}
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK); https://stackoverflow.com/questions/46095958
复制相似问题