I am currently experimenting with loading a gLTF file in Three.js r105. After successfully loading the file, I decided to try changing the URL post-loading to see if it was possible. However, this decision led me straight into a problem.
Initially, I attempted to modify the URL within the "onLoad" function. When that didn't work, I moved on to trying to change it within my gltf.scene.traverse method. Unfortunately, that also did not yield the desired result, so I resorted to turning the input into a function as the URL parameter.
var loader = new THREE.GLTFLoader().load( function () {
window.setTimeout(`this = 'gmtk.glb', alert('It changed');`, 5000);
**return "sword_1.glb";**
},
I was hoping to at least see my gLTF file rendered, but instead, my entire scene turned black. The console displayed an error:
three.js:38135 Uncaught TypeError: url.lastIndexOf is not a function
at Object.extractUrlBase (three.js:38135)
at GLTFLoader.load (GLTFLoader.js:40)
at Kube.js:31