-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGLTextures: Fix warning when using 3D Textures. #24753
WebGLTextures: Fix warning when using 3D Textures. #24753
Conversation
Previously, calling `WebGLRenderer.setRenderTarget(texture3D, layer)` would cause a warning `framebufferTexture2D: Bad 'imageTarget': 0x806f` (where `0x806f` translates to `TEXTURE_3D`). The warning is inconsequential but annoying.
Thanks for the check 🙏 Although the logic seems little bit hard to follow to me. @Mugen87 what do you think? |
I'm afraid I need a live example to better understand when the warning occurs. |
Haha, yes 😄 But it might help to look up a few lines before, at line 1254, there is already a check whether or not the texture target is a 3D texture or a 2D texture array. If it is possible that the texture target is a 3d/2d array texture up there, that must still be the case a few lines down where |
Yes, but I think it's more readable to check if something "is" something instead of checking if something "isn't" 🤓 |
Here is a tiny svelte component to reproduce the warning: <script lang="ts">
import { onMount } from 'svelte';
import { WebGLRenderer, WebGL3DRenderTarget } from 'three';
onMount(() => {
// create a renderer
let renderer = new WebGLRenderer();
// put it in the DOM
document.querySelector('#scene-container')?.append(renderer.domElement);
// create a 3d render target with arbitrary dimensions
const volumeRenderTarget = new WebGL3DRenderTarget(32, 32, 32);
// set the render target to the first slice of the volume
renderer.setRenderTarget(volumeRenderTarget, 0); // <-- warning here
});
</script>
<div id="scene-container" /> The call stack to the warning is as follows:
Agreed ... in general. |
Live example: https://jsfiddle.net/vmgud9x4/ When debugging the code, the line in question does not report a warning. Do I miss something in the example? |
Interesting. No, the live example is the same. And I do see the warning in the Developer Tools log when using Firefox. |
Chrome. When using Firefox, I can reproduce the warning, too.
Interesting to see this is browser dependent 🤔 . |
It seems nothing breaks if the
Nope, it would also be necessary to test for all |
Anyway, let's update the PR respectively. At the end, this explicit style is less confusing. |
to check for all valid texture targets explicitly
Done 👍 |
Thanks! Way easier to read 🙏 |
Hi all,
I am working on a 3D volumetric renderer and came across a warning today that I thought was an error. After fixing it, I realized that the reason why I wasn't seeing anything was in my code, not in three.js, but my solution contained a one-line fix for a real, albeit inconsequential, issue with this great library that I thought I'd might as well share.
Description
Previously, calling
WebGLRenderer.setRenderTarget(texture3D, layer)
would cause a warning framebufferTexture2D: Bad 'imageTarget': 0x806f (where0x806f
translates toTEXTURE_3D
).This fix simply checks whether the
textureTarget
argument is valid or not before callingframebufferTexture2D
. If it is not valid, the call is skipped - which is the same behavior that we have right now minus the annoying warning.Tests and linting succeeds 👍
Let me know if you need any more info or whatnot.
Cheers,