From 86d3e3a5017d36ed8ae43ce5c40709a7be55aad5 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 18 Apr 2020 22:12:50 -0400 Subject: [PATCH] add anti-alias levels 2,4,8 --- js/kiri-conf.js | 2 +- js/kiri-driver-cam.js | 1 + js/kiri-driver-sla.js | 39 +++++++++++++++++++-------------------- js/kiri-init.js | 8 ++++---- js/kiri.js | 8 +++++++- js/license.js | 2 +- js/moto-space.js | 2 +- 7 files changed, 34 insertions(+), 28 deletions(-) diff --git a/js/kiri-conf.js b/js/kiri-conf.js index 784089cb..9aa780e3 100644 --- a/js/kiri-conf.js +++ b/js/kiri-conf.js @@ -305,7 +305,7 @@ let gs_kiri_conf = exports; slaShell: 0.00, slaOpenTop: false, slaOpenBase: false, - slaAntiAlias: false, + slaAntiAlias: 1, slaLayerOff: 0.1, slaLayerOn: 7, slaPeelDist: 6, diff --git a/js/kiri-driver-cam.js b/js/kiri-driver-cam.js index a12ecb01..bb7dc017 100644 --- a/js/kiri-driver-cam.js +++ b/js/kiri-driver-cam.js @@ -1542,6 +1542,7 @@ var gs_kiri_cam = exports; // last layer/move is to zmax // injected into the last layer generated + if (lastPoint) addOutput(newOutput[newOutput.length-1], printPoint = lastPoint.clone().setZ(zmax_outer), 0, 0, tool.number); // replace output single flattened layer with all points diff --git a/js/kiri-driver-sla.js b/js/kiri-driver-sla.js index e604ab87..2587c528 100644 --- a/js/kiri-driver-sla.js +++ b/js/kiri-driver-sla.js @@ -413,32 +413,31 @@ let gs_kiri_sla = exports; layerBytes = width * height, small = conf.small, large = conf.large, - subcount = process.slaAntiAlias ? 2 : 1; + subcount = process.slaAntiAlias ? 2 : 1, + masks = [ ]; + + for (let l=0; l < subcount; l++) { + masks.push((Math.pow(2,8/subcount)-1) << (l * (8/subcount))); + } let converted = conf.lines.map((line, index) => { let count = line.length / 4; + let lineDV = new DataView(line.buffer); let bits = new Uint8Array(line.length / 4), bits2; let bitsDV = new DataView(bits.buffer), bitsDV2; - let lineDV = new DataView(line.buffer); - let subs = [{ - exposureTime: process.slaLayerOn, - data: bits - }]; - if (subcount === 2) { - bits2 = bits.slice(); - bitsDV2 = new DataView(bits2.buffer); - subs.push({ - exposureTime: process.slaLayerOn, - data: bits2 - }); + let subs = [{ data: bits, view: bitsDV }]; + for (let sl=1; sl= 128 ? 1 : 0); - if (subcount === 2) { - bitsDV2.setUint8(i, dv > 0 && dv < 128 ? 1 : 0); + // use R from RGB since that was painted on the canvas + for (let s=0; s 0 ? 1 : 0); } } progress(index / conf.lines.length); diff --git a/js/kiri-init.js b/js/kiri-init.js index f31cc4e7..c9e9dd60 100644 --- a/js/kiri-init.js +++ b/js/kiri-init.js @@ -1452,7 +1452,6 @@ var gs_kiri_init = exports; slaShell: UC.newInput('hollow shell', {title:'shell thickness in mm\nuse multiple of layer height\nuse 0 for solid', convert:UC.toFloat, modes:SLA}), slaOpenTop: UC.newBoolean('open top', onBooleanClick, {title:'solid layers', modes:SLA}), slaOpenBase: UC.newBoolean('open base', onBooleanClick, {title:'bottom layers', modes:SLA}), - slaAntiAlias: UC.newBoolean('anti alias', onBooleanClick, {title:'enable anti-aliasing\nproduces larger files', modes:SLA, expert:true}), // SLA slaOutput: UC.newGroup('layers', null, {modes:SLA, group:"sla-layers"}), @@ -1469,12 +1468,13 @@ var gs_kiri_init = exports; slaBasePeelDist: UC.newInput('peel distance', {title:'peel distance\nin millimeters', convert:UC.toFloat, modes:SLA}), slaBasePeelLiftRate: UC.newInput('peel lift rate', {title:'peel lift speed\nin mm/sec', convert:UC.toFloat, modes:SLA}), - slaFirst: UC.newGroup('first layer', null, {modes:SLA, group:"sla-first", expert:true}), - slaFirstOffset: UC.newInput('offset', {title:'first layer offset\nalmost always 0.0\n0.0-1.0 in millimeters', convert:UC.toFloat, bound:UC.bound(0,1), modes:SLA, expert:true}), - slaFill: UC.newGroup('infill', null, {modes:SLA, group:"sla-first"}), slaFillDensity: UC.newInput('density', {title:'percent infill\n0.0-1.0', convert:UC.toFloat, bound:UC.bound(0,1), modes:SLA}), slaFillLine: UC.newInput('line width', {title:'hatch line width\nin millimeters', convert:UC.toFloat, bound:UC.bound(0,5), modes:SLA}), + + slaOutput: UC.newGroup('output', null, {modes:SLA, group:"sla-first"}), + slaFirstOffset: UC.newInput('z offset', {title:'z layer offset\nalmost always 0.0\n0.0-1.0 in millimeters', convert:UC.toFloat, bound:UC.bound(0,1), modes:SLA, expert:true}), + slaAntiAlias: UC.newSelect('anti alias', {title: 'enable anti-aliasing\nproduces larger files', modes:SLA}, "antialias"), }); if (!lang_set) { diff --git a/js/kiri.js b/js/kiri.js index 7d89d8d1..b36d1b07 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -132,10 +132,16 @@ self.kiri.copyright = exports.COPYRIGHT; { name: "triangle" }, { name: "linear" } ], - units:[ + units: [ { name: "mm" }, { name: "in" } ], + antialias: [ + { name: "1", id: 1 }, + { name: "2", id: 2 }, + { name: "4", id: 4 }, + { name: "8", id: 8 } + ] }; const API = KIRI.api = { diff --git a/js/license.js b/js/license.js index 4227eaf0..3295b29d 100644 --- a/js/license.js +++ b/js/license.js @@ -1,7 +1,7 @@ var exports = { COPYRIGHT:"Copyright (C) Stewart Allen - All Rights Reserved", LICENSE:"See the license.md file included with the source distribution", - VERSION:"1.8.9" + VERSION:"1.9.0" }; if (!module) var module = {}; module.exports = exports; diff --git a/js/moto-space.js b/js/moto-space.js index 90b73452..61ed48f6 100644 --- a/js/moto-space.js +++ b/js/moto-space.js @@ -667,7 +667,7 @@ var MOTO = window.moto = window.moto || {}; preserveDrawingBuffer: true }); camera = perspective ? - new THREE.PerspectiveCamera(perspective, aspect(), 1, 100000) : + new THREE.PerspectiveCamera(perspective, aspect(), 5, 100000) : new THREE.OrthographicCamera(-100 * aspect(), 100 * aspect(), 100, -100, 0.1, 100000); camera.position.set(0, 200, 340);