I’m sorry for sentences that are difficult to understand by automatic translation.
Hi,
I am developing glTF Importer/Exporter in C++.
With Draco compression and some combinations,
I found two problems in GLTFLoader.js.
I created a sample glb file for confirmation (Using my exporter).
I confirmed it with three.js(r97) and glTF Viewer ( https://gltf-viewer.donmccurdy.com/ ).
Case 1 : Draco compression + Share vertices data
Sample glb file :
https://ft-lab.github.io/gltf/apple/apple_cut_vert_share_draco.glb
The following conditions are specified.
- Draco compression
- Multiple primitives in one mesh
- Share vertices data (position/normal/uv) of each primitive with a BufferView
However, in this case, Indices + all the vertices data are stored in Draco compressed BuferView, so waste increases ,,,
Result :
accessors is null.
I confirmed it with glTF Viewer.
Reference : https://ft-lab.github.io/gltf/apple/apple_cut_vert_share.glb
(Draco compression unused glb file)
Cause place :
js/loaders/GLTFLoader.js
When isMultiPass = true in GLTFParser.prototype.loadGeometries,
The number of array elements of primitives is 1.
In the case of Draco compression, I think that an error occurs because isMultiPass = true processing is not included.
Case 2 : Draco compression + Morph Targets
Sample glb file :
https://ft-lab.github.io/gltf/MorphTargets/multiplePrimitives_draco.glb
The following conditions are specified.
- Draco compression
- Multiple primitives in one mesh
- Morph Targets
Result :
If the weight value of Morph Targets is not 0.0, some Primitives disappear.
Reference : https://ft-lab.github.io/gltf/MorphTargets/multiplePrimitives.glb
(Draco compression unused glb file)
Cause place :
js/loaders/GLTFLoader.js
Failure with drawElements.
In GLTFParser.prototype.loadGeometries,
In “if ( primitive.extensions && primitive.extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ] )”,
I think that asynchronous processing in “var geometryPromise … then”, the primitive is not passed correctly.
It worked fine as follows.
In decodePrimitive function,
resolve( geometry );
–>
resolve( {'geometry' : geometry, 'primitive' : primitive} );
In GLTFParser.prototype.loadGeometries function,
var geometryPromise = extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]
.decodePrimitive( primitive, parser )
.then( function ( geometry ) {
addPrimitiveAttributes( geometry, primitive, accessors );
return geometry;
} );
–>
var geometryPromise = extensions[ EXTENSIONS.KHR_DRACO_MESH_COMPRESSION ]
.decodePrimitive( primitive, parser )
.then( function ( data ) {
addPrimitiveAttributes( data['geometry'], data['primitive'], accessors );
return data['geometry'];
} );
Three.js version
- Dev
- r97
- …
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
You’re right, it was a bug. I’ll have this fixed soon. 🙂