davidson16807 / tectonics.js

3d plate tectonics in your web browser
http://davidson16807.github.io/tectonics.js/
Creative Commons Attribution 4.0 International
200 stars 28 forks source link

Loading saved simulation doesn't work properly #38

Closed hilariousppp closed 5 years ago

hilariousppp commented 5 years ago

When I try to change views after loading a saved simulation, the planet disappears completely. This occurs in both Firefox and Chrome.

davidson16807 commented 5 years ago

I'll check it out.

davidson16807 commented 5 years ago

Looks like an error gets thrown in the console when this happens:

BufferGeometryUtils.js:23 Uncaught TypeError: Cannot read property 'length' of undefined at Object.geometryToBufferGeometry [as fromGeometry] (BufferGeometryUtils.js:23) at create_mesh (RealisticWorldView.js:14) at RealisticWorldView.updateScene (RealisticWorldView.js:68) at GlobeProjectionView.updateScene (GlobeProjectionView.js:15) at View.update (View.js:40) at update (index.html:541)

more sleuthing needed.

davidson16807 commented 5 years ago

Alright, this is an issue with Grid object serialization. Grid objects are initialized from Three.js geometries, however this isn't a strict requirement. They can also be initialized from json objects, which is what happens when loading save files. The Three.js geometries have properties that the json objects don't have, so if ever the model relies on them, it breaks.

The fix is simple enough: don't use the properties.

In an effort to keep this issue from reoccurring, I now convert the Three.js geometries to a json object on startup. This should make any bugs much easier to spot in the future.

The fix is out in prod. Go check it out. If there are no other related issues I'll close this out.

hilariousppp commented 5 years ago

Everything works properly with saves made after the update. Thank you!