diff --git a/package.json b/package.json index c3c662b1..69d6acb8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "grid-apps", - "version": "2.4.5D", + "version": "2.4.6D", "description": "grid.space 3d slice & modeling tools", "author": "Stewart Allen ", "license": "MIT", diff --git a/src/kiri/main.js b/src/kiri/main.js index 0a0cc2da..84e38e87 100644 --- a/src/kiri/main.js +++ b/src/kiri/main.js @@ -945,13 +945,34 @@ }); } - function loadImage(image) { - KIRI.client.image2mesh({settings, png:image}, progress => { + function loadImageDialog(image) { + const opt = {pre: [ + "
", + "

Image Conversion

", + "

", + " This will create a 3D model from a 2D PNG image. Photos must", + " be blurred to be usable. Values from 0=off to 50=high are suggested.", + " Higher values incur more processing time.", + "

", + "
", + "  ", + "
", + "
" + ]}; + UC.confirm(undefined, {convert:true, cancel:false}, undefined, opt).then((ok) => { + if (ok) { + loadImage(image, {blur: parseInt($('png-blur').value) || 0}); + } + }); + } + + function loadImage(image, opt = {}) { + let info = Object.assign({settings, png:image}, opt); + KIRI.client.image2mesh(info, progress => { API.show.progress(progress, "converting"); }, output => { API.show.progress(0); - let {bigv, verts, index, vi, ii} = output; - + let {bigv, verts, index} = output; // let mat = new THREE.MeshPhongMaterial({ // shininess: 0x101010, // specular: 0x101010, @@ -972,7 +993,6 @@ // mesh.receiveShadow = true; // // SPACE.platform.world.add(mesh); - platform.add(newWidget().loadVertices(bigv)); }); } @@ -1750,7 +1770,7 @@ if (isgcode) loadCode(e.target.result, 'gcode'); if (issvg) loadCode(e.target.result, 'svg'); if (isset) settingsImport(e.target.result, true); - if (ispng) loadImage(e.target.result); + if (ispng) loadImageDialog(e.target.result); if (--loaded === 0) platform.group_done(isgcode); }; if (isstl || ispng) { diff --git a/src/kiri/ui.js b/src/kiri/ui.js index 5840734e..074beb0c 100644 --- a/src/kiri/ui.js +++ b/src/kiri/ui.js @@ -89,9 +89,11 @@ let rnd = Date.now().toString(36); let any = $('mod-any'); let html = [ - `
`, - ``, + `
` ]; + if (message) { + html.push(``); + } if (opt.pre) { html = opt.pre.appendAll(html); } diff --git a/src/kiri/worker.js b/src/kiri/worker.js index 3882804a..d3cb8bab 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -278,6 +278,30 @@ KIRI.worker = { gray[gi++] = v; } } + let blur = parseInt(info.blur || 0); + while (blur-- > 0) { + let blur = new Uint8Array(width * height); + for (let y = 0; y < height; y++) { + for (let x = 0; x < width; x++) { + let xl = Math.max(x-1,0); + let xr = Math.min(x+1,width-1); + let yu = Math.max(y-1,0); + let yd = Math.min(y+1,height-1); + blur[x + width * y] = ( + gray[xl + (width * yu)] + + gray[x + (width * yu)] + + gray[xr + (width * yu)] + + gray[xl + (width * y)] + + gray[x + (width * y)] + // self + gray[xr + (width * y)] + + gray[xl + (width * yd)] + + gray[x + (width * yd)] + + gray[xr + (width * yd)] + ) / 9; + } + } + gray = blur; + } // create indexed mesh output let verts = new Float32Array(points * 3); let faces = new Uint32Array(flats * 6); @@ -315,7 +339,7 @@ KIRI.worker = { // create top vertices & faces VB = VI; let TL = VI; - if (true) for (let x = 0; x < width; x++) { + for (let x = 0; x < width; x++) { let y = 0; verts[vi++] = (-w2 + x) / div; verts[vi++] = (h2 - y) / div; diff --git a/src/license.js b/src/license.js index afb368bd..b24639ce 100644 --- a/src/license.js +++ b/src/license.js @@ -3,7 +3,7 @@ let terms = { COPYRIGHT: "Copyright (C) Stewart Allen - All Rights Reserved", LICENSE: "See the license.md file included with the source distribution", - VERSION: "2.4.D5" + VERSION: "2.4.D6" }; if (typeof(module) === 'object') { diff --git a/web/kiri/index.css b/web/kiri/index.css index 8bdfa9a5..c0254bab 100644 --- a/web/kiri/index.css +++ b/web/kiri/index.css @@ -126,6 +126,9 @@ th, tr, td, label { .grow { flex-grow: 1; } +.t-just { + text-align: justify; +} .a-start { align-items: flex-start; }