/* stl2web.js - image sequence viewer. * Part of STL2Web. A 3D object viewer and composing system. * by Erik de Bruijn * Licence: GPLv3. See: http://www.gnu.org/copyleft/gpl.html * * Changes: * v0.1 2009-03-29 First version (Can walk through a one-dimensional numbered sequence (pre-built animation). * TODOs: * - distributed rendering system (sort this out server side, use lowest latency server, write to cookie) * - controls * - playback & record movement paths (fly over object, highlight a detail, etc.) * - set object color (and perhaps even the material PLA,ABS, etc.) * - scene customization: * bg color, shadow on/off, grid on/off, put the rendering on top of a tabletop, put pencil besides it, etc. * - STL upload and fetching feature (e.g. fetch from thingiverse) * - Download/export as movie/.mjpeg/ani-gif?, etc. * - Allow various image sizes */ var r; $(document).ready(function(){ ri = 'Wineglass'; r= new Renderer(ri,'/stl2web/img/'); //r.debug = true; r.setFrameRate(2); r.animate(0,30); i = $(".s2wi"); }); function Renderer(ri,ipfx) { // renderer values var frame = 0; var frameInterval = 10; //binding var frameRate = 5; //non binding var startFrame = 0; var stopFrame = 4; var interval; // used to keep track of the setInterval() thread var debug = false; var imgPrefix = '/stl2web/img/'; // define function this.toggleDebug = toggleDebug; this.setFrameRate = rSetFrameRate; this.animate = rAnimate; this.pause = rPause; this.resume = rResume; this.showFrame = rShowFrame; this.nextFrame = rNextFrame; this.log = log; this.reset = rReset; if(ipfx) this.imgPrefix = ipfx; this.log(ipfx); this.reset(); } function log(str) { if(this.debug) console.log(str); } function rSetFrameRate(frameRate) { this.frameRate = frameRate; this.frameInterval = 1000/frameRate; } /* Reset or initialize the rendering */ function rReset() { $("div.stl2web").text(' '); // empty it all // populate it //$("div.stl2web").append(""); $("div.stl2web").append(""); $("div.stl2web").append("