@biolibs/bionet-space 0.0.0-stage → 0.1.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/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # @biolibs/bionet-space
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Where things are in a lab. A tree of places — rooms, freezers, shelves, racks, boxes, benches, instruments — with where each one stands and how big it is, the positions inside a box, what is stored where, and where a camera should stand to look at any of it. Plain data and arithmetic: nothing here draws anything, and nothing depends on React or three.js.
4
+
5
+ ```
6
+ npm install @biolibs/bionet-space
7
+ ```
8
+
9
+ ## A lab is a tree of places
10
+
11
+ ```ts
12
+ import { arrange, type Layout } from "@biolibs/bionet-space";
13
+
14
+ const lab: Layout = {
15
+ places: [
16
+ { id: "room", kind: "room", name: "Main lab", parent: null, standing: { position: [0, 0, 0], size: [6, 3, 4] } },
17
+ { id: "freezer", kind: "freezer", name: "−80", parent: "room" },
18
+ { id: "box", kind: "box", name: "Box 1", parent: "freezer", grid: { rows: 9, columns: 9 } },
19
+ ],
20
+ stored: [{ item: "tube-1", place: "box", slot: { row: 0, column: 0 }, part: "p1", name: "pWren-402", amount: 20, unit: "µL" }],
21
+ };
22
+
23
+ const arranged = arrange(lab);
24
+ arranged.map((one) => one.place.id); // [ "room", "freezer", "box" ]
25
+ arranged[2].path; // [ "room", "freezer", "box" ]
26
+ ```
27
+
28
+ Sizes are in metres. A place that says where it stands is put there; one that does not is given a size for its kind and a spot inside its parent, so a lab that has only said "there is a freezer with these boxes" can still be drawn. That is what makes dimensions optional: they are lab data when a lab gives them and a sensible default when it has not.
29
+
30
+ ## Where to look, and where a part is
31
+
32
+ ```ts
33
+ import { arrange, exampleLab, levelOf, poseFor, search } from "@biolibs/bionet-space";
34
+
35
+ const lab = exampleLab(); // a made-up lab: a freezer, a fridge, benches, 72 boxes
36
+ const arranged = arrange(lab);
37
+
38
+ poseFor(arranged, null).target; // the middle of the whole lab
39
+ levelOf(arranged.find((one) => one.place.id === "minus80")); // "unit"
40
+ search(lab, "t7 promoter").length > 0; // true
41
+ ```
42
+
43
+ `poseFor` gives a camera position and target for the whole lab or any one place, turned with the place so a freezer facing a side wall is still seen from its front. `search` matches by name, ignoring case.
44
+
45
+ ## Positions in a box
46
+
47
+ `slotCenter`, `slotSize`, `slotName` (`A1`, `B7`) and `firstFreeSlot` work out a box's grid. `storedWithin` gives everything in a place however deep.
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Giving every place somewhere to stand.
3
+ *
4
+ * A place that says where it stands is put there. One that does not is arranged by what it is:
5
+ * shelves split a freezer's height between them, racks share a shelf side by side, boxes stack in a
6
+ * rack. So a lab that has only ever said what is inside what still has a shape that can be drawn,
7
+ * and one that has been measured is drawn as measured.
8
+ *
9
+ * The result is in the lab's own coordinates, with turning already worked in. Every place comes out
10
+ * as a box with its sides along the axes, because places turn only by quarter turns — which is what
11
+ * keeps this arithmetic and not geometry.
12
+ */
13
+ import type { Arranged, Layout, Place, Slot } from "./model.js";
14
+ /** How big something is when nobody has said, by kind, in metres: wide, tall, deep. */
15
+ export declare const DEFAULT_SIZE: Readonly<Record<string, readonly [number, number, number]>>;
16
+ /** How big an instrument is by model, where that differs from the default. */
17
+ export declare const INSTRUMENT_SIZE: Readonly<Record<string, readonly [number, number, number]>>;
18
+ /**
19
+ * Give every place somewhere to stand.
20
+ *
21
+ * @param layout - The lab. Only its places are used.
22
+ * @returns Every place, with the space it takes up in the lab's coordinates, in an order where a
23
+ * place always comes after the place it is in. A place whose parent does not exist is left out.
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { arrange, exampleLab } from "@biolibs/bionet-space";
28
+ *
29
+ * const arranged = arrange(exampleLab());
30
+ * arranged.find((one) => one.place.kind === "freezer")?.size; // [ 0.9, 2, 0.85 ]
31
+ * ```
32
+ */
33
+ export declare function arrange(layout: Pick<Layout, "places">): Arranged[];
34
+ /**
35
+ * Where one position in a box is, in the lab's coordinates.
36
+ *
37
+ * @param box - The box, arranged.
38
+ * @param slot - Which position.
39
+ * @returns The centre of that position on the floor of the box, or `null` if the box has no such position.
40
+ */
41
+ export declare function slotCenter(box: Arranged, slot: Slot): [number, number, number] | null;
42
+ /**
43
+ * How big one position in a box is.
44
+ *
45
+ * @param box - The box, arranged.
46
+ * @returns The side of the square each position gets, in metres, or 0 if the box has no positions.
47
+ */
48
+ export declare function slotSize(box: Arranged): number;
49
+ /**
50
+ * The first position in a box that nothing is stored in.
51
+ *
52
+ * @param box - The box.
53
+ * @param taken - The positions already used.
54
+ * @returns A free position, row by row from the back left, or `null` if the box is full or has none.
55
+ */
56
+ export declare function firstFreeSlot(box: Place, taken: readonly Slot[]): Slot | null;
57
+ /**
58
+ * What a position is called, the way it is written on a box lid: a letter for the row, a number for
59
+ * the column.
60
+ *
61
+ * @param slot - The position.
62
+ * @returns Something like `C4`.
63
+ */
64
+ export declare function slotName(slot: Slot): string;
65
+ //# sourceMappingURL=arrange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrange.d.ts","sourceRoot":"","sources":["../src/arrange.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAkB,MAAM,YAAY,CAAC;AAEhF,uFAAuF;AACvF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAOpF,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAMvF,CAAC;AAsFF;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAE,CA8ClE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CASrF;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,QAAQ,GAAG,MAAM,CAK9C;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,IAAI,GAAG,IAAI,CAS7E;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAI3C"}
@@ -0,0 +1,221 @@
1
+ /** How big something is when nobody has said, by kind, in metres: wide, tall, deep. */
2
+ export const DEFAULT_SIZE = {
3
+ room: [6, 2.8, 5],
4
+ freezer: [0.9, 2.0, 0.85],
5
+ fridge: [0.7, 1.8, 0.7],
6
+ bench: [1.8, 0.9, 0.75],
7
+ instrument: [0.4, 0.3, 0.4],
8
+ box: [0.134, 0.052, 0.134],
9
+ };
10
+ /** How big an instrument is by model, where that differs from the default. */
11
+ export const INSTRUMENT_SIZE = {
12
+ thermocycler: [0.35, 0.25, 0.45],
13
+ "gel-station": [0.45, 0.18, 0.3],
14
+ centrifuge: [0.4, 0.3, 0.45],
15
+ computer: [0.5, 0.4, 0.25],
16
+ microscope: [0.3, 0.45, 0.4],
17
+ };
18
+ /** How much of a place's inside is kept clear of its walls, as a fraction of each side. */
19
+ const INSET = 0.06;
20
+ /** The gap left between things arranged side by side, in metres. */
21
+ const GAP = 0.02;
22
+ const sizeOf = (place) => {
23
+ if (place.standing !== undefined)
24
+ return [...place.standing.size];
25
+ const size = (place.kind === "instrument" && place.model !== undefined ? INSTRUMENT_SIZE[place.model] : undefined)
26
+ ?? DEFAULT_SIZE[place.kind] ?? [0.5, 0.5, 0.5];
27
+ return [...size];
28
+ };
29
+ /** Turn an offset measured in a turned place into the lab's directions. */
30
+ function turned([x, y, z], turn) {
31
+ switch (turn) {
32
+ case 90: return [-z, y, x];
33
+ case 180: return [-x, y, -z];
34
+ case 270: return [z, y, -x];
35
+ default: return [x, y, z];
36
+ }
37
+ }
38
+ /** A size as it lies once turned: a quarter turn swaps wide and deep. */
39
+ const lying = ([w, h, d], turn) => (turn === 90 || turn === 270 ? [d, h, w] : [w, h, d]);
40
+ /**
41
+ * Where each child stands inside a parent that has not been told, measured from the centre of the
42
+ * parent's base, with the parent facing front.
43
+ *
44
+ * @param parent - The size of the parent: wide, tall, deep.
45
+ * @param kind - What the parent is.
46
+ * @param children - The children with no standing of their own, in order.
47
+ * @returns A standing for each, in the same order.
48
+ */
49
+ function byDefault(parent, kind, children) {
50
+ const [W, H, D] = parent;
51
+ const inside = [W * (1 - 2 * INSET), H * (1 - 2 * INSET), D * (1 - 2 * INSET)];
52
+ const floor = H * INSET;
53
+ const count = children.length;
54
+ const sample = children[0].kind;
55
+ if (sample === "shelf") {
56
+ // Shelves split the height between them, the first at the top.
57
+ const each = inside[1] / count;
58
+ return children.map((_, at) => ({ position: [0, floor + (count - 1 - at) * each, 0], size: [inside[0], each - GAP, inside[2]] }));
59
+ }
60
+ if (sample === "box") {
61
+ // Boxes keep their own size and stack: upwards first, then across, then towards the back.
62
+ const [w, h, d] = sizeOf(children[0]);
63
+ const high = Math.max(1, Math.floor((inside[1] + GAP) / (h + GAP)));
64
+ const across = Math.max(1, Math.floor((inside[0] + GAP) / (w + GAP)));
65
+ return children.map((_, at) => {
66
+ const level = at % high;
67
+ const column = Math.floor(at / high) % across;
68
+ const back = Math.floor(at / (high * across));
69
+ return {
70
+ position: [-inside[0] / 2 + w / 2 + column * (w + GAP), floor + level * (h + GAP), inside[2] / 2 - d / 2 - back * (d + GAP)],
71
+ size: [w, h, d],
72
+ };
73
+ });
74
+ }
75
+ if (kind === "room") {
76
+ // Whatever stands on a room's floor lines up along the back wall, at its own size.
77
+ const sizes = children.map(sizeOf);
78
+ const total = sizes.reduce((sum, size) => sum + size[0], 0) + 0.4 * (count - 1);
79
+ let x = -total / 2;
80
+ return sizes.map((size) => {
81
+ const standing = { position: [x + size[0] / 2, 0, -D / 2 + size[2] / 2 + 0.1], size };
82
+ x += size[0] + 0.4;
83
+ return standing;
84
+ });
85
+ }
86
+ if (kind === "bench") {
87
+ // Things on a bench stand on its top, spread along it.
88
+ const sizes = children.map(sizeOf);
89
+ const step = W / count;
90
+ return sizes.map((size, at) => ({ position: [-W / 2 + step * (at + 0.5), H, 0], size }));
91
+ }
92
+ // Anything else shares the width side by side: racks on a shelf, or whatever a lab has invented.
93
+ const each = (inside[0] - GAP * (count - 1)) / count;
94
+ return children.map((_, at) => ({ position: [-inside[0] / 2 + each / 2 + at * (each + GAP), floor, 0], size: [each, inside[1], inside[2]] }));
95
+ }
96
+ /**
97
+ * Give every place somewhere to stand.
98
+ *
99
+ * @param layout - The lab. Only its places are used.
100
+ * @returns Every place, with the space it takes up in the lab's coordinates, in an order where a
101
+ * place always comes after the place it is in. A place whose parent does not exist is left out.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { arrange, exampleLab } from "@biolibs/bionet-space";
106
+ *
107
+ * const arranged = arrange(exampleLab());
108
+ * arranged.find((one) => one.place.kind === "freezer")?.size; // [ 0.9, 2, 0.85 ]
109
+ * ```
110
+ */
111
+ export function arrange(layout) {
112
+ const children = new Map();
113
+ for (const place of layout.places)
114
+ children.set(place.parent, [...(children.get(place.parent) ?? []), place]);
115
+ const out = [];
116
+ /**
117
+ * Put `places` inside a parent whose base is centred at `base`, with size `size` and turn `turn`.
118
+ * `given` holds standings already chosen for places that did not say where they stand.
119
+ */
120
+ const settle = (places, base, size, kind, turn, path, given = new Map()) => {
121
+ const chosen = new Map(given);
122
+ const unplaced = places.filter((place) => place.standing === undefined && !chosen.has(place));
123
+ // Shelves and boxes each have a rule of their own. Everything else in the same place is arranged
124
+ // together, so a freezer and a fridge in one room stand side by side and not on top of each other.
125
+ const sort = (place) => (place.kind === "shelf" || place.kind === "box" ? place.kind : "other");
126
+ for (const which of new Set(unplaced.map(sort))) {
127
+ const group = unplaced.filter((place) => sort(place) === which);
128
+ byDefault(size, kind, group).forEach((standing, at) => chosen.set(group[at], standing));
129
+ }
130
+ for (const place of places) {
131
+ const standing = place.standing ?? chosen.get(place);
132
+ const whole = ((turn + (standing.turn ?? 0)) % 360);
133
+ const offset = turned(standing.position, turn);
134
+ const at = [base[0] + offset[0], base[1] + offset[1], base[2] + offset[2]];
135
+ const space = lying([...standing.size], whole);
136
+ const here = [...path, place.id];
137
+ out.push({ place, center: [at[0], at[1] + space[1] / 2, at[2]], size: space, turn: whole, path: here,
138
+ placed: place.standing === undefined ? "by default" : "by hand" });
139
+ const inside = children.get(place.id);
140
+ if (inside !== undefined)
141
+ settle(inside, at, [...standing.size], place.kind, whole, here);
142
+ }
143
+ };
144
+ // Rooms that have not been told where to stand line up in a row, a little apart.
145
+ const rooms = children.get(null) ?? [];
146
+ const row = new Map();
147
+ let x = 0;
148
+ for (const room of rooms) {
149
+ if (room.standing !== undefined)
150
+ continue;
151
+ const size = sizeOf(room);
152
+ row.set(room, { position: [x + size[0] / 2, 0, 0], size });
153
+ x += size[0] + 1.5;
154
+ }
155
+ settle(rooms, [0, 0, 0], [0, 0, 0], "lab", 0, [], row);
156
+ return out;
157
+ }
158
+ /**
159
+ * Where one position in a box is, in the lab's coordinates.
160
+ *
161
+ * @param box - The box, arranged.
162
+ * @param slot - Which position.
163
+ * @returns The centre of that position on the floor of the box, or `null` if the box has no such position.
164
+ */
165
+ export function slotCenter(box, slot) {
166
+ const grid = box.place.grid;
167
+ if (grid === undefined || slot.row < 0 || slot.column < 0 || slot.row >= grid.rows || slot.column >= grid.columns)
168
+ return null;
169
+ // Rows run from the back to the front and columns from left to right, in the box's own facing.
170
+ const [w, , d] = lying([...box.size], box.turn); // undo the turn to get the box's own wide and deep
171
+ const across = -w / 2 + (w / grid.columns) * (slot.column + 0.5);
172
+ const forward = -d / 2 + (d / grid.rows) * (slot.row + 0.5);
173
+ const offset = turned([across, 0, forward], box.turn);
174
+ return [box.center[0] + offset[0], box.center[1] - box.size[1] / 2, box.center[2] + offset[2]];
175
+ }
176
+ /**
177
+ * How big one position in a box is.
178
+ *
179
+ * @param box - The box, arranged.
180
+ * @returns The side of the square each position gets, in metres, or 0 if the box has no positions.
181
+ */
182
+ export function slotSize(box) {
183
+ const grid = box.place.grid;
184
+ if (grid === undefined)
185
+ return 0;
186
+ const [w, , d] = lying([...box.size], box.turn);
187
+ return Math.min(w / grid.columns, d / grid.rows);
188
+ }
189
+ /**
190
+ * The first position in a box that nothing is stored in.
191
+ *
192
+ * @param box - The box.
193
+ * @param taken - The positions already used.
194
+ * @returns A free position, row by row from the back left, or `null` if the box is full or has none.
195
+ */
196
+ export function firstFreeSlot(box, taken) {
197
+ if (box.grid === undefined)
198
+ return null;
199
+ const used = new Set(taken.map((slot) => `${slot.row},${slot.column}`));
200
+ for (let row = 0; row < box.grid.rows; row++) {
201
+ for (let column = 0; column < box.grid.columns; column++) {
202
+ if (!used.has(`${row},${column}`))
203
+ return { row, column };
204
+ }
205
+ }
206
+ return null;
207
+ }
208
+ /**
209
+ * What a position is called, the way it is written on a box lid: a letter for the row, a number for
210
+ * the column.
211
+ *
212
+ * @param slot - The position.
213
+ * @returns Something like `C4`.
214
+ */
215
+ export function slotName(slot) {
216
+ let row = "";
217
+ for (let at = slot.row; at >= 0; at = Math.floor(at / 26) - 1)
218
+ row = String.fromCharCode(65 + (at % 26)) + row;
219
+ return `${row}${slot.column + 1}`;
220
+ }
221
+ //# sourceMappingURL=arrange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrange.js","sourceRoot":"","sources":["../src/arrange.ts"],"names":[],"mappings":"AAcA,uFAAuF;AACvF,MAAM,CAAC,MAAM,YAAY,GAAgE;IACvF,IAAI,EAAE,CAAC,CAAC,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,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC;QAAE,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC;IAC/G,OAAO,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A lab to look at: one room, a −80 freezer full of boxes, a fridge, two benches and their
3
+ * instruments.
4
+ *
5
+ * It is here so that anything that draws a lab has one to draw before a real one exists, and so that
6
+ * tests have something of a realistic size. The room, the freezer, the fridge and the benches say
7
+ * where they stand; the shelves, racks and boxes do not, and are arranged for them — which is the
8
+ * mix a real lab will have.
9
+ *
10
+ * It is the same every time it is made. The tubes are scattered by a fixed sequence, not by chance.
11
+ */
12
+ import type { Layout } from "./model.js";
13
+ /**
14
+ * Make the example lab.
15
+ *
16
+ * @returns Its places and what is stored in them.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { arrange, exampleLab, search } from "@biolibs/bionet-space";
21
+ *
22
+ * const lab = exampleLab();
23
+ * lab.places.filter((place) => place.kind === "box").length; // 72
24
+ * search(lab, "puc19").length > 0; // true
25
+ * arrange(lab).length === lab.places.length; // true: everything has somewhere to stand
26
+ * ```
27
+ */
28
+ export declare function exampleLab(): Layout;
29
+ //# sourceMappingURL=example.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.d.ts","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAC;AAkBxD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAkDnC"}
@@ -0,0 +1,81 @@
1
+ /** What the example freezer is stocked with. The first seven are the parts the Wren Lab publishes. */
2
+ const PARTS = ["f1", "f2", "acceptor", "part1", "part2", "template", "backbone", "pUC19", "pET-28a", "pBR322", "pGEX-4T-1",
3
+ "GFP insert", "mCherry insert", "lacZα", "T7 promoter", "Cas9", "sgRNA scaffold", "AmpR cassette", "KanR cassette",
4
+ "pSB1C3", "RFP reporter"];
5
+ /** A sequence of numbers between 0 and 1 that is the same every time. */
6
+ function sequence(seed) {
7
+ let state = seed >>> 0;
8
+ return () => {
9
+ state = (state + 0x6d2b79f5) >>> 0;
10
+ let mixed = Math.imul(state ^ (state >>> 15), 1 | state);
11
+ mixed = (mixed + Math.imul(mixed ^ (mixed >>> 7), 61 | mixed)) ^ mixed;
12
+ return ((mixed ^ (mixed >>> 14)) >>> 0) / 4294967296;
13
+ };
14
+ }
15
+ /**
16
+ * Make the example lab.
17
+ *
18
+ * @returns Its places and what is stored in them.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * import { arrange, exampleLab, search } from "@biolibs/bionet-space";
23
+ *
24
+ * const lab = exampleLab();
25
+ * lab.places.filter((place) => place.kind === "box").length; // 72
26
+ * search(lab, "puc19").length > 0; // true
27
+ * arrange(lab).length === lab.places.length; // true: everything has somewhere to stand
28
+ * ```
29
+ */
30
+ export function exampleLab() {
31
+ const next = sequence(20261115);
32
+ const places = [
33
+ { id: "main", kind: "room", name: "Main lab", parent: null, standing: { position: [0, 0, 0], size: [7, 2.8, 5] } },
34
+ { id: "minus80", kind: "freezer", name: "−80 freezer", parent: "main", standing: { position: [-2.7, 0, -1.975], size: [0.9, 2.0, 0.85] } },
35
+ { id: "fridge", kind: "fridge", name: "4 °C fridge", parent: "main", standing: { position: [-1.6, 0, -2.05], size: [0.7, 1.8, 0.7] } },
36
+ { id: "bench1", kind: "bench", name: "Bench 1", parent: "main", standing: { position: [0.7, 0, -2.0], size: [2.4, 0.9, 0.75] } },
37
+ { id: "bench2", kind: "bench", name: "Bench 2", parent: "main", standing: { position: [3.0, 0, 0.3], size: [2.2, 0.9, 0.75], turn: 90 } },
38
+ { id: "thermocycler", kind: "instrument", model: "thermocycler", name: "Thermocycler", parent: "bench1" },
39
+ { id: "gel", kind: "instrument", model: "gel-station", name: "Gel station", parent: "bench1" },
40
+ { id: "centrifuge", kind: "instrument", model: "centrifuge", name: "Centrifuge", parent: "bench1" },
41
+ { id: "computer", kind: "instrument", model: "computer", name: "Computer", parent: "bench2" },
42
+ { id: "microscope", kind: "instrument", model: "microscope", name: "Microscope", parent: "bench2" },
43
+ ];
44
+ const stored = [];
45
+ let tubes = 0;
46
+ /** Add a box, and scatter tubes in it. */
47
+ const box = (id, name, parent, rows, columns, fullness) => {
48
+ places.push({ id, kind: "box", name, parent, grid: { rows, columns } });
49
+ for (let row = 0; row < rows; row++) {
50
+ for (let column = 0; column < columns; column++) {
51
+ if (next() >= fullness)
52
+ continue;
53
+ const part = PARTS[Math.floor(next() * PARTS.length)];
54
+ tubes++;
55
+ stored.push({ item: `tube-${String(tubes).padStart(4, "0")}`, place: id, slot: { row, column }, part: `example:${part}`, name: part,
56
+ amount: 5 + Math.floor(next() * 46), unit: "µL", ...(next() < 0.012 ? { needsRecount: true } : {}) });
57
+ }
58
+ }
59
+ };
60
+ // The freezer: four shelves, three racks on each, five boxes of 81 in each rack.
61
+ for (let shelf = 1; shelf <= 4; shelf++) {
62
+ places.push({ id: `minus80-s${shelf}`, kind: "shelf", name: `Shelf ${shelf}`, parent: "minus80" });
63
+ for (const rack of ["A", "B", "C"]) {
64
+ const rackId = `minus80-s${shelf}-${rack}`;
65
+ places.push({ id: rackId, kind: "rack", name: `Rack ${shelf}${rack}`, parent: `minus80-s${shelf}` });
66
+ for (let at = 1; at <= 5; at++) {
67
+ // Some boxes are nearly full, some nearly empty, and a few have nothing in them yet.
68
+ const fullness = next() < 0.15 ? 0 : 0.15 + next() * 0.8;
69
+ box(`${rackId}-${at}`, `Box ${shelf}${rack}${at}`, rackId, 9, 9, fullness);
70
+ }
71
+ }
72
+ }
73
+ // The fridge: three shelves with four boxes of 25 standing on each.
74
+ for (let shelf = 1; shelf <= 3; shelf++) {
75
+ places.push({ id: `fridge-s${shelf}`, kind: "shelf", name: `Shelf ${shelf}`, parent: "fridge" });
76
+ for (let at = 1; at <= 4; at++)
77
+ box(`fridge-s${shelf}-${at}`, `Box F${shelf}-${at}`, `fridge-s${shelf}`, 5, 5, 0.2 + next() * 0.6);
78
+ }
79
+ return { places, stored };
80
+ }
81
+ //# sourceMappingURL=example.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"example.js","sourceRoot":"","sources":["../src/example.ts"],"names":[],"mappings":"AAaA,sGAAsG;AACtG,MAAM,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW;IAC3G,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe;IAClH,QAAQ,EAAE,cAAc,CAAC,CAAC;AAEzC,yEAAyE;AACzE,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,KAAK,GAAG,IAAI,KAAK,CAAC,CAAC;IACvB,OAAO,GAAG,EAAE;QACV,KAAK,GAAG,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC;QACzD,KAAK,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;QACvE,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,G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AAI,EAAE,EAAE,EAAE,WAAW,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,EAAE,GAAG,GAAG,CAAC,CAAC;IACrI,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
package/dist/find.d.ts ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Finding your way around an arranged lab: what is inside what, what a search turns up, and where a
3
+ * camera should look to see a place.
4
+ */
5
+ import type { Arranged, Layout, Stored } from "./model.js";
6
+ /** How close a place is to the things in it: a room, something standing in one, or a box of positions. */
7
+ export type Level = "lab" | "room" | "unit" | "inside" | "box";
8
+ /**
9
+ * How close a look at a place is.
10
+ *
11
+ * @param arranged - The place, or `null` for the whole lab.
12
+ * @returns `lab` for everything, `room` for a room, `unit` for whatever stands in a room (a freezer, a
13
+ * bench, an instrument), `box` for a place with positions, and `inside` for anything between.
14
+ */
15
+ export declare function levelOf(arranged: Arranged | null): Level;
16
+ /** A box that everything fits in. */
17
+ export interface Bounds {
18
+ center: [number, number, number];
19
+ size: [number, number, number];
20
+ }
21
+ /**
22
+ * The space some places take up together.
23
+ *
24
+ * @param places - The places.
25
+ * @returns The smallest box around all of them, or `null` if there are none.
26
+ */
27
+ export declare function boundsOf(places: readonly Pick<Arranged, "center" | "size">[]): Bounds | null;
28
+ /** Where a camera stands and what it looks at. */
29
+ export interface Pose {
30
+ /** Where the camera is. */
31
+ position: [number, number, number];
32
+ /** What it looks at. */
33
+ target: [number, number, number];
34
+ }
35
+ /**
36
+ * Where a camera should stand to see a place whole.
37
+ *
38
+ * It looks from in front and a little above, closer the smaller the thing is, and from nearly
39
+ * straight above for a box, since a box is read like a page. A place that is turned is looked at
40
+ * from its own front.
41
+ *
42
+ * @param arranged - Every place, arranged.
43
+ * @param id - The place to look at, or `null` for the whole lab.
44
+ * @param fov - The camera's vertical field of view, in degrees.
45
+ * @returns Where to stand and what to look at.
46
+ */
47
+ export declare function poseFor(arranged: readonly Arranged[], id: string | null, fov?: number): Pose;
48
+ /**
49
+ * Everything stored in a place or in anything inside it.
50
+ *
51
+ * @param layout - The lab.
52
+ * @param arranged - Its places, arranged.
53
+ * @param id - The place.
54
+ * @returns What is stored there, however deep.
55
+ */
56
+ export declare function storedWithin(layout: Pick<Layout, "stored">, arranged: readonly Arranged[], id: string): Stored[];
57
+ /**
58
+ * Search what is stored, by the name of the part.
59
+ *
60
+ * @param layout - The lab.
61
+ * @param words - What was typed. Case does not matter, and every word has to appear.
62
+ * @returns What matched, in the order it is stored. Nothing, if nothing was typed.
63
+ */
64
+ export declare function search(layout: Pick<Layout, "stored">, words: string): Stored[];
65
+ //# sourceMappingURL=find.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE3D,0GAA0G;AAC1G,MAAM,MAAM,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE/D;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,KAAK,CAMxD;AAED,qCAAqC;AACrC,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAc5F;AAED,kDAAkD;AAClD,MAAM,WAAW,IAAI;IACnB,2BAA2B;IAC3B,QAAQ,EAAE,CAAC,MAA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