Class: Edit

BIM.UserModeHandler. Edit

Handles the selection and editing of elements, paths and apertures in the model.

This is the default handler for the BIM-based PD.MODE.EDIT mode. It allows for interactive selection and editing of elements in the model using a large 3D touch-friendly cursor and manipulators.


new Edit()

Creates a new default model edit mode handler.

Author:
  • drajmarsh

Extends

Classes

dragApertureHandler
dragElementHandler
dragJunctionHandler
dragNodeHandler

Members


:object

_dragHandler

Stores a handler for interactive cursor dragging.

Type
  • object

:boolean

isUserModeHandler <readonly>

A flag identifying this object as an edit mode handler.

Type
  • boolean
Inherited From:
Overrides:

:number

lastOrientationAngle

Stores the reference rotation angle when orienting selected junctions.

Type
  • number

:BIM.Element|null

lastPreSelectedElement

Stores the last pre-selected object for change detection.

Type

:number

lastSelectionId

Stores the last host selection identifier.

Type
  • number

:boolean

wasMoved

Records whether or not a move actually occurs between drag start and end.

Type
  • boolean

Methods


cancel(host)

Cancels this edit mode.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:

complete(host)

Completes any pending modal action(s) in this edit mode.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

Inherited From:
Overrides:
Returns:

Returns true is a pending action was completed.

Type
boolean

displayDimensions(host, mesh)

Regenerates dimension lines for the current selection set, 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 the interactive selection of elements, paths and apertures in the model.

This method typically just accepts the current pre-selection and either adds to, removes from or sets it as the current selection set. However, it is always called when a click/tap event is detected and is passed the same information as the pre-selection event. This allows it the option to ignore pre-selection entirely where appropriate and perform selection only on release, if that is the desired behaviour.

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 move after a drag has finished.

This method removes any interactive dimensions or snap point indicators from the scene overlay, checks if the selected item was dragged in to or out of a container item, and initiates a check for any spatial overlap resulting from the drag. It then also updates the user interface if required.

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 selection in the model as the model cursor is dragged.

This method is called each time the scene manager detects that that the pointer has moved whilst it is pressed down on any of the 3D model cursor manipulators. This method applies the cursor movement to the current selection set and updates the model as required.

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

handleDragRotate(host, rotation, cursor, event)

Handles cursor drag rotation events.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

rotation THREE.Euler

The proposed new angle of the cursor.

cursor PD.Cursor

The cursor that rotated.

event object

The DOM event that triggered this move.

Returns:

Returns true if the rotation was applied.

Type
boolean

handleDragSelect(host, frustum, event, intersect)

Handles interactive region selection events in the canvas.

This is invoked after the user has clicked, dragged and released the pointer within the model to create a region that defines a frustum for model selection.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

frustum THREE.Frustum

The selection frustum within the current scene.

event object

The DOM event that triggered this selection.

intersect boolean

Whether or not the frustum was dragged right-left for intersection selection.

Returns:

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

Type
boolean

handleDragStart(host, cursor, event)

Prepare the selection set for an interactive drag event.

This method is called when the user has pressed the pointer on one of the 3D model cursor manipulators and the very first drag event has been detected. It is called only once at the very start of the drag sequence and immediately before the first call to handleDragMove().

Rather than applying movements incrementally to points in the model, it is much more accurate and stable to store their original positions just before the movement, and then apply the dynamic movement vector relative to that each time. This approach makes cancelling the movement mid-drag much simpler and means that a specific drag can be applied to the same point any number of times but it will still always end up in exactly the same position.

Thus, the role of this method is to make sure that the original positions of each selected point, line, wall and/or space are updated and stored so that the movement vector can be dynamically applied. This is done be calling the handleBeforeMove() method on each selected element to allow them to process and store whatever they need to.

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 interactive pre-selection events.

This method is called when the user first clicks/taps within the model canvas, but away from the 3D cursor. At this stage, the system doesn't yet know whether the user intends to select something in the model or is simply trying to rotate or pan the view.

This method checks for any element(s) that could be selected, then highlights them with a highly transparent pre-selection mesh as a visual indicator of what would be selected if the user then released the pointer. The method returns true if the handler would like to be notified if/when the user subsequently releases the pointer without dragging.

If the user subsequently drags the pointer, the handlePreSelectClear() method is called to clear the mesh as well as any stored potential selection data, and then the scene manager takes over to handle either drag selection or view manipulation.

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

handlePreSelectClear(host, event)

Handles the clearing of pre-selection events from the PD.SceneManager.

This is invoked after a pre-selection has been displayed, but the user then drags the pointer beyond the threshold to either change the model view or initiate drag selection. This method should hide the pre-selection mesh and clear any stored potential selection data.

Parameters:
Name Type Description
host PD.SelectionManager

The selection manager.

event object

The DOM event that triggered this callback.

Returns:

Returns true if something in the model was pre-selected and the mesh was subsequently cleared, 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 an interactive process.

This method should do whatever is required to end the previous stage and transition to the next stage in a multi-stage action.

Parameters:
Name Type Argument Description
host PD.SelectionManager

The selection manager.

stage number <optional>

An optional stage in the progress, defaults to -1.

Inherited From:
Overrides:

setCursorPosition(host, pos [, event])

Manually sets the cursor position during an 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.

This method should undertake whatever action dragging the cursor would have at the current progress stage.

Parameters:
Name Type Argument Description
host PD.SelectionManager

The selection manager.

pos Object | Array

The new position to move the cursor to.

event Event <optional>

The event that invoked this method.

Inherited From:
Overrides: