Calling all programmers!  For the past month (or longer) I've been trying to get

Calling all programmers! For the past month (or longer) I’ve been trying to get a STL Viewer Widget working for Chilipeppr (a cnc control workspace that runs in your browser and has very powerful capabilities like milling circuit boards from just an eagle file).
I haven’t gotten very far - as Edison would say, I’ve found 529 ways not to make it work. Parsing an STL isn’t actually that hard, there are multiple libraries out there and the logic is fairly straightforward. I can explain what needs to happen in an extreme level of detail, I’ve already done a lot of the research, and I just need someone else to put fingers to keyboard and make the code [that works] happen.
Why, may you ask? Because there’s no 3D Printing workspace that lets you set up all your objects in the browser yet [that I know of]. Octoprint, Astroprint, and 3DPrinterOS all let you upload a single STL file and shoot it off to their respective servers for slicing without letting you interact with it in any way. Now there’s no Javascript based slicer out there yet, so we still need to make an API call to generate the actual gCode, but it would be so much nicer to actually be able to render and interact with the object you want to print, lay out a build plate with multiple objects, resize, mirror, rotate, and drag them around as necessary, all in your browser client-side before making a single AJAX call to a server to do the slicing (gcode generation) in the cloud. We get the gCode back from the cloud and we can preview it and send it to a printer.

There are 3 of us (John Lauer, Frank Hermann, and myself) working on developing various features into Chilipeppr that tie into our grand vision of integrating electronics inside printed plastic objects, which would probably spark the 2nd IOT revolution. Wouldn’t it be awesome to be a part of that?

Contact me/ comment here for more details, with questions, or anything else!
http://chilipeppr.com/

https://github.com/andrewhodel/reprapweb/blob/master/i/main.js#L616 calls https://github.com/andrewhodel/reprapweb/blob/master/i/jsc3d/jsc3d.js#L5620

The jsc3d model can be modified, rotated, etc.

@Andrew_Hodel This is extremely thorough, thank you! This is the first single method that handles ASCII and Binary files I’ve seen for JS. Chilipeppr handles file upload a different way, but I’ve known for a while that switching over to FileReader needs to happen since binary stls aren’t just plain text that can be handled in simple fashions. I’m working on putting your code in.

@raykholo ​ yeah I’m setting that up for the next version of BotQueue. Right now it only supports a single file as well. The implementation I use does a decent job in most cases. The part I’m seeing when rewriting is that I don’t know how to put it back together, especial an amf file for dual extrusion

@raykholo you are welcome to use it for an STL Viewer Widget which is used by Chilipeppr for 3d Printing.

@Justin_Nesselrotte I don’t think you need to worry about reading an AMF file. If you do want to though, Repetier Host can natively import it and you should check out their source from the version 0.95[F] I think…They closed source around v1… It’s C# but you should get the idea.
Anyways - for multi-extrusion most people export the individual STL files per material from their CAD software, upload it that way to Thingiverse, and would have to use Slic3r to make an AMF file. All you need is to create this AMF file on the server side before you invoke Slic3r (you would pass it the one AMF file and the ini file with param1, param2 for slic3r values that are unique for dual extrusion). Couple of somewhat promising leads from a google search.
Point was, if you want to render on client side using ThreeJS, you can keep each STL as it’s own mesh, position them with the same coordinates, and export each STL based on the global coordinates after user has done all manipulations and is ready for slicing.
@Andrew_Hodel Thanks!

@raykholo ​ oh no reading amf isn’t the difficult part, it’s writing it back out from js that I’m having trouble with. Although, now that I think about it, the STL files are already uploaded, I could just send back location and orientation information and have a server job do it

@Justin_Nesselrotte Exactly. Export individual STLs and script the AMF creation server side.

You can do dual extrusion with gcode.

AMF is just false complexity for the sake of itself.

If you’re hard on about AMF writing an exporter shouldn’t be too hard, unless of course it is magic.

@Andrew_Hodel ​ yes but you can’t do dual extrusion via stl which is why amf was used in the first place. Of course you can do dual extrusion via g-code, there would hardly be any point otherwise. :smiley:

@Justin_Nesselrotte via stl? What do you mean, per what Slicer?

If a Slicer can combine 2 stl’s and output an amf it can output gcode.

@Andrew_Hodel ​ yes, but I’m talking about file formats themselves. An stl cannot hold the information necessary for dual extrusion. The slicer is irrelevant