Global

Members

(constant) action :Object.<String:Number>

The four actions for the Soldier model.
Type:
  • Object.<String:Number>
Source:

(constant) actionRobot :Object.<String:Number>

The fourteen actions for the RobotExpressive model.
Type:
  • Object.<String:Number>
Source:

aspect :Number

Canvas aspect ratio.
Type:
  • Number
Source:

(constant) cameraPos :Object.<String, THREE.Vector3>

Camera position for the three axes.

Type:
Source:

(constant) colorTable :Object.<String:hexadecimal>

Color names mapping.
Type:
  • Object.<String:hexadecimal>
Source:

ctrlType :Number

Type:
  • Number
Source:

(constant) ctype :number

Enum for types of controls.
Type:
  • number
Source:

(constant) environment :Object.<String, THREE.DataTexture>

Maps a model to its environment.
Type:
Source:

(constant) fnames :Object.<String, String>

Maps models to their environments given in the form of either HDR or EXR images.
Type:
  • Object.<String, String>
Source:

line :THREE.LineSegments

The edges of the mesh of the current loaded object.

Type:
  • THREE.LineSegments
Source:

loadedModelName :String

Loaded model name.
Type:
  • String
Source:

material :THREE.Material

Current material for STL or VTK files.

Type:
Source:

mesh :THREE.Mesh

The mesh of the current loaded object for the formats vtk/stl.

Every time a new object is loaded the previous one is disposed of.
Type:
  • THREE.Mesh
Source:

(constant) mobile :Boolean

ArcballControls zoom and pan do not work on mobile devices.
Type:
  • Boolean
Source:

modelCnt :Number

Selected model number.
Type:
  • Number
Source:

modelGeometry :THREE.Object3D

Animated model geometry.
Type:
Source:

modelj :Object

Maps model names to URLs, which were read from a json file.
Type:
  • Object
Source:

(constant) models :Array.<String>

Array holding model file names to create models from.
Type:
  • Array.<String>
Source:

object :THREE.Object3D

The geometry of the current loaded object for the formats obj/gltf.

Every time a new object is loaded the previous one is disposed of.
Type:
Source:

(constant) orthoView :Boolean

Define an orthographic view type.

The interpolate property is used to interpolate from the current orientation to the front, top, and side views.
Type:
  • Boolean
Source:

Methods

(async) anonymous()

Self-invoking anonymous function.

  • Appends the models read from the json file to the <select> element.
  • Sorts the list of models from the <select> element.
  • Displays the default model.
  • Resizes the window to occupy the maximum area of the device's viewport.
Source:

createBoxHelper(object)

Create a box and axes helpers for the object.
Parameters:
Name Type Description
object THREE.Object3D a three.js object.
Source:

createEvent(key, ctrl)

Returns a new keyboard event that can be passed to handleKeyPress.
Parameters:
Name Type Default Description
key String char code.
ctrl Boolean false control key.
Source:
Fires:

damp(position, target, lambda, dt) → {THREE.Vector3}

Exponential Decay: THREE.MathUtils.lerp(position, target, 1 - Math.exp(-lambda * dt))

Linearly interpolate between the given position and a target, where delta is the percent distance along the line:

dt = 0 will be position and
dt = 1 will be target.

Parameters:
Name Type Description
position THREE.Vector3 current point.
target THREE.Vector3 target point.
lambda Number a higher lambda value will make the movement more sudden,
and a lower value will make the movement more gradual.
dt DOMHighResTimeStamp delta time in seconds.
Source:
See:
Returns:
the new position.
Type
THREE.Vector3

delMaterial(mat)

Dispose material and its texture.

TO BE FINISHED.
Parameters:
Name Type Description
mat THREE.Material material.
Source:
See:

getModels(optionNames)

Populate the given array with model file names from an html <select> element identified by "models" and appends to it the extra models from modelj.
Parameters:
Name Type Description
optionNames Array.<String> array of model file names.
Source:

handleKeyPress() → {key_event}

Closure for keydown events.

Source:
Returns:
callback for handling a keyboard event.
Type
key_event

init(dfile)

Loads the viewer and starts the animation.
Parameters:
Name Type Description
dfile String initial model name.
Source:

isEqual(v1, v2, epsilon) → {Boolean}

Vector3 comparison must be based on distance: if the distance between two Vector3 is less than some predefined value, they are considered equal.

Parameters:
Name Type Description
v1 THREE.Vector3 first vector.
v2 THREE.Vector3 second vector.
epsilon Number tolerance.
Source:
Returns:
true if the distance between the two vectors is less than epsilon: Math.abs(v2.distanceTo(v1)) < epsilon
Type
Boolean

loadModel(geometry)

Callback to load a model from a file to the scene.

The previous model loaded is disposed of; that is, we try to release its geometry and material objects since they are no longer used. Render Targets allocate some resources needed by the shaders and should also be released.

Parameters:
Name Type Description
geometry THREE.BufferGeometry model.
Source:

(async) loadModelj() → {Object}

Read the json file with the URLs for loading models.
Source:
See:
Returns:
object for mapping model names to URLs.
Type
Object

loadTextures(dfile)

Load textures (before any model), then call init.

To be sure everything has been loaded, one can either use a series of nested load calls or, as I do, simply use loadAsync to avoid the so-called callback hell.
Parameters:
Name Type Description
dfile String initial model name.
Source:
See:

(async) loadTexturesAsync(dfile)

An Async alternative to loadTextures.
Parameters:
Name Type Description
dfile String initial model name.
Source:
See:

runAnimation()

Animation loop.

Updates controls, renders the scene and updates statistics.
Source:

setAnimationLoop(loop)

A built in function that can be used instead of requestAnimationFrame.

The renderer.setAnimationLoop parameter is a callback, which will be called every available frame.
If null is passed, it will stop any already ongoing animation.
Parameters:
Name Type Description
loop function callback.
Source:

setModels(optionNames)

Set model file names of an html <select> element identified by "models".
Parameters:
Name Type Description
optionNames Array.<String> array of model file names.
Source:

Type Definitions

handleWindowResize()

Fires when the document view (window) has been resized.

Also resizes the canvas and viewport.
Source:
See:

key_event(event)

Handler for keydown events.

Selects the next/previous model or turns stats and mesh visible/invisible when pressing keys ("n","N") or ("s","m"), respectively.
Parameters:
Name Type Description
event KeyboardEvent keyboard event.
Source:

Events

clickFront

Appends an event listener for events whose type attribute value is click.

Fires after both the mousedown and mouseup events have fired (in that order).

Front button must be pressed and released while the pointer is located inside it.

The callback argument sets the callback that will be invoked when the event is dispatched.

Source:
See:

clickReset

Appends an event listener for events whose type attribute value is click.

Fires after both the mousedown and mouseup events have fired (in that order).

Reset button must be pressed and released while the pointer is located inside it.

The callback argument sets the callback that will be invoked when the event is dispatched.

Source:
See:

clickSide

Appends an event listener for events whose type attribute value is click.

Fires after both the mousedown and mouseup events have fired (in that order).

Side button must be pressed and released while the pointer is located inside it.

The callback argument sets the callback that will be invoked when the event is dispatched.

Source:
See:

clickTop

Appends an event listener for events whose type attribute value is click.

Fires after both the mousedown and mouseup events have fired (in that order).

Top button must be pressed and released while the pointer is located inside it.

The callback argument sets the callback that will be invoked when the event is dispatched.

Source:
See:

controls

Appends an event listener for events whose type attribute value is change.

Fires when the camera has been transformed by the controls.

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event Event a generic event.
function callback function to run when the event occurs.
Source:
See:

keydown

Appends an event listener for events whose type attribute value is keydown.

Fired when a key is pressed.

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event KeyboardEvent a UIEvent.
function callback function to run when the event occurs.
Source:
See:

load

Sets the entry point of the application.

Fired when the whole page has loaded, including all dependent resources such as stylesheets, scripts, iframes, and images, except those that are loaded lazily.

Type:
  • function
Parameters:
Name Type Description
event Event load event.
Source:
See:

materialRadio

Appends an event listener for events whose type attribute value is change.

Fired when the material <input type="radio"> is checked (but not when unchecked).

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event Event a generic event.
function callback function to run when the event occurs.
Source:
See:

meshChkBox

Appends an event listener for events whose type attribute value is change.

Fired when the mesh <input type="checkbox"> is checked or unchecked (by clicking or using the keyboard).

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event Event a generic event.
function callback function to run when the event occurs.
Source:
See:

modelsSelect

Appends an event listener for events whose type attribute value is change.

Fired for models <select> element when the user modifies its value.

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event Event a generic event.
function callback function to run when the event occurs.
Source:
See:

pointerdown

Fired when the pointer is pressed on the canvas.

The orthoView.interpolate is set to false, so interpolation is interrupted as soon as the pointer is pressed.

Note that adding the event to the controls object does not work.

Source:

resize

Appends an event listener for events whose type attribute value is resize.

Fires when the document view (window) has been resized.

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event Event a generic event.
function callback function to run when the event occurs.
useCapture Boolean handler is executed in the bubbling or capturing phase.
Source:
See:

statsChkBox

Appends an event listener for events whose type attribute value is change.

Fired when the stats <input type="checkbox"> is checked or unchecked (by clicking or using the keyboard).

The callback argument sets the callback that will be invoked when the event is dispatched.

Parameters:
Name Type Description
event Event a generic event.
function callback function to run when the event occurs.
Source:
See: