zpup
v0.5.0Write a small 3D scene as JSON, get fixable errors back, and see the flat SVG from any angle.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
get_reference Zpup scene reference
Returns the reference for writing a Zpup scene: the scene format, every shape and its options, conventions for axes and angles, and common mistakes. Read it once before writing a scene.
check_scene Check a Zpup scene
Checks a scene without drawing it. Returns every error with its path and how to fix it, and warnings for things that are valid but probably not intended (angles in radians, shapes outside the image, shapes of different colors passing through each other). A scene is plain JSON: { width, height, rotate?, children: [...] } with shapes such as dot, path, ellipse, rect, polygon, box, pyramid, cylinder, cone and hemisphere placed with translate and rotate (degrees). x is right, y is down, z is toward the viewer. Call get_reference once before writing a first scene. The server remembers the last vali…
| Parameter | Type | Description |
|---|---|---|
scene | The scene: an object with width, height and children (JSON text of the same is accepted). Call get_reference for the full format. Leave it out to use the scene from the last valid call. |
get_scene Read the remembered Zpup scene
Returns the scene the server remembers, as JSON: the last valid scene sent, with every change applied since. Use it to see the current indexes after several edits, or to keep the scene.
render_scene Draw a Zpup scene
Draws a small 3D scene as a flat SVG picture and returns a PNG of it to look at, the SVG text, and any warnings. An invalid scene draws nothing and returns every error with its path and how to fix it. Pass views to see the same scene from several angles in one call, which is the quickest way to find a shape that is in the wrong place. views and pose change only this picture: an angle or a pose set with changes stays in the remembered scene. A scene is plain JSON: { width, height, rotate?, children: [...] } with shapes such as dot, path, ellipse, rect, polygon, box, pyramid, cylinder, cone and…
| Parameter | Type | Description |
|---|---|---|
changes | array | Edits to the remembered scene (or to scene, when both are passed), applied in order, so that a small fix does not need the whole scene again. Example: [{ "op": "set", "path": "children[2].translate.y"… |
pose | array | Changes to draw with but not to keep, in the form of changes: the picture shows the scene in this pose, and the remembered scene stays as it is. Use it with views to check one pose of a sprite sheet l… |
preview_size | number | Longer side of the PNG in pixels. Default 512. |
save_to | string | Absolute path ending in .svg or .png to write the picture to. With several views, -1, -2 and so on are added to the name. |
scene | The scene: an object with width, height and children (JSON text of the same is accepted). Call get_reference for the full format. Leave it out to use the scene from the last valid call. | |
svg | boolean | Whether to send the SVG text back. Default true. Set false while iterating on the look to save space. |
views | array | View angles to draw, each used in place of the scene's own rotate. Omit to draw the scene as written. |
render_spin Make a turning Zpup SVG
Makes an SVG that turns the scene forever about one axis, with no JavaScript in the file, so it plays inside an <img> tag or a README. Returns PNG stills at even steps of the turn, so you can see what the animation shows. These files are large (tens to hundreds of KB), so pass save_to; the SVG text comes back only when it is small. A scene is plain JSON: { width, height, rotate?, children: [...] } with shapes such as dot, path, ellipse, rect, polygon, box, pyramid, cylinder, cone and hemisphere placed with translate and rotate (degrees). x is right, y is down, z is toward the viewer. Call get_…
| Parameter | Type | Description |
|---|---|---|
axis | string | Which view angle turns. Default "y", a turntable. |
changes | array | Edits to the remembered scene (or to scene, when both are passed), applied in order, so that a small fix does not need the whole scene again. Example: [{ "op": "set", "path": "children[2].translate.y"… |
direction | string | |
duration | number | Seconds for one full turn. Default 8. |
keyframes | number | Angles computed exactly, 4 to 720. More is smoother and larger. Default 36. |
preview_frames | integer | How many stills to send back, at even steps of the turn. Default 4 (0, 90, 180 and 270 degrees). Their default size is 256. |
preview_size | number | Longer side of the PNG in pixels. Default 512. |
save_to | string | Absolute path ending in .svg to write the file to. |
scene | The scene: an object with width, height and children (JSON text of the same is accepted). Call get_reference for the full format. Leave it out to use the scene from the last valid call. |
render_sprites Make a sprite sheet of a Zpup scene
Draws one scene from every side, turned in equal steps about its vertical axis, and lays the pictures out as one transparent PNG sprite sheet for a game: the same object in 4, 8 or 16 directions, all from one scene, so they agree with each other. With poses it draws every direction in every pose, for a walk cycle: one row per direction, one column per pose. With save_to it also writes the frame list next to the PNG as JSON, in the form TexturePacker writes (JSON hash) and Phaser, PixiJS and other engines read. Returns the sheet to look at. Every cell has the scene's own frame, so check that no…
| Parameter | Type | Description |
|---|---|---|
cell_size | number | Longer side of each cell in pixels. Default 128. |
changes | array | Edits to the remembered scene (or to scene, when both are passed), applied in order, so that a small fix does not need the whole scene again. Example: [{ "op": "set", "path": "children[2].translate.y"… |
columns | integer | Cells per row. Default: all directions in one row, up to 8. Not used with poses, where a row is one direction. |
directions | integer | How many directions to draw, at even steps of a full turn. Default 8. |
fit | boolean | Set to true to have the frame set for you: every cell shows the same part of the scene, enlarged so that the drawing fills the cell in the direction and pose where it reaches furthest. Nothing is cut… |
poses | array | Poses of the scene, for a walk or any other motion: each pose is a list of changes, in the form of changes, applied to the scene on its own, and an empty list is the scene as it is. The sheet then has… |
preview_direction | integer | A direction, counted from 0, to send back on its own as a second, larger picture: its poses in a row, to judge the motion from one pose to the next. 2 is the side view when there are 8 directions. |
save_to | string | Absolute path ending in .png to write the sheet to. The frame list is written next to it with the same name ending in .json. |
scene | The scene: an object with width, height and children (JSON text of the same is accepted). Call get_reference for the full format. Leave it out to use the scene from the last valid call. |