@fmsim/machine 1.0.88 → 2.0.0-beta.100

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 (165) hide show
  1. package/dist/agv-line.js.map +1 -1
  2. package/dist/agv.js +6 -2
  3. package/dist/agv.js.map +1 -1
  4. package/dist/buffer.js.map +1 -1
  5. package/dist/carrier-manager.js +183 -0
  6. package/dist/carrier-manager.js.map +1 -0
  7. package/dist/carrier.js +105 -14
  8. package/dist/carrier.js.map +1 -1
  9. package/dist/conveyor-join.js +8 -2
  10. package/dist/conveyor-join.js.map +1 -1
  11. package/dist/conveyor.js +9 -1
  12. package/dist/conveyor.js.map +1 -1
  13. package/dist/crane-rail.js +53 -0
  14. package/dist/crane-rail.js.map +1 -0
  15. package/dist/crane.js +144 -1
  16. package/dist/crane.js.map +1 -1
  17. package/dist/equipment.js.map +1 -1
  18. package/dist/factories/agv-3d.js +147 -0
  19. package/dist/factories/agv-3d.js.map +1 -0
  20. package/dist/factories/conveyor-3d.js +345 -0
  21. package/dist/factories/conveyor-3d.js.map +1 -0
  22. package/dist/factories/crane-3d.js +186 -0
  23. package/dist/factories/crane-3d.js.map +1 -0
  24. package/dist/factories/crane-rail-3d.js +95 -0
  25. package/dist/factories/crane-rail-3d.js.map +1 -0
  26. package/dist/factories/machine-3d.js +973 -0
  27. package/dist/factories/machine-3d.js.map +1 -0
  28. package/dist/factories/oht-3d.js +177 -0
  29. package/dist/factories/oht-3d.js.map +1 -0
  30. package/dist/factories/shuttle-3d.js +159 -0
  31. package/dist/factories/shuttle-3d.js.map +1 -0
  32. package/dist/factories/z-priority-defaults.js +33 -0
  33. package/dist/factories/z-priority-defaults.js.map +1 -0
  34. package/dist/factories/z-priority.js +54 -0
  35. package/dist/factories/z-priority.js.map +1 -0
  36. package/dist/features/conveyor-mixin.js.map +1 -1
  37. package/dist/features/mcs-status-default.js +15 -1
  38. package/dist/features/mcs-status-default.js.map +1 -1
  39. package/dist/features/mcs-status-mixin.js +22 -0
  40. package/dist/features/mcs-status-mixin.js.map +1 -1
  41. package/dist/features/mcs-zone-mixin.js.map +1 -1
  42. package/dist/features/parent-object-mixin.js +15 -7
  43. package/dist/features/parent-object-mixin.js.map +1 -1
  44. package/dist/floating-container.js +5 -0
  45. package/dist/floating-container.js.map +1 -1
  46. package/dist/index.js +58 -2
  47. package/dist/index.js.map +1 -1
  48. package/dist/mcs-carrier-holder.js +56 -17
  49. package/dist/mcs-carrier-holder.js.map +1 -1
  50. package/dist/mcs-machine.js +39 -0
  51. package/dist/mcs-machine.js.map +1 -1
  52. package/dist/mcs-unit.js +20 -0
  53. package/dist/mcs-unit.js.map +1 -1
  54. package/dist/mcs-vehicle.js +10 -4
  55. package/dist/mcs-vehicle.js.map +1 -1
  56. package/dist/node.js +10 -3
  57. package/dist/node.js.map +1 -1
  58. package/dist/oht-line.js.map +1 -1
  59. package/dist/oht.js +4 -0
  60. package/dist/oht.js.map +1 -1
  61. package/dist/port-flow.js +4 -0
  62. package/dist/port-flow.js.map +1 -1
  63. package/dist/port.js +4 -0
  64. package/dist/port.js.map +1 -1
  65. package/dist/scanner.js +30 -0
  66. package/dist/scanner.js.map +1 -0
  67. package/dist/scene/root-container-override.js +160 -96
  68. package/dist/scene/root-container-override.js.map +1 -1
  69. package/dist/shelf.js +4 -0
  70. package/dist/shelf.js.map +1 -1
  71. package/dist/shuttle.js.map +1 -1
  72. package/dist/static-container.js +5 -0
  73. package/dist/static-container.js.map +1 -1
  74. package/dist/stocker-abnormal-bar.js +184 -0
  75. package/dist/stocker-abnormal-bar.js.map +1 -0
  76. package/dist/stocker-capacity-bar.js +253 -6
  77. package/dist/stocker-capacity-bar.js.map +1 -1
  78. package/dist/stocker-carrier-bar.js +198 -0
  79. package/dist/stocker-carrier-bar.js.map +1 -0
  80. package/dist/stocker.js +7 -1
  81. package/dist/stocker.js.map +1 -1
  82. package/dist/templates/backdrop.js +30 -0
  83. package/dist/templates/backdrop.js.map +1 -0
  84. package/dist/templates/decal.js +21 -0
  85. package/dist/templates/decal.js.map +1 -0
  86. package/dist/templates/index.js +7 -1
  87. package/dist/templates/index.js.map +1 -1
  88. package/dist/templates/scanner.js +20 -0
  89. package/dist/templates/scanner.js.map +1 -0
  90. package/dist/tsconfig.tsbuildinfo +1 -1
  91. package/dist/utils/crane-position.js +83 -0
  92. package/dist/utils/crane-position.js.map +1 -0
  93. package/dist/utils/data-value.js +21 -0
  94. package/dist/utils/data-value.js.map +1 -0
  95. package/dist/utils/fit-gauge-scale.js +28 -0
  96. package/dist/utils/fit-gauge-scale.js.map +1 -0
  97. package/dist/utils/get-value-on-ranges.js +2 -4
  98. package/dist/utils/get-value-on-ranges.js.map +1 -1
  99. package/dist/utils/stocker-gauge.js +78 -0
  100. package/dist/utils/stocker-gauge.js.map +1 -0
  101. package/dist/zone-capacity-bar.js +3 -3
  102. package/dist/zone-capacity-bar.js.map +1 -1
  103. package/icons/backdrop.png +0 -0
  104. package/icons/decal.png +0 -0
  105. package/jest.config.js +10 -0
  106. package/package.json +7 -6
  107. package/src/agv-line.ts +1 -1
  108. package/src/agv.ts +10 -5
  109. package/src/buffer.ts +1 -1
  110. package/src/carrier-manager.ts +223 -0
  111. package/src/carrier.ts +111 -18
  112. package/src/conveyor-join.ts +6 -3
  113. package/src/conveyor.ts +10 -2
  114. package/src/crane-rail.ts +58 -0
  115. package/src/crane.ts +182 -2
  116. package/src/equipment.ts +1 -1
  117. package/src/factories/agv-3d.ts +160 -0
  118. package/src/factories/conveyor-3d.ts +398 -0
  119. package/src/factories/crane-3d.ts +217 -0
  120. package/src/factories/crane-rail-3d.ts +115 -0
  121. package/src/factories/machine-3d.ts +1192 -0
  122. package/src/factories/oht-3d.ts +196 -0
  123. package/src/factories/shuttle-3d.ts +179 -0
  124. package/src/factories/z-priority-defaults.ts +38 -0
  125. package/src/factories/z-priority.ts +60 -0
  126. package/src/features/conveyor-mixin.ts +1 -1
  127. package/src/features/mcs-status-default.ts +15 -1
  128. package/src/features/mcs-status-mixin.ts +26 -4
  129. package/src/features/mcs-zone-mixin.ts +1 -1
  130. package/src/features/parent-object-mixin.ts +17 -8
  131. package/src/floating-container.ts +5 -0
  132. package/src/index.ts +66 -2
  133. package/src/mcs-carrier-holder.ts +58 -29
  134. package/src/mcs-machine.ts +43 -1
  135. package/src/mcs-unit.ts +25 -2
  136. package/src/mcs-vehicle.ts +12 -9
  137. package/src/node.ts +9 -3
  138. package/src/oht-line.ts +1 -1
  139. package/src/oht.ts +7 -2
  140. package/src/port-flow.ts +6 -1
  141. package/src/port.ts +6 -1
  142. package/src/scanner.ts +29 -0
  143. package/src/scene/root-container-override.ts +156 -105
  144. package/src/shelf.ts +6 -1
  145. package/src/shuttle.ts +1 -1
  146. package/src/static-container.ts +5 -0
  147. package/src/stocker-abnormal-bar.ts +247 -0
  148. package/src/stocker-capacity-bar.ts +301 -10
  149. package/src/stocker-carrier-bar.ts +262 -0
  150. package/src/stocker.ts +10 -3
  151. package/src/templates/backdrop.ts +30 -0
  152. package/src/templates/decal.ts +21 -0
  153. package/src/templates/index.ts +7 -1
  154. package/src/templates/scanner.ts +20 -0
  155. package/src/utils/crane-position.ts +105 -0
  156. package/src/utils/data-value.ts +19 -0
  157. package/src/utils/fit-gauge-scale.ts +35 -0
  158. package/src/utils/get-value-on-ranges.ts +2 -4
  159. package/src/utils/stocker-gauge.ts +111 -0
  160. package/src/zone-capacity-bar.ts +5 -5
  161. package/translations/en.json +26 -1
  162. package/translations/ja.json +26 -1
  163. package/translations/ko.json +26 -1
  164. package/translations/ms.json +26 -1
  165. package/translations/zh.json +26 -1
@@ -0,0 +1,196 @@
1
+ /**
2
+ * OHT (Overhead Hoist Transport) 3D Factory
3
+ *
4
+ * 천장 레일에 매달려 이동하는 반송 차량. 캐리어를 호이스트로 운반.
5
+ * 구조 (바닥 원점, y=0~depth):
6
+ * - 하단 그리퍼 바 (캐리어 집는 가로 바)
7
+ * - 호이스트 암 (좌우 수직 기둥)
8
+ * - 본체 하우징 (statusColor 적용)
9
+ * - 상단 트롤리 (납작+넓은 레일 클램프 + 좌우 바퀴)
10
+ */
11
+
12
+ import * as THREE from 'three'
13
+ import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
14
+ import { RoundedBoxGeometry } from 'three/examples/jsm/geometries/RoundedBoxGeometry.js'
15
+ import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } from '@hatiolab/things-scene'
16
+ import type { Component } from '@hatiolab/things-scene'
17
+ import { TRANSPORT_SURFACE_HEIGHT } from './machine-3d.js'
18
+
19
+ const TROLLEY_COLOR = 0x222222
20
+ const FRAME_COLOR = 0x444444
21
+ const DEFAULT_BODY_COLOR = 0x6688cc
22
+
23
+ /** OHT 레일 높이: 스토커(5x) 위 */
24
+ const OHT_RAIL_HEIGHT = 6 * TRANSPORT_SURFACE_HEIGHT
25
+
26
+ export class OHT3D extends RealObjectGroup {
27
+ private _ownMeshes: THREE.Mesh[] = []
28
+ get effectiveDepth(): number {
29
+ const { depth } = this.component.state
30
+ return depth || TRANSPORT_SURFACE_HEIGHT
31
+ }
32
+
33
+ /** 천장 레일 높이에 배치 (center origin 기준: 레일 높이 + 볼륨 중심 반깊이) */
34
+ protected get syncZPosOffset(): number {
35
+ return OHT_RAIL_HEIGHT + this.effectiveDepth / 2
36
+ }
37
+
38
+ private resolveColor(): number {
39
+ const comp = this.component as any
40
+
41
+ try {
42
+ const sc = comp.statusColor
43
+ if (typeof sc === 'string' && sc && sc.toUpperCase() !== '#F0F0F0') return new THREE.Color(sc).getHex()
44
+ } catch {
45
+ /* statusColor 미구현 시 무시 */
46
+ }
47
+
48
+ const { fillStyle } = this.component.state
49
+ if (fillStyle && typeof fillStyle === 'string') {
50
+ try {
51
+ return new THREE.Color(fillStyle).getHex()
52
+ } catch {
53
+ /* 파싱 실패 시 무시 */
54
+ }
55
+ }
56
+
57
+ return DEFAULT_BODY_COLOR
58
+ }
59
+
60
+ build() {
61
+ super.build()
62
+
63
+ const { width = 10, height = 10 } = this.component.state
64
+ const w = Math.abs(width)
65
+ const h = Math.abs(height)
66
+ const d = this.effectiveDepth
67
+ if (!w || !h) return
68
+
69
+ // 높이 배분: 그리퍼 8%, 호이스트암 22%, 본체 45%, 간격 5%, 트롤리 12%, 바퀴 8%
70
+ const gripperBarH = d * 0.08
71
+ const armH = d * 0.22
72
+ const bodyH = d * 0.45
73
+ const gap = d * 0.05
74
+ const trolleyH = d * 0.12
75
+ const wheelH = d * 0.08
76
+
77
+ const armThickness = Math.min(w, h) * 0.12
78
+ const bodyCornerR = Math.min(w, h, bodyH) * 0.1
79
+
80
+ const frameMat = new THREE.MeshStandardMaterial({
81
+ color: FRAME_COLOR,
82
+ roughness: 0.5,
83
+ metalness: 0.4,
84
+ })
85
+
86
+ // ── 1. 하단 그리퍼 바 (캐리어를 집는 가로 바 — 이동 방향과 직교) ──
87
+ const gripperBarW = w * 0.7
88
+ const gripperBarD = h * 0.15
89
+ const gripperGeo = new THREE.BoxGeometry(gripperBarW, gripperBarH, gripperBarD)
90
+ const gripperMesh = new THREE.Mesh(gripperGeo, frameMat)
91
+ gripperMesh.position.y = gripperBarH / 2
92
+ gripperMesh.castShadow = true
93
+
94
+ // ── 2. 호이스트 암 (전후 수직 기둥 + 하단 연결 바) ──
95
+ const armBaseY = gripperBarH
96
+ const armGeometries: THREE.BufferGeometry[] = []
97
+
98
+ // 전후 수직 기둥 (레일 방향 = Z축)
99
+ for (const zSign of [-1, 1]) {
100
+ const pillar = new THREE.BoxGeometry(armThickness, armH, armThickness)
101
+ pillar.translate(0, armBaseY + armH / 2, zSign * (h * 0.3))
102
+ armGeometries.push(pillar)
103
+ }
104
+
105
+ // 하단 연결 바 (레일 방향으로 연결)
106
+ const crossBarD = h * 0.6 + armThickness
107
+ const crossBarH = armThickness * 0.6
108
+ const crossBar = new THREE.BoxGeometry(armThickness, crossBarH, crossBarD)
109
+ crossBar.translate(0, armBaseY + crossBarH / 2, 0)
110
+ armGeometries.push(crossBar)
111
+
112
+ const armMesh = new THREE.Mesh(BufferGeometryUtils.mergeGeometries(armGeometries), frameMat)
113
+ armMesh.castShadow = true
114
+
115
+ // ── 3. 본체 하우징 (statusColor 적용) ──
116
+ const bodyBaseY = armBaseY + armH
117
+ const bodyColor = this.resolveColor()
118
+ const bodyGeo = new RoundedBoxGeometry(w, bodyH, h, 4, bodyCornerR)
119
+ const bodyMat = new THREE.MeshStandardMaterial({
120
+ color: bodyColor,
121
+ roughness: 0.3,
122
+ metalness: 0.5,
123
+ })
124
+ const bodyMesh = new THREE.Mesh(bodyGeo, bodyMat)
125
+ bodyMesh.position.y = bodyBaseY + bodyH / 2
126
+ bodyMesh.castShadow = true
127
+ bodyMesh.receiveShadow = true
128
+
129
+ // ── 4. 상단 트롤리 플레이트 (레일 방향으로 길게 — Z축) ──
130
+ const trolleyBaseY = bodyBaseY + bodyH + gap
131
+ const trolleyW = w * 0.6
132
+ const trolleyD = h * 1.15
133
+ const trolleyGeo = new THREE.BoxGeometry(trolleyW, trolleyH, trolleyD)
134
+ const trolleyMat = new THREE.MeshStandardMaterial({
135
+ color: TROLLEY_COLOR,
136
+ roughness: 0.6,
137
+ metalness: 0.3,
138
+ })
139
+ const trolleyMesh = new THREE.Mesh(trolleyGeo, trolleyMat)
140
+ trolleyMesh.position.y = trolleyBaseY + trolleyH / 2
141
+ trolleyMesh.castShadow = true
142
+
143
+ // ── 5. 전후 바퀴 (트롤리 위, 레일 방향 = Z축) ──
144
+ const wheelBaseY = trolleyBaseY + trolleyH
145
+ const wheelRadius = wheelH / 2
146
+ const wheelDepth = w * 0.2
147
+ const wheelMeshes: THREE.Mesh[] = []
148
+ for (const zSign of [-1, 1]) {
149
+ const wheelGeo = new THREE.CylinderGeometry(wheelRadius, wheelRadius, wheelDepth, 12)
150
+ wheelGeo.rotateZ(Math.PI / 2)
151
+ const wheelMesh = new THREE.Mesh(wheelGeo, trolleyMat)
152
+ wheelMesh.position.set(0, wheelBaseY + wheelRadius, zSign * (trolleyD * 0.35))
153
+ wheelMesh.castShadow = true
154
+ wheelMeshes.push(wheelMesh)
155
+ }
156
+
157
+ this._ownMeshes = [gripperMesh, armMesh, bodyMesh, trolleyMesh, ...wheelMeshes]
158
+ for (const m of this._ownMeshes) this.components3D.add(m)
159
+ }
160
+
161
+ updateDimension() {}
162
+
163
+ update() {
164
+ for (const m of this._ownMeshes) {
165
+ this.components3D.remove(m)
166
+ disposeObject3D(m)
167
+ }
168
+ this._ownMeshes = []
169
+ this.build()
170
+ this.updateTransform()
171
+ this.updateAlpha()
172
+ this.updateHidden()
173
+ }
174
+
175
+ updateAlpha() {
176
+ const { alpha = 1 } = this.component.state
177
+ for (const m of this._ownMeshes) {
178
+ const materials = Array.isArray(m.material) ? m.material : [m.material]
179
+ for (const mat of materials) {
180
+ ;(mat as THREE.MeshStandardMaterial).opacity = alpha
181
+ ;(mat as THREE.MeshStandardMaterial).transparent = alpha < 1
182
+ }
183
+ }
184
+ }
185
+
186
+ onchange(after: Record<string, unknown>, before: Record<string, unknown>) {
187
+ if ('width' in after || 'height' in after || 'depth' in after ||
188
+ 'fillStyle' in after || 'strokeStyle' in after || 'id' in after) {
189
+ this.update()
190
+ return
191
+ }
192
+ super.onchange(after, before)
193
+ }
194
+ }
195
+
196
+ registerRealObjectFactory('OHT', (component: Component) => new OHT3D(component))
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Shuttle 3D Factory
3
+ *
4
+ * 스토커 내부에서 캐리어를 선반↔포트 간 이송하는 포크 캐리지.
5
+ * 수평 레일 위를 이동하며, 포크를 밀어넣어 캐리어를 적재/하역.
6
+ *
7
+ * 구조 (바닥 원점, y=0~depth):
8
+ * - 하단 베이스 플레이트 (납작, 넓음, 레일 위 주행부)
9
+ * - 중앙 마스트 (좌우 수직 기둥, statusColor 적용)
10
+ * - 상단 포크 (2개의 평행한 가로 암, 캐리어 적재면)
11
+ */
12
+
13
+ import * as THREE from 'three'
14
+ import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
15
+ import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } from '@hatiolab/things-scene'
16
+ import type { Component } from '@hatiolab/things-scene'
17
+ import { TRANSPORT_SURFACE_HEIGHT } from './machine-3d.js'
18
+
19
+ const BASE_COLOR = 0x333333
20
+ const FORK_COLOR = 0x777777
21
+ const DEFAULT_BODY_COLOR = 0x6688cc
22
+
23
+ export class Shuttle3D extends RealObjectGroup {
24
+ private _ownMeshes: THREE.Mesh[] = []
25
+ get effectiveDepth(): number {
26
+ const { depth } = this.component.state
27
+ return depth || TRANSPORT_SURFACE_HEIGHT
28
+ }
29
+
30
+ private resolveColor(): number {
31
+ const comp = this.component as any
32
+
33
+ try {
34
+ const sc = comp.statusColor
35
+ if (typeof sc === 'string' && sc && sc.toUpperCase() !== '#F0F0F0') return new THREE.Color(sc).getHex()
36
+ } catch {
37
+ /* statusColor 미구현 시 무시 */
38
+ }
39
+
40
+ const { fillStyle } = this.component.state
41
+ if (fillStyle && typeof fillStyle === 'string') {
42
+ try {
43
+ return new THREE.Color(fillStyle).getHex()
44
+ } catch {
45
+ /* 파싱 실패 시 무시 */
46
+ }
47
+ }
48
+
49
+ return DEFAULT_BODY_COLOR
50
+ }
51
+
52
+ build() {
53
+ super.build()
54
+
55
+ const { width = 10, height = 10 } = this.component.state
56
+ const w = Math.abs(width)
57
+ const h = Math.abs(height)
58
+ const d = this.effectiveDepth
59
+ if (!w || !h) return
60
+
61
+ // 높이 배분: 베이스 15%, 마스트 55%, 포크 30%
62
+ const baseH = d * 0.15
63
+ const mastH = d * 0.55
64
+ const forkH = d * 0.30
65
+
66
+ const mastThickness = Math.min(w, h) * 0.15
67
+
68
+ // ── 1. 하단 베이스 플레이트 (납작하고 넓은 주행부) ──
69
+ const basePad = Math.min(w, h) * 0.05
70
+ const baseGeo = new THREE.BoxGeometry(w + basePad * 2, baseH, h + basePad * 2)
71
+ const baseMat = new THREE.MeshStandardMaterial({
72
+ color: BASE_COLOR,
73
+ roughness: 0.7,
74
+ metalness: 0.3,
75
+ })
76
+ const baseMesh = new THREE.Mesh(baseGeo, baseMat)
77
+ baseMesh.position.y = baseH / 2
78
+ baseMesh.castShadow = true
79
+ baseMesh.receiveShadow = true
80
+
81
+ // ── 2. 좌우 마스트 기둥 (statusColor 적용) ──
82
+ const mastBaseY = baseH
83
+ const bodyColor = this.resolveColor()
84
+ const mastMat = new THREE.MeshStandardMaterial({
85
+ color: bodyColor,
86
+ roughness: 0.4,
87
+ metalness: 0.5,
88
+ })
89
+
90
+ const mastGeometries: THREE.BufferGeometry[] = []
91
+
92
+ // 좌우 수직 기둥
93
+ for (const xSign of [-1, 1]) {
94
+ const pillar = new THREE.BoxGeometry(mastThickness, mastH, mastThickness)
95
+ pillar.translate(xSign * (w / 2 - mastThickness / 2), mastBaseY + mastH / 2, 0)
96
+ mastGeometries.push(pillar)
97
+ }
98
+
99
+ // 중간 가로 연결 바 (구조 강성)
100
+ const crossBarW = w - mastThickness
101
+ const crossBarH = mastThickness * 0.5
102
+ const crossBar = new THREE.BoxGeometry(crossBarW, crossBarH, mastThickness)
103
+ crossBar.translate(0, mastBaseY + mastH * 0.4, 0)
104
+ mastGeometries.push(crossBar)
105
+
106
+ const mastMesh = new THREE.Mesh(BufferGeometryUtils.mergeGeometries(mastGeometries), mastMat)
107
+ mastMesh.castShadow = true
108
+
109
+ // ── 3. 상단 포크 (2개의 평행 암 + 백 플레이트) ──
110
+ const forkBaseY = mastBaseY + mastH
111
+ const forkMat = new THREE.MeshStandardMaterial({
112
+ color: FORK_COLOR,
113
+ roughness: 0.4,
114
+ metalness: 0.6,
115
+ })
116
+
117
+ const forkGeometries: THREE.BufferGeometry[] = []
118
+
119
+ // 백 플레이트 (마스트 상단을 잇는 가로판)
120
+ const backPlateH = forkH * 0.4
121
+ const backPlate = new THREE.BoxGeometry(w, backPlateH, mastThickness * 0.8)
122
+ backPlate.translate(0, forkBaseY + backPlateH / 2, -h * 0.35)
123
+ forkGeometries.push(backPlate)
124
+
125
+ // 2개의 포크 암 (앞으로 뻗은 평행 막대)
126
+ const forkArmW = mastThickness * 0.7
127
+ const forkArmH = forkH * 0.25
128
+ const forkArmD = h * 0.85
129
+ const forkSpacing = w * 0.55
130
+
131
+ for (const xSign of [-1, 1]) {
132
+ const arm = new THREE.BoxGeometry(forkArmW, forkArmH, forkArmD)
133
+ arm.translate(xSign * (forkSpacing / 2), forkBaseY + forkArmH / 2, forkArmD / 2 - h * 0.35)
134
+ forkGeometries.push(arm)
135
+ }
136
+
137
+ const forkMesh = new THREE.Mesh(BufferGeometryUtils.mergeGeometries(forkGeometries), forkMat)
138
+ forkMesh.castShadow = true
139
+
140
+ this._ownMeshes = [baseMesh, mastMesh, forkMesh]
141
+ for (const m of this._ownMeshes) this.components3D.add(m)
142
+ }
143
+
144
+ updateDimension() {}
145
+
146
+ update() {
147
+ for (const m of this._ownMeshes) {
148
+ this.components3D.remove(m)
149
+ disposeObject3D(m)
150
+ }
151
+ this._ownMeshes = []
152
+ this.build()
153
+ this.updateTransform()
154
+ this.updateAlpha()
155
+ this.updateHidden()
156
+ }
157
+
158
+ updateAlpha() {
159
+ const { alpha = 1 } = this.component.state
160
+ for (const m of this._ownMeshes) {
161
+ const materials = Array.isArray(m.material) ? m.material : [m.material]
162
+ for (const mat of materials) {
163
+ ;(mat as THREE.MeshStandardMaterial).opacity = alpha
164
+ ;(mat as THREE.MeshStandardMaterial).transparent = alpha < 1
165
+ }
166
+ }
167
+ }
168
+
169
+ onchange(after: Record<string, unknown>, before: Record<string, unknown>) {
170
+ if ('width' in after || 'height' in after || 'depth' in after ||
171
+ 'fillStyle' in after || 'strokeStyle' in after || 'id' in after) {
172
+ this.update()
173
+ return
174
+ }
175
+ super.onchange(after, before)
176
+ }
177
+ }
178
+
179
+ registerRealObjectFactory('Shuttle', (component: Component) => new Shuttle3D(component))
@@ -0,0 +1,38 @@
1
+ /*
2
+ * 기본 factory (RealObjectDomTexture) 를 쓰는 컴포넌트들에 대한 zPriority override.
3
+ *
4
+ * `factories/machine-3d.ts`, `conveyor-3d.ts`, `crane-rail-3d.ts` 등에 등록된
5
+ * 커스텀 RealObject 들은 자기 클래스에서 `get zPriority()` override. 그 외 컴포넌트는
6
+ * 기본 RealObjectDomTexture 를 쓰는데, 이 파일이 그것들도 priority 갖도록 등록.
7
+ *
8
+ * 패턴: registerRealObjectFactory(type, (component) => withZ(new RealObjectDomTexture(...), N))
9
+ */
10
+ import { registerRealObjectFactory, RealObjectDomTexture } from '@hatiolab/things-scene'
11
+ import type { Component } from '@hatiolab/things-scene'
12
+ import { Z_FMSIM } from './z-priority'
13
+
14
+ /** 주어진 RealObject 의 zPriority getter 를 override (instance level). */
15
+ function withZ<T extends RealObjectDomTexture>(ro: T, zPriority: number): T {
16
+ Object.defineProperty(ro, 'zPriority', {
17
+ get: () => zPriority,
18
+ configurable: true
19
+ })
20
+ return ro
21
+ }
22
+
23
+ /** RealObjectDomTexture 기반 컴포넌트에 priority 일괄 등록 helper. */
24
+ function registerWithPriority(type: string, zPriority: number) {
25
+ registerRealObjectFactory(type, (component: Component) =>
26
+ withZ(new RealObjectDomTexture(component), zPriority)
27
+ )
28
+ }
29
+
30
+ // ── 미등록 컴포넌트들 ──────────────────────────────────────
31
+ registerWithPriority('ConveyorJoin', Z_FMSIM.CONVEYOR_JOIN)
32
+ registerWithPriority('NodePath', Z_FMSIM.NODE_PATH)
33
+ registerWithPriority('container', Z_FMSIM.STATIC_CONTAINER)
34
+ registerWithPriority('FloatingContainer', Z_FMSIM.FLOATING_CONTAINER)
35
+ registerWithPriority('popup', Z_FMSIM.POPUP)
36
+ registerWithPriority('confidential-overlay', Z_FMSIM.CONFIDENTIAL_OVERLAY)
37
+ registerWithPriority('StockerAbnormalBar', Z_FMSIM.STOCKER_ABNORMAL_BAR)
38
+ registerWithPriority('StockerCarrierBar', Z_FMSIM.STOCKER_CARRIER_BAR)
@@ -0,0 +1,60 @@
1
+ /*
2
+ * fmsim 컴포넌트별 z-priority 상수.
3
+ *
4
+ * 같은 평면에 겹친 *다른 type 의* mesh 들이 GPU depth test 에서 결정적으로 정렬되도록
5
+ * 각 컴포넌트 type 마다 unique polygonOffset 값을 부여. 각 RealObject 가 자기 클래스에서
6
+ * `get zPriority(): number` override 로 이 상수 중 하나를 반환.
7
+ *
8
+ * 위치 (geometry vertex, object3d.position) 는 변경하지 않음 — depth buffer 의 fragment
9
+ * depth 값에만 미세 bias.
10
+ *
11
+ * 컨벤션 (높은 값 = 뒤로, 낮은 값 = 앞으로):
12
+ *
13
+ * [14~17] 바닥 paths/lines (가장 뒤)
14
+ * [11~13] 큰 영역 시각화 (container, 흐름 영역)
15
+ * [10] zone capacity bar (영역 표시)
16
+ * [1~9] 바닥 설비 (facility)
17
+ * [0] 이동 entity (AGV/OHT/Crane/Shuttle/Carrier) — default OBJECTS
18
+ * [-1~-4] 설비 위 indicator bar (decal)
19
+ * [-9~-10] overlay / popup (가장 앞)
20
+ */
21
+
22
+ export const Z_FMSIM = {
23
+ // ── Floor paths (가장 뒤 — 바닥에 그려지는 선) ──────────────
24
+ AGV_LINE: 17,
25
+ OHT_LINE: 16,
26
+ CRANE_RAIL: 15,
27
+ NODE_PATH: 14,
28
+ PORT_FLOW: 13,
29
+
30
+ // ── Container 영역 ────────────────────────────────────────
31
+ STATIC_CONTAINER: 12,
32
+ FLOATING_CONTAINER: 11,
33
+
34
+ // ── Zone 표시 ─────────────────────────────────────────────
35
+ ZONE_CAPACITY_BAR: 10,
36
+
37
+ // ── 바닥 설비 (facility) ──────────────────────────────────
38
+ NODE: 9,
39
+ SCANNER: 8,
40
+ PORT: 7,
41
+ SHELF: 6,
42
+ STOCKER: 5,
43
+ CONVEYOR: 4,
44
+ CONVEYOR_JOIN: 3,
45
+ BUFFER: 2,
46
+ EQUIPMENT: 1,
47
+
48
+ // ── 이동 entity — priority 0 (default OBJECTS), polygonOffset 미적용 ──
49
+ // AGV, OHT, Crane, Shuttle, Carrier — override 안 함
50
+
51
+ // ── 설비 위 status indicator bar (decal) ─────────────────
52
+ MCS_GAUGE_CAPACITY_BAR: -1,
53
+ STOCKER_CAPACITY_BAR: -2,
54
+ STOCKER_CARRIER_BAR: -3,
55
+ STOCKER_ABNORMAL_BAR: -4,
56
+
57
+ // ── Overlay / popup (가장 앞) ──────────────────────────────
58
+ POPUP: -9,
59
+ CONFIDENTIAL_OVERLAY: -10
60
+ } as const
@@ -50,7 +50,7 @@ function pattern(component: any) {
50
50
  return component._pattern
51
51
  }
52
52
 
53
- export function ConveyorMixin<TBase extends Constructor<Component>>(Base: TBase) {
53
+ export function ConveyorMixin<TBase extends new (...args: any[]) => any>(Base: TBase): any {
54
54
  const A = class extends Base {
55
55
  _pattern
56
56
 
@@ -61,10 +61,24 @@ export const LEGEND_CARRIER: Legend = {
61
61
  default: '#F0F0F0'
62
62
  }
63
63
 
64
+ /**
65
+ * carrier legend(테마) 해석 — carrier 컴포넌트(carrier.ts get legend)와 동일 로직 단일 소스.
66
+ * parent 에 carrierLegendName 이 지정되면 그 style 을, 아니면 board 전역 carrierLegendTheme,
67
+ * 둘 다 없으면 LEGEND_CARRIER 기본값. carrier 컴포넌트·스토커 게이지(2D/3D)가 공유한다.
68
+ */
69
+ export function resolveCarrierLegend(component: any): Legend {
70
+ const carrierLegendName = component?.parent?.state?.carrierLegendName
71
+ if (carrierLegendName) {
72
+ return (component.root as any)?.style?.[carrierLegendName] || LEGEND_CARRIER
73
+ }
74
+ return (component.root as any)?.carrierLegendTheme || LEGEND_CARRIER
75
+ }
76
+
64
77
  export const LEGEND_CAPACITY: Legend = {
65
78
  '0~20': '#5630D0',
66
79
  '20~80': '#8BDA5B',
67
- '80~100': '#FD9B00',
80
+ '80~': '#FD9B00', // 80% 이상 (= 100% 초과도 포함). 'from~' 형식이라
81
+ // getValueOnRanges 가 value >= 80 매칭.
68
82
  default: '#F0F0F0'
69
83
  }
70
84
 
@@ -1,12 +1,13 @@
1
+ import { Component } from '@hatiolab/things-scene'
2
+ import { themesColorMap } from '@fmsim/api'
3
+ import { LEGEND_NULL } from './mcs-status-default'
4
+
1
5
  type Constructor<T = {}> = new (...args: any[]) => T
2
6
 
3
7
  interface Legend {
4
8
  [key: string]: string
5
9
  }
6
10
 
7
- import { themesColorMap } from '@fmsim/api'
8
- import { LEGEND_NULL } from './mcs-status-default'
9
-
10
11
  export const MCSStatusMixinProperties = [
11
12
  {
12
13
  type: 'select',
@@ -18,7 +19,7 @@ export const MCSStatusMixinProperties = [
18
19
  }
19
20
  ]
20
21
 
21
- export function MCSStatusMixin<TBase extends Constructor>(Base: TBase) {
22
+ export function MCSStatusMixin<TBase extends Constructor<Component>>(Base: TBase): any {
22
23
  return class extends Base {
23
24
  isLVComponent() {
24
25
  return true
@@ -53,5 +54,26 @@ export function MCSStatusMixin<TBase extends Constructor>(Base: TBase) {
53
54
 
54
55
  return (status && legend && (legend[status] || legend[status!] || legend.default)) || legend?.default
55
56
  }
57
+
58
+ /**
59
+ * 데이터 변경 시 status 기반 색상을 state.fillStyle 로 반영.
60
+ * things-scene 표준 경로(updateFillStyle)가 2D/3D 모두 자동 갱신하도록 유도.
61
+ *
62
+ * 주의: state.fillStyle 이 runtime 색상으로 덮어써짐. 모델 저장 시 status 색상이
63
+ * 남을 수 있는 트레이드오프가 있음 (data-driven 컴포넌트의 fillStyle 은 의미상
64
+ * 초기값일 뿐 항상 status 가 덮어쓰는 것이 자연스러움).
65
+ */
66
+ onchangeData(after: any, before: any) {
67
+ // Base (mixin 인자) 의 onchangeData 를 렉시컬하게 호출.
68
+ // Object.getPrototypeOf(this) 는 leaf 를 가리켜 무한재귀되므로 Base.prototype 직접 사용.
69
+ const baseOnchange = (Base.prototype as any).onchangeData
70
+ if (typeof baseOnchange === 'function') {
71
+ baseOnchange.call(this, after, before)
72
+ }
73
+ const color = this.statusColor
74
+ if (color && color !== (this as any).state?.fillStyle) {
75
+ ;(this as any).setState('fillStyle', color)
76
+ }
77
+ }
56
78
  }
57
79
  }
@@ -10,7 +10,7 @@ export const MCSZoneMixinProperties = [
10
10
  }
11
11
  ]
12
12
 
13
- export function MCSZoneMixin<TBase extends Constructor<MCSUnit>>(Base: TBase) {
13
+ export function MCSZoneMixin<TBase extends Constructor<MCSUnit>>(Base: TBase): any {
14
14
  return class extends Base {
15
15
  get zone(): string | undefined {
16
16
  return
@@ -4,15 +4,14 @@ import { Component } from '@hatiolab/things-scene'
4
4
  import MCSMachine from '../mcs-machine'
5
5
  import MCSUnit from '../mcs-unit'
6
6
 
7
- export const ParentObjectMixinProperties = [
8
- {
9
- type: 'string',
10
- label: 'parent-object-id',
11
- name: 'parentObjectId'
12
- }
13
- ]
7
+ /**
8
+ * parentObjectId 는 generic property builder 가 아니라 property-sidebar 의 모델 참조
9
+ * 룩업(ox-input-entity-id, parentObjectTypes 기준 씬 머신/유닛 선택)으로 렌더한다.
10
+ * 따라서 NATURE 속성 목록에서는 제외 — 빈 배열.
11
+ */
12
+ export const ParentObjectMixinProperties: any[] = []
14
13
 
15
- export function ParentObjectMixin<TBase extends Constructor<Component>>(Base: TBase) {
14
+ export function ParentObjectMixin<TBase extends Constructor<Component>>(Base: TBase): any {
16
15
  return class extends Base {
17
16
  get parentObject(): MCSMachine | MCSUnit | undefined {
18
17
  const { id, parentObjectId } = this.state
@@ -32,5 +31,15 @@ export function ParentObjectMixin<TBase extends Constructor<Component>>(Base: TB
32
31
  return parent
33
32
  }
34
33
  }
34
+
35
+ /**
36
+ * parentObjectId 가 참조하는 모델 컴포넌트 타입들 — parentObject 후보를 모델(씬)에서
37
+ * 수집할 때 이 타입들로 거른다 (머신/유닛 무관, 복수 허용).
38
+ * 빈 배열(기본) 이면 모델의 모든 머신 (폴백). 참조 타입이 정해진 컴포넌트는 override:
39
+ * AGV→['AGVLine'], OHT→['OHTLine'], Crane/Shelf→['STOCKER'], PortFlow→['Port'].
40
+ */
41
+ get parentObjectTypes(): string[] {
42
+ return []
43
+ }
35
44
  }
36
45
  }
@@ -42,6 +42,11 @@ const NATURE = {
42
42
  }
43
43
  @sceneComponent('FloatingContainer')
44
44
  export default class FloatingContainer extends Container {
45
+ // things-scene 의 `declare const Container_base` 패턴이 base 인스턴스 타입의 accessor
46
+ // 정보를 object-type property 로 평탄화하여 TS2611 발생. 동일 위치를 override 하는
47
+ // 케이스가 operato-scene 엔 없어 fmsim 만 영향. things-scene 측 mixin 타입 패턴이
48
+ // 개선되면 제거.
49
+ // @ts-expect-error TS2611
45
50
  get position() {
46
51
  return this.app?.isViewMode ? 'absolute' : 'static'
47
52
  }