Skip to content

Commit 26195ab

Browse files
committed
fixed multi instance variable collision bug / improved internal renderer / v1.1.4
1 parent 1ba17f2 commit 26195ab

File tree

21 files changed

+134
-99
lines changed

21 files changed

+134
-99
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [1.1.4] - 05-07-2019
8+
### Fixed
9+
- independent internal rendering engine
10+
- multiple instance of verly.js was causing global var collisions (WIDTH, HEIGHT, CTX)
11+
### Changed
12+
- Entity.js Class now expects two arguments (iteration, verlyInstance) because previously we used global variables to keep track of WIDTH, HEIGHT and ctx which was casing some problems
13+
- When extending Entity class we have to do super(iteration, verlyInstance)
14+
- Point.js Class's render, constrain, update methods now expects verlyInstance and ctx variables to be passed.

dist/verly.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/verly.bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/behavior.html

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,32 +45,26 @@
4545
mouse.setForceAcc(-30);
4646
mouse.setRadius(100);
4747

48-
48+
4949
let mBehavior = 2;
5050
window.addEventListener('mousemove', (e) => {
51-
if (e.altKey) {
52-
addParticles(e.offsetX, e.offsetY);
53-
}
54-
mouse.pos.x = e.offsetX;
55-
mouse.pos.y = e.offsetY;
51+
if (e.altKey) addParticles(e.offsetX, e.offsetY);
52+
mouse.pos.setXY(e.offsetX, e.offsetY)
5653
})
54+
window.addEventListener('mousedown', () => mBehavior = -5)
55+
window.addEventListener('mouseup', () => mBehavior = 5)
5756

58-
window.addEventListener('mousedown', () => {
59-
mBehavior = -5;
60-
})
61-
window.addEventListener('mouseup', () => {
62-
mBehavior = 5;
63-
})
6457

6558

66-
let particles = new Entity();
59+
let particles = new Entity(16, verly);
6760
function addParticles(x, y) {
6861
let p = new Point(x, y);
6962
p.setRadius(3);
7063
p.setGravity(new Vector(0, 0));
7164
particles.addPoint(p);
7265
}
73-
for (let i = 0; i < 1000; i++) {
66+
67+
for (let i = 0; i < 700; i++) {
7468
addParticles(random(width), random(height));
7569
}
7670

@@ -83,15 +77,15 @@
8377
for (let i = 0; i < particles.points.length; i++) {
8478
for (let j = 0; j < particles.points.length; j++) {
8579
if (particles.points[i] !== particles.points[j]) {
86-
particles.points[j].resolveBehaviors(particles.points[i], 20, 2)
80+
particles.points[j].resolveBehaviors(particles.points[i], 20, 3)
8781
}
8882
}
8983
particles.points[i].resolveBehaviors(mouse, mouse.radius, mBehavior)
9084
}
9185

9286
verly.update();
9387
verly.render();
94-
verly.interact();
88+
// verly.interact();
9589

9690
// verly.renderPointIndex();
9791

examples/behavior2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
let verly = new Verly(16, canvas, ctx);
4646

47-
let particle = new Entity();
47+
let particle = new Entity(16, verly);
4848
let p1 = new Point(0, 0);
4949
let p2 = new Point(0, 0);
5050
p1.setRadius(20);

examples/dynamicCustomMesh.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242

4343
let verly = new Verly(16, canvas, ctx);
4444

45-
let custom = new Entity(16);
45+
let custom = new Entity(16, verly);
4646

4747
window.addEventListener('contextmenu', (e) => {
4848
e.preventDefault();
@@ -62,6 +62,7 @@
6262

6363
verly.createRagdoll(100, 100, 100, 100);
6464
verly.addEntity(custom);
65+
6566
function animate() {
6667
ctx.clearRect(0, 0, width, height);
6768

examples/rotatingEntity.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
let verly = new Verly(16, canvas, ctx);
4545

46-
let b1 = new Box(200, 110, 20, 100);
46+
let b1 = new Box(200, 110, 20, 100, 16, verly);
4747
b1.setGravity(new Vector())
4848
verly.addEntity(b1);
4949

@@ -55,7 +55,7 @@
5555
p.resetVelocity();
5656
}
5757

58-
let b2 = new Box(150, 125, 20, 100);
58+
let b2 = new Box(150, 125, 20, 100, 16, verly);
5959
b2.setGravity(new Vector())
6060
verly.addEntity(b2);
6161

examples/shadedCloth.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<body>
2929

3030
<canvas id="c"></canvas>
31-
31+
3232
<script src="../dist/verly.bundle.js"></script>
3333

3434
<script>
@@ -44,8 +44,8 @@
4444
let verly = new Verly(16, canvas, ctx);
4545

4646
class Cloth extends Entity {
47-
constructor(posx, posy, w, h, segments, pinOffset) {
48-
super();
47+
constructor(posx, posy, w, h, segments, pinOffset, itteration, verlyInstance) {
48+
super(itteration, verlyInstance);
4949
verly.dontPush = true;
5050
let c = verly.createCloth(posx, posy, w, h, segments, pinOffset);
5151
this.points = c.points;
@@ -91,7 +91,7 @@
9191
}
9292
}
9393

94-
let cloth = new Cloth(300, 100, 500, 400, 25, 2);
94+
let cloth = new Cloth(300, 100, 500, 400, 25, 2, 16, verly);
9595
verly.addEntity(cloth);
9696

9797
function animate() {

examples/ship/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ window.onload = function () {
4343
let word = new Text('SAK', 300, 300, 25);
4444

4545
// let box = verly.createHexagon(200, 200, 15, 50);
46-
let ent = new Entity(60);
46+
let ent = new Entity(60, verly);
4747
ent.addPoint(ship);
4848
let boxtmp = verly.joinEntities(word.entity, ent);
4949
let BOX_POINTS = boxtmp.points.length;

examples/text/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta http-equiv="X-UA-Compatible" content="ie=edge">
88
<title>Verly.js Text</title>
9-
<script src="../../src/Vector.js"></script>
109

1110
<style>
1211
* {

0 commit comments

Comments
 (0)