Javascript Slicing API Live Tester

With the 2.5 release, there is a new easy way to include Kiri’s slicing engine into your web app. It’s a single script include that injects a web worker into the page that can asynchronous perform any of Kiri’s slicing functions without interrupting your UI.

Take a look and let me know what you think.

2 Likes

That’s interesting Stewart. It sorta had me perplexed for a while (what might I want to do with this?) but I have a use case in mind that I think this could be handy for.

My CNC is connected to a system running bCNC for G-code streaming. Typically I would do the CAD work, then export that and load it into Kiri:Moto and do the CAM, then I export that to somewhere reachable from the CNC system and load it into bCNC there, then mess with origins etc. before starting the cutting.

However, it looks like I could script all the CAM parts using the API. The demo looks like it does everything I would need to except pulling out the G-code itself into a file on the CNC controller. If I knew anything about js I am sure that part would be trivial, but I am not there yet.

Anyway, I am always happy to see APIs for things so thanks for this!

1 Like

All good and beautiful.
Except I can’t find detailed documentation on the api. It won’t be possible configure machine and slice parameters. It is not being provided any decent form of development guide to the tool, also.
Can you help me (and others, surely) with this?

for now, you can map the parameter to the english help text using src/kiri/init.js

starting around line 1575. or just grep the file for the parameter you’re curious about. the strings are short _s (label) and long _l (hover text) and appear like this:

LANG.dv_nozl_l

and are mapped into this language file web/kiri/lang/en.js

src/kiri/conf.js has the default structure for each device and profile for each mode (fdm/cam/laser/sla) starting at line 270.

I would welcome a commit that abstracts the two so documentation can be programmatically generated. but this evolved over several years, and I haven’t had the time.

1 Like

Thank you so much.

other topic about it: the code is probably bleeding memory (worker.js). Would you like to try to help me understand it better so maybe we could try to fix it?

are you using 3.0 or 2.9? why do you suspect a memory leak? I’ve used Chrome’s memory profiling extensively looking for leaks and am not aware of any.

I use A 16Gb computer and was trying to slice under 3 mb stls on 5 micron and it hangs during the operation. even the 8gb profile it is stated on your site is huge for a procedure as simple as slicing. a linux slicer could do the job with 256mb. maybe it is something else, but I really like your project and I have some almost 30 years experience in software designing and programming. Before I found your slicer, I was thinking on doing something similar for embedding in my wifi printer. But you already done it and it is working very well for small stls or slices bigger than 15 microns (using almost all available memory).

Javascript is far more constrained with things like memory management. And no shared memory. 3.0 introduced workers/threads and expanded use of WebAssembly for some code. Still a lot of room for improvements and speedups. Running in Chromium based browsers is going to be a lot faster than Node on the command line until I (or anyone) implement a proper “worker” substitute for that environment.

1 Like

Hi Stewart, I managed to extend your cli.js to KiriMotoSlicer - and I released it at https://github.com/Spiritdude/KiriMotoSlicer so I can use it within my 3d printing pipeline as illustrated in https://xyzdims.com/about/ (“Big Picture” section).

It’s a very early release, feel free to adapt or include in the original Kiri:Moto repo if you think it fits; I’m moderately skilled with git as my way coding clashes with its inner working.

1 Like

@Spiritdude looks good. Let me know if you need more info to improve this.

Let me know if you need more info to improve this.

A few things actually, do you store the version of Kiri:Moto somewhere, I like to display/reference it, I didn’t find it anywhere in

let kiri = self.kiri;
let moto = self.moto;
let engine = kiri.newEngine();

Also, in the slicing settings you have one key which is named sName, what does it stand for, and is it relevant (I did a quick search in your repo, and it doesn’t appear anywhere later)?

sName looks like a typo. it should be processName.

kiri.version should report the version name.

sName looks like a typo. it should be processName.

OK, will fix it.

kiri.version should report the version name.

Returns undefined, do you set it somewhere within web bootstrap and therefore not happening in the cli? It seems you set it in license.js, and in your cli.js the license is also listed and processed, but somehow it doesn’t set in self.kiri and therefore not in kiri as well.

fixed in this commit

:+1: Thank you. KiriMotoSlicer displays now version properly:

% ./kirimoto-slicer --version
KiriMotoSlicer 0.0.6 (Kiri:Moto 3.0.D19, node v14.15.5)
1 Like

Hi, I have been trying to use the Kiri:Moto API by following the example but when I run it locally, the slice() function does not return anything—no errors, no output. The program flow also stops at the slice() function call.

I am also getting the console log error Failed to load resource: the server responded with a status of 404 (Not Found) for the file code/kiri_work.js?3.2.1:1. Could that be related to the error?

we just discussed a related issue on the Discord server. are you running your own local server and loading the engine.js script? if so, you need to create a code directory and put copies of kiri_work.js and kiri_pool.js in there.

1 Like

Yes, I was doing exactly that. I tried looking for kiri_work.js and kiri_pool.js but unfortunately I was unable to find the files. Could you please point me to exactly where the files are?

they are synthesized are runtime by the grid-apps server. just curl them from grid.space or run local grid-apps and curl from that

@stewart, can we have a full documentation of integrating Kiri Moto on web. We are doing some research regarding 3d printing & resp. G-Code extraction. We have tested JS you sent, but there are some issues regarding the complete working of libraries. Can you please shed some light into it.

We are using this link, Kiri:Moto Javascript Engine API

Thanks in advance!