-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Bug when using mathbox + THREE.Color in a bundle #49
Comments
I looked into this a bit (while dealing with some madness around an exploded frozen pipe at our house, otherwise I would put up a full PR...) It looks like internally, threejs deals with this with methods like
etc... so my guess is that that is the best way for us to move forward here. Thoughts @ChristopherChudzicki ? |
Submitting this in haste b/c i have to run... hopefully didn't forget something. I would start off with the question "Do we want to support userland imports like OK, why did we start importing from "three/src" in the first place? Answer: to make mathbox easier for bundlers to tree-shake. Note!: Whether we do SuggestionMy suggestion: Stop importing from "three/src". Replace all our threejs imports with Pros:
Cons:
@sritchie Question: Footnotes
|
@sritchie Re using properties like |
Related: Though I haven't found anything particularly enlightening yet. |
@ChristopherChudzicki thanks for doing all of this research. Let me ask the resident Google Closure Compiler expert on the Clojure slack if he thinks that my switch over to the |
@ChristopherChudzicki based on that tree-shaking thread I'm convinced that I don't have a good mental model of how any of this works, and I am very happy to switch to THAT SAID — using the It seems that threejs has added these to every object where we are using wdyt @ChristopherChudzicki ? is this more work for not much gain? |
@sritchie 👍 , I agree; I am inclined to do both:
|
Previously we were importing from specific three/src files. Why change? Because: - we can still tree shake - we were actually (indeirectly) using bare imports before, too. E.g., ThreeStrap imports from "three/examples/jsm/controls/OrbitControls", and OrbitControls imports bare "three" - "three" seems like the more official import pattern; it's what is documented at https://threejs.org/docs/#manual/en/introduction/Installation See also unconed/mathbox#49
Previously we were importing from specific three/src files. Why change? Because: - we can still tree shake - we were actually (indeirectly) using bare imports before, too: MathBox (via Threestrap) imports from "three/examples/jsm/controls/OrbitControls", and OrbitControls imports bare "three" - "three" seems like the more official import pattern; it's what is documented at https://threejs.org/docs/#manual/en/introduction/Installation See also #49
Previously we were importing from specific three/src files. Why change? Because: - we can still tree shake - we were actually (indeirectly) using bare imports before, too: MathBox (via Threestrap) imports from "three/examples/jsm/controls/OrbitControls", and OrbitControls imports bare "three" - "three" seems like the more official import pattern; it's what is documented at https://threejs.org/docs/#manual/en/introduction/Installation See also #49
Previously we were importing from specific three/src files. Why change? Because: - we can still tree shake - we were actually (indeirectly) using bare imports before, too. E.g., ThreeStrap imports from "three/examples/jsm/controls/OrbitControls", and OrbitControls imports bare "three" - "three" seems like the more official import pattern; it's what is documented at https://threejs.org/docs/#manual/en/introduction/Installation See also unconed/mathbox#49
* simplify threejs imports Previously we were importing from specific three/src files. Why change? Because: - we can still tree shake - we were actually (indeirectly) using bare imports before, too: MathBox (via Threestrap) imports from "three/examples/jsm/controls/OrbitControls", and OrbitControls imports bare "three" - "three" seems like the more official import pattern; it's what is documented at https://threejs.org/docs/#manual/en/introduction/Installation See also #49 * npm install with new threestrap Now that it's published * reformat * fix primitive import
@sritchie brought this up in ChristopherChudzicki/mathbox-react#203, but fundamentally it's an issue with the way Mathbox imports stuff.
Expectation: Users consuming the mathbox library should be able to write code similar to that below, bundle it with some bundler (webpack, vite, turbopack, etc) and have it work
Actuality: Code like the above does not work because:
three/src
. For example,import { Color } from "three/src/math/Color.js";
( example)instanceof
checks likevalue instanceof Color
(example)three
(such as the code above), which means userland people usethree/build/three.module.js
. Consequently,instanceof
checks won't work.See https://github.com/ChristopherChudzicki/mathbox-color-bug for a full example.
Notes
The text was updated successfully, but these errors were encountered: