Class: Move

BIM.UserModeHandler. Move

Handles the interactive translation of the selection within the model.

This is registered as the default handler for PD.MODE.MOVE mode, and allows the user to interactively drag the current selection using a large 3D touch-friendly cursor and manipulators.

This class is also intended to serve as a base for customised interactions. Both the default BIM.UserModeHandler.Rotate and BIM.UserModeHandler.Scale derive from it to perform their actions. If you want to add your own custom interaction, you should consider sub classing this seeing how it works.


new Move()

Creates a new move selection mode handler.

Author:
  • drajmarsh

Extends

Members


:boolean

actionApplied

Whether or not the action was applied to the selection.

Type
  • boolean

:number

id

A unique id generated each time a new drag is initiated.

Type
  • number

:boolean

isUserModeHandler <readonly>

A flag identifying this object as an edit mode handler.

Type
  • boolean
Inherited From:
Overrides:

:Array.<THREE.Vector3>

refPoints

Stores the reference positions required for the action.

For a simple move, this is just the start point [0] and the drag point [1]. For a rotation, it is the center point [0], the reference direction [1] and the drag direction [2]. You can add any extra points your action needs within the subclass constructor.

Type
  • Array.<THREE.Vector3>

:number

setupStages

The progress stage at which setup finishes and dragging begins.

Setup stages display a detached cursor and are used to set the reference positions prior to actual dragging. During these stages, the user can click anywhere in the canvas and the cursor will move to that spot, and snapping should include the selected element. After the setup stages, when the user is dragging the selected element around, it should be excluded from snap detection.

Type
  • number

:boolean

stageMessages

Stores the messages for each progress stage.

The number of messages in this array also determines the maximum progress stage it wil get to.

Type
  • boolean

:THREE.Vector3

vector

Stores a movement vector.

Type
  • THREE.Vector3

Methods


applyActionOnDrag(host, cursor, event)

Apply the action to the selection set during cursor drag.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that moved.

event object

The DOM event that triggered this move.

Returns:

Returns true if the action was applied, otherwise false.

Type
boolean

applyActionOnRelease(host, cursor, event)

Apply the action to the selection set during cursor drag.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that moved.

event object

The DOM event that triggered this move.

Returns:

Returns true if the action was applied.

Type
boolean

cancel(host)

Cancels this edit mode.

This method is an opportunity for the action handler to back out and clean up when cancelled. The host will automatically remove any residual dimensions or snap indicators and will redraw the model, so you don't need to do anything like that here. You should also have already added and updated an undo entry during the drag action, so should be able to rely on that to undo any model changes.

Thus, use this method only to clean up anything extra that you may have added or modified during your custom action, and then reset to PD.MODE.EDIT mode and call undo.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:

checkToSnapValue(host, newPos, cursor, event)

Snaps the movement vector to grid values.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

newPos THREE.Vector3

The proposed new position of the cursor.

cursor PD.Cursor

The cursor that moved.

event object

The DOM event that triggered this move.


complete(host)

Completes any pending model action(s) and returns to model edit mode.

Most of the default edit modes update the selection and the model in real time during interaction, so all that is required here is to reset to the PD.MODE.EDIT mode.

However, if your custom action only simulates an action using the hosts selection meshes, then this is your time to actually apply that action.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:
Returns:

Returns true if the pending action was completed.

Type
boolean

displayDimensions(host, mesh)

Regenerates dimension lines for the current mode, if any.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

mesh PD.PolyMesh

The mesh to add the dimension(s) to.

Inherited From:
Overrides:
Returns:

Returns true if something in the model was dimensioned and the mesh should be visible, otherwise false.

Type
boolean

handleClickSelect(host, raycaster, event)

Handles selection on pointer release events.

This method is called when the user has clicked/tapped and released the pointer within the canvas without dragging, but away from the 3D cursor. If this action is still in its setup stages, it progresses to the next stage, the cursor is moved to the clicked/tapped position, and the method returns true. If setup stages are over, the action is completed and the method returns false.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

raycaster THREE.Raycaster

The ray cast into the current scene.

event object

The DOM event that triggered this selection.

Inherited From:
Overrides:
Returns:

Returns true if something in the model was selected and geometry was added to the mesh, otherwise false.

Type
boolean

handleDragEnd(host, cursor, event)

Completes the action after a drag has finished.

This method is called when the user releases the pointer after having dragged the 3D cursor with the pointer down.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that just finished moving.

event object

The DOM event that triggered the end of the move.

Inherited From:
Overrides:
Returns:

Returns true if the move was finalised.

Type
boolean

handleDragMove(host, newPos, cursor, event)

Moves the current reference point as the cursor is dragged.

This method is called multiple times as the user is dragging the cursor with the pointer down.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

newPos THREE.Vector3

The proposed new position of the cursor.

cursor PD.Cursor

The cursor that moved.

event object

The DOM event that triggered this move.

Inherited From:
Overrides:
Returns:

Returns true if the move was applied.

Type
boolean

handleDragStart(host, cursor, event)

Prepare the selection and model just prior to a drag event.

This method is called when the user has clicked/tapped the pointer on one of the active cursor manipulators and just begun to drag with the pointer down.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

cursor PD.Cursor

The cursor that is about to move.

event object

The DOM event that triggered this move.

Inherited From:
Overrides:
Returns:

Returns true if the move is allowed.

Type
boolean

handlePreSelect(host, raycaster, event)

Handles pointer down events.

At this stage, the system doesn't yet know whether the user is selecting something or simply trying to rotate the view.

If the current progress is still within the setup stages, the cursor will be positioned to where the pointer was pressed on the cursor plane. After setup stages, it allows the user to rotate.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

raycaster THREE.Raycaster

The ray cast into the current scene.

event object

The DOM event that triggered this callback.

Inherited From:
Overrides:
Returns:

Returns true if something in the model was pre-selected and geometry was added to the mesh, otherwise false.

Type
boolean

initialise(host)

Called each time this edit mode is entered.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:

progressToNextStage(host [, stage])

Increments through the stages of the interactive measurement process.

Parameters:
Name Type Argument Description
host PD.SelectionManager

The selection manager.

stage number <optional>

An optional new stage in the progress, defaults to host.userActionStage + 1.

Inherited From:
Overrides:

setCursorPosition(host, pos, cursor [, event])

Manually sets the cursor position during a measure action.

This method is called when the user manually edits the cursor position using the keyboard or other numeric input within the UI, as opposed to dragging the cursor. It is not called when the cursor is moved interactively using the manipulators and a pointer.

Parameters:
Name Type Argument Description
host PD.SelectionManager

The selection manager.

pos Object | Array

The new position to move the cursor to.

cursor PD.Cursor

The cursor that is being moved.

event Event <optional>

The DOM event that invoked this method.

Overrides: