model-viewer icon indicating copy to clipboard operation
model-viewer copied to clipboard

AR Mode: Scaling affects light behaviour unexpectedly

Open hybridherbst opened this issue 3 years ago • 10 comments

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

hybridherbst avatar Jun 14 '21 09:06 hybridherbst

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 avatar Jun 15 '21 16:06 elalish

@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.

hybridherbst avatar Jun 15 '21 17:06 hybridherbst

That's amazing! You made my wife's day with that one (oceanographer). Thanks for sharing!

elalish avatar Jun 15 '21 18:06 elalish

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 avatar Jun 15 '21 18:06 elalish

@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

hybridherbst avatar Nov 22 '23 16:11 hybridherbst

Okay, thanks for letting us know.

elalish avatar Nov 22 '23 18:11 elalish

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?

elalish avatar Nov 22 '23 18:11 elalish

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).

hybridherbst avatar Nov 22 '23 20:11 hybridherbst

Mind giving me a link to the PR you mean?

elalish avatar Nov 22 '23 21:11 elalish

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.

hybridherbst avatar Nov 23 '23 20:11 hybridherbst