py3dtiles.tileset.content.gltf module#

class py3dtiles.tileset.content.gltf.Gltf(gltf: GLTF2 | None = None)[source]#

Bases: TileContent

This class wraps a pygltflib.GLTF2 instance, to make it usable to py3dtiles where a TileContent can be used.

classmethod from_bytes(data: bytes) Self[source]#

Builds a Gltf from bytes, such as a glb files

classmethod from_meshes(meshes: list[GltfMesh], transform: ndarray[tuple[int, ...], dtype[float32]] | None = None) Self[source]#
get_colors() ndarray[tuple[int, ...], dtype[uint8 | uint16 | float32]] | None[source]#

Get the colors in the order they are defined, taking indices into account.

get_extra_field(fieldname: str) ndarray[tuple[int, ...], dtype[Any]] | None[source]#

Get an extra field in the order they are defined, taking indices into account.

get_extra_field_names() set[str][source]#

Get the extra field names found in this gltf file. For py3dtiles, an extra field is an attribute found on every primitive in this gltf.

The gltf convention mandates that custom attributes are uppercase and starts with a _. This method removes this leading _ and put each name to lowercase, to stay consistent with get_extra_field and the rest of the py3dtiles codebase.

get_vertex_count() int[source]#

Get the total vertex count. in the file, without taking into accounts indices. This is therefore different from the total number of vertices drawn on-screen.

get_vertices() ndarray[tuple[int, ...], dtype[float32 | uint16]] | None[source]#

Get the vertices in the order they are defined, taking indices into account.

save_as(path: Path) None[source]#

Save the gltf to a file

to_array() ndarray[tuple[int, ...], dtype[uint8]][source]#

Return a uint8 view of the bytes composing this tile content.

This is mainly a legacy method used to load from binary files.

class py3dtiles.tileset.content.gltf.PointsGltf(gltf: GLTF2 | None = None)[source]#

Bases: Gltf

Represents a simple GLTF made uniquely from points and with the following characteristicts:

  • one scene

  • one node

  • one mesh

  • one primitive

  • binary blob

This is used by py3dtiles to generate pure points gltf. These assumptions makes it vastly easier to implement some operations, like merging 2 PointsGltf together.

static can_build_from_gltf(gltf: GLTF2) bool[source]#
classmethod from_gltf(gltf: GLTF2) Self[source]#

Builds a PointsGltf from a pygltflib.GLTF2. This checks that the assumptions of PointsGltf are respected before constructing the object.

classmethod from_points(points: Points, name: str | None = None) Self[source]#
merge_with(other: Self) None[source]#

Merge 2 gltf built with gltf_from_points.

Warning: this performs a merge according to the structure of the gltf built with gtlf_from_points. Do not use with other gltf, it will certainly not do the correct thing!

This merges the buffers. It is slower than just concatenating the nodes/meshes, but decreases the number of draw call in the viewer, thus making the pointcloud performs better.

to_points(transform: ndarray[tuple[int, ...], dtype[float64]] | None) Points[source]#