model-viewer
model-viewer copied to clipboard
AR Mode: Scaling affects light behaviour unexpectedly
Description
GLB supports lights, and we're using them in a good number of scenes by now. When scaling models in the WebXR mode, lights behave "wrong", their effect isn't invariant (invariant would be expected).
Expected: scaling in WebXR mode has the same visual effect as scaling in Display mode - light intensity, radius etc. stays invariant. Actual: scaling in WebXR has a different visual effect, it seems that light radius and intensity aren't scaled accordingly.
Live Demo
Open attached file in modelviewer.dev/editor and deploy to mobile with AR enabled LightScale.zip
Video: https://user-images.githubusercontent.com/2693840/121874453-a87a8900-cd07-11eb-9191-7b7ad9bf30b9.mp4
Version
Latest on modelviewer.dev/editor
Browser Affected
all with WebXR support
OS
- [X] Android
- [ ] iOS
- [ ] Linux
- [ ] MacOS
- [ ] Windows
AR
- [X] WebXR
- [X] SceneViewer (behaves "better" in the sense that lights don't blow out as crazy, but has the same issue)
- [ ] QuickLook
Hmm, that's interesting. I didn't think we included the lights from a GLB at all. Can you post a pretty example using lighting so I can get a feel for the use case?
@elalish sure, here you go: https://prefrontalcortex.de/labs/model-viewer/upload/Giant-Isopod-Animation/ Link is most likely temporary but here for the next weeks, feel free to grab the model for internal testing.
That's amazing! You made my wife's day with that one (oceanographer). Thanks for sharing!
When these links are stable, I hope you share them in show-and-tell. I really want to tweet some of these out as inspiration.
@elalish I think you may have closed some of these incorrectly; the issue still happens. Please reopen!
While the fix you made fixes the weird light targeting of three.js (and the lack of serialization of the target), it does not fix the light intensity change under scale.
I keep raising that as issue and there's new discussions going on here:
- https://github.com/mrdoob/three.js/issues/26659
Okay, thanks for letting us know.
Your linked issues talks about applying a scale to the WebXR camera, but I don't think we do that. Will your PR fix this issue too, or do we have a separate but related problem?
You’re right, might just be related. I thought pinch zoom scales the user around the scene (then the PR would fix the issue) but if it scales the object down it’s a separate problem (and could have been fixed by my original PR for the three.js issue which I was requested to close - with some sort of global light intensity multiplier).
Mind giving me a link to the PR you mean?
It was this one:
- https://github.com/mrdoob/three.js/pull/26662
but not complete yet (since I don't know how to correctly update the uniforms) and for now closed since there's discussion for three in general. Maybe you want to chime in. I think for AR/VR usecases it's quite common to have "scaled worlds" of sorts.