Git Product home page Git Product logo

gltf-loader's Introduction

gltf-loader

Build Status Download Codacy Badge Codacy Badge

Loader for glTF2.0 files written in kotlin. The project uses Klaxon to parse JSON.

What it does

gltf-loader loads glTF file.

Features

  • loads .gltf files
  • loads .glb files
  • loads external .bin files
  • decodes base64 embedded buffers
  • decodes base64 embedded textures
  • minimal validation

Usage

val gltf = GltfAsset.fromFile("pathTo/asset.gltf")
val glb = GltfAsset.fromFile("pathTo/asset.glb")

Note that file extension is important because gltf-loader selects the proper loader implementation depending on the file extension

Concept

gltf-loader provides a higher level representation of the data present in the gltf files. The main difference is that objects hold actual references to other objects rather than the indices of these object in an centralized array. Those shared objects all have an index field which is their position in the array centralizing the resources of the same type. It makes navigation easier without loosing the benefit of having those resources centralized.

In the following example buffer is an object and not an index :

val buffer = asset.bufferViews[0].buffer

But you can retrieve its index :

val bufferIndex = buffer.index

Attributes with a defined range of allowed values are replaced by enums holding the original constant values.

val componentTypeConstantValue = ComponentType.FLOAT.code // 5126 

Validation

After loading the file gltf-loader performs a minimal validation pass on loaded data. For now it only checks that data respect the json schemas.

Buffers

Buffer data is loaded alongside the json descriptor so clients don't have to. This includes buffers contained in external .bin files and embedded base64 buffers. Base 64 buffers are decoded when the file is loaded.

Images

Embedded base64 image data is decoded too but external image files are not loaded.

Nodes' Transforms

In gltf files, as stated in gltf's specification : any node can define a local space transformation either by supplying a matrix property, or any of translation, rotation, and scale properties. When a node contains a matrix, gltf-loader will automatically extract the translation, scale and rotation properties even if their are not defined in the original file.

Todos

  • Extensions support (pbrSpecularGlossiness)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.