test bambu 3mf and sending

This commit is contained in:
Stewart Allen 2024-12-10 11:59:33 -05:00
commit 6ac07976f8
5 changed files with 817 additions and 12 deletions

View file

@ -1308,10 +1308,39 @@ gapp.register("moto.space", [], (root, exports) => {
return {
url: ncv.toDataURL(param.format || "image/png", param.options),
width: ncv.width,
height: ncv.height
height: ncv.height,
};
},
screenshot3(param = {}) {
let oco = renderer.domElement;
let oWidth = oco.offsetWidth;
let oHeight = oco.offsetHeight;
let oRatio = oWidth / oHeight;
let width = param.width || 512;
let height = param.height || width;
let nRatio = width / height;
let ncv = document.createElement('canvas');
ncv.width = width;
ncv.height = height;
let nco = ncv.getContext('2d');
let ox = 0, oy = 0;
if (oRatio > nRatio) {
let tmp = oWidth;
oWidth = oHeight * nRatio;
ox = (tmp - oWidth) / 2;
} else {
let tmp = oHeight;
oHeight = oWidth * nRatio;
oy = (tmp - oHeight) / 2;
}
nco.drawImage(oco, ox, oy, oWidth, oHeight, 0, 0, width, height);
if (param.out) {
ncv.toBlob(blob => blob.arrayBuffer().then(png => param.out({ png, width, height })));
}
return ncv;
},
internals: () => {
return { renderer, camera, platform };
},