Implement reset button
This commit is contained in:
parent
94b6fdead2
commit
6b6997511e
@ -28,6 +28,7 @@ var hover = null;
|
|||||||
var lastHover = null;
|
var lastHover = null;
|
||||||
var clickEnd = false;
|
var clickEnd = false;
|
||||||
var sprites = [];
|
var sprites = [];
|
||||||
|
var reset = false;
|
||||||
|
|
||||||
// global configurable vars
|
// global configurable vars
|
||||||
var resolution = 1; // scaling for PIXI renderer
|
var resolution = 1; // scaling for PIXI renderer
|
||||||
@ -472,10 +473,12 @@ function getRandomPoints (numPoints, maxX, maxY, maxZ, tweeningFns) {
|
|||||||
cycleStart = randomInt(0, cycleDuration - 1);
|
cycleStart = randomInt(0, cycleDuration - 1);
|
||||||
color = randomColor();
|
color = randomColor();
|
||||||
easingFn = tweeningFns[Math.floor(Math.random() * tweeningFns.length)];
|
easingFn = tweeningFns[Math.floor(Math.random() * tweeningFns.length)];
|
||||||
// save PIXI Sprite for each point in array
|
if (sprites.length <= i) {
|
||||||
sprite = createSprite();
|
// save PIXI Sprite for each point in array
|
||||||
sprites.push(sprite);
|
sprite = createSprite();
|
||||||
stage.addChild(sprite);
|
sprites.push(sprite);
|
||||||
|
stage.addChild(sprite);
|
||||||
|
}
|
||||||
points[i] = [x, y, z, cycleStart, color, easingFn];
|
points[i] = [x, y, z, cycleStart, color, easingFn];
|
||||||
}
|
}
|
||||||
return points;
|
return points;
|
||||||
@ -668,6 +671,18 @@ function loop () {
|
|||||||
|
|
||||||
polygon.clear();
|
polygon.clear();
|
||||||
|
|
||||||
|
if (reset === true) {
|
||||||
|
var newPoints;
|
||||||
|
newPoints = getRandomPoints(Math.round(totalScreenPixels / 6), screenWidth, screenHeight, zRange,
|
||||||
|
tweeningFns);
|
||||||
|
polygonPoints = {
|
||||||
|
original: newPoints,
|
||||||
|
target: JSON.parse(JSON.stringify(newPoints)),
|
||||||
|
tweened: JSON.parse(JSON.stringify(newPoints))
|
||||||
|
};
|
||||||
|
reset = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (click !== null) {
|
if (click !== null) {
|
||||||
if (clickEnd) {
|
if (clickEnd) {
|
||||||
// apply "rebound" effects
|
// apply "rebound" effects
|
||||||
@ -964,12 +979,14 @@ window.onload = function () {
|
|||||||
|
|
||||||
document.getElementById('synchronize-cycles').addEventListener('click', function () {
|
document.getElementById('synchronize-cycles').addEventListener('click', function () {
|
||||||
synchronizeCycles(polygonPoints, cycleDuration);
|
synchronizeCycles(polygonPoints, cycleDuration);
|
||||||
return false;
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.getElementById('randomize-cycles').addEventListener('click', function () {
|
document.getElementById('randomize-cycles').addEventListener('click', function () {
|
||||||
randomizeCycles(polygonPoints, cycleDuration);
|
randomizeCycles(polygonPoints, cycleDuration);
|
||||||
return false;
|
}, false);
|
||||||
|
|
||||||
|
document.getElementById('reset').addEventListener('click', function () {
|
||||||
|
reset = true;
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
var timeRange, timeInput;
|
var timeRange, timeInput;
|
||||||
|
Loading…
Reference in New Issue
Block a user