csg: size instead radius possible. openjscad,simple.html: use <base>
This commit is contained in:
parent
a91c07c68d
commit
5a6b976506
6
csg.js
6
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);
|
||||
|
|
12
openjscad.js
12
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";
|
||||
|
|
31
simple.html
31
simple.html
|
@ -1,12 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../lightgl.js"></script>
|
||||
<script src="../csg.js"></script>
|
||||
<script src="../openjscad.js"></script>
|
||||
<script src="../jquery.js"></script>
|
||||
<script src="../coffee-script.js"></script>
|
||||
<script src="../Math.uuid.js"></script>
|
||||
<base href="../" />
|
||||
<script src="lightgl.js"></script>
|
||||
<script src="csg.js"></script>
|
||||
<script src="openjscad.js"></script>
|
||||
<script src="jquery.js"></script>
|
||||
<script src="coffee-script.js"></script>
|
||||
<script src="Math.uuid.js"></script>
|
||||
<style>
|
||||
body {
|
||||
font: 14px/20px 'Helvetica Neue Light', HelveticaNeue-Light, 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||
|
@ -20,6 +21,10 @@
|
|||
margin: 0;
|
||||
color: #555;
|
||||
}
|
||||
body > * {
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
pre {
|
||||
padding: 10px;
|
||||
width: 100%;
|
||||
|
@ -48,8 +53,14 @@
|
|||
margin: 2em 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
#viewer > .statusdiv + div {
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
width: 800px;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="../openjscad.css" type="text/css">
|
||||
<link rel="stylesheet" href="openjscad.css" type="text/css">
|
||||
<script type="text/coffeescript">
|
||||
window.DelayedCall = (fun, delay = 250) ->
|
||||
self = (args...) ->
|
||||
|
@ -111,8 +122,10 @@
|
|||
currentFilename: -> /\/([^\/]*?)$/.exec(window.location.pathname)[1]
|
||||
|
||||
loadFile: (fn) ->
|
||||
rev = localStorage[fn]
|
||||
JSON.parse localStorage[rev]
|
||||
if rev = localStorage[fn]
|
||||
JSON.parse localStorage[rev]
|
||||
else
|
||||
[fn, null, 'CoffeeScript', "main = ->\n\tCSG.cube radius: 1"]
|
||||
|
||||
writeFile: (fn, lang, code) ->
|
||||
rev = Math.uuid()
|
||||
|
|
Loading…
Reference in a new issue