A pythonic interface for parsing gltf/glb files based on pygltflib.
Project description
Simple GLTF
Overview
Simple GLTF is a Python library that provides a user-friendly interface for parsing and accessing data within GLTF (GL Transmission Format) files. It leverages the pygltflib library to handle the low-level details of GLTF parsing, while offering a higher-level API for easy data manipulation and access.
Features
- Pythonic Interface: Provides a clean and intuitive interface for working with GLTF data.
- Data Access: Easily access various components of a GLTF file such as scenes, nodes, meshes, primitives, materials, etc.
Installation
You can install Simple GLTF using pip:
pip install simple-gltf
Alternatively, you can clone the repository and install it manually:
git clone https://github.com/turtleizzy/simple_gltf.git
cd simple_gltf
pip install .
Usage
Here's a basic example of how to use Simple GLTF to parse a GLTF file and access its data:
import pygltflib
from simple_gltf import RootInterface
# Load a GLTF file
gltf = pygltflib.GLTF2().load('path_to_your_file.glb')
# Create a RootInterface object
root = RootInterface(gltf)
# Access scenes
scenes = root.scenes
# Access the default scene
default_scene = root.scene
# Access nodes in the default scene
nodes = default_scene.nodes
# Access a specific node's mesh
mesh = nodes[0].mesh
# Access primitives in the mesh
primitives = mesh.primitives
# Access position data of the first primitive
positions = primitives[0].position
print(positions)
API Reference
Classes
-
RootInterface
scenes: List ofSceneInterfaceobjects.scene: DefaultSceneInterfaceobject.
-
SceneInterface
nodes: List ofNodeInterfaceobjects.
-
NodeInterface
children: List of childNodeInterfaceobjects.mesh:MeshInterfaceobject for the attached mesh.matrix: Transformation matrix of the node.name: Name of the node.
-
MeshInterface
primitives: List ofPrimitiveInterfaceobjects.name: Name of the mesh.
-
PrimitiveInterface
position: Numpy array of vertex positions.normal: Numpy array of vertex normals.tangent: Numpy array of vertex tangents.color: List of numpy arrays containing vertex colors.texcoords: List of numpy arrays containing texture coordinates.material: Material object associated with the primitive.mode: Rendering mode of the primitive.
Contributing
Contributions to Simple GLTF are welcome! Please follow these steps to contribute:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/AmazingFeature). - Commit your changes (
git commit -m 'Add some AmazingFeature'). - Push to the branch (
git push origin feature/AmazingFeature). - Open a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- pygltflib: A Python library for reading and writing GLTF files.
- Khronos Group: Maintainers of the GLTF specification.
Feel free to reach out if you have any questions or need further assistance!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_gltf-0.1.0.tar.gz.
File metadata
- Download URL: simple_gltf-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.11.7 Linux/6.11.0-061100-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2b0744634a8e886425d151cef6a3472d7008decc1cefc15963d1254a0f125f3
|
|
| MD5 |
1b8e2217b442e71f57ac256370a7e225
|
|
| BLAKE2b-256 |
6bc40f69a316c8692b6f9d5834f4754bf6155372a9e06dc3c70fed3a14238e70
|
File details
Details for the file simple_gltf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: simple_gltf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.11.7 Linux/6.11.0-061100-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0615c9c19ab762531b64a9ed394b5701ca9884c659dc3f1b32631b0d8be9f32
|
|
| MD5 |
2edd7442b7b50cbb6ecc51876ac6dc0b
|
|
| BLAKE2b-256 |
a0868eea801bda35eaacfb2e7226a7be3184771a06cd62e2461ec50e8306638a
|