pivotick / Simulation
Interface: Simulation
Defined in: Simulation.ts:174
Methods
applyPhysicsPreset()
applyPhysicsPreset(
name):void
Defined in: Simulation.ts:972
Apply a named preset (PHYSICS_PRESETS): sets every knob and reheats once, at CLICK_REHEAT_ALPHA rather than the slider default — a preset describes a whole layout, and reaching it from a settled graph takes a fresh layout's worth of travel.
Parameters
name
Returns
void
changeLayout()
changeLayout(
type,simulationOptions):Promise<void>
Defined in: Simulation.ts:1524
Allows to change the layout of the graph
Parameters
type
simulationOptions
DeepPartial<SimulationOptions> = {}
Returns
Promise<void>
Example
changeLayout('tree', {
layout: {
horizontal: false,
rootIdAlgorithmFinder: 'FirstZeroInDegree'
}
})destroy()
destroy():
void
Defined in: Simulation.ts:365
Stop the engine and release the container observer.
Returns
void
disable()
disable():
void
Defined in: Simulation.ts:569
Returns
void
disableAutoPhysics()
disableAutoPhysics():
void
Defined in: Simulation.ts:1216
Turn Auto off, leaving the knobs wherever they currently sit.
Returns
void
enable()
enable():
void
Defined in: Simulation.ts:563
Returns
void
enableAutoPhysics()
enableAutoPhysics():
void
Defined in: Simulation.ts:1210
Turn Auto on and tune immediately. force because this is the Auto button: an answer inside the deadband would otherwise make the click do nothing visible.
Returns
void
enableAutoTreeSpacing()
enableAutoTreeSpacing():
void
Defined in: Simulation.ts:1111
Hand the tree spacing back to the tuner, which re-derives both multipliers from the node sizes and tree shape and keeps doing so as the graph changes. The counterpart of setTreeSpacing. No-op under the force layout, where Auto is enableAutoPhysics.
Returns
void
getForceSimulation()
getForceSimulation():
SimulationForces
Defined in: Simulation.ts:1503
Returns
getLabelSide()
getLabelSide(
id):LabelSide|undefined
Defined in: Simulation.ts:1039
Which side of its node a node's floated label goes on, when the layout chose one — only the structured layout does.
Parameters
id
string
Returns
LabelSide | undefined
getLayoutType()
getLayoutType():
LayoutType
Defined in: Simulation.ts:1010
The active layout type — the Physics flyout greys out physics under non-force layouts.
Returns
getPhysicsKnobs()
getPhysicsKnobs():
PhysicsKnobs
Defined in: Simulation.ts:1005
Current knob values, for seeding the Physics-flyout sliders.
Returns
getSimulation()
getSimulation():
Simulation<Node,undefined>
Defined in: Simulation.ts:1507
Returns
Simulation<Node, undefined>
getTreeRoot()
getTreeRoot():
TreeRoot
Defined in: Simulation.ts:1076
Where the active tree hangs from. Under the force layout there is no tree, so this reports the finder a tree would start with and no pin.
Returns
getTreeSpacing()
getTreeSpacing():
TreeSpacing
Defined in: Simulation.ts:1044
The active tree layout's spacing multipliers; 1× under the force layout.
Returns
isAutoPhysicsEnabled()
isAutoPhysicsEnabled():
boolean
Defined in: Simulation.ts:1202
Is the Auto preset currently driving the knobs?
Returns
boolean
isAutoTreeSpacingEnabled()
isAutoTreeSpacingEnabled():
boolean
Defined in: Simulation.ts:1101
Is the tree spacing tuning itself? false under the force layout.
Returns
boolean
isDragging()
isDragging():
boolean
Defined in: Simulation.ts:1460
Returns
boolean
isEnabled()
isEnabled():
boolean
Defined in: Simulation.ts:737
Returns
boolean
isFitViewOnExpandCollapse()
isFitViewOnExpandCollapse():
boolean
Defined in: Simulation.ts:1484
Returns
boolean
isFreezeNodesOnDrag()
isFreezeNodesOnDrag():
boolean
Defined in: Simulation.ts:1472
Returns
boolean
isGridSnappingEnabled()
isGridSnappingEnabled():
boolean
Defined in: Simulation.ts:1476
Returns
boolean
pause()
pause():
void
Defined in: Simulation.ts:577
Pause the simulation
Returns
void
refreshForcesAndReheat()
refreshForcesAndReheat(
alpha):void
Defined in: Simulation.ts:874
Re-read the node-dependent force accessors and reheat. d3-force caches per-node radius/strength when a force is initialised, not per tick, so a radius mutated mid-run has no effect until the nodes are re-set. For a custom node that measures itself after the opening layout has cooled. No-op when disabled.
Parameters
alpha
number = 0.5
Returns
void
reheat()
reheat(
alpha):void
Defined in: Simulation.ts:861
Restart the simulation with a bit of heat
Parameters
alpha
number = 0.7
Returns
void
restart()
restart():
void
Defined in: Simulation.ts:585
Restart the simulation with rendering on each animation frame.
Returns
void
setCentering()
setCentering(
knob):void
Defined in: Simulation.ts:942
Pull toward the canvas centre. Knob 0–100 → d3GravityStrengthConnected, with d3GravityStrength (isolated nodes) following as a fixed multiple. Separate components only repel each other, so this is the only thing keeping them in frame.
Parameters
knob
number
Returns
void
setCollisionRadius()
setCollisionRadius(
knob):void
Defined in: Simulation.ts:919
Node spacing. Knob 4–60 → d3CollideRadiusMultiplier (scales each node's collision radius).
Parameters
knob
number
Returns
void
setFriction()
setFriction(
knob):void
Defined in: Simulation.ts:929
Motion damping. Knob 0–100 → d3VelocityDecay (÷100). Applied live each tick — no reheat.
Parameters
knob
number
Returns
void
setLinkDistance()
setLinkDistance(
knob):void
Defined in: Simulation.ts:909
Preferred edge length. Knob 40–600 (px) → d3LinkDistance.
Parameters
knob
number
Returns
void
setRepulsion()
setRepulsion(
knob):void
Defined in: Simulation.ts:898
Push-apart strength. Knob 0–100 → d3ManyBodyStrength.
Parameters
knob
number
Returns
void
setSettleTime()
setSettleTime(
knob):void
Defined in: Simulation.ts:958
How long the layout is given to settle, in seconds. Knob 0.5–8 → d3AlphaDecay and cooldownTime together: alpha decay sets how fast the sim cools, cooldown is the wall-clock wall that stops it. Moving either alone does nothing — raise the cooldown and the sim is already cold; slow the decay and the wall truncates it.
Parameters
knob
number
Returns
void
setTreeRoot()
setTreeRoot(
root):void
Defined in: Simulation.ts:1088
Re-hang the tree from another root: { rootId } pins it to that node, { algorithm } drops the pin and lets the finder choose. No-op under the force layout, which has no hierarchy to root.
A pinned root is walked ignoring edge direction, so any node — a leaf included — gives a whole tree rather than a stump beside the old one. See TreeLayout.setRoot.
Parameters
root
{ rootId: string; } | { algorithm: TreeLayoutAlgorithm; }
Returns
void
setTreeSpacing()
setTreeSpacing(
spacing):void
Defined in: Simulation.ts:1055
Re-lay-out the tree at new spacing multipliers (TREE_SPACING_RANGE). No-op under the force layout, where spacing is the physics knobs' job.
A redraw and a reheat: the pinned axis moves immediately, so the change shows even with physics paused, while the free axis still settles into its new sibling slots.
Parameters
spacing
Partial<TreeSpacing>
Returns
void
snapToGrid()
snapToGrid(
value):number
Defined in: Simulation.ts:1499
Snap a graph-space coordinate to the grid when grid-snapping is enabled (a no-op otherwise). Public so non-simulation draggables (e.g. notes) can snap on the same grid as nodes.
Parameters
value
number
Returns
number
start()
start(
recomputeLayout):Promise<void>
Defined in: Simulation.ts:595
Start the simulation with rendering on each animation frame.
Parameters
recomputeLayout
boolean = true
Returns
Promise<void>
stop()
stop():
void
Defined in: Simulation.ts:628
Manually stop the simulation and cancel animation frame.
Returns
void
toggleFitViewOnExpandCollapse()
toggleFitViewOnExpandCollapse():
void
Defined in: Simulation.ts:1480
Returns
void
toggleFreezeNodesOnDrag()
toggleFreezeNodesOnDrag():
void
Defined in: Simulation.ts:1468
Returns
void
toggleGridSnapping()
toggleGridSnapping():
void
Defined in: Simulation.ts:1464
Returns
void
update()
update():
void
Defined in: Simulation.ts:486
Returns
void
waitForSimulationStop()
waitForSimulationStop():
Promise<void>
Defined in: Simulation.ts:723
Returns a promise that resolves when the simulation stops naturally. Useful for performing actions (like fitAndCenter) after stabilization.
Returns
Promise<void>