SubSlopeComponent2D Class
Creates and draws subslopes in 2D.
Constructor
SubSlopeComponent2D
-
core
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
()
disable
()
draw
-
ctx
-
translation
-
zoom
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
-
ctx
-
translation
-
zoom
-
subSlope
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
()
getSubSlopes
-
force
-
[structure]
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
-
vector
Parameters:
-
vector
VectorA position, usually the cursor's one.
Returns:
The targeted element, or null if nothing is found.
initialize
()
onContextChanged
-
context
Parameters:
-
context
StringThe new context
onContextMenu
-
event
-
target
-
mstate
-
data
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
-
event
-
target
-
mstate
-
data
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
-
event
-
target
-
mstate
-
data
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
-
event
-
target
-
mstate
-
data
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
-
ctx
-
translation
-
zoom
-
data
Triggered on dynamic canvas draw request
Parameters:
-
ctx
CanvasRenderingContext2D2D Context of the canvas.
-
translation
BABYLON.Vector2The translation on the canvas.
-
zoom
NumberThe current zoom of the canvas.
-
data
ObjectData used for the drawing. Can be null or something else if you wish to override the function.
onEditSubSlope
()
private
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
-
event
-
target
-
mstate
-
data
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
-
event
-
target
-
mstate
-
data
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
-
ctx
-
translation
-
zoom
-
data
Triggered on static canvas draw request
Parameters:
-
ctx
CanvasRenderingContext2DContext 2D of the canvas.
-
translation
BABYLON.Vector2The translation on the canvas.
-
zoom
NumberThe current zoom of the canvas.
-
data
ObjectImportant data used for the draw (null).
splitSubSlope
-
sSS
-
dSS
Splits a subslope into two subslopes, with the help of a subslope divider.
Parameters:
-
sSS
SubSlopeStructureThe subslope to divide.
-
dSS
SubSlopeStructureThe subslope divider.
startListening
()
stopListening
()
subslope-end
()
private
Function called when the user goes back to normal mode and skips the drawing of the subslope.
update
()
updateSubslopeFromRoof
-
roof
Copies the settings of the subslope contained in a roof to its parent subslope.
Parameters:
-
roof
RoofStructureThe roof structure.
wnp.engine2d.onModeSubSlopeEnd
()
private
Function called when the user goes back to the MODE_NORMAL.
Triggered on event wnp.engine2d.onModeSubSlopeEnd
.
Properties
_default
SubSlopeStructure
private
Stores the properties that the user wants applied to all roofs (copied when creating a new subslope on a wall)
structure
wnp.Structure
Events
wnp.subslope.drag-end
Fired when the user stops dragging the subslope.