Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gnimuc/gltf.jl

glTF loader and writer for Julia
https://github.com/gnimuc/gltf.jl

gltf gltf-loader gltf2 julia

Last synced: 11 days ago
JSON representation

glTF loader and writer for Julia

Awesome Lists containing this project

README

        

# GLTF

[![CI](https://github.com/Gnimuc/GLTF.jl/actions/workflows/ci.yml/badge.svg)](https://github.com/Gnimuc/GLTF.jl/actions/workflows/ci.yml)
[![TagBot](https://github.com/Gnimuc/GLTF.jl/actions/workflows/TagBot.yml/badge.svg)](https://github.com/Gnimuc/GLTF.jl/actions/workflows/TagBot.yml)
[![Codecov](https://codecov.io/gh/Gnimuc/GLTF.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/Gnimuc/GLTF.jl)

[glTF](https://github.com/KhronosGroup/glTF) 2.0 loader and writer based on [JSON3](https://github.com/quinnj/JSON3.jl). This package only handles .gltf and not .glb.

## Installation
```julia
pkg> add GLTF
```

## Usage
glTF file format is just a JSON file + raw binaries. This package defines Julia types that map to the corresponding glTF objects.

```julia
julia> using JSON3, GLTF

julia> accessor_str = """{
"bufferView": 0,
"componentType": 5126,
"count": 24,
"type": "VEC3",
"max": [
0.3,
0.3,
0.3
],
"min": [
-0.3,
-0.3,
-0.3
],
"name": "Positions Accessor"
}"""
"{\n \"bufferView\": 0,\n \"componentType\": 5126,\n \"count\": 24,\n \"type\": \"VEC3\",\n \"max\": [\n 0.3,\n 0.3,\n 0.3\n ],\n \"min\": [\n -0.3,\n -0.3,\n -0.3\n ],\n \"name\": \"Positions Accessor\"\n}"

julia> accessor = JSON3.read(accessor_str, GLTF.Accessor)
GLTF.Accessor:
bufferView: 0
componentType: 5126
count: 24
type: VEC3
max: Any[0.3, 0.3, 0.3]
min: Any[-0.3, -0.3, -0.3]
name: Positions Accessor
```

load/save file from/to disk:
```
load("path/to/xxx.gltf") # -> GLTF.Object
save("path/to/xxx.gltf", x) # where x is of type GLTF.Object
```