antonio-gomez / three-gltf2-loader Goto Github PK
View Code? Open in Web Editor NEWNode.js wrapper for the GLTF2Loader library from Three.js
Home Page: https://threejs.org/examples/?q=glt#webgl_loader_gltf
License: MIT License
Node.js wrapper for the GLTF2Loader library from Three.js
Home Page: https://threejs.org/examples/?q=glt#webgl_loader_gltf
License: MIT License
I tried using the current npm package and it fails on the RiggedFigure sample from here:
https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/RiggedFigure
I manually copied the updated GLTF2Loader code from three.js and it now supports that scene. Issue was a change/deprecation to the skinWeight attribute (WEIGHTS_0).
i see you already have a dev branch with newer gltf2loader so it would be great to publish that on npm!
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 ?...
Might be a good idea to include an issue template mentioning that bugs in the loader itself should be filed against three.js, not here.
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 ==
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 ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.