mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 05:37:55 +01:00
disable line priview
This commit is contained in:
parent
774289895e
commit
5944153de7
@ -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;
|
||||
// }
|
||||
|
@ -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;
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user