@operato/scene-storage 10.0.0-beta.42 → 10.0.0-beta.43
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/CHANGELOG.md +8 -0
- package/dist/parcel-3d.js +42 -9
- package/dist/parcel-3d.js.map +1 -1
- package/package.json +2 -2
- package/src/parcel-3d.ts +41 -9
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.0.0-beta.43](https://github.com/things-scene/operato-scene/compare/v10.0.0-beta.42...v10.0.0-beta.43) (2026-05-21)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @operato/scene-storage
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
## [10.0.0-beta.42](https://github.com/things-scene/operato-scene/compare/v10.0.0-beta.41...v10.0.0-beta.42) (2026-05-21)
|
|
7
15
|
|
|
8
16
|
|
package/dist/parcel-3d.js
CHANGED
|
@@ -37,14 +37,48 @@ const PARCEL_LABEL_MATERIAL = new THREE.MeshStandardMaterial({
|
|
|
37
37
|
metalness: 0,
|
|
38
38
|
roughness: 0.4
|
|
39
39
|
});
|
|
40
|
+
// ── Geometry cache — 같은 (w,h,d) 인 parcel 들 BoxGeometry 공유. 수백 parcel 의
|
|
41
|
+
// GPU memory + setup cost 폭감.
|
|
42
|
+
const _BODY_GEO_CACHE = new Map();
|
|
43
|
+
const _TAPE_GEO_CACHE = new Map();
|
|
44
|
+
const _LABEL_GEO_CACHE = new Map();
|
|
45
|
+
function _key3(a, b, c) {
|
|
46
|
+
return `${a.toFixed(1)}-${b.toFixed(1)}-${c.toFixed(1)}`;
|
|
47
|
+
}
|
|
48
|
+
function _getBodyGeo(w, d, h) {
|
|
49
|
+
const k = _key3(w, d, h);
|
|
50
|
+
let g = _BODY_GEO_CACHE.get(k);
|
|
51
|
+
if (!g) {
|
|
52
|
+
g = new THREE.BoxGeometry(w, d, h);
|
|
53
|
+
_BODY_GEO_CACHE.set(k, g);
|
|
54
|
+
}
|
|
55
|
+
return g;
|
|
56
|
+
}
|
|
57
|
+
function _getTapeGeo(w, t, l) {
|
|
58
|
+
const k = _key3(w, t, l);
|
|
59
|
+
let g = _TAPE_GEO_CACHE.get(k);
|
|
60
|
+
if (!g) {
|
|
61
|
+
g = new THREE.BoxGeometry(w, t, l);
|
|
62
|
+
_TAPE_GEO_CACHE.set(k, g);
|
|
63
|
+
}
|
|
64
|
+
return g;
|
|
65
|
+
}
|
|
66
|
+
function _getLabelGeo(w, t, h) {
|
|
67
|
+
const k = _key3(w, t, h);
|
|
68
|
+
let g = _LABEL_GEO_CACHE.get(k);
|
|
69
|
+
if (!g) {
|
|
70
|
+
g = new THREE.BoxGeometry(w, t, h);
|
|
71
|
+
_LABEL_GEO_CACHE.set(k, g);
|
|
72
|
+
}
|
|
73
|
+
return g;
|
|
74
|
+
}
|
|
40
75
|
export class Parcel3D extends RealObjectGroup {
|
|
41
76
|
build() {
|
|
42
77
|
super.build();
|
|
43
78
|
const { width, height, depth = 150 } = this.component.state;
|
|
44
79
|
const baseY = -depth / 2;
|
|
45
80
|
// ── Main body ────────────────────────────────────────────────────
|
|
46
|
-
const
|
|
47
|
-
const bodyMesh = new THREE.Mesh(bodyGeo, PARCEL_BODY_MATERIAL);
|
|
81
|
+
const bodyMesh = new THREE.Mesh(_getBodyGeo(width, depth, height), PARCEL_BODY_MATERIAL);
|
|
48
82
|
bodyMesh.position.set(0, 0, 0);
|
|
49
83
|
bodyMesh.castShadow = true;
|
|
50
84
|
bodyMesh.receiveShadow = true;
|
|
@@ -53,24 +87,23 @@ export class Parcel3D extends RealObjectGroup {
|
|
|
53
87
|
const tapeW = Math.min(width, height) * 0.10;
|
|
54
88
|
const tapeT = depth * 0.02;
|
|
55
89
|
const tapeAlongLong = width >= height;
|
|
56
|
-
const
|
|
57
|
-
?
|
|
58
|
-
:
|
|
59
|
-
const tapeMesh = new THREE.Mesh(tapeGeo, PARCEL_TAPE_MATERIAL);
|
|
90
|
+
const tapeMesh = new THREE.Mesh(tapeAlongLong
|
|
91
|
+
? _getTapeGeo(width * 1.005, tapeT, tapeW)
|
|
92
|
+
: _getTapeGeo(tapeW, tapeT, height * 1.005), PARCEL_TAPE_MATERIAL);
|
|
60
93
|
tapeMesh.position.set(0, baseY + depth + tapeT / 2 - 0.01, 0);
|
|
94
|
+
// shadow 부담 줄임 — tape 는 얇아 shadow 시각 영향 미미
|
|
61
95
|
this.object3d.add(tapeMesh);
|
|
62
96
|
// ── Shipping label (small white rectangle on top) ────────────────
|
|
63
97
|
const labelW = Math.min(width, height) * 0.35;
|
|
64
98
|
const labelH = labelW * 0.6;
|
|
65
|
-
const
|
|
66
|
-
const labelMesh = new THREE.Mesh(labelGeo, PARCEL_LABEL_MATERIAL);
|
|
67
|
-
// Position on top, off-center by ~25% of long axis
|
|
99
|
+
const labelMesh = new THREE.Mesh(_getLabelGeo(labelW, depth * 0.005, labelH), PARCEL_LABEL_MATERIAL);
|
|
68
100
|
if (tapeAlongLong) {
|
|
69
101
|
labelMesh.position.set(width * 0.2, baseY + depth + depth * 0.0025, -height * 0.15);
|
|
70
102
|
}
|
|
71
103
|
else {
|
|
72
104
|
labelMesh.position.set(width * 0.15, baseY + depth + depth * 0.0025, height * 0.2);
|
|
73
105
|
}
|
|
106
|
+
// shadow 부담 줄임 — label 도 얇아 shadow 시각 영향 미미
|
|
74
107
|
this.object3d.add(labelMesh);
|
|
75
108
|
}
|
|
76
109
|
updateDimension() { }
|
package/dist/parcel-3d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parcel-3d.js","sourceRoot":"","sources":["../src/parcel-3d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OA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,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;QACrF,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,CAAA;QACpF,CAAC;QACD,4CAA4C;QAC5C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IAC9B,CAAC;IAED,eAAe,KAAI,CAAC;IAEpB,QAAQ,CAAC,KAA8B,EAAE,MAA+B;QACtE,IAAI,OAAO,IAAI,KAAK,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;YAC9D,IAAI,CAAC,MAAM,EAAE,CAAA;YACb,OAAM;QACR,CAAC;QACD,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,WAAW,KAAI,CAAC;CACjB","sourcesContent":["/*\n * Copyright © HatioLab Inc. All rights reserved.\n *\n * Parcel 3D — a cardboard package.\n *\n * Structure:\n * - main body box (cardboard color)\n * - tape line running across the top (the visual signature — what makes\n * this read as a \"shipping parcel\" rather than a generic box)\n * - small label area on top (white rectangle suggesting a shipping label)\n *\n * Kept very simple — parcels in a logistics scene are typically present in\n * large numbers (sortation lines, fulfillment bays), so polygon count\n * matters more than it does for one-off equipment.\n */\n\nimport * as THREE from 'three'\nimport { RealObjectGroup } from '@hatiolab/things-scene'\n\nconst CARDBOARD_COLOR = 0xc8a878\nconst TAPE_COLOR = 0xddc899\nconst LABEL_COLOR = 0xeeeeee\n\n// ── Module-level shared materials ───────────────────────────────────────────\n// Parcel 인스턴스가 수백~수천 가능. instance 별 new MeshStandardMaterial 시\n// material 개수 폭증 → GPU memory + draw call 비효율. static color 라 단일\n// instance 공유. 색 변경 시 모든 Parcel 에 자동 반영 (의도).\nconst PARCEL_BODY_MATERIAL = new THREE.MeshStandardMaterial({\n color: CARDBOARD_COLOR,\n metalness: 0,\n roughness: 0.9\n})\nconst PARCEL_TAPE_MATERIAL = new THREE.MeshStandardMaterial({\n color: TAPE_COLOR,\n metalness: 0.05,\n roughness: 0.5\n})\nconst PARCEL_LABEL_MATERIAL = new THREE.MeshStandardMaterial({\n color: LABEL_COLOR,\n metalness: 0,\n roughness: 0.4\n})\n\n// ── Geometry cache — 같은 (w,h,d) 인 parcel 들 BoxGeometry 공유. 수백 parcel 의\n// GPU memory + setup cost 폭감.\nconst _BODY_GEO_CACHE = new Map<string, THREE.BoxGeometry>()\nconst _TAPE_GEO_CACHE = new Map<string, THREE.BoxGeometry>()\nconst _LABEL_GEO_CACHE = new Map<string, THREE.BoxGeometry>()\n\nfunction _key3(a: number, b: number, c: number): string {\n return `${a.toFixed(1)}-${b.toFixed(1)}-${c.toFixed(1)}`\n}\nfunction _getBodyGeo(w: number, d: number, h: number): THREE.BoxGeometry {\n const k = _key3(w, d, h)\n let g = _BODY_GEO_CACHE.get(k)\n if (!g) { g = new THREE.BoxGeometry(w, d, h); _BODY_GEO_CACHE.set(k, g) }\n return g\n}\nfunction _getTapeGeo(w: number, t: number, l: number): THREE.BoxGeometry {\n const k = _key3(w, t, l)\n let g = _TAPE_GEO_CACHE.get(k)\n if (!g) { g = new THREE.BoxGeometry(w, t, l); _TAPE_GEO_CACHE.set(k, g) }\n return g\n}\nfunction _getLabelGeo(w: number, t: number, h: number): THREE.BoxGeometry {\n const k = _key3(w, t, h)\n let g = _LABEL_GEO_CACHE.get(k)\n if (!g) { g = new THREE.BoxGeometry(w, t, h); _LABEL_GEO_CACHE.set(k, g) }\n return g\n}\n\nexport class Parcel3D extends RealObjectGroup {\n build() {\n super.build()\n\n const { width, height, depth = 150 } = this.component.state\n const baseY = -depth / 2\n\n // ── Main body ────────────────────────────────────────────────────\n const bodyMesh = new THREE.Mesh(_getBodyGeo(width, depth, height), PARCEL_BODY_MATERIAL)\n bodyMesh.position.set(0, 0, 0)\n bodyMesh.castShadow = true\n bodyMesh.receiveShadow = true\n this.object3d.add(bodyMesh)\n\n // ── Tape line on top (running along the long axis) ───────────────\n const tapeW = Math.min(width, height) * 0.10\n const tapeT = depth * 0.02\n const tapeAlongLong = width >= height\n const tapeMesh = new THREE.Mesh(\n tapeAlongLong\n ? _getTapeGeo(width * 1.005, tapeT, tapeW)\n : _getTapeGeo(tapeW, tapeT, height * 1.005),\n PARCEL_TAPE_MATERIAL\n )\n tapeMesh.position.set(0, baseY + depth + tapeT / 2 - 0.01, 0)\n // shadow 부담 줄임 — tape 는 얇아 shadow 시각 영향 미미\n this.object3d.add(tapeMesh)\n\n // ── Shipping label (small white rectangle on top) ────────────────\n const labelW = Math.min(width, height) * 0.35\n const labelH = labelW * 0.6\n const labelMesh = new THREE.Mesh(\n _getLabelGeo(labelW, depth * 0.005, labelH),\n PARCEL_LABEL_MATERIAL\n )\n if (tapeAlongLong) {\n labelMesh.position.set(width * 0.2, baseY + depth + depth * 0.0025, -height * 0.15)\n } else {\n labelMesh.position.set(width * 0.15, baseY + depth + depth * 0.0025, height * 0.2)\n }\n // shadow 부담 줄임 — label 도 얇아 shadow 시각 영향 미미\n this.object3d.add(labelMesh)\n }\n\n updateDimension() {}\n\n onchange(after: Record<string, unknown>, before: Record<string, unknown>) {\n if ('width' in after || 'height' in after || 'depth' in after) {\n this.update()\n return\n }\n super.onchange(after, before)\n }\n\n updateAlpha() {}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@operato/scene-storage",
|
|
3
3
|
"description": "Storage-domain components for things-scene (smart factory / logistics) — pallet, box, parcel; AS/RS and shelves planned.",
|
|
4
4
|
"author": "heartyoh",
|
|
5
|
-
"version": "10.0.0-beta.
|
|
5
|
+
"version": "10.0.0-beta.43",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"typescript": "^5.0.4"
|
|
46
46
|
},
|
|
47
47
|
"prettier": "@hatiolab/prettier-config",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "6e92206ada64b1b0d4e6a4f73ee34ee99e87bd57"
|
|
49
49
|
}
|
package/src/parcel-3d.ts
CHANGED
|
@@ -41,6 +41,34 @@ const PARCEL_LABEL_MATERIAL = new THREE.MeshStandardMaterial({
|
|
|
41
41
|
roughness: 0.4
|
|
42
42
|
})
|
|
43
43
|
|
|
44
|
+
// ── Geometry cache — 같은 (w,h,d) 인 parcel 들 BoxGeometry 공유. 수백 parcel 의
|
|
45
|
+
// GPU memory + setup cost 폭감.
|
|
46
|
+
const _BODY_GEO_CACHE = new Map<string, THREE.BoxGeometry>()
|
|
47
|
+
const _TAPE_GEO_CACHE = new Map<string, THREE.BoxGeometry>()
|
|
48
|
+
const _LABEL_GEO_CACHE = new Map<string, THREE.BoxGeometry>()
|
|
49
|
+
|
|
50
|
+
function _key3(a: number, b: number, c: number): string {
|
|
51
|
+
return `${a.toFixed(1)}-${b.toFixed(1)}-${c.toFixed(1)}`
|
|
52
|
+
}
|
|
53
|
+
function _getBodyGeo(w: number, d: number, h: number): THREE.BoxGeometry {
|
|
54
|
+
const k = _key3(w, d, h)
|
|
55
|
+
let g = _BODY_GEO_CACHE.get(k)
|
|
56
|
+
if (!g) { g = new THREE.BoxGeometry(w, d, h); _BODY_GEO_CACHE.set(k, g) }
|
|
57
|
+
return g
|
|
58
|
+
}
|
|
59
|
+
function _getTapeGeo(w: number, t: number, l: number): THREE.BoxGeometry {
|
|
60
|
+
const k = _key3(w, t, l)
|
|
61
|
+
let g = _TAPE_GEO_CACHE.get(k)
|
|
62
|
+
if (!g) { g = new THREE.BoxGeometry(w, t, l); _TAPE_GEO_CACHE.set(k, g) }
|
|
63
|
+
return g
|
|
64
|
+
}
|
|
65
|
+
function _getLabelGeo(w: number, t: number, h: number): THREE.BoxGeometry {
|
|
66
|
+
const k = _key3(w, t, h)
|
|
67
|
+
let g = _LABEL_GEO_CACHE.get(k)
|
|
68
|
+
if (!g) { g = new THREE.BoxGeometry(w, t, h); _LABEL_GEO_CACHE.set(k, g) }
|
|
69
|
+
return g
|
|
70
|
+
}
|
|
71
|
+
|
|
44
72
|
export class Parcel3D extends RealObjectGroup {
|
|
45
73
|
build() {
|
|
46
74
|
super.build()
|
|
@@ -49,8 +77,7 @@ export class Parcel3D extends RealObjectGroup {
|
|
|
49
77
|
const baseY = -depth / 2
|
|
50
78
|
|
|
51
79
|
// ── Main body ────────────────────────────────────────────────────
|
|
52
|
-
const
|
|
53
|
-
const bodyMesh = new THREE.Mesh(bodyGeo, PARCEL_BODY_MATERIAL)
|
|
80
|
+
const bodyMesh = new THREE.Mesh(_getBodyGeo(width, depth, height), PARCEL_BODY_MATERIAL)
|
|
54
81
|
bodyMesh.position.set(0, 0, 0)
|
|
55
82
|
bodyMesh.castShadow = true
|
|
56
83
|
bodyMesh.receiveShadow = true
|
|
@@ -60,24 +87,29 @@ export class Parcel3D extends RealObjectGroup {
|
|
|
60
87
|
const tapeW = Math.min(width, height) * 0.10
|
|
61
88
|
const tapeT = depth * 0.02
|
|
62
89
|
const tapeAlongLong = width >= height
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
90
|
+
const tapeMesh = new THREE.Mesh(
|
|
91
|
+
tapeAlongLong
|
|
92
|
+
? _getTapeGeo(width * 1.005, tapeT, tapeW)
|
|
93
|
+
: _getTapeGeo(tapeW, tapeT, height * 1.005),
|
|
94
|
+
PARCEL_TAPE_MATERIAL
|
|
95
|
+
)
|
|
67
96
|
tapeMesh.position.set(0, baseY + depth + tapeT / 2 - 0.01, 0)
|
|
97
|
+
// shadow 부담 줄임 — tape 는 얇아 shadow 시각 영향 미미
|
|
68
98
|
this.object3d.add(tapeMesh)
|
|
69
99
|
|
|
70
100
|
// ── Shipping label (small white rectangle on top) ────────────────
|
|
71
101
|
const labelW = Math.min(width, height) * 0.35
|
|
72
102
|
const labelH = labelW * 0.6
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
103
|
+
const labelMesh = new THREE.Mesh(
|
|
104
|
+
_getLabelGeo(labelW, depth * 0.005, labelH),
|
|
105
|
+
PARCEL_LABEL_MATERIAL
|
|
106
|
+
)
|
|
76
107
|
if (tapeAlongLong) {
|
|
77
108
|
labelMesh.position.set(width * 0.2, baseY + depth + depth * 0.0025, -height * 0.15)
|
|
78
109
|
} else {
|
|
79
110
|
labelMesh.position.set(width * 0.15, baseY + depth + depth * 0.0025, height * 0.2)
|
|
80
111
|
}
|
|
112
|
+
// shadow 부담 줄임 — label 도 얇아 shadow 시각 영향 미미
|
|
81
113
|
this.object3d.add(labelMesh)
|
|
82
114
|
}
|
|
83
115
|
|