diff --git a/js/model.js b/js/model.js index 082b051a0c375c37e5ebc3c0b857076357978d09..173e48009563eb6ea3d27e5127f2d0aedadd3108 100644 --- a/js/model.js +++ b/js/model.js @@ -93,7 +93,12 @@ class Model { e: 0, }; for (let i = commandArrayLength; i > 0; i--) { + currCoords.x = +this.commands[commandArrayLength - 1].goalx.value; + currCoords.y = +this.commands[commandArrayLength - 1].goaly.value; + currCoords.z = +this.commands[commandArrayLength - 1].goalz.value; + currCoords.e = +this.commands[commandArrayLength - 1].flow.value; // TODO: Why is this checking so much stuff? Coordinates XYZE should always be set. + /* if (currCoords.x == 0 && this.commands[commandArrayLength - 1].goalx) { currCoords.x = +this.commands[commandArrayLength - 1].goalx; currCoords.y = +this.commands[commandArrayLength - 1].goaly; @@ -106,7 +111,7 @@ class Model { currCoords.e = +this.commands[commandArrayLength - 1].flow; } else { return currCoords; - } + }*/ } return currCoords; } diff --git a/js/project.js b/js/project.js index 26ed9ed802df6fe40adbb4612da3e6f9d05d721f..5edcd3f9be82e6e83a0fab68b75fc833f6ed895c 100644 --- a/js/project.js +++ b/js/project.js @@ -101,18 +101,20 @@ class Project { } addLine(flow, speed, toX, toY, toZ) { - if (flow > this.model.currentCoordinates().f) { - flow = this.model.currentCoordinates().f; + if (flow < this.model.currentCoordinates().e) { + flow = this.model.currentCoordinates().e; } var newLine = new Move(flow, speed, toX, toY, toZ); - window.currentProject.model.append(newLine); + //window.currentProject.model.append(newLine); + this.model.append(newLine); } addArc(flow, speed, size, directionXY, directionZ, curvature) { + const prevCoords = this.model.currentCoordinates(); var nextStartHeight = 0; const steps = Math.min(size, 50); + const flowStep = (flow - prevCoords.e) / steps; const angle = 90; - const prevCoords = this.model.currentCoordinates(); for (var i = 0; i <= steps; i++) { var sub_angle = (i / steps) * angle * 0.017453292519943295; // (angle / 180) * Math.PI; var xi = size * (1 - Math.cos(sub_angle)); @@ -173,7 +175,7 @@ class Project { } break; } - var newMove = new Move(flow, speed, newX, newY, newZ); + var newMove = new Move(prevCoords.e + flowStep * i, speed, newX, newY, newZ); this.model.append(newMove); } } diff --git a/main.js b/main.js index e60a7d56906db4eb6220c701fea10de792949c87..667c18fbb456941206f52318ca184fd56551b490 100644 --- a/main.js +++ b/main.js @@ -448,6 +448,24 @@ function getPresetModelVase() { function getPresetModelVertical() { var presetProject = new Project(); + var extMult = 4; + var ext = 0; + const startX = 40; + var currBig; + var currSmall; + + for (var i = 1; i < 15; i++) { + currBig = i * extMult; + currSmall = i * extMult - extMult / 2; + + presetProject.addLine(ext, 1500, startX - currSmall, 0, 0); + + presetProject.addArc(ext += currSmall * 1.5, 1500, currSmall, "1", "1", "1"); + + presetProject.addLine(ext, 1500, startX, 0, currBig); + + presetProject.addArc(ext += currBig * 1.5, 1500, currBig, "3", "2", "1"); + } return presetProject; }