diff --git a/template/test.svg b/src/img/test.svg
similarity index 80%
rename from template/test.svg
rename to src/img/test.svg
index 319fb31..3301792 100644
--- a/template/test.svg
+++ b/src/img/test.svg
@@ -7,7 +7,7 @@
+ d="M25.5 221.5 25.5 202.5 0.5 202.5 0.5 93.5 61.5 93.5 61.5 154.5 132.5 154.5 132.5 221.5 25.5 221.5" />
@@ -16,7 +16,7 @@
+ d="M218.5 429.5 218.5 349.5 232.5 349.5 232.5 93.5 270.5 93.5 270.5 349.5 511.5 349.5 511.5 429.5 218.5 429.5" />
\ No newline at end of file
diff --git a/template/src/lib/decomp.js b/src/scripts/lib/decomp.js
similarity index 100%
rename from template/src/lib/decomp.js
rename to src/scripts/lib/decomp.js
diff --git a/template/src/lib/matter.js b/src/scripts/lib/matter.js
similarity index 100%
rename from template/src/lib/matter.js
rename to src/scripts/lib/matter.js
diff --git a/template/src/lib/polyfill.js b/src/scripts/lib/polyfill.js
similarity index 100%
rename from template/src/lib/polyfill.js
rename to src/scripts/lib/polyfill.js
diff --git a/template/src/script.js b/src/scripts/physicsLayout.js
similarity index 69%
rename from template/src/script.js
rename to src/scripts/physicsLayout.js
index f9ac06c..7709a29 100644
--- a/template/src/script.js
+++ b/src/scripts/physicsLayout.js
@@ -37,11 +37,10 @@ for(let i = 0; i < sampleSVG.length; i++) {
}
}, true);
- // v.position.x *= 0.8;
- // v.position.y *= 0.8;
- v.mass = 0.001;
- v.restitution = 0;
-
+ v.position.x *= 0.8;
+ v.position.y *= 0.8;
+ v.mass = 1;
+ v.restitution = 0.3;
v.name = path.parentNode.id
// vertexSets.push(v);
frags.push(v);
@@ -59,12 +58,29 @@ World.add(engine.world, frags);
Engine.run(engine);
Render.run(render);
+SCALAR = 1;
+THRESHOLD = 0;
+
+window.addEventListener("resize", ()=>{
+ // TODO : complete resize function
+ console.log(window.innerWidth);
+ console.log(window.innerHeight);
+
+ // var leftWall = Bodies.rectangle(0, window.innerHeight/2, 60, window.innerHeight);
+ var rightWall = Bodies.rectangle(window.innerWidth, window.innerHeight/2, 60, window.innerHeight);
+
+ rightWall.position.x = window.innerWidth;
+})
+
setInterval(()=>{
for(let i = 0; i < frags.length; i++) {
+ frags[i].angle = 0; // lock rotation
let el = document.getElementById(frags[i].name);
- let x = frags[i].position.x;
- let y = frags[i].position.y;
- el.setAttribute('transform', "translate("+x+","+y+")");
+ // if((frags[i].velocity.x > THRESHOLD) && (frags[i].velocity.y > THRESHOLD)){
+ let x = frags[i].bounds.min.x * SCALAR
+ let y = frags[i].bounds.min.y * SCALAR
+ el.setAttribute('transform', "translate("+x+","+y+")");
+ // }
}
}, 15)
// document.querySelector("svg").remove();
\ No newline at end of file
diff --git a/template/test.html b/src/test.html
similarity index 89%
rename from template/test.html
rename to src/test.html
index dd34c0e..57dd86d 100644
--- a/template/test.html
+++ b/src/test.html
@@ -10,6 +10,8 @@
-
-
-