Is LOD Blending Possible?

Maybe mesh.onLODLevelSelection (it’s an observer).

mesh.onLODLevelSelection.add((distanceToCamera, mesh, levelMesh) => {
    // distanceToCamera: distance between camera and mesh bounding sphere center
    // mesh: the mesh
    // levelMesh: the mesh used for the LOD level selected
});

It misses the index of the LOD, which might be useful…

Maybe @Deltakosh would accept to pass the index as a 4th parameter (?).

But it’s easy to work around this, just store the lod index directly in the lod meshes themselves.

For eg, if you have 3 load meshes mlod1, mlod2, mlod3, you can store the index as mlod1._lodidx = 1, mlod2._lodidx = 2 and mlod3._lodidx = 3.

Then:

mesh.onLODLevelSelection.add((distanceToCamera, mesh, levelMesh) => {
    let lodIdx = levelMesh._lodidx;
});

Set mesh._lodidx = 0 if you don’t want an undefined value in lodIdx when levelMesh === mesh;

1 Like