How to handle "Skipping Draco compression on non-indexed primitive" #394
-
Is your feature request related to a problem? Please describe. Hi, I am using the JS api of the draco encoder in conjunction with the three.js' GLTFExporter like this: import { WebIO } from '@gltf-transform/core';
import { KHRONOS_EXTENSIONS, DracoMeshCompression } from '@gltf-transform/extensions';
const io = new WebIO()
.registerExtensions(KHRONOS_EXTENSIONS)
.registerDependencies({
'draco3d.encoder': await new DracoEncoderModule(),
});
new GLTFExporter().parse(scene, (gltf) => {
const document = io.readJSON({
json: gltf,
resources: {},
});
document.createExtension(DracoMeshCompression)
.setRequired(true)
const { json: compressedGltf } = io.writeJSON(document);
}); Whenever I run this code, it logs this: And the gltf is of course not compressed. The input geometry looks like this, as you can see it's a non-indexed geometry. I can provide an executable example if needed. Describe the solution you'd like Additional context |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The primitive needs to be indexed for compression, and that isn't done automatically because it's generally lossy... You can do this manually with the import { weld } from '@gltf-transform/functions';
await document.transform(weld({tolerance: 0.0001}));
const glb = io.writeBinary(document); const { json: compressedGltf } = io.writeJSON(document); Note that resources are returned here as well; if you need a single file it's best to write to a binary GLB. |
Beta Was this translation helpful? Give feedback.
The primitive needs to be indexed for compression, and that isn't done automatically because it's generally lossy... You can do this manually with the
weld
function though:Note that resources are returned here as well; if you need a single file it's best to write to a binary GLB.