Skip to content
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

.setRenderer(gl) on the LoaderBase class #33

Closed
drcmda opened this issue Mar 25, 2024 · 1 comment
Closed

.setRenderer(gl) on the LoaderBase class #33

drcmda opened this issue Mar 25, 2024 · 1 comment

Comments

@drcmda
Copy link
Contributor

drcmda commented Mar 25, 2024

Would it be possible to make the gl inject optional + an additional .setRenderer(gl) method on the loader (the LoaderBase class to be exact)? so that the end user can do:

const loader = new HDRJPGLoader()
loader.setRenderer(gl)

the THREE.Loader interface doesn't have a common interface because three lacks types, but it can generally be assumed that it is no parameters on the constructor + set functions, that's how most (all?) loaders worked. for instance:

const gltf = new GLTFLoader()
gltf.setDRACOLoader(new DRACOLoader())

this becomes important once you have loader managing layers that rely on uniform structure. one such example is react-three-fibers useLoader, but tresjs, threlte etc will run into the same problems.

current workaround: https://codesandbox.io/p/sandbox/sleepy-jackson-hqct6n?file=%2Fsrc%2FApp.js%3A35%2C3-35%2C101

const quad = useLoader(HDRJPGLoader, 'spruit_sunrise_4k.jpg', (loader) => (loader._renderer = gl))

we would like to add a shortcut/helper to drei but we can't rely on internals for that, it would be too risky. if we can rely on the api users would then be able to just do

<Environment files="spruit_sunrise_4k.jpg" />
@drcmda drcmda changed the title .setRenderer(gl) on the Loader .setRenderer(gl) on the LoaderBase class Mar 25, 2024
@daniele-pelagatti
Copy link
Contributor

@drcmda let me know if #34 solved your issue, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants