From d3b4a55e71a774a4c0ce2741cb9259f9f8f09327 Mon Sep 17 00:00:00 2001 From: Tom Boullay Date: Sun, 31 May 2026 22:14:13 +0200 Subject: [PATCH] fix(model): load lafabrik glb --- docs/technical/map-lod.md | 4 ++-- docs/technical/map-performance.md | 16 ++++++++-------- src/components/three/world/LaFabrikMapModel.tsx | 2 +- src/data/galleryModels.ts | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/technical/map-lod.md b/docs/technical/map-lod.md index fda0f5d..952a09c 100644 --- a/docs/technical/map-lod.md +++ b/docs/technical/map-lod.md @@ -84,11 +84,11 @@ This matters for `lafabrik`: adding `public/models/lafabrik-LOD/` is not enough To add LOD support for a model: 1. Add the light model in `public/models/-LOD/model.gltf`. -2. Keep the regular model in `public/models//model.gltf`. +2. Keep the regular model in `public/models//model.glb` or `public/models//model.gltf`. 3. Add the mapping in `src/data/world/mapLodConfig.ts`. 4. If the model uses a dedicated component, call `useMapLodModelPath()` in that component. 5. Preload both paths when the component is dedicated and uses `useGLTF.preload()`. -6. Verify the GLTF references: buffers, textures, opacity maps, and relative paths. +6. Verify the GLTF/GLB references: buffers, textures, opacity maps, and relative paths. ## Current LOD Models diff --git a/docs/technical/map-performance.md b/docs/technical/map-performance.md index 57d560d..853b890 100644 --- a/docs/technical/map-performance.md +++ b/docs/technical/map-performance.md @@ -14,12 +14,12 @@ This document tracks the current map-rendering performance pass. The first performance bottleneck was draw calls. Some assets were exported as many small GLTF primitives even when they used only a few materials. -| Model | Instances | Meshes / primitives | Notes | -| ---------------- | --------: | ------------------: | ---------------------------------------------------------------- | -| `generateur` | 3 | 3152 | Worst draw-call offender. Needs asset-side mesh merging. | -| `lafabrik` | 4 | 56 | Moderate draw calls, heavy 2048 texture set. | -| `ecole` | 1 | 107 | One material but many primitives; should be merged. | -| `fermeverticale` | 3 | 1 | Geometry is fine; textures are large for the visible complexity. | +| Model | Instances | Meshes / primitives | Notes | +| ---------------- | --------: | ------------------: | ------------------------------------------------------------------------------------ | +| `generateur` | 3 | 3152 | Worst draw-call offender. Needs asset-side mesh merging. | +| `lafabrik` | 4 | 474 | High primitive count; current HD GLB has embedded geometry and no external textures. | +| `ecole` | 1 | 107 | One material but many primitives; should be merged. | +| `fermeverticale` | 3 | 1 | Geometry is fine; textures are large for the visible complexity. | `generateur` was especially expensive because three visible instances could multiply thousands of primitives into thousands of draw calls. Instancing reduces repeated instance cost, but the source asset still needs a cleaner export. @@ -34,7 +34,7 @@ Estimated source primitive count versus runtime merged groups: | `generateur` | 3152 | 8 | | `ecole` | 107 | 2 | | `eolienne` | 118 | 8 | -| `lafabrik` | 56 | 14 | +| `lafabrik` | 474 | ~77 | This is a code-side safety net, not a replacement for clean asset exports. Clean GLB exports with merged meshes and fewer textures remain the preferred long-term path. @@ -255,7 +255,7 @@ Design/export should prioritize: 1. Produce lower-poly `buisson`, `arbre`, `sapin`, and crop assets. 2. Add LOD or billboard variants for far vegetation. 3. Merge `generateur` meshes from 3152 primitives to a small number of material groups. -4. Reduce `lafabrik` texture count and downscale flat/low-detail maps. +4. Keep `lafabrik` exports texture-light, and merge repeated material primitives where possible. 5. Merge `ecole` primitives because it uses a single material. 6. Prefer runtime `.glb` or compressed runtime textures when the pipeline supports it. diff --git a/src/components/three/world/LaFabrikMapModel.tsx b/src/components/three/world/LaFabrikMapModel.tsx index f6a9eae..d8cb6ce 100644 --- a/src/components/three/world/LaFabrikMapModel.tsx +++ b/src/components/three/world/LaFabrikMapModel.tsx @@ -6,7 +6,7 @@ import { import { getMapLodModelPath } from "@/data/world/mapLodConfig"; import { useMapLodModelPath } from "@/hooks/world/useMapLodModelPath"; -const LA_FABRIK_MODEL_PATH = "/models/lafabrik/model.gltf"; +const LA_FABRIK_MODEL_PATH = "/models/lafabrik/model.glb"; const LA_FABRIK_LOD_MODEL_PATH = getMapLodModelPath("lafabrik"); type LaFabrikMapModelProps = Omit; diff --git a/src/data/galleryModels.ts b/src/data/galleryModels.ts index 925160f..8ac0c36 100644 --- a/src/data/galleryModels.ts +++ b/src/data/galleryModels.ts @@ -101,7 +101,7 @@ export const galleryModels: GalleryModel[] = [ path: "/models/habitant2-animated/model.gltf", }, { id: "immeuble1", name: "Immeuble", path: "/models/immeuble1/model.gltf" }, - { id: "lafabrik", name: "La Fabrik", path: "/models/lafabrik/model.gltf" }, + { id: "lafabrik", name: "La Fabrik", path: "/models/lafabrik/model.glb" }, { id: "maison1", name: "Maison", path: "/models/maison1/model.gltf" }, { id: "packderelance",