@fmsim/machine 2.0.0-beta.10 → 2.0.0-beta.101

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 (152) hide show
  1. package/dist/agv.js +6 -2
  2. package/dist/agv.js.map +1 -1
  3. package/dist/carrier-manager.js +183 -0
  4. package/dist/carrier-manager.js.map +1 -0
  5. package/dist/carrier.js +99 -9
  6. package/dist/carrier.js.map +1 -1
  7. package/dist/conveyor-join.js +8 -2
  8. package/dist/conveyor-join.js.map +1 -1
  9. package/dist/conveyor.js +8 -0
  10. package/dist/conveyor.js.map +1 -1
  11. package/dist/crane.js +144 -1
  12. package/dist/crane.js.map +1 -1
  13. package/dist/factories/agv-3d.js +17 -36
  14. package/dist/factories/agv-3d.js.map +1 -1
  15. package/dist/factories/conveyor-3d.js +179 -100
  16. package/dist/factories/conveyor-3d.js.map +1 -1
  17. package/dist/factories/crane-3d.js +56 -29
  18. package/dist/factories/crane-3d.js.map +1 -1
  19. package/dist/factories/crane-rail-3d.js +14 -18
  20. package/dist/factories/crane-rail-3d.js.map +1 -1
  21. package/dist/factories/machine-3d.js +533 -197
  22. package/dist/factories/machine-3d.js.map +1 -1
  23. package/dist/factories/oht-3d.js +29 -47
  24. package/dist/factories/oht-3d.js.map +1 -1
  25. package/dist/factories/shuttle-3d.js +13 -32
  26. package/dist/factories/shuttle-3d.js.map +1 -1
  27. package/dist/factories/z-priority-defaults.js +33 -0
  28. package/dist/factories/z-priority-defaults.js.map +1 -0
  29. package/dist/factories/z-priority.js +54 -0
  30. package/dist/factories/z-priority.js.map +1 -0
  31. package/dist/features/conveyor-mixin.js.map +1 -1
  32. package/dist/features/mcs-status-default.js +15 -1
  33. package/dist/features/mcs-status-default.js.map +1 -1
  34. package/dist/features/mcs-status-mixin.js +22 -0
  35. package/dist/features/mcs-status-mixin.js.map +1 -1
  36. package/dist/features/mcs-zone-mixin.js.map +1 -1
  37. package/dist/features/parent-object-mixin.js +15 -7
  38. package/dist/features/parent-object-mixin.js.map +1 -1
  39. package/dist/floating-container.js +5 -0
  40. package/dist/floating-container.js.map +1 -1
  41. package/dist/index.js +52 -34
  42. package/dist/index.js.map +1 -1
  43. package/dist/mcs-carrier-holder.js +56 -22
  44. package/dist/mcs-carrier-holder.js.map +1 -1
  45. package/dist/mcs-machine.js +20 -0
  46. package/dist/mcs-machine.js.map +1 -1
  47. package/dist/mcs-unit.js +17 -0
  48. package/dist/mcs-unit.js.map +1 -1
  49. package/dist/mcs-vehicle.js +8 -3
  50. package/dist/mcs-vehicle.js.map +1 -1
  51. package/dist/node.js +10 -3
  52. package/dist/node.js.map +1 -1
  53. package/dist/oht.js +4 -0
  54. package/dist/oht.js.map +1 -1
  55. package/dist/port-flow.js +4 -0
  56. package/dist/port-flow.js.map +1 -1
  57. package/dist/port.js +4 -0
  58. package/dist/port.js.map +1 -1
  59. package/dist/scanner.js +30 -0
  60. package/dist/scanner.js.map +1 -0
  61. package/dist/scene/root-container-override.js +160 -96
  62. package/dist/scene/root-container-override.js.map +1 -1
  63. package/dist/shelf.js +4 -0
  64. package/dist/shelf.js.map +1 -1
  65. package/dist/static-container.js +5 -0
  66. package/dist/static-container.js.map +1 -1
  67. package/dist/stocker-abnormal-bar.js +5 -1
  68. package/dist/stocker-abnormal-bar.js.map +1 -1
  69. package/dist/stocker-capacity-bar.js +253 -6
  70. package/dist/stocker-capacity-bar.js.map +1 -1
  71. package/dist/stocker-carrier-bar.js +5 -1
  72. package/dist/stocker-carrier-bar.js.map +1 -1
  73. package/dist/stocker.js +6 -0
  74. package/dist/stocker.js.map +1 -1
  75. package/dist/templates/backdrop.js +30 -0
  76. package/dist/templates/backdrop.js.map +1 -0
  77. package/dist/templates/decal.js +21 -0
  78. package/dist/templates/decal.js.map +1 -0
  79. package/dist/templates/index.js +7 -1
  80. package/dist/templates/index.js.map +1 -1
  81. package/dist/templates/scanner.js +20 -0
  82. package/dist/templates/scanner.js.map +1 -0
  83. package/dist/tsconfig.tsbuildinfo +1 -1
  84. package/dist/utils/crane-position.js +83 -0
  85. package/dist/utils/crane-position.js.map +1 -0
  86. package/dist/utils/data-value.js +21 -0
  87. package/dist/utils/data-value.js.map +1 -0
  88. package/dist/utils/fit-gauge-scale.js +28 -0
  89. package/dist/utils/fit-gauge-scale.js.map +1 -0
  90. package/dist/utils/get-value-on-ranges.js +2 -4
  91. package/dist/utils/get-value-on-ranges.js.map +1 -1
  92. package/dist/utils/stocker-gauge.js +78 -0
  93. package/dist/utils/stocker-gauge.js.map +1 -0
  94. package/dist/zone-capacity-bar.js +3 -3
  95. package/dist/zone-capacity-bar.js.map +1 -1
  96. package/icons/backdrop.png +0 -0
  97. package/icons/decal.png +0 -0
  98. package/jest.config.js +10 -0
  99. package/package.json +4 -3
  100. package/src/agv.ts +7 -2
  101. package/src/carrier-manager.ts +223 -0
  102. package/src/carrier.ts +103 -10
  103. package/src/conveyor-join.ts +5 -2
  104. package/src/conveyor.ts +8 -0
  105. package/src/crane.ts +181 -1
  106. package/src/factories/agv-3d.ts +19 -36
  107. package/src/factories/conveyor-3d.ts +183 -103
  108. package/src/factories/crane-3d.ts +62 -29
  109. package/src/factories/crane-rail-3d.ts +17 -20
  110. package/src/factories/machine-3d.ts +631 -205
  111. package/src/factories/oht-3d.ts +30 -46
  112. package/src/factories/shuttle-3d.ts +14 -32
  113. package/src/factories/z-priority-defaults.ts +38 -0
  114. package/src/factories/z-priority.ts +60 -0
  115. package/src/features/conveyor-mixin.ts +1 -1
  116. package/src/features/mcs-status-default.ts +15 -1
  117. package/src/features/mcs-status-mixin.ts +26 -4
  118. package/src/features/mcs-zone-mixin.ts +1 -1
  119. package/src/features/parent-object-mixin.ts +17 -8
  120. package/src/floating-container.ts +5 -0
  121. package/src/index.ts +58 -34
  122. package/src/mcs-carrier-holder.ts +57 -34
  123. package/src/mcs-machine.ts +23 -0
  124. package/src/mcs-unit.ts +21 -1
  125. package/src/mcs-vehicle.ts +9 -6
  126. package/src/node.ts +9 -3
  127. package/src/oht.ts +6 -1
  128. package/src/port-flow.ts +5 -0
  129. package/src/port.ts +5 -0
  130. package/src/scanner.ts +29 -0
  131. package/src/scene/root-container-override.ts +154 -103
  132. package/src/shelf.ts +5 -0
  133. package/src/static-container.ts +5 -0
  134. package/src/stocker-abnormal-bar.ts +6 -1
  135. package/src/stocker-capacity-bar.ts +298 -7
  136. package/src/stocker-carrier-bar.ts +6 -1
  137. package/src/stocker.ts +7 -0
  138. package/src/templates/backdrop.ts +30 -0
  139. package/src/templates/decal.ts +21 -0
  140. package/src/templates/index.ts +7 -1
  141. package/src/templates/scanner.ts +20 -0
  142. package/src/utils/crane-position.ts +105 -0
  143. package/src/utils/data-value.ts +19 -0
  144. package/src/utils/fit-gauge-scale.ts +35 -0
  145. package/src/utils/get-value-on-ranges.ts +2 -4
  146. package/src/utils/stocker-gauge.ts +111 -0
  147. package/src/zone-capacity-bar.ts +3 -3
  148. package/translations/en.json +26 -1
  149. package/translations/ja.json +26 -1
  150. package/translations/ko.json +26 -1
  151. package/translations/ms.json +26 -1
  152. package/translations/zh.json +26 -1
@@ -12,7 +12,7 @@
12
12
  import * as THREE from 'three'
13
13
  import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
14
14
  import { RoundedBoxGeometry } from 'three/examples/jsm/geometries/RoundedBoxGeometry.js'
15
- import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } from '@hatiolab/things-scene'
15
+ import { RealObjectGroup, registerRealObjectFactory, disposeObject3D, MaterialBank } from '@hatiolab/things-scene'
16
16
  import type { Component } from '@hatiolab/things-scene'
17
17
  import { TRANSPORT_SURFACE_HEIGHT } from './machine-3d.js'
18
18
 
@@ -30,9 +30,9 @@ export class OHT3D extends RealObjectGroup {
30
30
  return depth || TRANSPORT_SURFACE_HEIGHT
31
31
  }
32
32
 
33
- /** 천장 레일 높이에 배치 */
33
+ /** 천장 레일 높이에 배치 (center origin 기준: 레일 높이 + 볼륨 중심 반깊이) */
34
34
  protected get syncZPosOffset(): number {
35
- return OHT_RAIL_HEIGHT
35
+ return OHT_RAIL_HEIGHT + this.effectiveDepth / 2
36
36
  }
37
37
 
38
38
  private resolveColor(): number {
@@ -77,13 +77,10 @@ export class OHT3D extends RealObjectGroup {
77
77
  const armThickness = Math.min(w, h) * 0.12
78
78
  const bodyCornerR = Math.min(w, h, bodyH) * 0.1
79
79
 
80
- const frameMat = new THREE.MeshStandardMaterial({
81
- color: FRAME_COLOR,
82
- roughness: 0.5,
83
- metalness: 0.4,
84
- })
80
+ // MaterialBank 공유 — dedup + faint 안전(코어 변형 스왑, disposeObject3D 가 __bankOwned 스킵).
81
+ const frameMat = MaterialBank.material('oht|frame', { roughness: 0.5, metalness: 0.4 }, FRAME_COLOR)
85
82
 
86
- // ── 1. 하단 그리퍼 바 (캐리어를 집는 가로 바) ──
83
+ // ── 1. 하단 그리퍼 바 (캐리어를 집는 가로 바 — 이동 방향과 직교) ──
87
84
  const gripperBarW = w * 0.7
88
85
  const gripperBarD = h * 0.15
89
86
  const gripperGeo = new THREE.BoxGeometry(gripperBarW, gripperBarH, gripperBarD)
@@ -91,21 +88,21 @@ export class OHT3D extends RealObjectGroup {
91
88
  gripperMesh.position.y = gripperBarH / 2
92
89
  gripperMesh.castShadow = true
93
90
 
94
- // ── 2. 호이스트 암 (좌우 수직 기둥 + 하단 가로연결) ──
91
+ // ── 2. 호이스트 암 (전후 수직 기둥 + 하단 연결 바) ──
95
92
  const armBaseY = gripperBarH
96
93
  const armGeometries: THREE.BufferGeometry[] = []
97
94
 
98
- // 좌우 수직 기둥
99
- for (const xSign of [-1, 1]) {
95
+ // 전후 수직 기둥 (레일 방향 = Z축)
96
+ for (const zSign of [-1, 1]) {
100
97
  const pillar = new THREE.BoxGeometry(armThickness, armH, armThickness)
101
- pillar.translate(xSign * (w * 0.3), armBaseY + armH / 2, 0)
98
+ pillar.translate(0, armBaseY + armH / 2, zSign * (h * 0.3))
102
99
  armGeometries.push(pillar)
103
100
  }
104
101
 
105
- // 하단 가로 연결 바 (그리퍼와 암을 잇는 수평 바)
106
- const crossBarW = w * 0.6 + armThickness
102
+ // 하단 연결 바 (레일 방향으로 연결)
103
+ const crossBarD = h * 0.6 + armThickness
107
104
  const crossBarH = armThickness * 0.6
108
- const crossBar = new THREE.BoxGeometry(crossBarW, crossBarH, armThickness)
105
+ const crossBar = new THREE.BoxGeometry(armThickness, crossBarH, crossBarD)
109
106
  crossBar.translate(0, armBaseY + crossBarH / 2, 0)
110
107
  armGeometries.push(crossBar)
111
108
 
@@ -116,53 +113,48 @@ export class OHT3D extends RealObjectGroup {
116
113
  const bodyBaseY = armBaseY + armH
117
114
  const bodyColor = this.resolveColor()
118
115
  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
- })
116
+ const bodyMat = MaterialBank.material('oht|body', { roughness: 0.3, metalness: 0.5 }, bodyColor)
124
117
  const bodyMesh = new THREE.Mesh(bodyGeo, bodyMat)
125
118
  bodyMesh.position.y = bodyBaseY + bodyH / 2
126
119
  bodyMesh.castShadow = true
127
120
  bodyMesh.receiveShadow = true
128
121
 
129
- // ── 4. 상단 트롤리 플레이트 (납작하고 넓은 레일 클램프) ──
122
+ // ── 4. 상단 트롤리 플레이트 (레일 방향으로 길게 — Z축) ──
130
123
  const trolleyBaseY = bodyBaseY + bodyH + gap
131
- const trolleyW = w * 1.15
132
- const trolleyD = h * 0.6
124
+ const trolleyW = w * 0.6
125
+ const trolleyD = h * 1.15
133
126
  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
- })
127
+ const trolleyMat = MaterialBank.material('oht|trolley', { roughness: 0.6, metalness: 0.3 }, TROLLEY_COLOR)
139
128
  const trolleyMesh = new THREE.Mesh(trolleyGeo, trolleyMat)
140
129
  trolleyMesh.position.y = trolleyBaseY + trolleyH / 2
141
130
  trolleyMesh.castShadow = true
142
131
 
143
- // ── 5. 좌우 바퀴 (트롤리 위, 레일을 타는 원통형 바퀴) ──
132
+ // ── 5. 전후 바퀴 (트롤리 위, 레일 방향 = Z축) ──
144
133
  const wheelBaseY = trolleyBaseY + trolleyH
145
134
  const wheelRadius = wheelH / 2
146
- const wheelDepth = h * 0.2
135
+ const wheelDepth = w * 0.2
147
136
  const wheelMeshes: THREE.Mesh[] = []
148
- for (const xSign of [-1, 1]) {
137
+ for (const zSign of [-1, 1]) {
149
138
  const wheelGeo = new THREE.CylinderGeometry(wheelRadius, wheelRadius, wheelDepth, 12)
150
- wheelGeo.rotateX(Math.PI / 2)
139
+ wheelGeo.rotateZ(Math.PI / 2)
151
140
  const wheelMesh = new THREE.Mesh(wheelGeo, trolleyMat)
152
- wheelMesh.position.set(xSign * (trolleyW * 0.35), wheelBaseY + wheelRadius, 0)
141
+ wheelMesh.position.set(0, wheelBaseY + wheelRadius, zSign * (trolleyD * 0.35))
153
142
  wheelMesh.castShadow = true
154
143
  wheelMeshes.push(wheelMesh)
155
144
  }
156
145
 
157
146
  this._ownMeshes = [gripperMesh, armMesh, bodyMesh, trolleyMesh, ...wheelMeshes]
158
- for (const m of this._ownMeshes) this.object3d.add(m)
147
+ for (const m of this._ownMeshes) this.components3D.add(m)
148
+
149
+ // mesh 는 super.build() 이후 생성 → 코어 faint 를 명시 적용(편집 흐림이 mesh 에 닿게).
150
+ this.updateAlpha()
159
151
  }
160
152
 
161
153
  updateDimension() {}
162
154
 
163
155
  update() {
164
156
  for (const m of this._ownMeshes) {
165
- this.object3d.remove(m)
157
+ this.components3D.remove(m)
166
158
  disposeObject3D(m)
167
159
  }
168
160
  this._ownMeshes = []
@@ -172,16 +164,8 @@ export class OHT3D extends RealObjectGroup {
172
164
  this.updateHidden()
173
165
  }
174
166
 
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
- }
167
+ // updateAlpha override 제거 — 코어 RealObject.updateAlpha(=applyMaterialOpacity)로 수렴.
168
+ // canonical(bank base opacity 1) × state.alpha × faint. view 모드 불변, 편집 모드 faint 추가.
185
169
 
186
170
  onchange(after: Record<string, unknown>, before: Record<string, unknown>) {
187
171
  if ('width' in after || 'height' in after || 'depth' in after ||
@@ -12,7 +12,7 @@
12
12
 
13
13
  import * as THREE from 'three'
14
14
  import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'
15
- import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } from '@hatiolab/things-scene'
15
+ import { RealObjectGroup, registerRealObjectFactory, disposeObject3D, MaterialBank } from '@hatiolab/things-scene'
16
16
  import type { Component } from '@hatiolab/things-scene'
17
17
  import { TRANSPORT_SURFACE_HEIGHT } from './machine-3d.js'
18
18
 
@@ -27,10 +27,6 @@ export class Shuttle3D extends RealObjectGroup {
27
27
  return depth || TRANSPORT_SURFACE_HEIGHT
28
28
  }
29
29
 
30
- protected get syncZPosOffset(): number {
31
- return 0
32
- }
33
-
34
30
  private resolveColor(): number {
35
31
  const comp = this.component as any
36
32
 
@@ -72,11 +68,9 @@ export class Shuttle3D extends RealObjectGroup {
72
68
  // ── 1. 하단 베이스 플레이트 (납작하고 넓은 주행부) ──
73
69
  const basePad = Math.min(w, h) * 0.05
74
70
  const baseGeo = new THREE.BoxGeometry(w + basePad * 2, baseH, h + basePad * 2)
75
- const baseMat = new THREE.MeshStandardMaterial({
76
- color: BASE_COLOR,
77
- roughness: 0.7,
78
- metalness: 0.3,
79
- })
71
+ // MaterialBank 공유 — 정적/상태색 dedup + faint 안전(코어가 공유 base 변형 스왑). dispose 는
72
+ // disposeObject3D 가 __bankOwned 를 건너뛰어 안전.
73
+ const baseMat = MaterialBank.material('shuttle|base', { roughness: 0.7, metalness: 0.3 }, BASE_COLOR)
80
74
  const baseMesh = new THREE.Mesh(baseGeo, baseMat)
81
75
  baseMesh.position.y = baseH / 2
82
76
  baseMesh.castShadow = true
@@ -85,11 +79,7 @@ export class Shuttle3D extends RealObjectGroup {
85
79
  // ── 2. 좌우 마스트 기둥 (statusColor 적용) ──
86
80
  const mastBaseY = baseH
87
81
  const bodyColor = this.resolveColor()
88
- const mastMat = new THREE.MeshStandardMaterial({
89
- color: bodyColor,
90
- roughness: 0.4,
91
- metalness: 0.5,
92
- })
82
+ const mastMat = MaterialBank.material('shuttle|mast', { roughness: 0.4, metalness: 0.5 }, bodyColor)
93
83
 
94
84
  const mastGeometries: THREE.BufferGeometry[] = []
95
85
 
@@ -112,11 +102,7 @@ export class Shuttle3D extends RealObjectGroup {
112
102
 
113
103
  // ── 3. 상단 포크 (2개의 평행 암 + 백 플레이트) ──
114
104
  const forkBaseY = mastBaseY + mastH
115
- const forkMat = new THREE.MeshStandardMaterial({
116
- color: FORK_COLOR,
117
- roughness: 0.4,
118
- metalness: 0.6,
119
- })
105
+ const forkMat = MaterialBank.material('shuttle|fork', { roughness: 0.4, metalness: 0.6 }, FORK_COLOR)
120
106
 
121
107
  const forkGeometries: THREE.BufferGeometry[] = []
122
108
 
@@ -142,14 +128,17 @@ export class Shuttle3D extends RealObjectGroup {
142
128
  forkMesh.castShadow = true
143
129
 
144
130
  this._ownMeshes = [baseMesh, mastMesh, forkMesh]
145
- for (const m of this._ownMeshes) this.object3d.add(m)
131
+ for (const m of this._ownMeshes) this.components3D.add(m)
132
+
133
+ // mesh 는 super.build() 이후 생성 → 코어 faint 를 명시 적용(편집 흐림이 mesh 에 닿게).
134
+ this.updateAlpha()
146
135
  }
147
136
 
148
137
  updateDimension() {}
149
138
 
150
139
  update() {
151
140
  for (const m of this._ownMeshes) {
152
- this.object3d.remove(m)
141
+ this.components3D.remove(m)
153
142
  disposeObject3D(m)
154
143
  }
155
144
  this._ownMeshes = []
@@ -159,16 +148,9 @@ export class Shuttle3D extends RealObjectGroup {
159
148
  this.updateHidden()
160
149
  }
161
150
 
162
- updateAlpha() {
163
- const { alpha = 1 } = this.component.state
164
- for (const m of this._ownMeshes) {
165
- const materials = Array.isArray(m.material) ? m.material : [m.material]
166
- for (const mat of materials) {
167
- ;(mat as THREE.MeshStandardMaterial).opacity = alpha
168
- ;(mat as THREE.MeshStandardMaterial).transparent = alpha < 1
169
- }
170
- }
171
- }
151
+ // updateAlpha override 제거 — 코어 RealObject.updateAlpha(=applyMaterialOpacity)로 수렴.
152
+ // 코어가 canonical(=bank base, opacity 1) 위에 state.alpha × faint 를 일괄. view 모드는
153
+ // 1×state.alpha = 기존 in-place 결과와 동일 → 불변, 편집 모드만 faint 추가.
172
154
 
173
155
  onchange(after: Record<string, unknown>, before: Record<string, unknown>) {
174
156
  if ('width' in after || 'height' in after || 'depth' in after ||
@@ -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
  }
package/src/index.ts CHANGED
@@ -1,55 +1,74 @@
1
1
  // ── side-effect: scene override ──
2
- import './scene/root-container-override.js'
2
+ import './scene/root-container-override'
3
3
 
4
4
  // ── side-effect: 3D factories ──
5
- import './factories/machine-3d.js'
6
- import './factories/conveyor-3d.js'
7
- import './factories/agv-3d.js'
8
- import './factories/oht-3d.js'
9
- import './factories/shuttle-3d.js'
10
- import './factories/crane-3d.js'
11
- import './factories/crane-rail-3d.js'
5
+ import './factories/machine-3d'
6
+ import './factories/conveyor-3d'
7
+ import './factories/agv-3d'
8
+ import './factories/oht-3d'
9
+ import './factories/shuttle-3d'
10
+ import './factories/crane-3d'
11
+ import './factories/crane-rail-3d'
12
+ // 기본 factory (RealObjectDomTexture) 쓰는 컴포넌트들의 z-priority override
13
+ import './factories/z-priority-defaults'
12
14
 
13
15
  // ── side-effect: @sceneComponent 등록 (tree-shaking 방지) ──
14
- import './zone-capacity-bar.js'
15
- import './stocker-capacity-bar.js'
16
- import './stocker-carrier-bar.js'
17
- import './stocker-abnormal-bar.js'
18
- import './port-flow.js'
19
- import './agv-line.js'
20
- import './buffer.js'
21
- import './conveyor.js'
22
- import './conveyor-join.js'
23
- import './equipment.js'
24
- import './oht-line.js'
25
- import './stocker.js'
26
- import './crane-rail.js'
27
- import './agv.js'
28
- import './oht.js'
29
- import './shuttle.js'
30
- import './port.js'
31
- import './crane.js'
32
- import './shelf.js'
33
- import './carrier.js'
34
- import './node.js'
35
- import './node-path.js'
36
- import './floating-container.js'
37
- import './static-container.js'
38
- import './clickable-popup.js'
16
+ // bars & overlays
17
+ import './zone-capacity-bar'
18
+ import './stocker-capacity-bar'
19
+ import './stocker-carrier-bar'
20
+ import './stocker-abnormal-bar'
21
+ import './port-flow'
39
22
 
23
+ // facilities
24
+ import './agv-line'
25
+ import './buffer'
26
+ import './conveyor'
27
+ import './conveyor-join'
28
+ import './equipment'
29
+ import './oht-line'
30
+ import './stocker'
31
+ import './crane-rail'
32
+ import './scanner'
33
+
34
+ // vehicles
35
+ import './agv'
36
+ import './oht'
37
+ import './shuttle'
38
+
39
+ // units
40
+ import './port'
41
+ import './crane'
42
+ import './shelf'
43
+ import './carrier'
44
+
45
+ // topology
46
+ import './node'
47
+ import './node-path'
48
+
49
+ // containers
50
+ import './floating-container'
51
+ import './static-container'
52
+ import './clickable-popup'
53
+
54
+ // ── groups ──
40
55
  export { default as MachineGroups } from './groups'
41
56
 
57
+ // ── base classes ──
42
58
  export { default as MCSMachine } from './mcs-machine'
43
59
  export { default as MCSUnit } from './mcs-unit'
44
60
  export { default as MCSCarrierHolder } from './mcs-carrier-holder'
45
61
  export { default as MCSVehicle } from './mcs-vehicle'
46
62
  export { default as MCSTransport } from './mcs-transport'
63
+
64
+ // ── bars & overlays ──
47
65
  export { default as ZoneCapacityBar } from './zone-capacity-bar'
48
66
  export { default as StockerCapacityBar } from './stocker-capacity-bar'
49
67
  export { default as StockerCarrierBar } from './stocker-carrier-bar'
50
68
  export { default as StockerAbnormalBar } from './stocker-abnormal-bar'
51
69
  export { default as PortFlow } from './port-flow'
52
70
 
71
+ // ── facilities ──
53
72
  export { default as AGVLine } from './agv-line'
54
73
  export { default as Buffer } from './buffer'
55
74
  export { default as Conveyor } from './conveyor'
@@ -58,19 +77,24 @@ export { default as Equipment } from './equipment'
58
77
  export { default as OHTLine } from './oht-line'
59
78
  export { default as Stocker } from './stocker'
60
79
  export { default as CraneRail } from './crane-rail'
80
+ export { default as Scanner } from './scanner'
61
81
 
82
+ // ── vehicles ──
62
83
  export { default as AGV } from './agv'
63
84
  export { default as OHT } from './oht'
64
85
  export { default as Shuttle } from './shuttle'
65
86
 
87
+ // ── units ──
66
88
  export { default as Port } from './port'
67
89
  export { default as Crane } from './crane'
68
90
  export { default as Shelf } from './shelf'
69
91
  export { default as Carrier } from './carrier'
70
92
 
93
+ // ── topology ──
71
94
  export { default as Node } from './node'
72
95
  export { default as NodePath } from './node-path'
73
96
 
97
+ // ── containers ──
74
98
  export { default as FloatingContainer } from './floating-container'
75
- export { default as StaticContainer } from './static-container.js'
99
+ export { default as StaticContainer } from './static-container'
76
100
  export { default as ClickablePopup } from './clickable-popup'