SubSlopeComponent2D
Summary
Creates and draws subslopes in 2D.
Constructor
SubSlopeComponent2D
Syntax
SubSlopeComponent2D
-
core
Summary
Parameters:
-
core
wnp.CoreWanaplan core.
Item Index
Methods
- destroy
- disable
- draw
- drawOnWall
- enable
- getSubSlopes
- getTargeted
- initialize
- onContextChanged
- onContextMenu
- onDragEnd
- onDragging
- onDragStart
- onDynamicDraw
- onEditSubSlope
- onHover
- onLeave
- onStaticDraw
- splitSubSlope
- startListening
- stopListening
- subslope-end
- update
- updateSubslopeFromRoof
- wnp.engine2d.onModeSubSlopeEnd
Properties
Events
Methods
destroy
Syntax
destroy
()
Summary
Method called when the component is destroyeddisable
Syntax
disable
()
Summary
Disables the componentdraw
Syntax
draw
-
ctx
-
translation
-
zoom
Summary
Draws all the subslopes for the current floor on the canvas.
Parameters:
-
ctx
CanvasRenderingContext2DContext 2D of the canvas.
-
translation
BABYLON.Vector2The translation on the canvas.
-
zoom
NumberThe current zoom of the canvas.
drawOnWall
Syntax
drawOnWall
-
ctx
-
translation
-
zoom
-
subSlope
Summary
Draws a single subslope.
Parameters:
-
ctx
CanvasRenderingContext2DContext 2D of the canvas.
-
translation
BABYLON.Vector2The translation on the canvas.
-
zoom
NumberThe current zoom of the canvas.
-
subSlope
SubSlopeStructureConcerned SubSlopeStructure.
enable
Syntax
enable
()
Summary
Enables the componentgetSubSlopes
Syntax
Summary
Gets the list of subslopes for a given floor.
Parameters:
-
force
BooleanForces the subslopes to be updated.
-
[structure]
FloorStructure optionalThe related floor. Currently selected floor by default.
Returns:
The computed subslopes.
getTargeted
Syntax
Summary
Finds out if the given position is over an element handled by the componentParameters:
-
vector
VectorA position, usually the cursor's one.
Returns:
The targeted element, or null if nothing is found.
initialize
Syntax
initialize
()
Summary
Method called when Wanaplan is initialized. You don't need to call this method manually.onContextChanged
Syntax
onContextChanged
-
context
Summary
Method called when the context is switched (2D -> 3D or 3D -> 2D)Parameters:
-
context
StringThe new context
onContextMenu
Syntax
onContextMenu
-
event
-
target
-
mstate
-
data
Summary
When the popup of the roof has to be opened.
Parameters:
-
event
EventThe JS event.
-
target
SubSlopeStructureThe subslope structure hovered by the mouse.
-
mstate
ObjectThe state of the mouse.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onDragEnd
Syntax
onDragEnd
-
event
-
target
-
mstate
-
data
Summary
When the mouse stops dragging the subslope.
Parameters:
-
event
EventThe JS event.
-
target
SubSlopeStructureThe subslope structure.
-
mstate
ObjectThe state of the mouse.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onDragging
Syntax
onDragging
-
event
-
target
-
mstate
-
data
Summary
When the mouse is dragging the subslope.
Parameters:
-
event
EventThe JS event.
-
target
SubSlopeStructureThe subslope structure dragging by the mouse.
-
mstate
ObjectThe state of the mouse.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onDragStart
Syntax
onDragStart
-
event
-
target
-
mstate
-
data
Summary
When the mouse begins to drag the subslope.
Parameters:
-
event
EventThe JS event.
-
target
SubSlopeStructureThe subslope structure dragged by the mouse.
-
mstate
ObjectThe state of the mouse.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onDynamicDraw
Syntax
onDynamicDraw
-
ctx
-
translation
-
zoom
-
data
Summary
Triggered on dynamic canvas draw request
onEditSubSlope
Syntax
onEditSubSlope
()
private
Summary
Function called when the user clicks on the subslope button and is in MODE_SUBSLOPE in the engine2D.
Triggered on event wnp.engine2d.onEditSubSlope
.
onHover
Syntax
onHover
-
event
-
target
-
mstate
-
data
Summary
When the mouse hovers over the subslope.
Parameters:
-
event
EventThe JS event.
-
target
SubSlopeStructureThe subslope structure hovered by the mouse.
-
mstate
ObjectThe state of the mouse.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onLeave
Syntax
onLeave
-
event
-
target
-
mstate
-
data
Summary
When the mouse leaves the subslope.
Parameters:
-
event
EventThe JS event.
-
target
SubSlopeStructureThe subslope structure left by the mouse.
-
mstate
ObjectThe state of the mouse.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onStaticDraw
Syntax
onStaticDraw
-
ctx
-
translation
-
zoom
-
data
Summary
Triggered on static canvas draw request
splitSubSlope
Syntax
splitSubSlope
-
sSS
-
dSS
Summary
Splits a subslope into two subslopes, with the help of a subslope divider.
Parameters:
-
sSS
SubSlopeStructureThe subslope to divide.
-
dSS
SubSlopeStructureThe subslope divider.
startListening
Syntax
startListening
()
Summary
Calls all the event listeners.stopListening
Syntax
stopListening
()
Summary
Removes all the event listeners.subslope-end
Syntax
subslope-end
()
private
Summary
Function called when the user goes back to normal mode and skips the drawing of the subslope.
update
Syntax
update
()
Summary
Generic update method, called on every frameupdateSubslopeFromRoof
Syntax
updateSubslopeFromRoof
-
roof
Summary
Copies the settings of the subslope contained in a roof to its parent subslope.
Parameters:
-
roof
RoofStructureThe roof structure.
wnp.engine2d.onModeSubSlopeEnd
Syntax
wnp.engine2d.onModeSubSlopeEnd
()
private
Summary
Function called when the user goes back to the MODE_NORMAL.
Triggered on event wnp.engine2d.onModeSubSlopeEnd
.
Properties
_default
Syntax
Summary
Stores the properties that the user wants applied to all roofs (copied when creating a new subslope on a wall)
_HANDLESTATICSTYLE
Syntax
_HANDLESTATICSTYLE
String
Summary
2D display style (static color).
Default: 'rgba(60,82,129,0.8)'
priority
Syntax
Summary
Priority of the component for update callbacks.
Default: 100
structure
Syntax
structure
wnp.Structure
Summary
Structure file instance (shortcut to wanaplan.structure). This is the base object where the whole plan is savedsubSlopes
Syntax
Summary
Currently computed subSlopes for caching purposes.
Events
wnp.subslope.drag-end
Syntax
wnp.subslope.drag-end
Summary
Fired when the user stops dragging the subslope.