@johnoscott/isometric-engine 0.12.6 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/EDITOR-GUIDE.md +9 -2
  2. package/README.md +1 -1
  3. package/assets/app.css +6 -0
  4. package/assets/marks.css +2 -0
  5. package/iso-editor.js +194 -184
  6. package/iso-render.js +157 -148
  7. package/iso-systems.js +170 -159
  8. package/js/iso-editor/make-way.js +62 -0
  9. package/js/iso-editor/ui/canvas.js +477 -216
  10. package/js/iso-editor/ui/palette-look.js +53 -0
  11. package/js/iso-editor/ui/setup.js +3 -0
  12. package/js/iso-objects/ants.js +36 -0
  13. package/js/iso-objects/index.js +47 -1
  14. package/js/iso-objects/looks.js +25 -0
  15. package/js/iso-objects/motion-builder.js +130 -0
  16. package/js/iso-objects/motion-doc.js +500 -0
  17. package/js/iso-objects/motion-entry.js +32 -0
  18. package/js/iso-objects/motion.js +635 -0
  19. package/js/iso-objects/resolve.js +238 -0
  20. package/js/iso-objects/scene.js +15 -13
  21. package/js/iso-objects/timeline.js +553 -0
  22. package/js/iso-systems/compile.js +59 -1
  23. package/js/iso-systems/index.js +4 -1
  24. package/js/iso-systems/render.js +20 -0
  25. package/js/iso-systems/schema.json +39 -0
  26. package/js/iso-viewer/page.js +2 -1
  27. package/js/iso-viewer/player.js +23 -34
  28. package/package.json +46 -1
  29. package/src/iso-editor/make-way.ts +89 -0
  30. package/src/iso-editor/ui/app.css +4 -0
  31. package/src/iso-editor/ui/canvas.ts +390 -170
  32. package/src/iso-editor/ui/marks.css +2 -0
  33. package/src/iso-editor/ui/palette-look.ts +51 -0
  34. package/src/iso-editor/ui/setup.ts +8 -0
  35. package/src/iso-objects/ants.ts +53 -0
  36. package/src/iso-objects/compile.ts +4 -1
  37. package/src/iso-objects/index.ts +14 -1
  38. package/src/iso-objects/looks.ts +21 -0
  39. package/src/iso-objects/motion-builder.ts +79 -0
  40. package/src/iso-objects/motion-doc.ts +361 -0
  41. package/src/iso-objects/motion-entry.ts +12 -0
  42. package/src/iso-objects/motion.ts +616 -0
  43. package/src/iso-objects/resolve.ts +196 -0
  44. package/src/iso-objects/scene.ts +29 -13
  45. package/src/iso-objects/timeline.ts +443 -0
  46. package/src/iso-objects/types.ts +20 -2
  47. package/src/iso-systems/compile.ts +58 -3
  48. package/src/iso-systems/index.ts +4 -1
  49. package/src/iso-systems/render.ts +41 -0
  50. package/src/iso-systems/schema.json +39 -0
  51. package/src/iso-viewer/page.ts +2 -1
  52. package/src/iso-viewer/player.ts +24 -41
  53. package/types/iso-editor/make-way.d.ts +40 -0
  54. package/types/iso-editor/ui/canvas.d.ts +33 -12
  55. package/types/iso-editor/ui/palette-look.d.ts +5 -0
  56. package/types/iso-editor/ui/setup.d.ts +5 -0
  57. package/types/iso-objects/ants.d.ts +33 -0
  58. package/types/iso-objects/compile.d.ts +3 -0
  59. package/types/iso-objects/index.d.ts +14 -1
  60. package/types/iso-objects/looks.d.ts +4 -0
  61. package/types/iso-objects/motion-builder.d.ts +105 -0
  62. package/types/iso-objects/motion-doc.d.ts +787 -0
  63. package/types/iso-objects/motion-entry.d.ts +10 -0
  64. package/types/iso-objects/motion.d.ts +200 -0
  65. package/types/iso-objects/resolve.d.ts +20 -0
  66. package/types/iso-objects/scene.d.ts +11 -0
  67. package/types/iso-objects/timeline.d.ts +46 -0
  68. package/types/iso-objects/types.d.ts +32 -0
  69. package/types/iso-systems/compile.d.ts +20 -3
  70. package/types/iso-systems/index.d.ts +4 -1
  71. package/types/iso-systems/render.d.ts +21 -0
@@ -0,0 +1,62 @@
1
+ const DWELL_HINT = 150;
2
+ const DWELL_GIVE = 700;
3
+ const BACK_AFTER = 250;
4
+ const GLIDE = 180;
5
+ const JIGGLE = { px: 1.5, hz: 8 };
6
+ const MAX_CHAIN = 3;
7
+ const E = 1e-6;
8
+ const hits = (a, b) => a.x0 < b.x1 - E && a.x1 > b.x0 + E && a.y0 < b.y1 - E && a.y1 > b.y0 + E;
9
+ const at = (b, [dx, dy]) => ({ x0: b.x0 + dx, y0: b.y0 + dy, x1: b.x1 + dx, y1: b.y1 + dy });
10
+ function makeWay({ foot, others, going, bounds, max = MAX_CHAIN }) {
11
+ const first = others.filter((o) => hits(o, foot));
12
+ if (!first.length) return /* @__PURE__ */ new Map();
13
+ if (first.some((o) => !o.movable)) return void 0;
14
+ const ways = [[1, 0], [-1, 0], [0, 1], [0, -1]];
15
+ let best;
16
+ for (const w of ways) {
17
+ const along = w[0] * going[0] + w[1] * going[1];
18
+ if (along < 0 && Math.abs(along) >= Math.max(Math.abs(going[0]), Math.abs(going[1])) - E) continue;
19
+ const steps = push(foot, others, w, bounds, max);
20
+ if (!steps) continue;
21
+ const cells = [...steps.values()].reduce((n, [dx, dy]) => n + Math.abs(dx) + Math.abs(dy), 0);
22
+ if (!best || cells < best.cells || cells === best.cells && along > best.along + E) best = { steps, cells, along };
23
+ }
24
+ return best?.steps;
25
+ }
26
+ function push(foot, others, w, bounds, max) {
27
+ const far = /* @__PURE__ */ new Map();
28
+ const byId = new Map(others.map((o) => [o.id, o]));
29
+ const boxOf = (o) => at(o, [w[0] * (far.get(o.id) ?? 0), w[1] * (far.get(o.id) ?? 0)]);
30
+ const queue = [void 0];
31
+ for (let guard = 0; queue.length; guard++) {
32
+ if (guard > 100) return void 0;
33
+ const id = queue.shift(), by = id === void 0 ? foot : boxOf(byId.get(id));
34
+ for (const o of others) {
35
+ if (o.id === id) continue;
36
+ const b = boxOf(o);
37
+ if (!hits(b, by)) continue;
38
+ if (!o.movable) return void 0;
39
+ const gap = w[0] > 0 ? by.x1 - b.x0 : w[0] < 0 ? b.x1 - by.x0 : w[1] > 0 ? by.y1 - b.y0 : b.y1 - by.y0;
40
+ far.set(o.id, (far.get(o.id) ?? 0) + Math.max(1, Math.ceil(gap - E)));
41
+ if (far.size > max) return void 0;
42
+ if (!queue.includes(o.id)) queue.push(o.id);
43
+ }
44
+ }
45
+ const steps = new Map([...far].map(([id, n]) => [id, [w[0] * n, w[1] * n]]));
46
+ for (const id of steps.keys()) {
47
+ const o = byId.get(id), b = boxOf(o);
48
+ if (hits(b, foot) || others.some((q) => q.id !== id && hits(b, boxOf(q)))) return void 0;
49
+ if (bounds && (b.x0 < bounds.x0 - E || b.y0 < bounds.y0 - E || b.x1 > bounds.x1 + E || b.y1 > bounds.y1 + E)) return void 0;
50
+ }
51
+ return steps;
52
+ }
53
+ export {
54
+ BACK_AFTER,
55
+ DWELL_GIVE,
56
+ DWELL_HINT,
57
+ GLIDE,
58
+ JIGGLE,
59
+ MAX_CHAIN,
60
+ hits,
61
+ makeWay
62
+ };