J
J
jscoder2016-06-30 16:56:12
JSON
jscoder, 2016-06-30 16:56:12

Three.js :: Saving/Loading custom objects?

Good day!
According to the subject
3D-constructor of the room. Three.js r73. Saving and loading the project accordingly.
Objects on the stage contain custom properties/methods that are not there by default. As a result, the object is reduced to a similar form:
85367e4e13c248beb3ea75c550e39caf.jpgSaving
The first thing they advise is to use SceneExporter.js + SceneLoader.js , but in this case, the exporter throws an exception like m.ambient.getHEX() is not a function , which is strange, since I don’t even imagine where should it come from. And even if we ignore this fact and manually write the expected value that this function should return, we end up with JSON that looks like this
e67f226b377a4e788f26ac0d75390754.jpg:scene.toJSON()
which is quite different from the view we're working with in the browser. Hence a few questions:

  • With such a structure, how can geometry and materials be separately connected (and indeed everything that lies in JSON) and how can we get intelligible meshes from this?
  • Since most of the properties are custom, how to save them?
  • I'm starting to look at the option of completely saving js objects as they are in memory, even though the result may be 50 megabytes in weight. But in this case, because of the references inside the objects, I get TypeError: Converting circular structure to JSON

Accordingly, you need to find a way to save objects as already created meshes so as not to experience problems with loading, because scene.add () and scene.remove () are much simpler bicycles. Who can offer what?
Thank you!
UPD:
46aa0f993d164985a88041792d121a5c.jpg
while writing this, I returned to the loaded object and realized that there is an option to iterate over geometries, but arrays of different lengths and it just won’t work to associate with the corresponding textures and materials.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question