Namespace vxl.api

Application Programing Interface namespace. Using vxl.api in your programs you will be able to access many of the features offered by Voxelent's Nucleo library. By design, type checking is enforced throughout the functions provided by the public API. The goal is to help novice programmers that will use the API more often than advanced programmers.

Namespace

vxl.api

Methods

<static> axisOFF()
Hides the axis in the current view
<static> axisON()
Activates the axis in the current viewThe axis is always centered in the focal point of the camera
<static> boundingBoxOFF()
Shows the global bounding box of the current scene
<static> boundingBoxON()
Shows the global bounding box of the current scene
<static> clearAnimation()
Removes the current animation from the scene
<static> vxlActorGroup createActorGroup(name, list)
Creates an actor group for the current scene

Parameters:

Type Name Description
String name

name of the actor group

List list

list of actors to add to the actor group

Returns:

{vxlActorGroup} the actor group

See:

vxlScene#createActorGroup
<static> flipActorNormals()
Flip the normals of the current actor or the whole scene if the current actor is undefined
<static> floorOFF()
Hides the floor in the current scene
<static> floorON(dimension, spacing)
Shows the scene's floor. If the dimension and spacing have not been set, then the floor wiill not be visible'

Parameters:

Type Name Description
dimension

spacing

<static> getActor(actorNameOrUID, scene)
Retrieves an actor by name or UID

Parameters:

Type Name Description
String actorNameOrUID

actor name or UID

vxlScene scene

looks in the specified scene. This parameter is optional. If not specified, the current scene (vxl.c.scene) will be queried

<static> getActorByName(actorName, scene)
Retrieves an actor object by name

Parameters:

Type Name Description
String actorName

the name of the actor

vxlScene scene

looks in the specified scene. This parameter is optional. If not specified, the current scene (vxl.c.scene) will be queried

<static> getActorByUID(actorUID, scene)
Retrieves an actor object by UID

Parameters:

Type Name Description
String actorUID

the UID of the actor

vxlScene scene

looks in the specified scene. This parameter is optional. If not specified, the current scene (vxl.c.scene) will be queried

<static> getActorNames(scene)
Returns a list of actor names.

Parameters:

Type Name Description
vxlScene scene

the scene. This parameter is optional

<static> Array getActorsThat(condition, scene)

Returns a list of actors based on the condition passed as parameter.

The condition is a function with the following signature:

condition(vxlActor): returns boolean

If the condition evaluates true then that actor is included in the results

Parameters:

Type Name Description
function condition

the condition to evaluate in the actor list

vxlScene scene

(Optional) If this parameter is not set, the current scene will be used

Returns:

{Array} list of actors
<static> getAllActors()
Returns a new actor group (vxlActorGroup) with all the actors in the current scene

See:

vxlActorGroup
<static> getCurrentActor()
<static> getCurrentCamera()
<static> vxlView getCurrentView()
Returns the current view. This is the view that is receiving all the API calls

Returns:

{vxlView} the current view
<static> getLookupTables()
<static> getProgram(view)
Returns the name of the current program

Parameters:

Type Name Description
vxlView view

the view that we want to query. If this parameter is not passed,the current view will be used (vxl.c.view)

<static> getUniform(uniformID)

Parameters:

Type Name Description
uniformID

<static> getUniformDefault(programID, uniformID)
Gets the default value for an uniform

Parameters:

Type Name Description
programID

uniformID

<static> getUniformList()
Return the uniform names of the current program
<static> load(arguments, path, mode, scene)
Loads 3D models, textures and other models to a Voxelent's scene.This method is very flexible. It can load one or multiple models depending on the type of the first parameter. If it is a String, it will try to find the file with that name in Voxelent's data folder(voxdata by default). Otherwise, if the parameter 'arguments' is an Array, load will iteratethrough it and will try to load every element of this list. Every element being the file name.Nucleo supports three different loading modes which are defined in vxl.def.model.loadingMode:LIVE: As each asset is loaded it is added immediately into the scene by creating the corresponding actorLATER: All the models are loaded first THEN the actors are created. This is useful when you want to display a full scene instead of showing incremental updates.DETACHED: The models are loaded into the vxlModelManager object but actors are never created.This allows background loading.

Parameters:

Type Name Description
String|Array arguments

the name of the asset or the list of models (each element being the file name).

String path

the path that will be concatenated to the list of files (optional).

vxl.def.model.loadingMode mode

the loading mode

vxlScene scene

the scene in case we do not want to load these models in the current one

See:

<static> loadLUTS()

Parameters:

Type Name Description
String folder.

This parameter is required. It specifies the location from wherethe lookup tables will be loaded. If this parameter is not passed the current folder willbe used. The current folder is determined on running time and it is the folder where voxelent is located.

<static> loadSequence(prefix, start, end, path, mode, scene)
Loads a sequence

Parameters:

Type Name Description
String prefix

the shared name by all the files. For instance part in part1, part2, ...

Number start

start number in the sequence

Number end

end number in the sequence

String path

relative path to the webpage where the files are located

String mode

a loading mode (See load method)

String scene

the scene where the generated actors should be placed

<static> pointsON()
Changes the visualization mode of the current actor (or all the actors if there's no current actor')to a point representation

See:

vxl.def.actor.mode
<static> releaseProgram(view)
Releases the program used by the view passed as parameter

Parameters:

Type Name Description
view

<static> resetCamera()
Resets the current camera
<static> resetScene()
Go back to square one. A clean scene with no actors
<static> retrieveCamera()
Retrieves the last saved camera state
<static> saveCamera()
Saves the current camera state
<static> setActorOpacity(op)

Parameters:

Type Name Description
Number op

opacity value between 0 and 1 (float)

<static> setActorProperty(actor, property, value)
Sets a property for one of the actors in the current scene.This metod requires a current scene

Parameters:

Type Name Description
vxlActor|String actor

it can be a vxlActor or a String with the actor name

String property

the property to change

Object value

the new value

<static> setAzimuth(a)
Sets the azimuth of the camera

Parameters:

Type Name Description
Number a

azimuth

<static> setBackgroundColor(r, g, b)
Sets the background color of the current view.

Parameters:

Type Name Description
Number|Array|vec3 r

it can be the red component, a 3-dimensional Array or a vec3 (glMatrix)

Number g

if r is a number, then this parameter corresponds to the green component

Number b

if r is a number, then this parameter corresponds to the blue component

<static> setCurrentActor(actor)
Sets the current actor

Parameters:

Type Name Description
vxlActor|String actor

This could be an actor object or an actor nameIf the actor name is passed to this method, there must be a current scene. Otherwise an exception will raise.

<static> setCurrentCamera(a)

Parameters:

Type Name Description
a

<static> setCurrentView(the)
If the object passed as a parameter is a vxlView then it sets it up as the current view.All subsequent calls to API functions that reference the current view will be redirectedto affect the newly set object.

Parameters:

Type Name Description
a the

vxlView object that we want to make the current one

<static> setElevation(e)
Sets the elevation of the camera

Parameters:

Type Name Description
Number e

elevation

<static> setFieldOfView(fov)
Changes the field of view of the current camera

Parameters:

Type Name Description
fov

<static> setFrame(f)
If there is a vxlFrameAnimation object attached to the scene then it sets the current animation frame

Parameters:

Type Name Description
Number f

the animation frame index

<static> setLookupTable(name)

Parameters:

Type Name Description
name

<static> setProgram(view, program)
Forces the renderer to use a specific program

Parameters:

Type Name Description
view

program

<static> setPropertyFor(list, property, value, scene)
Sets a property for all the actors in the list

Parameters:

Type Name Description
Array list

list of actors (String or vxlActor)

String property

the property to change

Object value

the new value

vxlScene scene

the scene (optional). If this parameter is not passed the current scene is used

<static> setPropertyForAll(property, value, scene)
Sets a property for all the actors

Parameters:

Type Name Description
String property

the property to change

Object value

the new value

vxlScene scene

the scene (optional). If this parameter is not passed the current scene is used

<static> setRenderMode(mode, view)
Sets the render mode for the current view or the view passed as secondparameter

Parameters:

Type Name Description
String mode

one of the modes defined in vxl.def.renderer.mode

vxlView view

the view (Optional) If this is not set up then the current view is used

<static> setRenderRate(r)
Sets the rendering rate of the current view

Parameters:

Type Name Description
Number r

the new rendering rate given as a number in milliseconds

See:

api#setCurrentView
<static> setUniform(uniformID, value)

Parameters:

Type Name Description
uniformID

value

<static> setUniformDefault(programID, uniformID, value)
Sets the default value for an uniform

Parameters:

Type Name Description
programID

uniformID

value

<static> vxlView setup(canvas_id, scene, handleLayout)
Creates and returns a vxlView object

Parameters:

Type Name Description
String canvas_id

The canvas' Document Object Model (DOM) id.

vxlScene scene

optional, the scene associated to this view

Boolean handleLayout

if true or absent, the canvas will be resized dynamically

Returns:

{vxlView} a new vxlView object
<static> solidWireframeON()
Changes the visualization mode of the current actor (or all the actors if there's no current actor')to a solid representation

See:

vxl.def.actor.mode
<static> startAnimation()
If there is an animation object (vxl.c.animation) then it starts the animation
<static> stopAnimation()
If there is an animation object (vxl.c.animation) thenit stops the animation
<static> subscribe(list, context)

Suscribes the to Voxelent events

The context parameter corresponds to the class that is going to listen for Voxelent events.

Such class needs to implement a method to handle the events that it has subscribed to. This method/function needsto have the following signature:

handleEvent(event, src)

The event parameter corresponds to the event that has been fired by Voxelent. Notice that your class will only be notified of those events that it has been subscribed to.

Parameters:

Type Name Description
String|Array list

the event or events that we are going to subscribe to

Object context

the object that needs to implement the handleEvent method

<static> surfaceON()
Changes the visualization mode of the current actor (or all the actors if there's no current actor')to a solid representation

See:

vxl.def.actor.mode
<static> wireframeON()
If an actor has been selected (If there is an current actor in vxl.c.actor), changes its visualization mode to WIREFRAME. Otherwise,shows all the scene in WIREFRAME mode.

See:

vxl.def.actor.mode