From 5a6b976506b5a4aa627d759c471be5d40f32ef9f Mon Sep 17 00:00:00 2001 From: Denis Knauf Date: Mon, 19 Mar 2012 23:24:29 +0100 Subject: [PATCH] csg: size instead radius possible. openjscad,simple.html: use --- csg.js | 8 +++++--- openjscad.js | 12 +++++++++--- simple.html | 31 ++++++++++++++++++++++--------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/csg.js b/csg.js index ef203c6..f7cf1b8 100644 --- a/csg.js +++ b/csg.js @@ -1017,7 +1017,8 @@ CSG.parseOptionAsBool = function(options, optionname, defaultvalue) { // }); CSG.cube = function(options) { var c = CSG.parseOptionAs3DVector(options, "center", [0,0,0]); - var r = CSG.parseOptionAs3DVector(options, "radius", [1,1,1]); + var s = CSG.parseOptionAs3DVector(options, "size", [2,2,2]); + var r = CSG.parseOptionAs3DVector(options, "radius", [s.x/2,s.y/2,s.z/2]); var result = CSG.fromPolygons([ [[0, 4, 6, 2], [-1, 0, 0]], [[1, 3, 7, 5], [+1, 0, 0]], @@ -1307,7 +1308,8 @@ CSG.roundedCylinder = function(options) { // }); CSG.roundedCube = function(options) { var center = CSG.parseOptionAs3DVector(options, "center", [0,0,0]); - var cuberadius = CSG.parseOptionAs3DVector(options, "radius", [1,1,1]); + var cubesize = CSG.parseOptionAs3DVector(options, "size", [2,2,2]); + var cuberadius = CSG.parseOptionAs3DVector(options, "radius", [cubesize.x/2,cubesize.y/2,cubesize.z/2]); var resolution = CSG.parseOptionAsFloat(options, "resolution", 8); if(resolution < 4) resolution = 4; var roundradius = CSG.parseOptionAsFloat(options, "roundradius", 0.2); @@ -4459,4 +4461,4 @@ CSG.Path2D.prototype = { return new CSG.Path2D(newpoints, this.closed); }, }; - \ No newline at end of file + diff --git a/openjscad.js b/openjscad.js index 6a6d73d..925b165 100644 --- a/openjscad.js +++ b/openjscad.js @@ -320,10 +320,16 @@ OpenJsCad.javaScriptToSolidSync = function(script, mainParameters, debugging) { // callback: should be function(error, csg) OpenJsCad.javaScriptToSolidASync = function(script, mainParameters, callback) { var baselibraries = [ - "../csg.js", - "../openjscad.js" + "csg.js", + "openjscad.js" ]; - var baseurl = document.location + ""; + var baseurl = document.location + ''; + var base = document.getElementsByTagName('base'); + if( base) { + base = base.getAttribute('href'); + if( base) + baseurl = OpenJsCad.makeAbsoluteUrl(baseurl, base); + } var workerscript = ""; workerscript += script; workerscript += "\n\n\n\n//// The following code is added by OpenJsCad:\n"; diff --git a/simple.html b/simple.html index 4b51b90..c09b2b1 100644 --- a/simple.html +++ b/simple.html @@ -1,12 +1,13 @@ - - - - - - + + + + + + + - +