Skip to content

Commit 4b25ca2

Browse files
committed
changing simulation -> verletjs
1 parent 4ca0bb1 commit 4b25ca2

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

experiments/01-shapes.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen, projection" />
88
<script type="text/javascript" src="../js/common/vec2.js"></script>
99
<script type="text/javascript" src="../js/common/constraint.js"></script>
10-
<script type="text/javascript" src="../js/common/simulation.js"></script>
10+
<script type="text/javascript" src="../js/common/verlet.js"></script>
1111
</head>
1212
<body>
1313
<canvas id="scratch" style="width: 500px; height: 300px;"></canvas>
@@ -27,7 +27,7 @@
2727
canvas.getContext("2d").scale(dpr, dpr);
2828

2929
// simulation
30-
var sim = new VerletSimulation(width, height, canvas);
30+
var sim = new VerletJS(width, height, canvas);
3131

3232
// entities
3333
var segment = sim.lineSegments([new Vec2(20,10), new Vec2(40,10), new Vec2(60,10), new Vec2(80,10), new Vec2(100,10)], 0.02);

experiments/02-angle.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen, projection" />
88
<script type="text/javascript" src="../js/common/vec2.js"></script>
99
<script type="text/javascript" src="../js/common/constraint.js"></script>
10-
<script type="text/javascript" src="../js/common/simulation.js"></script>
10+
<script type="text/javascript" src="../js/common/verlet.js"></script>
1111
</head>
1212
<body>
1313
<canvas id="scratch" style="width: 800px; height: 500px;"></canvas>
@@ -27,7 +27,7 @@
2727
canvas.getContext("2d").scale(dpr, dpr);
2828

2929
// simulation
30-
var sim = new VerletSimulation(width, height, canvas);
30+
var sim = new VerletJS(width, height, canvas);
3131

3232
// entities
3333
var segment = sim.lineSegments([new Vec2(20,10), new Vec2(40,30), new Vec2(60,10)], 0.1);

experiments/03-cloth.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<title>Verlet Spider web - Sub Protocol</title>
4+
<title>Verlet Cloth Simulation - Sub Protocol</title>
55
<meta name="author" content="Sub Protocol" />
66
<meta charset="UTF-8" />
77
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen, projection" />
88
<script type="text/javascript" src="../js/common/vec2.js"></script>
99
<script type="text/javascript" src="../js/common/constraint.js"></script>
10-
<script type="text/javascript" src="../js/common/simulation.js"></script>
10+
<script type="text/javascript" src="../js/common/verlet.js"></script>
1111
</head>
1212
<body>
1313
<canvas id="scratch" style="width: 800px; height: 500px; background: #000;"></canvas>
@@ -28,7 +28,7 @@
2828
canvas.getContext("2d").scale(dpr, dpr);
2929

3030
// simulation
31-
var sim = new VerletSimulation(width, height, canvas);
31+
var sim = new VerletJS(width, height, canvas);
3232
sim.highlightColor = "#fff";
3333

3434
// entities

experiments/04-spiderweb.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<title>Verlet Spider web - Sub Protocol</title>
4+
<title>Verlet Spider Simulation - Sub Protocol</title>
55
<meta name="author" content="Sub Protocol" />
66
<meta charset="UTF-8" />
77
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen, projection" />
88
<script type="text/javascript" src="../js/common/vec2.js"></script>
99
<script type="text/javascript" src="../js/common/constraint.js"></script>
10-
<script type="text/javascript" src="../js/common/simulation.js"></script>
10+
<script type="text/javascript" src="../js/common/verlet.js"></script>
1111
</head>
1212
<body>
1313
<canvas id="scratch" style="width: 800px; height: 500px;"></canvas>
1414
<script type="text/javascript">
1515

16-
VerletSimulation.prototype.spider = function(origin) {
16+
VerletJS.prototype.spider = function(origin) {
1717
var i;
1818
var legSeg1Stiffness = 0.95;
1919
var legSeg2Stiffness = 0.95;
@@ -90,7 +90,7 @@
9090
return composite;
9191
}
9292

93-
VerletSimulation.prototype.spiderweb = function(origin, radius, segments, depth) {
93+
VerletJS.prototype.spiderweb = function(origin, radius, segments, depth) {
9494
var stiffness = 0.6;
9595
var tensor = 0.3;
9696
var stride = (2*Math.PI)/segments;
@@ -139,7 +139,7 @@
139139
return o;
140140
}
141141

142-
VerletSimulation.prototype.crawl = function(leg) {
142+
VerletJS.prototype.crawl = function(leg) {
143143

144144
var stepRadius = 100;
145145
var minStepRadius = 40;
@@ -216,7 +216,7 @@
216216
canvas.getContext("2d").scale(dpr, dpr);
217217

218218
// simulation
219-
var sim = new VerletSimulation(width, height, canvas);
219+
var sim = new VerletJS(width, height, canvas);
220220

221221
// entities
222222
var spiderweb = sim.spiderweb(new Vec2(width/2,height/2), Math.min(width, height)/2, 20, 7);

js/common/simulation.js renamed to js/common/verlet.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Particle.prototype.draw = function(ctx) {
2121
ctx.fill();
2222
}
2323

24-
var VerletSimulation = function(width, height, canvas) {
24+
var VerletJS = function(width, height, canvas) {
2525
this.width = width;
2626
this.height = height;
2727
this.canvas = canvas;
@@ -65,29 +65,29 @@ var VerletSimulation = function(width, height, canvas) {
6565
this.composites = [];
6666
}
6767

68-
VerletSimulation.prototype.Composite = function() {
68+
VerletJS.prototype.Composite = function() {
6969
this.particles = [];
7070
this.constraints = [];
7171

7272
this.drawParticles = null;
7373
this.drawConstraints = null;
7474
}
7575

76-
VerletSimulation.prototype.Composite.prototype.pin = function(index, pos) {
76+
VerletJS.prototype.Composite.prototype.pin = function(index, pos) {
7777
pos = pos || this.particles[index].pos;
7878
var pc = new PinConstraint(this.particles[index], pos);
7979
this.constraints.push(pc);
8080
return pc;
8181
}
8282

83-
VerletSimulation.prototype.point = function(pos) {
83+
VerletJS.prototype.point = function(pos) {
8484
var composite = new this.Composite();
8585
composite.particles.push(new Particle(pos));
8686
this.composites.push(composite);
8787
return composite;
8888
}
8989

90-
VerletSimulation.prototype.lineSegments = function(vertices, stiffness) {
90+
VerletJS.prototype.lineSegments = function(vertices, stiffness) {
9191
var i;
9292

9393
var composite = new this.Composite();
@@ -102,7 +102,7 @@ VerletSimulation.prototype.lineSegments = function(vertices, stiffness) {
102102
return composite;
103103
}
104104

105-
VerletSimulation.prototype.cloth = function(origin, width, height, segments, pinMod, stiffness) {
105+
VerletJS.prototype.cloth = function(origin, width, height, segments, pinMod, stiffness) {
106106

107107
var composite = new this.Composite();
108108

@@ -134,7 +134,7 @@ VerletSimulation.prototype.cloth = function(origin, width, height, segments, pin
134134
}
135135

136136

137-
VerletSimulation.prototype.tire = function(origin, radius, segments, spokeStiffness, treadStiffness) {
137+
VerletJS.prototype.tire = function(origin, radius, segments, spokeStiffness, treadStiffness) {
138138
var stride = (2*Math.PI)/segments;
139139
var i;
140140

@@ -161,7 +161,7 @@ VerletSimulation.prototype.tire = function(origin, radius, segments, spokeStiffn
161161
}
162162

163163

164-
VerletSimulation.prototype.frame = function(step) {
164+
VerletJS.prototype.frame = function(step) {
165165
var i, j, c;
166166

167167
for (c in this.composites) {
@@ -219,7 +219,7 @@ VerletSimulation.prototype.frame = function(step) {
219219
}
220220
}
221221

222-
VerletSimulation.prototype.draw = function() {
222+
VerletJS.prototype.draw = function() {
223223
var i, c;
224224

225225
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
@@ -259,7 +259,7 @@ VerletSimulation.prototype.draw = function() {
259259
}
260260
}
261261

262-
VerletSimulation.prototype.nearestEntity = function() {
262+
VerletJS.prototype.nearestEntity = function() {
263263
var c, i;
264264
var d2Nearest = 0;
265265
var entity = null;

0 commit comments

Comments
 (0)