@fmsim/machine 2.0.0-beta.78 → 2.0.0-beta.80

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.78",
5
+ "version": "2.0.0-beta.80",
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": "ec49cb13a3210741a7002d0f3fb002ed280594f4"
58
+ "gitHead": "154b52d88246116ee030f14a0d399f6172640318"
59
59
  }
@@ -16,12 +16,15 @@ import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUti
16
16
  import { RealObjectGroup, registerRealObjectFactory } from '@hatiolab/things-scene'
17
17
  import type { Component } from '@hatiolab/things-scene'
18
18
  import { TRANSPORT_SURFACE_HEIGHT } from './machine-3d.js'
19
+ import { Z_FMSIM } from './z-priority'
19
20
 
20
21
  const FRAME_COLOR = 0x888899
21
22
  const ROLLER_COLOR = 0xaaaabc
22
23
  const DEFAULT_COLOR = 0x999999
23
24
 
24
25
  export class Conveyor3D extends RealObjectGroup {
26
+ get zPriority(): number { return Z_FMSIM.CONVEYOR }
27
+
25
28
  get effectiveDepth(): number {
26
29
  const { depth } = this.component.state
27
30
  return depth || TRANSPORT_SURFACE_HEIGHT
@@ -15,6 +15,7 @@ import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUti
15
15
  import { RealObjectGroup, registerRealObjectFactory } from '@hatiolab/things-scene'
16
16
  import type { Component } from '@hatiolab/things-scene'
17
17
  import { TRANSPORT_SURFACE_HEIGHT } from './machine-3d.js'
18
+ import { Z_FMSIM } from './z-priority'
18
19
 
19
20
  const RAIL_COLOR = 0x666677
20
21
  const SUPPORT_COLOR = 0x555566
@@ -23,6 +24,8 @@ const SUPPORT_COLOR = 0x555566
23
24
  const DEFAULT_RAIL_DEPTH = 5 * TRANSPORT_SURFACE_HEIGHT
24
25
 
25
26
  export class CraneRail3D extends RealObjectGroup {
27
+ get zPriority(): number { return Z_FMSIM.CRANE_RAIL }
28
+
26
29
  get effectiveDepth(): number {
27
30
  const { depth } = this.component.state
28
31
  return depth || DEFAULT_RAIL_DEPTH
@@ -14,6 +14,7 @@ import { RealObjectGroup, registerRealObjectFactory, disposeObject3D } from '@ha
14
14
  import type { Component } from '@hatiolab/things-scene'
15
15
  import { LEGEND_CAPACITY } from '../features/mcs-status-default'
16
16
  import { getValueOnRanges } from '../utils/get-value-on-ranges'
17
+ import { Z_FMSIM } from './z-priority'
17
18
 
18
19
  // ── 설정 타입 ────────────────────────────────────────────
19
20
 
@@ -48,6 +49,8 @@ interface MCS3DConfig {
48
49
  keepBottomFace?: boolean
49
50
  /** syncZPosOffset 고정값 (설정 시 다른 로직 무시) */
50
51
  zPosOverride?: number
52
+ /** z-priority — polygonOffset 으로 z-fight 완화. 기본 0 (OBJECTS). */
53
+ zPriority?: number
51
54
  }
52
55
 
53
56
  /**
@@ -76,6 +79,10 @@ class MCSRealObject3D extends RealObjectGroup {
76
79
  this._config = config
77
80
  }
78
81
 
82
+ get zPriority(): number {
83
+ return this._config.zPriority ?? 0
84
+ }
85
+
79
86
  // width, height 절대값 (음수 값은 양수로 취급).
80
87
  // `resizable:false` 컴포넌트(예: Scanner)는 state.width/height 가 없고
81
88
  // bounds 만 있을 수 있으므로 bounds 를 fallback 으로 사용.
@@ -503,6 +510,7 @@ register('Equipment', {
503
510
  metalness: 0.4,
504
511
  roughness: 0.6,
505
512
  defaultColor: 0x8899aa,
513
+ zPriority: Z_FMSIM.EQUIPMENT,
506
514
  })
507
515
 
508
516
  register('Buffer', {
@@ -512,6 +520,7 @@ register('Buffer', {
512
520
  roughness: 0.7,
513
521
  defaultColor: 0x99aa88,
514
522
  shape: 'hexagon',
523
+ zPriority: Z_FMSIM.BUFFER,
515
524
  })
516
525
 
517
526
  register('AGVLine', {
@@ -520,6 +529,7 @@ register('AGVLine', {
520
529
  metalness: 0.6,
521
530
  roughness: 0.3,
522
531
  defaultColor: 0x888899,
532
+ zPriority: Z_FMSIM.AGV_LINE,
523
533
  })
524
534
 
525
535
  // ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
@@ -532,6 +542,7 @@ const OHT_LINE_HEIGHT = 7 * TRANSPORT_SURFACE_HEIGHT // OHT 상단과 일치
532
542
  class OHTLineRealObject3D extends RealObjectGroup {
533
543
  private _mesh?: THREE.Mesh
534
544
 
545
+ get zPriority(): number { return Z_FMSIM.OHT_LINE }
535
546
  get effectiveDepth(): number { return 0 }
536
547
  protected get syncZPosOffset(): number { return OHT_LINE_HEIGHT }
537
548
 
@@ -624,6 +635,7 @@ const STOCKER_CONFIG: MCS3DConfig = {
624
635
  metalness: 0.3,
625
636
  roughness: 0.6,
626
637
  defaultColor: 0x8899bb,
638
+ zPriority: Z_FMSIM.STOCKER,
627
639
  }
628
640
 
629
641
  class StockerRealObject3D extends MCSRealObject3D {
@@ -815,6 +827,7 @@ const PORT_CONFIG: MCS3DConfig = {
815
827
  roughness: 0.8,
816
828
  defaultColor: 0xb0a090,
817
829
  shape: 'plane',
830
+ zPriority: Z_FMSIM.PORT,
818
831
  }
819
832
  registerRealObjectFactory('Port', (component: Component) => new MCSRealObject3D(component, PORT_CONFIG))
820
833
 
@@ -823,6 +836,7 @@ register('Shelf', {
823
836
  metalness: 0.3,
824
837
  roughness: 0.7,
825
838
  defaultColor: 0xaabbcc,
839
+ zPriority: Z_FMSIM.SHELF,
826
840
  })
827
841
 
828
842
  // Carrier: CARRIERSTATUS에 따른 3D 애니메이션 지원
@@ -835,6 +849,7 @@ const CARRIER_CONFIG: MCS3DConfig = {
835
849
  isVisible: (c: Component) => !!(c.state as any).id,
836
850
  sizeRatio: 0.8,
837
851
  texturedTop: true,
852
+ // Carrier 는 이동 entity — default OBJECTS(0). zPriority 미설정.
838
853
  }
839
854
 
840
855
  class CarrierRealObject3D extends MCSRealObject3D {
@@ -867,6 +882,7 @@ class PortFlowRealObject3D extends RealObjectGroup {
867
882
  private _mesh?: THREE.Mesh
868
883
  private _texture?: THREE.CanvasTexture
869
884
 
885
+ get zPriority(): number { return Z_FMSIM.PORT_FLOW }
870
886
  get effectiveDepth(): number { return 0 }
871
887
  protected get syncZPosOffset(): number {
872
888
  // 부모 Port/Conveyor의 zPos와 동일하게
@@ -980,6 +996,7 @@ class NodeRealObject3D extends RealObjectGroup {
980
996
  private _mesh?: THREE.Mesh
981
997
  private _texture?: THREE.CanvasTexture
982
998
 
999
+ get zPriority(): number { return Z_FMSIM.NODE }
983
1000
  get effectiveDepth(): number { return 0 }
984
1001
  protected get syncZPosOffset(): number { return 0 }
985
1002
 
@@ -1070,5 +1087,6 @@ const SCANNER_CONFIG: MCS3DConfig = {
1070
1087
  roughness: 0.7,
1071
1088
  defaultColor: 0x888888,
1072
1089
  shape: 'triangle',
1090
+ zPriority: Z_FMSIM.SCANNER,
1073
1091
  }
1074
1092
  registerRealObjectFactory('Scanner', (component: Component) => new MCSRealObject3D(component, SCANNER_CONFIG))
@@ -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
package/src/index.ts CHANGED
@@ -9,6 +9,8 @@ import './factories/oht-3d'
9
9
  import './factories/shuttle-3d'
10
10
  import './factories/crane-3d'
11
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
16
  // bars & overlays
@@ -229,9 +229,9 @@ Object.defineProperty(ModelLayer.prototype, 'nature', {
229
229
  * 를 일괄 set → three-capability 의 변경 감지 핸들러가 즉시 갱신.
230
230
  */
231
231
  const LIGHT_PRESETS: Record<string, { exposure: number; hemiIntensity: number; dirLightIntensity: number }> = {
232
- dark: { exposure: 0.7, hemiIntensity: 2.0, dirLightIntensity: 1.0 },
232
+ dark: { exposure: 1.2, hemiIntensity: 4.0, dirLightIntensity: 0.6 },
233
233
  medium: { exposure: 1.2, hemiIntensity: 4.0, dirLightIntensity: 2.0 },
234
- bright: { exposure: 1.6, hemiIntensity: 6.0, dirLightIntensity: 3.0 }
234
+ bright: { exposure: 1.2, hemiIntensity: 4.0, dirLightIntensity: 5.0 }
235
235
  }
236
236
 
237
237
  const _origModelLayerOnchange = ModelLayer.prototype.onchange