@fmsim/machine 2.0.0-beta.19 → 2.0.0-beta.20

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.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fmsim/machine",
3
3
  "description": "Layout View를 구성하는 설비(machine)들과 유닛을 구현한 모듈입니다.",
4
4
  "author": "heartyoh",
5
- "version": "2.0.0-beta.19",
5
+ "version": "2.0.0-beta.20",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
8
8
  "things-scene": true,
@@ -55,5 +55,5 @@
55
55
  "prettier --write"
56
56
  ]
57
57
  },
58
- "gitHead": "29a0fc9444f6eec0961401d979fd21fdfd34e041"
58
+ "gitHead": "a1eba5205556e34ec21bbecbd7816fe0eaa85dce"
59
59
  }
@@ -59,19 +59,9 @@ export class AGV3D extends RealObjectGroup {
59
59
  return DEFAULT_BODY_COLOR
60
60
  }
61
61
 
62
- private _dataHandler?: () => void
63
-
64
62
  build() {
65
63
  super.build()
66
64
 
67
- // data 변경 감지 (배터리 잔량 업데이트)
68
- if (!this._dataHandler) {
69
- this._dataHandler = (_after: any, _before: any) => {
70
- if (_after.data !== undefined) this.updateBattery()
71
- }
72
- this.component.on('change', this._dataHandler)
73
- }
74
-
75
65
  const { width = 10, height = 10 } = this.component.state
76
66
  const w = Math.abs(width)
77
67
  const h = Math.abs(height)
@@ -128,127 +118,9 @@ export class AGV3D extends RealObjectGroup {
128
118
  plat.receiveShadow = true
129
119
 
130
120
  this._ownMeshes = [bumper, body, plat]
131
-
132
- // ── 배터리 실린더 (바디 뒷면, BATTERYRATE 데이터가 있을 때만) ──
133
- if (this.getBatteryRate() > 0) {
134
- const batteryMeshes = this.buildBattery(w, h, bumperH, bodyH)
135
- this._ownMeshes.push(...batteryMeshes)
136
- }
137
-
138
121
  for (const m of this._ownMeshes) this.object3d.add(m)
139
122
  }
140
123
 
141
- private _batteryFillMesh?: THREE.Mesh
142
- private _batteryLen = 0
143
- private _batteryY = 0
144
- private _batteryZ = 0
145
-
146
- private buildBattery(agvW: number, agvH: number, bodyBottomY: number, bodyH: number): THREE.Mesh[] {
147
- const radius = Math.min(agvW, agvH) * 0.15
148
- this._batteryLen = agvW * 0.7
149
- this._batteryY = bodyBottomY + bodyH * 0.5
150
- this._batteryZ = -agvH / 2 - radius * 1.5
151
-
152
- const rate = this.getBatteryRate()
153
- const batteryColor = this.getBatteryColor(rate)
154
- const innerRadius = radius * 0.85
155
- const capWidth = radius * 0.3
156
- const meshes: THREE.Mesh[] = []
157
-
158
- // 투명 외장 (유리 쉘, 양단 막힘)
159
- const shellGeo = new THREE.CylinderGeometry(radius, radius, this._batteryLen, 20)
160
- shellGeo.rotateZ(Math.PI / 2)
161
- const shellMat = new THREE.MeshStandardMaterial({
162
- color: 0xffffff,
163
- transparent: true,
164
- opacity: 0.25,
165
- roughness: 0.1,
166
- metalness: 0.1,
167
- side: THREE.DoubleSide,
168
- depthWrite: false,
169
- })
170
- const shell = new THREE.Mesh(shellGeo, shellMat)
171
- shell.position.set(0, this._batteryY, this._batteryZ)
172
- meshes.push(shell)
173
-
174
- // 좌측 캡 (금속)
175
- const capGeo = new THREE.CylinderGeometry(radius * 0.6, radius, capWidth, 20)
176
- capGeo.rotateZ(Math.PI / 2)
177
- const capMat = new THREE.MeshStandardMaterial({
178
- color: batteryColor, roughness: 0.3, metalness: 0.7,
179
- emissive: batteryColor, emissiveIntensity: 0.2,
180
- })
181
- const leftCap = new THREE.Mesh(capGeo, capMat)
182
- leftCap.position.set(-this._batteryLen / 2 - capWidth / 2, this._batteryY, this._batteryZ)
183
- meshes.push(leftCap)
184
-
185
- // 우측 캡 (금속)
186
- const rightCapGeo = capGeo.clone()
187
- const rightCap = new THREE.Mesh(rightCapGeo, capMat)
188
- rightCap.position.set(this._batteryLen / 2 + capWidth / 2, this._batteryY, this._batteryZ)
189
- rightCap.rotation.z = Math.PI
190
- meshes.push(rightCap)
191
-
192
- // 내부 잔량/빈 부분
193
- const fillLen = Math.max(this._batteryLen * rate / 100, 0.1)
194
- const emptyLen = Math.max(this._batteryLen - fillLen, 0.1)
195
-
196
- // 빈 부분 (짙은 회색, 불투명, 양단 닫힘)
197
- const emptyGeo = new THREE.CylinderGeometry(innerRadius, innerRadius, emptyLen, 16)
198
- emptyGeo.rotateZ(Math.PI / 2)
199
- const emptyMat = new THREE.MeshStandardMaterial({
200
- color: 0x333333,
201
- roughness: 0.6,
202
- metalness: 0.2,
203
- side: THREE.DoubleSide,
204
- })
205
- const emptyMesh = new THREE.Mesh(emptyGeo, emptyMat)
206
- emptyMesh.position.set(
207
- (this._batteryLen - emptyLen) / 2,
208
- this._batteryY, this._batteryZ
209
- )
210
- meshes.push(emptyMesh)
211
-
212
- // 잔량 채움 (상태 컬러)
213
- const fillGeo = new THREE.CylinderGeometry(innerRadius * 0.98, innerRadius * 0.98, fillLen, 16)
214
- fillGeo.rotateZ(Math.PI / 2)
215
- const fillMat = new THREE.MeshStandardMaterial({
216
- color: batteryColor,
217
- roughness: 0.3,
218
- metalness: 0.1,
219
- emissive: batteryColor,
220
- emissiveIntensity: 0.4,
221
- side: THREE.DoubleSide,
222
- })
223
- this._batteryFillMesh = new THREE.Mesh(fillGeo, fillMat)
224
- this._batteryFillMesh.position.set(
225
- -(this._batteryLen - fillLen) / 2,
226
- this._batteryY, this._batteryZ
227
- )
228
- meshes.push(this._batteryFillMesh)
229
-
230
- return meshes
231
- }
232
-
233
- private getBatteryRate(): number {
234
- const data = (this.component as any).data
235
- return typeof data?.BATTERYRATE === 'number' ? data.BATTERYRATE : 0
236
- }
237
-
238
- private getBatteryColor(rate: number): number {
239
- try {
240
- const comp = this.component as any
241
- if (comp.getBatteryColor) {
242
- const color = comp.getBatteryColor(rate)
243
- if (color) return new THREE.Color(color).getHex()
244
- }
245
- } catch { /* fallback */ }
246
- // 기본: 녹색 > 노랑 > 빨강
247
- if (rate > 50) return 0x4caf50
248
- if (rate > 20) return 0xffc107
249
- return 0xf44336
250
- }
251
-
252
124
  updateDimension() {}
253
125
 
254
126
  update() {
@@ -286,11 +158,6 @@ export class AGV3D extends RealObjectGroup {
286
158
 
287
159
  super.onchange(after, before)
288
160
  }
289
-
290
- private updateBattery() {
291
- // 전체 rebuild로 정확한 geometry 생성
292
- this.update()
293
- }
294
161
  }
295
162
 
296
163
  registerRealObjectFactory('AGV', (component: Component) => new AGV3D(component))
@@ -637,7 +637,7 @@ const PORT_CONFIG: MCS3DConfig = {
637
637
  ...DEFAULTS,
638
638
  depthRatio: 0.01,
639
639
  defaultZPosFromParent: true,
640
- opacity: 1,
640
+ opacity: 0.1,
641
641
  metalness: 0.3,
642
642
  roughness: 0.8,
643
643
  defaultColor: 0xb0a090,
@@ -656,13 +656,12 @@ register('Shelf', {
656
656
  const CARRIER_CONFIG: MCS3DConfig = {
657
657
  ...DEFAULTS,
658
658
  depthRatio: 0.5,
659
- metalness: 0.2,
660
- roughness: 0.8,
659
+ metalness: 0,
660
+ roughness: 1,
661
661
  defaultColor: 0x66bb66,
662
662
  isVisible: (c: Component) => !!(c.state as any).id,
663
663
  sizeRatio: 0.8,
664
664
  texturedTop: true,
665
- emissiveIntensity: 0.4,
666
665
  }
667
666
 
668
667
  class CarrierRealObject3D extends MCSRealObject3D {