Skip to content

Commit

Permalink
improve legibility
Browse files Browse the repository at this point in the history
  • Loading branch information
genbs committed Mar 19, 2021
1 parent 74b9a9e commit 8f9b8fa
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/GCODEExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,41 +177,46 @@ class GCODEExporter {

const childBuffer = sceneChilds[i].getBuffer() || []
const childIndexedBuffer = sceneChilds[i].getIndexedBuffer() || []
let childVertexIndex = 0

for (
let currentBufferIndex = 0, vertexIndex = 0, len = childIndexedBuffer.length;
let currentBufferIndex = 0, len = childIndexedBuffer.length;
currentBufferIndex < len;
currentBufferIndex++
) {
const currentIndexing = childIndexedBuffer[currentBufferIndex]
const initialPointX = clamp(
settings.minX,
settings.maxX,
settings.minX + childBuffer[vertexIndex] / scale + drawAreaSceneOffset[0]
settings.minX + childBuffer[childVertexIndex] / scale + drawAreaSceneOffset[0]
)

const initialPointY = clamp(
settings.minY,
settings.maxY,
settings.minY + childBuffer[vertexIndex + 1] / scale + drawAreaSceneOffset[1]
settings.minY + childBuffer[childVertexIndex + 1] / scale + drawAreaSceneOffset[1]
)

concat(
gcode,
this.moveTo(settings.penUpCommand, settings.penDownCommand, initialPointX, initialPointY, settings.decimals)
)

vertexIndex += 2
for (let len = vertexIndex - 2 + currentIndexing.frameLength; vertexIndex < len; vertexIndex += 2) {
childVertexIndex += 2
for (
let len = childVertexIndex + currentIndexing.frameLength - 2;
childVertexIndex < len;
childVertexIndex += 2
) {
const currentX = clamp(
settings.minX,
settings.maxX,
settings.minX + childBuffer[vertexIndex] / scale + drawAreaSceneOffset[0]
settings.minX + childBuffer[childVertexIndex] / scale + drawAreaSceneOffset[0]
)
const currentY = clamp(
settings.minY,
settings.maxY,
settings.minY + childBuffer[vertexIndex + 1] / scale + drawAreaSceneOffset[1]
settings.minY + childBuffer[childVertexIndex + 1] / scale + drawAreaSceneOffset[1]
)
concat(gcode, this.lineTo(currentX, currentY, settings.velocity, settings.decimals))
}
Expand Down

0 comments on commit 8f9b8fa

Please sign in to comment.