@entro314labs/iso-engine 0.0.0-stage → 0.5.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.
- package/LICENSE +21 -0
- package/README.md +165 -2
- package/THIRD_PARTY_NOTICES.md +39 -0
- package/dist/engine/anim.js +225 -0
- package/dist/engine/behaviors.js +105 -0
- package/dist/engine/diagram.js +80 -0
- package/dist/engine/draw.js +117 -0
- package/dist/engine/export.js +81 -0
- package/dist/engine/figure.js +35 -0
- package/dist/engine/global.js +4 -0
- package/dist/engine/index.d.ts +278 -0
- package/dist/engine/index.js +164 -0
- package/dist/engine/math.js +190 -0
- package/dist/engine/node.js +290 -0
- package/dist/engine/paths.js +76 -0
- package/dist/engine/prefabs/architecture.js +136 -0
- package/dist/engine/prefabs/basics.js +131 -0
- package/dist/engine/prefabs/devices.js +295 -0
- package/dist/engine/prefabs/icons.js +49 -0
- package/dist/engine/prefabs/index.js +12 -0
- package/dist/engine/prefabs/logistics.js +156 -0
- package/dist/engine/scene.js +466 -0
- package/dist/engine/shapes.js +781 -0
- package/dist/engine/sort.js +153 -0
- package/dist/engine/spec.js +81 -0
- package/dist/engine/style.js +87 -0
- package/dist/engine.css +1 -0
- package/dist/figure.css +93 -0
- package/dist/figure.d.ts +22 -0
- package/dist/figure.js +73 -0
- package/dist/filters.d.ts +9 -0
- package/dist/filters.js +22 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +8 -0
- package/dist/iso.global.js +7990 -0
- package/dist/kernel.d.ts +102 -0
- package/dist/kernel.js +172 -0
- package/dist/loops.d.ts +49 -0
- package/dist/loops.js +64 -0
- package/dist/patterns.d.ts +44 -0
- package/dist/patterns.js +97 -0
- package/dist/theme.css +19 -0
- package/dist/types.d.ts +86 -0
- package/dist/types.js +1 -0
- package/package.json +50 -4
- package/skills/iso-engine/SKILL.md +143 -0
- package/skills/iso-engine/examples/engine.html +42 -0
- package/skills/iso-engine/examples/figure.html +51 -0
- package/skills/iso-engine/examples/loop.html +68 -0
- package/skills/iso-engine/examples/loop.js +36 -0
- package/skills/iso-engine/examples/matcher.js +134 -0
- package/skills/iso-engine/examples/spec.html +42 -0
- package/skills/iso-engine/references/animation.md +116 -0
- package/skills/iso-engine/references/api.md +207 -0
- package/skills/iso-engine/references/composition.md +66 -0
- package/skills/iso-engine/references/diagrams.md +68 -0
- package/skills/iso-engine/references/figures.md +359 -0
- package/skills/iso-engine/references/loops.md +126 -0
- package/skills/iso-engine/references/prefabs.md +103 -0
- package/skills/iso-engine/references/spec.md +66 -0
- package/skills/iso-engine/references/style.md +76 -0
- package/skills/iso-engine/references/troubleshooting.md +49 -0
- package/skills/iso-engine/scripts/build.mjs +35 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { pathData, cssClass } from '../math.js';
|
|
2
|
+
|
|
3
|
+
/* Line icons on a 24-unit grid (stroke only, round caps). Drawn for this engine.
|
|
4
|
+
Use them on faces: face.svg(Iso.icon('database'), { transform: 'scale(0.5)' }) or the `block` prefab. */
|
|
5
|
+
export const ICONS = {
|
|
6
|
+
database: 'M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3ZM4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3',
|
|
7
|
+
server: 'M4 4h16v6H4zM4 14h16v6H4zM7.5 7h.01M7.5 17h.01M11 7h5M11 17h5',
|
|
8
|
+
user: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM4 21c0-4 3.6-6 8-6s8 2 8 6',
|
|
9
|
+
users: 'M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7ZM2.5 20c0-3.5 2.9-5.5 6.5-5.5s6.5 2 6.5 5.5M16 4.3a3.5 3.5 0 0 1 0 6.4M18 14.8c2.1.6 3.5 2.4 3.5 5.2',
|
|
10
|
+
lock: 'M6 11h12v10H6zM8.5 11V8a3.5 3.5 0 0 1 7 0v3M12 15v2',
|
|
11
|
+
cloud: 'M7 18h10.5a4 4 0 0 0 .4-7.98A6 6 0 0 0 6.3 9 4.5 4.5 0 0 0 7 18Z',
|
|
12
|
+
bolt: 'M13 3 5 14h6l-1 7 8-11h-6l1-7Z',
|
|
13
|
+
globe: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM3 12h18M12 3c2.4 2.5 3.6 5.5 3.6 9s-1.2 6.5-3.6 9c-2.4-2.5-3.6-5.5-3.6-9S9.6 5.5 12 3Z',
|
|
14
|
+
code: 'M8 7l-5 5 5 5M16 7l5 5-5 5M13.5 4l-3 16',
|
|
15
|
+
terminal: 'M3.5 5h17v14h-17zM7 9.5l3 2.5-3 2.5M12 15h5',
|
|
16
|
+
cpu: 'M7 7h10v10H7zM10 10h4v4h-4zM9.5 3.5V7M14.5 3.5V7M9.5 17v3.5M14.5 17v3.5M3.5 9.5H7M3.5 14.5H7M17 9.5h3.5M17 14.5h3.5',
|
|
17
|
+
mail: 'M3 6h18v12H3zM3.5 6.5l8.5 6 8.5-6',
|
|
18
|
+
chart: 'M4 20V11M10 20V5M16 20v-6M2.5 20h19',
|
|
19
|
+
gear: 'M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6ZM12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M5.3 18.7l2.1-2.1M16.6 7.4l2.1-2.1',
|
|
20
|
+
key: 'M8 16a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM12 12h9M18 12v3M21 12v2',
|
|
21
|
+
file: 'M6 3h8l4 4v14H6zM14 3v4h4M9 12h6M9 16h6',
|
|
22
|
+
search: 'M10.5 17.5a7 7 0 1 0 0-14 7 7 0 0 0 0 14ZM15.5 15.5 21 21',
|
|
23
|
+
cart: 'M2.5 4h2.5l2.5 11h11l2-8H6.3M9 19.5h.01M17.5 19.5h.01',
|
|
24
|
+
shield: 'M12 3l8 3v6c0 4.5-3.4 8-8 9-4.6-1-8-4.5-8-9V6l8-3ZM8.5 12l2.5 2.5 4.5-5',
|
|
25
|
+
layers: 'M12 3 2.5 8 12 13l9.5-5L12 3ZM2.5 12.5 12 17.5l9.5-5M2.5 16.5 12 21.5l9.5-5',
|
|
26
|
+
queue: 'M4 6h16M4 12h16M4 18h10',
|
|
27
|
+
plug: 'M9 3v5M15 3v5M6 8h12v3a6 6 0 0 1-12 0V8ZM12 17v4',
|
|
28
|
+
spark: 'M12 3l1.9 5.1L19 10l-5.1 1.9L12 17l-1.9-5.1L5 10l5.1-1.9L12 3ZM18.5 16l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7.7-1.8Z',
|
|
29
|
+
phone: 'M8 2.5h8a1 1 0 0 1 1 1v17a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-17a1 1 0 0 1 1-1ZM11 18.5h2',
|
|
30
|
+
wifi: 'M2.5 9a14 14 0 0 1 19 0M5.8 12.5a9.5 9.5 0 0 1 12.4 0M9 16a5 5 0 0 1 6 0M12 19.5h.01',
|
|
31
|
+
check: 'M5 12.5l4.5 4.5L19 7',
|
|
32
|
+
bell: 'M6 16V11a6 6 0 0 1 12 0v5l1.5 2h-15L6 16ZM10 20.5a2 2 0 0 0 4 0',
|
|
33
|
+
play: 'M8 5v14l11-7L8 5Z',
|
|
34
|
+
box: 'M12 3l8.5 4.5v9L12 21l-8.5-4.5v-9L12 3ZM3.5 7.5 12 12l8.5-4.5M12 12v9',
|
|
35
|
+
card: 'M3 6h18v12H3zM3 10h18M6.5 14.5h4',
|
|
36
|
+
pin: 'M12 21s-6.5-6-6.5-11a6.5 6.5 0 0 1 13 0c0 5-6.5 11-6.5 11ZM12 12.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z',
|
|
37
|
+
eye: 'M2.5 12s3.5-6.5 9.5-6.5 9.5 6.5 9.5 6.5-3.5 6.5-9.5 6.5S2.5 12 2.5 12ZM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z',
|
|
38
|
+
clock: 'M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18ZM12 7v5l3.5 2',
|
|
39
|
+
flow: 'M5 6.5a2.5 2.5 0 1 0 0-.01M19 17.5a2.5 2.5 0 1 0 0-.01M7.5 6.5H13a3 3 0 0 1 3 3v5a3 3 0 0 0 3 3',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/* A 9×9 pixel mark (filled), used as the default logo on devices. */
|
|
43
|
+
export const MARK = 'M0 0h3v3H0zM6 0h3v3H6zM3 3h3v3H3zM0 6h3v3H0zM6 6h3v3H6z';
|
|
44
|
+
|
|
45
|
+
/* a built-in icon by name, or raw path data (anything else is dropped) */
|
|
46
|
+
export function iconPath(name) { return ICONS[name] || pathData(name); }
|
|
47
|
+
export function icon(name, cls = 'ln-strong') {
|
|
48
|
+
return '<path class="' + cssClass(cls) + '" d="' + iconPath(name) + '"/>';
|
|
49
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import basics from './basics.js';
|
|
2
|
+
import devices from './devices.js';
|
|
3
|
+
import architecture from './architecture.js';
|
|
4
|
+
import logistics from './logistics.js';
|
|
5
|
+
export { ICONS, MARK, icon, iconPath } from './icons.js';
|
|
6
|
+
|
|
7
|
+
export function installPrefabs(define, Iso) {
|
|
8
|
+
basics(define, Iso);
|
|
9
|
+
devices(define, Iso);
|
|
10
|
+
architecture(define, Iso);
|
|
11
|
+
logistics(define, Iso);
|
|
12
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/* Logistics prefabs: parcel, pallet, rack, forklift, truck, scanner, tunnel.
|
|
2
|
+
Local origin = centre of the footprint at the base; `at` and `rot` place the prefab. */
|
|
3
|
+
import { rng } from '../math.js';
|
|
4
|
+
|
|
5
|
+
export default function install(define) {
|
|
6
|
+
/* Cardboard box. open: flaps up and a dark mouth; otherwise taped. label: a printed sticker on the
|
|
7
|
+
front (+y) face; `labelLit` makes it glow-free bright. API: open(bool), label(bool). */
|
|
8
|
+
define('parcel', (g, o) => {
|
|
9
|
+
const [w, d, h] = o.size || [16, 13, 11];
|
|
10
|
+
const mat = o.material ?? 'paper', id = (s) => (o.id ? o.id + '-' + s : undefined);
|
|
11
|
+
g.box({ at: [-w / 2, -d / 2, 0], size: [w, d, h], r: 0.5, material: mat, color: o.color });
|
|
12
|
+
/* taped state */
|
|
13
|
+
const tapes = [
|
|
14
|
+
g.rect({ id: id('tape'), class: 'tape', at: [-w / 2, -1.1, h], size: [w, 2.2], fill: 'f-bevel', line: 'ln-faint', material: mat }),
|
|
15
|
+
g.pane({ id: id('tape-side'), class: 'tape', plane: 'right', at: [w / 2, 1.1, h], w: 2.2, h: h * 0.42, fill: 'f-bevel', line: 'ln-faint', material: mat }),
|
|
16
|
+
];
|
|
17
|
+
/* open state: a dark mouth and four flaps leaning out */
|
|
18
|
+
const a = ((o.flapAngle ?? 32) * Math.PI) / 180, s = Math.sin(a), c = Math.cos(a), ft = 0.5;
|
|
19
|
+
const fd = d * 0.46, fw = w * 0.36;
|
|
20
|
+
const open = [
|
|
21
|
+
g.rect({ id: id('mouth'), at: [-w / 2 + 0.7, -d / 2 + 0.7, h], size: [w - 1.4, d - 1.4], fill: 'f-dark', line: 'ln-soft' }),
|
|
22
|
+
g.slab({ origin: [-w / 2, -d / 2, h], u: [w, 0, 0], v: [0, -s * fd, c * fd], w: [0, c * ft, s * ft], material: mat }),
|
|
23
|
+
g.slab({ origin: [-w / 2, -d / 2, h], u: [0, d, 0], v: [-s * fw, 0, c * fw], w: [c * ft, 0, s * ft], material: mat }),
|
|
24
|
+
g.slab({ origin: [w / 2, -d / 2, h], u: [0, d, 0], v: [s * fw, 0, c * fw], w: [-c * ft, 0, s * ft], material: mat }),
|
|
25
|
+
g.slab({ origin: [-w / 2, d / 2, h], u: [w, 0, 0], v: [0, s * fd, c * fd], w: [0, -c * ft, s * ft], material: mat }),
|
|
26
|
+
];
|
|
27
|
+
/* printed label on the front face */
|
|
28
|
+
const lw = Math.min(w * 0.46, 9), lh = Math.min(h * 0.42, 5);
|
|
29
|
+
const label = g.pane({
|
|
30
|
+
id: id('label'), class: 'label', plane: 'left', at: [w / 2 - lw - 1.6, d / 2, h * 0.78], w: lw, h: lh, r: 0.4,
|
|
31
|
+
fill: o.labelLit === false ? 'f-bg' : 'f-lit', line: 'ln-faint',
|
|
32
|
+
draw: (f) => { for (let i = 0; i < 6; i++) f.line(1 + i * (lw - 2) / 5.5, lh * 0.45, 1 + i * (lw - 2) / 5.5, lh - 0.8, 'ln-strong'); },
|
|
33
|
+
});
|
|
34
|
+
const apply = (isOpen, hasLabel) => {
|
|
35
|
+
for (const n of tapes) n.set('hidden', isOpen);
|
|
36
|
+
for (const n of open) n.set('hidden', !isOpen);
|
|
37
|
+
label.set('hidden', !hasLabel);
|
|
38
|
+
};
|
|
39
|
+
const state = { open: !!o.open, label: !!o.label };
|
|
40
|
+
apply(state.open, state.label);
|
|
41
|
+
return {
|
|
42
|
+
state,
|
|
43
|
+
open(v = true) { if (state.open !== v) { state.open = v; apply(state.open, state.label); } return this; },
|
|
44
|
+
label(v = true) { if (state.label !== v) { state.label = v; apply(state.open, state.label); } return this; },
|
|
45
|
+
};
|
|
46
|
+
}, { sort: 'none' });
|
|
47
|
+
|
|
48
|
+
/* Wooden pallet, optionally loaded: load: [cols, rows, layers] of taped parcels. */
|
|
49
|
+
define('pallet', (g, o) => {
|
|
50
|
+
const [w, d] = o.size || [30, 26], R = rng(o.seed ?? 4);
|
|
51
|
+
for (const y of [-d / 2, -1.2, d / 2 - 2.4]) g.box({ at: [-w / 2, y, 0], size: [w, 2.4, 2.4], material: o.material });
|
|
52
|
+
const n = 5, bw = (w - (n - 1) * 1.4) / n;
|
|
53
|
+
for (let i = 0; i < n; i++) g.box({ at: [-w / 2 + i * (bw + 1.4), -d / 2, 2.4], size: [bw, d, 1.4], material: o.material });
|
|
54
|
+
if (o.load) {
|
|
55
|
+
const [cols, rows, layers] = o.load, gap = 0.6, top = 3.8;
|
|
56
|
+
const cw = (w - gap * (cols - 1)) / cols, cd = (d - gap * (rows - 1)) / rows, ch = o.boxH ?? Math.min(11, cw * 0.75);
|
|
57
|
+
for (let k = 0; k < layers; k++) for (let j = 0; j < rows; j++) for (let i = 0; i < cols; i++) {
|
|
58
|
+
if (k === layers - 1 && o.partial && R() < o.partial) continue;
|
|
59
|
+
g.parcel({ at: [-w / 2 + cw / 2 + i * (cw + gap), -d / 2 + cd / 2 + j * (cd + gap), top + k * (ch + 0.3)], size: [cw, cd, ch], material: o.boxMaterial });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/* Warehouse rack: four uprights, shelves, parcels on the shelves (seeded). */
|
|
65
|
+
define('rack', (g, o) => {
|
|
66
|
+
const [w, d] = o.size || [70, 24], h = o.h ?? 54, levels = o.levels ?? 3, p = 2.2, R = rng(o.seed ?? 5), fill = o.fill ?? 0.7;
|
|
67
|
+
for (const [x, y] of [[-w / 2, -d / 2], [w / 2 - p, -d / 2], [-w / 2, d / 2 - p], [w / 2 - p, d / 2 - p]]) g.box({ at: [x, y, 0], size: [p, p, h], material: o.material });
|
|
68
|
+
const step = (h - 3) / levels;
|
|
69
|
+
for (let i = 0; i < levels; i++) {
|
|
70
|
+
const z = 2 + i * step;
|
|
71
|
+
g.box({ at: [-w / 2, -d / 2 + p, z], size: [w, d - 2 * p, 1.6], material: o.material, left: (f) => f.hlines(2, 0.8, f.w - 4, 0, 1, 'ln-faint') });
|
|
72
|
+
const slots = Math.max(1, Math.floor((w - 4) / 17));
|
|
73
|
+
const sw = (w - 4) / slots;
|
|
74
|
+
for (let k = 0; k < slots; k++) {
|
|
75
|
+
if (R() > fill) continue;
|
|
76
|
+
const bw = sw * R.range(0.68, 0.86), bd = (d - 2 * p) * R.range(0.62, 0.82), bh = Math.min(step - 3.5, R.range(7, 12));
|
|
77
|
+
g.parcel({ at: [-w / 2 + 2 + sw * (k + 0.5), R.range(-1, 1), z + 1.6], size: [bw, bd, bh], material: o.boxMaterial });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/* Forklift facing +x. lift: fork height. load: carry a loaded pallet. */
|
|
83
|
+
define('forklift', (g, o) => {
|
|
84
|
+
const fz = o.lift ?? 1.4, mat = o.material;
|
|
85
|
+
for (const [x, y] of [[-9.5, -8.2], [4.5, -8.2], [-9.5, 6], [4.5, 6]]) g.box({ at: [x, y, 0], size: [5, 2.2, 5], r: 1, material: 'dark' });
|
|
86
|
+
g.box({ at: [-13, -6.5, 1.5], size: [3, 13, 10], r: 1.5, chamfer: 0.6, material: mat });
|
|
87
|
+
g.box({ at: [-10, -6, 1.5], size: [18, 12, 6.5], r: 2, chamfer: 0.8, material: mat, left: (f) => f.hlines(3, 3, f.w - 6, 0, 1, 'ln-faint') });
|
|
88
|
+
g.box({ at: [-7, -3, 8], size: [5, 6, 3.5], r: 1, material: 'dark' });
|
|
89
|
+
for (const [x, y] of [[-9.6, -5.6], [-1.6, -5.6], [-9.6, 4.6], [-1.6, 4.6]]) g.box({ at: [x, y, 8], size: [1, 1, 14] });
|
|
90
|
+
g.box({ at: [-10, -6, 22], size: [9.5, 12, 1], r: 0.6, material: mat, top: (f) => f.hlines(1.5, 2, f.w - 3, f.h - 4, 4, 'ln-faint') });
|
|
91
|
+
for (const y of [-4.6, 3.4]) g.box({ at: [8, y, 1.2], size: [1.6, 1.2, 26] });
|
|
92
|
+
g.box({ at: [8, -4.6, 26], size: [1.6, 9.2, 1.2] });
|
|
93
|
+
g.box({ at: [9.6, -5, fz], size: [1, 10, 9], material: 'dark' });
|
|
94
|
+
for (const y of [-4, 2.4]) g.box({ at: [10.6, y, fz], size: [13, 1.6, 0.8] });
|
|
95
|
+
if (o.load) g.pallet({ at: [17.4, 0, fz + 0.8], size: [13, 12], load: [1, 1, 2], boxH: 6 });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/* Box truck with its open rear toward +x (backs onto a dock or a conveyor). */
|
|
99
|
+
define('truck', (g, o) => {
|
|
100
|
+
const L = o.length ?? 90, W = o.w ?? 40, H = o.h ?? 44, fl = o.floor ?? 12, mat = o.material;
|
|
101
|
+
for (const x of [L / 2 - 16, L / 2 - 28, -L / 2 - 14]) for (const y of [-W / 2 + 1, W / 2 - 3.4]) g.box({ at: [x, y, 0], size: [9, 2.4, 9], r: 2, material: 'dark' });
|
|
102
|
+
g.box({ at: [-L / 2 - 24, -W / 2 + 4, 4], size: [L + 22, W - 8, fl - 4], material: 'dark' });
|
|
103
|
+
g.box({ at: [-L / 2 - 25, -W / 2 + 2, 6], size: [22, W - 4, fl + 18], r: 3, chamfer: 1, material: mat,
|
|
104
|
+
left: (f) => { f.rect(f.w * 0.5, 4, f.w * 0.42, f.h * 0.38, { r: 1.5, fill: 'f-screen', line: 'ln-soft' }); f.line(f.w * 0.46, 4, f.w * 0.46, f.h - 3, 'ln-faint'); } });
|
|
105
|
+
g.box({
|
|
106
|
+
at: [-L / 2, -W / 2, fl], size: [L, W, H], r: 1.5, chamfer: 1, material: mat,
|
|
107
|
+
left: (f) => { f.vlines(4, 3, f.w - 8, f.h - 6, Math.round(L / 8), 'ln-faint'); if (o.text) f.text(o.text, 8, f.h * 0.62, { size: 6, cls: 'tx tx-label', spacing: 1.5 }); },
|
|
108
|
+
right: (f) => {
|
|
109
|
+
if (o.open === false) { f.hlines(3, 3, f.w - 6, f.h - 6, 10, 'ln-soft'); return; }
|
|
110
|
+
f.rect(2.5, 2.5, f.w - 5, f.h - 4, { r: 1, fill: 'f-dark', line: 'ln' });
|
|
111
|
+
f.hlines(3, 3, f.w - 6, 5, 4, 'ln-faint');
|
|
112
|
+
},
|
|
113
|
+
top: (f) => f.rect(2, 2, f.w - 4, f.h - 4, { r: 1, line: 'ln-faint' }),
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/* Scanner arch over a belt with a lit beam. axis: the belt direction ('x' or 'y').
|
|
118
|
+
w = clear width between posts, h = clearance; beam node id `${id}-beam`, class `scan-beam`. */
|
|
119
|
+
define('scanner', (g, o) => {
|
|
120
|
+
const w = o.w ?? 30, h = o.h ?? 38, t = o.t ?? 4, from = o.beamFrom ?? 0, axis = o.axis || 'x', mat = o.material;
|
|
121
|
+
const id = (s) => (o.id ? o.id + '-' + s : undefined);
|
|
122
|
+
if (axis === 'x') {
|
|
123
|
+
g.box({ at: [-t / 2, -w / 2 - t, 0], size: [t, t, h], r: 0.8, material: mat });
|
|
124
|
+
g.box({ at: [-t / 2, w / 2, 0], size: [t, t, h], r: 0.8, material: mat, left: (f) => f.rect(f.w / 2 - 0.8, 4, 1.6, 1.6, { r: 0.8, fill: 'f-lit', line: null }) });
|
|
125
|
+
g.box({ at: [-t / 2 - 1, -w / 2 - t, h], size: [t + 2, w + 2 * t, 5], r: 1, chamfer: 0.6, material: mat, right: (f) => f.rect(t, 1.6, f.w - 2 * t, 1.4, { r: 0.7, fill: 'f-lit', line: null }) });
|
|
126
|
+
g.pane({ id: id('beam'), class: 'scan-beam', plane: 'right', at: [0, w / 2, h], w, h: h - from, fill: 'f-lit', line: null, material: 'lit', glow: o.glow ?? true, style: { opacity: o.beamOpacity ?? 0.35 } });
|
|
127
|
+
} else {
|
|
128
|
+
g.box({ at: [-w / 2 - t, -t / 2, 0], size: [t, t, h], r: 0.8, material: mat });
|
|
129
|
+
g.box({ at: [w / 2, -t / 2, 0], size: [t, t, h], r: 0.8, material: mat, right: (f) => f.rect(f.w / 2 - 0.8, 4, 1.6, 1.6, { r: 0.8, fill: 'f-lit', line: null }) });
|
|
130
|
+
g.box({ at: [-w / 2 - t, -t / 2 - 1, h], size: [w + 2 * t, t + 2, 5], r: 1, chamfer: 0.6, material: mat, left: (f) => f.rect(t, 1.6, f.w - 2 * t, 1.4, { r: 0.7, fill: 'f-lit', line: null }) });
|
|
131
|
+
g.pane({ id: id('beam'), class: 'scan-beam', plane: 'left', at: [-w / 2, 0, h], w, h: h - from, fill: 'f-lit', line: null, material: 'lit', glow: o.glow ?? true, style: { opacity: o.beamOpacity ?? 0.35 } });
|
|
132
|
+
}
|
|
133
|
+
}, { flat: true });
|
|
134
|
+
|
|
135
|
+
/* Machine hood a belt runs through (sealing, labelling, wrapping). axis: the belt direction.
|
|
136
|
+
A strip curtain hangs at the exit; status light id `${id}-led`. */
|
|
137
|
+
define('tunnel', (g, o) => {
|
|
138
|
+
const L = o.length ?? 30, w = o.w ?? 30, h = o.h ?? 36, t = o.t ?? 3, roof = o.roof ?? 7, axis = o.axis || 'x', mat = o.material;
|
|
139
|
+
const id = (s) => (o.id ? o.id + '-' + s : undefined);
|
|
140
|
+
const strips = (f) => { const n = Math.round(f.w / 3); for (let i = 1; i < n; i++) f.line((i * f.w) / n, 0, (i * f.w) / n, f.h, 'ln-faint'); };
|
|
141
|
+
const panel = (f) => { f.rect(4, 5, f.w - 8, f.h * 0.34, { r: 1, fill: 'f-screen', line: 'ln-soft' }); f.hlines(5, f.h * 0.58, f.w * 0.45, f.h * 0.22, 4, 'ln-faint'); };
|
|
142
|
+
if (axis === 'x') {
|
|
143
|
+
g.box({ at: [-L / 2, -w / 2 - t, 0], size: [L, t, h], material: mat });
|
|
144
|
+
g.box({ at: [-L / 2, w / 2, 0], size: [L, t, h], r: 0.6, material: mat, left: panel });
|
|
145
|
+
g.box({ at: [-L / 2 - 1, -w / 2 - t - 1, h], size: [L + 2, w + 2 * t + 2, roof], r: 1.5, chamfer: 1, material: mat, top: (f) => f.hlines(4, 4, f.w - 8, f.h - 8, 5, 'ln-faint') });
|
|
146
|
+
g.pane({ plane: 'right', at: [L / 2, w / 2, h], w, h: h * 0.55, fill: 'f-glass', line: 'ln-faint', material: 'glass', draw: strips });
|
|
147
|
+
g.pane({ id: id('led'), class: 'tunnel-led', plane: 'left', at: [L / 2 - 4, w / 2 + t, h - 2], w: 2, h: 2, r: 1, fill: 'f-lit', line: null });
|
|
148
|
+
} else {
|
|
149
|
+
g.box({ at: [-w / 2 - t, -L / 2, 0], size: [t, L, h], material: mat });
|
|
150
|
+
g.box({ at: [w / 2, -L / 2, 0], size: [t, L, h], r: 0.6, material: mat, right: panel });
|
|
151
|
+
g.box({ at: [-w / 2 - t - 1, -L / 2 - 1, h], size: [w + 2 * t + 2, L + 2, roof], r: 1.5, chamfer: 1, material: mat, top: (f) => f.vlines(4, 4, f.w - 8, f.h - 8, 5, 'ln-faint') });
|
|
152
|
+
g.pane({ plane: 'left', at: [-w / 2, L / 2, h], w, h: h * 0.55, fill: 'f-glass', line: 'ln-faint', material: 'glass', draw: strips });
|
|
153
|
+
g.pane({ id: id('led'), class: 'tunnel-led', plane: 'right', at: [w / 2 + t, -L / 2 + 6, h - 2], w: 2, h: 2, r: 1, fill: 'f-lit', line: null });
|
|
154
|
+
}
|
|
155
|
+
}, { flat: true });
|
|
156
|
+
}
|