Identify Three.js objects across module copies - #443
oscarlorentzon wants to merge 1 commit into
Conversation
Three.js objects were identified by their class, which fails when an application loads a second copy of the module, so the checks now read the flag Three.js sets on every object it creates.
Multiple instance of The changes themselves are fine. It is more idiomatic for Three to discriminate types through the In short, I don't think we should make these changes to "support" setups with multiple instance of Three. Even if it might resolves some issue, the setup remains broken and can cause problems down the line for the user. As for using guards vs One change that might still be interesting is for the |
|
Agree that the multi-instance The guard functions narrow the type, since each is declared Still, |
Three.js objects were identified with
instanceof, which fails when an application loads a second copy of thethreemodule. An application passing objects from the secondthreecopy got no translation fromPointerControls, no environment map fromrecurseSetEnvMap, a throw or aNaNliteral fromDynoConst.getLiteral, and a level of detail limited only by the splat budget, never by on-screen size. All 20 checks now read the boolean marker Three.js sets on every object it creates, such asisVector3. Three.js identifies its own objects by the marker, and its build never usesinstanceofon a Three.js class. A single copy ofthreebehaves as before.Also raised in #250.