toxiclibs.js load stl?
in
Processing with Other Languages
•
11 months ago
does anyone know if it is possible to load stl files with toxiclibs.js? i can't seem to get the STLReader to work...
- <!DOCTYPE html>
<head>
<script src="processing.js" type="text/javascript"></script>
<script src="toxiclibs.js" type="text/javascript"></script>
</head>
<body>
<script type="text/processing" data-processing-target="myCanvas">
var TriangleMesh = toxi.geom.mesh.TriangleMesh,
ToxiclibsSupport = toxi.processing.ToxiclibsSupport;
import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.processing.*;
TriangleMesh mesh;
ToxiclibsSupport gfx;
void setup()
{
size(500,500,OPENGL);
mesh=(TriangleMesh)new STLReader().loadBinary("myModel.stl",STLReader.TRIANGLEMESH);
gfx=new ToxiclibsSupport(this);
}
void draw()
{
background(0);
fill(255);
pushMatrix();
translate(20,20,0);
scale(40,40,40);
gfx.mesh(mesh,true);
popMatrix();
}
</script>
<canvas id="myCanvas" width="500" height="500">
<p>Your browser does not support the canvas tag.</p>
<!-- Note: you can put any alternative content here. -->
</canvas>
<noscript>
<p>JavaScript is required to view the contents of this page.</p>
</noscript>
</body>
</html>
1