2

I am trying to load a 3d model into my website using the modelviewer library. However, the file it not loading and I am getting the below (see image).

FYI if it could be causing some issues - I am using github pages, but hosting a custom domain that I purchased from godaddy.

I thought that it was a permission issue, but I tried adding my .glb model to the folder and then downloading it by going to (example: www.website.com/origami.glb) and it downloaded.

Here is my code:

<!DOCTYPE html>
<html style="font-size: 100%;">

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>test</title>
        <link rel="stylesheet" href="./styles/styles.css" id="" type="text/css">
        <link rel="stylesheet" href="./styles/stylesMob.css" id="" type="text/css">
        <link rel="stylesheet" href="./styles/navStyle.css" id="" type="text/css">
        <link href='https://fonts.googleapis.com/css?family=Poppins' rel='stylesheet'>   
        <script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>   

        <style>
        model-viewer{
            width: 400px;
            height: 1600px;
            margin: auto;
        }   

        </style>
        
    </head>

    <body>
        <ul>
            <li><a  href="index.html">main</a></li>
            <li><a class="active" href="projects.html">projects</a></li>
            <li><a href="about.html">about</a></li>
            <li><a href="about.html">contact</a></li>
          </ul>
          
        
        <h4 style="font-size: 20px; color: red;"> * the website is wip * </h4>
        <div>
            <model-viewer src="origami.glb" ></model-viewer>
        </div>            
       

        
    </body>
</html>

enter image description here

enter image description here

ibib
  • 109
  • 5
  • Where exactly is your glb file hosted? Can you give us the full URL. – A Haworth Jan 05 '22 at 06:37
  • I have it on my github website repo, in the main root. I just added a photo of my file structure. Does that answer your question? Thank you for the help – ibib Jan 05 '22 at 07:05
  • Is there a reason you can't give us the full URL? I am asking because I suspect github isn't happy to serve image type data, but I don't know and without knowing where your file is stored I can only guess. – A Haworth Jan 05 '22 at 07:08
  • Is it possible you're just missing a `display: block;` from the CSS styling on model-viewer? – emackey Jan 05 '22 at 15:04
  • I'd also suggest checking the JS console for any errors. – Don McCurdy Jan 05 '22 at 16:37
  • if I add display: block in my css, I get 1 error: Failed to load resource: net::ERR_CONNECTION_RESET. However, if I remove the display: block in my css, I get 2 errors: 1)Access to XMLHttpRequest at ''file:///C:/Users/-----/origami.glb' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, edge, https, chrome-untrusted. 2) Failed to load resource: net::ERR_FAILED – ibib Jan 06 '22 at 20:54
  • 1
    I figured it out. I had to have a live web server to be able to load it. – ibib Jan 06 '22 at 21:04

1 Answers1

0

You can check this here model is showing.

<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.min.js"></script>

<model-viewer 
  src="http://raw.githubusercontent.com/german-alvarez-dev/workshop-webvr-aframe/master/ship/scene_ship.gltf" 
  auto-rotate
  alt="boat">
</model-viewer>
Iron Man
  • 35
  • 3