cientos icon indicating copy to clipboard operation
cientos copied to clipboard

fix: add import to lensflare from three addons

Open alvarosabu opened this issue 10 months ago • 2 comments

alvarosabu avatar Jan 08 '25 16:01 alvarosabu

I created this issue on three-stdlib:

https://github.com/pmndrs/three-stdlib/issues/396

Until three-stdlib is fixed, how about sticking Lensflare.js from /examples/jsm in Cientos? That avoids build errors and works as expected.

andretchen0 avatar Jan 09 '25 14:01 andretchen0

I fixed the upstream issue but would suggest importing from three/addons if possible since this is an ESM-only package. The benefits of three-stdlib are to support CJS builds and offer backwards compatibility. In time, I hope to remove the need for the package entirely. three/addons (since r158) was a first step towards that.

three-stdlib does tree shake completely, where three/addons or three/examples/jsm/** does not. You can mitigate that with the latter (three/addons is impossible to tree-shake unfortunately; needs https://github.com/mrdoob/three.js/pull/26912) by emitting separate JS files with preserveModules or similar and package.sideEffects = false, so bundlers won't include files unless referenced in code.

Importing from three/examples/jsm/** creates hazards since some bundlers require explicit file extensions, which can be lost during transpilation, as it is technically source code (e.g. https://github.com/mrdoob/three.js/issues/24593).

CodyJasonBennett avatar Jan 11 '25 23:01 CodyJasonBennett