diff --git a/docs/api/en/objects/LOD.html b/docs/api/en/objects/LOD.html index 314420e229fe16..49aec0cf64560a 100644 --- a/docs/api/en/objects/LOD.html +++ b/docs/api/en/objects/LOD.html @@ -85,6 +85,15 @@

Adds a mesh that will display at a certain distance and greater. Typically the further away the distance, the lower the detail on the mesh.

+

+ [method:Boolean removeLevel]( [param:Float distance]) +

+

+ distance - Distance of the level to delete.

+ + Removes an existing level, based on the distance from the camera. + Returns `true` when the level has been removed. Otherwise `false`. +

[method:Integer getCurrentLevel]()

Get the currently active LOD level. As index of the levels array.

diff --git a/src/objects/LOD.js b/src/objects/LOD.js index 08fbc102222284..57bdaa7cc4acba 100644 --- a/src/objects/LOD.js +++ b/src/objects/LOD.js @@ -74,6 +74,27 @@ class LOD extends Object3D { } + removeLevel( distance ) { + + const levels = this.levels; + + for ( let i = 0; i < levels.length; i ++ ) { + + if ( levels[ i ].distance === distance ) { + + const removedElements = levels.splice( i, 1 ); + this.remove( removedElements[ 0 ].object ); + + return true; + + } + + } + + return false; + + } + getCurrentLevel() { return this._currentLevel;