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 | ArrayDistance or distance range
[min, max]
between particles -
a
Int | ArrayParticle index or list of many constraint sets
-
[b]
IntParticle index (only used if
a
is not an array)
applyConstraint
( index, p0, p1
)
protected
src/constraints/Constraint.js:90
Apply constraint to one set of particles defining a constrint relation.
Called _count
times per relaxation loop.
-
index
IntConstraint 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]
)
src/constraints/Constraint.js:73
Set particle indices with Array
or list of arguments
.
-
indices
Int | ArraySingle or many particle indices
-
[a]
Int (*..n)Particle index
_count
Int
private
src/constraints/Constraint.js:37
Number of constraint relations managed by this instance
_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