I have a scene with many objects of circle geometry.
I display each object using a radious and N segments (e.g. 10), to view each object as a circle.
Currently when the scene is saved into .obj, .mtl file all the vertices are saved.
But there is no real reason to do that.
To simplify the .obj file and minimize the amount of transferred data,
I could only save the centre point coordinate of each circle object, and construct the circle geometry in memory, when loading from file .
One way to do this is to have a shadow dot object for each circle, and only save the dot.
I’m curious if there is a better way to implement this
Thanks,
Avi
If you circles are based on THREE.CircleGeometry
, consider to save your scene in three.js
JSON format. This can be done by doing:
const json = scene.toJSON();
You can load/deserialize such a JSON via ObjectLoader.
When using toJSON()
, only the parameters for creating THREE.CircleGeometry
will be saved, not the buffer attributes itself. When you load the geometries, they are generated from scratch based on the saved paramters.
2 Likes
This is great.
I didn’t know about load/deserialize JSON ObjectLoader
I used OBJLoader, and MTLLoader to load/store .obj, and .mtl files.
But with JSON ObjectLoader, I found that in addition to storing the model shape and material, I can also store other three-js objects such as the camera position.
Thank you for the answer!