Skip to content

DRACOLoader: Add exported urls for GLTF decoder - #33691

Merged
gkjohnson merged 3 commits into
mrdoob:devfrom
gkjohnson:draco-gltf
Jun 4, 2026
Merged

DRACOLoader: Add exported urls for GLTF decoder#33691
gkjohnson merged 3 commits into
mrdoob:devfrom
gkjohnson:draco-gltf

Conversation

@gkjohnson

@gkjohnson gkjohnson commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Related issue: #33564 (comment), #33602

Description

This PR updates DRACOLoader to support passing an object into "setDecoderPath" that specifies both the "js" and "wasm" file paths, and additionally provides an export of a pre-formed paths object for pointing to the in-project gltf decoder files:

import { DRACOLoader, DRACO_GLTF_CONFIG } from 'three/addons/loaders/DRACOLoader.js;

// takes a string OR an object
const loader = new DRACOLoader().setDecoderPath( {
  js: './path/to/decoder.js',
  wasm: './path/to/decoder.wasm',
} );

// or use the provided config
const loader = new DRACOLoader().setDecoderPath( DRACO_GLTF_CONFIG );
  • Exporting the urls like this allows the bundlers to resolve the urls correctly so they can be used by users.
  • This will enable these urls to be tree-shaken by bundlers.
  • Using "setDecoderPath" rather than something like a "useGltfVariant" flag avoids conceptual conflicts between the two (eg what does it mean if a user has explicitly set the decoder paths but also set "useGltfVariant" to true?)
  • It might be worth considering a different function name for this? Or a separate function entirely?
  • Updates 1 example to demonstrate functionality. I will submit a subsequent PR updating the remaining examples if this is accepted.

@gkjohnson
gkjohnson requested review from Mugen87 and donmccurdy May 31, 2026 05:41
@gkjohnson gkjohnson added this to the r185 milestone May 31, 2026
@gkjohnson

Copy link
Copy Markdown
Collaborator Author

Okay merging this! There's some working happening on a "tinydraco" WASM bundle so we may be able to converge on one WASM bundle sooner rather than later if everything works out and this proves to be reliable:

https://x.com/boulabiar/status/2062257485491110112

@gkjohnson
gkjohnson merged commit 70410f4 into mrdoob:dev Jun 4, 2026
9 checks passed
@gkjohnson
gkjohnson deleted the draco-gltf branch June 4, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants