wire up default png loading into load.file for mesh:tool
This commit is contained in:
parent
87df96d23f
commit
b6e0c1783b
3 changed files with 13 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ if (load.File) return;
|
|||
// dep: load.stl
|
||||
// dep: load.svg
|
||||
// dep: load.url
|
||||
// dep: load.png
|
||||
gapp.register('load.file', []);
|
||||
|
||||
load.File = {
|
||||
|
|
@ -52,6 +53,13 @@ function load_data(data, file, ext) {
|
|||
case "svg":
|
||||
resolve(load.SVG.parse(data).map(m => { return {mesh: m.toFloat32(), file} }));
|
||||
break;
|
||||
case "png":
|
||||
load.PNG.parse(data, {
|
||||
done(data) {
|
||||
resolve({ mesh: data, file });
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
reject(`unknown file type: "${ext}" from ${file}`);
|
||||
break;
|
||||
|
|
@ -76,7 +84,7 @@ function load_file(file) {
|
|||
.then(data => resolve(data))
|
||||
.catch(e => reject(e));
|
||||
};
|
||||
if (ext === 'stl') {
|
||||
if (["stl","png","3mf"].indexOf(ext) >= 0) {
|
||||
reader.readAsArrayBuffer(reader.file);
|
||||
} else {
|
||||
reader.readAsBinaryString(reader.file);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,9 @@ function parse(bin, opt = {}) {
|
|||
let ondone = opt.done || noop;
|
||||
img.parse(bin, (err, output) => {
|
||||
let { width, height, data } = output;
|
||||
let { outHeight, outWidth } = opt;
|
||||
// let { outHeight, outWidth } = opt;
|
||||
let outHeight = opt.outHeight || height;
|
||||
let outWidth = opt.outWidth || width;
|
||||
let imageAspect = height / width;
|
||||
let deviceAspect = outHeight / outWidth;
|
||||
let div = 1;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function parse(text, opt = {}) {
|
|||
bevelEnabled: false
|
||||
});
|
||||
let array = geom.attributes.position.array;
|
||||
// invert y
|
||||
// invert y (todo: invert vertex order otherwise normals inverted)
|
||||
for (let i=0; i<array.length; i+=3) {
|
||||
array[i+1] = -array[i+1];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue