metafizzy / zdog

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG
https://zzz.dog
10.38k stars 394 forks source link

Save/load graph JSON #35

Open eeropic opened 5 years ago

eeropic commented 5 years ago

The ability to save and load graphs from Zdog .json files could be quite useful in the future, at least in gamedev purposes.

Arranged in a tree structure, i.e. illustration:{ children:[ shape:{ children:[{},{}] } ] }

natemoo-re commented 5 years ago

This could be accomplished using the native JSON methods, although I'm not sure if there's a particular structure that would be the most efficient.

For serialization, a [toJSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#toJSON()_behavior) method could be added to Anchor (and Illustration?). For deserialization, a method could be exposed (Zdog.parse?) which extends JSON.parse by using a custom reviver parameter.

desandro commented 5 years ago

Add a 👍 reaction to this issue if you would like to see this feature added. Do not add +1 comments — They will be deleted.

Yeah, this one makes lots of sense.

webocs commented 5 years ago

I'm working on an 3D editor that will be able to write/read zdog drawings, It'll be super cool to have an official format, or even several illos. I think the JSON needs, a name for each Illustration

[
  illustration:{
    name: "SomeName"
    children:[
       shape:{
         children:[
           {...},
           {...}
        ]
      }
   ]
  },
...
]

I'm thinking about something like this..

newbold commented 5 years ago

It would also be super cool if there was a way to generate an STL file from a Zdog illustration (imagine 3D printing your Zdog creations!) or other formats (USDZ for ARKit fun!). I wouldn't imagine that kind of specialized output being a Zdog feature per se, but I'm adding this note here in case smart people can figure out how to harvest the 3D data from Zdog illustrations (or from the proposed JSON export, if that's added). ❤️

gut4 commented 5 years ago

Maybe its possible to import .vox files from MagicaVoxel? - https://ephtracy.github.io/ File format - https://github.com/ephtracy/voxel-model/blob/master/MagicaVoxel-file-format-vox.txt https://github.com/tommyettinger/IsoVoxel

loreanvictor commented 1 year ago

I'm working on an 3D editor that will be able to write/read zdog drawings, It'll be super cool to have an official format, or even several illos. I think the JSON needs, a name for each Illustration

[
  illustration:{
    name: "SomeName"
    children:[
       shape:{
         children:[
           {...},
           {...}
        ]
      }
   ]
  },
...
]

I'm thinking about something like this..

I don't know if you are still working on this, but just in case you are, why not a format close to SVG, for potential interops?