新增verlet物理引擎(实验性)

This commit is contained in:
yhh
2021-07-02 18:25:30 +08:00
parent 3d9c8699e7
commit 85bdd97d48
15 changed files with 1142 additions and 23 deletions

View 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;
}
}
}