Hylograph.Simulation.Scene
- Package
- purescript-hylograph-simulation
- Repository
- afcondon/purescript-hylograph-simulation
Scene Orchestration Module (Legacy)
This module re-exports from the new Hylograph.Scene modules for backwards compatibility.
It also provides the applyRulesInPlace_ FFI which preserves object identity
for D3 data binding.
For new code, prefer importing from:
Hylograph.Scene.Types(types)Hylograph.Scene.Rules(rule helpers)Hylograph.Scene.Engine(orchestration)
#applyRules Source
applyRules :: forall node. Array (NodeRule node) -> Array node -> Array nodeApply rules to nodes (first matching rule wins) - creates new array
Re-exports from Hylograph.Scene.Types
#TransitionState Source
type TransitionState node = { progress :: Progress, startPositions :: PositionMap, targetPositions :: PositionMap, targetScene :: SceneConfig node }Runtime state during an active transition.
Tracks the target scene, start/end positions, and current progress. The interpolation engine updates progress each tick until complete. Uses tick-based progress (0.0 to 1.0) rather than time-based elapsed.
#SceneConfig Source
type SceneConfig node = { finalRules :: Array node -> Array (NodeRule node), initRules :: Array (NodeRule node), layout :: Array node -> PositionMap, name :: String, stableMode :: EngineMode }Scene configuration with three-phase lifecycle.
Phase 1: Initialize (initRules)
Applied before transition starts. Use this to set up starting positions,
e.g., moving tree nodes to the root for a "grow from root" animation.
Phase 2: Transition (layout)
The interpolation engine smoothly moves nodes from their current positions
to the target positions computed by the layout function.
Phase 3: Finalize (finalRules)
Applied after transition completes. Use this to set up the stable state,
e.g., unpinning nodes so forces can take over, or setting gridX/gridY.
Example:
treeFormScene :: SceneConfig MyNode
treeFormScene =
{ name: "TreeForm"
, initRules: [ moveToRootRule ]
, layout: \nodes -> computeTreePositions nodes
, finalRules: \_ -> [ pinAtTreePositionsRule ]
, stableMode: Static
}
#PositionMap Source
type PositionMap = Object PositionPosition map: node ID (as string) -> position Used for capturing current positions and specifying targets
#NodeRule Source
type NodeRule node = { apply :: node -> node, name :: String, select :: node -> Boolean }A rule that selects nodes and applies a transform.
Rules are applied with first-match-wins semantics (like CSS cascade). If multiple rules match a node, only the first one applies.
Example:
pinPackages :: NodeRule MyNode
pinPackages =
{ name: "pinPackages"
, select: \n -> n.nodeType == Package
, apply: \n -> n { fx = notNull n.x, fy = notNull n.y }
}
#EngineMode Source
data EngineModeEngine mode determines what happens after a transition completes.
Physics: D3 force simulation runs, nodes settle via forcesStatic: Nodes stay pinned at their final positions
Constructors
Instances
- Modules
- Hylograph.
Config. Apply - Hylograph.
Config. Force - Hylograph.
Config. Scene - Hylograph.
ForceEngine - Hylograph.
ForceEngine. Core - Hylograph.
ForceEngine. Demo - Hylograph.
ForceEngine. Events - Hylograph.
ForceEngine. Links - Hylograph.
ForceEngine. Registry - Hylograph.
ForceEngine. Render - Hylograph.
ForceEngine. Setup - Hylograph.
ForceEngine. Setup. WASM - Hylograph.
ForceEngine. Simulation - Hylograph.
ForceEngine. Types - Hylograph.
ForceEngine. WASM - Hylograph.
ForceEngine. WASMEngine - Hylograph.
Scene. Engine - Hylograph.
Scene. Handle - Hylograph.
Scene. Rules - Hylograph.
Scene. Types - Hylograph.
Simulation - Hylograph.
Simulation. Emitter - Hylograph.
Simulation. HATS - Hylograph.
Simulation. Scene - Hylograph.
Transition. Consumers - Hylograph.
Transition. Example