Solve KTX2Loader performance issues with Singleton Loaders #632
umar-ahmed
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Some of the loaders provided by Three in the examples folder assume that only one instance of a loader is ever created (ex. KTX2Loader). But
useLoader
instantiates a new loader instance whenever the arguments change and this can cause some major performance issues.To workaround this limitation, I created a factory function called
createSingletonLoader
that returns a new Loader constructor that makes sure that there is only at most 1 instance of the underlying loader:You can use it like so:
Hopefully this is useful for others that run into this issue
Beta Was this translation helpful? Give feedback.
All reactions