Skip to content

Commit ba77e6f

Browse files
committed
showing pin points on cloth example
1 parent d1beb71 commit ba77e6f

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

examples/03-cloth.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
var cloth = sim.cloth(new Vec2(width/2,height/3), min, min, segments, 6, 0.9);
3939

4040
cloth.drawConstraints = function(ctx, composite) {
41-
}
42-
43-
cloth.drawParticles = function(ctx, composite) {
44-
4541
var stride = min/segments;
4642
var x,y;
4743
for (y=1;y<segments;++y) {
@@ -70,6 +66,21 @@
7066
ctx.fill();
7167
}
7268
}
69+
70+
var c;
71+
for (c in composite.constraints) {
72+
if (composite.constraints[c] instanceof PinConstraint) {
73+
var point = composite.constraints[c];
74+
ctx.beginPath();
75+
ctx.arc(point.pos.x, point.pos.y, 1.2, 0, 2*Math.PI);
76+
ctx.fillStyle = "rgba(255,255,255,1)";
77+
ctx.fill();
78+
}
79+
}
80+
}
81+
82+
cloth.drawParticles = function(ctx, composite) {
83+
// do nothing for particles
7384
}
7485

7586
// animation loop

0 commit comments

Comments
 (0)