From 8d1cf5874e8ba67ec5effdac7e0ba03aae49c43b Mon Sep 17 00:00:00 2001 From: Scott Vorthmann Date: Wed, 1 Nov 2023 09:33:17 -0700 Subject: [PATCH] Cell selection implemented in 59icosahedra This is a bit of a hack, requiring hand-editing of the .vZome files for the two selector models to add `label` attributes to the `GroupSelection` commands. Still, the hack is limited to the Javascript code, so far. For the stellation model, I now have named bookmarks for all the stellation faces, and the first four stellation cells. I have implemented a very rough "macro capture" to use in Online classic, and a means to trigger a macro from the client. The side-effect of clicking on one of the selector cells is still just a log statement, until I work out how to communicate the macros to the stellation worker. For the moment, a background click in the stellation scene will trigger a macro to produce colored "c" cells. --- .../models/icosahedron-stellation-faces.vZome | 3431 +++++++++++++++++ online/public/models/pieces-aceg.vZome | 12 +- online/public/models/pieces-bdfh.vZome | 12 +- online/src/app/59icosahedra/index.jsx | 9 +- online/src/app/59icosahedra/macros.js | 213 + online/src/app/59icosahedra/selector.jsx | 37 +- online/src/viewer/solid/geometry.jsx | 2 +- .../src/worker/legacy/controllers/wrapper.js | 13 +- online/src/worker/legacy/core.js | 28 +- online/src/worker/legacy/scenes.js | 3 +- online/src/worker/vzome-worker-static.js | 16 + online/src/workerClient/actions.js | 2 + online/src/workerClient/controllers-solid.js | 2 + 13 files changed, 3758 insertions(+), 22 deletions(-) create mode 100644 online/public/models/icosahedron-stellation-faces.vZome create mode 100644 online/src/app/59icosahedra/macros.js diff --git a/online/public/models/icosahedron-stellation-faces.vZome b/online/public/models/icosahedron-stellation-faces.vZome new file mode 100644 index 000000000..68c16b89d --- /dev/null +++ b/online/public/models/icosahedron-stellation-faces.vZome @@ -0,0 +1,3431 @@ + + + + + + + + + { + "field": "golden", + "vertices": [ + [ + [ + 0, + 0, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + 0, + 0, + 1 + ] + ], + [ + [ + -2, + -3, + 1 + ], + [ + 3, + 5, + 1 + ], + [ + 5, + 8, + 1 + ] + ], + [ + [ + -5, + -8, + 1 + ], + [ + 2, + 3, + 1 + ], + [ + 3, + 5, + 1 + ] + ], + [ + [ + -5, + -8, + 1 + ], + [ + -2, + -3, + 1 + ], + [ + 3, + 5, + 1 + ] + ], + [ + [ + -2, + -3, + 1 + ], + [ + -3, + -5, + 1 + ], + [ + 5, + 8, + 1 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + 6, + 10, + 1 + ] + ], + [ + [ + -5, + -8, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ] + ], + [ + [ + 5, + 8, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + 8, + 13, + 1 + ], + [ + -5, + -8, + 1 + ] + ], + [ + [ + 29, + 47, + 5 + ], + [ + 29, + 47, + 5 + ], + [ + -29, + -47, + 5 + ] + ], + [ + [ + -29, + -47, + 5 + ], + [ + 29, + 47, + 5 + ], + [ + -29, + -47, + 5 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + -18, + -29, + 5 + ], + [ + -47, + -76, + 5 + ] + ], + [ + [ + -21, + -34, + 2 + ], + [ + 8, + 13, + 2 + ], + [ + -13, + -21, + 2 + ] + ], + [ + [ + -13, + -21, + 2 + ], + [ + 21, + 34, + 2 + ], + [ + -8, + -13, + 2 + ] + ], + [ + [ + 8, + 13, + 2 + ], + [ + -13, + -21, + 2 + ], + [ + -21, + -34, + 2 + ] + ], + [ + [ + -8, + -13, + 2 + ], + [ + -13, + -21, + 2 + ], + [ + -21, + -34, + 2 + ] + ], + [ + [ + 21, + 34, + 2 + ], + [ + 8, + 13, + 2 + ], + [ + -13, + -21, + 2 + ] + ], + [ + [ + 13, + 21, + 2 + ], + [ + 21, + 34, + 2 + ], + [ + -8, + -13, + 2 + ] + ], + [ + [ + -3, + -5, + 1 + ], + [ + 13, + 21, + 1 + ], + [ + -3, + -5, + 1 + ] + ], + [ + [ + -10, + -16, + 1 + ], + [ + 8, + 13, + 1 + ], + [ + -5, + -8, + 1 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ], + [ + -11, + -18, + 1 + ] + ], + [ + [ + 10, + 16, + 1 + ], + [ + 8, + 13, + 1 + ], + [ + -5, + -8, + 1 + ] + ], + [ + [ + -11, + -18, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ] + ], + [ + [ + 8, + 13, + 1 + ], + [ + -5, + -8, + 1 + ], + [ + -10, + -16, + 1 + ] + ], + [ + [ + 3, + 5, + 1 + ], + [ + 13, + 21, + 1 + ], + [ + -3, + -5, + 1 + ] + ], + [ + [ + -8, + -13, + 1 + ], + [ + -5, + -8, + 1 + ], + [ + -10, + -16, + 1 + ] + ], + [ + [ + 11, + 18, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + 76, + 123, + 5 + ], + [ + -11, + -18, + 5 + ] + ], + [ + [ + -13, + -21, + 1 + ], + [ + 29, + 47, + 5 + ], + [ + -29, + -47, + 5 + ] + ], + [ + [ + -18, + -29, + 5 + ], + [ + -47, + -76, + 5 + ], + [ + -58, + -94, + 5 + ] + ], + [ + [ + -58, + -94, + 5 + ], + [ + -18, + -29, + 5 + ], + [ + -47, + -76, + 5 + ] + ], + [ + [ + 13, + 21, + 1 + ], + [ + 29, + 47, + 5 + ], + [ + -29, + -47, + 5 + ] + ], + [ + [ + 58, + 94, + 5 + ], + [ + -18, + -29, + 5 + ], + [ + -47, + -76, + 5 + ] + ], + [ + [ + 47, + 76, + 5 + ], + [ + 58, + 94, + 5 + ], + [ + -18, + -29, + 5 + ] + ], + [ + [ + 18, + 29, + 5 + ], + [ + -47, + -76, + 5 + ], + [ + -58, + -94, + 5 + ] + ], + [ + [ + -47, + -76, + 5 + ], + [ + 58, + 94, + 5 + ], + [ + -18, + -29, + 5 + ] + ], + [ + [ + -21, + -34, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ] + ], + [ + [ + 13, + 21, + 1 + ], + [ + -13, + -21, + 1 + ], + [ + -13, + -21, + 1 + ] + ], + [ + [ + -13, + -21, + 1 + ], + [ + -13, + -21, + 1 + ], + [ + -13, + -21, + 1 + ] + ], + [ + [ + 8, + 13, + 1 + ], + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ] + ], + [ + [ + -8, + -13, + 1 + ], + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ] + ], + [ + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ], + [ + -8, + -13, + 1 + ] + ], + [ + [ + -34, + -55, + 1 + ], + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + -34, + -55, + 1 + ], + [ + -21, + -34, + 1 + ] + ], + [ + [ + 34, + 55, + 1 + ], + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ] + ], + [ + [ + 76, + 123, + 1 + ], + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ] + ], + [ + [ + -21, + -34, + 1 + ], + [ + -68, + -110, + 1 + ], + [ + -34, + -55, + 1 + ] + ], + [ + [ + 0, + 0, + 1 + ], + [ + 76, + 123, + 1 + ], + [ + 21, + 34, + 1 + ] + ], + [ + [ + -68, + -110, + 1 + ], + [ + -34, + -55, + 1 + ], + [ + -21, + -34, + 1 + ] + ], + [ + [ + -55, + -89, + 1 + ], + [ + 55, + 89, + 1 + ], + [ + 13, + 21, + 1 + ] + ], + [ + [ + 68, + 110, + 1 + ], + [ + -34, + -55, + 1 + ], + [ + -21, + -34, + 1 + ] + ], + [ + [ + 21, + 34, + 1 + ], + [ + -68, + -110, + 1 + ], + [ + -34, + -55, + 1 + ] + ], + [ + [ + 55, + 89, + 1 + ], + [ + 55, + 89, + 1 + ], + [ + 13, + 21, + 1 + ] + ], + [ + [ + -76, + -123, + 1 + ], + [ + 21, + 34, + 1 + ], + [ + 0, + 0, + 1 + ] + ] + ], + "balls": [ + { + "vertex": 1, + "color": "#ffffff" + }, + { + "vertex": 2, + "color": "#ffffff" + }, + { + "vertex": 3, + "color": "#ffffff" + }, + { + "vertex": 4, + "color": "#ffffff" + }, + { + "vertex": 5, + "color": "#ffffff" + }, + { + "vertex": 6, + "color": "#ffffff" + }, + { + "vertex": 7, + "color": "#ffffff" + }, + { + "vertex": 8, + "color": "#ffffff" + }, + { + "vertex": 10, + "color": "#ffffff" + }, + { + "vertex": 11, + "color": "#ffffff" + }, + { + "vertex": 9, + "color": "#ffffff" + }, + { + "vertex": 12, + "color": "#ffffff" + }, + { + "vertex": 13, + "color": "#ffffff" + }, + { + "vertex": 14, + "color": "#ffffff" + }, + { + "vertex": 15, + "color": "#ffffff" + }, + { + "vertex": 16, + "color": "#ffffff" + }, + { + "vertex": 17, + "color": "#ffffff" + }, + { + "vertex": 20, + "color": "#ffffff" + }, + { + "vertex": 21, + "color": "#ffffff" + }, + { + "vertex": 22, + "color": "#ffffff" + }, + { + "vertex": 18, + "color": "#ffffff" + }, + { + "vertex": 23, + "color": "#ffffff" + }, + { + "vertex": 25, + "color": "#ffffff" + }, + { + "vertex": 19, + "color": "#ffffff" + }, + { + "vertex": 26, + "color": "#ffffff" + }, + { + "vertex": 24, + "color": "#ffffff" + }, + { + "vertex": 33, + "color": "#ffffff" + }, + { + "vertex": 29, + "color": "#ffffff" + }, + { + "vertex": 34, + "color": "#ffffff" + }, + { + "vertex": 27, + "color": "#ffffff" + }, + { + "vertex": 30, + "color": "#ffffff" + }, + { + "vertex": 28, + "color": "#ffffff" + }, + { + "vertex": 31, + "color": "#ffffff" + }, + { + "vertex": 32, + "color": "#ffffff" + }, + { + "vertex": 35, + "color": "#ffffff" + }, + { + "vertex": 36, + "color": "#ffffff" + }, + { + "vertex": 37, + "color": "#ffffff" + }, + { + "vertex": 38, + "color": "#ffffff" + }, + { + "vertex": 39, + "color": "#ffffff" + }, + { + "vertex": 40, + "color": "#ffffff" + }, + { + "vertex": 41, + "color": "#ffffff" + }, + { + "vertex": 43, + "color": "#ffffff" + }, + { + "vertex": 42, + "color": "#ffffff" + }, + { + "vertex": 44, + "color": "#ffffff" + }, + { + "vertex": 45, + "color": "#ffffff" + }, + { + "vertex": 46, + "color": "#ffffff" + }, + { + "vertex": 47, + "color": "#ffffff" + }, + { + "vertex": 51, + "color": "#ffffff" + }, + { + "vertex": 52, + "color": "#ffffff" + }, + { + "vertex": 48, + "color": "#ffffff" + }, + { + "vertex": 49, + "color": "#ffffff" + }, + { + "vertex": 53, + "color": "#ffffff" + }, + { + "vertex": 50, + "color": "#ffffff" + }, + { + "vertex": 0, + "color": "#ffffff" + } + ], + "struts": [ + { + "vertices": [ + 0, + 1 + ], + "color": "#007695" + }, + { + "vertices": [ + 0, + 2 + ], + "color": "#007695" + }, + { + "vertices": [ + 0, + 3 + ], + "color": "#007695" + }, + { + "vertices": [ + 0, + 4 + ], + "color": "#007695" + }, + { + "vertices": [ + 0, + 5 + ], + "color": "#007695" + }, + { + "vertices": [ + 6, + 7 + ], + "color": "#007695" + }, + { + "vertices": [ + 6, + 8 + ], + "color": "#007695" + }, + { + "vertices": [ + 7, + 8 + ], + "color": "#007695" + }, + { + "vertices": [ + 9, + 7 + ], + "color": "#008d36" + }, + { + "vertices": [ + 10, + 8 + ], + "color": "#008d36" + }, + { + "vertices": [ + 10, + 6 + ], + "color": "#008d36" + }, + { + "vertices": [ + 11, + 6 + ], + "color": "#008d36" + }, + { + "vertices": [ + 11, + 7 + ], + "color": "#008d36" + }, + { + "vertices": [ + 9, + 8 + ], + "color": "#008d36" + }, + { + "vertices": [ + 9, + 17 + ], + "color": "#008d36" + }, + { + "vertices": [ + 10, + 12 + ], + "color": "#008d36" + }, + { + "vertices": [ + 10, + 13 + ], + "color": "#008d36" + }, + { + "vertices": [ + 11, + 15 + ], + "color": "#008d36" + }, + { + "vertices": [ + 11, + 14 + ], + "color": "#008d36" + }, + { + "vertices": [ + 9, + 16 + ], + "color": "#008d36" + }, + { + "vertices": [ + 6, + 15 + ], + "color": "#008d36" + }, + { + "vertices": [ + 8, + 17 + ], + "color": "#008d36" + }, + { + "vertices": [ + 8, + 13 + ], + "color": "#008d36" + }, + { + "vertices": [ + 6, + 12 + ], + "color": "#008d36" + }, + { + "vertices": [ + 7, + 16 + ], + "color": "#008d36" + }, + { + "vertices": [ + 7, + 14 + ], + "color": "#008d36" + }, + { + "vertices": [ + 13, + 18 + ], + "color": "#008d36" + }, + { + "vertices": [ + 19, + 13 + ], + "color": "#008d36" + }, + { + "vertices": [ + 14, + 20 + ], + "color": "#008d36" + }, + { + "vertices": [ + 17, + 21 + ], + "color": "#008d36" + }, + { + "vertices": [ + 22, + 12 + ], + "color": "#008d36" + }, + { + "vertices": [ + 23, + 14 + ], + "color": "#008d36" + }, + { + "vertices": [ + 12, + 19 + ], + "color": "#008d36" + }, + { + "vertices": [ + 24, + 17 + ], + "color": "#008d36" + }, + { + "vertices": [ + 22, + 6 + ], + "color": "#007695" + }, + { + "vertices": [ + 18, + 8 + ], + "color": "#007695" + }, + { + "vertices": [ + 23, + 7 + ], + "color": "#007695" + }, + { + "vertices": [ + 25, + 6 + ], + "color": "#007695" + }, + { + "vertices": [ + 26, + 7 + ], + "color": "#007695" + }, + { + "vertices": [ + 24, + 8 + ], + "color": "#007695" + }, + { + "vertices": [ + 18, + 27 + ], + "color": "#008d36" + }, + { + "vertices": [ + 28, + 19 + ], + "color": "#008d36" + }, + { + "vertices": [ + 20, + 29 + ], + "color": "#008d36" + }, + { + "vertices": [ + 27, + 24 + ], + "color": "#008d36" + }, + { + "vertices": [ + 30, + 22 + ], + "color": "#008d36" + }, + { + "vertices": [ + 21, + 31 + ], + "color": "#008d36" + }, + { + "vertices": [ + 32, + 23 + ], + "color": "#008d36" + }, + { + "vertices": [ + 17, + 33 + ], + "color": "#008d36" + }, + { + "vertices": [ + 15, + 29 + ], + "color": "#008d36" + }, + { + "vertices": [ + 14, + 34 + ], + "color": "#008d36" + }, + { + "vertices": [ + 12, + 28 + ], + "color": "#008d36" + }, + { + "vertices": [ + 16, + 31 + ], + "color": "#008d36" + }, + { + "vertices": [ + 19, + 35 + ], + "color": "#008d36" + }, + { + "vertices": [ + 13, + 35 + ], + "color": "#008d36" + }, + { + "vertices": [ + 15, + 38 + ], + "color": "#008d36" + }, + { + "vertices": [ + 16, + 41 + ], + "color": "#008d36" + }, + { + "vertices": [ + 14, + 37 + ], + "color": "#008d36" + }, + { + "vertices": [ + 13, + 40 + ], + "color": "#008d36" + }, + { + "vertices": [ + 17, + 39 + ], + "color": "#008d36" + }, + { + "vertices": [ + 12, + 36 + ], + "color": "#008d36" + }, + { + "vertices": [ + 29, + 38 + ], + "color": "#008d36" + }, + { + "vertices": [ + 31, + 41 + ], + "color": "#008d36" + }, + { + "vertices": [ + 38, + 30 + ], + "color": "#008d36" + }, + { + "vertices": [ + 41, + 32 + ], + "color": "#008d36" + }, + { + "vertices": [ + 35, + 40 + ], + "color": "#008d36" + }, + { + "vertices": [ + 40, + 27 + ], + "color": "#008d36" + }, + { + "vertices": [ + 38, + 25 + ], + "color": "#007695" + }, + { + "vertices": [ + 37, + 23 + ], + "color": "#007695" + }, + { + "vertices": [ + 41, + 26 + ], + "color": "#007695" + }, + { + "vertices": [ + 39, + 24 + ], + "color": "#007695" + }, + { + "vertices": [ + 40, + 18 + ], + "color": "#007695" + }, + { + "vertices": [ + 36, + 22 + ], + "color": "#007695" + }, + { + "vertices": [ + 27, + 39 + ], + "color": "#008d36" + }, + { + "vertices": [ + 36, + 28 + ], + "color": "#008d36" + }, + { + "vertices": [ + 37, + 41 + ], + "color": "#007695" + }, + { + "vertices": [ + 36, + 38 + ], + "color": "#007695" + }, + { + "vertices": [ + 39, + 40 + ], + "color": "#007695" + }, + { + "vertices": [ + 28, + 42 + ], + "color": "#008d36" + }, + { + "vertices": [ + 34, + 43 + ], + "color": "#008d36" + }, + { + "vertices": [ + 35, + 42 + ], + "color": "#008d36" + }, + { + "vertices": [ + 29, + 43 + ], + "color": "#008d36" + }, + { + "vertices": [ + 33, + 44 + ], + "color": "#008d36" + }, + { + "vertices": [ + 31, + 44 + ], + "color": "#008d36" + }, + { + "vertices": [ + 36, + 42 + ], + "color": "#007695" + }, + { + "vertices": [ + 39, + 44 + ], + "color": "#007695" + }, + { + "vertices": [ + 38, + 43 + ], + "color": "#007695" + }, + { + "vertices": [ + 41, + 44 + ], + "color": "#007695" + }, + { + "vertices": [ + 37, + 43 + ], + "color": "#007695" + }, + { + "vertices": [ + 40, + 42 + ], + "color": "#007695" + }, + { + "vertices": [ + 41, + 45 + ], + "color": "#008d36" + }, + { + "vertices": [ + 38, + 46 + ], + "color": "#008d36" + }, + { + "vertices": [ + 40, + 47 + ], + "color": "#008d36" + }, + { + "vertices": [ + 38, + 48 + ], + "color": "#008d36" + }, + { + "vertices": [ + 40, + 49 + ], + "color": "#008d36" + }, + { + "vertices": [ + 41, + 50 + ], + "color": "#008d36" + }, + { + "vertices": [ + 39, + 47 + ], + "color": "#008d36" + }, + { + "vertices": [ + 37, + 51 + ], + "color": "#008d36" + }, + { + "vertices": [ + 39, + 52 + ], + "color": "#008d36" + }, + { + "vertices": [ + 36, + 48 + ], + "color": "#008d36" + }, + { + "vertices": [ + 36, + 53 + ], + "color": "#008d36" + }, + { + "vertices": [ + 37, + 50 + ], + "color": "#008d36" + }, + { + "vertices": [ + 44, + 45 + ], + "color": "#007695" + }, + { + "vertices": [ + 43, + 46 + ], + "color": "#007695" + }, + { + "vertices": [ + 43, + 51 + ], + "color": "#007695" + }, + { + "vertices": [ + 44, + 52 + ], + "color": "#007695" + }, + { + "vertices": [ + 42, + 49 + ], + "color": "#007695" + }, + { + "vertices": [ + 42, + 53 + ], + "color": "#007695" + } + ], + "panels": [] +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/online/public/models/pieces-aceg.vZome b/online/public/models/pieces-aceg.vZome index 19dcc98e1..bf2186648 100644 --- a/online/public/models/pieces-aceg.vZome +++ b/online/public/models/pieces-aceg.vZome @@ -1072,7 +1072,7 @@ - + @@ -1097,7 +1097,7 @@ - + @@ -1126,7 +1126,7 @@ - + @@ -1151,7 +1151,7 @@ - + @@ -1185,7 +1185,7 @@ - + @@ -1281,7 +1281,7 @@ - + diff --git a/online/public/models/pieces-bdfh.vZome b/online/public/models/pieces-bdfh.vZome index 8625c5361..7dd2b6cc8 100644 --- a/online/public/models/pieces-bdfh.vZome +++ b/online/public/models/pieces-bdfh.vZome @@ -1037,7 +1037,7 @@ - + @@ -1126,7 +1126,7 @@ - + @@ -1162,7 +1162,7 @@ - + @@ -1187,7 +1187,7 @@ - + @@ -1230,7 +1230,7 @@ - + @@ -1281,7 +1281,7 @@ - + diff --git a/online/src/app/59icosahedra/index.jsx b/online/src/app/59icosahedra/index.jsx index c3a6a4af1..614fee104 100644 --- a/online/src/app/59icosahedra/index.jsx +++ b/online/src/app/59icosahedra/index.jsx @@ -11,7 +11,7 @@ import { SceneCanvas } from '../../viewer/solid/index.jsx' import { getModelURL } from '../classic/components/folder.jsx'; import { RotationProvider } from "../../viewer/solid/rotation.jsx"; import { InteractionToolProvider } from '../../viewer/solid/interaction.jsx'; -import { CellSelectorTool } from './selector.jsx'; +import { CellSelectorTool, MacroTriggerTool } from './selector.jsx'; // We must have this split using WorkerStateProvider and useWorkerClient because // LightedCameraControls and TrackballControls require the WorkerStateProvider anyway. @@ -85,8 +85,11 @@ const App = () => ( - - + + + + + diff --git a/online/src/app/59icosahedra/macros.js b/online/src/app/59icosahedra/macros.js new file mode 100644 index 000000000..297b4162e --- /dev/null +++ b/online/src/app/59icosahedra/macros.js @@ -0,0 +1,213 @@ + +export const c = [ + { + "controllerPath": "strutBuilder:tools:tool-32", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tetrahedral.tool-2", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "ColorManifestations/d40202ff", + "parameters": {} + }, + { + "controllerPath": "", + "action": "DeselectAll", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-32", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tetrahedral.tool-3", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "ColorManifestations/ffd814ff", + "parameters": {} + }, + { + "controllerPath": "", + "action": "DeselectAll", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-32", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "ColorManifestations/1430ffff", + "parameters": {} + }, + { + "controllerPath": "", + "action": "DeselectAll", + "parameters": {} + }, + { + "controllerPath": "undoRedo", + "action": "undo", + "parameters": {} + }, + { + "controllerPath": "undoRedo", + "action": "undo", + "parameters": {} + }, + { + "controllerPath": "undoRedo", + "action": "undo", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tetrahedral.tool-4", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "DeselectAll", + "parameters": {} + }, + { + "controllerPath": "undoRedo", + "action": "undo", + "parameters": {} + }, + { + "controllerPath": "undoRedo", + "action": "undo", + "parameters": {} + }, + { + "controllerPath": "undoRedo", + "action": "undo", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tetrahedral.tool-4", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "ColorManifestations/1a34ffff", + "parameters": {} + }, + { + "controllerPath": "", + "action": "DeselectAll", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-32", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tetrahedral.tool-5", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "ColorManifestations/ff811aff", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-32", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tool-29", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "strutBuilder:tools:tetrahedral.tool-6", + "action": "apply", + "parameters": {} + }, + { + "controllerPath": "", + "action": "ColorManifestations/069b03ff", + "parameters": {} + }, + { + "controllerPath": "", + "action": "DeselectAll", + "parameters": {} + } +]; diff --git a/online/src/app/59icosahedra/selector.jsx b/online/src/app/59icosahedra/selector.jsx index 3f27e6584..bf1457ad3 100644 --- a/online/src/app/59icosahedra/selector.jsx +++ b/online/src/app/59icosahedra/selector.jsx @@ -4,6 +4,8 @@ import { createEffect } from "solid-js"; import { useWorkerClient } from "../../workerClient/index.js"; import { useInteractionTool } from "../../viewer/solid/interaction.jsx"; import { controllerAction, subController } from "../../workerClient/controllers-solid.js"; +import { c } from './macros.js'; +import { doControllerMacro } from "../../workerClient/actions.js"; export const CellSelectorTool = props => { @@ -14,9 +16,13 @@ export const CellSelectorTool = props => allowTrackball: true, - onClick: ( id, position, type, selected ) => { - if ( !type ) { // a panel + onClick: ( id, position, type, selected, label ) => { + if ( !!label ) { // a labeled panel controllerAction( pickingController(), 'SelectManifestation', { id } ) + console.log( selected? 'deselecting' : 'selecting', label ); + if ( selected && label === 'c' ) { + + } } }, @@ -36,3 +42,30 @@ export const CellSelectorTool = props => return null; } + +export const MacroTriggerTool = props => +{ + const { postMessage } = useWorkerClient(); + + const handlers = { + + allowTrackball: true, + + onClick: ( id, position, type, selected, label ) => {}, + + bkgdClick: () => + { + postMessage( doControllerMacro( c ) ); + }, + + onDragStart: ( id, position, type, starting, evt ) => {}, + onDrag: evt => {}, + onDragEnd: evt => {}, + onContextMenu: ( id, position, type, selected ) => {} + }; + + const [ _, setTool ] = useInteractionTool(); + createEffect( () => setTool( handlers ) ); + + return null; +} diff --git a/online/src/viewer/solid/geometry.jsx b/online/src/viewer/solid/geometry.jsx index 3d928fb24..36827656e 100644 --- a/online/src/viewer/solid/geometry.jsx +++ b/online/src/viewer/solid/geometry.jsx @@ -33,7 +33,7 @@ const Instance = ( props ) => const handler = tool && tool() ?.onClick; if ( handler ) { e.stopPropagation() - handler( props.id, props.position, props.type, props.selected ) + handler( props.id, props.position, props.type, props.selected, props.label ) } } const handleContextMenu = ( e ) => diff --git a/online/src/worker/legacy/controllers/wrapper.js b/online/src/worker/legacy/controllers/wrapper.js index 03d29139f..3a84bf443 100644 --- a/online/src/worker/legacy/controllers/wrapper.js +++ b/online/src/worker/legacy/controllers/wrapper.js @@ -9,6 +9,7 @@ export class ControllerWrapper{ this.__clientEvents = clientEvents; this.__changeTables = {}; this.children = {}; + this.macro = []; } createChildWrapper(name, controller) { @@ -94,7 +95,17 @@ export class ControllerWrapper{ wrapper.controller.setProperty( name, value ); } - doAction(controllerPath, action, parameters = {}) { + doAction( controllerPath, action, parameters = {} ) + { + // Macro recording + // if ( action === 'undoAll' ) { + // if ( !!this.macro.length ) + // console.log( JSON.stringify( this.macro, null, 2 ) ); + // this.macro = []; + // } else { + // this.macro .push( { controllerPath, action, parameters } ); + // } + const controllerNames = controllerPath ? controllerPath.split(':') : []; const wrapper = this.getSubControllerByNames(controllerNames); if (parameters && Object.keys(parameters).length !== 0) diff --git a/online/src/worker/legacy/core.js b/online/src/worker/legacy/core.js index cd19c3220..22e222c52 100644 --- a/online/src/worker/legacy/core.js +++ b/online/src/worker/legacy/core.js @@ -217,8 +217,20 @@ const makeFloatMatrices = ( matrices ) => } const editClass = xmlToEditClass( editName ) - if ( editClass ) - return new editClass( editor ) + if ( editClass ) { + const edit = new editClass( editor ); + + // HACK! This works only when the .vZome file has been hand-edited to add label + // attributes to GroupSelection commands. + if ( editName === 'GroupSelection' ) { + const label = xmlElement .getAttribute( "label" ); + if ( label ) { + edit .label = label; + } + } + + return edit; + } else return new vzomePkg.core.editor.CommandEdit( null, editor ) } @@ -523,6 +535,18 @@ const makeFloatMatrices = ( matrices ) => const edit = editFactory( editor, toolFactories, toolsModel )( wrappedElement ) if ( ! edit ) // Null edit only happens for expected cases (e.g. "Shapshot"); others become CommandEdit. return null // Not indicating failure, just indicating nothing to record in history + + // HACK! This works only when the .vZome file has been hand-edited to add label + // attributes to GroupSelection commands. + if ( xmlElement.tagName === 'GroupSelection' && !!edit.label ) { + console.log( `Performed GroupSelection with label ${edit.label}`); + const selection = edit.mSelection; // HACK! violating encapsulation + for (let index = selection.mManifestations.iterator(); index.hasNext(); ) { + let m = index.next(); + m .mRendered .label = edit.label; + } + } + edit.loadAndPerform( wrappedElement, format, context ) checkSideEffects( edit, wrappedElement ); diff --git a/online/src/worker/legacy/scenes.js b/online/src/worker/legacy/scenes.js index ee8b70d56..30ef1e1b9 100644 --- a/online/src/worker/legacy/scenes.js +++ b/online/src/worker/legacy/scenes.js @@ -26,6 +26,7 @@ export const toWebColor = color => export const normalizeRenderedManifestation = rm => { const id = rm.getGuid().toString(); + const label = rm.label; const type = rm .getShape() .name; const shapeId = 's' + rm.getShapeId().toString(); const positionAV = rm.getLocationAV(); @@ -38,7 +39,7 @@ export const normalizeRenderedManifestation = rm => } let color = toWebColor( rm.getColor() ); - return { id, position: [ x, y, z ], rotation, color, selected, shapeId, type }; + return { id, position: [ x, y, z ], rotation, color, selected, shapeId, type, label }; } export const renderedModelTransducer = ( shapeCache, clientEvents ) => diff --git a/online/src/worker/vzome-worker-static.js b/online/src/worker/vzome-worker-static.js index cc653a4e9..d21cc8a37 100644 --- a/online/src/worker/vzome-worker-static.js +++ b/online/src/worker/vzome-worker-static.js @@ -388,6 +388,22 @@ onmessage = ({ data }) => break; } + case 'MACRO_TRIGGERED': + { + try { + for (const actionData of payload) { + const { controllerPath, action, parameters } = actionData; + designWrapper .doAction( controllerPath, action, parameters ); + } + const { shapes, embedding } = designWrapper .getScene( '--END--', true ); // never send camera or lighting! + postMessage( { type: 'SCENE_RENDERED', payload: { scene: { shapes, embedding } } } ); + } catch (error) { + console.log( `Macro error: ${error.message}` ); + postMessage( { type: 'ALERT_RAISED', payload: `Failed to complete macro.` } ); + } + break; + } + case 'ACTION_TRIGGERED': { const { controllerPath, action, parameters } = payload; diff --git a/online/src/workerClient/actions.js b/online/src/workerClient/actions.js index 62bf73075..cd85ca636 100644 --- a/online/src/workerClient/actions.js +++ b/online/src/workerClient/actions.js @@ -37,6 +37,8 @@ export const newDesign = ( field='golden' ) => workerAction( 'NEW_DESIGN_STARTED export const doControllerAction = ( controllerPath='', action, parameters ) => workerAction( 'ACTION_TRIGGERED', { controllerPath, action, parameters } ); +export const doControllerMacro = ( actions ) => workerAction( 'MACRO_TRIGGERED', actions ); + export const requestControllerProperty = ( controllerPath='', propName, changeName=propName, isList=false ) => workerAction( 'PROPERTY_REQUESTED', { controllerPath, propName, changeName, isList } ); export const setControllerProperty = ( controllerPath='', name, value ) => workerAction( 'PROPERTY_SET', { controllerPath, name, value } ); diff --git a/online/src/workerClient/controllers-solid.js b/online/src/workerClient/controllers-solid.js index c32725038..e7db0be8e 100644 --- a/online/src/workerClient/controllers-solid.js +++ b/online/src/workerClient/controllers-solid.js @@ -201,6 +201,8 @@ const createWorkerStore = ( worker ) => case 'SYMMETRY_CHANGED': case 'DESIGN_XML_PARSED': + case 'LAST_BALL_CREATED': + case 'DESIGN_XML_SAVED': // TODO these are not implemented yet! break;