@fmsim/machine 2.0.0-beta.2 → 2.0.0-beta.21

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.
@@ -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 } from '@hatiolab/things-scene'
15
+ import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } 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
 
@@ -21,6 +21,7 @@ const FORK_COLOR = 0x777777
21
21
  const DEFAULT_BODY_COLOR = 0x6688cc
22
22
 
23
23
  export class Shuttle3D extends RealObjectGroup {
24
+ private _ownMeshes: THREE.Mesh[] = []
24
25
  get effectiveDepth(): number {
25
26
  const { depth } = this.component.state
26
27
  return depth || TRANSPORT_SURFACE_HEIGHT
@@ -80,7 +81,6 @@ export class Shuttle3D extends RealObjectGroup {
80
81
  baseMesh.position.y = baseH / 2
81
82
  baseMesh.castShadow = true
82
83
  baseMesh.receiveShadow = true
83
- this.object3d.add(baseMesh)
84
84
 
85
85
  // ── 2. 좌우 마스트 기둥 (statusColor 적용) ──
86
86
  const mastBaseY = baseH
@@ -109,7 +109,6 @@ export class Shuttle3D extends RealObjectGroup {
109
109
 
110
110
  const mastMesh = new THREE.Mesh(BufferGeometryUtils.mergeGeometries(mastGeometries), mastMat)
111
111
  mastMesh.castShadow = true
112
- this.object3d.add(mastMesh)
113
112
 
114
113
  // ── 3. 상단 포크 (2개의 평행 암 + 백 플레이트) ──
115
114
  const forkBaseY = mastBaseY + mastH
@@ -141,14 +140,39 @@ export class Shuttle3D extends RealObjectGroup {
141
140
 
142
141
  const forkMesh = new THREE.Mesh(BufferGeometryUtils.mergeGeometries(forkGeometries), forkMat)
143
142
  forkMesh.castShadow = true
144
- this.object3d.add(forkMesh)
143
+
144
+ this._ownMeshes = [baseMesh, mastMesh, forkMesh]
145
+ for (const m of this._ownMeshes) this.object3d.add(m)
145
146
  }
146
147
 
147
148
  updateDimension() {}
148
- updateAlpha() {}
149
+
150
+ update() {
151
+ for (const m of this._ownMeshes) {
152
+ this.object3d.remove(m)
153
+ disposeObject3D(m)
154
+ }
155
+ this._ownMeshes = []
156
+ this.build()
157
+ this.updateTransform()
158
+ this.updateAlpha()
159
+ this.updateHidden()
160
+ }
161
+
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
+ }
149
172
 
150
173
  onchange(after: Record<string, unknown>, before: Record<string, unknown>) {
151
- if ('width' in after || 'height' in after || 'depth' in after || 'fillStyle' in after || 'strokeStyle' in after) {
174
+ if ('width' in after || 'height' in after || 'depth' in after ||
175
+ 'fillStyle' in after || 'strokeStyle' in after || 'id' in after) {
152
176
  this.update()
153
177
  return
154
178
  }
package/src/index.ts CHANGED
@@ -1,55 +1,71 @@
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
+
31
+ // vehicles
32
+ import './agv'
33
+ import './oht'
34
+ import './shuttle'
35
+
36
+ // units
37
+ import './port'
38
+ import './crane'
39
+ import './shelf'
40
+ import './carrier'
41
+
42
+ // topology
43
+ import './node'
44
+ import './node-path'
45
+
46
+ // containers
47
+ import './floating-container'
48
+ import './static-container'
49
+ import './clickable-popup'
50
+
51
+ // ── groups ──
40
52
  export { default as MachineGroups } from './groups'
41
53
 
54
+ // ── base classes ──
42
55
  export { default as MCSMachine } from './mcs-machine'
43
56
  export { default as MCSUnit } from './mcs-unit'
44
57
  export { default as MCSCarrierHolder } from './mcs-carrier-holder'
45
58
  export { default as MCSVehicle } from './mcs-vehicle'
46
59
  export { default as MCSTransport } from './mcs-transport'
60
+
61
+ // ── bars & overlays ──
47
62
  export { default as ZoneCapacityBar } from './zone-capacity-bar'
48
63
  export { default as StockerCapacityBar } from './stocker-capacity-bar'
49
64
  export { default as StockerCarrierBar } from './stocker-carrier-bar'
50
65
  export { default as StockerAbnormalBar } from './stocker-abnormal-bar'
51
66
  export { default as PortFlow } from './port-flow'
52
67
 
68
+ // ── facilities ──
53
69
  export { default as AGVLine } from './agv-line'
54
70
  export { default as Buffer } from './buffer'
55
71
  export { default as Conveyor } from './conveyor'
@@ -59,18 +75,22 @@ export { default as OHTLine } from './oht-line'
59
75
  export { default as Stocker } from './stocker'
60
76
  export { default as CraneRail } from './crane-rail'
61
77
 
78
+ // ── vehicles ──
62
79
  export { default as AGV } from './agv'
63
80
  export { default as OHT } from './oht'
64
81
  export { default as Shuttle } from './shuttle'
65
82
 
83
+ // ── units ──
66
84
  export { default as Port } from './port'
67
85
  export { default as Crane } from './crane'
68
86
  export { default as Shelf } from './shelf'
69
87
  export { default as Carrier } from './carrier'
70
88
 
89
+ // ── topology ──
71
90
  export { default as Node } from './node'
72
91
  export { default as NodePath } from './node-path'
73
92
 
93
+ // ── containers ──
74
94
  export { default as FloatingContainer } from './floating-container'
75
- export { default as StaticContainer } from './static-container.js'
95
+ export { default as StaticContainer } from './static-container'
76
96
  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)
@@ -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
+ })