Class: Tool
Base class for all tools
Hierarchy
- Tool
Index
Constructors
Properties
- accessUiComponent
- animationFunction
- chosenUiManifestation
- compositeModel
- continueInteractionOnAnimate
- editor
- hintManager
- parameters
- pauseFidelityControl
- pausePhysicsSimulation
- renderContext
- threeNode
- undoEngine
- userMessageEventEmitter
- userProgressCancelEventEmitter
- userProgressEventEmitter
- userProgressFinishEventEmitter
- visualizationManager
- wakeUpCallback
Methods
- cancel
- cancelUserProgress
- clickInteraction
- consecutiveClick
- continueInteraction
- displayUserMessage
- displayUserProgress
- equals
- finishInteraction
- finishUserProgress
- getAnimationFunction
- getCanHandleMultipleInteractions
- getCanWorkWithHints
- getChosenUiManifestation
- getCompositeModel
- getEditor
- getHintManager
- getInteractionCancelled
- getInteractionStarted
- getInternalName
- getManifestationParameters
- getParameters
- getPauseFidelityControl
- getPausePhysicsSimulation
- getRenderContext
- getReproduceInfo
- getRequiresContinuousModelIntersection
- getThreeNode
- getUiComponentAccessMethod
- getUndoEngine
- getUserMessageEventEmitter
- getUserProgressCancelEventEmitter
- getUserProgressEventEmitter
- getUserProgressFinishEventEmitter
- getVisualizationManager
- getWakeUpCallback
- getWorksInEmptySpace
- getWorksWithConsecutiveClicks
- needsReset
- startInteraction
- canHandleInteraction
- getInternalName
- keepLastBoxelUnMerged
- onSelected
- onUserDeselected
- requiresHintReset
Constructors
constructor
+ new Tool(chosenUiManifestation: IToolManifestation, options: IToolOptions): Tool
Defined in src/tools/Tool.ts:162
Parameters:
| Name | Type | Description |
|---|---|---|
chosenUiManifestation |
IToolManifestation | the manifestation object as chosen by the user |
options |
IToolOptions | - |
Returns: Tool
Properties
Protected Readonly accessUiComponent
• accessUiComponent: any = null
Defined in src/tools/Tool.ts:151
Protected Readonly animationFunction
• animationFunction: function = null
Defined in src/tools/Tool.ts:147
Type declaration:
▸ (animation: any): void
Parameters:
| Name | Type |
|---|---|
animation |
any |
Protected Readonly chosenUiManifestation
• chosenUiManifestation: IToolManifestation
Defined in src/tools/Tool.ts:162
Protected Readonly compositeModel
• compositeModel: CompositeModel | null = null
Defined in src/tools/Tool.ts:141
Protected Readonly continueInteractionOnAnimate
• continueInteractionOnAnimate: boolean = false
Defined in src/tools/Tool.ts:133
Protected Readonly editor
• editor: Editor | null = null
Defined in src/tools/Tool.ts:145
Protected Readonly hintManager
• hintManager: HintManager = null
Defined in src/tools/Tool.ts:153
Protected Readonly parameters
• parameters: any = null
Defined in src/tools/Tool.ts:160
Protected Readonly pauseFidelityControl
• pauseFidelityControl: boolean = true
Defined in src/tools/Tool.ts:137
Protected Readonly pausePhysicsSimulation
• pausePhysicsSimulation: boolean = false
Defined in src/tools/Tool.ts:135
Protected Readonly renderContext
• renderContext: RenderContext | null = null
Defined in src/tools/Tool.ts:143
Protected Readonly threeNode
• threeNode: Object3D = null
Defined in src/tools/Tool.ts:139
Protected Readonly undoEngine
• undoEngine: UndoEngine | null = null
Defined in src/tools/Tool.ts:155
Protected Readonly userMessageEventEmitter
• userMessageEventEmitter: EventEmitter‹string› = new EventEmitter
Defined in src/tools/Tool.ts:126
Protected Readonly userProgressCancelEventEmitter
• userProgressCancelEventEmitter: EventEmitter‹number› = new EventEmitter
Defined in src/tools/Tool.ts:129
Protected Readonly userProgressEventEmitter
• userProgressEventEmitter: EventEmitter‹IToolUserProgressEvent› = new EventEmitter()
Defined in src/tools/Tool.ts:127
Protected Readonly userProgressFinishEventEmitter
• userProgressFinishEventEmitter: EventEmitter‹number› = new EventEmitter
Defined in src/tools/Tool.ts:128
Protected Readonly visualizationManager
• visualizationManager: VisualizationManager | null = null
Defined in src/tools/Tool.ts:157
Protected Readonly wakeUpCallback
• wakeUpCallback: function = null
Defined in src/tools/Tool.ts:149
Type declaration:
▸ (): void
Methods
cancel
▸ cancel(): void
Defined in src/tools/Tool.ts:403
Abstract method that should be implemented: Called when the user selects another tool or the InteractionManager throws away this instance or when the InteractionHandler throws it away on mapping change. Note that the content of the three node and modifications on the composite model get cleared automatically.
Returns: void
cancelUserProgress
▸ cancelUserProgress(id: number): void
Defined in src/tools/Tool.ts:234
Parameters:
| Name | Type |
|---|---|
id |
number |
Returns: void
clickInteraction
▸ clickInteraction(mappingResult: IMapping, interactionData: IInteractionData): Promise‹boolean› | void
Defined in src/tools/Tool.ts:371
Called when tool interaction is finished and the user performed a first click interaction, not a drag interaction. This method is called after startInteraction was called. It is also called by consecutiveClick if no custom implementation has been created. Implementing this method is optional, but the default is to forward the call to Tool.finishInteraction.
Parameters:
| Name | Type | Description |
|---|---|---|
mappingResult |
IMapping | object returned from the InteractionMapping specified in startInteraction() or null |
interactionData |
IInteractionData | - |
Returns: Promise‹boolean› | void
Same as Tool.finishInteraction
consecutiveClick
▸ consecutiveClick(mappingResult: IMapping, interactionData: IInteractionData, n: number): Promise‹boolean› | void
Defined in src/tools/Tool.ts:386
Called after start, continue when there has been a consecutive click, signaling that there has been a double or triple etc. click. It never signals the first click! No new tool instance will be created, consecutiveClick will be called on the same instance that already received the click. It will only be called if the tool specifies worksWithConsecutiveClick as true in the toolManifestations Defaults to forwarding the interaction to Tool.clickInteraction
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
mappingResult |
IMapping | - | object returned from the InteractionMapping specified in startInteraction() or null |
interactionData |
IInteractionData | - | - |
n |
number | 2 | the in in this is the nTh click. The first click (consumed by clickInteraction) would have n=1, so the lowest value in consecutiveClick is 2. |
Returns: Promise‹boolean› | void
Same as Tool.finishInteraction
continueInteraction
▸ continueInteraction(mappingResult: IMapping, interactionData: IInteractionData): void
Defined in src/tools/Tool.ts:341
Abstract method that needs to be implemented: Called when tool interaction is continued (after startInteraction) Typical use-case is supporting mouse-dragging operations
Parameters:
| Name | Type | Description |
|---|---|---|
mappingResult |
IMapping | object returned from the InteractionMapping specified in startInteraction() or null |
interactionData |
IInteractionData | - |
Returns: void
displayUserMessage
▸ displayUserMessage(message: string): void
Defined in src/tools/Tool.ts:216
Parameters:
| Name | Type |
|---|---|
message |
string |
Returns: void
displayUserProgress
▸ displayUserProgress(id: number, progress: number, message: string, type: string, cancelFunction: function): void
Defined in src/tools/Tool.ts:220
Parameters:
▪ id: number
▪ progress: number
▪ message: string
▪ type: string
▪ cancelFunction: function
▸ (): void
Returns: void
equals
▸ equals(otherTool: Tool): boolean
Defined in src/tools/Tool.ts:410
Parameters:
| Name | Type |
|---|---|
otherTool |
Tool |
Returns: boolean
whether otherTool is the same kind of tool as this one
finishInteraction
▸ finishInteraction(mappingResult: IMapping, interactionData: IInteractionData): Promise‹boolean› | void
Defined in src/tools/Tool.ts:358
Abstract method that needs to be implemented: Called when tool interaction is finished (after start/continue) and the interaction has been a drag interaction (note that clickInteraction by default forwards to this method) This method is called after startInteraction was called.
Parameters:
| Name | Type | Description |
|---|---|---|
mappingResult |
IMapping | object returned from the InteractionMapping specified in startInteraction() or null |
interactionData |
IInteractionData | - |
Returns: Promise‹boolean› | void
Tool has to return a Promise that resolves when all tool logic has finished. If this tool can handle multiple interactions, it has to resolve to true when the last interaction was handled and overall tool interaction finished, else, the promise has to resolve to false. In the latter case, the same tool instance will be used. So, it will receive start, continue, finish cycles until it return true.
finishUserProgress
▸ finishUserProgress(id: number): void
Defined in src/tools/Tool.ts:230
Parameters:
| Name | Type |
|---|---|
id |
number |
Returns: void
getAnimationFunction
▸ getAnimationFunction(): function
Defined in src/tools/Tool.ts:284
Returns: function
the addAnimation function of the render context
▸ (animation: any): void
Parameters:
| Name | Type |
|---|---|
animation |
any |
getCanHandleMultipleInteractions
▸ getCanHandleMultipleInteractions(): boolean
Defined in src/tools/Tool.ts:242
Returns: boolean
getCanWorkWithHints
▸ getCanWorkWithHints(): boolean
Defined in src/tools/Tool.ts:238
Returns: boolean
getChosenUiManifestation
▸ getChosenUiManifestation(): IToolManifestation
Defined in src/tools/Tool.ts:258
Returns: IToolManifestation
getCompositeModel
▸ getCompositeModel(): CompositeModel | null
Defined in src/tools/Tool.ts:307
Returns: CompositeModel | null
getEditor
▸ getEditor(): Editor | null
Defined in src/tools/Tool.ts:288
Returns: Editor | null
getHintManager
▸ getHintManager(): HintManager
Defined in src/tools/Tool.ts:311
Returns: HintManager
getInteractionCancelled
▸ getInteractionCancelled(): object
Defined in src/tools/Tool.ts:188
Returns: object
- interaction: InteractionCancelled
getInteractionStarted
▸ getInteractionStarted‹T›(mappings: T): object
Defined in src/tools/Tool.ts:176
Type parameters:
▪ T: AbstractInteractionMapping[]
Parameters:
| Name | Type | Default |
|---|---|---|
mappings |
T | [] as T |
Returns: object
-
interaction: InteractionStartedReturnValues
-
mappings: T
getInternalName
▸ getInternalName(): string
Defined in src/tools/Tool.ts:433
Get tool name from the instance
Returns: string
getManifestationParameters
▸ getManifestationParameters(): any
Defined in src/tools/Tool.ts:269
Returns: any
the parameters that were specified in the tool manifestation
getParameters
▸ getParameters(): any
Defined in src/tools/Tool.ts:262
Returns: any
getPauseFidelityControl
▸ getPauseFidelityControl(): boolean
Defined in src/tools/Tool.ts:254
Returns: boolean
getPausePhysicsSimulation
▸ getPausePhysicsSimulation(): boolean
Defined in src/tools/Tool.ts:250
Returns: boolean
getRenderContext
▸ getRenderContext(): RenderContext
Defined in src/tools/Tool.ts:273
Returns: RenderContext
getReproduceInfo
▸ getReproduceInfo(): ISerializableObject
Defined in src/tools/Tool.ts:426
returns information to reproduce the current state of the tool on error. Can essentially be any object, should be human-readable and enable you to understand the error when looking at a log.
Returns: ISerializableObject
getRequiresContinuousModelIntersection
▸ getRequiresContinuousModelIntersection(): boolean
Defined in src/tools/Tool.ts:246
Returns: boolean
getThreeNode
▸ getThreeNode(): Object3D
Defined in src/tools/Tool.ts:303
Returns the reference to the THREE node
Returns: Object3D
getUiComponentAccessMethod
▸ getUiComponentAccessMethod(): any
Defined in src/tools/Tool.ts:296
Returns: any
getUndoEngine
▸ getUndoEngine(): UndoEngine
Defined in src/tools/Tool.ts:277
Returns: UndoEngine
getUserMessageEventEmitter
▸ getUserMessageEventEmitter(): IPublicEventEmitterInterface‹string›
Defined in src/tools/Tool.ts:200
Returns: IPublicEventEmitterInterface‹string›
getUserProgressCancelEventEmitter
▸ getUserProgressCancelEventEmitter(): IPublicEventEmitterInterface‹number›
Defined in src/tools/Tool.ts:212
Returns: IPublicEventEmitterInterface‹number›
getUserProgressEventEmitter
▸ getUserProgressEventEmitter(): IPublicEventEmitterInterface‹IToolUserProgressEvent›
Defined in src/tools/Tool.ts:204
Returns: IPublicEventEmitterInterface‹IToolUserProgressEvent›
getUserProgressFinishEventEmitter
▸ getUserProgressFinishEventEmitter(): IPublicEventEmitterInterface‹number›
Defined in src/tools/Tool.ts:208
Returns: IPublicEventEmitterInterface‹number›
getVisualizationManager
▸ getVisualizationManager(): VisualizationManager
Defined in src/tools/Tool.ts:315
Returns: VisualizationManager
getWakeUpCallback
▸ getWakeUpCallback(): function
Defined in src/tools/Tool.ts:292
Returns: function
▸ (): void
getWorksInEmptySpace
▸ getWorksInEmptySpace(): boolean
Defined in src/tools/Tool.ts:192
Returns: boolean
getWorksWithConsecutiveClicks
▸ getWorksWithConsecutiveClicks(): boolean
Defined in src/tools/Tool.ts:196
Returns: boolean
needsReset
▸ needsReset(): boolean
Defined in src/tools/Tool.ts:394
If the model should be reset when another tool takes over. Only used to declare no need for resets on non-sticky multiclicks with the moveTool as the default tool.
Returns: boolean
startInteraction
▸ startInteraction(interactionData: IInteractionData, canHandleResult: ICanHandleInteractionResult["resultObject"]): object
Defined in src/tools/Tool.ts:328
Abstract method that needs to be implemented: Called when tool interaction is started
Parameters:
| Name | Type |
|---|---|
interactionData |
IInteractionData |
canHandleResult |
ICanHandleInteractionResult["resultObject"] |
Returns: object
desired interaction mappings for future interaction events. {interaction: interactionStarted} if the tool can work without mappings {interaction: interactionStarted, mappings: [mapping1, …]} if the tool works with mappings {interaction: interactionCancelled} if the user selected an invalid object or area and the tool cannot work and should be canceled. If the tool is canceled, it remains selected.
-
interaction: InteractionStartedReturnValues
-
mappings? : AbstractInteractionMapping[]
Static canHandleInteraction
▸ canHandleInteraction(interactionData: IInteractionData, parameters?: any): CanHandleInteractionResult
Defined in src/tools/Tool.ts:113
Checks whether the tool is able to do something meaningful with the given interaction data. This method is guaranteed to be called before startInteraction, so null checks should only happen here. It can provide a resultObject which will get passed to startInteraction (eg for found model elements).
Parameters:
| Name | Type | Description |
|---|---|---|
interactionData |
IInteractionData | - |
parameters? |
any | additional parameters to configure behavior (eg when not triggered from the menu)) |
Returns: CanHandleInteractionResult
a quality and an optional resultObject if the tool wants to handle the interaction itself. A quality with a delegation object and optional resultObject if the tool knows where to delegate the interaction for sure. null when the interaction cannot be handled or delegated by the tool.
Static getInternalName
▸ getInternalName(): string
Defined in src/tools/Tool.ts:80
Returns: string
the internal, unique name of the tool. Used by the menu items to define which tool to use.
Static keepLastBoxelUnMerged
▸ keepLastBoxelUnMerged(): boolean
Defined in src/tools/Tool.ts:122
When the tool is selected and this returns true, the last boxel in the boxelqueue will stay unconnected to the base mesh so we can apply rotations to it.
Returns: boolean
Static onSelected
▸ onSelected(editorInstance: Editor, toolManifestation?: IToolManifestation, parameters?: any): boolean
Defined in src/tools/Tool.ts:87
Parameters:
| Name | Type |
|---|---|
editorInstance |
Editor |
toolManifestation? |
IToolManifestation |
parameters? |
any |
Returns: boolean
whether the tool requires rendering the scene after it was selected.
Static onUserDeselected
▸ onUserDeselected(editorInstance: Editor): void
Defined in src/tools/Tool.ts:92
Parameters:
| Name | Type |
|---|---|
editorInstance |
Editor |
Returns: void
Static requiresHintReset
▸ requiresHintReset(): boolean
Defined in src/tools/Tool.ts:100
Defines whether any hints added by previous tools used should be cleared.
Returns: boolean