1moveTo(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--)f 7let node = this.nodes[i]; 8let ang = Math.atan2(node.y - y, node.x - x); 9node.x =x+len * Math.cos(ang); 10node.y = y + len * Math.sin(ang); 11x = node.x; y = node.y; len = node.size; 12) 13 update() (this.moveTo(Input.mouse.x, Input.mouse.y))