@fmsim/machine 2.0.0-beta.7 → 2.0.0-beta.75

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 (119) hide show
  1. package/dist/agv.js +2 -2
  2. package/dist/agv.js.map +1 -1
  3. package/dist/carrier-manager.js +93 -0
  4. package/dist/carrier-manager.js.map +1 -0
  5. package/dist/carrier.js +81 -5
  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.map +1 -1
  12. package/dist/factories/agv-3d.js +8 -9
  13. package/dist/factories/agv-3d.js.map +1 -1
  14. package/dist/factories/conveyor-3d.js +166 -81
  15. package/dist/factories/conveyor-3d.js.map +1 -1
  16. package/dist/factories/crane-3d.js +5 -7
  17. package/dist/factories/crane-3d.js.map +1 -1
  18. package/dist/factories/crane-rail-3d.js +4 -6
  19. package/dist/factories/crane-rail-3d.js.map +1 -1
  20. package/dist/factories/machine-3d.js +384 -133
  21. package/dist/factories/machine-3d.js.map +1 -1
  22. package/dist/factories/oht-3d.js +20 -20
  23. package/dist/factories/oht-3d.js.map +1 -1
  24. package/dist/factories/shuttle-3d.js +2 -5
  25. package/dist/factories/shuttle-3d.js.map +1 -1
  26. package/dist/features/conveyor-mixin.js.map +1 -1
  27. package/dist/features/mcs-status-mixin.js +22 -0
  28. package/dist/features/mcs-status-mixin.js.map +1 -1
  29. package/dist/features/mcs-zone-mixin.js.map +1 -1
  30. package/dist/features/parent-object-mixin.js.map +1 -1
  31. package/dist/floating-container.js +5 -0
  32. package/dist/floating-container.js.map +1 -1
  33. package/dist/index.js +50 -34
  34. package/dist/index.js.map +1 -1
  35. package/dist/mcs-carrier-holder.js +39 -22
  36. package/dist/mcs-carrier-holder.js.map +1 -1
  37. package/dist/mcs-machine.js +28 -0
  38. package/dist/mcs-machine.js.map +1 -1
  39. package/dist/mcs-unit.js +10 -0
  40. package/dist/mcs-unit.js.map +1 -1
  41. package/dist/mcs-vehicle.js +8 -3
  42. package/dist/mcs-vehicle.js.map +1 -1
  43. package/dist/node.js +1 -1
  44. package/dist/node.js.map +1 -1
  45. package/dist/oht.js.map +1 -1
  46. package/dist/scanner.js +30 -0
  47. package/dist/scanner.js.map +1 -0
  48. package/dist/scene/root-container-override.js +9 -0
  49. package/dist/scene/root-container-override.js.map +1 -1
  50. package/dist/static-container.js +5 -0
  51. package/dist/static-container.js.map +1 -1
  52. package/dist/stocker-abnormal-bar.js +1 -1
  53. package/dist/stocker-abnormal-bar.js.map +1 -1
  54. package/dist/stocker-capacity-bar.js +3 -3
  55. package/dist/stocker-capacity-bar.js.map +1 -1
  56. package/dist/stocker-carrier-bar.js +1 -1
  57. package/dist/stocker-carrier-bar.js.map +1 -1
  58. package/dist/stocker.js +6 -0
  59. package/dist/stocker.js.map +1 -1
  60. package/dist/templates/backdrop.js +30 -0
  61. package/dist/templates/backdrop.js.map +1 -0
  62. package/dist/templates/decal.js +21 -0
  63. package/dist/templates/decal.js.map +1 -0
  64. package/dist/templates/index.js +7 -1
  65. package/dist/templates/index.js.map +1 -1
  66. package/dist/templates/scanner.js +20 -0
  67. package/dist/templates/scanner.js.map +1 -0
  68. package/dist/tsconfig.tsbuildinfo +1 -1
  69. package/dist/utils/get-value-on-ranges.js +2 -4
  70. package/dist/utils/get-value-on-ranges.js.map +1 -1
  71. package/dist/zone-capacity-bar.js +3 -3
  72. package/dist/zone-capacity-bar.js.map +1 -1
  73. package/icons/backdrop.png +0 -0
  74. package/icons/decal.png +0 -0
  75. package/jest.config.js +10 -0
  76. package/package.json +4 -3
  77. package/src/agv.ts +2 -2
  78. package/src/carrier-manager.ts +117 -0
  79. package/src/carrier.ts +80 -3
  80. package/src/conveyor-join.ts +5 -2
  81. package/src/conveyor.ts +8 -0
  82. package/src/crane.ts +1 -1
  83. package/src/factories/agv-3d.ts +9 -10
  84. package/src/factories/conveyor-3d.ts +168 -84
  85. package/src/factories/crane-3d.ts +6 -8
  86. package/src/factories/crane-rail-3d.ts +5 -7
  87. package/src/factories/machine-3d.ts +452 -145
  88. package/src/factories/oht-3d.ts +20 -20
  89. package/src/factories/shuttle-3d.ts +2 -6
  90. package/src/features/conveyor-mixin.ts +1 -1
  91. package/src/features/mcs-status-mixin.ts +26 -4
  92. package/src/features/mcs-zone-mixin.ts +1 -1
  93. package/src/features/parent-object-mixin.ts +1 -1
  94. package/src/floating-container.ts +5 -0
  95. package/src/index.ts +56 -34
  96. package/src/mcs-carrier-holder.ts +38 -34
  97. package/src/mcs-machine.ts +29 -0
  98. package/src/mcs-unit.ts +12 -1
  99. package/src/mcs-vehicle.ts +9 -6
  100. package/src/node.ts +1 -1
  101. package/src/oht.ts +1 -1
  102. package/src/scanner.ts +29 -0
  103. package/src/scene/root-container-override.ts +12 -0
  104. package/src/static-container.ts +5 -0
  105. package/src/stocker-abnormal-bar.ts +1 -1
  106. package/src/stocker-capacity-bar.ts +3 -3
  107. package/src/stocker-carrier-bar.ts +1 -1
  108. package/src/stocker.ts +7 -0
  109. package/src/templates/backdrop.ts +30 -0
  110. package/src/templates/decal.ts +21 -0
  111. package/src/templates/index.ts +7 -1
  112. package/src/templates/scanner.ts +20 -0
  113. package/src/utils/get-value-on-ranges.ts +2 -4
  114. package/src/zone-capacity-bar.ts +3 -3
  115. package/translations/en.json +16 -1
  116. package/translations/ja.json +16 -1
  117. package/translations/ko.json +16 -1
  118. package/translations/ms.json +16 -1
  119. package/translations/zh.json +16 -1
@@ -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 {
@@ -83,7 +83,7 @@ export class OHT3D extends RealObjectGroup {
83
83
  metalness: 0.4,
84
84
  })
85
85
 
86
- // ── 1. 하단 그리퍼 바 (캐리어를 집는 가로 바) ──
86
+ // ── 1. 하단 그리퍼 바 (캐리어를 집는 가로 바 — 이동 방향과 직교) ──
87
87
  const gripperBarW = w * 0.7
88
88
  const gripperBarD = h * 0.15
89
89
  const gripperGeo = new THREE.BoxGeometry(gripperBarW, gripperBarH, gripperBarD)
@@ -91,21 +91,21 @@ export class OHT3D extends RealObjectGroup {
91
91
  gripperMesh.position.y = gripperBarH / 2
92
92
  gripperMesh.castShadow = true
93
93
 
94
- // ── 2. 호이스트 암 (좌우 수직 기둥 + 하단 가로연결) ──
94
+ // ── 2. 호이스트 암 (전후 수직 기둥 + 하단 연결 바) ──
95
95
  const armBaseY = gripperBarH
96
96
  const armGeometries: THREE.BufferGeometry[] = []
97
97
 
98
- // 좌우 수직 기둥
99
- for (const xSign of [-1, 1]) {
98
+ // 전후 수직 기둥 (레일 방향 = Z축)
99
+ for (const zSign of [-1, 1]) {
100
100
  const pillar = new THREE.BoxGeometry(armThickness, armH, armThickness)
101
- pillar.translate(xSign * (w * 0.3), armBaseY + armH / 2, 0)
101
+ pillar.translate(0, armBaseY + armH / 2, zSign * (h * 0.3))
102
102
  armGeometries.push(pillar)
103
103
  }
104
104
 
105
- // 하단 가로 연결 바 (그리퍼와 암을 잇는 수평 바)
106
- const crossBarW = w * 0.6 + armThickness
105
+ // 하단 연결 바 (레일 방향으로 연결)
106
+ const crossBarD = h * 0.6 + armThickness
107
107
  const crossBarH = armThickness * 0.6
108
- const crossBar = new THREE.BoxGeometry(crossBarW, crossBarH, armThickness)
108
+ const crossBar = new THREE.BoxGeometry(armThickness, crossBarH, crossBarD)
109
109
  crossBar.translate(0, armBaseY + crossBarH / 2, 0)
110
110
  armGeometries.push(crossBar)
111
111
 
@@ -126,10 +126,10 @@ export class OHT3D extends RealObjectGroup {
126
126
  bodyMesh.castShadow = true
127
127
  bodyMesh.receiveShadow = true
128
128
 
129
- // ── 4. 상단 트롤리 플레이트 (납작하고 넓은 레일 클램프) ──
129
+ // ── 4. 상단 트롤리 플레이트 (레일 방향으로 길게 — Z축) ──
130
130
  const trolleyBaseY = bodyBaseY + bodyH + gap
131
- const trolleyW = w * 1.15
132
- const trolleyD = h * 0.6
131
+ const trolleyW = w * 0.6
132
+ const trolleyD = h * 1.15
133
133
  const trolleyGeo = new THREE.BoxGeometry(trolleyW, trolleyH, trolleyD)
134
134
  const trolleyMat = new THREE.MeshStandardMaterial({
135
135
  color: TROLLEY_COLOR,
@@ -140,29 +140,29 @@ export class OHT3D extends RealObjectGroup {
140
140
  trolleyMesh.position.y = trolleyBaseY + trolleyH / 2
141
141
  trolleyMesh.castShadow = true
142
142
 
143
- // ── 5. 좌우 바퀴 (트롤리 위, 레일을 타는 원통형 바퀴) ──
143
+ // ── 5. 전후 바퀴 (트롤리 위, 레일 방향 = Z축) ──
144
144
  const wheelBaseY = trolleyBaseY + trolleyH
145
145
  const wheelRadius = wheelH / 2
146
- const wheelDepth = h * 0.2
146
+ const wheelDepth = w * 0.2
147
147
  const wheelMeshes: THREE.Mesh[] = []
148
- for (const xSign of [-1, 1]) {
148
+ for (const zSign of [-1, 1]) {
149
149
  const wheelGeo = new THREE.CylinderGeometry(wheelRadius, wheelRadius, wheelDepth, 12)
150
- wheelGeo.rotateX(Math.PI / 2)
150
+ wheelGeo.rotateZ(Math.PI / 2)
151
151
  const wheelMesh = new THREE.Mesh(wheelGeo, trolleyMat)
152
- wheelMesh.position.set(xSign * (trolleyW * 0.35), wheelBaseY + wheelRadius, 0)
152
+ wheelMesh.position.set(0, wheelBaseY + wheelRadius, zSign * (trolleyD * 0.35))
153
153
  wheelMesh.castShadow = true
154
154
  wheelMeshes.push(wheelMesh)
155
155
  }
156
156
 
157
157
  this._ownMeshes = [gripperMesh, armMesh, bodyMesh, trolleyMesh, ...wheelMeshes]
158
- for (const m of this._ownMeshes) this.object3d.add(m)
158
+ for (const m of this._ownMeshes) this.components3D.add(m)
159
159
  }
160
160
 
161
161
  updateDimension() {}
162
162
 
163
163
  update() {
164
164
  for (const m of this._ownMeshes) {
165
- this.object3d.remove(m)
165
+ this.components3D.remove(m)
166
166
  disposeObject3D(m)
167
167
  }
168
168
  this._ownMeshes = []
@@ -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
 
@@ -142,14 +138,14 @@ export class Shuttle3D extends RealObjectGroup {
142
138
  forkMesh.castShadow = true
143
139
 
144
140
  this._ownMeshes = [baseMesh, mastMesh, forkMesh]
145
- for (const m of this._ownMeshes) this.object3d.add(m)
141
+ for (const m of this._ownMeshes) this.components3D.add(m)
146
142
  }
147
143
 
148
144
  updateDimension() {}
149
145
 
150
146
  update() {
151
147
  for (const m of this._ownMeshes) {
152
- this.object3d.remove(m)
148
+ this.components3D.remove(m)
153
149
  disposeObject3D(m)
154
150
  }
155
151
  this._ownMeshes = []
@@ -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
 
@@ -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
@@ -12,7 +12,7 @@ export const ParentObjectMixinProperties = [
12
12
  }
13
13
  ]
14
14
 
15
- export function ParentObjectMixin<TBase extends Constructor<Component>>(Base: TBase) {
15
+ export function ParentObjectMixin<TBase extends Constructor<Component>>(Base: TBase): any {
16
16
  return class extends Base {
17
17
  get parentObject(): MCSMachine | MCSUnit | undefined {
18
18
  const { id, parentObjectId } = this.state
@@ -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,72 @@
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
12
 
13
13
  // ── 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'
14
+ // bars & overlays
15
+ import './zone-capacity-bar'
16
+ import './stocker-capacity-bar'
17
+ import './stocker-carrier-bar'
18
+ import './stocker-abnormal-bar'
19
+ import './port-flow'
39
20
 
21
+ // facilities
22
+ import './agv-line'
23
+ import './buffer'
24
+ import './conveyor'
25
+ import './conveyor-join'
26
+ import './equipment'
27
+ import './oht-line'
28
+ import './stocker'
29
+ import './crane-rail'
30
+ import './scanner'
31
+
32
+ // vehicles
33
+ import './agv'
34
+ import './oht'
35
+ import './shuttle'
36
+
37
+ // units
38
+ import './port'
39
+ import './crane'
40
+ import './shelf'
41
+ import './carrier'
42
+
43
+ // topology
44
+ import './node'
45
+ import './node-path'
46
+
47
+ // containers
48
+ import './floating-container'
49
+ import './static-container'
50
+ import './clickable-popup'
51
+
52
+ // ── groups ──
40
53
  export { default as MachineGroups } from './groups'
41
54
 
55
+ // ── base classes ──
42
56
  export { default as MCSMachine } from './mcs-machine'
43
57
  export { default as MCSUnit } from './mcs-unit'
44
58
  export { default as MCSCarrierHolder } from './mcs-carrier-holder'
45
59
  export { default as MCSVehicle } from './mcs-vehicle'
46
60
  export { default as MCSTransport } from './mcs-transport'
61
+
62
+ // ── bars & overlays ──
47
63
  export { default as ZoneCapacityBar } from './zone-capacity-bar'
48
64
  export { default as StockerCapacityBar } from './stocker-capacity-bar'
49
65
  export { default as StockerCarrierBar } from './stocker-carrier-bar'
50
66
  export { default as StockerAbnormalBar } from './stocker-abnormal-bar'
51
67
  export { default as PortFlow } from './port-flow'
52
68
 
69
+ // ── facilities ──
53
70
  export { default as AGVLine } from './agv-line'
54
71
  export { default as Buffer } from './buffer'
55
72
  export { default as Conveyor } from './conveyor'
@@ -58,19 +75,24 @@ export { default as Equipment } from './equipment'
58
75
  export { default as OHTLine } from './oht-line'
59
76
  export { default as Stocker } from './stocker'
60
77
  export { default as CraneRail } from './crane-rail'
78
+ export { default as Scanner } from './scanner'
61
79
 
80
+ // ── vehicles ──
62
81
  export { default as AGV } from './agv'
63
82
  export { default as OHT } from './oht'
64
83
  export { default as Shuttle } from './shuttle'
65
84
 
85
+ // ── units ──
66
86
  export { default as Port } from './port'
67
87
  export { default as Crane } from './crane'
68
88
  export { default as Shelf } from './shelf'
69
89
  export { default as Carrier } from './carrier'
70
90
 
91
+ // ── topology ──
71
92
  export { default as Node } from './node'
72
93
  export { default as NodePath } from './node-path'
73
94
 
95
+ // ── containers ──
74
96
  export { default as FloatingContainer } from './floating-container'
75
- export { default as StaticContainer } from './static-container.js'
97
+ export { default as StaticContainer } from './static-container'
76
98
  export { default as ClickablePopup } from './clickable-popup'
@@ -1,7 +1,5 @@
1
- import { Model, Properties } from '@hatiolab/things-scene'
2
1
  import { themesColorMap, themesAnimationMap } from '@fmsim/api'
3
2
  import MCSUnit from './mcs-unit.js'
4
- import Carrier from './carrier.js'
5
3
 
6
4
  export default class MCSCarrierHolder extends MCSUnit {
7
5
  static get properties(): any {
@@ -31,50 +29,56 @@ export default class MCSCarrierHolder extends MCSUnit {
31
29
  ]
32
30
  }
33
31
 
34
- carrier?: Carrier | null
35
-
36
- async ready() {
37
- super.ready()
32
+ get showOverflow() {
33
+ return true
34
+ }
38
35
 
39
- for (let component of this.components) {
40
- this.removeComponent(component)
36
+ get hierarchy() {
37
+ return {
38
+ ...super.hierarchy,
39
+ components: []
41
40
  }
42
-
43
- const { width, height } = this.state
44
-
45
- this.carrier = Model.compile(
46
- {
47
- type: 'Carrier',
48
- left: 0,
49
- top: 0,
50
- width,
51
- height,
52
- showText: this.getState('showCarrierText') || false
53
- },
54
- this.root.app
55
- ) as any
56
-
57
- this.addComponent(this.carrier!)
58
-
59
- this.carrier!.data = this.data
60
41
  }
61
42
 
62
43
  dispose(): void {
63
- this.carrier = null
64
-
44
+ ;(this.root as any)?.carrierManager?.update(this, {}, this.data)
65
45
  super.dispose()
66
46
  }
67
47
 
68
- get hierarchy() {
69
- return {
70
- ...super.hierarchy,
71
- components: []
48
+ async ready() {
49
+ super.ready()
50
+
51
+ const { CARRIERNAME, CARRIERTYPE = '', EMPTYTYPE, CARRIERSTATUS } = this.data || {}
52
+
53
+ if(CARRIERNAME) {
54
+ ;(this.root as any).carrierManager.update(this, {
55
+ CARRIERNAME,
56
+ CARRIERTYPE,
57
+ EMPTYTYPE,
58
+ CARRIERSTATUS
59
+ }, undefined)
72
60
  }
73
61
  }
74
62
 
75
63
  onchangeData(after: Record<string, any>, before: Record<string, any>): void {
76
- if (this.carrier) {
77
- this.carrier.data = this.data
64
+ // CARRIERNAME, CARRIERTYPE = '', EMPTYTYPE, CARRIERSTATUS 이 변경되었을 때만 캐리어 관리자에게 알린다.
65
+ const { CARRIERNAME, CARRIERTYPE = '', EMPTYTYPE, CARRIERSTATUS } = after.data || {}
66
+ const { CARRIERNAME: beforeCARRIERNAME, CARRIERTYPE: beforeCARRIERTYPE = '', EMPTYTYPE: beforeEMPTYTYPE, CARRIERSTATUS: beforeCARRIERSTATUS } = before.data || {}
67
+ if(CARRIERNAME !== beforeCARRIERNAME ||
68
+ CARRIERTYPE !== beforeCARRIERTYPE ||
69
+ EMPTYTYPE !== beforeEMPTYTYPE ||
70
+ CARRIERSTATUS !== beforeCARRIERSTATUS) {
71
+ ;(this.root as any).carrierManager.update(this, {
72
+ CARRIERNAME,
73
+ CARRIERTYPE,
74
+ EMPTYTYPE,
75
+ CARRIERSTATUS
76
+ }, {
77
+ CARRIERNAME: beforeCARRIERNAME,
78
+ CARRIERTYPE: beforeCARRIERTYPE,
79
+ EMPTYTYPE: beforeEMPTYTYPE,
80
+ CARRIERSTATUS: beforeCARRIERSTATUS
81
+ })
78
82
  }
79
83
 
80
84
  super.onchangeData(after, before)
@@ -70,6 +70,35 @@ export default class MCSMachine extends MCSStatusMixin(ContainerAbstract) {
70
70
  return LEGEND_MACHINE
71
71
  }
72
72
 
73
+ /**
74
+ * In 2D, ignore `state.alpha`; preserve everything else.
75
+ *
76
+ * things-scene's base prerender (component-drawing.ts:31, 44) does:
77
+ * const fade = (alpha || 1) - this._delta.fade
78
+ * if (fade) context.globalAlpha = fade
79
+ *
80
+ * It *overwrites* `globalAlpha` (not multiplies), so the inherited
81
+ * parent alpha is also lost — that's a base-layer quirk we match the
82
+ * recovery for. Then at line 48 it applies editMode+hidden dimming
83
+ * with a *= 0.5.
84
+ *
85
+ * Our recovery:
86
+ * 1. Capture the inherited `globalAlpha` *before* super runs.
87
+ * 2. Let super do its work (transforms / shadow / dim flags).
88
+ * 3. Restore globalAlpha to inherited × editMode-hidden dim factor —
89
+ * i.e., what super would have produced if our state.alpha were 1.
90
+ *
91
+ * 3D path is unaffected: 3D factories read `state.alpha` directly via
92
+ * their `updateAlpha()` implementations and continue to honor it (with
93
+ * per-config opacity fallback).
94
+ */
95
+ prerender(ctx: any) {
96
+ const inherited = ctx.globalAlpha
97
+ super.prerender(ctx)
98
+ const dim = this.app.isEditMode && this.hidden ? 0.5 : 1
99
+ ctx.globalAlpha = inherited * dim
100
+ }
101
+
73
102
  render(ctx) {
74
103
  var { round = 0, lineWidth } = this.state
75
104
  var { left, top, width, height } = this.bounds
package/src/mcs-unit.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component, ContainerAbstract } from '@hatiolab/things-scene'
1
+ import { ContainerAbstract } from '@hatiolab/things-scene'
2
2
  import { getPopupData } from '@fmsim/api'
3
3
 
4
4
  import { MCSStatusMixin, MCSStatusMixinProperties } from './features/mcs-status-mixin'
@@ -49,6 +49,17 @@ export default class MCSUnit extends MCSStatusMixin(ParentObjectMixin(ContainerA
49
49
  return LEGEND_UNIT
50
50
  }
51
51
 
52
+ /**
53
+ * In 2D, ignore `state.alpha`; preserve inherited alpha + editMode-hidden dim.
54
+ * See MCSMachine.prerender for the full rationale.
55
+ */
56
+ prerender(ctx: any) {
57
+ const inherited = ctx.globalAlpha
58
+ super.prerender(ctx)
59
+ const dim = this.app.isEditMode && this.hidden ? 0.5 : 1
60
+ ctx.globalAlpha = inherited * dim
61
+ }
62
+
52
63
  contains(x, y) {
53
64
  var { left, top, width, height, lineWidth = 0 } = this.state
54
65
  var extend = lineWidth / 2
@@ -1,4 +1,3 @@
1
- import { Properties } from '@hatiolab/things-scene'
2
1
  import { LEGEND_VEHICLE, Legend } from './features/mcs-status-default'
3
2
  import MCSCarrierHolder from './mcs-carrier-holder'
4
3
  import Node from './node'
@@ -124,22 +123,26 @@ export default class MCSVehicle extends MCSCarrierHolder {
124
123
 
125
124
  if ((this.root as any).vehicleAnimation) {
126
125
  this.trigger('waypoint', {
127
- from: beforeNode,
126
+ from: beforeNode || afterNode,
128
127
  to: afterNode,
129
128
  duration: 5000
130
129
  })
131
- } else {
132
- const fromCenter = beforeNode!.center
130
+ } else if (beforeNode) {
131
+ const fromCenter = beforeNode.center
133
132
  const toCenter = afterNode.center
134
133
 
135
- const { x: startX, y: startY } = beforeNode!.transcoordS2T(fromCenter.x, fromCenter.y)
134
+ const { x: startX, y: startY } = beforeNode.transcoordS2T(fromCenter.x, fromCenter.y)
136
135
  const { x: endX, y: endY } = afterNode.transcoordS2T(toCenter.x, toCenter.y)
137
136
 
138
137
  const theta = Math.atan2(endY - startY, endX - startX) + Math.PI / 2
139
138
 
140
- // 위치 설정
141
139
  this.location = { x: endX, y: endY }
142
140
  this.setState('rotation', theta)
141
+ } else {
142
+ // beforeNode 없음: afterNode 위치로 즉시 이동
143
+ const toCenter = afterNode.center
144
+ const { x, y } = afterNode.transcoordS2T(toCenter.x, toCenter.y)
145
+ this.location = { x, y }
143
146
  }
144
147
  }
145
148
  }
package/src/node.ts CHANGED
@@ -28,7 +28,7 @@ export default class Node extends Shape {
28
28
  static RADIUS = 8
29
29
 
30
30
  is3dish() {
31
- return false
31
+ return true
32
32
  }
33
33
 
34
34
  isDescendible() {
package/src/oht.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component, ComponentNature, Properties, sceneComponent } from '@hatiolab/things-scene'
1
+ import { Component, ComponentNature, sceneComponent } from '@hatiolab/things-scene'
2
2
  import MCSVehicle from './mcs-vehicle'
3
3
 
4
4
  const NATURE: ComponentNature = {
package/src/scanner.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { Component, ComponentNature, Triangle, sceneComponent } from '@hatiolab/things-scene'
2
+ import { MCSStatusMixin } from './features/mcs-status-mixin'
3
+
4
+ const NATURE: ComponentNature = {
5
+ mutable: true,
6
+ resizable: false,
7
+ rotatable: true,
8
+ properties: [
9
+ {
10
+ type: 'number',
11
+ label: 'round',
12
+ name: 'round',
13
+ property: { min: 0, max: 100, step: 1 }
14
+ }
15
+ ]
16
+ }
17
+
18
+ @sceneComponent('Scanner')
19
+ export default class Scanner extends MCSStatusMixin(Triangle) {
20
+ static get nature() {
21
+ return NATURE
22
+ }
23
+
24
+ is3dish() {
25
+ return true
26
+ }
27
+ }
28
+
29
+ Component.memoize(Scanner.prototype, 'path', false)
@@ -1,6 +1,7 @@
1
1
  import { Component, RootContainer } from '@hatiolab/things-scene'
2
2
  import { themesColorMap, themesColorRange, themesAnimationMap } from '@fmsim/api'
3
3
  import { Legend } from '../features/mcs-status-default'
4
+ import CarrierManager from '../carrier-manager'
4
5
 
5
6
  // RootContainer 클래스 타입 확장
6
7
  declare module '@hatiolab/things-scene' {
@@ -26,6 +27,8 @@ declare module '@hatiolab/things-scene' {
26
27
  vehicleAnimation?: boolean
27
28
  // 캐시 관련 속성 추가
28
29
  _animationConfigCache?: Map<string, any>
30
+ _carrierManager?: CarrierManager
31
+ carrierManager: CarrierManager
29
32
  }
30
33
  }
31
34
 
@@ -326,3 +329,12 @@ Object.defineProperty(RootContainer.prototype, 'vehicleAnimation', {
326
329
  return !!vehicleAnimation
327
330
  }
328
331
  })
332
+
333
+ Object.defineProperty(RootContainer.prototype, 'carrierManager', {
334
+ get: function () {
335
+ if (!this._carrierManager) {
336
+ this._carrierManager = new CarrierManager(this)
337
+ }
338
+ return this._carrierManager
339
+ }
340
+ })
@@ -13,6 +13,11 @@ const NATURE = {
13
13
 
14
14
  @sceneComponent('container')
15
15
  export default class StaticContainer extends Container {
16
+ // things-scene 의 `declare const Container_base` 패턴이 base 인스턴스 타입의 accessor
17
+ // 정보를 object-type property 로 평탄화하여 TS2611 발생. operato-scene 은 position
18
+ // override 케이스가 없어 미발현, fmsim 만 해당. things-scene 측 mixin 타입 패턴이
19
+ // 개선되면 제거.
20
+ // @ts-expect-error TS2611
16
21
  get position() {
17
22
  return 'static'
18
23
  }
@@ -232,7 +232,7 @@ export default class StockerAbnormalBar extends ParentObjectMixin(RectPath(Shape
232
232
  const {
233
233
  CARRIER_NORMAL = 0,
234
234
  CARRIER_ABNORMAL = 0
235
- } = typeof this.data == 'object' ? this.data : {}
235
+ } = this.data && typeof this.data == 'object' ? this.data : {}
236
236
 
237
237
  this.setState({
238
238
  carrierNormal: Number(CARRIER_NORMAL) || 0,