GLTFMesh

class compas.files.GLTFMesh(primitive_data_list, context, mesh_name=None, weights=None, extras=None, extensions=None)[source]

Bases: object

Object containing mesh data in a format compatible with the glTF standard.

Attributes
  • mesh_name (str) – String of the name of the mesh.

  • weights (list) – List containing the weights to be applied to morph targets.

  • primitive_data_list (list) – List of objects defining the geometry and material of the mesh.

  • extras (object)

  • extensions (object)

  • context (GLTFContent) – GLTF context in which the mesh exists.

  • key (int) – Key of the mesh used in compas.files.GLTFMesh.context.meshes.

  • vertices (list) – List of xyz-tuples representing the points of the mesh.

  • faces (list) – List of tuples referencing the indices of compas.files.GLTFMesh.vertices representing faces of the mesh.

Methods

from_data

Creates a GLTFMesh from a glTF node dictionary and inserts it in the provided context.

from_mesh

Construct a GLTFMesh object from a compas mesh.

from_vertices_and_faces

Construct a GLTFMesh object from lists of vertices and faces.

group_indices

Returns a list of the elements of indices grouped into tuples of size group_size.

shift_indices

Given a list of indices, returns a list of indices, all shifted by shift.

to_data

Returns a JSONable dictionary object in accordance with glTF specifications.

validate_faces

Raises an exception if not all faces in faces are defining either all triangles, lines or points.

validate_vertices

Raise an exception if there are either too many vertices, or the vertices do not represent points in 3-space.