py3dtiles.tileset.content package

class py3dtiles.tileset.content.B3dm(header: B3dmHeader, body: B3dmBody)[source]

Bases: TileContent

static from_array(array: ndarray[Any, dtype[uint8]]) B3dm[source]
static from_gltf(gltf: GLTF2, batch_table: BatchTable | None = None, feature_table: B3dmFeatureTable | None = None) B3dm[source]
static from_numpy_arrays(points: ndarray[Any, dtype[float32]], triangles: ndarray[Any, dtype[uint8]] | None = None, batch_table: BatchTable | None = None, feature_table: B3dmFeatureTable | None = None, normal: ndarray[Any, dtype[float32]] | None = None, uvs: ndarray[Any, dtype[float32]] | None = None, batchids: ndarray[Any, dtype[uint32]] | None = None, transform: ndarray[Any, dtype[float32]] | None = None, texture_uri: str | None = None, material: Material | None = None) B3dm[source]

Creates a B3DM body from numpy arrays.

Parameters:
  • points – array of vertex positions, must have a (n, 3) shape.

  • triangles – array of triangle indices, must have a (n, 3) shape.

  • batch_table – a batch table.

  • feature_table – a feature table.

  • normals – array of vertex normals, must have a (n, 3) shape.

  • uvs – array of texture coordinates, must have a (n, 2) shape.

  • batchids – array of batch table IDs, must have a (n) shape.

  • texture_uri – the URI of the texture image if the primitive is textured.

  • material – a glTF material. If not set, a default material is created.

static from_primitives(primitives: list[GltfPrimitive], batch_table: BatchTable | None = None, feature_table: B3dmFeatureTable | None = None, transform: ndarray[Any, dtype[float32]] | None = None) B3dm[source]
sync() None[source]

Allow to synchronize headers with contents.

class py3dtiles.tileset.content.B3dmBody[source]

Bases: TileContentBody

static from_array(b3dm_header: B3dmHeader, array: ndarray[Any, dtype[uint8]]) B3dmBody[source]
static from_gltf(gltf: GLTF2) B3dmBody[source]
static from_primitives(primitives: list[GltfPrimitive], transform: ndarray[Any, dtype[float32]] | None = None) B3dmBody[source]
to_array() ndarray[Any, dtype[uint8]][source]
class py3dtiles.tileset.content.B3dmHeader[source]

Bases: TileContentHeader

BYTE_LENGTH = 28
static from_array(array: ndarray[Any, dtype[uint8]]) B3dmHeader[source]
to_array() ndarray[Any, dtype[uint8]][source]
class py3dtiles.tileset.content.GltfAttribute(name, accessor_type, component_type, array)[source]

Bases: NamedTuple

accessor_type: pygltflib.SCALAR | pygltflib.VEC2 | pygltflib.VEC3

Alias for field number 1

array: npt.NDArray[np.uint8 | np.uint16 | np.uint32 | np.float32]

Alias for field number 3

component_type: pygltflib.UNSIGNED_BYTE | pygltflib.UNSIGNED_INT | pygltflib.FLOAT

Alias for field number 2

name: str

Alias for field number 0

class py3dtiles.tileset.content.GltfPrimitive(points: ndarray[Any, dtype[float32]], triangles: ndarray[Any, dtype[uint8 | uint16 | uint32]] | None = None, normals: ndarray[Any, dtype[float32]] | None = None, uvs: ndarray[Any, dtype[float32]] | None = None, batchids: ndarray[Any, dtype[uint32]] | None = None, additional_attributes: list[GltfAttribute] | None = None, texture_uri: str | None = None, material: Material | None = None)[source]

Bases: object

class py3dtiles.tileset.content.Pnts(header: PntsHeader, body: PntsBody)[source]

Bases: TileContent

static from_array(array: ndarray[Any, dtype[uint8]]) Pnts[source]

Creates a Pnts from an array

static from_features(feature_table_header: PntsFeatureTableHeader, position_array: ndarray[Any, dtype[float32 | uint16]], color_array: ndarray[Any, dtype[uint8 | uint16]] | None = None, normal_position: ndarray[Any, dtype[float32 | uint8]] | None = None) Pnts[source]

Creates a Pnts from features defined by pd_type and cd_type.

static from_file(tile_path: Path) Pnts[source]
static from_points(points: ndarray[Any, dtype[uint8]], include_rgb: bool, include_classification: bool, include_intensity: bool) Pnts[source]

Create a pnts from an uint8 data array containing:

  • points as SemanticPoint.POSITION

  • if include_rgb, rgb as SemanticPoint.RGB

  • if include_classification, classification as a single np.uint8 value that will be put in the batch table

  • if include_intensity, intensity as a single np.uint8 value that will be put in the batch table

Parameters:
  • include_rgb – Whether the points array contains rgb values

  • include_classification – Whether the point array contains classification values

  • include_intensity – whether the point array contains intensity values

  • points – the points array. Contains at least 3

sync() None[source]

Synchronizes headers with the Pnts body.

class py3dtiles.tileset.content.PntsBody[source]

Bases: TileContentBody

static from_array(header: PntsHeader, array: ndarray[Any, dtype[uint8]]) PntsBody[source]

Creates a PntsBody from an array and the header

get_points(transform: ndarray[Any, dtype[float64]] | None) tuple[ndarray[Any, dtype[float32]], ndarray[Any, dtype[uint8 | uint16]] | None][source]
to_array() ndarray[Any, dtype[uint8]][source]

Returns the body as a numpy array.

class py3dtiles.tileset.content.PntsHeader[source]

Bases: TileContentHeader

BYTE_LENGTH = 28
static from_array(array: ndarray[Any, dtype[uint8]]) PntsHeader[source]

Create a PntsHeader from an array

to_array() ndarray[Any, dtype[uint8]][source]

Returns the header as a numpy array.

class py3dtiles.tileset.content.TileContent[source]

Bases: ABC

body: TileContentBody
abstract static from_array(array: ndarray[Any, dtype[uint8]]) TileContent[source]
header: TileContentHeader
save_as(path: Path) None[source]
abstract sync() None[source]

Allow to synchronize headers with contents.

to_array() ndarray[Any, dtype[uint8]][source]
to_hex_str() str[source]
class py3dtiles.tileset.content.TileContentBody[source]

Bases: ABC

batch_table: BatchTable
feature_table: FeatureTable[Any, Any]
abstract to_array() ndarray[Any, dtype[uint8]][source]
class py3dtiles.tileset.content.TileContentHeader[source]

Bases: ABC

abstract static from_array(array: ndarray[Any, dtype[uint8]]) TileContentHeader[source]
magic_value: Literal[b'b3dm', b'pnts']
abstract to_array() ndarray[Any, dtype[uint8]][source]
version: int
py3dtiles.tileset.content.gltf_component_from_primitive(primitive: GltfPrimitive, byte_offset: int = 0, attribute_counter: int = 0) tuple[Primitive, list[Accessor], list[BufferView], bytes][source]

Build the GlTF structure that corresponds to a triangulated mesh.

The mesh is represented as numpy arrays as follows:

  • a 3D-point array;

  • a triangle array, where points are identified by their positional ID in the 3D-point array.

See https://gitlab.com/dodgyville/pygltflib/ (section “Create a mesh, convert to bytes, convert back to mesh”).

py3dtiles.tileset.content.read_binary_tile_content(tile_path: Path) TileContent[source]

Submodules