question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GLTFLoader : Failure of combination Draco compression and multiple primitives

See original GitHub issue

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. threejs_r97_draco_share_vertices 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. threejs_r97_draco_morphtargets 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
Hardware Requirements (graphics card, VR Device, …)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
donmccurdycommented, Oct 19, 2018

You’re right, it was a bug. I’ll have this fixed soon. 😃

0reactions
ft-labcommented, Oct 19, 2018

I did not upload the sample here, but I’ll write it for reference. When using Draco Since I store the triangle indices + vertices data with one Draco’s bitstream, I think that waste may increase when compressing Draco.

When I verified with the specification of Draco, when sharing vertices data with multiple primitives, All the vertices data had to be copied to Draco’s bitstream.

I’m sorry if I misunderstood the specification.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple UV Sets Getting Lost With Draco Compression
We are seeing strange behavior when dealing with Draco compressed GLTF files that use multiple UV sets. When compressing with Draco, ...
Read more >
[threejs-journey] Part 5 - Поделиться Курсом / Книгой / и тд.
You can still load not compressed glTF file with the GLTFLoader and the Draco decoder is only loaded when needed. When to use...
Read more >
Efficiently rendering glTF models | WebGPU ... - GitHub Pages
glTF files define meshes which each contain a list of chunks of renderable geometry called (confusingly) primitives . A primitive is represented as...
Read more >
three FrontSide JavaScript Examples - ProgramCreek.com
chunkIndex += chunkLength; } if ( this.content === null ) { throw new Error( 'THREE.GLTFLoader: JSON content not found.' ); } } /**...
Read more >
Three js gltf loader npm - allfreetools.de
To fix this, you should uninstall the npm package babel, ... 55 GLTF Loader 56 DRACO Loader 57 FBX Loader 58 FBX Animations...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found