From 5ff9d0e8b99dd660bf207447d2f66796a2d312f9 Mon Sep 17 00:00:00 2001 From: Matthew Minuti Date: Fri, 18 Sep 2015 18:57:03 -0400 Subject: [PATCH] Updated version number to more accurately reflect changes. --- blockscad/blockscad.js | 2 +- blockscad/blockscad_compressed.js | 132 +++++++++++++++--------------- index.html | 2 +- 3 files changed, 68 insertions(+), 68 deletions(-) diff --git a/blockscad/blockscad.js b/blockscad/blockscad.js index 85655f45..6fcf4b18 100644 --- a/blockscad/blockscad.js +++ b/blockscad/blockscad.js @@ -30,7 +30,7 @@ BlocklyStorage = BlocklyStorage || {}; var Blockly = Blockly || {}; var BSUtils = BSUtils || {}; -Blockscad.version = "1.0.1"; +Blockscad.version = "1.1.0"; Blockscad.offline = true; diff --git a/blockscad/blockscad_compressed.js b/blockscad/blockscad_compressed.js index 1cfb0fb0..f6d24c95 100644 --- a/blockscad/blockscad_compressed.js +++ b/blockscad/blockscad_compressed.js @@ -1,12 +1,12 @@ // Do not edit this file; automatically generated by blockscad_build.py. "use strict"; var BlocklyStorage=BlocklyStorage||{},Blockscad=Blockscad||{};Blockscad.Auth=Blockscad.Auth||{};var Blockly=Blockly||{};Blockly.Xml=Blockly.Xml||{}; -BlocklyStorage.backupBlocks_=function(){console.log("in backupBlocks");if("localStorage"in window){localStorage.clear();for(var a=Blockly.Xml.workspaceToDom(Blockscad.workspace),d=window.location.href.split("#")[0],e=d+"proj_name",h=d+"current_project",m=Blockscad.workspace.getAllBlocks(),k=0;kBlockscad.csg_commands[l].length){var n=Base64.toBase64(RawDeflate.deflate(Base64.utob(Blockscad.csg_commands[l]))); -window.localStorage.setItem(q,n);window.localStorage.setItem(w,Blockscad.csg_center[l])}}}window.localStorage.setItem(d,Blockly.Xml.domToText(a));window.localStorage.setItem(e,$("#project-name").val());window.localStorage.setItem(h,Blockscad.Auth.current_project)}};BlocklyStorage.backupOnUnload=function(){window.addEventListener("unload",BlocklyStorage.backupBlocks_,!1)}; -BlocklyStorage.restoreBlocks=function(){var a=window.location.href.split("#")[0],d=a+"proj_name",e=a+"current_project";console.log(window.localStorage);if("localStorage"in window&&window.localStorage[a]){var h=Blockly.Xml.textToDom(window.localStorage[a]);Blockly.Xml.domToWorkspace(Blockscad.workspace,h);for(var h=Blockscad.workspace.getAllBlocks(),m=0;mBlockscad.csg_commands[l].length){var n=Base64.toBase64(RawDeflate.deflate(Base64.utob(Blockscad.csg_commands[l]))); +window.localStorage.setItem(r,n);window.localStorage.setItem(w,Blockscad.csg_center[l])}}}window.localStorage.setItem(d,Blockly.Xml.domToText(a));window.localStorage.setItem(e,$("#project-name").val());window.localStorage.setItem(h,Blockscad.Auth.current_project)}};BlocklyStorage.backupOnUnload=function(){window.addEventListener("unload",BlocklyStorage.backupBlocks_,!1)}; +BlocklyStorage.restoreBlocks=function(){var a=window.location.href.split("#")[0],d=a+"proj_name",e=a+"current_project";console.log(window.localStorage);if("localStorage"in window&&window.localStorage[a]){var h=Blockly.Xml.textToDom(window.localStorage[a]);Blockly.Xml.domToWorkspace(Blockscad.workspace,h);for(var h=Blockscad.workspace.getAllBlocks(),m=0;me[0]?1:a[0]screen.availWidth&&a.setAttribute("content","width=725, initial-scale=.35, user-scalable=no")}; @@ -14,8 +14,8 @@ BSUtils.initReadonly=function(){Blockly.inject(document.getElementById("blockly" BSUtils.loadBlocks=function(a){try{var d=window.sessionStorage.loadOnceBlocks}catch(e){d=null}"BlocklyStorage"in window&&1=d.length?"?lang="+a:d.match(/[?&]lang=[^&]*/)?d.replace(/([?&]lang=)[^&]*/,"$1"+a):d.replace(/\?/,"?lang="+a+"&");window.location=window.location.protocol+"//"+ window.location.host+window.location.pathname+d};BSUtils.isDialogVisible_=!1;BSUtils.dialogOrigin_=null;BSUtils.dialogDispose_=null; -BSUtils.showDialog=function(a,d,e,h,m,k){function l(){BSUtils.isDialogVisible_&&(q.style.visibility="visible",q.style.zIndex=1,w.style.visibility="hidden")}BSUtils.isDialogVisible_&&BSUtils.hideDialog(!1);BSUtils.isDialogVisible_=!0;BSUtils.dialogOrigin_=d;BSUtils.dialogDispose_=k;var q=document.getElementById("dialog");k=document.getElementById("dialogShadow");var w=document.getElementById("dialogBorder"),n;for(n in m)q.style[n]=m[n];h&&(k.style.visibility="visible",k.style.opacity=.3,h=document.createElement("div"), -h.id="dialogHeader",q.appendChild(h),BSUtils.dialogMouseDownWrapper_=Blockly.bindEvent_(h,"mousedown",null,BSUtils.dialogMouseDown_));q.appendChild(a);a.className=a.className.replace("dialogHiddenContent","");e&&d?(BSUtils.matchBorder_(d,!1,.2),BSUtils.matchBorder_(q,!0,.8),window.setTimeout(l,175)):l()};BSUtils.dialogStartX_=0;BSUtils.dialogStartY_=0; +BSUtils.showDialog=function(a,d,e,h,m,k){function l(){BSUtils.isDialogVisible_&&(r.style.visibility="visible",r.style.zIndex=1,w.style.visibility="hidden")}BSUtils.isDialogVisible_&&BSUtils.hideDialog(!1);BSUtils.isDialogVisible_=!0;BSUtils.dialogOrigin_=d;BSUtils.dialogDispose_=k;var r=document.getElementById("dialog");k=document.getElementById("dialogShadow");var w=document.getElementById("dialogBorder"),n;for(n in m)r.style[n]=m[n];h&&(k.style.visibility="visible",k.style.opacity=.3,h=document.createElement("div"), +h.id="dialogHeader",r.appendChild(h),BSUtils.dialogMouseDownWrapper_=Blockly.bindEvent_(h,"mousedown",null,BSUtils.dialogMouseDown_));r.appendChild(a);a.className=a.className.replace("dialogHiddenContent","");e&&d?(BSUtils.matchBorder_(d,!1,.2),BSUtils.matchBorder_(r,!0,.8),window.setTimeout(l,175)):l()};BSUtils.dialogStartX_=0;BSUtils.dialogStartY_=0; BSUtils.dialogMouseDown_=function(a){BSUtils.dialogUnbindDragEvents_();if(!Blockly.isRightButton(a)){var d=document.getElementById("dialog");BSUtils.dialogStartX_=d.offsetLeft-a.clientX;BSUtils.dialogStartY_=d.offsetTop-a.clientY;BSUtils.dialogMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",null,BSUtils.dialogUnbindDragEvents_);BSUtils.dialogMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",null,BSUtils.dialogMouseMove_);a.stopPropagation()}}; BSUtils.dialogMouseMove_=function(a){var d=document.getElementById("dialog"),e=BSUtils.dialogStartX_+a.clientX;a=BSUtils.dialogStartY_+a.clientY;a=Math.max(a,0);a=Math.min(a,window.innerHeight-d.offsetHeight);e=Math.max(e,0);e=Math.min(e,window.innerWidth-d.offsetWidth);d.style.left=e+"px";d.style.top=a+"px"}; BSUtils.dialogUnbindDragEvents_=function(){BSUtils.dialogMouseUpWrapper_&&(Blockly.unbindEvent_(BSUtils.dialogMouseUpWrapper_),BSUtils.dialogMouseUpWrapper_=null);BSUtils.dialogMouseMoveWrapper_&&(Blockly.unbindEvent_(BSUtils.dialogMouseMoveWrapper_),BSUtils.dialogMouseMoveWrapper_=null)}; @@ -26,17 +26,17 @@ BSUtils.getBBox_=function(a){var d=a.offsetHeight,e=a.offsetWidth,h=0,m=0;do h+= BSUtils.storageAlert=function(a){var d=document.getElementById("containerStorage");d.textContent="";a=a.split("\n");for(var e=0;e$("#main").height()-$(".resizableDiv").height()&&$(".resizableDiv").height($("#main").height()-70);20>$("#main").width()-$(".resizableDiv").width()&&$(".resizableDiv").width($("#main").width()- 20);$(".resizableDiv").position({of:$("#main"),my:"right top",at:"right top",offset:"-12 -55"})},!1);Blockscad.workspace=Blockly.inject(document.getElementById("blocklyDiv"),{media:"blockly/media/",zoom:{enabled:!0,scaleSpeed:1.1,controls:!0},trashcan:!1,toolbox:Blockscad.Toolbox.adv});Blockscad.Toolbox.setColorScheme(Blockscad.Toolbox.colorScheme.one);Blockscad.Toolbox.setCatColors();$("#advancedToolbox").hide();BSUtils.loadBlocks("");"BlocklyStorage"in window&&BlocklyStorage.backupOnUnload();$(".resizableDiv").resizable({handles:"s,w,sw", resize:function(a,d){var m=$(window).height();gProcessor&&(m=gProcessor.viewerdiv.offsetHeight,gProcessor.viewer.rendered_resize(gProcessor.viewerdiv.offsetWidth,m));20>$("#main").width()-d.size.width&&(d.size.width=$("#main").width()-20);70>$("#main").height()-d.size.height&&(d.size.height=$("#main").height()-70);d.position.left=$(window).width()-(d.size.width+12);d.position.top=55}});Blockly.fireUiEvent(window,"resize");Blockscad.offline||Blockscad.Auth.init();BSUtils.bindClick("trashButton",function(){Blockscad.discard()}); BSUtils.bindClick("renderButton",Blockscad.doRender);BSUtils.bindClick("undoButton",Blockscad.onUndo);BSUtils.bindClick("redoButton",Blockscad.onRedo);$("#axesButton").click(function(){Blockscad.drawAxes=(Blockscad.drawAxes+1)%2;$("#axesButton").toggleClass("btn-pushed");gProcessor.viewer.onDraw()});$("#displayCode").click(function(){var a=document.getElementById("openScadPre"),d=Blockly.OpenSCAD.workspaceToCode(Blockscad.workspace);a.textContent=d;"function"==typeof prettyPrintOne&&(d=a.innerHTML, -d=prettyPrintOne(d,"js"),a.innerHTML=d);Blockly.fireUiEvent(window,"resize")});$("#renderButton").prop("disabled",!0);$("#throw-it-away").click(Blockscad.clearProject);$("#main").on("click",".new-project",Blockscad.newProject);Blockscad.readStlFile=function(a){var d=a.target.files[0];d?(a=new FileReader,a.onload=function(a){a=importSTL(a.target.result);var e=a[0];(a=a[1])||(a="blah");for(var l=d.name.substr(0,d.name.lastIndexOf("("))||d.name,l=l.substr(0,d.name.lastIndexOf("."))||l,q=l=l.replace(/^\s+|\s+$/g, -""),w=1,n=0;Blockscad.csg_commands[q]&&!n;)e!=Blockscad.csg_commands[q]?(q=l+"_"+w,w++):n=1;Blockscad.csg_commands[q]=e;Blockscad.csg_filename[q]=n?Blockscad.csg_filename[q]+(d.name+":::"):d.name+":::";Blockscad.csg_center[q]=a;Blockscad.currentInterestingBlock?(l=Blockscad.currentInterestingBlock.getField("STL_FILENAME"),e=Blockscad.currentInterestingBlock.getField("STL_BUTTON"),w=Blockscad.currentInterestingBlock.getField("STL_CONTENTS"),l.setText(d.name),l.setVisible(!0),e.setVisible(!1),w.setText(q), -Blockscad.currentInterestingBlock.setCommentText(d.name+"\ncenter:("+a+")"),Blockscad.currentInterestingBlock=null):(q=Blockly.Xml.textToDom(''+d.name+'Browse'+q+""),q=Blockly.Xml.domToBlock(Blockscad.workspace,q.firstChild),e=q.getField("STL_BUTTON"),e.setVisible(!1),q.setCommentText(d.name+"\ncenter:("+ -a+")"),q.render())},a.readAsBinaryString(d),$("#importStl")[0].value="",$("#displayBlocks").click(),$("#renderButton").prop("disabled",!1)):alert("Failed to load file")};$("#file-menu").on("change","#loadLocal",function(d){a(d,!0)});$("#file-menu").on("change","#importLocal",function(d){a(d,!1)});$("#file-menu").on("change","#importStl",function(a){Blockscad.readStlFile(a)});gProcessor=new Blockscad.Processor(document.getElementById("renderDiv"));BSUtils.bindClick("viewReset",Blockscad.resetView); +d=prettyPrintOne(d,"js"),a.innerHTML=d);Blockly.fireUiEvent(window,"resize")});$("#renderButton").prop("disabled",!0);$("#throw-it-away").click(Blockscad.clearProject);$("#main").on("click",".new-project",Blockscad.newProject);Blockscad.readStlFile=function(a){var d=a.target.files[0];d?(a=new FileReader,a.onload=function(a){a=importSTL(a.target.result);var e=a[0];(a=a[1])||(a="blah");for(var l=d.name.substr(0,d.name.lastIndexOf("("))||d.name,l=l.substr(0,d.name.lastIndexOf("."))||l,r=l=l.replace(/^\s+|\s+$/g, +""),w=1,n=0;Blockscad.csg_commands[r]&&!n;)e!=Blockscad.csg_commands[r]?(r=l+"_"+w,w++):n=1;Blockscad.csg_commands[r]=e;Blockscad.csg_filename[r]=n?Blockscad.csg_filename[r]+(d.name+":::"):d.name+":::";Blockscad.csg_center[r]=a;Blockscad.currentInterestingBlock?(l=Blockscad.currentInterestingBlock.getField("STL_FILENAME"),e=Blockscad.currentInterestingBlock.getField("STL_BUTTON"),w=Blockscad.currentInterestingBlock.getField("STL_CONTENTS"),l.setText(d.name),l.setVisible(!0),e.setVisible(!1),w.setText(r), +Blockscad.currentInterestingBlock.setCommentText(d.name+"\ncenter:("+a+")"),Blockscad.currentInterestingBlock=null):(r=Blockly.Xml.textToDom(''+d.name+'Browse'+r+""),r=Blockly.Xml.domToBlock(Blockscad.workspace,r.firstChild),e=r.getField("STL_BUTTON"),e.setVisible(!1),r.setCommentText(d.name+"\ncenter:("+ +a+")"),r.render())},a.readAsBinaryString(d),$("#importStl")[0].value="",$("#displayBlocks").click(),$("#renderButton").prop("disabled",!1)):alert("Failed to load file")};$("#file-menu").on("change","#loadLocal",function(d){a(d,!0)});$("#file-menu").on("change","#importLocal",function(d){a(d,!1)});$("#file-menu").on("change","#importStl",function(a){Blockscad.readStlFile(a)});gProcessor=new Blockscad.Processor(document.getElementById("renderDiv"));BSUtils.bindClick("viewReset",Blockscad.resetView); Blockscad.undo={blockList:[],oldBlockList:[],undoStack:[],redoStack:[],current_xml:null,blockCount:0,yesthis:0,fieldChanging:0,blockIds:[],fieldValues:[],parentIds:[],oldBlockIds:[],oldFieldValues:[],oldParentIds:[],just_did_undo:0};Blockscad.workspace.addUndoListener(Blockscad.workspaceChanged);Blockscad.offline||Blockscad.Auth.checkForUser();$("#help-menu").on("click","#about",function(){$("#about-modal").modal("show")});$("#file-menu").on("click","#saveLocal",Blockscad.saveBlocksLocal);$("#simpleToolbox").on("click", function(){console.log("switching to simple toolbox");$("#simpleToolbox").hide();$("#advancedToolbox").show();Blockscad.workspace&&(Blockscad.Toolbox.catIDs=[],Blockscad.workspace.updateToolbox(Blockscad.Toolbox.sim),Blockscad.Toolbox.setCatColors())});$("#advancedToolbox").on("click",function(){console.log("switching to advanced toolbox");$("#advancedToolbox").hide();$("#simpleToolbox").show();Blockscad.workspace&&(Blockscad.Toolbox.catIDs=[],Blockscad.workspace.updateToolbox(Blockscad.Toolbox.adv), Blockscad.Toolbox.setCatColors())});$("#colors_one").on("click",function(){console.log("switching block color scheme");Blockscad.workspace&&(Blockscad.Toolbox.setColorScheme(Blockscad.Toolbox.colorScheme.one),Blockscad.Toolbox.setCatColors(),Blockscad.workspace.clear(),Blockly.Xml.domToWorkspace(Blockscad.workspace,Blockscad.undo.current_xml))});$("#colors_two").on("click",function(){console.log("switching block color scheme");Blockscad.workspace&&(Blockscad.Toolbox.setColorScheme(Blockscad.Toolbox.colorScheme.two), @@ -46,8 +46,8 @@ Blockscad.clearStlBlocks=function(){for(var a=Blockscad.workspace.getAllBlocks() (h=e),e=e.getSurroundParent();h&&h.setCollapsed(!0,!0);a[d].render();$("#error-message").html("Warning: re-load your STL file block")}};Blockscad.newProject=function(){0a||window.confirm("Delete all "+a+" blocks?"))Blockly.mainWorkspace.clear(),window.location.hash=""};Blockscad.resetView=function(){gProcessor&&gProcessor.viewer&&gProcessor.viewer.viewReset()}; -Blockscad.mixes2and3D=function(){for(var a=[],a=Blockly.mainWorkspace.getTopBlocks(),d=0,e=0,h=0,m=0,k=0;kd[0]?1:a[0]e.length&&(e=[]);return[e,h]};Blockscad.whichFonts=function(a){for(var d=[],e=0;ee.length&&(e=[]);return[e,h]};Blockscad.whichFonts=function(a){for(var d=[],e=0;ef;f++)c[f]=b[f]};g.multMatrix=function(b){g.loadMatrix(p.multiply(g[d],b,f))};g.perspective=function(b,f,a,d){g.multMatrix(p.perspective(b,f,a,d,c))};g.frustum=function(b,f,a,d,e,B){g.multMatrix(p.frustum(b,f,a,d,e,B,c))};g.ortho=function(b,f,a,d,e,B){g.multMatrix(p.ortho(b,f,a,d,e,B,c))};g.scale=function(b,f,a){g.multMatrix(p.scale(b,f,a,c))};g.translate=function(b,f,a){g.multMatrix(p.translate(b,f,a,c))};g.rotate= function(b,f,a,d){g.multMatrix(p.rotate(b,f,a,d,c))};g.lookAt=function(b,f,a,d,e,B,k,h,G){g.multMatrix(p.lookAt(b,f,a,d,e,B,k,h,G,c))};g.pushMatrix=function(){e.push(Array.prototype.slice.call(g[d].m))};g.popMatrix=function(){var b=e.pop();g[d].m=H?new Float32Array(b):b};g.project=function(b,c,f,a,d,e){a=a||g.modelviewMatrix;d=d||g.projectionMatrix;e=e||g.getParameter(g.VIEWPORT);b=d.transformPoint(a.transformPoint(new k(b,c,f)));return new k(e[0]+e[2]*(.5*b.x+.5),e[1]+e[3]*(.5*b.y+.5),.5*b.z+.5)}; -g.unProject=function(b,a,d,e,B,h){e=e||g.modelviewMatrix;B=B||g.projectionMatrix;h=h||g.getParameter(g.VIEWPORT);b=new k((b-h[0])/h[2]*2-1,(a-h[1])/h[3]*2-1,2*d-1);return p.inverse(p.multiply(B,e,c),f).transformPoint(b)};g.matrixMode(g.MODELVIEW)}function n(){var c=new h({coords:!0,colors:!0,triangles:!1}),f=-1,b=[0,0,0,0],a=[1,1,1,1],d=new q("uniform float pointSize;varying vec4 color;varying vec4 coord;void main() {color = gl_Color;coord = gl_TexCoord;gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;gl_PointSize = pointSize;}", +g.unProject=function(b,a,d,e,B,h){e=e||g.modelviewMatrix;B=B||g.projectionMatrix;h=h||g.getParameter(g.VIEWPORT);b=new k((b-h[0])/h[2]*2-1,(a-h[1])/h[3]*2-1,2*d-1);return p.inverse(p.multiply(B,e,c),f).transformPoint(b)};g.matrixMode(g.MODELVIEW)}function n(){var c=new h({coords:!0,colors:!0,triangles:!1}),f=-1,b=[0,0,0,0],a=[1,1,1,1],d=new r("uniform float pointSize;varying vec4 color;varying vec4 coord;void main() {color = gl_Color;coord = gl_TexCoord;gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;gl_PointSize = pointSize;}", "uniform sampler2D texture;uniform float pointSize;uniform bool useTexture;varying vec4 color;varying vec4 coord;void main() {gl_FragColor = color;if (useTexture) gl_FragColor *= texture2D(texture, coord.xy);}");g.pointSize=function(b){d.uniforms({pointSize:b})};g.begin=function(b){if(-1!=f)throw"mismatched gl.begin() and gl.end() calls";f=b;c.colors=[];c.coords=[];c.vertices=[]};g.color=function(b,c,f,d){a=1==arguments.length?b.toArray().concat(1):[b,c,f,d||1]};g.texCoord=function(c,f){b=1==arguments.length? c.toArray(2):[c,f]};g.vertex=function(f,d,e){c.colors.push(a);c.coords.push(b);c.vertices.push(1==arguments.length?f.toArray():[f,d,e])};g.end=function(){if(-1==f)throw"mismatched gl.begin() and gl.end() calls";c.compile();d.uniforms({useTexture:!!g.getParameter(g.TEXTURE_BINDING_2D)}).draw(c,f);f=-1}}function u(){function c(){for(var b in E)if(t.call(E,b)&&E[b])return!0;return!1}function f(b){var f={},a;for(a in b)f[a]="function"==typeof b[a]?function(c){return function(){c.apply(b,arguments)}}(b[a]): -b[a];f.original=b;f.x=f.pageX;f.y=f.pageY;for(a=g.canvas;a;a=a.offsetParent)f.x-=a.offsetLeft,f.y-=a.offsetTop;r?(f.deltaX=f.x-p,f.deltaY=f.y-n):(f.deltaX=0,f.deltaY=0,r=!0);p=f.x;n=f.y;f.dragging=c();f.preventDefault=function(){f.original.preventDefault()};f.stopPropagation=function(){f.original.stopPropagation()};return f}function b(b){var c={},f;for(f in b)c[f]="function"==typeof b[f]?function(c){return function(){c.apply(b,arguments)}}(b[f]):b[f];c.original=b;if(0=c?String.fromCharCode(c):null)}function v(c,f,b){c.addEventListener(f,b)}function x(){(function(c){g.makeCurrent=function(){g=c}})(g);g.animate=function(){function c(){g=a;var d=(new Date).getTime();if(g.onupdate)g.onupdate((d-b)/1E3); +h);g=l;c=b(c);if(g.ontouchend)g.ontouchend(c);c.preventDefault()}function m(){q=!1}function r(){E={};q=!1}var l=g,p=0,n=0,E={},q=!1,t=Object.prototype.hasOwnProperty;g.canvas.addEventListener("mousedown",function(b){g=l;c()||(document.addEventListener("mousemove",a),document.addEventListener("mouseup",d),g.canvas.removeEventListener("mousemove",a),g.canvas.removeEventListener("mouseup",d));E[b.which]=!0;b=f(b);if(g.onmousedown)g.onmousedown(b);b.preventDefault()});g.canvas.addEventListener("mousemove", +a);g.canvas.addEventListener("mouseup",d);g.canvas.addEventListener("mousewheel",e);g.canvas.addEventListener("DOMMouseScroll",e);g.canvas.addEventListener("mouseover",m);g.canvas.addEventListener("mouseout",m);g.canvas.addEventListener("touchstart",function(c){r();document.addEventListener("touchmove",k);document.addEventListener("touchend",h);g.canvas.removeEventListener("touchmove",k);g.canvas.removeEventListener("touchend",h);g=l;c=b(c);if(g.ontouchstart)g.ontouchstart(c);c.preventDefault()}); +g.canvas.addEventListener("touchmove",k);g.canvas.addEventListener("touchend",h);document.addEventListener("contextmenu",r)}function t(c){return{8:"BACKSPACE",9:"TAB",13:"ENTER",16:"SHIFT",27:"ESCAPE",32:"SPACE",37:"LEFT",38:"UP",39:"RIGHT",40:"DOWN"}[c]||(65<=c&&90>=c?String.fromCharCode(c):null)}function v(c,f,b){c.addEventListener(f,b)}function x(){(function(c){g.makeCurrent=function(){g=c}})(g);g.animate=function(){function c(){g=a;var d=(new Date).getTime();if(g.onupdate)g.onupdate((d-b)/1E3); if(g.ondraw)g.ondraw();f(c);b=d}var f=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(b){setTimeout(b,1E3/60)},b=(new Date).getTime(),a=g;c()};g.fullscreen=function(c){function f(){g.canvas.width=window.innerWidth-a-d;g.canvas.height=window.innerHeight-b-e;g.viewport(0,0,g.canvas.width,g.canvas.height);!c.camera&&"camera"in c||(g.matrixMode(g.PROJECTION),g.loadIdentity(),g.perspective(c.fov||45,g.canvas.width/g.canvas.height,c.near||.1,c.far|| 1E3),g.matrixMode(g.MODELVIEW));if(g.onresize)g.onresize();if(g.ondraw)g.ondraw()}c=c||{};var b=c.paddingTop||0,a=c.paddingLeft||0,d=c.paddingRight||0,e=c.paddingBottom||0;if(!document.body)throw"document.body doesn't exist yet (call gl.fullscreen() from window.onload() or from inside the tag)";document.body.appendChild(g.canvas);document.body.style.overflow="hidden";g.canvas.style.position="absolute";g.canvas.style.left=a+"px";g.canvas.style.top=b+"px";window.addEventListener("resize",f); f()}}function p(){var c=Array.prototype.concat.apply([],arguments);c.length||(c=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);this.m=H?new Float32Array(c):c}function y(c,f,b){this.t=arguments.length?c:Number.MAX_VALUE;this.hit=f;this.normal=b}function F(){var c=g.getParameter(g.VIEWPORT),f=g.modelviewMatrix.m,b=new k(f[0],f[4],f[8]),a=new k(f[1],f[5],f[9]),d=new k(f[2],f[6],f[10]),f=new k(f[3],f[7],f[11]);this.eye=new k(-f.dot(b),-f.dot(a),-f.dot(d));b=c[0];a=b+c[2];d=c[1];f=d+c[3];this.ray00=g.unProject(b, -d,1).subtract(this.eye);this.ray10=g.unProject(a,d,1).subtract(this.eye);this.ray01=g.unProject(b,f,1).subtract(this.eye);this.ray11=g.unProject(a,f,1).subtract(this.eye);this.viewport=c}var K,L,r;a.prototype={bind:function(c){g.activeTexture(g.TEXTURE0+(c||0));g.bindTexture(g.TEXTURE_2D,this.id)},unbind:function(c){g.activeTexture(g.TEXTURE0+(c||0));g.bindTexture(g.TEXTURE_2D,null)},drawTo:function(c,f){f=f||{};var b=g.getParameter(g.VIEWPORT);g.viewport(0,0,this.width,this.height);K=K||g.createFramebuffer(); +d,1).subtract(this.eye);this.ray10=g.unProject(a,d,1).subtract(this.eye);this.ray01=g.unProject(b,f,1).subtract(this.eye);this.ray11=g.unProject(a,f,1).subtract(this.eye);this.viewport=c}var K,L,q;a.prototype={bind:function(c){g.activeTexture(g.TEXTURE0+(c||0));g.bindTexture(g.TEXTURE_2D,this.id)},unbind:function(c){g.activeTexture(g.TEXTURE0+(c||0));g.bindTexture(g.TEXTURE_2D,null)},drawTo:function(c,f){f=f||{};var b=g.getParameter(g.VIEWPORT);g.viewport(0,0,this.width,this.height);K=K||g.createFramebuffer(); g.bindFramebuffer(g.FRAMEBUFFER,K);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,g.TEXTURE_2D,this.id,0);if(!1!==f.depth){L=L||g.createRenderbuffer();g.bindRenderbuffer(g.RENDERBUFFER,L);if(this.width!=L.width||this.height!=L.height)L.width=this.width,L.height=this.height,g.renderbufferStorage(g.RENDERBUFFER,g.DEPTH_COMPONENT16,this.width,this.height);g.framebufferRenderbuffer(g.FRAMEBUFFER,g.DEPTH_ATTACHMENT,g.RENDERBUFFER,L)}c();g.bindFramebuffer(g.FRAMEBUFFER,null);g.bindRenderbuffer(g.RENDERBUFFER, null);g.viewport(b[0],b[1],b[2],b[3])},swapWith:function(c){var f;f=c.id;c.id=this.id;this.id=f;f=c.width;c.width=this.width;this.width=f;f=c.height;c.height=this.height;this.height=f}};a.fromImage=function(c,f){f=f||{};var b=new a(c.width,c.height,f);try{g.texImage2D(g.TEXTURE_2D,0,b.format,b.format,b.type,c)}catch(d){if("file:"==window.location.protocol)throw'image not loaded for security reasons (serve this page over "http://" instead)';throw"image not loaded for security reasons (image must originate from the same domain as this page or use Cross-Origin Resource Sharing)"; -}f.minFilter&&f.minFilter!=g.NEAREST&&f.minFilter!=g.LINEAR&&g.generateMipmap(g.TEXTURE_2D);return b};a.fromURL=function(c,f){r=r||function(){var b=document.createElement("canvas").getContext("2d");b.canvas.width=b.canvas.height=128;for(var c=0;cd;d++)c.vertices.push(m(b[d]).toArray()),c.coords&&c.coords.push([d&1,(d&2)/2]),c.normals&&c.normals.push(b.slice(4,7));c.triangles.push([a,a+1,a+2]);c.triangles.push([a+2,a+1,a+3])}c.compile();return c};h.sphere=function(c){function f(b,c,f){return l?[b,f,c]:[b,c,f]}c=c||{};var b=new h(c),a=new d;c=c.detail|| -6;for(var e=0;8>e;e++)for(var g=m(e),l=0e;e++)for(var g=m(e),l=0arguments.length?g.TRIANGLES:a)},drawBuffers:function(c,a,b){var d=this.usedMatrices,e=g.modelviewMatrix,k=g.projectionMatrix,h=d.MVMI||d.NM?e.inverse():null,m=d.PMI?k.inverse():null,q=d.MVPM||d.MVPMI?k.multiply(e):null,l={};d.MVM&&(l[d.MVM]=e);d.MVMI&&(l[d.MVMI]=h);d.PM&&(l[d.PM]=k);d.PMI&&(l[d.PMI]=m);d.MVPM&&(l[d.MVPM]=q);d.MVPMI&&(l[d.MVPMI]=q.inverse()); +f+'" to invalid value '+a;}}return this},draw:function(c,a){this.drawBuffers(c.vertexBuffers,c.indexBuffers[a==g.LINES?"lines":"triangles"],2>arguments.length?g.TRIANGLES:a)},drawBuffers:function(c,a,b){var d=this.usedMatrices,e=g.modelviewMatrix,k=g.projectionMatrix,h=d.MVMI||d.NM?e.inverse():null,m=d.PMI?k.inverse():null,r=d.MVPM||d.MVPMI?k.multiply(e):null,l={};d.MVM&&(l[d.MVM]=e);d.MVMI&&(l[d.MVMI]=h);d.PM&&(l[d.PM]=k);d.PMI&&(l[d.PMI]=m);d.MVPM&&(l[d.MVPM]=r);d.MVPMI&&(l[d.MVPMI]=r.inverse()); d.NM&&(e=h.m,l[d.NM]=[e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]]);this.uniforms(l);var d=0,p;for(p in c)l=c[p],e=this.attributes[p]||g.getAttribLocation(this.program,p.replace(/^(gl_.*)$/,"LIGHTGL$1")),-1!=e&&l.buffer&&(this.attributes[p]=e,g.bindBuffer(g.ARRAY_BUFFER,l.buffer),g.enableVertexAttribArray(e),g.vertexAttribPointer(e,l.buffer.spacing,g.FLOAT,!1,0,0),d=l.buffer.length/l.buffer.spacing);for(p in this.attributes)p in c||g.disableVertexAttribArray(this.attributes[p]);!d||a&&!a.buffer|| -(a?(g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,a.buffer),g.drawElements(b,a.buffer.length,g.UNSIGNED_SHORT,0)):g.drawArrays(b,0,d));return this}};q.fromURL=function(c,a){var b=function(b){var c=new XMLHttpRequest;c.open("GET",b,!1);c.send(null);if(200!==c.status)throw"could not load "+b;return c.responseText},d=b(c),b=b(a);return new q(d,b)};q.from=function(c,a){try{return new q(c,a)}catch(b){return q.fromURL(c,a)}};var g,z={create:function(c){c=c||{};var a=c.canvas;a||(a=document.createElement("canvas"), -a.width=c.width||800,a.height=c.height||600);"alpha"in c||(c.alpha=!1);try{g=a.getContext("webgl",c)}catch(b){}try{g=g||a.getContext("experimental-webgl",c)}catch(b){}if(!g)throw"WebGL not supported";w();n();u();x();return g},keys:{},Matrix:p,Indexer:d,Buffer:e,Mesh:h,HitTest:y,Raytracer:F,Shader:q,Texture:a,Vector:k};v(document,"keydown",function(c){if(!c.altKey&&!c.ctrlKey&&!c.metaKey){var a=t(c.keyCode);a&&(z.keys[a]=!0);z.keys[c.keyCode]=!0}});v(document,"keyup",function(c){if(!c.altKey&&!c.ctrlKey&& +(a?(g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,a.buffer),g.drawElements(b,a.buffer.length,g.UNSIGNED_SHORT,0)):g.drawArrays(b,0,d));return this}};r.fromURL=function(c,a){var b=function(b){var c=new XMLHttpRequest;c.open("GET",b,!1);c.send(null);if(200!==c.status)throw"could not load "+b;return c.responseText},d=b(c),b=b(a);return new r(d,b)};r.from=function(c,a){try{return new r(c,a)}catch(b){return r.fromURL(c,a)}};var g,z={create:function(c){c=c||{};var a=c.canvas;a||(a=document.createElement("canvas"), +a.width=c.width||800,a.height=c.height||600);"alpha"in c||(c.alpha=!1);try{g=a.getContext("webgl",c)}catch(b){}try{g=g||a.getContext("experimental-webgl",c)}catch(b){}if(!g)throw"WebGL not supported";w();n();u();x();return g},keys:{},Matrix:p,Indexer:d,Buffer:e,Mesh:h,HitTest:y,Raytracer:F,Shader:r,Texture:a,Vector:k};v(document,"keydown",function(c){if(!c.altKey&&!c.ctrlKey&&!c.metaKey){var a=t(c.keyCode);a&&(z.keys[a]=!0);z.keys[c.keyCode]=!0}});v(document,"keyup",function(c){if(!c.altKey&&!c.ctrlKey&& !c.metaKey){var a=t(c.keyCode);a&&(z.keys[a]=!1);z.keys[c.keyCode]=!1}});var Q=305397760,H="undefined"!=typeof Float32Array;p.prototype={inverse:function(){return p.inverse(this,new p)},transpose:function(){return p.transpose(this,new p)},multiply:function(c){return p.multiply(this,c,new p)},transformPoint:function(c){var a=this.m;return(new k(a[0]*c.x+a[1]*c.y+a[2]*c.z+a[3],a[4]*c.x+a[5]*c.y+a[6]*c.z+a[7],a[8]*c.x+a[9]*c.y+a[10]*c.z+a[11])).divide(a[12]*c.x+a[13]*c.y+a[14]*c.z+a[15])},transformVector:function(c){var a= this.m;return new k(a[0]*c.x+a[1]*c.y+a[2]*c.z,a[4]*c.x+a[5]*c.y+a[6]*c.z,a[8]*c.x+a[9]*c.y+a[10]*c.z)}};p.inverse=function(c,a){a=a||new p;var b=c.m,d=a.m;d[0]=b[5]*b[10]*b[15]-b[5]*b[14]*b[11]-b[6]*b[9]*b[15]+b[6]*b[13]*b[11]+b[7]*b[9]*b[14]-b[7]*b[13]*b[10];d[1]=-b[1]*b[10]*b[15]+b[1]*b[14]*b[11]+b[2]*b[9]*b[15]-b[2]*b[13]*b[11]-b[3]*b[9]*b[14]+b[3]*b[13]*b[10];d[2]=b[1]*b[6]*b[15]-b[1]*b[14]*b[7]-b[2]*b[5]*b[15]+b[2]*b[13]*b[7]+b[3]*b[5]*b[14]-b[3]*b[13]*b[6];d[3]=-b[1]*b[6]*b[11]+b[1]*b[10]* b[7]+b[2]*b[5]*b[11]-b[2]*b[9]*b[7]-b[3]*b[5]*b[10]+b[3]*b[9]*b[6];d[4]=-b[4]*b[10]*b[15]+b[4]*b[14]*b[11]+b[6]*b[8]*b[15]-b[6]*b[12]*b[11]-b[7]*b[8]*b[14]+b[7]*b[12]*b[10];d[5]=b[0]*b[10]*b[15]-b[0]*b[14]*b[11]-b[2]*b[8]*b[15]+b[2]*b[12]*b[11]+b[3]*b[8]*b[14]-b[3]*b[12]*b[10];d[6]=-b[0]*b[6]*b[15]+b[0]*b[14]*b[7]+b[2]*b[4]*b[15]-b[2]*b[12]*b[7]-b[3]*b[4]*b[14]+b[3]*b[12]*b[6];d[7]=b[0]*b[6]*b[11]-b[0]*b[10]*b[7]-b[2]*b[4]*b[11]+b[2]*b[8]*b[7]+b[3]*b[4]*b[10]-b[3]*b[8]*b[6];d[8]=b[4]*b[9]*b[15]-b[4]* @@ -132,8 +132,8 @@ d[8]=b[2];d[9]=b[6];d[10]=b[10];d[11]=b[14];d[12]=b[3];d[13]=b[7];d[14]=b[11];d[ a[7]+c[6]*a[11]+c[7]*a[15];d[8]=c[8]*a[0]+c[9]*a[4]+c[10]*a[8]+c[11]*a[12];d[9]=c[8]*a[1]+c[9]*a[5]+c[10]*a[9]+c[11]*a[13];d[10]=c[8]*a[2]+c[9]*a[6]+c[10]*a[10]+c[11]*a[14];d[11]=c[8]*a[3]+c[9]*a[7]+c[10]*a[11]+c[11]*a[15];d[12]=c[12]*a[0]+c[13]*a[4]+c[14]*a[8]+c[15]*a[12];d[13]=c[12]*a[1]+c[13]*a[5]+c[14]*a[9]+c[15]*a[13];d[14]=c[12]*a[2]+c[13]*a[6]+c[14]*a[10]+c[15]*a[14];d[15]=c[12]*a[3]+c[13]*a[7]+c[14]*a[11]+c[15]*a[15];return b};p.identity=function(a){a=a||new p;var d=a.m;d[0]=d[5]=d[10]=d[15]= 1;d[1]=d[2]=d[3]=d[4]=d[6]=d[7]=d[8]=d[9]=d[11]=d[12]=d[13]=d[14]=0;return a};p.perspective=function(a,d,b,e,g){a=Math.tan(a*Math.PI/360)*b;d*=a;return p.frustum(-d,d,-a,a,b,e,g)};p.frustum=function(a,d,b,e,g,k,h){h=h||new p;var l=h.m;l[0]=2*g/(d-a);l[1]=0;l[2]=(d+a)/(d-a);l[3]=0;l[4]=0;l[5]=2*g/(e-b);l[6]=(e+b)/(e-b);l[7]=0;l[8]=0;l[9]=0;l[10]=-(k+g)/(k-g);l[11]=-2*k*g/(k-g);l[12]=0;l[13]=0;l[14]=-1;l[15]=0;return h};p.ortho=function(a,d,b,e,g,k,h){h=h||new p;var l=h.m;l[0]=2/(d-a);l[1]=0;l[2]=0; l[3]=-(d+a)/(d-a);l[4]=0;l[5]=2/(e-b);l[6]=0;l[7]=-(e+b)/(e-b);l[8]=0;l[9]=0;l[10]=-2/(k-g);l[11]=-(k+g)/(k-g);l[12]=0;l[13]=0;l[14]=0;l[15]=1;return h};p.scale=function(a,d,b,e){e=e||new p;var g=e.m;g[0]=a;g[1]=0;g[2]=0;g[3]=0;g[4]=0;g[5]=d;g[6]=0;g[7]=0;g[8]=0;g[9]=0;g[10]=b;g[11]=0;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return e};p.translate=function(a,d,b,e){e=e||new p;var g=e.m;g[0]=1;g[1]=0;g[2]=0;g[3]=a;g[4]=0;g[5]=1;g[6]=0;g[7]=d;g[8]=0;g[9]=0;g[10]=1;g[11]=b;g[12]=0;g[13]=0;g[14]=0;g[15]=1;return e}; -p.rotate=function(a,d,b,e,g){if(!a||!d&&!b&&!e)return p.identity(g);g=g||new p;var k=g.m,h=Math.sqrt(d*d+b*b+e*e);a*=Math.PI/180;d/=h;b/=h;e/=h;h=Math.cos(a);a=Math.sin(a);var l=1-h;k[0]=d*d*l+h;k[1]=d*b*l-e*a;k[2]=d*e*l+b*a;k[3]=0;k[4]=b*d*l+e*a;k[5]=b*b*l+h;k[6]=b*e*l-d*a;k[7]=0;k[8]=e*d*l-b*a;k[9]=e*b*l+d*a;k[10]=e*e*l+h;k[11]=0;k[12]=0;k[13]=0;k[14]=0;k[15]=1;return g};p.lookAt=function(a,d,b,e,g,h,l,m,q,n){n=n||new p;var r=n.m;a=new k(a,d,b);e=new k(e,g,h);m=new k(l,m,q);l=a.subtract(e).unit(); -m=m.cross(l).unit();q=l.cross(m).unit();r[0]=m.x;r[1]=m.y;r[2]=m.z;r[3]=-m.dot(a);r[4]=q.x;r[5]=q.y;r[6]=q.z;r[7]=-q.dot(a);r[8]=l.x;r[9]=l.y;r[10]=l.z;r[11]=-l.dot(a);r[12]=0;r[13]=0;r[14]=0;r[15]=1;return n};y.prototype={mergeWith:function(a){0e.x)-(a.xe.y)-(a.ye.z)-(a.z=m+k)return new y(e,a,g)}return null};return z}();Blockscad=Blockscad||{};Blockscad.Toolbox={};Blockly=Blockly||{};Blockscad.Toolbox.catIDs=[];Blockscad.Toolbox.allcats="HEX_3D_PRIMITIVE HEX_2D_PRIMITIVE HEX_TRANSFORM HEX_SETOP HEX_MATH HEX_LOGIC HEX_LOOP HEX_TEXT HEX_VARIABLE HEX_PROCEDURE".split(" ");Blockscad.Toolbox.whichCatsInSimple=[0,2,3,4,8,9];Blockscad.Toolbox.colorScheme={};Blockscad.Toolbox.colorScheme.one="#006205 #209303 #26549E #7450E2 #0186E2 #BF6920 #612485 #727272 #8C7149 #900355".split(" ");Blockscad.Toolbox.colorScheme.two="#885ee3 #82af5a #23901c #377eb8 #ba9969 #afaf13 #a66658 #d761bf #999999 #b02375".split(" "); Blockscad.Toolbox.catHex=[];Blockscad.Toolbox.simpCatHex=[];Blockscad.Toolbox.setColorScheme=function(a){for(var d=0;d1100';Blockscad.Toolbox.catLoops='1 101'; Blockscad.Toolbox.catOther='10';Blockscad.Toolbox.catOther_sim=''; Blockscad.Toolbox.adv='