Pop
This commit is contained in:
parent
fd130e92a5
commit
069ad0dfa2
3 changed files with 61 additions and 18 deletions
|
|
@ -18,9 +18,11 @@ var render = Render.create({
|
||||||
});
|
});
|
||||||
|
|
||||||
var ceiling = Bodies.rectangle(window.innerWidth/2, 0, window.innerWidth, 60, { isStatic: true });
|
var ceiling = Bodies.rectangle(window.innerWidth/2, 0, window.innerWidth, 60, { isStatic: true });
|
||||||
var floor = Bodies.rectangle(window.innerWidth/2, window.innerHeight-30, window.innerWidth, 60, { isStatic: true });
|
var floor = Bodies.rectangle(window.innerWidth/2, window.innerHeight-100, window.innerWidth, 60, { isStatic: true });
|
||||||
var leftWall = Bodies.rectangle(0, window.innerHeight/2, 60, window.innerHeight, { isStatic: true });
|
var leftWall = Bodies.rectangle(0, window.innerHeight/2, 60, window.innerHeight, { isStatic: true });
|
||||||
var rightWall = Bodies.rectangle(window.innerWidth, window.innerHeight/2, 60, window.innerHeight, { isStatic: true });
|
var rightWall = Bodies.rectangle(window.innerWidth, window.innerHeight/2, 60, window.innerHeight, { isStatic: true });
|
||||||
|
var title = Bodies.rectangle(window.innerWidth/2, 0, 300, 200, { isStatic: true });
|
||||||
|
var timeline = Bodies.rectangle(window.innerWidth-60, window.innerHeight-150, 150, 150, { isStatic: true });
|
||||||
|
|
||||||
// Get SVG
|
// Get SVG
|
||||||
var sampleSVG = document.getElementsByClassName("shape");
|
var sampleSVG = document.getElementsByClassName("shape");
|
||||||
|
|
@ -30,30 +32,34 @@ color = ['#556270'];
|
||||||
var frags = [];
|
var frags = [];
|
||||||
for(let i = 0; i < sampleSVG.length; i++) {
|
for(let i = 0; i < sampleSVG.length; i++) {
|
||||||
path = sampleSVG[i];
|
path = sampleSVG[i];
|
||||||
|
console.log(path);
|
||||||
var v = Bodies.fromVertices(100+(i*80), 80, Svg.pathToVertices(path, 20), {
|
var v = Bodies.fromVertices(100+(i*80), 80, Svg.pathToVertices(path, 20), {
|
||||||
render: {
|
render: {
|
||||||
fillStyle: color,
|
fillStyle: color,
|
||||||
strokeStyle: color
|
strokeStyle: color
|
||||||
}
|
},
|
||||||
|
position: {
|
||||||
|
x: window.innerWidth/2 + (Math.random() - 0.5) * window.innerWidth*0.8,
|
||||||
|
y: window.innerHeight/3 + (Math.random() - 0.5) * window.innerHeight*0.3
|
||||||
|
},
|
||||||
|
mass: 0.01,
|
||||||
|
restitution: 0.5,
|
||||||
|
name: path.parentNode.id
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
v.position.x *= 0.8;
|
let el = document.getElementById(path.parentNode.id)
|
||||||
v.position.y *= 0.8;
|
el.setAttribute("visibility", "hidden")
|
||||||
v.mass = 1;
|
|
||||||
v.restitution = 0.3;
|
|
||||||
v.name = path.parentNode.id
|
|
||||||
// vertexSets.push(v);
|
|
||||||
frags.push(v);
|
frags.push(v);
|
||||||
};
|
};
|
||||||
|
|
||||||
// vertexSets.push(ground)
|
// vertexSets.push(ground)
|
||||||
|
|
||||||
console.log(engine.world);
|
console.log(engine.world);
|
||||||
engine.world.gravity = {scale: 0.0001, x: 0, y: -1}
|
engine.world.gravity = {scale: 0.0001, x: 0, y: 0}
|
||||||
|
|
||||||
World.add(engine.world, [ceiling, floor, leftWall, rightWall]);
|
World.add(engine.world, [ceiling, floor, leftWall, rightWall, title, timeline]);
|
||||||
World.add(engine.world, frags);
|
// World.add(engine.world, frags);
|
||||||
// World.add(engine.world, [boxA, ballA, ballB, ground]);
|
|
||||||
|
|
||||||
Engine.run(engine);
|
Engine.run(engine);
|
||||||
Render.run(render);
|
Render.run(render);
|
||||||
|
|
@ -63,15 +69,31 @@ THRESHOLD = 0;
|
||||||
|
|
||||||
window.addEventListener("resize", ()=>{
|
window.addEventListener("resize", ()=>{
|
||||||
// TODO : complete resize function
|
// TODO : complete resize function
|
||||||
console.log(window.innerWidth);
|
// console.log(window.innerWidth);
|
||||||
console.log(window.innerHeight);
|
// console.log(window.innerHeight);
|
||||||
|
|
||||||
// var leftWall = Bodies.rectangle(0, window.innerHeight/2, 60, 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);
|
var rightWall = Bodies.rectangle(window.innerWidth, window.innerHeight/2, 60, window.innerHeight);
|
||||||
|
|
||||||
rightWall.position.x = window.innerWidth;
|
rightWall.position.x = window.innerWidth;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let count = 0;
|
||||||
|
let duration = 800;
|
||||||
|
let addFrags = ()=>{
|
||||||
|
if (count >= frags.length){
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
let el = document.getElementById(frags[count].name);
|
||||||
|
el.setAttribute("visibility", "visible")
|
||||||
|
World.add(engine.world, frags[count]);
|
||||||
|
count += 1;
|
||||||
|
duration *= 0.85;
|
||||||
|
setTimeout(addFrags, duration)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addFrags();
|
||||||
|
|
||||||
setInterval(()=>{
|
setInterval(()=>{
|
||||||
for(let i = 0; i < frags.length; i++) {
|
for(let i = 0; i < frags.length; i++) {
|
||||||
frags[i].angle = 0; // lock rotation
|
frags[i].angle = 0; // lock rotation
|
||||||
|
|
@ -83,4 +105,7 @@ setInterval(()=>{
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}, 15)
|
}, 15)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// document.querySelector("svg").remove();
|
// document.querySelector("svg").remove();
|
||||||
21
src/style/authors.css
Normal file
21
src/style/authors.css
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
canvas {
|
||||||
|
display: none;
|
||||||
|
width:100%;
|
||||||
|
height:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
/* transition: 0.1s; */
|
||||||
|
}
|
||||||
|
|
||||||
|
.shape {
|
||||||
|
fill: #888888;
|
||||||
|
fill: rgba(0,0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
svg {
|
||||||
|
position: fixed;
|
||||||
|
top: 80px;
|
||||||
|
height: calc(100vh - 100px);
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
|
@ -283,9 +283,6 @@
|
||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FRAGMENTS !!!TEMP!!! */
|
|
||||||
svg#authors{max-height:860px;}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media ( min-width: 1080px ) {
|
@media ( min-width: 1080px ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue