Skip to main content

Python library for reading, writing and managing 3D objects in the Khronos Group gltf and gltf2 formats. Python 3.7+

Project description

# pygltflib

Python library for reading, writing and handling GLTF files. Python3.7+

## Requirements
* Python 3.7
* numpy


## About
The library tracks the [official file format](https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md) for GLTF2.

The library was initially built to load and save simple meshes, support for materials and animations is experimental.
Check the table below for an idea of which sample models validate.



Roadmap:
* Finishing building out schemas
* Validate sample models
* Add helper functions

## Install
pip install pygltflib

or

python3.7 -m pip install pygltflib

## Usage
Note: These examples use the official [sample models](https://github.com/KhronosGroup/glTF-Sample-Models) provided by Kronos at:

https://github.com/KhronosGroup/glTF-Sample-Models

```python3.7
>>> from pygltflib import GLTF2
>>> filename = "glTF-Sample-Models/2.0/AnimatedCube/glTF/AnimatedCube.gltf"
>>> gltf = GLTF2().load(filename)
>>> gltf
>>> gltf.scene
0

>>> gltf.scenes
[Scene(name='', nodes=[0])]

>>> gltf.nodes[0]
Node(mesh=0, name='AnimatedCube', rotation=[0.0, -1.0, 0.0, 0.0])

>>> gltf.nodes[0].name
'AnimatedCube'

>>> gltf.meshes[0].primitives[0].attributes
Attributes(NORMAL=4, POSITION=None, TANGENT=5, TEXCOORD_0=6)

>>> filename2 = "test.gltf"
>>> gltf = GLTF2().save(filename2)

```


## Running the tests

### Status of gltf-validator
Using sample models loaded and then saved using this library, here are validator reports (blank is untested).


| Model | Validator Status |
| ------| ------- |
| 2CylinderEngine | errors: 67 |
| AlphaBlendModeTest | errors: 8 |
| AnimatedCube | passes |
| AnimatedMorphCube | |
| AnimatedMorphSphere | |
| AnimatedTriangle | |
| Avocado | |
| BarramundiFish | |
| BoomBox | |
| BoomBoxWithAxes | |
| Box | passes |
| BoxAnimated | passes |
| BoxInterleaved | |
| BoxTextured | |
| BoxTexturedNonPowerOfTwo | |
| BoxVertexColors | |
| BrainStem | |
| Buggy | |
| Cameras | |
| CesiumMan | |
| CesiumMilkTruck | |
| Corset | |
| Cube | errors: 2 |
| DamagedHelmet | |
| Duck | |
| FlightHelmet | |
| GearboxAssy | |
| Lantern | |
| MetalRoughSpheres | |
| Monster | errors: 2 |
| MultiUVTest | |
| NormalTangentMirrorTest | |
| NormalTangentTest | |
| OrientationTest | |
| ReciprocatingSaw | |
| RiggedFigure | |
| RiggedSimple | |
| SciFiHelmet | |
| SimpleMeshes | passes |
| SimpleMorph | |
| SimpleSparseAccessor | |
| SpecGlossVsMetalRough | |
| Sponza | |
| Suzanne | |
| TextureCoordinateTest | |
| TextureSettingsTest | |
| TextureTransformTest | |
| Triangle | passes |
| TriangleWithoutIndices | |
| TwoSidedPlane | errors: 3 |
| VC | |
| VertexColorTest | |
| WaterBottle | |





### unittests
python -m tests



Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygltflib-0.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

pygltflib-0.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pygltflib-0.2.tar.gz.

File metadata

  • Download URL: pygltflib-0.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pygltflib-0.2.tar.gz
Algorithm Hash digest
SHA256 2a474f1543b80ae7feb02e8b4022eb0d3d7497a733a479c8b44da5c80a749f55
MD5 7b224675e79342f17e8ee56b65fb1cb0
BLAKE2b-256 921048a949de1914623d4edaecc7e8bc9557f926291ab0103f5cb6042f88c6d2

See more details on using hashes here.

File details

Details for the file pygltflib-0.2-py3-none-any.whl.

File metadata

  • Download URL: pygltflib-0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for pygltflib-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 190b241a6537bb78745766f2952fbe28b79989d4d913f921107542417b87a91d
MD5 a43af996037aa0732027fe460fdfec2e
BLAKE2b-256 85d506b300430a818a14ea90f34000227d97aead703b638ff7a9e446f200907a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page