THREE.BufferGeometry sent from api request to client side for rendering: issues adding geometry to scene

I have a DB with OBJ files. I have a backend application that loads them, converts them to three.js buffer geometries, and then send them client side for rendering.

My old workflow was to load OBJ files directly to front end, process them and merge them into a three.js buffer geometry then add to scene. This was killing battery life and making cell phones really hot. so, im trying to prep as much of the content in my backend app then send full and light three.js objects to client side for rendering.

My problem is when I send the Buffer Geometries over, they have changed for some reason.

then I get this error:
“error: TypeError: attribute.onUploadCallback is not a function”!

this is a log of the buffer geometry from the backend server.

I guess this has something to do with compression from sending it through a request? Although I’m not too sure. Is there something I need to do on the front end to unzipp or reconfigure the buffer? Sorry I’m quite a novice with this.

This error indicates that something in the deserialization process might go wrong. For example missing type information. Or in other words, you pass in an object to the renderer which is not of type BufferGeometry and hence its attributes are no type of BufferAttribute.

Can you please show your code that performs the client-side deserialization?

I don’t have any deserialization. So, I guess that is my question. How do I deserialize the BufferGeometry? I am currently simply loading the BufferGeometry from my backend and trying to take that object (which is in the format of my image above) and add it to my scene. I guess I need to use the JSON Loader? So, I’m trying that now, but it’s not working.

ERROR: “JSONLoader is not a function”


import * as JSONLoader from 'three-json-loader';
const JSONLoader = new this.THREE.JSONLoader( );
let test = JSONLoader( my_serialized_buffer_geometry );

JSONLoader is deprecated and removed from the code base since a while now. Use BufferGeometry.toJSON() for serialization and BufferGeometryLoader.parse() for deserialization.

1 Like

Thank you, very much appreciated.