kenny-designs / voxel-edit

A web based voxel art program.
https://kenny-designs.github.io/voxel-edit/
5 stars 3 forks source link

Save Project #34

Closed kenny-designs closed 3 years ago

kenny-designs commented 3 years ago

Allow users to save their work and load it back in later on with the same color palette and voxel scene.

kenny-designs commented 3 years ago

Working on this issue now.

Currently, the major data that must be preserved between sessions is the makeup of the cells and the colors on the color palette. Currently, there is code that supports this between switching mobile and desktop UIs. This code can likely be reused for losing a pre-existing project.

Project's will be saved in .json files to the user's device. I know this works fine for android and pc. I am uncertain how iPhone's handle saving files and reuploading them. That will require some testing.

Lastly, we need to place the save and load project buttons somewhere. Originally, I had came up with an edit component. Now, I think I'll create a file component that deals with tasks related to files.

kenny-designs commented 3 years ago

Ran into various issues with the UI on both desktop and mobile while trying to get dropdowns to work. It took a while but they appear to be working now.

Now I can finally implement the saving feature.

kenny-designs commented 3 years ago

Now using FileSaver.js to assist with file downloads.

kenny-designs commented 3 years ago

Users can now download files and upload files. The actual loading of projects is being worked on now.

I wanted to note that a single 32x32x32 cell within the VoxelWorld takes up 309kb of space. As the user expands the scene, every new cell takes up an additional ~300kb of space! One solution is to just limit the size of the scene for users but this isn't necessarily the best idea. I'll need to think over a few ideas. One thing that might work is finding ways to compress json data.

This website has some advice on reducing JSON size.

Another idea I just had is to disregard unimportant information when saving if at all possible. There is a lot of empty space within a single scene and there's no good reason to save it for that is the default. However, then we'll need a way to determine which piece of voxel data goes where.

kenny-designs commented 3 years ago

Users can now save their projects and also load old projects! The UI also updates to reflect these changes as well.

This issue is almost complete. There are a few qualms I have that may either be moved to another issue or fixed before merging these changes into dev then main.

kenny-designs commented 3 years ago

Saving and loading projects now works! In addition, users can supply a name for their project as well.

There are some other issues that should be addressed such as sanitizing project files when loading, reducing file size, and considering a new file extension. These are problems that can be addressed in separate issues. For now, I am considering save project a success and will merge into dev and main.