I am attempting to integrate a gltf file into a Vue project. Below is the code I have been working on:
import * as THREE from 'three'
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader';
let scene, camera, renderer;
function init(){
scene = new THREE.Scene();
scene.background = new THREE.Color(0xdddddd);
camera = new THREE.PerspectiveCamera(40, window.innerWidth / window.innerHeight, 1, 5000);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
let loader = new GLTFLoader();
loader.load(require('../../assets/tshirt/gitF/tshirt.glb'), function(gltf){
//some code here
}
init();
The issue I am encountering reads:
./src/assets/tshirt/gitF/tshirt.glb 1:4
Module parse failed: Unexpected character '' (1:4)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
I am unsure of what I am overlooking in this scenario. PS: My knowledge in VUE and Three.js is limited. The same script functions correctly when not using any framework; however, the error exclusively occurs within the context of VUE.