openalea.plantconvert.gltf#

Internal functions to handle buffer on .gltf files.#

openalea.plantconvert.gltf.buffer_tools.get_buffer(acsr: Accessor, g: GLTF2)[source]#

Get the buffer referenced by the accessor in a gltf asset.

openalea.plantconvert.gltf.buffer_tools.get_data(byte_string, acsr: Accessor, buffer_view: BufferView)[source]#
openalea.plantconvert.gltf.buffer_tools.get_key(d: dict, value)[source]#

Functions to read .gltf files.#

class openalea.plantconvert.gltf.reader.mtg_builder(filename)[source]#

Bases: object

build()[source]#

Functions to write .gltf files.#

class openalea.plantconvert.gltf.writer.gltf_builder(g: MTG, features: list = None)[source]#

Bases: object

Class used to build a gltf object from the mtg.

The gltf object is implemented in pygltflib :

A Python library for reading, writing and handling GLTF files. link : sergkr/gltflib.

basic usage :

builder = gltf_builder(g, features = [“Length”, “Width”]) # you should initiate an instnace with your mtg g and a list of features to be written in the gltf object.

builder.build() #by calling this method, the build.gltf object will be created according to the mtg g.

#Finally, use the gltf’s method to output a gltf file Here we choose :

builder.gltf.save_json(“test.gltf”) #here we choose to output a simple json file. The meshes are written in an embedded (when we construct the gltf object). You can choose also to output in a more compact file type. Please refer to the pygltflib’s documentation

Parameters:
  • g (mtg.MTG) – the mtg object

  • features (list or None) – a list of features to be written in the gltf object. Default is None.

build()[source]#

Build the gltf object with embedded mesh information.

Uses the methods implemented in pygltflib to output it into a file of a given type.