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

File diff suppressed because one or more lines are too long

View file

@ -32,6 +32,9 @@ function prepareSlices(callback, scale = 1, offset = 0) {
let snap = space.screenshot();
view.snapshot = snap.substring(snap.indexOf(",") + 1);
client.snap(space.screenshot2({ width: 640 }));
let bambu = view.bambu = { };
space.screenshot3({ width: 512, out(png) { bambu.s512 = png } });
space.screenshot3({ width: 128, out(png) { bambu.s128 = png } });
}
if (mode.is_sla() && !callback) {

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 };
},

View file

@ -1670,6 +1670,8 @@ details[open] > summary::after {
height: 12em;
font-size: smaller;
font-family: Courier,monospace;
white-space: nowrap;
resize: none;
}
.mod-end {
height: 10px;

View file

@ -595,15 +595,16 @@
<div><label>filament used (mm)</label><input id="print-filament" size="12" disabled="true" /></div>
<div><label>printed weight (g)</label><input id="print-weight" size="12" disabled="true" /></div>
</div>
<div id="code-preview-head" class="header"><label>code preview</label></div>
<div id="code-preview-head" class="header"><label>preview</label></div>
<div id="code-preview" class="f-col box">
<div><textarea id="code-preview-textarea"></textarea></div>
</div>
<div class="header"><label>gcode</label></div>
<div class="header"><label>download</label></div>
<div class="f-row box">
<button id="print-download" class="grow">download</button>
<button id="print-download" class="grow">gcode</button>
<button id="print-palette" class="grow">palette</button>
<button id="print-zip" class="grow">zip file</button>
<button id="print-zip" class="grow">zip</button>
<button id="print-3mf" class="grow">3mf</button>
</div>
<div id="send-to-octohead" class="header"><label>octoprint</label></div>
<div id="send-to-octoprint" class="f-col box">