HandleOperator

class wv.Operators.HandleOperator()

Handles are added scene elements that can update the position of your parts through user interaction. Find more information here.

Constructors

wv.Operators.HandleOperator.constructor()
HandleOperator(viewer: IWebViewer, view: IView): HandleOperator

Parameters

viewer: IWebViewer

view: IView

Returns: HandleOperator

Methods

wv.Operators.HandleOperator.addAxisRotationHandle()
addAxisRotationHandle(position: Point3, axis: Point3, color: Color, positionNormal: (None | Point3)?, groupId: (None | number)?): Promise

Adds a handle that rotates around an axis

Parameters

position: Point3

center of the handle.

axis: Point3

axis to rotate around

color: Color

color of the handle geometry

positionNormal: (None | Point3) = null

optional vector to control the orientation of the handle geometry.

groupId: (None | number) = null

optional parameter to associate this handle with a group of NodeIds

Returns: Promise

wv.Operators.HandleOperator.addAxisTranslationHandle()
addAxisTranslationHandle(position: Point3, axis: Point3, color: Color, positionNormal: (None | Point3)?, groupId: (None | number)?): Promise

Adds a handle that moves along an axis.

Parameters

position: Point3

center of the handle.

axis: Point3

axis to move along

color: Color

color of the handle geometry

positionNormal: (None | Point3) = null

optional vector to control the orientation of the handle geometry.

groupId: (None | number) = null

optional parameter to associate this handle with a group of NodeIds

Returns: Promise

wv.Operators.HandleOperator.addHandles()
addHandles(nodeIds: number[], position: (None | Point3)?, groupId: (None | number)?): Promise

Adds all handles into the scene, oriented along the primary axes

Parameters

nodeIds: number[]

corresponding to the parts that will move with the handles

position: (None | Point3) = null

world space coordinates the the handle position

groupId: (None | number) = null

Returns: Promise

wv.Operators.HandleOperator.addMapping()

inherited

addMapping(button: Button, modifier: KeyModifiers?): void

Adds a button and key modifier mapping for the operator. If no mapping is provided, all combinations are considered valid. All mappings require a mouse button, but a key modifier is optional.

Parameters

button: Button

modifier: KeyModifiers = KeyModifiers.None

Returns: void

wv.Operators.HandleOperator.addPlaneTranslationHandle()
addPlaneTranslationHandle(position: Point3, normal: Point3, faceColor: Color, lineColor: Color, positionNormal: (None | Point3)?, groupId: (None | number)?): Promise

Adds a handle that restricts movement to a plane.

Parameters

position: Point3

center of the handle.

normal: Point3

normal of the plane

faceColor: Color

face color of the handle geometry

lineColor: Color

outline color of the handle geometry

positionNormal: (None | Point3) = null

optional vector to control the orientation of the handle geometry.

groupId: (None | number) = null

optional parameter to associate this handle with a group of NodeIds

Returns: Promise

wv.Operators.HandleOperator.addTrackedPoint()
addTrackedPoint(point: Point3): number

Add a point to the tracked points list. When the handle moves, these points will update in world space.

Parameters

point: Point3

Returns: number

point index
wv.Operators.HandleOperator.addViewPlaneTranslationHandle()
addViewPlaneTranslationHandle(position: Point3, color: Color, groupId: (None | number)?): Promise

Adds a handle that restricts movement to the viewplane.

Parameters

position: Point3

center of the handle

color: Color

geometry color

groupId: (None | number) = null

optional parameter to associate this handle with a group of NodeIds

Returns: Promise

wv.Operators.HandleOperator.checkMapping()

inherited

checkMapping(event: MouseInputEvent): boolean

Checks if the given mouse event matches any of the button and key modifier mappings for the operator. If no mappings are defined, it returns true.

Parameters

event: MouseInputEvent

The mouse event to check against the operator’s mappings.

Returns: boolean

True if the event matches any mapping or if no mappings are defined, false otherwise.
wv.Operators.HandleOperator.clearMapping()

inherited

clearMapping(): void

Clears any button and key modifier mappings for the operator.

Returns: void

wv.Operators.HandleOperator.clearTrackedPoints()
clearTrackedPoints(): void

Clear the list of tracked points.

Returns: void

wv.Operators.HandleOperator.generateGroupId()
generateGroupId(): number

This will generate a unique id to associate a group of handles with a group of NodeIds.

Returns: number

wv.Operators.HandleOperator.getNodeIds()
getNodeIds(groupId: (None | number)?): number[]

Gets the NodeIds that the handles in the scene will move.

Parameters

groupId: (None | number) = null

optional parameter that specifies if the NodeIds to retrieve are part of a group.

Returns: number[]

wv.Operators.HandleOperator.getPosition()
getPosition(): (None | Point3)

Returns: (None | Point3)

the current handle position or null if not currently active.
wv.Operators.HandleOperator.getTrackedPoints()
getTrackedPoints(): Point3[]

Gets the tracked point list.

Returns: Point3[]

wv.Operators.HandleOperator.getTranslation()
getTranslation(): Point3

Returns: Point3

the total translation applied to the handles.
wv.Operators.HandleOperator.isActive()

inherited

isActive(): boolean

Checks if the operator is currently active, which is determined by whether the button and key modifier mapping is active or a touch event is active, and that a double click has not occurred and the context menu is not open.

Returns: boolean

True if the operator is active, false otherwise.
wv.Operators.HandleOperator.isDragging()

inherited

isDragging(): boolean

Checks if the operator is currently dragging.

Returns: boolean

True if the operator is dragging, false otherwise.
wv.Operators.HandleOperator.isEnabled()
isEnabled(): boolean

Returns a boolean value indicating if handles are available to be added to the scene If there is an active explode, active measure, or the model is a 2d drawing. this will be false.

Returns: boolean

wv.Operators.HandleOperator.onDeactivate()

inherited

onDeactivate(): (void | Promise)

Called when the operator is deactivated. This method stops any ongoing interactions and resets the primary touch ID. It can be overridden by child classes to provide additional cleanup behavior when the operator is deactivated.

Returns: (void | Promise)

A promise that resolves when the deactivation process is complete, or void if no asynchronous operations are performed.
wv.Operators.HandleOperator.onDoubleClick()

inherited

onDoubleClick(_event: MouseInputEvent): void

NO-OP method for handling double click events. By default, it does nothing, but child classes can override this method to provide specific behavior for double click events.

Parameters

_event: MouseInputEvent

The double click event to handle.

Returns: void

wv.Operators.HandleOperator.onTouchEnd()

inherited

onTouchEnd(event: TouchInputEvent): void

Base method for handling touch end events. If the touch event corresponds to the primary touch point, it emulates a mouse up event using the touch position and resets the primary touch ID. It also sets the event as handled based on the operator’s setHandled method.

Parameters

event: TouchInputEvent

The touch end event to handle.

Returns: void

wv.Operators.HandleOperator.onTouchMove()

inherited

onTouchMove(event: TouchInputEvent): Promise

Base method for handling touch move events. If the touch event corresponds to the primary touch point, it emulates a mouse move event using the touch position. It awaits the onMouseMove method to allow for asynchronous behavior in child classes.

Parameters

event: TouchInputEvent

The touch move event to handle.

Returns: Promise

wv.Operators.HandleOperator.onTouchStart()

inherited

onTouchStart(event: TouchInputEvent): void

Base method for handling touch start events. It tracks the primary touch point and emulates a mouse down event using the touch position. If there is already an active touch, it ignores additional touch start events.

Parameters

event: TouchInputEvent

The touch start event to handle.

Returns: void

wv.Operators.HandleOperator.removeHandles()
removeHandles(): Promise

Removes all handles from the scene.

Returns: Promise

wv.Operators.HandleOperator.setAxisMeshData()
setAxisMeshData(meshData: MeshData): Promise

Sets the mesh data for axis handles.

Parameters

meshData: MeshData

Returns: Promise

wv.Operators.HandleOperator.setHandleSize()
setHandleSize(size: number): void

Takes a scale value to change the handle size with 1 representing the default size

Parameters

size: number

Returns: void

wv.Operators.HandleOperator.setMapping()

inherited

setMapping(button: Button, modifier: KeyModifiers?): void

Sets the button and key modifier mapping for the operator.

Parameters

button: Button

modifier: KeyModifiers = KeyModifiers.None

Returns: void

wv.Operators.HandleOperator.setNodeIds()
setNodeIds(nodeIds: number[], groupId: (None | number)?): void

Sets the NodeIds that any handles in the scene will move.

Parameters

nodeIds: number[]

groupId: (None | number) = null

optional parameter that associates a group of NodeIds with a group of handles.

Returns: void

wv.Operators.HandleOperator.setPlaneMeshData()
setPlaneMeshData(meshData: MeshData): Promise

Sets the mesh data for plane handles.

Parameters

meshData: MeshData

Returns: Promise

wv.Operators.HandleOperator.setRotateMeshData()
setRotateMeshData(meshData: MeshData): Promise

Sets the mesh data for rotation handles.

Parameters

meshData: MeshData

Returns: Promise

wv.Operators.HandleOperator.setViewPlaneMeshData()
setViewPlaneMeshData(meshData: MeshData): Promise

Sets the mesh data for view plane handles.

Parameters

meshData: MeshData

Returns: Promise

wv.Operators.HandleOperator.showHandles()
showHandles(): void

Shows any handles that have been added to the scene.

Returns: void

wv.Operators.HandleOperator.stopInteraction()

inherited

Stops an operator from interacting with the scene.

stopInteraction(): void

Stops the current interaction by triggering the “endInteraction” event on the viewer, and resets the dragging state, drag count, and button modifier active state.

Returns: void

wv.Operators.HandleOperator.updatePosition()
updatePosition(translation: Point3, rotation: Matrix, finalizePosition: boolean, groupId: (None | number)?): Promise

Updates the current handle position.

Parameters

translation: Point3

additional translation

rotation: Matrix

additional rotation

finalizePosition: boolean

keep translation and rotation. If true, added translation and rotation will not reset the next time the position is updated.

groupId: (None | number) = null

Returns: Promise