新增verlet物理引擎(实验性)
This commit is contained in:
20
source/src/Physics/Verlet/Composites/LineSegments.ts
Normal file
20
source/src/Physics/Verlet/Composites/LineSegments.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
module es {
|
||||
export class LineSegments extends Composite {
|
||||
constructor(vertices: Vector2[], stiffness: number) {
|
||||
super();
|
||||
|
||||
for (let i = 0; i < vertices.length; i ++) {
|
||||
const p = new Particle(vertices[i]);
|
||||
this.addParticle(p);
|
||||
|
||||
if (i > 0)
|
||||
this.addConstraint(new DistanceConstraint(this.particles[i], this.particles[i - 1], stiffness));
|
||||
}
|
||||
}
|
||||
|
||||
public pinParticleAtIndex(index: number): LineSegments {
|
||||
this.particles[index].pin();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user