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] )
  • 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

Create instance, accepts constructor arguments.

setDistance( min, [max] )

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 )

Set maximum distance

  • max Float
setMin( min )

Set minimum distance

  • min Float
_count Int private

Number of constraint relations managed by this instance

_itemSize Int private

Number of particles per constraint relation

_max2 Float private

Cached value of maximum distance squared

_min2 Float private

Cached value of minimum distance squared

_offset Int private

Number of indices to save at beginning of index array

indices Uint16Array

Particle indices defining constraint relations