complete image import dialog. bump rev 2.4.d6
This commit is contained in:
parent
7807c813d9
commit
6b90e6a9bd
6 changed files with 60 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "grid-apps",
|
"name": "grid-apps",
|
||||||
"version": "2.4.5D",
|
"version": "2.4.6D",
|
||||||
"description": "grid.space 3d slice & modeling tools",
|
"description": "grid.space 3d slice & modeling tools",
|
||||||
"author": "Stewart Allen <sa@grid.space>",
|
"author": "Stewart Allen <sa@grid.space>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
||||||
|
|
@ -945,13 +945,34 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadImage(image) {
|
function loadImageDialog(image) {
|
||||||
KIRI.client.image2mesh({settings, png:image}, progress => {
|
const opt = {pre: [
|
||||||
|
"<div class='f-col a-center'>",
|
||||||
|
" <h3>Image Conversion</h3>",
|
||||||
|
" <p class='t-just' style='width:300px;line-height:1.5em'>",
|
||||||
|
" 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.",
|
||||||
|
" </p>",
|
||||||
|
" <div class='f-row'>",
|
||||||
|
" <label>blur value</label> <input id='png-blur' value='0' size='3'>",
|
||||||
|
" </div>",
|
||||||
|
"</div>"
|
||||||
|
]};
|
||||||
|
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");
|
API.show.progress(progress, "converting");
|
||||||
}, output => {
|
}, output => {
|
||||||
API.show.progress(0);
|
API.show.progress(0);
|
||||||
let {bigv, verts, index, vi, ii} = output;
|
let {bigv, verts, index} = output;
|
||||||
|
|
||||||
// let mat = new THREE.MeshPhongMaterial({
|
// let mat = new THREE.MeshPhongMaterial({
|
||||||
// shininess: 0x101010,
|
// shininess: 0x101010,
|
||||||
// specular: 0x101010,
|
// specular: 0x101010,
|
||||||
|
|
@ -972,7 +993,6 @@
|
||||||
// mesh.receiveShadow = true;
|
// mesh.receiveShadow = true;
|
||||||
//
|
//
|
||||||
// SPACE.platform.world.add(mesh);
|
// SPACE.platform.world.add(mesh);
|
||||||
|
|
||||||
platform.add(newWidget().loadVertices(bigv));
|
platform.add(newWidget().loadVertices(bigv));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1750,7 +1770,7 @@
|
||||||
if (isgcode) loadCode(e.target.result, 'gcode');
|
if (isgcode) loadCode(e.target.result, 'gcode');
|
||||||
if (issvg) loadCode(e.target.result, 'svg');
|
if (issvg) loadCode(e.target.result, 'svg');
|
||||||
if (isset) settingsImport(e.target.result, true);
|
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 (--loaded === 0) platform.group_done(isgcode);
|
||||||
};
|
};
|
||||||
if (isstl || ispng) {
|
if (isstl || ispng) {
|
||||||
|
|
|
||||||
|
|
@ -89,9 +89,11 @@
|
||||||
let rnd = Date.now().toString(36);
|
let rnd = Date.now().toString(36);
|
||||||
let any = $('mod-any');
|
let any = $('mod-any');
|
||||||
let html = [
|
let html = [
|
||||||
`<div class="confirm f-col a-stretch">`,
|
`<div class="confirm f-col a-stretch">`
|
||||||
`<label style="user-select:text">${message}</label>`,
|
|
||||||
];
|
];
|
||||||
|
if (message) {
|
||||||
|
html.push(`<label style="user-select:text">${message}</label>`);
|
||||||
|
}
|
||||||
if (opt.pre) {
|
if (opt.pre) {
|
||||||
html = opt.pre.appendAll(html);
|
html = opt.pre.appendAll(html);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -278,6 +278,30 @@ KIRI.worker = {
|
||||||
gray[gi++] = v;
|
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
|
// create indexed mesh output
|
||||||
let verts = new Float32Array(points * 3);
|
let verts = new Float32Array(points * 3);
|
||||||
let faces = new Uint32Array(flats * 6);
|
let faces = new Uint32Array(flats * 6);
|
||||||
|
|
@ -315,7 +339,7 @@ KIRI.worker = {
|
||||||
// create top vertices & faces
|
// create top vertices & faces
|
||||||
VB = VI;
|
VB = VI;
|
||||||
let TL = VI;
|
let TL = VI;
|
||||||
if (true) for (let x = 0; x < width; x++) {
|
for (let x = 0; x < width; x++) {
|
||||||
let y = 0;
|
let y = 0;
|
||||||
verts[vi++] = (-w2 + x) / div;
|
verts[vi++] = (-w2 + x) / div;
|
||||||
verts[vi++] = (h2 - y) / div;
|
verts[vi++] = (h2 - y) / div;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
let terms = {
|
let terms = {
|
||||||
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
||||||
LICENSE: "See the license.md file included with the source distribution",
|
LICENSE: "See the license.md file included with the source distribution",
|
||||||
VERSION: "2.4.D5"
|
VERSION: "2.4.D6"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof(module) === 'object') {
|
if (typeof(module) === 'object') {
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,9 @@ th, tr, td, label {
|
||||||
.grow {
|
.grow {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
|
.t-just {
|
||||||
|
text-align: justify;
|
||||||
|
}
|
||||||
.a-start {
|
.a-start {
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue