I would like to use the GLTFLoader to do some server side loading of models for the purpose of making thumbnail images. Towards this end, I have created a small node script which downloads zip files containing gltf models from S3, unzips them to a
tmp directory, then attempts to load the models locally.
My first attempt was to use
loader.parse(myGLTF,...). This correctly reads the gltf manifest as json, but as soon as it attempts loads the first .bin file, I get an exception
TypeError: Cannot read property 'slice' of undefined. This exception occurs in
GLTFParser.prototype.loadBufferView. It seems that it can’t load the local binary files.
For my second attempt, having followed several other threads that suggest to server the files statically, I stood up a server which serves the gltf files (.gltf (JSON) and, .bin (binary)) at http://localhost:8080/… When calling
loader.load("http://127.0.0.1:8080/model0.gltf,..."), I can see that the XMLHttpRequest is being made, but I get an error,
Unexpected end of JSON input. It can’t even read the gltf json.
The gltf models I am using are sound. I have successfully loaded the same in the client. And I can use the Threejs gltf preview in VS Code to see the models.
Has anyone successfully used GLTFLoader on the server?
Also, I have attempted to do both of the above with and without a LoadingManager, attempting to use the LoadingManager’s capability to modify urls to use
file://. Using the LoadingManager callbacks, I can see that my files are being “succesfully loaded”, but the errors remain.