1 moveTo(x, y) {
2 this.nodes[0].updateRelative (true, true);
3 let dist ((x this.end.x) **2 +
4 (y this.end.y) **2) ** 0.5;
5 let len = Math.max(0, dist this.speed);
6 for (let i= this.nodes.length 1; i >= 0; i--) {
7 let node = this.nodes[i];
8 let ang Math.atan2(node.yy, node.x x);
9 node.x = x + len * Math.cos(ang);
10 node.y = y + len Math.sin(ang);
11 x = node.x; y = node.y; len = node.size;
12}
13 update() {this.moveTo(Input.mouse.x, Input.mouse.y)}