I am Trying to load gltfLoader at node js server side but i will give that error.
if i will run script in browser then it will working fine but not at server side
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
global.THREE = require('/home/visilean/Ravi/HoungCode/threebim/js/libsCore/three');
const GLTFLoader = require('/home/visilean/Ravi/HoungCode/threebim/js/libs/loaders/GLTFLoader.js');
const loader = new THREE.GLTFLoader();
loader.load(
'http://localhost:8080/download?token=02b7ed8fabb84e987ac2cb40c0538d2352f6f8a630bdde708ec8ea1d9db3d0d289e9b97658c07acaa3146c8a72a6acc0&serializerOid=1572902&topicId=1',
( gltf ) => {
// called when the resource is loaded
scene.add( gltf.scene );
},
( xhr ) => {
// called while loading is progressing
console.log( `${( xhr.loaded / xhr.total * 100 )}% loaded` );
},
( error ) => {
console.error( 'An error happened', error );
},
);
i will getting that below error.
An error happened SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at GLTFLoader.parse (/home/visilean/Ravi/HoungCode/threebim/js/libs/loaders/GLTFLoader.js:139:20)
at Object.onLoad (/home/visilean/Ravi/HoungCode/threebim/js/libs/loaders/GLTFLoader.js:62:12)
at exports.XMLHttpRequest.<anonymous> (/home/visilean/Ravi/HoungCode/threebim/js/libsCore/three.js:31780:40)
at exports.XMLHttpRequest.dispatchEvent (/home/visilean/Ravi/HoungCode/threebim/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:595:29)
at setState (/home/visilean/Ravi/HoungCode/threebim/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:614:14)
at IncomingMessage.<anonymous> (/home/visilean/Ravi/HoungCode/threebim/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:447:13)