google / model-viewer

Easily display interactive 3D models on the web and in AR!
https://modelviewer.dev
Apache License 2.0
6.96k stars 822 forks source link

Instant placement for WebXR #1973

Closed christianpenya closed 3 years ago

christianpenya commented 3 years ago

Description

Hello, I can't always run 3D models on AR on my Android phone using Chrome. I have a working website with a few 3D models but it works or stops working depending on the server. As far as I could find, accessing via HTTP or HTTPS makes the difference. HTTP works for me, but not HTTPS. When it doesn't work resources get loaded but everything is messed up and it doesn't seem to be reaching the AR engine. The only log in the inspector is "Attempting to present in AR..." and it shows no other message or error.

I find it very weird since I can access other sites using model viewer and HTTPS. Also, I amb able to access my site via HTTPS with an iOS device. I wonder if it has anything to do with the file format.

Any ideas on how to solve this?

I leave a couple of screenshots. Working on HTTP: image

Broken version of the same site on HTTPS: image

Live Demo

working version: http://losreyesmagosencasa.com/

not working version; https://webar-8a6b6.web.app/

Version

Browser Affected

OS

elalish commented 3 years ago

Okay, so it's not quite as simple as working/not working. To get WebXR mode you must use HTTPS, which is the version in your second screenshot, which is why it also includes your DOM Overlay. With HTTP, WebXR fails and it uses SceneViewer instead (no DOM Overlay, but with a record button). Since the AR prompt is showing in your WebXR version, it appears to have not found the floor yet; does it look better once you move your phone around and the model is placed?

christianpenya commented 3 years ago

Thaks for your reply. I did not know all that, nice to know.
Not really, it feels like it never finds the floor.

elalish commented 3 years ago

Can you upload a video of WebXR failing to find to floor? I'd like to look into that. Keep in mind that you do have to move the phone side to side (hence the prompt) or ARCore won't get enough parallax to find the floor.

christianpenya commented 3 years ago

Here's the video: https://drive.google.com/file/d/1-Rr3y5LSi3lGX8hsovI7oUztWBsOe1Rh/view?usp=sharing

It looks like at some point it finds something, but it's not close to the floor. As you can see on the SceneViewer version, 3D models don't have any offset that could cause this.

elalish commented 3 years ago

Yeah, that's definitely not great. However, it looks like you're only pointing your phone in different directions, rather than actually moving it around. It needs accelerometer readings to find the scale of the room. Though I do intend to look into how SceneViewer seems to manage this better.

christianpenya commented 3 years ago

It doesn't get better if I move it more around. To be honest I was surprised how it actually found something in the video, even if it doesn't match the floor. Usually it doesn't find anything. Anyway, we cannot expect final users to move the phone in a unique certain way.

Thanks for the replies. I'll stay tuned to see new improvements!

elalish commented 3 years ago

Agreed! But since I haven't been able to repro this behavior it'd be great to have some more information to see if I can diagnose the problem. What device or devices have you tested? Have you tried in different environments? Any info you can give us on when it works better or worse will help us improve it.

elalish commented 3 years ago

I just had an idea for improving this and behaving a bit more like SceneViewer. Stay tuned...

christianpenya commented 3 years ago

Hi!

I tried with all the devices that I have around: Xiaomi's Pocophone F1, with Chrome and Android 10: This is the main device I use for development. It doesn't work fine, just as described before. Motorola G6, Chrome, Android 9: works fine, but I think it falls back to scene viewer just as you described before. Ipad 8th gen, ios 14.4, Safari: works fine, but I think it falls back to scene viewer just as you described before.

I've tried all the devices indoors and outdoors with same result. Unfortunately I think it falls back a lot to scene viewer... I'm not sure if it will be a lot of help. Please don't hesitate to ask for further tests if it can be helpful.

On the other hand, all the examples on the model viewer site work just fine with my phone (the Pocophone F1). It's just this project that for some reason doesn't.

I'm really looking forward to see this working flawlessly :)

elalish commented 3 years ago

Ah, so the same phone works with other WebXR examples! This is key information, thank you! In that case I would bet the problem is the model. I notice it's animated: one problem we see sometimes is that an animated model will have a translation from its resting position. We make our bounding box (and therefore height off the floor) based on the resting position. Also, sometimes models are at enormous scale, which can be hard to realize in AR sometimes. Ensure that it is properly sized in meters.