First off I want to clarify that the glb file is there. I know because because I’ve tried putting a text file in the same folder instead, and that was found. I’ve double checked the extension and also tried the gltf format. It has been exported from Blender 2.82.
This is my js code:
import * as THREE from './three/build/three.module.js';
var camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.set( 500, 800, 1300 );
camera.lookAt( 0, 0, 0 );
var scene = new THREE.Scene();
scene.background = new THREE.Color( 0xf0f0f0 );
var renderer = new THREE.WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
import { GLTFLoader } from './three/examples/jsm/loaders/GLTFLoader.js';
var loader = new GLTFLoader();
loader.load( 'cube.glb', function ( gltf ) {
var model = gltf.scene;
scene.add( model );
} );
renderer.render( scene, camera );
Does anyone know what could be wrong? Any help is greatly appreciated.