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.

  • 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.


from_data(mesh, context, primitive_data_list)

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

from_mesh(context, mesh)

Construct a compas.files.GLTFMesh object from a compas mesh.

from_vertices_and_faces(context, vertices, faces)

Construct a compas.files.GLTFMesh object from lists of vertices and faces.

group_indices(indices, group_size)

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

shift_indices(indices, shift)

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


Returns a JSONable dictionary object in accordance with glTF specifications.


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


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