2

I am trying to build a demo of model-viewer using a simple box object. It works fine on iOS/Safari, but I am unable to get this to work on Android. On Android, it will not activate the camera, just shows the model in blank space, the model can be moved around. I have tried using multiple models, including ones I have pulled from the internet, that are in working demos. Here is the complete HTML

<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="styles.css">
  <script src="https://unpkg.com/@webcomponents/webcomponentsjs@2.1.3/webcomponents-loader.js"></script>
  <script src="https://unpkg.com/intersection-observer@0.5.1/intersection-observer.js"></script>
  <script src="https://unpkg.com/resize-observer-polyfill@1.5.0/dist/ResizeObserver.js"></script>
  <script src="https://unpkg.com/fullscreen-polyfill@1.0.2/dist/fullscreen.polyfill.js"></script>
  <script src="https://unpkg.com/@magicleap/prismatic/prismatic.min.js"></script>
  <script src="https://unpkg.com/focus-visible@5.0.2/dist/focus-visible.js" defer></script>
  <title>Model Viewer Demo</title>
</head>
<body>
  <h1>WebAR Demo</h1>
  <p>A Basic demo of WebAR using Google's model-viewer component.</p>
  <div id="card">
    <model-viewer alt="its just a box" 
      src="assets/BoxTest.glb" 
      ios-src="assets/BoxTest.usdz" 
      background-color="#afe" 
      shadow-intensity="1" 
      camera-controls 
      interaction-prompt="auto" 
      ar 
      quick-look-browsers="safari chrome">
    </model-viewer>
  </div>
  <script type="module" src="https://unpkg.com/@google/model-viewer@v0.6.2/dist/model-viewer.js">
  </script>
  <script nomodule src="https://unpkg.com/@google/model-viewer@v0.6.2/dist/model-viewer-legacy.js">
  </script>
</body>
</html>

I am at a complete loss as to why it doesn't work and to what I need to try next.

Arto Bendiken
  • 2,293
  • 1
  • 22
  • 26
David Karasek
  • 248
  • 3
  • 15

1 Answers1

1

Turns out I was using simpleHTTPServer to serve it and it for some reason was the cause of the issue. I assume it didn't support the MIME type for the gltf file.

David Karasek
  • 248
  • 3
  • 15
  • Hey I have the same issue. Can you elaborate more on this? What do you mean you were using "simpleHTTPServer"? I'm using NginX on my server side and my model is in `.glb` format – xperator Nov 03 '19 at 12:21
  • @xperator Basically, the simpleHTTPServer implementation does not support serving .glb files, so when the website tries to grab the file it is unsupported. I could have added support for the mime types myself (being the .glb files) but instead I used a more robust solution. You likely just need to go into your nginx.conf and add support for .glb, however, that is not my expertise so I cannot give you a more robust answer/solution. But hopefully that is enough to get you in the right direction if you havent already. – David Karasek Dec 02 '19 at 21:21