|
|
|
@ -3462,40 +3462,48 @@ var _rxjs2 = _interopRequireDefault(_rxjs); |
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
|
|
|
|
|
|
|
|
function Controls(node, _ref) { |
|
|
|
|
var speed = _ref.speed, |
|
|
|
|
otherstuff = _ref.otherstuff; |
|
|
|
|
|
|
|
|
|
function Controls(node, options) { |
|
|
|
|
this.node = node; |
|
|
|
|
this.options = options; |
|
|
|
|
|
|
|
|
|
this.countCtrl = createCountControl(); |
|
|
|
|
this.speedCtrl = createSpeedControl(); |
|
|
|
|
this.radiusCtrl = createRadiusControl(); |
|
|
|
|
this.rotationCtrl = createRotationControl(); |
|
|
|
|
this.animatingCtrl = createAnimatingControl(); |
|
|
|
|
|
|
|
|
|
this.updateOptions(options); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Controls.prototype.updateOptions = function (_ref) { |
|
|
|
|
var animating = _ref.animating, |
|
|
|
|
count = _ref.count, |
|
|
|
|
speed = _ref.speed; |
|
|
|
|
|
|
|
|
|
this.animatingCtrl.innerHTML = animating ? '◼ Stop' : '▶ Start'; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Controls.prototype.mount = function (customNodes) { |
|
|
|
|
var countCtrl = renderCountControl(); |
|
|
|
|
var speedCtrl = renderSpeedControl(); |
|
|
|
|
var radiusCtrl = renderRadiusControl(); |
|
|
|
|
var rotationCtrl = renderRotationControl(); |
|
|
|
|
var startStopCtrl = renderStartStopControl(); |
|
|
|
|
|
|
|
|
|
this.node.appendChild(countCtrl); |
|
|
|
|
this.node.appendChild(speedCtrl); |
|
|
|
|
this.node.appendChild(radiusCtrl); |
|
|
|
|
this.node.appendChild(rotationCtrl); |
|
|
|
|
this.node.appendChild(startStopCtrl); |
|
|
|
|
|
|
|
|
|
return _rxjs2.default.Observable.merge(_rxjs2.default.Observable.fromEvent(countCtrl, 'change').map(function (evt) { |
|
|
|
|
this.node.appendChild(this.countCtrl); |
|
|
|
|
this.node.appendChild(this.speedCtrl); |
|
|
|
|
this.node.appendChild(this.radiusCtrl); |
|
|
|
|
this.node.appendChild(this.rotationCtrl); |
|
|
|
|
this.node.appendChild(this.animatingCtrl); |
|
|
|
|
|
|
|
|
|
return _rxjs2.default.Observable.merge(_rxjs2.default.Observable.fromEvent(this.countCtrl, 'change').map(function (evt) { |
|
|
|
|
return { key: 'count', value: evt.target.value * 1 }; |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(speedCtrl, 'change').map(function (evt) { |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(this.speedCtrl, 'change').map(function (evt) { |
|
|
|
|
return { key: 'speed', value: evt.target.value * 1 }; |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(radiusCtrl, 'change').map(function (evt) { |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(this.radiusCtrl, 'change').map(function (evt) { |
|
|
|
|
return { key: 'radius', value: evt.target.checked }; |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(rotationCtrl, 'change').map(function (evt) { |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(this.rotationCtrl, 'change').map(function (evt) { |
|
|
|
|
return { key: 'rotation', value: evt.target.checked }; |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(startStopCtrl, 'click').map(function (evt) { |
|
|
|
|
return { key: 'startstop', value: null }; |
|
|
|
|
}), _rxjs2.default.Observable.fromEvent(this.animatingCtrl, 'click').map(function (evt) { |
|
|
|
|
return { key: 'animating', value: null }; |
|
|
|
|
})); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var renderCountControl = function renderCountControl() { |
|
|
|
|
var createCountControl = function createCountControl() { |
|
|
|
|
var label = document.createElement('label'); |
|
|
|
|
label.className = 'controls-label'; |
|
|
|
|
|
|
|
|
@ -3515,7 +3523,7 @@ var renderCountControl = function renderCountControl() { |
|
|
|
|
return label; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var renderSpeedControl = function renderSpeedControl() { |
|
|
|
|
var createSpeedControl = function createSpeedControl() { |
|
|
|
|
var label = document.createElement('label'); |
|
|
|
|
label.className = 'controls-label'; |
|
|
|
|
|
|
|
|
@ -3535,7 +3543,7 @@ var renderSpeedControl = function renderSpeedControl() { |
|
|
|
|
return label; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var renderRadiusControl = function renderRadiusControl() { |
|
|
|
|
var createRadiusControl = function createRadiusControl() { |
|
|
|
|
var label = document.createElement('label'); |
|
|
|
|
label.className = 'controls-label'; |
|
|
|
|
|
|
|
|
@ -3553,7 +3561,7 @@ var renderRadiusControl = function renderRadiusControl() { |
|
|
|
|
return label; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var renderRotationControl = function renderRotationControl() { |
|
|
|
|
var createRotationControl = function createRotationControl() { |
|
|
|
|
var label = document.createElement('label'); |
|
|
|
|
label.className = 'controls-label'; |
|
|
|
|
|
|
|
|
@ -3571,12 +3579,9 @@ var renderRotationControl = function renderRotationControl() { |
|
|
|
|
return label; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var renderStartStopControl = function renderStartStopControl() { |
|
|
|
|
var createAnimatingControl = function createAnimatingControl() { |
|
|
|
|
var button = document.createElement('button'); |
|
|
|
|
button.className = 'controls-button controls-bottom'; |
|
|
|
|
button.innerHTML = '▶ Start'; |
|
|
|
|
|
|
|
|
|
// button.innerHTML = '◼ Stop';
|
|
|
|
|
|
|
|
|
|
return button; |
|
|
|
|
}; |
|
|
|
@ -6207,7 +6212,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de |
|
|
|
|
|
|
|
|
|
function Animation1() { |
|
|
|
|
this.options = { |
|
|
|
|
count: 1 |
|
|
|
|
count: 1, |
|
|
|
|
animating: false |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
this.container = document.getElementById('animation1'); |
|
|
|
@ -6216,36 +6222,18 @@ function Animation1() { |
|
|
|
|
|
|
|
|
|
var eventStack = this.controls.mount(); |
|
|
|
|
|
|
|
|
|
eventStack.subscribe(this.subscriber); |
|
|
|
|
eventStack.subscribe(this.subscriber.bind(this)); |
|
|
|
|
|
|
|
|
|
this.particles = []; |
|
|
|
|
|
|
|
|
|
this.updateCount(); |
|
|
|
|
this.updateAnimating(true); |
|
|
|
|
|
|
|
|
|
// TODO Change animal pic
|
|
|
|
|
// TODO show movement circle
|
|
|
|
|
// TODO add core UI
|
|
|
|
|
|
|
|
|
|
// this.particles = Array(5).fill().map(_ => new Particle(this.container, this.bounds));
|
|
|
|
|
//
|
|
|
|
|
// const stop$ = Rx.Observable.fromEvent(this.container, 'stop');
|
|
|
|
|
//
|
|
|
|
|
// // Change animation speed
|
|
|
|
|
// // Change animal pic
|
|
|
|
|
// // Enable random radius changes
|
|
|
|
|
// // Enable random rotation changes
|
|
|
|
|
// // Show movement circle
|
|
|
|
|
// // Show vision grid (including touches!)
|
|
|
|
|
// // Start / stop
|
|
|
|
|
// // TODO add core UI
|
|
|
|
|
//
|
|
|
|
|
// console.error("Click container to stop.");
|
|
|
|
|
// const fps$ = Rx.Observable.interval(1000 / 32)
|
|
|
|
|
// .takeUntil(stop$)
|
|
|
|
|
// .finally(() => { console.error("Stopped."); })
|
|
|
|
|
//
|
|
|
|
|
// const click$ = Rx.Observable.fromEvent(this.container, 'click');
|
|
|
|
|
// click$.subscribe(() => {
|
|
|
|
|
// this.container.dispatchEvent(new CustomEvent('stop'));
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// fps$.subscribe(this.nextFrame.bind(this));
|
|
|
|
|
// TODO ANIM2 Show vision grid (including touches!)
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Animation1.prototype.subscriber = function (_ref) { |
|
|
|
@ -6254,7 +6242,11 @@ Animation1.prototype.subscriber = function (_ref) { |
|
|
|
|
|
|
|
|
|
switch (key) { |
|
|
|
|
case 'count': |
|
|
|
|
this.updateCount();break; |
|
|
|
|
this.updateCount(); |
|
|
|
|
break; |
|
|
|
|
case 'animating': |
|
|
|
|
this.updateAnimating(!this.options.animating); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -6276,6 +6268,23 @@ Animation1.prototype.updateCount = function () { |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Animation1.prototype.updateAnimating = function (animating) { |
|
|
|
|
var _this = this; |
|
|
|
|
|
|
|
|
|
Object.assign(this.options, { animating: animating }); |
|
|
|
|
this.controls.updateOptions(this.options); |
|
|
|
|
|
|
|
|
|
if (animating) { |
|
|
|
|
var fps$ = _rxjs2.default.Observable.interval(1000 / 32).takeWhile(function (_) { |
|
|
|
|
return _this.options.animating; |
|
|
|
|
}).finally(function () { |
|
|
|
|
console.error("Stopped."); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
fps$.subscribe(this.nextFrame.bind(this)); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
exports.default = Animation1; |
|
|
|
|
|
|
|
|
|
/***/ }), |
|
|
|
|