VoxelCell

new Cesium.VoxelCell(primitive, tileIndex, sampleIndex)

VoxelPrimitive 的一个单元。

提供对与体素原语的一个单元相关的属性的访问。

请勿直接构造此对象。通过使用 Scene#pickVoxel 进行选择访问。

Name Type Description
primitive VoxelPrimitive 包含该单元的体素原语。
tileIndex number 瓦片的索引。
sampleIndex number 瓦片内样本的索引,包含此单元的元数据。
Example:
// On left click, display all the properties for a voxel cell in the console log.
handler.setInputAction(function(movement) {
  const voxelCell = scene.pickVoxel(movement.position);
  if (voxelCell instanceof Cesium.VoxelCell) {
    const propertyIds = voxelCell.getPropertyIds();
    const length = propertyIds.length;
    for (let i = 0; i < length; ++i) {
      const propertyId = propertyIds[i];
      console.log(`{propertyId}: ${voxelCell.getProperty(propertyId)}`);
    }
  }
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Experimental

该功能尚未最终确定,可能会根据 Cesium 的标准弃用政策而发生变化

Members

获取包含该单元的有向包围盒的副本。
Scene#pick 返回的所有对象都有一个 primitive 属性。此属性返回 包含该单元的 VoxelPrimitive。

readonly sampleIndex : number

获取单元的样本索引。

readonly tileIndex : number

获取包含该单元的瓦片的索引。

Methods

getNames()Array.<string>

返回特征的元数据属性名称数组。
Returns:
特征属性的ID。

getProperty(name)*

返回具有给定名称的单元中元数据值的副本。
Name Type Description
name string 属性名称(区分大小写)。
Returns:
属性的值,如果特征没有此属性,则返回 undefined
Example:
// Display all the properties for a voxel cell in the console log.
const names = voxelCell.getNames();
for (let i = 0; i < names.length; ++i) {
  const name = names[i];
  console.log(`{name}: ${voxelCell.getProperty(name)}`);
}

hasProperty(name)boolean

如果特征包含此属性,则返回 true
Name Type Description
name string 属性的名称(区分大小写)。
Returns:
特征是否包含此属性。
需要帮助?获得答案的最快方法是来自社区和团队 Cesium Forum.