Skip to content

Commit

Permalink
Merge pull request #13234 from Dok11/test-babylon-mesh-lod-2
Browse files Browse the repository at this point in the history
Test babylon mesh lod 2

Former-commit-id: 594b70b558abb1abbbe5030619675e62003c98a2
  • Loading branch information
sebavan authored Nov 14, 2022
2 parents 40de1ff + e8ad45d commit f761618
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 75 deletions.
15 changes: 3 additions & 12 deletions packages/dev/core/src/Meshes/mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
* @param mesh defines the mesh to be removed
* @returns This mesh (for chaining)
*/
public removeLODLevel(mesh: Mesh): Mesh {
public removeLODLevel(mesh: Nullable<Mesh>): Mesh {
const internalDataInfo = this._internalMeshDataInfo;
for (let index = 0; index < internalDataInfo._LODLevels.length; index++) {
if (internalDataInfo._LODLevels[index].mesh === mesh) {
Expand Down Expand Up @@ -923,22 +923,13 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
return this;
}

let bSphere: BoundingSphere;

if (boundingSphere) {
bSphere = boundingSphere;
} else {
const boundingInfo = this.getBoundingInfo();

bSphere = boundingInfo.boundingSphere;
}
const bSphere = boundingSphere || this.getBoundingInfo().boundingSphere;

const distanceToCamera = camera.mode === Camera.ORTHOGRAPHIC_CAMERA ? camera.minZ : bSphere.centerWorld.subtract(camera.globalPosition).length();
const useScreenCoverage = internalDataInfo._useLODScreenCoverage;
let compareValue = distanceToCamera;
let compareSign = 1;

if (useScreenCoverage) {
if (internalDataInfo._useLODScreenCoverage) {
const screenArea = camera.screenArea;
let meshArea = (bSphere.radiusWorld * camera.minZ) / distanceToCamera;
meshArea = meshArea * meshArea * Math.PI;
Expand Down
Loading

0 comments on commit f761618

Please sign in to comment.