I’ve been building a front-end with vue which pings an API acting as a model server.
This has been working fine up until I added authorization to the API and for whatever reason i’m getting the error below when I try to load a model based of the api url.
RangeError: Invalid typed array length: 4
at new Uint8Array ()
at GLTFLoader.parse (GLTFLoader.js?34ad:187)
at Object.eval [as onLoad] (GLTFLoader.js?34ad:144)
at XMLHttpRequest.eval (three.module.js?5a89:35704)
I have pinged the api using the same url and authorization token and the model returns fine. I also checked the model at glTF Validator and it comes up as valid. The model is attached.
On the front end, this is the code i’m using to load the model:
I"m guessing it is because i need to add in authorization token to url get request used by loader. Does anyone know of way to add header to gltf loader?
For now I think you would have to fetch the .glb first — either using FileLoader or with your JS HTTP request method of choice — and then pass the ArrayBuffer into GLTFLoader’s loader.parse(...) method.
I tried setting up http request and passing response to the parse method as suggestion. I get the error “Unexpected token g in JSON at position 0” when I try to do so which I’ve had an issue with before. Seems to happen when it trys to load from gltf string rather than glb directly from url.
Good to know headers will be included with r115, hopefully that will resolve a few issues.
Thanks again for your help mate. The issue was with getting arraybuffer from response data while using axios… Seems i’m not the only one with the issue https://github.com/axios/axios/issues/1392