VoxelCell

new Cesium.VoxelCell(primitive, tileIndex, sampleIndex)

来自 VoxelPrimitive 的一个体素单元。

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

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

Name Type Description
primitive VoxelPrimitive 包含该单元的体素图元
tileIndex number 瓦片的索引
sampleIndex number 瓦片内样本的索引,包含此单元的元数据
Example:
// 左键点击时,在控制台日志中显示体素单元的所有属性。
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:
// 在控制台日志中显示体素单元的所有属性。
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.