Skip to content

Issue reading glTF/GLB with draco compression using draco3dgltf in both client-side browser and backend Node.js #1564

Answered by sonipapa
sonipapa asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the reply! I managed to get it working on both browser and node.js by downloading the decoder scripts (js and wsam) from https://github.com/google/draco/tree/main/javascript to my package, and importing the decoder directly from the js script. This script seems to have a environment branching logic for browser and node.js

import * as DracoDecoder from '<local_path>/draco_decoder_gltf.js';

function someMethodToReadFileAndGetBoundingBox() {
    ...

    // Configure I/O.
    io.registerExtensions(ALL_EXTENSIONS)
        .registerDependencies({
            'draco3d.decoder': await DracoDecoder.default(),
            'meshopt.decoder': MeshoptDecoder,
        });

    ...
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sonipapa
Comment options

Answer selected by donmccurdy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants