@fmsim/machine 2.0.0-beta.5 → 2.0.0-beta.52
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/dist/agv.js +2 -2
- package/dist/agv.js.map +1 -1
- package/dist/carrier-manager.js +93 -0
- package/dist/carrier-manager.js.map +1 -0
- package/dist/carrier.js +51 -6
- package/dist/carrier.js.map +1 -1
- package/dist/conveyor-join.js +8 -2
- package/dist/conveyor-join.js.map +1 -1
- package/dist/conveyor.js +8 -0
- package/dist/conveyor.js.map +1 -1
- package/dist/crane.js.map +1 -1
- package/dist/factories/agv-3d.js +36 -8
- package/dist/factories/agv-3d.js.map +1 -1
- package/dist/factories/conveyor-3d.js +159 -69
- package/dist/factories/conveyor-3d.js.map +1 -1
- package/dist/factories/machine-3d.js +449 -62
- package/dist/factories/machine-3d.js.map +1 -1
- package/dist/factories/oht-3d.js +50 -24
- package/dist/factories/oht-3d.js.map +1 -1
- package/dist/factories/shuttle-3d.js +32 -6
- package/dist/factories/shuttle-3d.js.map +1 -1
- package/dist/index.js +50 -34
- package/dist/index.js.map +1 -1
- package/dist/mcs-carrier-holder.js +39 -22
- package/dist/mcs-carrier-holder.js.map +1 -1
- package/dist/mcs-vehicle.js +8 -3
- package/dist/mcs-vehicle.js.map +1 -1
- package/dist/node.js +1 -1
- package/dist/node.js.map +1 -1
- package/dist/oht.js.map +1 -1
- package/dist/scanner.js +30 -0
- package/dist/scanner.js.map +1 -0
- package/dist/scene/root-container-override.js +9 -0
- package/dist/scene/root-container-override.js.map +1 -1
- package/dist/stocker-capacity-bar.js +2 -2
- package/dist/stocker-capacity-bar.js.map +1 -1
- package/dist/templates/index.js +2 -0
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/scanner.js +20 -0
- package/dist/templates/scanner.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/get-value-on-ranges.js +2 -4
- package/dist/utils/get-value-on-ranges.js.map +1 -1
- package/dist/zone-capacity-bar.js +2 -2
- package/dist/zone-capacity-bar.js.map +1 -1
- package/jest.config.js +10 -0
- package/package.json +4 -3
- package/src/agv.ts +2 -2
- package/src/carrier-manager.ts +117 -0
- package/src/carrier.ts +50 -4
- package/src/conveyor-join.ts +5 -2
- package/src/conveyor.ts +8 -0
- package/src/crane.ts +1 -1
- package/src/factories/agv-3d.ts +36 -8
- package/src/factories/conveyor-3d.ts +161 -71
- package/src/factories/machine-3d.ts +535 -56
- package/src/factories/oht-3d.ts +48 -24
- package/src/factories/shuttle-3d.ts +30 -6
- package/src/index.ts +56 -34
- package/src/mcs-carrier-holder.ts +38 -34
- package/src/mcs-vehicle.ts +9 -6
- package/src/node.ts +1 -1
- package/src/oht.ts +1 -1
- package/src/scanner.ts +29 -0
- package/src/scene/root-container-override.ts +12 -0
- package/src/stocker-capacity-bar.ts +2 -2
- package/src/templates/index.ts +2 -0
- package/src/templates/scanner.ts +20 -0
- package/src/utils/get-value-on-ranges.ts +2 -4
- package/src/zone-capacity-bar.ts +2 -2
- package/translations/en.json +2 -1
- package/translations/ja.json +2 -1
- package/translations/ko.json +2 -1
- package/translations/ms.json +2 -1
- package/translations/zh.json +2 -1
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* - Unit: 낮은 depth, 불투명
|
|
9
9
|
*/
|
|
10
10
|
import * as THREE from 'three';
|
|
11
|
-
import
|
|
11
|
+
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js';
|
|
12
|
+
import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } from '@hatiolab/things-scene';
|
|
12
13
|
import { LEGEND_CAPACITY } from '../features/mcs-status-default';
|
|
13
|
-
import {
|
|
14
|
+
import { getValueOnRanges } from '../utils/get-value-on-ranges';
|
|
14
15
|
/**
|
|
15
16
|
* 포트 기본 높이 (절대값).
|
|
16
17
|
* 모든 이송장치의 상단 높이 = 이 값.
|
|
@@ -29,6 +30,8 @@ const DEFAULTS = {
|
|
|
29
30
|
class MCSRealObject3D extends RealObjectGroup {
|
|
30
31
|
constructor(component, config) {
|
|
31
32
|
super(component);
|
|
33
|
+
// ── Change handling ──
|
|
34
|
+
this._updatePending = false;
|
|
32
35
|
this._config = config;
|
|
33
36
|
}
|
|
34
37
|
// width, height 절대값 (음수 값은 양수로 취급)
|
|
@@ -47,14 +50,22 @@ class MCSRealObject3D extends RealObjectGroup {
|
|
|
47
50
|
}
|
|
48
51
|
get syncZPosOffset() {
|
|
49
52
|
var _a, _b;
|
|
53
|
+
// zPosOverride: 고정 높이 (OHTLine 등)
|
|
54
|
+
if (this._config.zPosOverride != null) {
|
|
55
|
+
return this._config.zPosOverride;
|
|
56
|
+
}
|
|
50
57
|
// Port: 이송 표면 높이에 배치
|
|
51
58
|
if (this._config.defaultZPosFromParent) {
|
|
52
59
|
return TRANSPORT_SURFACE_HEIGHT;
|
|
53
60
|
}
|
|
54
|
-
// Carrier:
|
|
61
|
+
// Carrier: 부모 유형에 따라 배치 위치 결정
|
|
55
62
|
if (this._config.sizeRatio && this._config.sizeRatio < 1) {
|
|
56
63
|
const parentType = (_b = (_a = this.component.parent) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.type;
|
|
57
|
-
|
|
64
|
+
// OHT: 그리퍼 아래에 매달림 (캐리어 상단이 OHT 하단에 붙음)
|
|
65
|
+
if (parentType === 'OHT') {
|
|
66
|
+
return -this.effectiveDepth;
|
|
67
|
+
}
|
|
68
|
+
if (parentType === 'Port' || parentType === 'Shelf' || parentType === 'Shuttle') {
|
|
58
69
|
return 0;
|
|
59
70
|
}
|
|
60
71
|
return TRANSPORT_SURFACE_HEIGHT;
|
|
@@ -68,7 +79,7 @@ class MCSRealObject3D extends RealObjectGroup {
|
|
|
68
79
|
// '#F0F0F0'은 상태 미설정 시 기본 fallback — 무시하고 defaultColor 사용
|
|
69
80
|
try {
|
|
70
81
|
const sc = comp.statusColor;
|
|
71
|
-
if (typeof sc === 'string' && sc && sc.toUpperCase() !== '#F0F0F0')
|
|
82
|
+
if (typeof sc === 'string' && sc && sc.toUpperCase() !== '#F0F0F0' && sc !== 'transparent')
|
|
72
83
|
return new THREE.Color(sc).getHex();
|
|
73
84
|
}
|
|
74
85
|
catch (_a) {
|
|
@@ -76,7 +87,7 @@ class MCSRealObject3D extends RealObjectGroup {
|
|
|
76
87
|
}
|
|
77
88
|
// 2) state.fillStyle fallback
|
|
78
89
|
const { fillStyle } = this.component.state;
|
|
79
|
-
if (fillStyle && typeof fillStyle === 'string') {
|
|
90
|
+
if (fillStyle && typeof fillStyle === 'string' && fillStyle !== 'transparent') {
|
|
80
91
|
try {
|
|
81
92
|
return new THREE.Color(fillStyle).getHex();
|
|
82
93
|
}
|
|
@@ -116,7 +127,7 @@ class MCSRealObject3D extends RealObjectGroup {
|
|
|
116
127
|
// ── Geometry builders ──
|
|
117
128
|
buildBoxGeometry(w, d, h) {
|
|
118
129
|
const geo = new THREE.BoxGeometry(w, d, h);
|
|
119
|
-
return this.removeBottomFace(geo);
|
|
130
|
+
return this._config.keepBottomFace ? geo : this.removeBottomFace(geo);
|
|
120
131
|
}
|
|
121
132
|
buildHexagonGeometry(w, d, h) {
|
|
122
133
|
// Buffer의 2D 형태: 좌우 끝이 꺾인 육각형
|
|
@@ -141,7 +152,11 @@ class MCSRealObject3D extends RealObjectGroup {
|
|
|
141
152
|
geo.rotateX(Math.PI / 2);
|
|
142
153
|
return this.removeBottomFace(geo);
|
|
143
154
|
}
|
|
144
|
-
|
|
155
|
+
buildPlaneGeometry(w, h) {
|
|
156
|
+
const geo = new THREE.PlaneGeometry(w, h);
|
|
157
|
+
geo.rotateX(-Math.PI / 2);
|
|
158
|
+
return geo;
|
|
159
|
+
}
|
|
145
160
|
build() {
|
|
146
161
|
var _a;
|
|
147
162
|
super.build();
|
|
@@ -158,46 +173,164 @@ class MCSRealObject3D extends RealObjectGroup {
|
|
|
158
173
|
const depth = rawDepth * ratio;
|
|
159
174
|
const color = this.resolveColor();
|
|
160
175
|
const { opacity, metalness, roughness, shape } = this._config;
|
|
161
|
-
const geometry = shape === '
|
|
162
|
-
? this.
|
|
163
|
-
:
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
const geometry = shape === 'plane'
|
|
177
|
+
? this.buildPlaneGeometry(w, h)
|
|
178
|
+
: shape === 'hexagon'
|
|
179
|
+
? this.buildHexagonGeometry(w, depth, h)
|
|
180
|
+
: this.buildBoxGeometry(w, depth, h);
|
|
181
|
+
const isPlane = shape === 'plane';
|
|
182
|
+
const material = isPlane
|
|
183
|
+
? new THREE.MeshBasicMaterial({
|
|
184
|
+
color,
|
|
185
|
+
opacity,
|
|
186
|
+
transparent: opacity < 1,
|
|
187
|
+
side: THREE.DoubleSide,
|
|
188
|
+
})
|
|
189
|
+
: new THREE.MeshStandardMaterial(Object.assign({ color,
|
|
190
|
+
metalness,
|
|
191
|
+
roughness,
|
|
192
|
+
opacity, transparent: opacity < 1, side: opacity < 1 ? THREE.DoubleSide : THREE.FrontSide }, (this._config.emissiveIntensity ? { emissive: color, emissiveIntensity: this._config.emissiveIntensity } : {})));
|
|
173
193
|
// z-fighting 방지: 바닥면(floor grid)보다 항상 앞에 렌더링
|
|
174
194
|
material.polygonOffset = true;
|
|
175
195
|
material.polygonOffsetFactor = -1;
|
|
176
196
|
material.polygonOffsetUnit = -1;
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
197
|
+
// BoxGeometry material groups: +x(0), -x(1), +y(2), -y(3), +z(4), -z(5)
|
|
198
|
+
let meshMaterial = material;
|
|
199
|
+
if (shape === 'box') {
|
|
200
|
+
if (this._config.openTop) {
|
|
201
|
+
// 상단면 제거 → 5면 개방 박스
|
|
202
|
+
const invisible = new THREE.MeshBasicMaterial({ visible: false });
|
|
203
|
+
meshMaterial = [material, material, invisible, material, material, material];
|
|
204
|
+
}
|
|
205
|
+
else if (this._config.texturedTop) {
|
|
206
|
+
// 상판에 2D 렌더링 텍스처
|
|
207
|
+
const topMat = this.buildTopTexture(w, h);
|
|
208
|
+
meshMaterial = [material, material, topMat, material, material, material];
|
|
209
|
+
}
|
|
210
|
+
else if (this._config.matteTop) {
|
|
211
|
+
// 상판만 무반사
|
|
212
|
+
const matte = new THREE.MeshBasicMaterial({ color, opacity, transparent: opacity < 1 });
|
|
213
|
+
meshMaterial = [material, material, matte, material, material, material];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
this._ownMesh = new THREE.Mesh(geometry, meshMaterial);
|
|
217
|
+
// sizeRatio < 1이면 부모 중심에 배치 (rawDepth/2), plane은 살짝 띄움
|
|
218
|
+
this._ownMesh.position.y = isPlane ? 1 : ratio < 1 ? rawDepth / 2 : depth / 2;
|
|
219
|
+
this._ownMesh.castShadow = !isPlane;
|
|
220
|
+
this._ownMesh.receiveShadow = true;
|
|
221
|
+
this.object3d.add(this._ownMesh);
|
|
222
|
+
}
|
|
185
223
|
onchange(after, before) {
|
|
186
224
|
if ('width' in after ||
|
|
187
225
|
'height' in after ||
|
|
188
226
|
'depth' in after ||
|
|
189
227
|
'fillStyle' in after ||
|
|
190
228
|
'strokeStyle' in after ||
|
|
191
|
-
'id' in after
|
|
192
|
-
|
|
193
|
-
|
|
229
|
+
'id' in after ||
|
|
230
|
+
'EMPTYTYPE' in after ||
|
|
231
|
+
'CARRIERSTATUS' in after) {
|
|
232
|
+
// 연속 setState에 의한 다중 rebuild 방지: 한 프레임에 한 번만 실행
|
|
233
|
+
if (!this._updatePending) {
|
|
234
|
+
this._updatePending = true;
|
|
235
|
+
queueMicrotask(() => {
|
|
236
|
+
this._updatePending = false;
|
|
237
|
+
this.update();
|
|
238
|
+
});
|
|
239
|
+
}
|
|
194
240
|
return;
|
|
195
241
|
}
|
|
196
242
|
super.onchange(after, before);
|
|
197
243
|
}
|
|
198
|
-
|
|
244
|
+
/**
|
|
245
|
+
* 상판 텍스처: 컴포넌트의 2D render()를 캔버스에 그려서 텍스처로 사용
|
|
246
|
+
*/
|
|
247
|
+
buildTopTexture(w, h) {
|
|
248
|
+
var _a;
|
|
249
|
+
const scale = 4;
|
|
250
|
+
const cw = this.nextPow2(w * scale);
|
|
251
|
+
const ch = this.nextPow2(h * scale);
|
|
252
|
+
const canvas = document.createElement('canvas');
|
|
253
|
+
canvas.width = cw;
|
|
254
|
+
canvas.height = ch;
|
|
255
|
+
const ctx = canvas.getContext('2d');
|
|
256
|
+
const statusColor = '#' + this.resolveColor().toString(16).padStart(6, '0');
|
|
257
|
+
const emptyType = ((_a = this.component.state) === null || _a === void 0 ? void 0 : _a.EMPTYTYPE) || '';
|
|
258
|
+
const text = emptyType === 'FULL' ? 'F' : emptyType === 'EMPTY' ? 'E' : emptyType === 'EMPTYEMPTY' ? 'X' : '';
|
|
259
|
+
// 실제 사용 영역 (nextPow2 이전 크기)
|
|
260
|
+
const usedW = w * scale;
|
|
261
|
+
const usedH = h * scale;
|
|
262
|
+
// 바탕: 캐리어 상태 색상 (사용 영역만)
|
|
263
|
+
ctx.fillStyle = statusColor;
|
|
264
|
+
ctx.fillRect(0, 0, usedW, usedH);
|
|
265
|
+
// 텍스트 (사용 영역 중앙)
|
|
266
|
+
if (text) {
|
|
267
|
+
const fontSize = Math.round(Math.min(usedW, usedH) * 0.7);
|
|
268
|
+
ctx.font = `bold ${fontSize}px Arial`;
|
|
269
|
+
ctx.textAlign = 'center';
|
|
270
|
+
ctx.textBaseline = 'middle';
|
|
271
|
+
ctx.fillStyle = '#000000';
|
|
272
|
+
ctx.fillText(text, usedW / 2, usedH / 2);
|
|
273
|
+
}
|
|
274
|
+
const texture = new THREE.CanvasTexture(canvas);
|
|
275
|
+
texture.offset.set(0, 1 - usedH / ch);
|
|
276
|
+
texture.repeat.set(usedW / cw, usedH / ch);
|
|
277
|
+
texture.colorSpace = THREE.SRGBColorSpace;
|
|
278
|
+
return new THREE.MeshBasicMaterial({
|
|
279
|
+
map: texture,
|
|
280
|
+
transparent: true,
|
|
281
|
+
side: THREE.DoubleSide,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
nextPow2(n) {
|
|
285
|
+
if (!(n > 0))
|
|
286
|
+
return 1;
|
|
287
|
+
let v = Math.ceil(n);
|
|
288
|
+
v--;
|
|
289
|
+
v |= v >> 1;
|
|
290
|
+
v |= v >> 2;
|
|
291
|
+
v |= v >> 4;
|
|
292
|
+
v |= v >> 8;
|
|
293
|
+
v |= v >> 16;
|
|
294
|
+
return v + 1;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* 자신의 mesh만 제거 후 rebuild.
|
|
298
|
+
* 기본 update()는 clear()로 object3d의 모든 children을 제거하는데,
|
|
299
|
+
* 컨테이너(Port 등)의 경우 자식 컴포넌트(Carrier 등)의 3D 오브젝트도 함께 제거됨.
|
|
300
|
+
* 이를 방지하기 위해 자신이 생성한 mesh만 제거한다.
|
|
301
|
+
*/
|
|
302
|
+
update() {
|
|
303
|
+
// 자신의 mesh만 제거 (자식 컴포넌트 3D 오브젝트 보존)
|
|
304
|
+
if (this._ownMesh) {
|
|
305
|
+
this.object3d.remove(this._ownMesh);
|
|
306
|
+
disposeObject3D(this._ownMesh);
|
|
307
|
+
this._ownMesh = undefined;
|
|
308
|
+
}
|
|
309
|
+
this.build();
|
|
310
|
+
this.updateTransform();
|
|
311
|
+
this.updateAlpha();
|
|
312
|
+
this.updateHidden();
|
|
313
|
+
}
|
|
314
|
+
// RealObjectGroup 기본 동작 비활성화
|
|
199
315
|
updateDimension() { }
|
|
200
|
-
updateAlpha() {
|
|
316
|
+
updateAlpha() {
|
|
317
|
+
const state = this.component.state;
|
|
318
|
+
// alpha가 명시적으로 설정되어 있으면 그 값을 사용, 없으면 config 기본값 적용
|
|
319
|
+
const effective = ('alpha' in state) ? state.alpha : this._config.opacity;
|
|
320
|
+
this.object3d.traverse((o) => {
|
|
321
|
+
if (!o.material)
|
|
322
|
+
return;
|
|
323
|
+
const materials = Array.isArray(o.material) ? o.material : [o.material];
|
|
324
|
+
for (const m of materials) {
|
|
325
|
+
if (!m.visible)
|
|
326
|
+
continue; // openTop invisible face 무시
|
|
327
|
+
if (m.map)
|
|
328
|
+
continue; // 텍스처 material은 자체 transparent 유지
|
|
329
|
+
m.opacity = effective;
|
|
330
|
+
m.transparent = effective < 1;
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
201
334
|
}
|
|
202
335
|
// ── 팩토리 등록 헬퍼 ─────────────────────────────────────
|
|
203
336
|
function register(type, overrides = {}) {
|
|
@@ -223,17 +356,89 @@ register('Buffer', {
|
|
|
223
356
|
shape: 'hexagon',
|
|
224
357
|
});
|
|
225
358
|
register('AGVLine', {
|
|
226
|
-
depthRatio: 0
|
|
227
|
-
|
|
228
|
-
roughness: 0.3,
|
|
229
|
-
defaultColor: 0x888899,
|
|
230
|
-
});
|
|
231
|
-
register('OHTLine', {
|
|
232
|
-
depthRatio: 0.12,
|
|
359
|
+
depthRatio: 0,
|
|
360
|
+
defaultDepth: 0.1,
|
|
233
361
|
metalness: 0.6,
|
|
234
362
|
roughness: 0.3,
|
|
235
363
|
defaultColor: 0x888899,
|
|
236
364
|
});
|
|
365
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
366
|
+
// OHTLine — 천장 I-beam 레일
|
|
367
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
368
|
+
const OHT_LINE_RAIL_COLOR = 0xcccccc;
|
|
369
|
+
const OHT_LINE_HEIGHT = 7 * TRANSPORT_SURFACE_HEIGHT; // OHT 상단과 일치
|
|
370
|
+
class OHTLineRealObject3D extends RealObjectGroup {
|
|
371
|
+
get effectiveDepth() { return 0; }
|
|
372
|
+
get syncZPosOffset() { return OHT_LINE_HEIGHT; }
|
|
373
|
+
build() {
|
|
374
|
+
super.build();
|
|
375
|
+
const { width = 10, height = 10 } = this.component.state;
|
|
376
|
+
const w = Math.abs(width);
|
|
377
|
+
const h = Math.abs(height);
|
|
378
|
+
if (!w || !h)
|
|
379
|
+
return;
|
|
380
|
+
// I-beam 치수: 이송 방향 = 긴 변, 폭은 2D의 1/2
|
|
381
|
+
const isVertical = w < h;
|
|
382
|
+
const shortSide = isVertical ? w : h; // 2D 원본 짧은 쪽 폭
|
|
383
|
+
const beltW = shortSide * 0.25; // I-beam 폭: 원본의 1/4
|
|
384
|
+
const beamH = Math.max(beltW * 0.5, 3); // I-beam 전체 높이
|
|
385
|
+
const inset = shortSide * 0.5; // 양끝 여백: 원본 폭의 1/2
|
|
386
|
+
const railLen = (isVertical ? h : w) - inset * 2;
|
|
387
|
+
const flangeH = beamH * 0.2; // 플랜지 두께
|
|
388
|
+
const flangeW = beltW * 0.8; // 플랜지 폭
|
|
389
|
+
const webH = beamH - flangeH * 2; // 웹 높이
|
|
390
|
+
const webW = Math.max(flangeW * 0.25, 1); // 웹 두께
|
|
391
|
+
const mat = new THREE.MeshStandardMaterial({
|
|
392
|
+
color: OHT_LINE_RAIL_COLOR,
|
|
393
|
+
metalness: 0.5,
|
|
394
|
+
roughness: 0.4,
|
|
395
|
+
});
|
|
396
|
+
const geoms = [];
|
|
397
|
+
// 상부 플랜지
|
|
398
|
+
const topFlange = isVertical
|
|
399
|
+
? new THREE.BoxGeometry(flangeW, flangeH, railLen)
|
|
400
|
+
: new THREE.BoxGeometry(railLen, flangeH, flangeW);
|
|
401
|
+
topFlange.translate(0, -flangeH / 2, 0);
|
|
402
|
+
geoms.push(topFlange);
|
|
403
|
+
// 웹 (수직판)
|
|
404
|
+
const web = isVertical
|
|
405
|
+
? new THREE.BoxGeometry(webW, webH, railLen)
|
|
406
|
+
: new THREE.BoxGeometry(railLen, webH, webW);
|
|
407
|
+
web.translate(0, -flangeH - webH / 2, 0);
|
|
408
|
+
geoms.push(web);
|
|
409
|
+
// 하부 플랜지
|
|
410
|
+
const botFlange = isVertical
|
|
411
|
+
? new THREE.BoxGeometry(flangeW, flangeH, railLen)
|
|
412
|
+
: new THREE.BoxGeometry(railLen, flangeH, flangeW);
|
|
413
|
+
botFlange.translate(0, -flangeH - webH - flangeH / 2, 0);
|
|
414
|
+
geoms.push(botFlange);
|
|
415
|
+
this._mesh = new THREE.Mesh(BufferGeometryUtils.mergeGeometries(geoms), mat);
|
|
416
|
+
this._mesh.castShadow = true;
|
|
417
|
+
this.object3d.add(this._mesh);
|
|
418
|
+
}
|
|
419
|
+
update() {
|
|
420
|
+
if (this._mesh) {
|
|
421
|
+
this.object3d.remove(this._mesh);
|
|
422
|
+
this._mesh.geometry.dispose();
|
|
423
|
+
this._mesh.material.dispose();
|
|
424
|
+
this._mesh = undefined;
|
|
425
|
+
}
|
|
426
|
+
this.build();
|
|
427
|
+
this.updateTransform();
|
|
428
|
+
this.updateHidden();
|
|
429
|
+
}
|
|
430
|
+
onchange(after, before) {
|
|
431
|
+
if ('width' in after || 'height' in after || 'depth' in after ||
|
|
432
|
+
'fillStyle' in after || 'strokeStyle' in after) {
|
|
433
|
+
this.update();
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
super.onchange(after, before);
|
|
437
|
+
}
|
|
438
|
+
updateDimension() { }
|
|
439
|
+
updateAlpha() { }
|
|
440
|
+
}
|
|
441
|
+
registerRealObjectFactory('OHTLine', (component) => new OHTLineRealObject3D(component));
|
|
237
442
|
// STOCKER: 벽면에 용량 게이지 바를 포함하는 커스텀 3D 오브젝트
|
|
238
443
|
const STOCKER_CONFIG = Object.assign(Object.assign({}, DEFAULTS), { defaultDepth: 5 * TRANSPORT_SURFACE_HEIGHT, opacity: 0.75, metalness: 0.3, roughness: 0.6, defaultColor: 0x8899bb });
|
|
239
444
|
class StockerRealObject3D extends MCSRealObject3D {
|
|
@@ -355,7 +560,7 @@ class StockerRealObject3D extends MCSRealObject3D {
|
|
|
355
560
|
const fullup = data.FULLUP === 'T';
|
|
356
561
|
const usage = Math.round((cur / max) * 100);
|
|
357
562
|
const legend = ((_b = (_a = this.component.root) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.LEGEND_CAPACITY) || LEGEND_CAPACITY;
|
|
358
|
-
const color = fullup ? 'red' : (
|
|
563
|
+
const color = fullup ? 'red' : (getValueOnRanges(usage, legend) || '#44aa44');
|
|
359
564
|
return {
|
|
360
565
|
segments: [{ ratio: usage / 100, color }],
|
|
361
566
|
borderColor: color,
|
|
@@ -364,6 +569,10 @@ class StockerRealObject3D extends MCSRealObject3D {
|
|
|
364
569
|
}
|
|
365
570
|
}
|
|
366
571
|
}
|
|
572
|
+
update() {
|
|
573
|
+
this.clearGauge();
|
|
574
|
+
super.update();
|
|
575
|
+
}
|
|
367
576
|
onchange(after, before) {
|
|
368
577
|
if ('data' in after) {
|
|
369
578
|
this.clearGauge();
|
|
@@ -391,37 +600,215 @@ registerRealObjectFactory('STOCKER', (component) => new StockerRealObject3D(comp
|
|
|
391
600
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
392
601
|
// Unit (이동체 · 홀더) — 낮은 depth, 불투명
|
|
393
602
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
opacity: 0.5,
|
|
398
|
-
metalness: 0.4,
|
|
399
|
-
roughness: 0.6,
|
|
400
|
-
defaultColor: 0xb0a090,
|
|
401
|
-
});
|
|
603
|
+
// Port: 바닥판 (PlaneGeometry)
|
|
604
|
+
const PORT_CONFIG = Object.assign(Object.assign({}, DEFAULTS), { depthRatio: 0.01, defaultZPosFromParent: true, opacity: 0.1, metalness: 0.3, roughness: 0.8, defaultColor: 0xb0a090, shape: 'plane' });
|
|
605
|
+
registerRealObjectFactory('Port', (component) => new MCSRealObject3D(component, PORT_CONFIG));
|
|
402
606
|
register('Shelf', {
|
|
403
607
|
depthRatio: 0.25,
|
|
404
608
|
metalness: 0.3,
|
|
405
609
|
roughness: 0.7,
|
|
406
610
|
defaultColor: 0xaabbcc,
|
|
407
611
|
});
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
612
|
+
// Carrier: CARRIERSTATUS에 따른 3D 애니메이션 지원
|
|
613
|
+
const CARRIER_CONFIG = Object.assign(Object.assign({}, DEFAULTS), { depthRatio: 0.5, metalness: 0, roughness: 1, defaultColor: 0xf0f0f0, isVisible: (c) => !!c.state.id, sizeRatio: 0.8, texturedTop: true });
|
|
614
|
+
class CarrierRealObject3D extends MCSRealObject3D {
|
|
615
|
+
constructor(component) {
|
|
616
|
+
super(component, CARRIER_CONFIG);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
registerRealObjectFactory('Carrier', (component) => new CarrierRealObject3D(component));
|
|
416
620
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
417
621
|
// Gauge (용량 게이지) — 얇은 바
|
|
418
622
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
419
623
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
420
624
|
// Gauge (용량 게이지) — 2D 렌더링을 Plane 텍스처로 3D 표시
|
|
421
625
|
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
422
|
-
// Gauge
|
|
423
|
-
//
|
|
424
|
-
registerRealObjectFactory('StockerCapacityBar', () =>
|
|
425
|
-
registerRealObjectFactory('MCSGaugeCapacityBar', () =>
|
|
426
|
-
registerRealObjectFactory('ZoneCapacityBar', () =>
|
|
626
|
+
// Gauge 컴포넌트는 3D에서 표시하지 않음 (부모 STOCKER의 3D 모델에서 직접 게이지 렌더링)
|
|
627
|
+
// null 반환으로 3D 오브젝트 생성을 억제하고, default factory fallback도 방지
|
|
628
|
+
registerRealObjectFactory('StockerCapacityBar', () => undefined);
|
|
629
|
+
registerRealObjectFactory('MCSGaugeCapacityBar', () => undefined);
|
|
630
|
+
registerRealObjectFactory('ZoneCapacityBar', () => undefined);
|
|
631
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
632
|
+
// PortFlow — 2D render를 Plane 텍스처로 3D 표시
|
|
633
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
634
|
+
class PortFlowRealObject3D extends RealObjectGroup {
|
|
635
|
+
get effectiveDepth() { return 0; }
|
|
636
|
+
get syncZPosOffset() {
|
|
637
|
+
var _a;
|
|
638
|
+
// 부모 Port/Conveyor의 zPos와 동일하게
|
|
639
|
+
const parent = this.component.parentObject;
|
|
640
|
+
if (((_a = parent === null || parent === void 0 ? void 0 : parent.state) === null || _a === void 0 ? void 0 : _a.zPos) != null)
|
|
641
|
+
return parent.state.zPos;
|
|
642
|
+
return TRANSPORT_SURFACE_HEIGHT;
|
|
643
|
+
}
|
|
644
|
+
build() {
|
|
645
|
+
super.build();
|
|
646
|
+
const { width = 10, height = 10 } = this.component.state;
|
|
647
|
+
const w = Math.abs(width);
|
|
648
|
+
const h = Math.abs(height);
|
|
649
|
+
if (!w || !h)
|
|
650
|
+
return;
|
|
651
|
+
// 2D render를 캔버스에 캡처
|
|
652
|
+
// 화살표 날개 + 텍스트 영역이 bounds 밖으로 나가므로 전체 영역 계산
|
|
653
|
+
const { left, top } = this.component.bounds;
|
|
654
|
+
const { fontSize = 24, labelPosition = 'top' } = this.component.state;
|
|
655
|
+
const arrowPad = Math.min(w, h) * 0.4;
|
|
656
|
+
// 텍스트 영역 확장
|
|
657
|
+
let padLeft = arrowPad, padRight = arrowPad, padTop = arrowPad, padBottom = arrowPad;
|
|
658
|
+
if (this.component.hasTextProperty) {
|
|
659
|
+
switch (labelPosition) {
|
|
660
|
+
case 'top':
|
|
661
|
+
padTop = Math.max(padTop, fontSize + 4);
|
|
662
|
+
break;
|
|
663
|
+
case 'bottom':
|
|
664
|
+
padBottom = Math.max(padBottom, fontSize + 4);
|
|
665
|
+
break;
|
|
666
|
+
case 'left':
|
|
667
|
+
padLeft = Math.max(padLeft, fontSize * 4 + 4);
|
|
668
|
+
break;
|
|
669
|
+
case 'right':
|
|
670
|
+
padRight = Math.max(padRight, fontSize * 4 + 4);
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
const totalW = w + padLeft + padRight;
|
|
675
|
+
const totalH = h + padTop + padBottom;
|
|
676
|
+
const scale = 2;
|
|
677
|
+
const canvas = document.createElement('canvas');
|
|
678
|
+
canvas.width = totalW * scale;
|
|
679
|
+
canvas.height = totalH * scale;
|
|
680
|
+
const ctx = canvas.getContext('2d');
|
|
681
|
+
ctx.save();
|
|
682
|
+
ctx.scale(scale, scale);
|
|
683
|
+
ctx.translate(-left + padLeft, -top + padTop);
|
|
684
|
+
try {
|
|
685
|
+
// 화살표 렌더
|
|
686
|
+
this.component.render(ctx);
|
|
687
|
+
ctx.fillStyle = this.component.state.strokeStyle || '#666666';
|
|
688
|
+
ctx.fill();
|
|
689
|
+
// 텍스트 렌더
|
|
690
|
+
if (this.component.hasTextProperty && this.component.drawText) {
|
|
691
|
+
;
|
|
692
|
+
this.component.drawText(ctx);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
catch ( /* render 실패 시 빈 텍스처 */_a) { /* render 실패 시 빈 텍스처 */ }
|
|
696
|
+
ctx.restore();
|
|
697
|
+
this._texture = new THREE.CanvasTexture(canvas);
|
|
698
|
+
this._texture.colorSpace = THREE.SRGBColorSpace;
|
|
699
|
+
const geo = new THREE.PlaneGeometry(totalW, totalH);
|
|
700
|
+
geo.rotateX(-Math.PI / 2);
|
|
701
|
+
const mat = new THREE.MeshBasicMaterial({
|
|
702
|
+
map: this._texture,
|
|
703
|
+
alphaTest: 0.1,
|
|
704
|
+
side: THREE.DoubleSide,
|
|
705
|
+
});
|
|
706
|
+
this._mesh = new THREE.Mesh(geo, mat);
|
|
707
|
+
// 비대칭 패딩 보정: 플레인 센터를 컴포넌트 bounds 센터에 맞춤
|
|
708
|
+
this._mesh.position.x = (padRight - padLeft) / 2;
|
|
709
|
+
this._mesh.position.y = 1;
|
|
710
|
+
this._mesh.position.z = (padBottom - padTop) / 2;
|
|
711
|
+
this.object3d.add(this._mesh);
|
|
712
|
+
}
|
|
713
|
+
update() {
|
|
714
|
+
var _a;
|
|
715
|
+
if (this._mesh) {
|
|
716
|
+
this.object3d.remove(this._mesh);
|
|
717
|
+
this._mesh.geometry.dispose();
|
|
718
|
+
this._mesh.material.dispose();
|
|
719
|
+
(_a = this._texture) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
720
|
+
this._mesh = undefined;
|
|
721
|
+
this._texture = undefined;
|
|
722
|
+
}
|
|
723
|
+
this.build();
|
|
724
|
+
this.updateTransform();
|
|
725
|
+
this.updateHidden();
|
|
726
|
+
}
|
|
727
|
+
onchange(after, before) {
|
|
728
|
+
if ('width' in after || 'height' in after || 'orientation' in after ||
|
|
729
|
+
'direction' in after || 'strokeStyle' in after || 'INOUTTYPE' in after) {
|
|
730
|
+
this.update();
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
super.onchange(after, before);
|
|
734
|
+
}
|
|
735
|
+
updateDimension() { }
|
|
736
|
+
updateAlpha() { }
|
|
737
|
+
}
|
|
738
|
+
registerRealObjectFactory('PortFlow', (component) => new PortFlowRealObject3D(component));
|
|
739
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
740
|
+
// Node — 2D render를 바닥 Plane 텍스처로 3D 표시
|
|
741
|
+
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
742
|
+
class NodeRealObject3D extends RealObjectGroup {
|
|
743
|
+
get effectiveDepth() { return 0; }
|
|
744
|
+
get syncZPosOffset() { return 0; }
|
|
745
|
+
build() {
|
|
746
|
+
super.build();
|
|
747
|
+
const { cx, cy } = this.component.state;
|
|
748
|
+
const radius = 8;
|
|
749
|
+
const size = radius * 2;
|
|
750
|
+
const scale = 2;
|
|
751
|
+
const pad = 2;
|
|
752
|
+
const canvas = document.createElement('canvas');
|
|
753
|
+
canvas.width = (size + pad * 2) * scale;
|
|
754
|
+
canvas.height = (size + pad * 2) * scale;
|
|
755
|
+
const ctx = canvas.getContext('2d');
|
|
756
|
+
ctx.save();
|
|
757
|
+
ctx.scale(scale, scale);
|
|
758
|
+
ctx.translate(-cx + radius + pad, -cy + radius + pad);
|
|
759
|
+
try {
|
|
760
|
+
this.component.render(ctx);
|
|
761
|
+
const { fillStyle = '#888888' } = this.component.state;
|
|
762
|
+
ctx.fillStyle = typeof fillStyle === 'string' ? fillStyle : '#888888';
|
|
763
|
+
ctx.fill();
|
|
764
|
+
const { strokeStyle } = this.component.state;
|
|
765
|
+
if (strokeStyle && typeof strokeStyle === 'string') {
|
|
766
|
+
ctx.strokeStyle = strokeStyle;
|
|
767
|
+
ctx.lineWidth = 1;
|
|
768
|
+
ctx.stroke();
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
catch ( /* render 실패 시 빈 텍스처 */_a) { /* render 실패 시 빈 텍스처 */ }
|
|
772
|
+
ctx.restore();
|
|
773
|
+
this._texture = new THREE.CanvasTexture(canvas);
|
|
774
|
+
this._texture.colorSpace = THREE.SRGBColorSpace;
|
|
775
|
+
const geo = new THREE.PlaneGeometry(size + pad * 2, size + pad * 2);
|
|
776
|
+
geo.rotateX(-Math.PI / 2);
|
|
777
|
+
const mat = new THREE.MeshBasicMaterial({
|
|
778
|
+
map: this._texture,
|
|
779
|
+
alphaTest: 0.1,
|
|
780
|
+
side: THREE.DoubleSide,
|
|
781
|
+
});
|
|
782
|
+
this._mesh = new THREE.Mesh(geo, mat);
|
|
783
|
+
this._mesh.position.y = 1;
|
|
784
|
+
this.object3d.add(this._mesh);
|
|
785
|
+
}
|
|
786
|
+
update() {
|
|
787
|
+
var _a;
|
|
788
|
+
if (this._mesh) {
|
|
789
|
+
this.object3d.remove(this._mesh);
|
|
790
|
+
this._mesh.geometry.dispose();
|
|
791
|
+
this._mesh.material.dispose();
|
|
792
|
+
(_a = this._texture) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
793
|
+
this._mesh = undefined;
|
|
794
|
+
this._texture = undefined;
|
|
795
|
+
}
|
|
796
|
+
this.build();
|
|
797
|
+
this.updateTransform();
|
|
798
|
+
this.updateHidden();
|
|
799
|
+
}
|
|
800
|
+
onchange(after, before) {
|
|
801
|
+
if ('fillStyle' in after || 'strokeStyle' in after) {
|
|
802
|
+
this.update();
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
super.onchange(after, before);
|
|
806
|
+
}
|
|
807
|
+
updateDimension() { }
|
|
808
|
+
updateAlpha() { }
|
|
809
|
+
}
|
|
810
|
+
registerRealObjectFactory('Node', (component) => new NodeRealObject3D(component));
|
|
811
|
+
// Scanner — 이송 표면 높이의 기둥 형태
|
|
812
|
+
const SCANNER_CONFIG = Object.assign(Object.assign({}, DEFAULTS), { defaultDepth: TRANSPORT_SURFACE_HEIGHT * 0.2, defaultZPosFromParent: true, opacity: 1, metalness: 0.3, roughness: 0.7, defaultColor: 0x888888, shape: 'box' });
|
|
813
|
+
registerRealObjectFactory('Scanner', (component) => new MCSRealObject3D(component, SCANNER_CONFIG));
|
|
427
814
|
//# sourceMappingURL=machine-3d.js.map
|