ViewerInteractionAPI¶
Interface ViewerInteractionAPI
interface ViewerInteractionAPI {
enableSnapping(useSnapping: boolean): void;
getInteractionLevel(): ViewerInteractionLevel;
isSnappingEnabled(): boolean;
setInteractionLevel(level: ViewerInteractionLevel): void;
}
enableSnapping(useSnapping: boolean): void;
getInteractionLevel(): ViewerInteractionLevel;
isSnappingEnabled(): boolean;
setInteractionLevel(level: ViewerInteractionLevel): void;
}
Hierarchy (View Summary)
- ViewerInteractionAPI
Methods
enable Snapping
Enables or disables snapping in the viewer.
Parameters
- useSnapping: boolean
Whether to enable or disable snapping.
Returns void
- useSnapping: boolean
get Interaction Level
Returns the current interaction level of the viewer.
Returns ViewerInteractionLevel
The current interaction level of the viewer.
is Snapping Enabled
Returns whether snapping is enabled in the viewer.
Returns boolean
trueif snapping is enabled,falseotherwise.
set Interaction Level
Sets the viewer's interaction level.
Parameters
- level: ViewerInteractionLevel
Specifies the viewer's interaction level.
Returns void
- level: ViewerInteractionLevel
ViewerInteractionAPI
Overview
The
ViewerInteractionAPIprovides methods to control the user's interaction with a viewer.Quick Start
The following example enables snapping to topological entities and then reacts to NodeClickedEvents:
Interaction Levels
Get the current interaction level of a viewer:
By default, the interaction level is set to
NODE, which means that the user will interact with viewer at the node level. In other words, on a desktop device using a mouse, the viewer will respond to clicks with the respective node under the mouse cursor.Changing the interaction level to
TOPOLOGYwill make the viewer respond to clicks with the respective topology under the mouse cursor:Snapping
The
ViewerInteractionAPIalso provides the option to enable or disable snapping. Snapping is a feature that allows the user to snap to the nearest edge or point.Remarks
Interaction and snapping only work on entities that are being rendered in the viewer. For example, if the ViewerInteractionLevel is set to ViewerInteractionLevel.TOPOLOGY, but the viewer's ViewerSettingStrings.RENDER_MODE is set to RenderMode.Faces only, then snapping to edges will not work. To enable snapping to all topological entities, the render mode should be set to RenderMode.FacesTopology instead.
Events
The
ViewerInteractionAPIemits the following events: