Skip to content

editorGlobalsBoxelTool

Class: BoxelTool

Hierarchy

BoxelTool

Index

Constructors

Properties

Methods

Constructors

constructor

+ new BoxelTool(chosenUiManifestation: IToolManifestation, options: IToolOptions): BoxelTool

Inherited from BoxelTool.constructor

Defined in src/tools/Tool.ts:162

Parameters:

Name Type Description
chosenUiManifestation IToolManifestation the manifestation object as chosen by the user
options IToolOptions -

Returns: BoxelTool

Properties

Protected Readonly accessUiComponent

accessUiComponent: any = null

Inherited from BoxelTool.accessUiComponent

Defined in src/tools/Tool.ts:151


Private alignmentsBoxelMeshLocal

alignmentsBoxelMeshLocal: IBoxelMeshLocalAlignment[]

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:83


Protected Readonly animationFunction

animationFunction: function = null

Inherited from BoxelTool.animationFunction

Defined in src/tools/Tool.ts:147

Type declaration:

▸ (animation: any): void

Parameters:

Name Type
animation any

Protected Readonly chosenUiManifestation

chosenUiManifestation: IToolManifestation

Inherited from BoxelTool.chosenUiManifestation

Defined in src/tools/Tool.ts:162


Protected Readonly compositeModel

compositeModel: CompositeModel | null = null

Inherited from BoxelTool.compositeModel

Defined in src/tools/Tool.ts:141


Protected Readonly continueInteractionOnAnimate

continueInteractionOnAnimate: boolean = false

Inherited from BoxelTool.continueInteractionOnAnimate

Defined in src/tools/Tool.ts:133


Private currentBoxel

currentBoxel: ICurrentBoxel = null

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:80


Protected Readonly editor

editor: Editor | null = null

Inherited from BoxelTool.editor

Defined in src/tools/Tool.ts:145


Protected Readonly hintManager

hintManager: HintManager = null

Inherited from BoxelTool.hintManager

Defined in src/tools/Tool.ts:153


Private operation

operation: "add" | "remove" = null

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:81


Protected Readonly parameters

parameters: any = null

Inherited from BoxelTool.parameters

Defined in src/tools/Tool.ts:160


Protected Readonly pauseFidelityControl

pauseFidelityControl: boolean = true

Inherited from BoxelTool.pauseFidelityControl

Defined in src/tools/Tool.ts:137


Protected pausePhysicsSimulation

pausePhysicsSimulation: boolean = true

Overrides AssemblePlateTool.pausePhysicsSimulation

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:78


Private removeCandidates

removeCandidates: boolean = true

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:86


Protected Readonly renderContext

renderContext: RenderContext | null = null

Inherited from BoxelTool.renderContext

Defined in src/tools/Tool.ts:143


Protected Readonly threeNode

threeNode: Object3D = null

Inherited from BoxelTool.threeNode

Defined in src/tools/Tool.ts:139


Protected Readonly undoEngine

undoEngine: UndoEngine | null = null

Inherited from BoxelTool.undoEngine

Defined in src/tools/Tool.ts:155


Protected Readonly userMessageEventEmitter

userMessageEventEmitter: EventEmitter‹string› = new EventEmitter()

Inherited from BoxelTool.userMessageEventEmitter

Defined in src/tools/Tool.ts:126


Protected Readonly userProgressCancelEventEmitter

userProgressCancelEventEmitter: EventEmitter‹number› = new EventEmitter()

Inherited from BoxelTool.userProgressCancelEventEmitter

Defined in src/tools/Tool.ts:129


Protected Readonly userProgressEventEmitter

userProgressEventEmitter: EventEmitterIToolUserProgressEvent = new EventEmitter()

Inherited from BoxelTool.userProgressEventEmitter

Defined in src/tools/Tool.ts:127


Protected Readonly userProgressFinishEventEmitter

userProgressFinishEventEmitter: EventEmitter‹number› = new EventEmitter()

Inherited from BoxelTool.userProgressFinishEventEmitter

Defined in src/tools/Tool.ts:128


Protected Readonly visualizationManager

visualizationManager: VisualizationManager | null = null

Inherited from BoxelTool.visualizationManager

Defined in src/tools/Tool.ts:157


Protected Readonly wakeUpCallback

wakeUpCallback: function = null

Inherited from BoxelTool.wakeUpCallback

Defined in src/tools/Tool.ts:149

Type declaration:

▸ (): void

Methods

Private _alignBoxel

_alignBoxel(interactionData: IInteractionData): object

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:383

Align the boxel assembly using the GridInferrer.

Parameters:

Name Type Description
interactionData IInteractionData -

Returns: object

or null if the boxel could not be aligned with an assembly


Private _cleanUp

_cleanUp(): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:194

Returns: void


Private _copyMaterialProperties

_copyMaterialProperties(currentBoxel: ICurrentBoxel, interactionData: IInteractionData): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:879

Parameters:

Name Type Description
currentBoxel ICurrentBoxel -
interactionData IInteractionData -

Returns: void


Private _findAttachCandidate

_findAttachCandidate(interactionData: IInteractionData, mergeDistance: number, rayHeight: number): object | null

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:518

Finds the best candidate MeshSurface to attach to within a given merge distance or a placement for the new boxel if it has to be placed close to an existing mesh Walks backwards along the ray, then checks at a specific height whether we find a surface that is close by

Parameters:

Name Type Description
interactionData IInteractionData -
mergeDistance number -
rayHeight number the height of the point on the ray from where we look for surfaces

Returns: object | null

[the MeshSurface to attach to, including a reference to the Mesh and the corresponding plate and the intersectionPoint (the simulated click point) for this surface] XOR [newBoxPos and newBoxDir: the position and orientation for a new box if one has to be added near the existing mesh] The other fields are null in these two cases. All fields are null if the boxel should be created independently from existing meshes.


Private _findNearbyCandidate

_findNearbyCandidate(interactionData: IInteractionData): object

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:446

This tries to find a nearby surface candidate that wasn't clicked directly.

Parameters:

Name Type Description
interactionData IInteractionData -

Returns: object

the best best nearby surface candidate (mesh surface, mesh plate) if one was found alternatively returns a direction for the new boxel if a new boxel has to be created near the mesh in both of these cases the simulated intersection point is also returned if no candidate position was found, a valid object with null values is returned


Private _findNonOverlappingNewBoxelPos

_findNonOverlappingNewBoxelPos(allFoundSurfaces: Array‹object›, boxelSize: number): object | null

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:610

If someone clicked near a boxel but not in front of a surface, we want to create a new boxel at a position where the boxel doesn't overlaps with our existing mesh. However, this would usually happen if we create it at the clicked position. This finds a better position and rotation that doesn't overlap with the closest mesh.

Parameters:

Name Type Description
allFoundSurfaces Array‹object› the surfaces near the clicked position from findModelElement
boxelSize number -

Returns: object | null


Private _getCurrentBoxel

_getCurrentBoxel(size?: Vector3): ICurrentBoxel

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:727

Parameters:

Name Type Description
size? Vector3 -

Returns: ICurrentBoxel


Private _getProjectedIntersectionPoint

_getProjectedIntersectionPoint(surface: MeshSurface, mesh: Mesh, point: Vector3): Vector3

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:662

Projects a point to a candidate MeshSurface plane

Parameters:

Name Type Description
surface MeshSurface single result from findModelElement
mesh Mesh -
point Vector3 in world coordinates

Returns: Vector3

the projected point in mesh world coordinates


Private _isAPointAtAnyHeightInMeshSurface

_isAPointAtAnyHeightInMeshSurface(baseSurface: MeshSurface, mesh: Mesh, samplePoint: Vector3, boxelSize: number): Vector3 | null

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:585

Looks at different heights (in minPlateLength steps) if the projected samplePoint lies within the baseSurface

Parameters:

Name Type Description
baseSurface MeshSurface -
mesh Mesh -
samplePoint Vector3 in world coordinates
boxelSize number -

Returns: Vector3 | null

the projection point at a height where it lies in the surface if existent, otherwise null


Protected _performAlignment

_performAlignment(mappingResult: any, interactionData: any): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:176

Parameters:

Name Type
mappingResult any
interactionData any

Returns: void


Private _placeBoxelOntoAsset

_placeBoxelOntoAsset(assetPlate: Plate): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:205

Attaches a boxel to the connector of an asset. Looks for one mergeable section and sizes the boxel accordingly.

Parameters:

Name Type Description
assetPlate Plate a plate generated by the MakerAssetRealizer

Returns: void


Private _positionStartingBoxel

_positionStartingBoxel(assembly: Assembly, handledConnector: IConnector, intersectionPoint: Vector3, secondaryNormal: Vector3): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:674

Parameters:

Name Type Default Description
assembly Assembly - -
handledConnector IConnector - he connector that is conceptually in the "users hand" - used to align this on ground
intersectionPoint Vector3 - -
secondaryNormal Vector3 null -

Returns: void


Private _setMaterialOfAssemblies

_setMaterialOfAssemblies(assemblies: Assembly[], material: IPlateMaterial, polished?: boolean): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:907

Parameters:

Name Type
assemblies Assembly[]
material IPlateMaterial
polished? boolean

Returns: void


Private _showRotateButton

_showRotateButton(assembly: Assembly, worldPosition: Vector3, relativeTransformsAnchor: RelativeTransformsAnchor, debouncedFlush: DebouncedFunc‹function›, delay: number): FloatieHint‹›

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:338

Parameters:

Name Type
assembly Assembly
worldPosition Vector3
relativeTransformsAnchor RelativeTransformsAnchor
debouncedFlush DebouncedFunc‹function›
delay number

Returns: FloatieHint‹›


Private _startBoxelOperation

_startBoxelOperation(alignmentResult: object, interactionPoint: Vector3): void

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:261

After a boxel has been aligned to the base assembly, this method starts the boxel operation

Parameters:

alignmentResult: object

-

Name Type
baseSurface MeshSurfaceAnchor
connectorSurface MeshSurfaceAnchor

interactionPoint: Vector3

-

Returns: void


cancel

cancel(): void

Overrides MirrorTool.cancel

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:171

Returns: void


cancelUserProgress

cancelUserProgress(id: number): void

Inherited from BoxelTool.cancelUserProgress

Defined in src/tools/Tool.ts:234

Parameters:

Name Type
id number

Returns: void


clickInteraction

clickInteraction(mappingResult: IMapping, interactionData: IInteractionData): Promise‹boolean› | void

Inherited from BoxelTool.clickInteraction

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

Inherited from BoxelTool.consecutiveClick

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: any, interactionData: any): void

Overrides Tool.continueInteraction

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:161

Parameters:

Name Type
mappingResult any
interactionData any

Returns: void


displayUserMessage

displayUserMessage(message: string): void

Inherited from BoxelTool.displayUserMessage

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

Inherited from BoxelTool.displayUserProgress

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

Inherited from BoxelTool.equals

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: any, interactionData: any): void

Overrides Tool.finishInteraction

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:165

Parameters:

Name Type
mappingResult any
interactionData any

Returns: void


finishUserProgress

finishUserProgress(id: number): void

Inherited from BoxelTool.finishUserProgress

Defined in src/tools/Tool.ts:230

Parameters:

Name Type
id number

Returns: void


getAnimationFunction

getAnimationFunction(): function

Inherited from BoxelTool.getAnimationFunction

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

Inherited from BoxelTool.getCanHandleMultipleInteractions

Defined in src/tools/Tool.ts:242

Returns: boolean


getCanWorkWithHints

getCanWorkWithHints(): boolean

Inherited from BoxelTool.getCanWorkWithHints

Defined in src/tools/Tool.ts:238

Returns: boolean


getChosenUiManifestation

getChosenUiManifestation(): IToolManifestation

Inherited from BoxelTool.getChosenUiManifestation

Defined in src/tools/Tool.ts:258

Returns: IToolManifestation


getCompositeModel

getCompositeModel(): CompositeModel | null

Inherited from BoxelTool.getCompositeModel

Defined in src/tools/Tool.ts:307

Returns: CompositeModel | null


getEditor

getEditor(): Editor | null

Inherited from BoxelTool.getEditor

Defined in src/tools/Tool.ts:288

Returns: Editor | null


getHintManager

getHintManager(): HintManager

Inherited from BoxelTool.getHintManager

Defined in src/tools/Tool.ts:311

Returns: HintManager


getInteractionCancelled

getInteractionCancelled(): object

Inherited from BoxelTool.getInteractionCancelled

Defined in src/tools/Tool.ts:188

Returns: object


getInteractionStarted

getInteractionStartedT›(mappings: T): object

Inherited from BoxelTool.getInteractionStarted

Defined in src/tools/Tool.ts:176

Type parameters:

T: AbstractInteractionMapping[]

Parameters:

Name Type Default
mappings T [] as T

Returns: object


getInternalName

getInternalName(): string

Inherited from BoxelTool.getInternalName

Defined in src/tools/Tool.ts:433

Get tool name from the instance

Returns: string


getManifestationParameters

getManifestationParameters(): any

Inherited from BoxelTool.getManifestationParameters

Defined in src/tools/Tool.ts:269

Returns: any

the parameters that were specified in the tool manifestation


getParameters

getParameters(): any

Inherited from BoxelTool.getParameters

Defined in src/tools/Tool.ts:262

Returns: any


getPauseFidelityControl

getPauseFidelityControl(): boolean

Inherited from BoxelTool.getPauseFidelityControl

Defined in src/tools/Tool.ts:254

Returns: boolean


getPausePhysicsSimulation

getPausePhysicsSimulation(): boolean

Inherited from BoxelTool.getPausePhysicsSimulation

Defined in src/tools/Tool.ts:250

Returns: boolean


getRenderContext

getRenderContext(): RenderContext

Inherited from BoxelTool.getRenderContext

Defined in src/tools/Tool.ts:273

Returns: RenderContext


getReproduceInfo

getReproduceInfo(): ISerializableObject

Inherited from BoxelTool.getReproduceInfo

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

Inherited from BoxelTool.getRequiresContinuousModelIntersection

Defined in src/tools/Tool.ts:246

Returns: boolean


getThreeNode

getThreeNode(): Object3D

Inherited from BoxelTool.getThreeNode

Defined in src/tools/Tool.ts:303

Returns the reference to the THREE node

Returns: Object3D


getUiComponentAccessMethod

getUiComponentAccessMethod(): any

Inherited from BoxelTool.getUiComponentAccessMethod

Defined in src/tools/Tool.ts:296

Returns: any


getUndoEngine

getUndoEngine(): UndoEngine

Inherited from BoxelTool.getUndoEngine

Defined in src/tools/Tool.ts:277

Returns: UndoEngine


getUserMessageEventEmitter

getUserMessageEventEmitter(): IPublicEventEmitterInterface‹string›

Inherited from BoxelTool.getUserMessageEventEmitter

Defined in src/tools/Tool.ts:200

Returns: IPublicEventEmitterInterface‹string›


getUserProgressCancelEventEmitter

getUserProgressCancelEventEmitter(): IPublicEventEmitterInterface‹number›

Inherited from BoxelTool.getUserProgressCancelEventEmitter

Defined in src/tools/Tool.ts:212

Returns: IPublicEventEmitterInterface‹number›


getUserProgressEventEmitter

getUserProgressEventEmitter(): IPublicEventEmitterInterfaceIToolUserProgressEvent

Inherited from BoxelTool.getUserProgressEventEmitter

Defined in src/tools/Tool.ts:204

Returns: IPublicEventEmitterInterfaceIToolUserProgressEvent


getUserProgressFinishEventEmitter

getUserProgressFinishEventEmitter(): IPublicEventEmitterInterface‹number›

Inherited from BoxelTool.getUserProgressFinishEventEmitter

Defined in src/tools/Tool.ts:208

Returns: IPublicEventEmitterInterface‹number›


getVisualizationManager

getVisualizationManager(): VisualizationManager

Inherited from BoxelTool.getVisualizationManager

Defined in src/tools/Tool.ts:315

Returns: VisualizationManager


getWakeUpCallback

getWakeUpCallback(): function

Inherited from BoxelTool.getWakeUpCallback

Defined in src/tools/Tool.ts:292

Returns: function

▸ (): void


getWorksInEmptySpace

getWorksInEmptySpace(): boolean

Inherited from BoxelTool.getWorksInEmptySpace

Defined in src/tools/Tool.ts:192

Returns: boolean


getWorksWithConsecutiveClicks

getWorksWithConsecutiveClicks(): boolean

Inherited from BoxelTool.getWorksWithConsecutiveClicks

Defined in src/tools/Tool.ts:196

Returns: boolean


needsReset

needsReset(): boolean

Inherited from BoxelTool.needsReset

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): object | object

Overrides Tool.startInteraction

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:101

Boxel alignment lifecycle: 1. create the boxel - (e.g. boxel, tetra, etc) in this._getCurrentBoxel - also determine "connectors" = non-symmetric base sides of the boxel that we want to attach. Cube only has one. 2. align the boxel (this._alignBoxel) - align the connectors (of the boxel that we want to place) to the base surface - calls BoxelCSG.getBoxelAlignments (mostly wraps GridInferrer.inferGrid) 3. place an unmerged boxel in the world at the determined position 4. start csg operation (_startBoxelOperation), this will place the boxel in BoxelQueue.enqueue. Upon completion, the BoxelQueue will remove the unmerged "candidate" boxel and replace the base with the new base model.

Parameters:

Name Type Description
interactionData IInteractionData

Returns: object | object


Static canHandleInteraction

canHandleInteraction(interactionData: IInteractionData, parameters?: any): CanHandleInteractionResult

Inherited from BoxelTool.canHandleInteraction

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

Overrides BoxelTool.getInternalName

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:69

Returns: string


Static keepLastBoxelUnMerged

keepLastBoxelUnMerged(): boolean

Overrides AssemblePlateTool.keepLastBoxelUnMerged

Defined in src/modules/kyub.core.boxel/src/BoxelTool.ts:73

Returns: boolean


Static onSelected

onSelected(editorInstance: Editor, toolManifestation?: IToolManifestation, parameters?: any): boolean

Inherited from BoxelTool.onSelected

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

Inherited from BoxelTool.onUserDeselected

Defined in src/tools/Tool.ts:92

Parameters:

Name Type
editorInstance Editor

Returns: void


Static requiresHintReset

requiresHintReset(): boolean

Inherited from BoxelTool.requiresHintReset

Defined in src/tools/Tool.ts:100

Defines whether any hints added by previous tools used should be cleared.

Returns: boolean