DistanceConstraint

Defines one or many relationships between sets of two particles.

var a = 0, b = 1, c = 2
var single = DistanceConstraint.create(10, a, b)
var many = DistanceConstraint.create(10, [a, b, a, c])

Particles are constrained by a fixed distance or a distance range.

var min = 0.5, max = 2.5
var fixed = DistanceConstraint.create(max, 0, 1)
var range = DistanceConstraint.create([min, max], 0, 1)
DistanceConstraint( distance, a, [b] )
src/constraints/DistanceConstraint.js:14
  • distance Float | Array

    Distance or distance range [min, max] between particles

  • a Int | Array

    Particle index or list of many constraint sets

  • [b] Int

    Particle index (only used if a is not an array)

applyConstraint( index, p0, p1 ) protected
Defined in Constraint: src/constraints/Constraint.js:90

Apply constraint to one set of particles defining a constrint relation. Called _count times per relaxation loop.

  • index Int

    Constraint set index

  • p0 Float32Array (Vec3)

    Reference to ParticleSystem.positions

  • p1 Float32Array (Vec3)

    Reference to ParticleSystem.positionsPrev

create( ) static
src/constraints/DistanceConstraint.js:48

Create instance, accepts constructor arguments.

setDistance( min, [max] )
src/constraints/DistanceConstraint.js:56

Set distance

  • min Float
  • [max] Float
setIndices( indices, [a] )
Defined in Constraint: src/constraints/Constraint.js:73

Set particle indices with Array or list of arguments.

  • indices Int | Array

    Single or many particle indices

  • [a] Int (*..n)

    Particle index

setMax( max )
src/constraints/DistanceConstraint.js:87

Set maximum distance

  • max Float
setMin( min )
src/constraints/DistanceConstraint.js:68

Set minimum distance

  • min Float
_count Int private
src/constraints/Constraint.js:37

Number of constraint relations managed by this instance

_itemSize Int private
src/constraints/Constraint.js:46

Number of particles per constraint relation

_max2 Float private
src/constraints/DistanceConstraint.js:97

Cached value of maximum distance squared

_min2 Float private
src/constraints/DistanceConstraint.js:78

Cached value of minimum distance squared

_offset Int private
src/constraints/Constraint.js:55

Number of indices to save at beginning of index array

indices Uint16Array
src/constraints/Constraint.js:29

Particle indices defining constraint relations