shawn0326 / zen-3d

JavaScript 3D library.
MIT License
196 stars 24 forks source link

GLTF Loader #4

Closed danschultz closed 4 years ago

danschultz commented 4 years ago

Hi, nice work on this project!

We're using your library in our project and would like to load GLTF models using your loader. However, GLTFLoader is not included in the bundle, but is instead part of your example folder. Because of this, we can't import it through a bundle.

What are you thoughts on including this into the main bundle so folks can include it through an import. If you have some direction, I'd be willing to submit a PR.

shawn0326 commented 4 years ago

https://github.com/mrdoob/three.js/pull/15518 Maybe this is a better way to solve the problem, like three.js did?

danschultz commented 4 years ago

I don't think this'll work in my scenario without some additional setup. The GLTFLoader is expecting zen3d as a global variable, and I'm consuming zen3d as an ESM bundle, so zen3d wouldn't be available globally. I'm doing this so I can take advantage of Rollup's treeshaking feature.

I think I might start a separate zen-3d-addons package that contains the extras I need and has zen3d as a peer dependency.

I also noticed that the version of Zen3d published to NPM is pretty out of date, about 3 years ago. Any plans to publish a more recent version?

xtronoid commented 4 years ago

You´re my secret warrior... in the future you will know... For now, maybe you will need this as some insightfull material:

https://github.com/yushijinhun/three-minifier

So many thanks, one day in the future, probably I will explain.

shawn0326 commented 4 years ago

I don't think this'll work in my scenario without some additional setup. The GLTFLoader is expecting zen3d as a global variable, and I'm consuming zen3d as an ESM bundle, so zen3d wouldn't be available globally. I'm doing this so I can take advantage of Rollup's treeshaking feature.

I think I might start a separate zen-3d-addons package that contains the extras I need and has zen3d as a peer dependency.

I also noticed that the version of Zen3d published to NPM is pretty out of date, about 3 years ago. Any plans to publish a more recent version?

https://github.com/mrdoob/three.js/blob/master/examples/jsm/loaders/GLTFLoader.js GLTFLoader will not expecting zen3d namespace, but import from 'zen3d.module.js' instead.

I will update the version of zen3d on NMP after solving this problem.

shawn0326 commented 4 years ago

You´re my secret warrior... in the future you will know... For now, maybe you will need this as some insightfull material:

https://github.com/yushijinhun/three-minifier

So many thanks, one day in the future, probably I will explain.

Thanks, it's a great example of using tree-shaking.

xtronoid commented 4 years ago

Haha cool that now I can import it normally (without using script loader)... but as threejs, it´s not tree shakeable...

so... if i use script loader with min version, i got 300kb (your rollup treeshake)... but if i use a prettier import way, i will end with doubled size...

decisions...

Im using threejs as sky/water background (bottom canvas composition) i know you ported sky... maybe i can try to port water... (probably it will be easy or not lol)

and lastly, im using three gltf export , and zen3d gltf import, to create geometry that i dont have in zen...

in other words, the golden scenary for me would be:

1 - getting away from threejs ( if i got zen3d water that one from sky ocean example ), and if i get text 3d geometry... and extrude geometry, shape hole, dodecahedron etc...

2 - using only zen-3d, with nice imports and treeshaking, instead importing via script loader the min tree shaked version...

Many thanks for now...

danschultz commented 4 years ago

I ended up creating a separate NPM package to contain these extra Zen 3D types. https://github.com/danschultz/zen-3d-addons. I'll go ahead and close this issue.