pmndrs / gltfjsx

🎮 Turns GLTFs into JSX components
https://gltf.pmnd.rs
MIT License
4.41k stars 290 forks source link

work in progress: avoid shipping a modify copy of three's GLTFLoader and DRACOLoader #232

Open TimKraemer opened 7 months ago

TimKraemer commented 7 months ago

Motivation:

The primary goal of this pull request is to enhance the CLI functionality within a Node environment. This initiative was prompted by challenges encountered due to the current inclusion of modified versions of GLTFLoader and DRACOLoader in src/bin. These versions, being outdated, have led to issues, particularly in generating correctly structured JSX.

Proposed Changes:

Refactoring GLTFLoader:

To make it work I just had to remove one line in https://github.com/pmndrs/three-stdlib/loaders/GLTFLoader.js: const URL = self.URL || self.webkitURL

I assume that URL already exists in node. This probably needs a condition to not break browser use... Unfortunately I'm not speaking typescript and don't understand enough of the project to create a pull-request directly in three-stdlib.

Adapting DRACOLoader:

Addressing the DRACOLoader was more complex due to extensive browser dependencies. As a workaround, I incorporated the DRACOLoader from Brakebein/node-three-gltf. This is a temporary measure until DRACOLoader in three-stdlib is optimized for Node/CLI usage.

Package Updates:

I have also updated various packages to their latest versions. Note: The update excludes prettier. If these updates cause any conflicts, they can be excluded from this pull request.

Caveats and Future Work:

Conclusion:

This pull request is functional and addresses the immediate issues with CLI functionality in a Node environment. However, it needs further refinements and potential contributions to three-stdlib for a more integrated approach.