From d3725243ea9157e411c5e913ccc28f27c9c2dd8b Mon Sep 17 00:00:00 2001 From: Joe Innes Date: Fri, 21 Apr 2017 16:56:38 +0200 Subject: [PATCH] Only propagate signals beyond a threshold Only propagate signals beyond a threshold, and don't allow input to take a node above or below threshold --- v1.1/js/Node.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/v1.1/js/Node.js b/v1.1/js/Node.js index c76bb04..5b29acb 100644 --- a/v1.1/js/Node.js +++ b/v1.1/js/Node.js @@ -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({ @@ -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