diff --git a/src/sliceActions/slice.js b/src/sliceActions/slice.js index b3eff9e..8a36539 100644 --- a/src/sliceActions/slice.js +++ b/src/sliceActions/slice.js @@ -1,4 +1,4 @@ -import * as THREE from 'three'; +// import * as THREE from 'three'; import calculateLayersIntersections from './calculateLayersIntersections.js'; import createLines from './createLines.js'; import generateInfills from './generateInfills.js'; @@ -64,9 +64,9 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev updateProgress('Finished'); - if (constructLinePreview) gcode.linePreview = createGcodeGeometry(gcode.gcode); - gcode.gcode = gcodeToString(gcode.gcode); - return gcode; + // if (constructLinePreview) gcode.linePreview = createGcodeGeometry(gcode.gcode); + // gcode.gcode = gcodeToString(gcode.gcode); + // return gcode; } const PRECISION_INVERSE = 1 / PRECISION; @@ -98,39 +98,39 @@ function gcodeToString(gcode) { }, ''); } -const MAX_SPEED = 100 * 60; -const COLOR = new THREE.Color(); -function createGcodeGeometry(gcode) { - const positions = []; - const colors = []; - - let lastPoint = [0, 0, 0]; - for (let i = 0; i < gcode.length; i ++) { - const command = gcode[i]; - if (typeof command === 'string') continue; - - const { G, F, X, Y, Z } = command; - - if (X || Y || Z) { - if (G === 1) { - positions.push(lastPoint.Y, lastPoint.Z, lastPoint.X); - positions.push(Y, Z, X); - - const color = (G === 0) ? COLOR.setHex(0x00ff00) : COLOR.setHSL(F / MAX_SPEED, 0.5, 0.5); - colors.push(color.r, color.g, color.b); - colors.push(color.r, color.g, color.b); - } - lastPoint = { X, Y, Z }; - } - } - - const geometry = new THREE.BufferGeometry(); - - geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3)); - geometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3)); - - const material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors }); - const linePreview = new THREE.LineSegments(geometry, material); - - return linePreview; -} +// const MAX_SPEED = 100 * 60; +// const COLOR = new THREE.Color(); +// function createGcodeGeometry(gcode) { +// const positions = []; +// const colors = []; +// +// let lastPoint = [0, 0, 0]; +// for (let i = 0; i < gcode.length; i ++) { +// const command = gcode[i]; +// if (typeof command === 'string') continue; +// +// const { G, F, X, Y, Z } = command; +// +// if (X || Y || Z) { +// if (G === 1) { +// positions.push(lastPoint.Y, lastPoint.Z, lastPoint.X); +// positions.push(Y, Z, X); +// +// const color = (G === 0) ? COLOR.setHex(0x00ff00) : COLOR.setHSL(F / MAX_SPEED, 0.5, 0.5); +// colors.push(color.r, color.g, color.b); +// colors.push(color.r, color.g, color.b); +// } +// lastPoint = { X, Y, Z }; +// } +// } +// +// const geometry = new THREE.BufferGeometry(); +// +// geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3)); +// geometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(colors), 3)); +// +// const material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors }); +// const linePreview = new THREE.LineSegments(geometry, material); +// +// return linePreview; +// } diff --git a/src/slicer.js b/src/slicer.js index c49ec2e..7ee9723 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -70,18 +70,18 @@ function sliceAsync(settings, geometry, openObjectIndexes, constructLinePreview, case 'SLICE': { slicerWorker.terminate(); - if (data.gcode.linePreview) { - const geometry = new THREE.BufferGeometry(); - - const { position, color } = data.gcode.linePreview; - geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(position), 3)); - geometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(color), 3)); - - const material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors }); - const linePreview = new THREE.LineSegments(geometry, material); - - data.gcode.linePreview = linePreview; - } + // if (data.gcode.linePreview) { + // const geometry = new THREE.BufferGeometry(); + // + // const { position, color } = data.gcode.linePreview; + // geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(position), 3)); + // geometry.addAttribute('color', new THREE.BufferAttribute(new Float32Array(color), 3)); + // + // const material = new THREE.LineBasicMaterial({ vertexColors: THREE.VertexColors }); + // const linePreview = new THREE.LineSegments(geometry, material); + // + // data.gcode.linePreview = linePreview; + // } resolve(data.gcode); break; diff --git a/src/slicer.worker.js b/src/slicer.worker.js index f06ce93..c43f88a 100644 --- a/src/slicer.worker.js +++ b/src/slicer.worker.js @@ -21,12 +21,12 @@ self.addEventListener('message', (event) => { const gcode = slice(settings, geometry, openObjectIndexes, constructLinePreview, onProgress); const buffers = []; - if (gcode.linePreview) { - const position = gcode.linePreview.geometry.getAttribute('position').array; - const color = gcode.linePreview.geometry.getAttribute('color').array; - buffers.push(position.buffer, color.buffer); - gcode.linePreview = { position, color }; - } + // if (gcode.linePreview) { + // const position = gcode.linePreview.geometry.getAttribute('position').array; + // const color = gcode.linePreview.geometry.getAttribute('color').array; + // buffers.push(position.buffer, color.buffer); + // gcode.linePreview = { position, color }; + // } self.postMessage({ message: 'SLICE',