New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update draco decoder #12178
Update draco decoder #12178
Conversation
Since this is dynamically loading JS or WebAssembly files, it will become even more painful to use whenever there is a bundling step involved (i.e. when using webpack). It was already non-trivial before due to the direct usage of the It would be great if a strategy would be put in place to better support bundlers like webpack or rollup since any non-trivial app these days requires bundling (and probably also transpiling, etc). |
examples/webgl_loader_draco.html
Outdated
<script src="js/loaders/draco/DRACOLoader.js"></script> | ||
<script src="js/loaders/draco/geometry_helper.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not include this inside DRACOLoader.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found out this was not used in this example. So removed the file and the line.
I agree, but this isn't currently possible within the For the short-term, since this is already in Longer term... I'm curious how loading WebAssembly with JS fallback in webpack or rollup works. I'd be interested to see a proof of concept on this. 🙂 |
(dracoDecoderType !== undefined) ? dracoDecoderType : {}; | ||
this.drawMode = THREE.TrianglesDrawMode; | ||
this.dracoSrcPath = (dracoPath !== undefined) ? dracoPath : './'; | ||
THREE.DRACOLoader.loadDracoDecoder(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding an option to set the decoder explicitly:
var loader = new THREE.DRACOLoader(null, decoderType, manager);
loader.setDecoder(decoder);
loader.load(function () {
// ...
});
And then either (a) making the constructor decoderPath
optional, or (b) only providing it through a similar setDecoderPath(path)
method.
This would (I think) provide an opt-out for users with a bundler, who don't necessarily control their folder structure.
Thoughts @mrdoob?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the latest commit, I added the condition that if DracoDecoderModule
is defined then skip loading the decoder file. I think it could somehow solve this issue. But still looking at how to make it work with wasm.
Hi @hccampos , thanks for pointing out this problem. We don't have much experience with JS bundler so far, so good to learn! We made a change to |
Thanks! |
Rework of PR. Addressed comments and update Draco loader/decoder to the latest 1.1.0 release.
Now picking decoder according support for wasm is done in DRACOLoader.js. This will make it much easier to use the loader.
@donmccurdy
@mrdoob
@FrankGalligan
@ondys