I'm attempting to initiate the loading and exhibition of a .stl file through three.js by implementing the following code:
var stlLoader = new THREE.STLLoader();
stlLoader.load('assets/Cap.stl', function (object){
object.position.y = - 100;
scene.add(object);
console.log("Object inserted.");
fitCameraToObject(camera,object,2,controls);
controls.update();
animate();
},
function ( xhr ) {
console.log( (xhr.loaded / xhr.total * 100) + '% loaded' );
},
function (err)
{
console.error(err);
}
);
(Lines 142-158)
However, when I load my webpage, my console shows this error:
webGLLoader.js:156 TypeError: Cannot set property 'y' of undefined
at webGLLoader.js:144
at Object.onLoad (STLLoader.js:80)
at XMLHttpRequest.<anonymous> (three.js:35998)
(anonymous) @ webGLLoader.js:156
(anonymous) @ STLLoader.js:86
(anonymous) @ three.js:35998
load (async)
load @ three.js:35976
load @ STLLoader.js:76
(anonymous) @ webGLLoader.js:143
It's puzzling me as to why this issue is occurring, considering I can successfully adjust an object's position using the same method with other loaders.