Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only propagate signals beyond a threshold #10

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions v1.1/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ function Node(model, config){
// Change my value
var delta = _controlsDirection*0.33; // HACK: hard-coded 0.33
self.value += delta;

// Don't allow the node to pass threshold
if (self.value > 1) {
self.value = 1;
} else if (self.value < 0) {
self.value = 0;
}

// And also PROPAGATE THE DELTA
self.sendSignal({
Expand Down Expand Up @@ -112,14 +119,26 @@ function Node(model, config){
myEdges[i].addSignal(signal);
}
};

self.takeSignal = function(signal){

// Change value
self.value += signal.delta;

// Propagate signal
self.sendSignal(signal);

// Only propagate beyond threshold
if (signal.delta < 0) {
if (self.value < 0.1) {
self.sendSignal(signal);
} else {
self.value += signal.delta;
}
} else if (signal.delta > 0) {
if (self.value > 0.9) {
self.sendSignal(signal);
} else {
self.value += signal.delta;
}
} else {
self.value += signal.delta;
}

// self.sendSignal(signal.delta*0.9); // PROPAGATE SLIGHTLY WEAKER

// Animation
Expand Down