Namespace: Scene

Scene

The MLJ.core.Scene namespace defines the functions to manage the scene, i.e. the set of mesh layers that constitute the ''document'' of the MeshLabJS system. This namespace also actually stores the set of meshes, the reference to current mesh, the threejs container for the scene, the threejs camera and the threejs renderer (e.g. the webgl context where the scene is rendered).

Author:
  • Stefano Gabriele
Source:

Members

(static) _decorators :MLJ.util.AssociativeArray

Associative array that contains all the scene level "background" decorators (axes, background grid etc..)

Type:
Source:

(static) _group :THREE.Object

The ThreeJs group that contains all the layers. It also store the global transformation (scale + translation) that brings the global bbox of the scene in the origin of the camera reference system.

Type:
  • THREE.Object
Source:

(static) _layers :MLJ.util.AssociativeArray

Associative Array that contains all the meshes in the scene

Type:
Source:

(static) _postProcessPasses :MLJ.util.AssociativeArray

Associative array that contains all the currently active post process rendering passes. For details see MLJ.core.Scene.addPostProcessPass.

Type:
Source:

(static) _scene :THREE.Scene

It contains the ThreeJs Representation of the current set of layers. Each Layer is associated to a ThreeJS mesh whose contained in the MLJ.core.MeshFile object.

Type:
  • THREE.Scene
Source:

(static) _scene2D

This scene contains 2D overlays that are drawn on top of everything else

Source:

(static) _selectedLayer :MLJ.core.Layer

Reference to current layer

Type:
Source:

Methods

(static) this.addLayer(layer)

Adds a new layer in the scene

Parameters:
Name Type Description
layer MLJ.core.Layer

The mesh file to add

Author:
  • Stefano Gabriele
Source:

(static) this.addPostProcessPass(name, pass)

Adds a post process pass to the rendering chain. As of now the interface to post process effects is minimal: an effect is simply a callable object that must accept two render buffers as parameters. The first buffer contains the color generated by the rendering chain of MeshLabJS up to the effect invocation, (this includes the basic scene rendering plus the result of any post process effect that was applied before the current one). The second buffer must be used as the render target of the pass, will be forwarded as input to the next effect, or will be transfered to the canvas if no other effects are active. Both buffers have the same size as the page canvas. Any other information that may be needed by an effect must be passed with closure variables or queried directly to MLJ.core.Scene.

Parameters:
Name Type Description
name String

The name of the pass

pass Object

The callable (function) object that will apply the pass

Source:

(static) this.addSceneDecorator(name, decorator)

Adds a scene decorator. A scene decorator differs fron an overlay layer in that it's not tied to a particular layer, but to the scene as a whole (for example an axes descriptor that highlights the direction of the x, y, and z coordinates).

Parameters:
Name Type Description
name String

The name of the decorator

decorator THREE.Object3D

The decorator object

Source:

(static) this.getLayerByName(name) → {MLJ.core.Layer}

Returns the layer corresponding to the given name

Parameters:
Name Type Description
name String

The name of the layer

Author:
  • Stefano Gabriele
Source:
Returns:

The layer corresponding to the given name

Type
MLJ.core.Layer

(static) this.getLayers() → {MLJ.util.AssociativeArray}

Returns the layers list

Author:
  • Stefano Gabriele
Source:
Returns:

The layers list

Type
MLJ.util.AssociativeArray

(static) this.getSelectedLayer() → {MLJ.core.Layer}

Returns the currently selected layer

Author:
  • Stefano Gabriele
Source:
Returns:

The currently selected layer

Type
MLJ.core.Layer

(static) this.removeLayerByName(name)

Removes the layer corresponding to the given name

Parameters:
Name Type Description
name String

The name of the layer which must be removed

Author:
  • Stefano Gabriele
Source:

(static) this.removePostProcessPass(name)

Removes a post process effect from the rendering chain.

Parameters:
Name Type Description
name String

The name of the pass to remove

Source:

(static) this.removeSceneDecorator(name)

Removes a decorator object from the scene.

Parameters:
Name Type Description
name String

The name of the decorator to remove

Source:

(static) this.render()

Renders the scene. If there are no post process effects enabled, the THREE.js scene that contains all the scene decorators and the overlay layers is rendered straight to the canvas. Otherwise, the basic scene is rendered to an off screen render target, and post process effects are applied one after the other (according to the user's activation order) before displaying the result.

Source:

(static) this.selectLayerByName(layerName)

Selects the layer with the name layerName

Parameters:
Name Type Description
layerName String

The name of the layer

Author:
  • Stefano Gabriele
Source:

(static) this.setLayerVisible(layerName, visible)

Sets the visibility of layer with the name layerName

Parameters:
Name Type Description
layerName String

The name of the layer

visible Boolean

true if the layers must be visible, false otherwise

Author:
  • Stefano Gabriele
Source:

(static) this.updateLayer(layer)

Updates a layer. This function should be called if the layer geometry or properties was modified.

Parameters:
Name Type Description
layer MLJ.core.Layer

The mesh file corresponding to the level

Author:
  • Stefano Gabriele
Source:
Example
//Apply Laplacian smooth filter
Module.LaplacianSmooth(layer.ptrMesh, 1, false);
//The filter has changed mesh geometry ...
scene.updateLayer(layer);

Events

SceneLayerAdded

Triggered when a layer is added

Type:
  • Object
Properties:
Name Type Description
layer MLJ.core.Layer

The last mesh file added

layersNumber Integer

The number of layers in the scene

Source:
Example

Event Interception:

 $(document).on("SceneLayerAdded",
     function (event, layer, layersNumber) {
         //do something
     }
 );

SceneLayerReloaded

Triggered when a layer is reloaded

Type:
  • Object
Properties:
Name Type Description
layer MLJ.core.Layer

The reloaded mesh file

Source:
Example

Event Interception:

 $(document).on("SceneLayerReloaded",
     function (event, layer) {
         //do something
     }
 );

SceneLayerSelected

Triggered when a layer is selected

Type:
  • Object
Properties:
Name Type Description
layer MLJ.core.Layer

The selected mesh file

Source:
Example

Event Interception:

 $(document).on("SceneLayerSelected",
     function (event, layer) {
         //do something
     }
 );

SceneLayerUpdated

Triggered when a layer is updated

Type:
  • Object
Properties:
Name Type Description
layer MLJ.core.Layer

The updated mesh file

Source:
Example

Event Interception:

 $(document).on("SceneLayerUpdated",
     function (event, layer) {
         //do something
     }
 );