jdurrant Posted April 7, 2017 Share Posted April 7, 2017 Once LOD has been automatically created with the MESH.simplify function, is it possible to change the cutoff distances? I'd like to be able to adjust these distances dynamically based on the frame rate, as an optimization strategy. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted April 7, 2017 Share Posted April 7, 2017 Hello yep you can get the mesh at a specific lod level with : lodMesh = mesh.getLODLevelAtDistance(x) then remove it with mesh.removeLODLevel(lodMesh) and add it where you want it with mesh.addLODLevel(newDistance, lodMesh) Wingnut 1 Quote Link to comment Share on other sites More sharing options...
jdurrant Posted April 8, 2017 Author Share Posted April 8, 2017 Seems to work! The code is pretty trivial, but in case it helps others: function adjustLODDistances(dist1: number, dist2: number, dist3ForNull: number) { for (let i = 0; i < scene.meshes.length; i++) { let m =scene.meshes[i]; if (m.hasLODLevels === true) { // Get the current LOD levels let CurLODDist1 = m._LODLevels[0].distance; let CurLODDist2 = m._LODLevels[1].distance; let CurLODDist3 = m._LODLevels[2].distance; // Get the LOD meshes at those levels. let lodMesh1 = m.getLODLevelAtDistance(CurLODDist1); let lodMesh2 = m.getLODLevelAtDistance(CurLODDist2); let lodMesh3 = m.getLODLevelAtDistance(CurLODDist3); // Remove those levels from the mesh m.removeLODLevel(lodMesh1); m.removeLODLevel(lodMesh2); m.removeLODLevel(lodMesh3); // Add them back in, with new distances m.addLODLevel(dist1, lodMesh1); m.addLODLevel(dist2, lodMesh2); m.addLODLevel(dist3ForNull, lodMesh3); } } } Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.