WanaPlan

API Docs for: 2.7.0
Show:

Controls

Module: Input
Parent Module: Wanaplan

Summary

High-level controller for the 3D scene, that handles selection, dragging, and notifying events to 3D widgets. It is derived into a higher level of abstraction class : EditionComponent3D, but can still be used by another component.

Controls is the selection/dragging system on wanaplan, it wraps all Engine3D events into a high-level system. You provide a list of objects that can be selected and dragged. These objects have a hierarchy (parent - children), and an ancestor, called the root.

Dragging : A referent parent is always set, you can only drag object that are direct children of the referent parent, or direct children of the root.

Selection : You select objects by clicking on them. You can only select objects that are direct children of the referent parent, or direct children of the root.

Here is the list of all events you can set callbacks to, and the type of the argument provided to the callback :

  • before-dragstart (no argument)
  • before-dragging (BABYLON.Ray)
  • dragstart (BABYLON.PickingInfo)
  • dragging (BABYLON.PickingInfo)
  • dragend (BABYLON.PickingInfo)
  • mouseup (MouseEvent)
  • mousedown (MouseEvent)
  • mousemove (MouseEvent)
  • before-click (no argument)
  • click (BABYLON.PickingInfo)
  • double-click (BABYLON.PickingInfo)
  • select (BABYLON.PickingInfo)
  • deselect (BABYLON.PickingInfo)

Constructor

Controls

Syntax

Controls

()

Summary

Methods

addDraggable

Syntax

addDraggable

(
  • object
)

Summary

Adds an object to the list of handled objects.

Parameters:

  • object BABYLON.Mesh

    The object.

addUnremovableDraggable

Syntax

addUnremovableDraggable

(
  • object
)
deprecated private

Summary

Adds an object to the list of handled objects, that can't be removed. Do not use this

Parameters:

  • object BABYLON.Mesh

    The object.

clickSelection

Syntax

clickSelection

(
  • event
)

Summary

Implements the behaviour "click = selection of top-level object"

Parameters:

  • event MouseEvent

    The JS event

constrains

Syntax

constrains

(
  • [U]
  • [V]
)

Summary

Sets the constrains for the dragging. 3 cases :

  • No param is specified, no constraint on the dragging, the object is dragged on a sphere around the camera.
  • Only the param U is specified, the object is dragged along an axis, carried by the vector U.
  • Both params are specified, the object is dragged along a plane, directed by U and V.

Parameters:

  • [U] BABYLON.Vector3 optional

    First Vector.

  • [V] BABYLON.Vector3 optional

    Second Vector.

deselect

Syntax

deselect

()

Summary

Deselects the object, even if no object has been selected.

dragLock

Syntax

dragLock

()

Summary

Unlocks the dragging capabilities.

dragLock

Syntax

dragLock

()

Summary

Locks the dragging capabilities.

dragSelection

Syntax

dragSelection

(
  • event
)

Summary

Implements the behaviour "dragging of top-level object"

Parameters:

  • event MouseEvent

    The JS event

getDragged

Syntax

getDragged

() BABYLON.PickingInfo

Summary

Returns the dragged object as a picking information.

Returns:

BABYLON.PickingInfo:

The dragged object, as a picking information.

getLastPosition

Syntax

getLastPosition

()

Summary

Returns the last position of the dragged object.

getPointerCoordinates

Syntax

getPointerCoordinates

(
  • event
)

Summary

Gets the correct values for the current pointer. Cross device.

Parameters:

  • event Event

    The JS event

getReferentParent

Syntax

getReferentParent

() BABYLON.Mesh

Summary

Returns the current referent parent, used to select or drag objects. See Controls wiki for more info.

Returns:

BABYLON.Mesh:

The current referent parent.

getReferentPlane

Syntax

getReferentPlane

() BABYLON.Plane

Summary

Returns the current referent plane, on which the mouse is projected when dragging.

Returns:

BABYLON.Plane:

The current referent plane.

getRoot

Syntax

getRoot

() BABYLON.Mesh

Summary

Returns the current root, that is the top-level parent of all handled objects. NB : All objects that are not descendants of the root can't be handled by Controls.

Returns:

BABYLON.Mesh:

The current root.

getSelected

Syntax

getSelected

() BABYLON.PickingInfo

Summary

Returns the selected object, as picking information.

Returns:

BABYLON.PickingInfo:

The selected object, as picking information.

getSelectedObject

Syntax

getSelectedObject

() BABYLON.Mesh

Summary

Returns the selected object. NB : This is equivalent to getSelected().pickedMesh.

Returns:

BABYLON.Mesh:

The selected object.

notify

Syntax

notify

(
  • event
  • data
)

Summary

Calls every callback registered for a specific event.

Parameters:

  • event Event

    The event.

  • data Object

    The data associated to this event.

off

Syntax

off

(
  • event
  • handler
)
Controls

Summary

Removes a callback from a specific event.

Parameters:

  • event Event

    The event.

  • handler Function

    The callback function.

Returns:

Controls:

this.

on

Syntax

on

(
  • event
  • handler
  • insertFirst
)
Controls

Summary

Adds a callback to a specific event.

Parameters:

  • event Event

    The event.

  • handler Function

    The callback function.

  • insertFirst Boolean

    If true then insert function in first position of listeners.

Returns:

Controls:

this.

onClick

Syntax

onClick

(
  • event
)

Summary

Triggered on event wnp.engine3D.click.

Parameters:

  • event Event

    The JS event.

onDoubleClick

Syntax

onDoubleClick

(
  • event
)

Summary

Triggered on event wnp.engine3D.dblclick.collided.

Parameters:

  • event Event

    The JS event.

onDragEnd

Syntax

onDragEnd

(
  • event
)

Summary

Triggered on event wnp.engine3D.drag-end.

Parameters:

  • event Event

    The JS event.

onDragging

Syntax

onDragging

(
  • event
)

Summary

Triggered on event wnp.engine3D.dragging.

Parameters:

  • event Event

    The JS event.

onDragStart

Syntax

onDragStart

(
  • event
)

Summary

Triggered on event wnp.engine3D.drag-start.

Parameters:

  • event Event

    The JS event.

onMouseDown

Syntax

onMouseDown

(
  • event
)

Summary

Triggered on event wnp.engine3D.mousedown.

Parameters:

  • event Event

    The JS event.

onMouseMove

Syntax

onMouseMove

(
  • event
)

Summary

Triggered on event wnp.engine3D.mouse-move.

Parameters:

  • event Event

    The JS event.

pickMeshUnderCursor

Syntax

pickMeshUnderCursor

(
  • event
  • [ref]
)

Summary

Picks the mesh under the mouse pointer, and returns the top-level object as a pickingInfo

Parameters:

  • event MouseEvent

    The JS event

  • [ref] BABYLON.Mesh optional

    Optional parameter to override the referent parent.

refreshReferentPlane

Syntax

refreshReferentPlane

()

Summary

Refresh the referent dragging plane, taking the constraints into account.

removeDraggable

Syntax

removeDraggable

(
  • object
)

Summary

Removes an object to the list of handled objects.

Parameters:

  • object BABYLON.Mesh

    The object.

resetDraggable

Syntax

resetDraggable

()

Summary

Empties the list of handled objects.

select

Syntax

select

(
  • topLevelObjectPI
)

Summary

Selects an object, as a picking information.

Parameters:

  • topLevelObjectPI BABYLON.PickingInfo

    The new selected object, as a picking information.

selectObject

Syntax

selectObject

(
  • object
)

Summary

Selects an object. NB : A picking info is created, with a null distance and a null pickedPoint. NB 2 : The difference with setSelectedObject is that a select event is fired.

Parameters:

  • object BABYLON.Mesh

    The new selected object.

selectTopLevelObject

Syntax

selectTopLevelObject

(
  • object
)

Summary

Selects the top-level object, relative to the referent parent, for the given object. NB : A picking info is created, with a null distance and a null pickedPoint.

Parameters:

  • object BABYLON.Mesh

    The object from which we have to find the top-level object.

setDragged

Syntax

setDragged

(
  • dragged
)

Summary

Forces the dragged object without having to click on it. NB : Warning, the parameter is a picking info !

Parameters:

  • dragged BABYLON.PickingInfo

    The new dragged object.

setReferentParent

Syntax

setReferentParent

(
  • parent
)

Summary

Sets the current referent parent, used to select or drag objects. See Controls wiki for more info.

Parameters:

  • parent BABYLON.Mesh

    The new referent parent.

setRoot

Syntax

setRoot

(
  • root
)

Summary

Sets the current root, that is the top-level parent of all handled objects. NB : All objects that are not descendants of the root can't be handled by Controls. NB 2 : The referent parent is also set to the new root, for consistency.

Parameters:

  • root BABYLON.Mesh

    The new root.

setScreenSize

Syntax

setScreenSize

(
  • width
  • height
)

Summary

Sets the canvas size.

Parameters:

setSelectedObject

Syntax

setSelectedObject

(
  • object
)

Summary

Forces the selected object without having to click on it. NB : A picking info is created, with a null distance and a null pickedPoint. NB 2 : The difference with selectObject is that no select event is fired.

Parameters:

  • object BABYLON.Mesh

    The new selected object.

startListening

Syntax

startListening

()

Summary

Starts the listening of Engine3D events.

stopListening

Syntax

stopListening

()

Summary

Stops the listening of Engine3D events.

Properties

_screenSizes

Syntax

_screenSizes

Object

Summary

Screen Sizes (width and height)

domElement

Syntax

domElement

HTMLCanvasElement

Summary

The canvas.

listens

Syntax

listens

Boolean

Summary

Flag that indicates if the Controls are listening to the Engine3D events

move

Syntax

move

Function

Summary

Move callback, called by Controls to move an object in the scene.

objects

Syntax

objects

BABYLON.Mesh

Summary

3D objects handled by the controls (selectable and draggable).

params

Syntax

params

Object

Summary

Controls parameters.

scene

Syntax

scene

BABYLON.Scene

Summary

The 3D scene.

Events

wnp.request.disable-orbit-camera

Syntax

wnp.request.disable-orbit-camera

Summary

Fired to disable the orbit camera.

wnp.request.enable-orbit-camera

Syntax

wnp.request.enable-orbit-camera

Summary

Fired to enable the orbit camera.