Spaces:
Paused
Paused
Surf commited on
Commit ·
a8359b3
1
Parent(s): 3d3569d
暮归江南 · 步骤8 补充:扫描货物按镜头观感放大、摊位铺满、提升货物天光;README 记录 SimReady 目录调研结论与验证
Browse files- README.md +2 -1
- src/jiangnan/engine/assets.ts +22 -19
README.md
CHANGED
|
@@ -249,7 +249,8 @@ tools/jiangnan/ # 旁白生成、字体子集化、实况图
|
|
| 249 |
- **USD → 网页**:浏览器不能直接加载 USD,写了 `tools/jiangnan/usd2glb.py`(usd-core 读 UsdPreviewSurface 材质与网格 → 三角化、烘焙世界变换、Z-up 转 Y-up → pymeshlab 保留贴图坐标的二次误差简化到 1 200–6 000 面 → 贴图缩到 512、金属度 / 粗糙度打包成 glTF 规范 → 写 GLB)。原始资产每件 30–90 MB(27 万三角形、4K 贴图),转换后每件 45–435 KB,18 件共 4.3 MB,放在 `public/jiangnan/models/`。
|
| 250 |
- **接入**(`engine/assets.ts`):GLTFLoader 加载后换成本项目带高度雾的材质;每个摊位随机 3–4 种台面货物 + 1–2 种地面货物,按资产真实尺寸(米)落在桌面网格上,同种模型用 InstancedMesh 一次绘制;原来的程序化「多面体果子 + 圆柱篮子 + 车削陶罐」在模型加载成功后隐藏,加载失败(离线 / 被拦截)时自动保留,画面不会空。加载进度显示为「摆上竹篮、陶罐与瓜菜(SimReady 扫描模型)」。
|
| 251 |
- 版权:Palatial NV Asset Library,CC-BY-4.0,页脚已署名。
|
| 252 |
-
-
|
|
|
|
| 253 |
|
| 254 |
---
|
| 255 |
|
|
|
|
| 249 |
- **USD → 网页**:浏览器不能直接加载 USD,写了 `tools/jiangnan/usd2glb.py`(usd-core 读 UsdPreviewSurface 材质与网格 → 三角化、烘焙世界变换、Z-up 转 Y-up → pymeshlab 保留贴图坐标的二次误差简化到 1 200–6 000 面 → 贴图缩到 512、金属度 / 粗糙度打包成 glTF 规范 → 写 GLB)。原始资产每件 30–90 MB(27 万三角形、4K 贴图),转换后每件 45–435 KB,18 件共 4.3 MB,放在 `public/jiangnan/models/`。
|
| 250 |
- **接入**(`engine/assets.ts`):GLTFLoader 加载后换成本项目带高度雾的材质;每个摊位随机 3–4 种台面货物 + 1–2 种地面货物,按资产真实尺寸(米)落在桌面网格上,同种模型用 InstancedMesh 一次绘制;原来的程序化「多面体果子 + 圆柱篮子 + 车削陶罐」在模型加载成功后隐藏,加载失败(离线 / 被拦截)时自动保留,画面不会空。加载进度显示为「摆上竹篮、陶罐与瓜菜(SimReady 扫描模型)」。
|
| 251 |
- 版权:Palatial NV Asset Library,CC-BY-4.0,页脚已署名。
|
| 252 |
+
- 推送方式:Hugging Face 拒绝通过 git 直接推送二进制文件,18 个 GLB 改由 Hub API 以 LFS 上传(提交 `3d3569d`),代码走 git。
|
| 253 |
+
- 验证(无头 Chromium):17 个模型全部加载成功(`failed: []`),共 212 个实例、约 59 万三角形(实例化后绘制调用只增加 17 次);集市镜头 33.5 s / 36.5 s 与 62 s 渲染正常、无报错;摊位正面特写能看到桌上的陶瓶、碗、杯。按截图调整:真实尺寸的茶杯(10 cm)、馒头(4 cm)在镜头里太小,统一放大 1.2–1.8 倍,桌面网格加密到 7×3、每摊 4–5 种货物、数量上调,并把货物材质的天光强度提到 1.6 以免在房檐阴影里发黑。
|
| 254 |
|
| 255 |
---
|
| 256 |
|
src/jiangnan/engine/assets.ts
CHANGED
|
@@ -21,23 +21,23 @@ export interface AssetDef {
|
|
| 21 |
|
| 22 |
/** Palatial NV Asset Library IDs (https://huggingface.co/datasets/PalatialSim/palatial-nv-asset-library), CC-BY-4.0 */
|
| 23 |
export const ASSETS: AssetDef[] = [
|
| 24 |
-
{ id: 'D00006', name: '竹篮', slot: 'table', count: [1, 2] },
|
| 25 |
-
{ id: 'D00016', name: '提篮', slot: 'table', count: [1, 2] },
|
| 26 |
-
{ id: 'D00323', name: '果篮', slot: 'table', count: [1,
|
| 27 |
-
{ id: 'D00395', name: '蛋篮', slot: 'table', count: [
|
| 28 |
-
{ id: 'D00952', name: '木碗', slot: 'table', count: [
|
| 29 |
-
{ id: 'D00854', name: '茶壶', slot: 'table', count: [
|
| 30 |
-
{ id: 'D00855', name: '茶杯', slot: 'table', count: [
|
| 31 |
-
{ id: 'D00945', name: '铁锅', slot: 'table', count: [
|
| 32 |
-
{ id: 'D00953', name: '木箱', slot: 'ground', count: [1, 2] },
|
| 33 |
-
{ id: 'D00954', name: '木盒', slot: 'table', count: [
|
| 34 |
-
{ id: 'D00902', name: '陶瓶', slot: 'table', count: [1,
|
| 35 |
-
{ id: 'D00645', name: '大白菜', slot: 'table', count: [
|
| 36 |
-
{ id: 'D00638', name: '茄子', slot: 'table', count: [
|
| 37 |
-
{ id: 'D00668', name: '米缸', slot: 'ground', count: [1, 2] },
|
| 38 |
-
{ id: 'D00839', name: '陶罐', slot: 'table', count: [1,
|
| 39 |
-
{ id: 'D00930', name: '面粉袋', slot: 'ground', count: [1,
|
| 40 |
-
{ id: 'D00479', name: '馒头', slot: 'table', count: [
|
| 41 |
]
|
| 42 |
|
| 43 |
export interface AssetsOut {
|
|
@@ -62,6 +62,9 @@ async function loadGlb(loader: GLTFLoader, id: string) {
|
|
| 62 |
color: src.color, roughness: src.roughness, metalness: Math.min(src.metalness, 0.6),
|
| 63 |
}), { key: 'asset-' + id })
|
| 64 |
if (mat.map) mat.map.colorSpace = THREE.SRGBColorSpace
|
|
|
|
|
|
|
|
|
|
| 65 |
geo.computeBoundingBox()
|
| 66 |
return { geo, mat, box: geo.boundingBox! }
|
| 67 |
}
|
|
@@ -103,10 +106,10 @@ export async function createAssets(stalls: StallSpot[], onProgress?: (p: number)
|
|
| 103 |
const ground = ASSETS.filter((a) => a.slot === 'ground' && models.has(a.id))
|
| 104 |
// table top is 2.2 × 1.0 m at y = 0.82 (see props.ts)
|
| 105 |
const cells: [number, number][] = []
|
| 106 |
-
for (let i = -
|
| 107 |
for (let k = cells.length - 1; k > 0; k--) { const r = Math.floor(rng() * (k + 1)); [cells[k], cells[r]] = [cells[r], cells[k]] }
|
| 108 |
// 3–4 kinds per stall, so each stall reads differently
|
| 109 |
-
const kinds = [...table].sort(() => rng() - 0.5).slice(0,
|
| 110 |
let c = 0
|
| 111 |
for (const a of kinds) {
|
| 112 |
const n = a.count[0] + Math.floor(rng() * (a.count[1] - a.count[0] + 1))
|
|
|
|
| 21 |
|
| 22 |
/** Palatial NV Asset Library IDs (https://huggingface.co/datasets/PalatialSim/palatial-nv-asset-library), CC-BY-4.0 */
|
| 23 |
export const ASSETS: AssetDef[] = [
|
| 24 |
+
{ id: 'D00006', name: '竹篮', slot: 'table', count: [1, 2], scale: 1.3 },
|
| 25 |
+
{ id: 'D00016', name: '提篮', slot: 'table', count: [1, 2], scale: 1.3 },
|
| 26 |
+
{ id: 'D00323', name: '果篮', slot: 'table', count: [1, 2], scale: 1.4 },
|
| 27 |
+
{ id: 'D00395', name: '蛋篮', slot: 'table', count: [1, 1], scale: 1.4 },
|
| 28 |
+
{ id: 'D00952', name: '木碗', slot: 'table', count: [2, 4], scale: 1.5 },
|
| 29 |
+
{ id: 'D00854', name: '茶壶', slot: 'table', count: [1, 1], scale: 1.4 },
|
| 30 |
+
{ id: 'D00855', name: '茶杯', slot: 'table', count: [3, 5], scale: 1.5 },
|
| 31 |
+
{ id: 'D00945', name: '铁锅', slot: 'table', count: [1, 1], scale: 1.2 },
|
| 32 |
+
{ id: 'D00953', name: '木箱', slot: 'ground', count: [1, 2], scale: 1.3 },
|
| 33 |
+
{ id: 'D00954', name: '木盒', slot: 'table', count: [1, 1], scale: 1.3 },
|
| 34 |
+
{ id: 'D00902', name: '陶瓶', slot: 'table', count: [1, 3], scale: 1.5 },
|
| 35 |
+
{ id: 'D00645', name: '大白菜', slot: 'table', count: [3, 6], scale: 1.4 },
|
| 36 |
+
{ id: 'D00638', name: '茄子', slot: 'table', count: [4, 7], scale: 1.5 },
|
| 37 |
+
{ id: 'D00668', name: '米缸', slot: 'ground', count: [1, 2], scale: 1.6 },
|
| 38 |
+
{ id: 'D00839', name: '陶罐', slot: 'table', count: [1, 3], scale: 1.6 },
|
| 39 |
+
{ id: 'D00930', name: '面粉袋', slot: 'ground', count: [1, 3], scale: 1.8 },
|
| 40 |
+
{ id: 'D00479', name: '馒头', slot: 'table', count: [6, 10], scale: 1.6 },
|
| 41 |
]
|
| 42 |
|
| 43 |
export interface AssetsOut {
|
|
|
|
| 62 |
color: src.color, roughness: src.roughness, metalness: Math.min(src.metalness, 0.6),
|
| 63 |
}), { key: 'asset-' + id })
|
| 64 |
if (mat.map) mat.map.colorSpace = THREE.SRGBColorSpace
|
| 65 |
+
// the stalls stand in the shade of the house fronts at sunset: lift the sky light a little so
|
| 66 |
+
// the scanned goods read as warm objects rather than silhouettes
|
| 67 |
+
mat.envMapIntensity = 1.6
|
| 68 |
geo.computeBoundingBox()
|
| 69 |
return { geo, mat, box: geo.boundingBox! }
|
| 70 |
}
|
|
|
|
| 106 |
const ground = ASSETS.filter((a) => a.slot === 'ground' && models.has(a.id))
|
| 107 |
// table top is 2.2 × 1.0 m at y = 0.82 (see props.ts)
|
| 108 |
const cells: [number, number][] = []
|
| 109 |
+
for (let i = -3; i <= 3; i++) for (let j = -1; j <= 1; j++) cells.push([i * 0.3, j * 0.3])
|
| 110 |
for (let k = cells.length - 1; k > 0; k--) { const r = Math.floor(rng() * (k + 1)); [cells[k], cells[r]] = [cells[r], cells[k]] }
|
| 111 |
// 3–4 kinds per stall, so each stall reads differently
|
| 112 |
+
const kinds = [...table].sort(() => rng() - 0.5).slice(0, 4 + Math.floor(rng() * 2))
|
| 113 |
let c = 0
|
| 114 |
for (const a of kinds) {
|
| 115 |
const n = a.count[0] + Math.floor(rng() * (a.count[1] - a.count[0] + 1))
|