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:
特征是否包含此属性。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.