@operato/scene-storage 10.0.0-beta.28 → 10.0.0-beta.31

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 (58) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/asrs-crane-3d.d.ts +10 -0
  3. package/dist/asrs-crane-3d.js +17 -0
  4. package/dist/asrs-crane-3d.js.map +1 -1
  5. package/dist/asrs-crane.d.ts +58 -13
  6. package/dist/asrs-crane.js +120 -16
  7. package/dist/asrs-crane.js.map +1 -1
  8. package/dist/asrs-rack.d.ts +58 -19
  9. package/dist/asrs-rack.js +107 -20
  10. package/dist/asrs-rack.js.map +1 -1
  11. package/dist/box.d.ts +10 -3
  12. package/dist/box.js +1 -2
  13. package/dist/box.js.map +1 -1
  14. package/dist/generic-container-3d.js.map +1 -1
  15. package/dist/generic-container.d.ts +12 -2
  16. package/dist/generic-container.js +1 -2
  17. package/dist/generic-container.js.map +1 -1
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.js +2 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/pallet.d.ts +9 -2
  22. package/dist/pallet.js +1 -2
  23. package/dist/pallet.js.map +1 -1
  24. package/dist/parcel.d.ts +10 -3
  25. package/dist/parcel.js +1 -2
  26. package/dist/parcel.js.map +1 -1
  27. package/dist/rack-cell-3d.d.ts +25 -0
  28. package/dist/rack-cell-3d.js +88 -0
  29. package/dist/rack-cell-3d.js.map +1 -0
  30. package/dist/rack-cell.d.ts +64 -0
  31. package/dist/rack-cell.js +197 -0
  32. package/dist/rack-cell.js.map +1 -0
  33. package/dist/spot-3d.js.map +1 -1
  34. package/dist/spot.d.ts +12 -11
  35. package/dist/spot.js +2 -3
  36. package/dist/spot.js.map +1 -1
  37. package/dist/templates/index.d.ts +42 -0
  38. package/dist/templates/index.js +43 -1
  39. package/dist/templates/index.js.map +1 -1
  40. package/package.json +9 -4
  41. package/src/asrs-crane-3d.ts +20 -0
  42. package/src/asrs-crane.ts +153 -17
  43. package/src/asrs-rack.ts +137 -22
  44. package/src/box.ts +15 -5
  45. package/src/generic-container-3d.ts +1 -1
  46. package/src/generic-container.ts +22 -7
  47. package/src/index.ts +3 -0
  48. package/src/pallet.ts +16 -6
  49. package/src/parcel.ts +15 -5
  50. package/src/rack-cell-3d.ts +101 -0
  51. package/src/rack-cell.ts +241 -0
  52. package/src/spot-3d.ts +1 -1
  53. package/src/spot.ts +17 -7
  54. package/src/templates/index.ts +43 -1
  55. package/test/setup.js +279 -0
  56. package/test/test-asrs-crane.ts +319 -0
  57. package/tsconfig.json +2 -1
  58. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ *
4
+ * RackCell 3D — invisible anchor group positioned at the cell's location
5
+ * within the parent rack's 3D coordinate space.
6
+ *
7
+ * RackCell has no geometry of its own. Its sole 3D purpose is to provide
8
+ * an Object3D that carriers can be attached to (via Three.js `.attach()`),
9
+ * placed at the exact cell position within the rack. The position is derived
10
+ * from the parent AsrsRack's CellMap (by cellId), not from 2D state fields —
11
+ * rack cells occupy 3D levels that have no 2D analogue.
12
+ *
13
+ * updateTransform() override: things-scene's standard updateTransform
14
+ * reads `component.center` (2D) and flattens it to 3D. For rack cells this
15
+ * is wrong — we need the 3D cell position (bay x, level y, row z) from the
16
+ * parent rack. So we override and read it directly from the CellMap.
17
+ */
18
+ import * as THREE from 'three';
19
+ import { RealObjectGroup } from '@hatiolab/things-scene';
20
+ export class RackCell3D extends RealObjectGroup {
21
+ build() {
22
+ super.build();
23
+ this._repositionFromCellMap();
24
+ }
25
+ updateDimension() {
26
+ // intentional no-op — size comes from the cell definition, not state
27
+ }
28
+ updateTransform() {
29
+ this._repositionFromCellMap();
30
+ }
31
+ updateAlpha() {
32
+ // invisible — no materials to update
33
+ }
34
+ /**
35
+ * Position this group at the cell's localPosition within the rack's 3D space.
36
+ *
37
+ * CellMap.grid() places cell origins at:
38
+ * x = b * bayWidth, y = l * levelHeight, z = r * rowDepth
39
+ * (starting from 0,0,0 at the rack's bottom-left-front corner).
40
+ *
41
+ * The rack's object3d is centered: X spans [-width/2, +width/2],
42
+ * Y spans [-depth/2, +depth/2], Z spans [-height/2, +height/2].
43
+ *
44
+ * So the cell centre in rack-local 3D space:
45
+ * x3d = cellPos.x + bayWidth/2 - width/2
46
+ * y3d = cellPos.y + levelHeight/2 - rackDepth/2
47
+ * z3d = cellPos.z + rowDepth/2 - rackHeight/2
48
+ */
49
+ _repositionFromCellMap() {
50
+ const rack = this.component.parent;
51
+ if (!rack?.cellMap)
52
+ return;
53
+ const cellId = this.component.state.cellId;
54
+ if (!cellId)
55
+ return;
56
+ const cell = rack.cellMap.findById(cellId);
57
+ if (!cell)
58
+ return;
59
+ const rs = rack.state;
60
+ const rackWidth = rs?.width || 1000;
61
+ const rackDepth = rs?.depth || 3000; // Y dimension (floor→ceiling)
62
+ const rackHeight = rs?.height || 600; // Z dimension (front→back, 2D height)
63
+ const bays = Math.max(1, Math.floor(rs?.bays || 5));
64
+ const levels = Math.max(1, Math.floor(rs?.levels || 4));
65
+ const rows = 1;
66
+ const bayWidth = rackWidth / bays;
67
+ const levelHeight = rackDepth / levels;
68
+ const rowDepth = rackHeight / rows;
69
+ const x3d = cell.localPosition.x + bayWidth / 2 - rackWidth / 2;
70
+ const y3d = cell.localPosition.y + levelHeight / 2 - rackDepth / 2;
71
+ const z3d = cell.localPosition.z + rowDepth / 2 - rackHeight / 2;
72
+ this.object3d.position.set(x3d, y3d, z3d);
73
+ // Optionally visualise cells in debug mode (outline box, very faint)
74
+ if (process.env.NODE_ENV !== 'production' && rack.state?.debugCells) {
75
+ this._addDebugBox(bayWidth, levelHeight, rowDepth);
76
+ }
77
+ }
78
+ _debugBox;
79
+ _addDebugBox(w, h, d) {
80
+ if (this._debugBox)
81
+ return;
82
+ const geo = new THREE.BoxGeometry(w * 0.98, h * 0.98, d * 0.98);
83
+ const edges = new THREE.EdgesGeometry(geo);
84
+ this._debugBox = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({ color: 0x00ff88, transparent: true, opacity: 0.2 }));
85
+ this.object3d.add(this._debugBox);
86
+ }
87
+ }
88
+ //# sourceMappingURL=rack-cell-3d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rack-cell-3d.js","sourceRoot":"","sources":["../src/rack-cell-3d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD,MAAM,OAAO,UAAW,SAAQ,eAAe;IAC7C,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,IAAI,CAAC,sBAAsB,EAAE,CAAA;IAC/B,CAAC;IAED,eAAe;QACb,qEAAqE;IACvE,CAAC;IAED,eAAe;QACb,IAAI,CAAC,sBAAsB,EAAE,CAAA;IAC/B,CAAC;IAED,WAAW;QACT,qCAAqC;IACvC,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,sBAAsB;QACpB,MAAM,IAAI,GAAI,IAAI,CAAC,SAAiB,CAAC,MAAM,CAAA;QAC3C,IAAI,CAAC,IAAI,EAAE,OAAO;YAAE,OAAM;QAE1B,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAA4B,CAAA;QAChE,IAAI,CAAC,MAAM;YAAE,OAAM;QAEnB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,CAAC,IAAI;YAAE,OAAM;QAEjB,MAAM,EAAE,GAAG,IAAI,CAAC,KAAY,CAAA;QAC5B,MAAM,SAAS,GAAI,EAAE,EAAE,KAAgB,IAAI,IAAI,CAAA;QAC/C,MAAM,SAAS,GAAI,EAAE,EAAE,KAAgB,IAAI,IAAI,CAAA,CAAG,8BAA8B;QAChF,MAAM,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IAAI,IAAI,CAAC,SAAS;YAAE,OAAM;QAC1B,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;QAC/D,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,YAAY,CACrC,KAAK,EACL,IAAI,KAAK,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAClF,CAAA;QACD,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACnC,CAAC;CACF","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n *\n * RackCell 3D — invisible anchor group positioned at the cell's location\n * within the parent rack's 3D coordinate space.\n *\n * RackCell has no geometry of its own. Its sole 3D purpose is to provide\n * an Object3D that carriers can be attached to (via Three.js `.attach()`),\n * placed at the exact cell position within the rack. The position is derived\n * from the parent AsrsRack's CellMap (by cellId), not from 2D state fields —\n * rack cells occupy 3D levels that have no 2D analogue.\n *\n * updateTransform() override: things-scene's standard updateTransform\n * reads `component.center` (2D) and flattens it to 3D. For rack cells this\n * is wrong — we need the 3D cell position (bay x, level y, row z) from the\n * parent rack. So we override and read it directly from the CellMap.\n */\n\nimport * as THREE from 'three'\nimport { RealObjectGroup } from '@hatiolab/things-scene'\n\nexport class RackCell3D extends RealObjectGroup {\n build() {\n super.build()\n this._repositionFromCellMap()\n }\n\n updateDimension() {\n // intentional no-op — size comes from the cell definition, not state\n }\n\n updateTransform() {\n this._repositionFromCellMap()\n }\n\n updateAlpha() {\n // invisible — no materials to update\n }\n\n /**\n * Position this group at the cell's localPosition within the rack's 3D space.\n *\n * CellMap.grid() places cell origins at:\n * x = b * bayWidth, y = l * levelHeight, z = r * rowDepth\n * (starting from 0,0,0 at the rack's bottom-left-front corner).\n *\n * The rack's object3d is centered: X spans [-width/2, +width/2],\n * Y spans [-depth/2, +depth/2], Z spans [-height/2, +height/2].\n *\n * So the cell centre in rack-local 3D space:\n * x3d = cellPos.x + bayWidth/2 - width/2\n * y3d = cellPos.y + levelHeight/2 - rackDepth/2\n * z3d = cellPos.z + rowDepth/2 - rackHeight/2\n */\n _repositionFromCellMap() {\n const rack = (this.component as any).parent\n if (!rack?.cellMap) return\n\n const cellId = this.component.state.cellId as string | undefined\n if (!cellId) return\n\n const cell = rack.cellMap.findById(cellId)\n if (!cell) return\n\n const rs = rack.state as any\n const rackWidth = (rs?.width as number) || 1000\n const rackDepth = (rs?.depth as number) || 3000 // Y dimension (floor→ceiling)\n const rackHeight = (rs?.height as number) || 600 // Z dimension (front→back, 2D height)\n const bays = Math.max(1, Math.floor(rs?.bays || 5))\n const levels = Math.max(1, Math.floor(rs?.levels || 4))\n const rows = 1\n\n const bayWidth = rackWidth / bays\n const levelHeight = rackDepth / levels\n const rowDepth = rackHeight / rows\n\n const x3d = cell.localPosition.x + bayWidth / 2 - rackWidth / 2\n const y3d = cell.localPosition.y + levelHeight / 2 - rackDepth / 2\n const z3d = cell.localPosition.z + rowDepth / 2 - rackHeight / 2\n\n this.object3d.position.set(x3d, y3d, z3d)\n\n // Optionally visualise cells in debug mode (outline box, very faint)\n if (process.env.NODE_ENV !== 'production' && (rack.state as any)?.debugCells) {\n this._addDebugBox(bayWidth, levelHeight, rowDepth)\n }\n }\n\n private _debugBox?: THREE.LineSegments\n\n private _addDebugBox(w: number, h: number, d: number) {\n if (this._debugBox) return\n const geo = new THREE.BoxGeometry(w * 0.98, h * 0.98, d * 0.98)\n const edges = new THREE.EdgesGeometry(geo)\n this._debugBox = new THREE.LineSegments(\n edges,\n new THREE.LineBasicMaterial({ color: 0x00ff88, transparent: true, opacity: 0.2 })\n )\n this.object3d.add(this._debugBox)\n }\n}\n"]}
@@ -0,0 +1,64 @@
1
+ import { Component, ComponentNature, RealObject } from '@hatiolab/things-scene';
2
+ import type { State, Material3D } from '@hatiolab/things-scene';
3
+ import { type AttachFrame } from '@operato/scene-base';
4
+ /**
5
+ * How many carriers a cell can hold simultaneously.
6
+ * - single: exactly 1 (typical pallet bay)
7
+ * - multi: small stack (up to 4, e.g. a multi-deep tray)
8
+ * - bulk: unlimited (e.g. a floor area measured in slots)
9
+ */
10
+ export type RackCellType = 'single' | 'multi' | 'bulk';
11
+ /** RackCell 컴포넌트 state */
12
+ export interface RackCellState extends State {
13
+ cellId?: string;
14
+ cellType?: RackCellType;
15
+ material3d?: Material3D;
16
+ }
17
+ declare const RackCell_base: any;
18
+ /**
19
+ * RackCell — single-slot storage cell inside an AsrsRack.
20
+ *
21
+ * Mixin chain: CarrierHolder(ContainerAbstract)
22
+ * - CarrierHolder: publishes attachPointFor(), gates containable() to Carriables
23
+ * - ContainerAbstract: manages child carrier components
24
+ *
25
+ * No Placeable mixin — RackCell3D self-positions from the parent rack's
26
+ * CellMap (via updateTransform override), bypassing things-scene's standard
27
+ * 2D→3D coordinate mapping which cannot express 3D levels.
28
+ */
29
+ export default class RackCell extends RackCell_base {
30
+ state: RackCellState;
31
+ get cellId(): string;
32
+ get cellType(): RackCellType;
33
+ /** Maximum carrier count for this cell based on cellType. */
34
+ get capacity(): number;
35
+ get nature(): ComponentNature;
36
+ get anchors(): [];
37
+ /** True when fewer carriers are currently held than capacity. */
38
+ canReceive(_component?: any): boolean;
39
+ /**
40
+ * Accept a carrier into this cell.
41
+ * Sets TRANSFER_SLOT_KEY = cellId on the carrier, then reparents.
42
+ * Fires 'transfer-received' so monitors can react.
43
+ */
44
+ receive(carrier: any, options?: any): Promise<void>;
45
+ /**
46
+ * Release a carrier from this cell to `target`.
47
+ * Delegates to `target.receive()` if available, otherwise `target.reparent()`.
48
+ */
49
+ dispatch(carrier: any, target: any, options?: any): Promise<void>;
50
+ /** Alias for receive() — semantic sugar for the storage domain. */
51
+ store(carrier: any, options?: any): Promise<void>;
52
+ /** Alias for dispatch() — semantic sugar for the storage domain. */
53
+ retrieve(carrier: any, target: any, options?: any): Promise<void>;
54
+ /**
55
+ * Return the 3D attach frame for carriers placed in this cell.
56
+ * Carriers are lifted by their own halfDepth so the bottom face
57
+ * rests at the cell's Y-center (which is levelHeight/2 above the beam).
58
+ */
59
+ attachPointFor(carrier: Component): AttachFrame | null;
60
+ /** RackCell has no 2D visual — the rack draws its own structure. */
61
+ render(_ctx: CanvasRenderingContext2D): void;
62
+ buildRealObject(): RealObject | undefined;
63
+ }
64
+ export {};
@@ -0,0 +1,197 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ *
4
+ * RackCell — a single storage slot within an AsrsRack.
5
+ *
6
+ * A RackCell is a virtual component: it occupies a specific (bay, row, level)
7
+ * coordinate within the parent rack and acts as a CarrierHolder for one carrier
8
+ * (or several, depending on `cellType`).
9
+ *
10
+ * The crane (AsrsCrane) navigates toward a RackCell as its `place()` destination —
11
+ * because the rack cell is a discrete component, Mover.moveTo() can target it
12
+ * directly and arrive at exactly the right bay × level position.
13
+ *
14
+ * Visual: invisible in 2D (no visible 2D footprint — rack cells don't make
15
+ * sense as 2D top-down boxes). In 3D, each cell is an invisible Group
16
+ * positioned within the rack's coordinate space (RackCell3D handles
17
+ * this via updateTransform override).
18
+ *
19
+ * Lifecycle: AsrsRack._buildCells() instantiates RackCell children.
20
+ * Do not create RackCell components manually — they are managed by the rack.
21
+ *
22
+ * Domain aliases:
23
+ * cell.store(carrier) ← cell.receive(carrier)
24
+ * cell.retrieve(carrier, target) ← cell.dispatch(carrier, target)
25
+ */
26
+ import { __decorate } from "tslib";
27
+ import { ContainerAbstract, TRANSFER_SLOT_KEY, sceneComponent } from '@hatiolab/things-scene';
28
+ import { CarrierHolder } from '@operato/scene-base';
29
+ import { RackCell3D } from './rack-cell-3d.js';
30
+ const NATURE = {
31
+ mutable: false,
32
+ resizable: false,
33
+ rotatable: false,
34
+ properties: [
35
+ {
36
+ type: 'string',
37
+ label: 'cell-id',
38
+ name: 'cellId',
39
+ placeholder: 'e.g. 0-0-0'
40
+ },
41
+ {
42
+ type: 'select',
43
+ label: 'cell-type',
44
+ name: 'cellType',
45
+ property: {
46
+ options: [
47
+ { display: 'Single', value: 'single' },
48
+ { display: 'Multi', value: 'multi' },
49
+ { display: 'Bulk', value: 'bulk' }
50
+ ]
51
+ }
52
+ }
53
+ ],
54
+ help: 'scene/component/rack-cell'
55
+ };
56
+ /**
57
+ * RackCell — single-slot storage cell inside an AsrsRack.
58
+ *
59
+ * Mixin chain: CarrierHolder(ContainerAbstract)
60
+ * - CarrierHolder: publishes attachPointFor(), gates containable() to Carriables
61
+ * - ContainerAbstract: manages child carrier components
62
+ *
63
+ * No Placeable mixin — RackCell3D self-positions from the parent rack's
64
+ * CellMap (via updateTransform override), bypassing things-scene's standard
65
+ * 2D→3D coordinate mapping which cannot express 3D levels.
66
+ */
67
+ let RackCell = class RackCell extends CarrierHolder(ContainerAbstract) {
68
+ // ── Identification ────────────────────────────────────────────────────────
69
+ get cellId() {
70
+ return this.state.cellId ?? '';
71
+ }
72
+ get cellType() {
73
+ return this.state.cellType ?? 'single';
74
+ }
75
+ /** Maximum carrier count for this cell based on cellType. */
76
+ get capacity() {
77
+ switch (this.cellType) {
78
+ case 'single': return 1;
79
+ case 'multi': return 4;
80
+ case 'bulk': return Infinity;
81
+ }
82
+ }
83
+ // ── Interface ─────────────────────────────────────────────────────────────
84
+ get nature() {
85
+ return NATURE;
86
+ }
87
+ get anchors() {
88
+ return [];
89
+ }
90
+ // ── Transfer protocol ─────────────────────────────────────────────────────
91
+ /** True when fewer carriers are currently held than capacity. */
92
+ canReceive(_component) {
93
+ const occupied = this.components?.length ?? 0;
94
+ return occupied < this.capacity;
95
+ }
96
+ /**
97
+ * Accept a carrier into this cell.
98
+ * Sets TRANSFER_SLOT_KEY = cellId on the carrier, then reparents.
99
+ * Fires 'transfer-received' so monitors can react.
100
+ */
101
+ async receive(carrier, options = {}) {
102
+ if (!this.canReceive(carrier)) {
103
+ this.trigger('transfer-rejected', {
104
+ type: 'transfer-rejected',
105
+ component: carrier,
106
+ container: this,
107
+ reason: 'no-slot'
108
+ });
109
+ return;
110
+ }
111
+ carrier[TRANSFER_SLOT_KEY] = this.cellId;
112
+ this.reparent(carrier, options);
113
+ this.trigger('transfer-received', {
114
+ type: 'transfer-received',
115
+ component: carrier,
116
+ container: this,
117
+ slotId: this.cellId
118
+ });
119
+ }
120
+ /**
121
+ * Release a carrier from this cell to `target`.
122
+ * Delegates to `target.receive()` if available, otherwise `target.reparent()`.
123
+ */
124
+ async dispatch(carrier, target, options = {}) {
125
+ if (target?.canReceive && !target.canReceive(carrier)) {
126
+ this.trigger('transfer-rejected', {
127
+ type: 'transfer-rejected',
128
+ component: carrier,
129
+ container: this,
130
+ reason: 'target-full'
131
+ });
132
+ return;
133
+ }
134
+ delete carrier[TRANSFER_SLOT_KEY];
135
+ if (typeof target?.receive === 'function') {
136
+ await target.receive(carrier, options);
137
+ }
138
+ else {
139
+ ;
140
+ target.reparent?.(carrier, options);
141
+ }
142
+ this.trigger('transfer-dispatched', {
143
+ type: 'transfer-dispatched',
144
+ component: carrier,
145
+ container: this,
146
+ target
147
+ });
148
+ }
149
+ // ── Domain aliases ────────────────────────────────────────────────────────
150
+ /** Alias for receive() — semantic sugar for the storage domain. */
151
+ store(carrier, options) {
152
+ return this.receive(carrier, options);
153
+ }
154
+ /** Alias for dispatch() — semantic sugar for the storage domain. */
155
+ retrieve(carrier, target, options) {
156
+ return this.dispatch(carrier, target, options);
157
+ }
158
+ // ── 3D attach frame ───────────────────────────────────────────────────────
159
+ /**
160
+ * Return the 3D attach frame for carriers placed in this cell.
161
+ * Carriers are lifted by their own halfDepth so the bottom face
162
+ * rests at the cell's Y-center (which is levelHeight/2 above the beam).
163
+ */
164
+ attachPointFor(carrier) {
165
+ const root = this._realObject?.object3d;
166
+ if (!root)
167
+ return null;
168
+ const carrierDepth = resolveCarrierDepth(carrier);
169
+ return {
170
+ attach: root,
171
+ localPosition: { x: 0, y: carrierDepth / 2, z: 0 }
172
+ };
173
+ }
174
+ // ── 2D rendering ──────────────────────────────────────────────────────────
175
+ /** RackCell has no 2D visual — the rack draws its own structure. */
176
+ render(_ctx) {
177
+ // intentional no-op
178
+ }
179
+ // ── 3D ───────────────────────────────────────────────────────────────────
180
+ buildRealObject() {
181
+ return new RackCell3D(this);
182
+ }
183
+ };
184
+ RackCell = __decorate([
185
+ sceneComponent('rack-cell')
186
+ ], RackCell);
187
+ export default RackCell;
188
+ function resolveCarrierDepth(c) {
189
+ const eff = c._realObject?.effectiveDepth;
190
+ if (typeof eff === 'number' && Number.isFinite(eff))
191
+ return eff;
192
+ return numOr(c?.state?.depth, 0);
193
+ }
194
+ function numOr(v, dflt) {
195
+ return typeof v === 'number' && Number.isFinite(v) ? v : dflt;
196
+ }
197
+ //# sourceMappingURL=rack-cell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rack-cell.js","sourceRoot":"","sources":["../src/rack-cell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;AAEH,OAAO,EAGL,iBAAiB,EAEjB,iBAAiB,EACjB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAE/B,OAAO,EAAE,aAAa,EAAoB,MAAM,qBAAqB,CAAA;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAoB9C,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;IAChB,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,YAAY;SAC1B;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,UAAU;YAChB,QAA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A;IAC/D,OAAO,KAAK,CAAE,CAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,KAAK,CAAC,CAAU,EAAE,IAAY;IACrC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/D,CAAC","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n *\n * RackCell — a single storage slot within an AsrsRack.\n *\n * A RackCell is a virtual component: it occupies a specific (bay, row, level)\n * coordinate within the parent rack and acts as a CarrierHolder for one carrier\n * (or several, depending on `cellType`).\n *\n * The crane (AsrsCrane) navigates toward a RackCell as its `place()` destination —\n * because the rack cell is a discrete component, Mover.moveTo() can target it\n * directly and arrive at exactly the right bay × level position.\n *\n * Visual: invisible in 2D (no visible 2D footprint — rack cells don't make\n * sense as 2D top-down boxes). In 3D, each cell is an invisible Group\n * positioned within the rack's coordinate space (RackCell3D handles\n * this via updateTransform override).\n *\n * Lifecycle: AsrsRack._buildCells() instantiates RackCell children.\n * Do not create RackCell components manually — they are managed by the rack.\n *\n * Domain aliases:\n * cell.store(carrier) ← cell.receive(carrier)\n * cell.retrieve(carrier, target) ← cell.dispatch(carrier, target)\n */\n\nimport {\n Component,\n ComponentNature,\n ContainerAbstract,\n RealObject,\n TRANSFER_SLOT_KEY,\n sceneComponent\n} from '@hatiolab/things-scene'\nimport type { State, Material3D } from '@hatiolab/things-scene'\nimport { CarrierHolder, type AttachFrame } from '@operato/scene-base'\n\nimport { RackCell3D } from './rack-cell-3d.js'\n\n/**\n * How many carriers a cell can hold simultaneously.\n * - single: exactly 1 (typical pallet bay)\n * - multi: small stack (up to 4, e.g. a multi-deep tray)\n * - bulk: unlimited (e.g. a floor area measured in slots)\n */\nexport type RackCellType = 'single' | 'multi' | 'bulk'\n\n/** RackCell 컴포넌트 state */\nexport interface RackCellState extends State {\n // ── 식별 ──\n cellId?: string\n cellType?: RackCellType\n\n // ── 3D 재질 ──\n material3d?: Material3D\n}\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: false,\n rotatable: false,\n properties: [\n {\n type: 'string',\n label: 'cell-id',\n name: 'cellId',\n placeholder: 'e.g. 0-0-0'\n },\n {\n type: 'select',\n label: 'cell-type',\n name: 'cellType',\n property: {\n options: [\n { display: 'Single', value: 'single' },\n { display: 'Multi', value: 'multi' },\n { display: 'Bulk', value: 'bulk' }\n ]\n }\n }\n ],\n help: 'scene/component/rack-cell'\n}\n\n/**\n * RackCell — single-slot storage cell inside an AsrsRack.\n *\n * Mixin chain: CarrierHolder(ContainerAbstract)\n * - CarrierHolder: publishes attachPointFor(), gates containable() to Carriables\n * - ContainerAbstract: manages child carrier components\n *\n * No Placeable mixin — RackCell3D self-positions from the parent rack's\n * CellMap (via updateTransform override), bypassing things-scene's standard\n * 2D→3D coordinate mapping which cannot express 3D levels.\n */\n@sceneComponent('rack-cell')\nexport default class RackCell extends CarrierHolder(ContainerAbstract) {\n declare state: RackCellState\n\n // ── Identification ────────────────────────────────────────────────────────\n\n get cellId(): string {\n return this.state.cellId ?? ''\n }\n\n get cellType(): RackCellType {\n return this.state.cellType ?? 'single'\n }\n\n /** Maximum carrier count for this cell based on cellType. */\n get capacity(): number {\n switch (this.cellType) {\n case 'single': return 1\n case 'multi': return 4\n case 'bulk': return Infinity\n }\n }\n\n // ── Interface ─────────────────────────────────────────────────────────────\n\n get nature(): ComponentNature {\n return NATURE\n }\n\n get anchors(): [] {\n return []\n }\n\n // ── Transfer protocol ─────────────────────────────────────────────────────\n\n /** True when fewer carriers are currently held than capacity. */\n canReceive(_component?: any): boolean {\n const occupied = (this.components as Component[] | undefined)?.length ?? 0\n return occupied < this.capacity\n }\n\n /**\n * Accept a carrier into this cell.\n * Sets TRANSFER_SLOT_KEY = cellId on the carrier, then reparents.\n * Fires 'transfer-received' so monitors can react.\n */\n async receive(carrier: any, options: any = {}): Promise<void> {\n if (!this.canReceive(carrier)) {\n this.trigger('transfer-rejected', {\n type: 'transfer-rejected',\n component: carrier,\n container: this,\n reason: 'no-slot'\n })\n return\n }\n carrier[TRANSFER_SLOT_KEY] = this.cellId\n this.reparent(carrier, options)\n this.trigger('transfer-received', {\n type: 'transfer-received',\n component: carrier,\n container: this,\n slotId: this.cellId\n })\n }\n\n /**\n * Release a carrier from this cell to `target`.\n * Delegates to `target.receive()` if available, otherwise `target.reparent()`.\n */\n async dispatch(carrier: any, target: any, options: any = {}): Promise<void> {\n if (target?.canReceive && !target.canReceive(carrier)) {\n this.trigger('transfer-rejected', {\n type: 'transfer-rejected',\n component: carrier,\n container: this,\n reason: 'target-full'\n })\n return\n }\n delete carrier[TRANSFER_SLOT_KEY]\n if (typeof target?.receive === 'function') {\n await target.receive(carrier, options)\n } else {\n ;(target as any).reparent?.(carrier, options)\n }\n this.trigger('transfer-dispatched', {\n type: 'transfer-dispatched',\n component: carrier,\n container: this,\n target\n })\n }\n\n // ── Domain aliases ────────────────────────────────────────────────────────\n\n /** Alias for receive() — semantic sugar for the storage domain. */\n store(carrier: any, options?: any): Promise<void> {\n return this.receive(carrier, options)\n }\n\n /** Alias for dispatch() — semantic sugar for the storage domain. */\n retrieve(carrier: any, target: any, options?: any): Promise<void> {\n return this.dispatch(carrier, target, options)\n }\n\n // ── 3D attach frame ───────────────────────────────────────────────────────\n\n /**\n * Return the 3D attach frame for carriers placed in this cell.\n * Carriers are lifted by their own halfDepth so the bottom face\n * rests at the cell's Y-center (which is levelHeight/2 above the beam).\n */\n attachPointFor(carrier: Component): AttachFrame | null {\n const root = this._realObject?.object3d\n if (!root) return null\n const carrierDepth = resolveCarrierDepth(carrier)\n return {\n attach: root,\n localPosition: { x: 0, y: carrierDepth / 2, z: 0 }\n }\n }\n\n // ── 2D rendering ──────────────────────────────────────────────────────────\n\n /** RackCell has no 2D visual — the rack draws its own structure. */\n render(_ctx: CanvasRenderingContext2D) {\n // intentional no-op\n }\n\n // ── 3D ───────────────────────────────────────────────────────────────────\n\n buildRealObject(): RealObject | undefined {\n return new RackCell3D(this)\n }\n}\n\nfunction resolveCarrierDepth(c: Component): number {\n const eff = (c as any)._realObject?.effectiveDepth\n if (typeof eff === 'number' && Number.isFinite(eff)) return eff\n return numOr((c as any)?.state?.depth, 0)\n}\n\nfunction numOr(v: unknown, dflt: number): number {\n return typeof v === 'number' && Number.isFinite(v) ? v : dflt\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"spot-3d.js","sourceRoot":"","sources":["../src/spot-3d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,WAAW,EAEZ,MAAM,wBAAwB,CAAA;AAE/B,MAAM,iBAAiB,GAAG,SAAS,CAAA;AACnC,MAAM,gBAAgB,GAAG,IAAI,CAAA,CAAC,4BAA4B;AAE1D,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAA;QAEb,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAY,CAAA;QACzC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACxD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACzD,MAAM,CAAC,GAAG,IAAI,CAAC,cAAc,CAAA,CAAC,0BAA0B;QACxD,wEAAwE;QACxE,uEAAuE;QACvE,oEAAoE;QACpE,MAAM,QAAQ,GAAG,WAAW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AE,CAAC,CAAC,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,KAAK,CAAC,CAAU,EAAE,IAAY;IACrC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/D,CAAC","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n *\n * Spot 3D — translucent floor pad.\n *\n * Renders only the FLOOR face of the conceptual zone box; side walls are\n * absent. Children (carriers) sit on the top face via an explicit attach\n * frame; the pad doesn't occlude them (`depthWrite: false`).\n *\n * Standard things-scene properties read directly:\n * - state.fillStyle → pad color (sole color source)\n * - state.strokeStyle → outline color (defaults to fillStyle)\n * - state.alpha → pad transparency, multiplied with the base 0.35 tint\n * - state.text → label, rendered as a CanvasTexture quad on the pad\n * - state.fontColor → label fill (defaults to fillStyle)\n * - state.fontSize / fontFamily / bold / italic → label typography\n * (composed via the things-scene fontStyle helper)\n * - state.material3d → metalness / roughness / castShadow / receiveShadow\n * (resolved + applied via the things-scene helpers,\n * no hard-coded numbers)\n */\n\nimport * as THREE from 'three'\nimport {\n RealObjectGroup,\n resolveMaterial3d,\n applyMaterial3dProps,\n fontStyle,\n opaqueColor,\n type Material3D\n} from '@hatiolab/things-scene'\n\nconst DEFAULT_PAD_COLOR = '#3a8fbd'\nconst BASE_PAD_OPACITY = 0.35 // multiplied by state.alpha\n\nexport class Spot3D extends RealObjectGroup {\n build() {\n super.build()\n\n const state = this.component.state as any\n const w = Math.max(Math.abs(numOr(state.width, 100)), 1)\n const h = Math.max(Math.abs(numOr(state.height, 100)), 1)\n const d = this.effectiveDepth // 2 by default (thin pad)\n // opaqueColor strips alpha from rgba/hsla strings — THREE.Color doesn't\n // honor alpha, would emit a console warning, and ignore the alpha bit.\n // The actual transparency comes through the material.opacity below.\n const padColor = opaqueColor((state.fillStyle as string) || DEFAULT_PAD_COLOR)\n const alpha = clamp(numOr(state.alpha, 1), 0, 1)\n const padOpacity = clamp(BASE_PAD_OPACITY * alpha, 0.05, 1)\n\n // material3d: pulls user-set metalness / roughness / shadow / side.\n // Local defaults (transparent + DoubleSide + depthWrite:false) come\n // from the constructor below; user values override via applyMaterial3dProps.\n const resolved = resolveMaterial3d(state.material3d as Material3D | undefined)\n\n // ── Floor pad (the only visible surface of the conceptual zone box) ──\n const padThickness = Math.max(d * 0.4, 0.5)\n const padMat = new THREE.MeshStandardMaterial({\n color: padColor,\n transparent: true,\n opacity: padOpacity,\n side: THREE.DoubleSide,\n depthWrite: false\n })\n applyMaterial3dProps(padMat, resolved)\n const pad = new THREE.Mesh(new THREE.BoxGeometry(w, padThickness, h), padMat)\n pad.position.set(0, -d / 2 + padThickness / 2, 0)\n pad.castShadow = resolved.castShadow\n pad.receiveShadow = resolved.receiveShadow\n this.object3d.add(pad)\n\n // ── Outline of the zone footprint (line on the floor) ──\n const outlineGeo = new THREE.BufferGeometry().setFromPoints([\n new THREE.Vector3(-w / 2, -d / 2 + padThickness + 0.05, -h / 2),\n new THREE.Vector3(w / 2, -d / 2 + padThickness + 0.05, -h / 2),\n new THREE.Vector3(w / 2, -d / 2 + padThickness + 0.05, h / 2),\n new THREE.Vector3(-w / 2, -d / 2 + padThickness + 0.05, h / 2),\n new THREE.Vector3(-w / 2, -d / 2 + padThickness + 0.05, -h / 2)\n ])\n const outlineMat = new THREE.LineBasicMaterial({\n color: opaqueColor((state.strokeStyle as string) || padColor),\n transparent: true,\n opacity: 0.7 * alpha\n })\n const outline = new THREE.Line(outlineGeo, outlineMat)\n this.object3d.add(outline)\n\n // ── Label (uses standard text + font fields) ──\n const text = state.text\n if (typeof text === 'string' && text.length > 0) {\n const label = this._buildLabel(text, state, padColor, w, h)\n if (label) {\n label.position.set(0, -d / 2 + padThickness + Math.max(w, h) * 0.05, 0)\n this.object3d.add(label)\n }\n }\n }\n\n /**\n * Build the label as a canvas-textured quad. Uses the same `fontStyle`\n * helper things-scene uses for its 2D text rendering, so the label\n * here matches what the property panel previews.\n */\n private _buildLabel(text: string, state: any, defaultColor: string, w: number, h: number): THREE.Mesh | null {\n const fontSize = clamp(numOr(state.fontSize, 36), 8, 200)\n const fontFamily = String(state.fontFamily ?? 'sans-serif')\n const bold = !!state.bold\n const italic = !!state.italic\n const color = (state.fontColor as string) || defaultColor\n\n const canvas = document.createElement('canvas')\n canvas.width = 512\n canvas.height = 128\n const ctx = canvas.getContext('2d')\n if (!ctx) return null\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n ctx.font = fontStyle(bold, italic, fontSize, fontFamily)\n ctx.fillStyle = color\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n ctx.fillText(text, canvas.width / 2, canvas.height / 2)\n const tex = new THREE.CanvasTexture(canvas)\n tex.needsUpdate = true\n const labelMat = new THREE.MeshBasicMaterial({\n map: tex,\n transparent: true,\n depthWrite: false,\n side: THREE.DoubleSide\n })\n const labelW = Math.min(w, h) * 0.6\n const labelH = labelW * (canvas.height / canvas.width)\n const mesh = new THREE.Mesh(new THREE.PlaneGeometry(labelW, labelH), labelMat)\n mesh.rotation.x = -Math.PI / 2 // lay flat, readable from above\n return mesh\n }\n\n /**\n * The sub-frame that carrier components should mount onto.\n *\n * Semantically Spot is a virtual cuboid SPACE — it marks \"stuff goes\n * here\" — and carriers are placed INSIDE that space, resting on the\n * cuboid's BOTTOM face. So the attach frame sits at the cuboid's\n * bottom (`y = -d/2` in spot-local), NOT at the top of the rendered\n * pad. The pad is just a translucent visual marker for the zone; the\n * floor of the conceptual volume is what carriers stand on.\n *\n * The Spot.attachPointFor mixin lifts the carrier by its own halfDepth\n * (in the +Y direction within this frame), placing the carrier's\n * BOTTOM face exactly at the cuboid floor.\n */\n getAttachFrame(): THREE.Object3D {\n if (!this._attachFrame) {\n const d = this.effectiveDepth\n this._attachFrame = new THREE.Object3D()\n this._attachFrame.position.set(0, -d / 2, 0)\n this.object3d.add(this._attachFrame)\n }\n return this._attachFrame\n }\n\n private _attachFrame?: THREE.Object3D\n\n updateDimension() {}\n\n onchange(after: Record<string, unknown>, before: Record<string, unknown>) {\n if (\n 'width' in after ||\n 'height' in after ||\n 'depth' in after ||\n 'fillStyle' in after ||\n 'strokeStyle' in after ||\n 'alpha' in after ||\n 'text' in after ||\n 'fontColor' in after ||\n 'fontSize' in after ||\n 'fontFamily' in after ||\n 'bold' in after ||\n 'italic' in after ||\n 'material3d' in after\n ) {\n this._attachFrame = undefined\n this.update()\n return\n }\n super.onchange(after, before)\n }\n\n // alpha is rebuilt into the materials on every build; opt out of the\n // base RealObject's \"multiply existing material opacity\" pass to avoid\n // double-application.\n updateAlpha() {}\n}\n\nfunction clamp(v: number, lo: number, hi: number) {\n return Math.max(lo, Math.min(hi, v))\n}\n\nfunction numOr(v: unknown, dflt: number): number {\n return typeof v === 'number' && Number.isFinite(v) ? v : dflt\n}\n"]}
1
+ {"version":3,"file":"spot-3d.js","sourceRoot":"","sources":["../src/spot-3d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,SAAS,EACT,WAAW,EAEZ,MAAM,wBAAwB,CAAA;AAE/B,MAAM,iBAAiB,GAAG,SAAS,CAAA;AACnC,MAAM,gBAAgB,GAAG,IAAI,CAAA,CAAC,4BAA4B;AAE1D,MAAM,OAAO,MAAO,SAAQ,eAAe;IACzC,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAA;QAEb,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAA;QAClC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;QACxD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG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,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,qEAAqE;IACrE,uEAAuE;IACvE,sBAAsB;IACtB,WAAW,KAAI,CAAC;CACjB;AAED,SAAS,KAAK,CAAC,CAAS,EAAE,EAAU,EAAE,EAAU;IAC9C,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,KAAK,CAAC,CAAU,EAAE,IAAY;IACrC,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC/D,CAAC","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n *\n * Spot 3D — translucent floor pad.\n *\n * Renders only the FLOOR face of the conceptual zone box; side walls are\n * absent. Children (carriers) sit on the top face via an explicit attach\n * frame; the pad doesn't occlude them (`depthWrite: false`).\n *\n * Standard things-scene properties read directly:\n * - state.fillStyle → pad color (sole color source)\n * - state.strokeStyle → outline color (defaults to fillStyle)\n * - state.alpha → pad transparency, multiplied with the base 0.35 tint\n * - state.text → label, rendered as a CanvasTexture quad on the pad\n * - state.fontColor → label fill (defaults to fillStyle)\n * - state.fontSize / fontFamily / bold / italic → label typography\n * (composed via the things-scene fontStyle helper)\n * - state.material3d → metalness / roughness / castShadow / receiveShadow\n * (resolved + applied via the things-scene helpers,\n * no hard-coded numbers)\n */\n\nimport * as THREE from 'three'\nimport {\n RealObjectGroup,\n resolveMaterial3d,\n applyMaterial3dProps,\n fontStyle,\n opaqueColor,\n type Material3D\n} from '@hatiolab/things-scene'\n\nconst DEFAULT_PAD_COLOR = '#3a8fbd'\nconst BASE_PAD_OPACITY = 0.35 // multiplied by state.alpha\n\nexport class Spot3D extends RealObjectGroup {\n build() {\n super.build()\n\n const state = this.component.state\n const w = Math.max(Math.abs(numOr(state.width, 100)), 1)\n const h = Math.max(Math.abs(numOr(state.height, 100)), 1)\n const d = this.effectiveDepth // 2 by default (thin pad)\n // opaqueColor strips alpha from rgba/hsla strings — THREE.Color doesn't\n // honor alpha, would emit a console warning, and ignore the alpha bit.\n // The actual transparency comes through the material.opacity below.\n const padColor = opaqueColor((state.fillStyle as string) || DEFAULT_PAD_COLOR)\n const alpha = clamp(numOr(state.alpha, 1), 0, 1)\n const padOpacity = clamp(BASE_PAD_OPACITY * alpha, 0.05, 1)\n\n // material3d: pulls user-set metalness / roughness / shadow / side.\n // Local defaults (transparent + DoubleSide + depthWrite:false) come\n // from the constructor below; user values override via applyMaterial3dProps.\n const resolved = resolveMaterial3d(state.material3d as Material3D | undefined)\n\n // ── Floor pad (the only visible surface of the conceptual zone box) ──\n const padThickness = Math.max(d * 0.4, 0.5)\n const padMat = new THREE.MeshStandardMaterial({\n color: padColor,\n transparent: true,\n opacity: padOpacity,\n side: THREE.DoubleSide,\n depthWrite: false\n })\n applyMaterial3dProps(padMat, resolved)\n const pad = new THREE.Mesh(new THREE.BoxGeometry(w, padThickness, h), padMat)\n pad.position.set(0, -d / 2 + padThickness / 2, 0)\n pad.castShadow = resolved.castShadow\n pad.receiveShadow = resolved.receiveShadow\n this.object3d.add(pad)\n\n // ── Outline of the zone footprint (line on the floor) ──\n const outlineGeo = new THREE.BufferGeometry().setFromPoints([\n new THREE.Vector3(-w / 2, -d / 2 + padThickness + 0.05, -h / 2),\n new THREE.Vector3(w / 2, -d / 2 + padThickness + 0.05, -h / 2),\n new THREE.Vector3(w / 2, -d / 2 + padThickness + 0.05, h / 2),\n new THREE.Vector3(-w / 2, -d / 2 + padThickness + 0.05, h / 2),\n new THREE.Vector3(-w / 2, -d / 2 + padThickness + 0.05, -h / 2)\n ])\n const outlineMat = new THREE.LineBasicMaterial({\n color: opaqueColor((state.strokeStyle as string) || padColor),\n transparent: true,\n opacity: 0.7 * alpha\n })\n const outline = new THREE.Line(outlineGeo, outlineMat)\n this.object3d.add(outline)\n\n // ── Label (uses standard text + font fields) ──\n const text = state.text\n if (typeof text === 'string' && text.length > 0) {\n const label = this._buildLabel(text, state, padColor, w, h)\n if (label) {\n label.position.set(0, -d / 2 + padThickness + Math.max(w, h) * 0.05, 0)\n this.object3d.add(label)\n }\n }\n }\n\n /**\n * Build the label as a canvas-textured quad. Uses the same `fontStyle`\n * helper things-scene uses for its 2D text rendering, so the label\n * here matches what the property panel previews.\n */\n private _buildLabel(text: string, state: any, defaultColor: string, w: number, h: number): THREE.Mesh | null {\n const fontSize = clamp(numOr(state.fontSize, 36), 8, 200)\n const fontFamily = String(state.fontFamily ?? 'sans-serif')\n const bold = !!state.bold\n const italic = !!state.italic\n const color = (state.fontColor as string) || defaultColor\n\n const canvas = document.createElement('canvas')\n canvas.width = 512\n canvas.height = 128\n const ctx = canvas.getContext('2d')\n if (!ctx) return null\n ctx.clearRect(0, 0, canvas.width, canvas.height)\n ctx.font = fontStyle(bold, italic, fontSize, fontFamily)\n ctx.fillStyle = color\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n ctx.fillText(text, canvas.width / 2, canvas.height / 2)\n const tex = new THREE.CanvasTexture(canvas)\n tex.needsUpdate = true\n const labelMat = new THREE.MeshBasicMaterial({\n map: tex,\n transparent: true,\n depthWrite: false,\n side: THREE.DoubleSide\n })\n const labelW = Math.min(w, h) * 0.6\n const labelH = labelW * (canvas.height / canvas.width)\n const mesh = new THREE.Mesh(new THREE.PlaneGeometry(labelW, labelH), labelMat)\n mesh.rotation.x = -Math.PI / 2 // lay flat, readable from above\n return mesh\n }\n\n /**\n * The sub-frame that carrier components should mount onto.\n *\n * Semantically Spot is a virtual cuboid SPACE — it marks \"stuff goes\n * here\" — and carriers are placed INSIDE that space, resting on the\n * cuboid's BOTTOM face. So the attach frame sits at the cuboid's\n * bottom (`y = -d/2` in spot-local), NOT at the top of the rendered\n * pad. The pad is just a translucent visual marker for the zone; the\n * floor of the conceptual volume is what carriers stand on.\n *\n * The Spot.attachPointFor mixin lifts the carrier by its own halfDepth\n * (in the +Y direction within this frame), placing the carrier's\n * BOTTOM face exactly at the cuboid floor.\n */\n getAttachFrame(): THREE.Object3D {\n if (!this._attachFrame) {\n const d = this.effectiveDepth\n this._attachFrame = new THREE.Object3D()\n this._attachFrame.position.set(0, -d / 2, 0)\n this.object3d.add(this._attachFrame)\n }\n return this._attachFrame\n }\n\n private _attachFrame?: THREE.Object3D\n\n updateDimension() {}\n\n onchange(after: Record<string, unknown>, before: Record<string, unknown>) {\n if (\n 'width' in after ||\n 'height' in after ||\n 'depth' in after ||\n 'fillStyle' in after ||\n 'strokeStyle' in after ||\n 'alpha' in after ||\n 'text' in after ||\n 'fontColor' in after ||\n 'fontSize' in after ||\n 'fontFamily' in after ||\n 'bold' in after ||\n 'italic' in after ||\n 'material3d' in after\n ) {\n this._attachFrame = undefined\n this.update()\n return\n }\n super.onchange(after, before)\n }\n\n // alpha is rebuilt into the materials on every build; opt out of the\n // base RealObject's \"multiply existing material opacity\" pass to avoid\n // double-application.\n updateAlpha() {}\n}\n\nfunction clamp(v: number, lo: number, hi: number) {\n return Math.max(lo, Math.min(hi, v))\n}\n\nfunction numOr(v: unknown, dflt: number): number {\n return typeof v === 'number' && Number.isFinite(v) ? v : dflt\n}\n"]}
package/dist/spot.d.ts CHANGED
@@ -1,7 +1,15 @@
1
1
  import { Component, ComponentNature, RealObject } from '@hatiolab/things-scene';
2
- import { type Alignment, type Heights, type PlacementArchetype } from '@operato/scene-base';
3
- declare const Base: typeof Component;
4
- export default class Spot extends Base {
2
+ import type { State, Material3D } from '@hatiolab/things-scene';
3
+ import { type AttachFrame, type Alignment, type Heights, type PlacementArchetype } from '@operato/scene-base';
4
+ import { Spot3D } from './spot-3d.js';
5
+ /** Spot 컴포넌트 state */
6
+ export interface SpotState extends State {
7
+ material3d?: Material3D;
8
+ }
9
+ declare const Spot_base: any;
10
+ export default class Spot extends Spot_base {
11
+ state: SpotState;
12
+ _realObject?: Spot3D;
5
13
  static placement: PlacementArchetype;
6
14
  static align: Alignment;
7
15
  static defaultDepth: (_h: Heights) => number;
@@ -29,13 +37,6 @@ export default class Spot extends Base {
29
37
  * falling back to raw `state.depth` for components built before
30
38
  * RealObject creation.
31
39
  */
32
- attachPointFor(carrier: Component): {
33
- attach: import("three").Object3D<import("three").Object3DEventMap>;
34
- localPosition: {
35
- x: number;
36
- y: number;
37
- z: number;
38
- };
39
- } | undefined;
40
+ attachPointFor(carrier: Component): AttachFrame | null;
40
41
  }
41
42
  export {};
package/dist/spot.js CHANGED
@@ -49,8 +49,7 @@ const NATURE = {
49
49
  // `ContainerAbstract` (not `Container`) — Container = MixinHTMLElement(ContainerAbstract),
50
50
  // which forces `isHTMLElement(): true` and trips the 3D pipeline's
51
51
  // addObject DOM-skip gate. Spot is purely 3D.
52
- const Base = CarrierHolder(Placeable(ContainerAbstract));
53
- let Spot = class Spot extends Base {
52
+ let Spot = class Spot extends CarrierHolder(Placeable(ContainerAbstract)) {
54
53
  static placement = 'floor';
55
54
  static align = 'bottom';
56
55
  static defaultDepth = (_h) => 2; // a thin pad
@@ -127,7 +126,7 @@ let Spot = class Spot extends Base {
127
126
  const ro = this._realObject;
128
127
  const frame = ro?.getAttachFrame?.();
129
128
  if (!frame)
130
- return undefined;
129
+ return null;
131
130
  const carrierDepth = resolveDepth(carrier);
132
131
  return {
133
132
  attach: frame,
package/dist/spot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"spot.js","sourceRoot":"","sources":["../src/spot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;AAEH,OAAO,EAA8B,iBAAiB,EAAc,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAClH,OAAO,EACL,aAAa,EACb,SAAS,EAIV,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAA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up / drop zone.\n *\n * A modeling-time anchor for \"this is where things land\" — the destination\n * of a robot arm pick-and-place, the slot of an AGV stop, the staging\n * zone next to a conveyor. Spot itself does not move and does\n * not perform any logistics action; it only marks a location and accepts\n * carrier components as children.\n *\n * Visual identity:\n * - 2D: outlined rectangle with corner \"L\" marks (so it reads as a\n * virtual zone, not a solid object).\n * - 3D: a thin translucent floor pad — only the floor of the conceptual\n * box is rendered, the side walls are absent.\n *\n * Standard things-scene properties used (no component-specific extras —\n * keep the property-panel UX uniform with other components):\n * - `fillStyle` — pad / outline color (sole color source)\n * - `strokeStyle` — outline color override (defaults to fillStyle)\n * - `lineWidth` / `lineDash` — outline stroke style\n * - `alpha` — overall transparency, framework-applied\n * - `text` / `fontColor` / `fontSize` / `fontFamily` / `bold` / `italic`\n * — label rendered by the standard text pipeline\n * - `material3d` (3D) — metalness / roughness / castShadow / receiveShadow\n *\n * Role: `CarrierHolder` — accepts any Carrier as a child and lays it on\n * the top face of the pad (overrides default attachPointFor).\n */\n\nimport { Component, ComponentNature, ContainerAbstract, RealObject, sceneComponent } from '@hatiolab/things-scene'\nimport {\n CarrierHolder,\n Placeable,\n type Alignment,\n type Heights,\n type PlacementArchetype\n} from '@operato/scene-base'\n\nimport { Spot3D } from './spot-3d.js'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n // No component-specific properties — fillStyle / strokeStyle / lineWidth /\n // alpha / text / font* are framework-standard, surfaced by the property\n // panel automatically.\n properties: [],\n help: 'scene/component/spot'\n}\n\n// ContainerAbstract base — Spot accepts carrier children (parcel/box/pallet/...).\n// CarrierHolder mixin only publishes the attach-point hook; the actual\n// child-list management comes from things-scene's container abstract.\n//\n// `ContainerAbstract` (not `Container`) — Container = MixinHTMLElement(ContainerAbstract),\n// which forces `isHTMLElement(): true` and trips the 3D pipeline's\n// addObject DOM-skip gate. Spot is purely 3D.\nconst Base = CarrierHolder(Placeable(ContainerAbstract)) as unknown as typeof Component\n\n@sceneComponent('spot')\nexport default class Spot extends Base {\n static placement: PlacementArchetype = 'floor'\n static align: Alignment = 'bottom'\n static defaultDepth = (_h: Heights) => 2 // a thin pad\n\n get nature(): ComponentNature {\n return NATURE\n }\n\n get anchors() {\n return []\n }\n\n /**\n * 2D — outlined rectangle + corner L marks. The pad body is drawn with a\n * fixed low alpha (0.15) on top of the user's `fillStyle` so the zone reads\n * as virtual even when fillStyle is fully opaque. Outline + corner marks\n * use `strokeStyle` (or fall back to `fillStyle`) at the user's `lineWidth`\n * and `lineDash`. The text label is drawn by the framework's standard\n * postrender pipeline using `text` / `fontColor` / `fontSize` / etc.\n */\n render(ctx: CanvasRenderingContext2D) {\n const { left = 0, top = 0, width = 100, height = 100 } = this.state\n const fillStyle = (this.state.fillStyle as string) || '#3a8fbd'\n const strokeStyle = (this.state.strokeStyle as string) || fillStyle\n const lineWidth = numOr(this.state.lineWidth, 1)\n const lineDashStyle = String(this.state.lineDash ?? 'dash')\n\n // ── Pad body (fixed-low-alpha tint of fillStyle) ───────────────────\n ctx.save()\n ctx.fillStyle = fillStyle\n ctx.globalAlpha = 0.15\n ctx.fillRect(left, top, width, height)\n ctx.restore()\n\n // ── Outline ────────────────────────────────────────────────────────\n ctx.save()\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n applyLineDash(ctx, lineDashStyle, lineWidth)\n ctx.strokeRect(\n left + lineWidth / 2,\n top + lineWidth / 2,\n width - lineWidth,\n height - lineWidth\n )\n ctx.setLineDash([])\n ctx.restore()\n\n // ── Corner L marks (solid, slightly heavier than outline) ──────────\n const ml = Math.min(width, height) * 0.18\n const cornerW = Math.max(lineWidth * 1.5, 1.5)\n ctx.save()\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = cornerW\n for (const [cx, cy, sx, sy] of [\n [left, top, 1, 1],\n [left + width, top, -1, 1],\n [left + width, top + height, -1, -1],\n [left, top + height, 1, -1]\n ] as [number, number, number, number][]) {\n ctx.beginPath()\n ctx.moveTo(cx + sx * ml, cy)\n ctx.lineTo(cx, cy)\n ctx.lineTo(cx, cy + sy * ml)\n ctx.stroke()\n }\n ctx.restore()\n }\n\n buildRealObject(): RealObject | undefined {\n return new Spot3D(this as any)\n }\n\n /**\n * Mount carriers on the TOP of the pad (Spot3D's `getAttachFrame` is\n * already at pad-top in spot-local). Then lift the carrier by its\n * own halfDepth so the carrier's BOTTOM rests ON the pad surface, not\n * its volumetric center — without this lift, half the carrier would\n * sink below the pad / floor.\n *\n * Reads `_realObject.effectiveDepth` first (the framework-resolved\n * value, accounting for `static defaultDepth` and parent context),\n * falling back to raw `state.depth` for components built before\n * RealObject creation.\n */\n attachPointFor(carrier: Component) {\n const ro = (this as any)._realObject as Spot3D | undefined\n const frame = ro?.getAttachFrame?.()\n if (!frame) return undefined\n const carrierDepth = resolveDepth(carrier)\n return {\n attach: frame,\n localPosition: { x: 0, y: carrierDepth / 2, z: 0 }\n }\n }\n}\n\nfunction resolveDepth(c: Component): number {\n const eff = (c as any)._realObject?.effectiveDepth\n if (typeof eff === 'number' && Number.isFinite(eff)) return eff\n return numOr((c as any)?.state?.depth, 0)\n}\n\nfunction numOr(v: unknown, dflt: number): number {\n return typeof v === 'number' && Number.isFinite(v) ? v : dflt\n}\n\n/**\n * Map a things-scene `lineDash` string to a Canvas dash pattern. Mirrors\n * the keys understood by things-scene's `drawer/stroke.ts` so users see\n * consistent options across components. Unknown strings fall through to\n * a plain dashed pattern instead of throwing on setLineDash.\n */\nfunction applyLineDash(ctx: CanvasRenderingContext2D, style: string, lw: number) {\n switch (style) {\n case 'solid':\n ctx.setLineDash([])\n return\n case 'round-dot':\n ctx.setLineDash([0.1, lw * 2])\n ctx.lineCap = 'round'\n return\n case 'square-dot':\n ctx.setLineDash([lw, lw])\n return\n case 'long-dash':\n ctx.setLineDash([lw * 6, lw * 3])\n return\n case 'dash-dot':\n ctx.setLineDash([lw * 4, lw * 2, lw, lw * 2])\n return\n case 'dash':\n default:\n ctx.setLineDash([lw * 4, lw * 1.5])\n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E,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;YAC7C,OAAM;QACR,KAAK,MAAM,CAAC;QACZ;YACE,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,GAAG,CAAC,CAAC,CAAA;YACnC,OAAM;IACV,CAAC;AACH,CAAC","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n *\n * Spot — virtual pickup / drop zone.\n *\n * A modeling-time anchor for \"this is where things land\" — the destination\n * of a robot arm pick-and-place, the slot of an AGV stop, the staging\n * zone next to a conveyor. Spot itself does not move and does\n * not perform any logistics action; it only marks a location and accepts\n * carrier components as children.\n *\n * Visual identity:\n * - 2D: outlined rectangle with corner \"L\" marks (so it reads as a\n * virtual zone, not a solid object).\n * - 3D: a thin translucent floor pad — only the floor of the conceptual\n * box is rendered, the side walls are absent.\n *\n * Standard things-scene properties used (no component-specific extras —\n * keep the property-panel UX uniform with other components):\n * - `fillStyle` — pad / outline color (sole color source)\n * - `strokeStyle` — outline color override (defaults to fillStyle)\n * - `lineWidth` / `lineDash` — outline stroke style\n * - `alpha` — overall transparency, framework-applied\n * - `text` / `fontColor` / `fontSize` / `fontFamily` / `bold` / `italic`\n * — label rendered by the standard text pipeline\n * - `material3d` (3D) — metalness / roughness / castShadow / receiveShadow\n *\n * Role: `CarrierHolder` — accepts any Carrier as a child and lays it on\n * the top face of the pad (overrides default attachPointFor).\n */\n\nimport { Component, ComponentNature, ContainerAbstract, RealObject, sceneComponent } from '@hatiolab/things-scene'\nimport type { State, Material3D } from '@hatiolab/things-scene'\nimport {\n CarrierHolder,\n Placeable,\n type AttachFrame,\n type Alignment,\n type Heights,\n type PlacementArchetype\n} from '@operato/scene-base'\n\nimport { Spot3D } from './spot-3d.js'\n\n/** Spot 컴포넌트 state */\nexport interface SpotState extends State {\n // Spot has no component-specific state — it uses standard fillStyle /\n // strokeStyle / lineWidth / alpha / text / font* / material3d.\n material3d?: Material3D\n}\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n // No component-specific properties — fillStyle / strokeStyle / lineWidth /\n // alpha / text / font* are framework-standard, surfaced by the property\n // panel automatically.\n properties: [],\n help: 'scene/component/spot'\n}\n\n// ContainerAbstract base — Spot accepts carrier children (parcel/box/pallet/...).\n// CarrierHolder mixin only publishes the attach-point hook; the actual\n// child-list management comes from things-scene's container abstract.\n//\n// `ContainerAbstract` (not `Container`) — Container = MixinHTMLElement(ContainerAbstract),\n// which forces `isHTMLElement(): true` and trips the 3D pipeline's\n// addObject DOM-skip gate. Spot is purely 3D.\n@sceneComponent('spot')\nexport default class Spot extends CarrierHolder(Placeable(ContainerAbstract)) {\n declare state: SpotState\n declare _realObject?: Spot3D\n\n static placement: PlacementArchetype = 'floor'\n static align: Alignment = 'bottom'\n static defaultDepth = (_h: Heights) => 2 // a thin pad\n\n get nature(): ComponentNature {\n return NATURE\n }\n\n get anchors() {\n return []\n }\n\n /**\n * 2D — outlined rectangle + corner L marks. The pad body is drawn with a\n * fixed low alpha (0.15) on top of the user's `fillStyle` so the zone reads\n * as virtual even when fillStyle is fully opaque. Outline + corner marks\n * use `strokeStyle` (or fall back to `fillStyle`) at the user's `lineWidth`\n * and `lineDash`. The text label is drawn by the framework's standard\n * postrender pipeline using `text` / `fontColor` / `fontSize` / etc.\n */\n render(ctx: CanvasRenderingContext2D) {\n const { left = 0, top = 0, width = 100, height = 100 } = this.state\n const fillStyle = (this.state.fillStyle as string) || '#3a8fbd'\n const strokeStyle = (this.state.strokeStyle as string) || fillStyle\n const lineWidth = numOr(this.state.lineWidth, 1)\n const lineDashStyle = String(this.state.lineDash ?? 'dash')\n\n // ── Pad body (fixed-low-alpha tint of fillStyle) ───────────────────\n ctx.save()\n ctx.fillStyle = fillStyle\n ctx.globalAlpha = 0.15\n ctx.fillRect(left, top, width, height)\n ctx.restore()\n\n // ── Outline ────────────────────────────────────────────────────────\n ctx.save()\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = lineWidth\n applyLineDash(ctx, lineDashStyle, lineWidth)\n ctx.strokeRect(\n left + lineWidth / 2,\n top + lineWidth / 2,\n width - lineWidth,\n height - lineWidth\n )\n ctx.setLineDash([])\n ctx.restore()\n\n // ── Corner L marks (solid, slightly heavier than outline) ──────────\n const ml = Math.min(width, height) * 0.18\n const cornerW = Math.max(lineWidth * 1.5, 1.5)\n ctx.save()\n ctx.strokeStyle = strokeStyle\n ctx.lineWidth = cornerW\n for (const [cx, cy, sx, sy] of [\n [left, top, 1, 1],\n [left + width, top, -1, 1],\n [left + width, top + height, -1, -1],\n [left, top + height, 1, -1]\n ] as [number, number, number, number][]) {\n ctx.beginPath()\n ctx.moveTo(cx + sx * ml, cy)\n ctx.lineTo(cx, cy)\n ctx.lineTo(cx, cy + sy * ml)\n ctx.stroke()\n }\n ctx.restore()\n }\n\n buildRealObject(): RealObject | undefined {\n return new Spot3D(this)\n }\n\n /**\n * Mount carriers on the TOP of the pad (Spot3D's `getAttachFrame` is\n * already at pad-top in spot-local). Then lift the carrier by its\n * own halfDepth so the carrier's BOTTOM rests ON the pad surface, not\n * its volumetric center — without this lift, half the carrier would\n * sink below the pad / floor.\n *\n * Reads `_realObject.effectiveDepth` first (the framework-resolved\n * value, accounting for `static defaultDepth` and parent context),\n * falling back to raw `state.depth` for components built before\n * RealObject creation.\n */\n attachPointFor(carrier: Component): AttachFrame | null {\n const ro = this._realObject\n const frame = ro?.getAttachFrame?.()\n if (!frame) return null\n const carrierDepth = resolveDepth(carrier)\n return {\n attach: frame,\n localPosition: { x: 0, y: carrierDepth / 2, z: 0 }\n }\n }\n}\n\nfunction resolveDepth(c: Component): number {\n const eff = (c as any)._realObject?.effectiveDepth\n if (typeof eff === 'number' && Number.isFinite(eff)) return eff\n return numOr((c as any)?.state?.depth, 0)\n}\n\nfunction numOr(v: unknown, dflt: number): number {\n return typeof v === 'number' && Number.isFinite(v) ? v : dflt\n}\n\n/**\n * Map a things-scene `lineDash` string to a Canvas dash pattern. Mirrors\n * the keys understood by things-scene's `drawer/stroke.ts` so users see\n * consistent options across components. Unknown strings fall through to\n * a plain dashed pattern instead of throwing on setLineDash.\n */\nfunction applyLineDash(ctx: CanvasRenderingContext2D, style: string, lw: number) {\n switch (style) {\n case 'solid':\n ctx.setLineDash([])\n return\n case 'round-dot':\n ctx.setLineDash([0.1, lw * 2])\n ctx.lineCap = 'round'\n return\n case 'square-dot':\n ctx.setLineDash([lw, lw])\n return\n case 'long-dash':\n ctx.setLineDash([lw * 6, lw * 3])\n return\n case 'dash-dot':\n ctx.setLineDash([lw * 4, lw * 2, lw, lw * 2])\n return\n case 'dash':\n default:\n ctx.setLineDash([lw * 4, lw * 1.5])\n return\n }\n}\n"]}
@@ -36,6 +36,7 @@ declare const _default: ({
36
36
  bays?: undefined;
37
37
  status?: undefined;
38
38
  carriageHeight?: undefined;
39
+ components?: undefined;
39
40
  };
40
41
  } | {
41
42
  type: string;
@@ -53,6 +54,7 @@ declare const _default: ({
53
54
  bays?: undefined;
54
55
  status?: undefined;
55
56
  carriageHeight?: undefined;
57
+ components?: undefined;
56
58
  };
57
59
  } | {
58
60
  type: string;
@@ -70,6 +72,7 @@ declare const _default: ({
70
72
  material?: undefined;
71
73
  status?: undefined;
72
74
  carriageHeight?: undefined;
75
+ components?: undefined;
73
76
  };
74
77
  } | {
75
78
  type: string;
@@ -87,6 +90,45 @@ declare const _default: ({
87
90
  material?: undefined;
88
91
  levels?: undefined;
89
92
  bays?: undefined;
93
+ components?: undefined;
94
+ };
95
+ } | {
96
+ type: string;
97
+ description: string;
98
+ group: string;
99
+ icon: string;
100
+ model: {
101
+ type: string;
102
+ top: number;
103
+ left: number;
104
+ width: number;
105
+ height: number;
106
+ components: ({
107
+ type: string;
108
+ top: number;
109
+ left: number;
110
+ width: number;
111
+ height: number;
112
+ levels: number;
113
+ bays: number;
114
+ status?: undefined;
115
+ carriageHeight?: undefined;
116
+ } | {
117
+ type: string;
118
+ top: number;
119
+ left: number;
120
+ width: number;
121
+ height: number;
122
+ status: string;
123
+ carriageHeight: number;
124
+ levels?: undefined;
125
+ bays?: undefined;
126
+ })[];
127
+ material?: undefined;
128
+ levels?: undefined;
129
+ bays?: undefined;
130
+ status?: undefined;
131
+ carriageHeight?: undefined;
90
132
  };
91
133
  })[];
92
134
  export default _default;