Module

Hylograph.Forces.ThreeD.Position

Package
purescript-hylograph-forces
Repository
afcondon/purescript-hylograph-forces

The positioning forces in three dimensions: pull each node towards a target x, y or z.

Ported from d3-force-3d 3.0.6, x.js, y.js and z.js (MIT, Copyright 2017 Vasco Asturiano; itself from d3-force, ISC, Mike Bostock); see LICENSE. x.js and y.js are d3-force's unchanged; z.js is the same on the third axis.

#Config Source

type Config :: Row Type -> Typetype Config row = { strength :: Node row -> Number, target :: Node row -> Number }

forceX / forceY / forceZ settings. target and strength are asked once per node when the force is initialized.

#defaultConfig Source

defaultConfig :: forall row. Config row

d3's defaults: towards zero, at strength 0.1.

#Position Source

newtype Position :: Row Type -> Typenewtype Position row

An initialized positioning force. The axis it acts along is decided by which of applyX, applyY and applyZ it is given to.

#initialize Source

initialize :: forall row. Config row -> Array (Node row) -> Position row

d3's force.initialize(nodes). A node whose target is NaN gets strength zero.

#applyX Source

applyX :: forall row. Position row -> Number -> Effect Unit

node.vx += (target - node.x) * strength * alpha.

#applyY Source

applyY :: forall row. Position row -> Number -> Effect Unit

node.vy += (target - node.y) * strength * alpha.

#applyZ Source

applyZ :: forall row. Position row -> Number -> Effect Unit

node.vz += (target - node.z) * strength * alpha.