0

I have copied code from https://threejs.org/examples/#webgl_loader_gltf and pasted it into an html document. I relinked all of the models, textures and .js files locally from MrDoob's JavaScript 3D library https://github.com/mrdoob/three.js/. When I link GLTF files from his folder locally on my computer I am able to view them in firefox but when I simply change the GLTF to my model I am unable to see it. I tried scalling the model down in blender before I export it and I also tried viewing it in Babylon viewer online (I was able to view my own GLTF model on the online Babylon viewer no problem).

    // model
    var loader = new THREE.GLTFLoader();
    loader.load( '../../skull_downloadable/scene.gltf', function ( gltf ) {

    gltf.scene.traverse( function ( child ) {

      if ( child.isMesh ) {

       child.material.envMap = envMap;

      }

     } );

     scene.add( gltf.scene );

    }, undefined, function ( error ) {

     console.error( error );

    } );

    renderer = new THREE.WebGLRenderer( { antialias: true } );
    renderer.setPixelRatio( window.devicePixelRatio );
    renderer.setSize( window.innerWidth, window.innerHeight );
    renderer.gammaOutput = true;
    container.appendChild( renderer.domElement );
    window.addEventListener( 'resize', onWindowResize, false );

    // stats
    stats = new Stats();
    container.appendChild( stats.dom );

   }

   function onWindowResize() {

    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize( window.innerWidth, window.innerHeight );

   }

Here is an image of my firefox console log**

Zain Farooq
  • 2,956
  • 3
  • 20
  • 42
  • are you running a local server like [Servez](https://greggman.github.io/servez) or one of these (https://stackoverflow.com/questions/12905426/what-is-a-faster-alternative-to-pythons-http-server-or-simplehttpserver) – gman Nov 12 '18 at 17:39
  • I am not running a local server I'm just using the files off of my hard drive – Gideon Chrapko Nov 12 '18 at 19:27
  • then you are going to have problems. you need to run a local server. it will take you 30 seconds. without one you can't do WebGL dev as the browser will block loading files and images of.yoir hard drive has it would be a security risk – gman Nov 13 '18 at 02:11
  • Amazing thank you so much, I am using Servez and it helped. I also had trouble locating files within my html document but I was able to find the proper files while running it off of the server fixed everything! – Gideon Chrapko Nov 13 '18 at 11:08

0 Answers0