Skip to content

Commit

Permalink
Refactor LOD further.
Browse files Browse the repository at this point in the history
  • Loading branch information
digisomni committed Oct 1, 2023
1 parent b34ee66 commit e610ffc
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/modules/scene/LODManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
InstancedMesh,
Mesh,
} from "@babylonjs/core";
import _ from "lodash";
import _, { size } from "lodash";
import Log from "../debugging/log";

// TODO: Move these types and consts to a central types file for Vircadia: vircadia/types (repo)
Expand Down Expand Up @@ -184,6 +184,14 @@ export class LODManager {
}
}

private static setLODLevel(root: Mesh, lodMesh: Mesh, value: number): void {
root.addLODLevel(value, lodMesh);
Log.debug(
Log.types.ENTITIES,
`Added LOD value ${value} with mesh ${lodMesh.name} to root ${root.name}.`
);
}

public static setLODLevels(meshes: AbstractMesh[]): AbstractMesh[] {
const roots: {
prefix: string | undefined;
Expand Down Expand Up @@ -313,14 +321,10 @@ export class LODManager {
metadata.vircadia_lod_distance;
}

roots[root].mesh?.addLODLevel(
distanceTarget,
typedMesh
);

Log.debug(
Log.types.ENTITIES,
`Added LOD level ${level} to ${roots[root].mesh.name} with for distance target ${distanceTarget}.`
LODManager.setLODLevel(
roots[root].mesh,
typedMesh,
distanceTarget
);

break;
Expand All @@ -335,14 +339,10 @@ export class LODManager {
sizeTarget = metadata.vircadia_lod_size;
}

roots[root].mesh?.addLODLevel(
sizeTarget,
typedMesh
);

Log.debug(
Log.types.ENTITIES,
`Added LOD level ${level} to ${roots[root].mesh.name} with for size target ${sizeTarget}.`
LODManager.setLODLevel(
roots[root].mesh,
typedMesh,
sizeTarget
);

break;
Expand Down

0 comments on commit e610ffc

Please sign in to comment.