Giter Site home page Giter Site logo

antonio-gomez / three-gltf2-loader Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 9.0 46 KB

Node.js wrapper for the GLTF2Loader library from Three.js

Home Page: https://threejs.org/examples/?q=glt#webgl_loader_gltf

License: MIT License

JavaScript 100.00%
gltf three-js es6 bundler webpack browserify

three-gltf2-loader's Introduction

Three-glTF2-loader

npm-image version-image

Install


npm install three-gltf2-loader --save

Description


Node.js wrapper for the GLTF2Loader library from three.js so that it can be installed through npm and used with bundle libraries like webpack, browserify, etc.

glTF (Graphic Library Transmission Format) was developed and mantained by KhronosGroup as the specification for efficient transmission and loading of 3D scenes and models by WebGL, OpenGL ES, and OpenGL applications.

Usage


import THREE from 'three'
import GLTF2Loader from 'three-gltf2-loader'

GLTF2Loader(THREE)

console.log(typeof THREE.GLTF2Loader)
// => "function"

Changelog


1.2.0 (Oct 22 2017)

  • Updated to latest glTF loader from Three.js r87.

1.1.0 (Jun 28 2017)

  • Updated to latest glTF spec from Three.js r86.

1.0.0 (Mar 24 2017)

  • Main module functionality.

0.0.0 (Mar 21 2017)

  • Initial development.

License

MIT © Antonio Gomez

three-gltf2-loader's People

Contributors

antonio-gomez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

three-gltf2-loader's Issues

Version 1.2 breaking change

In version 1.1, the loader is defined as:

THREE.GLTF2Loader = ( function () {

In version 1.2, the loader is defined as:

THREE.GLTFLoader = ( function () {

This is a huge breaking change. React-vr and react-vr-web both use THREE.GLTF2Loader, so gltf files now won't load in React VR at all. There is no workaround, other than to downgrade to 1.1.0. I'm also following up with React VR.

Was there a reason for this change?

Will the rename be permanent? Seems odd as GLTF2 files are more common now than GLTF1.

Also, I notice the GLTFSHADER seems to have disappeared; that seems drastic - did it move somewhere? What's it for?

Thank you,

== John ==

Data is already json in parse function

Hey, sorry if I dont provide a patch but im in a bit of hurry
Anyway, file https://raw.githubusercontent.com/antonio-gomez/three-gltf2-loader/master/lib/main.js
Used "as is" with GLTF2 models (downloaded from different sources, like sketchfab) give the error "Uncaught SyntaxError: Unexpected end of JSON input (GLTF2Loader.js:69)"

Solved changed this piece of code:

if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
  extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
  content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
} else {
  content = convertUint8ArrayToString( new Uint8Array( data ) );
}
var json = JSON.parse( content );

into this:

if ( magic === BINARY_EXTENSION_HEADER_MAGIC ) {
    extensions[ EXTENSIONS.KHR_BINARY_GLTF ] = new GLTFBinaryExtension( data );
    content = extensions[ EXTENSIONS.KHR_BINARY_GLTF ].content;
    var json = JSON.parse( content );
} else {
  try {
    var json = JSON.parse( data );
  }
  catch ( e ) {
    content = convertUint8ArrayToString( new Uint8Array( data ) );
    var json = JSON.parse( content );
  }
}

(just check if it is already valid Json)

I'll submit a patch in the next days as soon as i'll find some time ;)

Can not read property of 'undefined'

I'm trying to use this module with the code below :

import THREE from 'three'; import GLTF2Loader from 'three-gltf2-loader'; GLTF2Loader(THREE); console.log(typeof THREE.GLTF2Loader);

But I have the error 'Can not read property of undefined', referencing the 'THREE'. However I'm using some elements of THREE which works.
And even if I remove the '2', the error still remains.

Another clue : webpack is displaying warning :
"export 'default' (imported as 'THREE') was not found in 'three'

For you, is it a THREE error, or a GLTF2Loader error ?...

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.