VoxelCell

new Cesium.VoxelCell(primitive, tileIndex, sampleIndex)

来自 VoxelPrimitive 的一个单元。

提供对体素图元中某个单元相关属性的访问。

不要直接构造此对象。请通过拾取使用 Scene#pickVoxel 来访问它。

Name Type Description
primitive VoxelPrimitive 包含该单元的体素图元
tileIndex number 瓦片的索引
sampleIndex number 瓦片内样本的索引,包含此单元的 metadata
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

This feature is not final and is subject to change without Cesium's standard deprecation policy.

Members

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

readonly sampleIndex : number

获取该单元的采样索引。

readonly tileIndex : number

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

Methods

getNames()Array.<string>

返回该要素(feature)的 metadata 属性名称数组。
Returns:
该要素的属性 ID。

getProperty(name)*

返回该单元中指定名称的 metadata 值的副本。
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 论坛 上向社区和团队提问。