Object3D

LOD

Level of Detail - show meshes with more or less geometry based on distance from the camera.

Every level is associated with an object, and rendering can be switched between them at the distances specified. Typically you would create, say, three meshes, one for far away (low detail), one for mid range (medium detail) and one for close up (high detail).

Example

webgl / lod

var lod = new v3d.LOD(); //Create spheres with 3 levels of detail and create new LOD levels for them for(var i = 0; i < 3; i++) { var geometry = new v3d.IcosahedronBufferGeometry(10, 3 - i) var mesh = new v3d.Mesh(geometry, material); lod.addLevel(mesh, i * 75); } scene.add(lod);

Note that for the LOD to switch between the different detail levels, you will have to call update(camera) in your render loop. See the source code for this example for details: WebGL / LOD

Constructor

LOD()

Creates a new LOD.

Properties

See the base Object3D class for common properties.

.levels : array

An array of level objects

Each level is an object with two properties:
object - The Object3D to display at this level.
distance - The distance at which to display this level of detail.

Methods

See the base Object3D class for common methods.

.addLevel (object : Object3D, distance : Float) : null

object - The Object3D to display at this level.
distance - The distance at which to display this level of detail.

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.

.clone () : LOD

Returns a clone of this LOD object and its associated distance specific objects.

.getObjectForDistance (distance : Float) : Object3D

Get a reference to the first Object3D (mesh) that is greater than distance.

.raycast (raycaster : Raycaster, intersects : Array) : Array

Get intersections between a casted Ray and this LOD. Raycaster.intersectObject will call this method.

.toJSON (meta) : null

Create a JSON structure with details of this LOD object.

.update (camera : Camera) : null

Set the visibility of each level's object based on distance from the camera. This needs to be called in the render loop for levels of detail to be updated dynamically.

Source

For more info on how to obtain the source code of this module see this page.