switch laser stack 3d output to obj
This commit is contained in:
parent
080d7a23e2
commit
70c1587667
4 changed files with 16 additions and 14 deletions
|
|
@ -76,7 +76,7 @@ function isSecure(proto) {
|
|||
* @param {string} filename - Filename for download
|
||||
*/
|
||||
function download(data, filename) {
|
||||
let url = WIN.URL.createObjectURL(new Blob([data], {type: "octet/stream"}));
|
||||
let url = window.URL.createObjectURL(new Blob([data], {type: "octet/stream"}));
|
||||
$('mod-any').innerHTML = `<a id="_dexport_" href="${url}" download="${filename}">x</a>`;
|
||||
$('_dexport_').click();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,9 +136,9 @@ function exportLaserDialog(data, names) {
|
|||
const driver = laser_driver;
|
||||
const { process } = settings;
|
||||
if (process.ctOutStack) {
|
||||
$('print-stl').classList.remove('hide');
|
||||
$('print-obj').classList.remove('hide');
|
||||
} else {
|
||||
$('print-stl').classList.add('hide');
|
||||
$('print-obj').classList.add('hide');
|
||||
}
|
||||
|
||||
function download_svg() {
|
||||
|
|
@ -155,10 +155,10 @@ function exportLaserDialog(data, names) {
|
|||
);
|
||||
}
|
||||
|
||||
function download_stl() {
|
||||
function download_obj() {
|
||||
api.util.download(
|
||||
driver.exportSTL(settings, data),
|
||||
$('print-filename-laser').value + ".stl"
|
||||
driver.exportOBJ(settings, data),
|
||||
$('print-filename-laser').value + ".obj"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ function exportLaserDialog(data, names) {
|
|||
$('print-lines').value = util.comma(segments);
|
||||
$('print-svg').onclick = download_svg;
|
||||
$('print-dxf').onclick = download_dxf;
|
||||
$('print-stl').onclick = download_stl;
|
||||
$('print-obj').onclick = download_obj;
|
||||
$('print-lg').onclick = download_gcode;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { render } from '../../core/render.js';
|
|||
import { slicer } from '../../../geo/slicer.js';
|
||||
import { newSlice } from '../../core/slice.js';
|
||||
import { newPolygon } from '../../../geo/polygon.js';
|
||||
import { STL } from '../../../load/stl.js';
|
||||
import { encode as encodeOBJ } from '../../../load/obj.js';
|
||||
|
||||
export const TYPE = {
|
||||
LASER: 0,
|
||||
|
|
@ -610,7 +610,7 @@ function exportElements(settings, output, onpre, onpoly, onpost, onpoint, onlaye
|
|||
onpost();
|
||||
};
|
||||
|
||||
function exportSTL(settings, data) {
|
||||
function exportOBJ(settings, data) {
|
||||
let { ctSliceHeight, ctOutSmooth } = settings.process;
|
||||
let polys = [];
|
||||
for (let array of data) {
|
||||
|
|
@ -633,7 +633,7 @@ function exportSTL(settings, data) {
|
|||
}).flat().filter(v => v);
|
||||
}
|
||||
let layers = {};
|
||||
let mesh = [];
|
||||
let obj = [];
|
||||
for (let poly of polys) {
|
||||
let z = poly.getZ();
|
||||
let layer = layers[z];
|
||||
|
|
@ -644,13 +644,15 @@ function exportSTL(settings, data) {
|
|||
}
|
||||
for (let rec of Object.entries(layers)) {
|
||||
let [ z, polys ] = rec;
|
||||
let layer = [];
|
||||
polys = POLY.nest(polys);
|
||||
for (let poly of polys) {
|
||||
let ext = poly.setZ(0).extrude(ctSliceHeight, { zadd: parseFloat(z) });
|
||||
mesh = mesh.concat(ext);
|
||||
layer = layer.concat(ext);
|
||||
}
|
||||
obj.push({ file:`z-${z}`, varr: layer });
|
||||
}
|
||||
return new STL().encode(mesh);
|
||||
return encodeOBJ(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -933,5 +935,5 @@ export const LASER = {
|
|||
exportGCode,
|
||||
exportDXF,
|
||||
exportSVG,
|
||||
exportSTL
|
||||
exportOBJ
|
||||
};
|
||||
|
|
|
|||
|
|
@ -716,7 +716,7 @@
|
|||
<div class="f-row box">
|
||||
<button id="print-svg" class="grow">svg</button>
|
||||
<button id="print-dxf" class="grow">dxf</button>
|
||||
<button id="print-stl" class="grow">stl</button>
|
||||
<button id="print-obj" class="grow">obj</button>
|
||||
<button id="print-lg" class="grow">gcode</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue