Skip to content

lod generator standalone#32382

Closed
FlankaLanka wants to merge 2 commits intomrdoob:devfrom
FlankaLanka:lod-gen
Closed

lod generator standalone#32382
FlankaLanka wants to merge 2 commits intomrdoob:devfrom
FlankaLanka:lod-gen

Conversation

@FlankaLanka
Copy link
Copy Markdown

@FlankaLanka FlankaLanka commented Nov 26, 2025

Description

A LOD generator tool. Upload a mesh and create different LOD meshes with QEM algorithm.

Screenshot 2025-11-27 at 04 58 13

https://raw.githack.com/FlankaLanka/three.js/lod-gen/tools/lod-generator/index.html

</div>
</div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>

Check warning

Code scanning / CodeQL

Inclusion of functionality from an untrusted source Medium

Script loaded from content delivery network with no integrity check.
import { FBXLoader } from 'three/addons/loaders/FBXLoader.js';
import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';

import { LODGenerator, LODDistanceCalculator } from './LODGenerator.js';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import LODDistanceCalculator.
@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented Nov 27, 2025

Screenshot 2025-11-27 at 04 59 53

Is QEM the best algorithm? 🤔

@mrdoob mrdoob added this to the r183 milestone Nov 27, 2025
@gkjohnson
Copy link
Copy Markdown
Collaborator

I'll just point out that gltf-transform also has a reasonable mesh decimation algorithm (there are a number of easy-to-use tools available for this) so I question whether it's valuable to rewrite it let alone maintain a tool for it in this repo.

@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented Nov 27, 2025

I'm mostly curious about the algorithm.

If the output could get better we could easily integrate this in the Three.js Editor instead.

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Nov 27, 2025

To clarify, QEM is the approach from Garland and Heckbert [1998] and well know for its conceptual issues like it does not properly preserve uv coordinates such that textures are correctly projected on the simplified meshes.

A very promising approach known from #14058 is this one: https://cragl.cs.gmu.edu/seamless/

In the link you find the related paper, the presentation from SIGGRAPH Asia 2017 and also a GitHub repository with a C++ implementation: https://github.com/songrun/SeamAwareDecimater?tab=readme-ov-file#seam-aware-decimater

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Nov 27, 2025

BTW: Before adding a new component, a PR should improve the existing SimplifyModifier.

https://threejs.org/examples/webgl_modifier_simplifier

@donmccurdy
Copy link
Copy Markdown
Collaborator

donmccurdy commented Dec 4, 2025

I'll just add that the implementation in glTF Transform uses meshoptimizer's 15kb WASM geometry simplifier. The older version of meshoptimizer used in glTF Transform preserves UVs but doesn't optimize for them; the newer version preserves UVs and gives UV error weight during simplification. See donmccurdy/glTF-Transform#1714.

I'd also done a standalone simplification example using meshoptimizer directly in three.js here:

https://discourse.threejs.org/t/mesh-simplification-using-meshoptimizer/63002/4

A nice feature of this approach — specifically for LODs — is that LODs don't need separate vertex attributes, only different indices. Applications could switch between LODs within a geometry using geometry.groups.

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Jan 15, 2026

Closing since the PR in the current state can't be merged.

I'd also done a standalone simplification example using meshoptimizer directly in three.js here:

@donmccurdy I've just tested the approach from your fiddle with our simplifier example and I'm impressed by the result:

https://jsfiddle.net/bpyhv6zj/

Couldn't we ditch the existing implementation of SimplifyModifier and internally use MeshoptSimplifier instead? The code from the fiddle's simplify() function is something we could hide in SimplifyModifier to ease the usage.

@Mugen87 Mugen87 closed this Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants