fix engine api example. add code download
This commit is contained in:
parent
c0ff5d7ac7
commit
2d9bc91973
3 changed files with 40 additions and 5 deletions
2
notes.md
2
notes.md
|
|
@ -26,8 +26,8 @@
|
||||||
* `B` multi-extruder rendering of raft fails to offset the rest of the print
|
* `B` multi-extruder rendering of raft fails to offset the rest of the print
|
||||||
* `B` multi-extruder purge blocks fail to generate properly for rafts
|
* `B` multi-extruder purge blocks fail to generate properly for rafts
|
||||||
|
|
||||||
|
* `F` more explicit line width control with ranges and min/max adaptive
|
||||||
* `F` test outlining solid projected areas (internally)
|
* `F` test outlining solid projected areas (internally)
|
||||||
* `F` slicing controls per user-defined z-region
|
|
||||||
* `F` control for size of purge block (with 0=disabled)
|
* `F` control for size of purge block (with 0=disabled)
|
||||||
* `F` polishing and other non-planar work
|
* `F` polishing and other non-planar work
|
||||||
* `F` gradient infill https://www.youtube.com/watch?v=hq53gsYREHU&feature=emb_logo
|
* `F` gradient infill https://www.youtube.com/watch?v=hq53gsYREHU&feature=emb_logo
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
let KIRI = self.kiri = self.kiri || {};
|
let KIRI = self.kiri = self.kiri || {};
|
||||||
KIRI.newEngine = ()=> { return new Engine ()};
|
KIRI.newEngine = ()=> { return new Engine ()};
|
||||||
|
|
||||||
|
if (!KIRI.api) {
|
||||||
|
KIRI.api = {
|
||||||
|
event: {
|
||||||
|
emit: () => {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class Engine {
|
class Engine {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.widget = KIRI.newWidget();
|
this.widget = KIRI.newWidget();
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,12 @@
|
||||||
#jbody, #gbody {
|
#jbody, #gbody {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
}
|
}
|
||||||
#jfoot {
|
#jfoot, #dfoot {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
#jfoot button {
|
#jfoot button, #dfoot button {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
#gbody {
|
#gbody {
|
||||||
|
|
@ -58,6 +58,7 @@
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
#gfoot {
|
#gfoot {
|
||||||
|
display: none;
|
||||||
background-color: rgba(61,133,198,0.25);
|
background-color: rgba(61,133,198,0.25);
|
||||||
border-top: 1px solid #aaa;
|
border-top: 1px solid #aaa;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
|
@ -66,6 +67,9 @@
|
||||||
#api {
|
#api {
|
||||||
width: 812px;
|
width: 812px;
|
||||||
}
|
}
|
||||||
|
#download {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
li {
|
li {
|
||||||
list-style: circle;
|
list-style: circle;
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +81,7 @@
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"></script>
|
||||||
<script src="/code/engine.js"></script>
|
<script src="/code/engine.js"></script>
|
||||||
<script>
|
<script>
|
||||||
let edit;
|
let edit, saveit = "";
|
||||||
function $(id) { return document.getElementById(id) }
|
function $(id) { return document.getElementById(id) }
|
||||||
function onload() {
|
function onload() {
|
||||||
let fnstr = demo.toString().split("\n");
|
let fnstr = demo.toString().split("\n");
|
||||||
|
|
@ -97,10 +101,14 @@
|
||||||
$('gfoot').innerText = msg ? Object.keys(msg).join(' - ') : '';
|
$('gfoot').innerText = msg ? Object.keys(msg).join(' - ') : '';
|
||||||
}
|
}
|
||||||
function display_gcode(gcode) {
|
function display_gcode(gcode) {
|
||||||
$('gbody').innerText = gcode;
|
$('gbody').innerText = saveit = gcode;
|
||||||
display_message();
|
display_message();
|
||||||
|
$('dfoot').style.display = 'block';
|
||||||
|
$('gfoot').style.display = '';
|
||||||
}
|
}
|
||||||
function run_code() {
|
function run_code() {
|
||||||
|
$('dfoot').style.display = 'none';
|
||||||
|
$('gfoot').style.display = 'block';
|
||||||
let code = edit.session.getValue();
|
let code = edit.session.getValue();
|
||||||
eval(`(function(){${code}})()`);
|
eval(`(function(){${code}})()`);
|
||||||
}
|
}
|
||||||
|
|
@ -108,11 +116,28 @@
|
||||||
kiri.newEngine()
|
kiri.newEngine()
|
||||||
.setListener(display_message)
|
.setListener(display_message)
|
||||||
.load("/obj/cube.stl")
|
.load("/obj/cube.stl")
|
||||||
|
.then(eng => eng.setProcess({
|
||||||
|
sliceShells: 1,
|
||||||
|
sliceFillSparse: 0.25,
|
||||||
|
sliceTopLayers: 2,
|
||||||
|
sliceSolidLayers: 2,
|
||||||
|
sliceBottomLayers: 2
|
||||||
|
}))
|
||||||
|
.then(eng => eng.setDevice({
|
||||||
|
gcodePre: [ "M82", "M104 S220" ],
|
||||||
|
gcodePost: [ "M107" ]
|
||||||
|
}))
|
||||||
.then(eng => eng.slice())
|
.then(eng => eng.slice())
|
||||||
.then(eng => eng.prepare())
|
.then(eng => eng.prepare())
|
||||||
.then(eng => eng.export())
|
.then(eng => eng.export())
|
||||||
.then(display_gcode);
|
.then(display_gcode);
|
||||||
}
|
}
|
||||||
|
function download() {
|
||||||
|
let blob = new Blob([saveit], {type: "octet/stream"});
|
||||||
|
let url = window.URL.createObjectURL(blob);
|
||||||
|
$('download').innerHTML = `<a id="xo" href="${url}" download="sample.gcode"></a>`;
|
||||||
|
$('xo').click();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="onload()">
|
<body onload="onload()">
|
||||||
|
|
@ -127,6 +152,7 @@
|
||||||
<div id="ghead">gcode output</div>
|
<div id="ghead">gcode output</div>
|
||||||
<div id="gbody"></div>
|
<div id="gbody"></div>
|
||||||
<div id="gfoot"></div>
|
<div id="gfoot"></div>
|
||||||
|
<div id="dfoot"><button onclick="download()">download</button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="api">
|
<div id="api">
|
||||||
|
|
@ -145,5 +171,6 @@
|
||||||
<li><label>prepare()</label> - async path routing of slice data</li>
|
<li><label>prepare()</label> - async path routing of slice data</li>
|
||||||
<li><label>export()</label> - async gcode generation from path routing</li>
|
<li><label>export()</label> - async gcode generation from path routing</li>
|
||||||
</div>
|
</div>
|
||||||
|
<a id="download"></a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue