@_@_vid_@_@ = function() {
// @_@_name_@_@ part
var childs = '@_@_childs_@_@';
var translate = [@_@_translate_@_@];
return makeUnion(childs).translate(translate);
}
@_@_vid_@_@ = function() {
var translate=[@_@_translate_@_@];
var childs = '@_@_childs_@_@';
return extrudeUnion({offset: [0, 0, 0.01],},childs).translate(translate);
}
@_@_vid_@_@ = function(extru=0,extrudeoptions,rotateextude=false) {
// @_@_name_@_@ polyline
//console.log('polyline start');
var anker= '@_@_anker_@_@';
var translate='@_@_translate_@_@';
var rotate=@_@_rotate_@_@;
var quality=@_@_quality_@_@;
var linelist='@_@_translate_@_@;@_@_linelist_@_@';
var newlist = [[@_@_translate_@_@]];
var linear = linelist.split(';');
var x = parseFloat(linear[0].split(',')[0]);
var y = parseFloat(linear[0].split(',')[1]);
for (var i = 1; i !== linear.length; i++) {
x = x + parseFloat(linear[i].split(',')[0]);
y = y + parseFloat(linear[i].split(',')[1]);
newlist.push([x,y]);
}
//console.log('polyline end');
//console.log(JSON.stringify( newlist));
/*
if(extru==0){
return CAG.fromPoints(newlist);
}
*/
if(extru!==0){
if(!rotateextude){
return CAG.fromPoints(newlist).extrude(extrudeoptions).rotateZ(rotate);
}
if(rotateextude){
return CAG.fromPoints(newlist).rotateExtrude(extrudeoptions).rotateZ(rotate);
}
}
if(typeof extrudeoptions['angle'] !== 'undefined'){
console.log(extrudeoptions);
return CAG.fromPoints(newlist).rotateZ(rotate).translate(translate).rotateExtrude(extrudeoptions);
}
}
@_@_vid_@_@ = function(extru=0,extrudeoptions,rotateextude=false) {
// @_@_name_@_@ circle
var anker= '@_@_anker_@_@';
var translate=[@_@_translate_@_@];
var diameter=@_@_diameter_@_@;
var quality=@_@_quality_@_@;
if(extru==0){
return CAG.circle({center: translate, radius: diameter/2, resolution: quality});
}
if(extru!==0){
if(!rotateextude){
return CAG.circle({center: translate, radius: diameter/2, resolution: quality}).extrude(extrudeoptions);
}
if(rotateextude){
return CAG.circle({center: translate, radius: diameter/2, resolution: quality}).rotateExtrude(extrudeoptions);
}
}
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ extrusion
var quality=@_@_quality_@_@;
var intersects = '@_@_intersects_@_@';
var unions='@_@_unions_@_@';
var diffus='@_@_diffus_@_@';
var value = @_@_value_@_@;
var minusval = @_@_minusval_@_@;
var angle = @_@_angle_@_@;
var twiststeps = @_@_twiststeps_@_@;
var rotate = [@_@_rotate_@_@];
var translate = [@_@_translate_@_@];
var offset = [@_@_offset_@_@,value];
if(angle === 0){
var extrudeoptions = {offset: offset,extrude: value};
var Eintersects =extrudeUnion(extrudeoptions,intersects);
var Eunions=extrudeUnion(extrudeoptions,unions);
var Ediffus=extrudeUnion(extrudeoptions,diffus);
}else{
if(twiststeps === 0){
var extrudeoptions = {angle: angle, resolution: quality,extrude: value};
var Eintersects =extrudeRotateUnion(extrudeoptions,intersects);
var Eunions=extrudeRotateUnion(extrudeoptions,unions);
var Ediffus=extrudeRotateUnion(extrudeoptions,diffus);
}else{
var extrudeoptions = {offset: offset,twistangle: angle,twiststeps: twiststeps,extrude: value};
var Eintersects =extrudeUnion(extrudeoptions,intersects);
var Eunions=extrudeUnion(extrudeoptions,unions);
var Ediffus=extrudeUnion(extrudeoptions,diffus);
}
}
if (minusval) {
var Evalue = 0 - value;
}
if (!minusval) {
var Evalue = 0;
}
var moveing = [0,0,Evalue];
if (!Eintersects) {
if (!Ediffus) {return Eunions;}
return Eunions.subtract(Ediffus).translate(moveing).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
if (!Ediffus) {
return Eintersects.intersect(Eunions).translate(moveing).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
if (Eintersects) {if (Eunions) {if (Ediffus) {
return Eintersects.intersect(Eunions).subtract(Ediffus).translate(moveing).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}}
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ merge
var quality=@_@_quality_@_@;
var intersects = '@_@_intersects_@_@';
var unions='@_@_unions_@_@';
var diffus='@_@_diffus_@_@';
var value = @_@_value_@_@;
var minusval = @_@_minusval_@_@;
var angle = @_@_angle_@_@;
var twiststeps = @_@_twiststeps_@_@;
var rotate = [@_@_rotate_@_@];
var translate = [@_@_translate_@_@];
var offset = [@_@_offset_@_@,value];
var Eintersects =makeUnion(intersects);
var Eunions=makeUnion(unions);
var Ediffus=makeUnion(diffus);
if (Eunions) {
if (!Eintersects) {if (Ediffus) {
var newobject = Eunions.subtract(Ediffus).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}
if (!Ediffus) { if (Eintersects) {
var newobject = Eintersects.intersect(Eunions).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}
if (Eintersects) {if (Ediffus) {
var newobject = Eintersects.intersect(Eunions).subtract(Ediffus).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}
if (!Eintersects) {if (!Ediffus) {
var newobject = Eunions.rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);;
}}
}
if(value === 0){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 1; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((360/value)*i)]);
}
}}}}}
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] === 0){
var endobject = newobject.scale([offset[0], 1, 1]);
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] !== 0){
var endobject = newobject.scale([1,offset[1], 1]);
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject.scale([offset[0],offset[1], 1]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject.scale([1,1, twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] !== 0){if(offset[1] === 0){
var endobject = newobject.scale([offset[0],1, twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] === 0){if(offset[1] !== 0){
var endobject = newobject.scale([1,offset[1], twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject.scale([offset[0],offset[1], twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 1){if(offset[1] === 0){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX();
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredY();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 0){if(offset[1] === 0){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 1){if(offset[1] === 0){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX().mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 0){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredY().mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 1){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX().mirroredY().mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 1){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX().mirroredY();
}}}}}
if(value !== 0){if(angle !== 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 1; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i)]);
}
}}}}}
if(value !== 0){if(angle !== 0){if(twiststeps !== 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 1; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i)]);
}
for(var i = 1; i !== value; i++)
{
for(var v = 1; v !== twiststeps; v++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i).rotateX((angle/twiststeps)*v)]);
}
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i).rotateX(angle)]);
}
}}}}}
if(value !== 0){if(true){if(twiststeps !== 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
for(var v = 0; v !== twiststeps; v++)
{
var endobject = endobject.union([endobject,newobject.translate([(offset[0]/(value-1))*i,((offset[1]/(twiststeps-1))*v),0])]);
}
}
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.translate([(offset[0]/(value-1))*i,0,0])]);
}
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] !== 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.translate([0,(offset[1]/(value-1))*i,0])]);
}
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.translate([(offset[0]/(value-1))*i,(offset[1]/(value-1))*i,0])]);
}
}}}}}
if(value === 0){if(angle !== 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = CSG.sphere({center: [0, 0, 0],radius: angle, resolution: quality}).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}}}}
return endobject;
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ object
var originid = '@_@_originid_@_@';
var translate = [@_@_translate_@_@];
var color = [@_@_color_@_@];
var rotate = [@_@_rotate_@_@];
var quality=@_@_quality_@_@;
if (originid.substr(0, 3)==='vid') {
if (color[3]) {
if (color[3]!==0) {
return makeUnion(originid).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate).setColor(color);
}
}
return makeUnion(originid).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
}
module @_@_vid_@_@() {
// Define template variables as local variables
originid = "@_@_originid_@_@";
translate_vec = [@_@_translate_@_@];
color_vec = [@_@_color_@_@];
rotate_vec = [@_@_rotate_@_@];
quality = @_@_quality_@_@; // quality parameter (not used in the translation)
// Check if originid starts with 'vid'
if (str(originid, 0, 3) == "vid") {
// Check if color is defined and alpha is not zero
if (len(color_vec) == 4 && color_vec[3] != 0) {
// Apply color and transformations to a placeholder for makeUnion(originid)
color(color_vec)
rotate(a = rotate_vec)
translate(v = translate_vec)
makeUnion_placeholder();
} else {
// Apply transformations without color
rotate(a = rotate_vec)
translate(v = translate_vec)
makeUnion_placeholder();
}
}
}
// Define the module that mimics the behavior of the JSCAD function
module @_@_vid_@_@() {
// Define local variables using template variables
vod = "@_@_originid_@_@";
translate_vec = [@_@_translate_@_@]; // The translation vector
rotate_vec = [@_@_rotate_@_@]; // The rotation vector
// OpenSCAD does not support dynamic module names directly,
// so replace the dynamic reference by using a conditional approach or pre-defined modules.
if (vod == "vid1") {
ncsgu = vod1();
} else if (vod == "vid2") {
ncsgu = vod2();
}
// Continue to add more conditions if there are more modules...
// Apply transformations to the object
rotate(a = rotate_vec)
translate(v = translate_vec)
children(); // Use children() to apply transformations to the included part
}
// Example usage of the @_@_vid_@_@ module
//@_@_vid_@_@();
// In OpenSCAD, we use modules instead of functions.
// Define a main module to use a dynamically named object or part.
module main() {
// Call the module named by the template variable
@_@_activpart_@_@();
}
// OpenSCAD does not support dynamic function calls like JSCAD.
// We'll use a module with recursion to achieve similar functionality.
// Define a module to perform extrusion and union on multiple objects based on a list of strings
module extrudeUnion(extrudeoptions, liststring) {
if (liststring == "") {
// Do nothing if the list is empty
} else {
// Split the liststring by commas to get an array of object names
inters = str_split(liststring, ",");
// Get the extrusion parameters from extrudeoptions
$height = extrudeoptions["height"];
$center = extrudeoptions["center"];
$convexity = extrudeoptions["convexity"];
$fn = extrudeoptions["fn"];
$fa = extrudeoptions["fa"];
$fs = extrudeoptions["fs"];
// If there is only one object in the list
if (len(inters) == 1) {
// Apply linear extrusion to the single object
linear_extrude(height = $height, center = $center, convexity = $convexity, $fn = $fn, $fa = $fa, $fs = $fs) {
intersection_for(inters[0]) {
children();
}
}
} else {
// Apply linear extrusion to the first object in the list
linear_extrude(height = $height, center = $center, convexity = $convexity, $fn = $fn, $fa = $fa, $fs = $fs) {
intersection_for(inters[0]) {
children();
}
}
// Recursively call extrudeUnion with the remaining elements
extrudeUnion(extrudeoptions, str_join(",", inters[1:]));
}
}
}
// Example usage of extrudeUnion with template variables
// extrudeUnion(
// extrudeoptions = @_@_extrudeoptions_@_@, // Template variable for extrusion options
// liststring = "@_@_liststring_@_@" // Template variable for list of objects
// );
// OpenSCAD does not have direct functions like JSCAD.
// Instead, we define a module that uses recursion to perform similar operations.
// Define a module that performs rotational extrusion on multiple objects based on a list of strings
module extrudeRotateUnion(extrudeoptions, liststring) {
if (liststring == "") {
// Do nothing if the list is empty
} else {
// Split the liststring by commas to get an array of object names
inters = str_split(liststring, ",");
// Get the rotational extrusion parameters from extrudeoptions
$angle = extrudeoptions["angle"];
$height = extrudeoptions["height"];
$fn = extrudeoptions["fn"];
$fa = extrudeoptions["fa"];
$fs = extrudeoptions["fs"];
// If there is only one object in the list
if (len(inters) == 1) {
rotate_extrude(angle = $angle, $fn = $fn, $fa = $fa, $fs = $fs) {
intersection_for(inters[0]) {
children();
}
}
} else {
// Apply rotational extrusion to the first object in the list
rotate_extrude(angle = $angle, $fn = $fn, $fa = $fa, $fs = $fs) {
intersection_for(inters[0]) {
children();
}
}
// Recursively call extrudeRotateUnion with the remaining elements
extrudeRotateUnion(extrudeoptions, str_join(",", inters[1:]));
}
}
}
// Example usage of extrudeRotateUnion with template variables
// extrudeRotateUnion(
// extrudeoptions = [_@_@extrudeoptions_@_@], // Template variable for extrusion options
// liststring = "@_@_liststring_@_@" // Template variable for list of objects
// );
// OpenSCAD does not have direct function definitions like JSCAD,
// but we can use a module with recursive calls to achieve similar results.
// Function to create a union of multiple objects based on a list of strings
module makeUnion(liststring) {
if (liststring == "") {
// Do nothing if the list is empty
} else {
// Split the liststring by commas
inters = str_split(liststring, ",");
// Check the length of the resulting array
if (len(inters) == 1) {
// Call the named module or object function
intersection_for(inters[0]) {
children();
}
} else {
// Recursive call to makeUnion for union of multiple objects
intersection_for(inters[0]) {
children();
}
// Recursively call makeUnion with the remaining elements
makeUnion(str_join(",", inters[1:]));
}
}
}
// Example usage of makeUnion with template variables
//makeUnion("@_@_liststring_@_@");
function split_string(str) = [for (s = search(",", str, 0)) if (s == []) [0, len(str)] else s];
@_@_vid_@_@ = function() {
// @_@_name_@_@ part
var childs = '@_@_childs_@_@';
var translate = [@_@_translate_@_@];
return makeUnion(childs).translate(translate);
}
@_@_vid_@_@ = function() {
var translate=[@_@_translate_@_@];
var childs = '@_@_childs_@_@';
return extrudeUnion({offset: [0, 0, 0.01],},childs).translate(translate);
}
@_@_vid_@_@ = function(extru=0,extrudeoptions,rotateextude=false) {
// @_@_name_@_@ polyline
//console.log('polyline start');
var anker= '@_@_anker_@_@';
var translate='@_@_translate_@_@';
var rotate=@_@_rotate_@_@;
var quality=@_@_quality_@_@;
var linelist='@_@_translate_@_@;@_@_linelist_@_@';
var newlist = [[@_@_translate_@_@]];
var linear = linelist.split(';');
var x = parseFloat(linear[0].split(',')[0]);
var y = parseFloat(linear[0].split(',')[1]);
for (var i = 1; i !== linear.length; i++) {
x = x + parseFloat(linear[i].split(',')[0]);
y = y + parseFloat(linear[i].split(',')[1]);
newlist.push([x,y]);
}
//console.log('polyline end');
//console.log(JSON.stringify( newlist));
/*
if(extru==0){
return CAG.fromPoints(newlist);
}
*/
if(extru!==0){
if(!rotateextude){
return CAG.fromPoints(newlist).extrude(extrudeoptions).rotateZ(rotate);
}
if(rotateextude){
return CAG.fromPoints(newlist).rotateExtrude(extrudeoptions).rotateZ(rotate);
}
}
if(typeof extrudeoptions['angle'] !== 'undefined'){
console.log(extrudeoptions);
return CAG.fromPoints(newlist).rotateZ(rotate).translate(translate).rotateExtrude(extrudeoptions);
}
}
@_@_vid_@_@ = function(extru=0,extrudeoptions,rotateextude=false) {
// @_@_name_@_@ circle
var anker= '@_@_anker_@_@';
var translate=[@_@_translate_@_@];
var diameter=@_@_diameter_@_@;
var quality=@_@_quality_@_@;
if(extru==0){
return CAG.circle({center: translate, radius: diameter/2, resolution: quality});
}
if(extru!==0){
if(!rotateextude){
return CAG.circle({center: translate, radius: diameter/2, resolution: quality}).extrude(extrudeoptions);
}
if(rotateextude){
return CAG.circle({center: translate, radius: diameter/2, resolution: quality}).rotateExtrude(extrudeoptions);
}
}
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ extrusion
var quality=@_@_quality_@_@;
var intersects = '@_@_intersects_@_@';
var unions='@_@_unions_@_@';
var diffus='@_@_diffus_@_@';
var value = @_@_value_@_@;
var minusval = @_@_minusval_@_@;
var angle = @_@_angle_@_@;
var twiststeps = @_@_twiststeps_@_@;
var rotate = [@_@_rotate_@_@];
var translate = [@_@_translate_@_@];
var offset = [@_@_offset_@_@,value];
if(angle === 0){
var extrudeoptions = {offset: offset,extrude: value};
var Eintersects =extrudeUnion(extrudeoptions,intersects);
var Eunions=extrudeUnion(extrudeoptions,unions);
var Ediffus=extrudeUnion(extrudeoptions,diffus);
}else{
if(twiststeps === 0){
var extrudeoptions = {angle: angle, resolution: quality,extrude: value};
var Eintersects =extrudeRotateUnion(extrudeoptions,intersects);
var Eunions=extrudeRotateUnion(extrudeoptions,unions);
var Ediffus=extrudeRotateUnion(extrudeoptions,diffus);
}else{
var extrudeoptions = {offset: offset,twistangle: angle,twiststeps: twiststeps,extrude: value};
var Eintersects =extrudeUnion(extrudeoptions,intersects);
var Eunions=extrudeUnion(extrudeoptions,unions);
var Ediffus=extrudeUnion(extrudeoptions,diffus);
}
}
if (minusval) {
var Evalue = 0 - value;
}
if (!minusval) {
var Evalue = 0;
}
var moveing = [0,0,Evalue];
if (!Eintersects) {
if (!Ediffus) {return Eunions;}
return Eunions.subtract(Ediffus).translate(moveing).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
if (!Ediffus) {
return Eintersects.intersect(Eunions).translate(moveing).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
if (Eintersects) {if (Eunions) {if (Ediffus) {
return Eintersects.intersect(Eunions).subtract(Ediffus).translate(moveing).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}}
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ merge
var quality=@_@_quality_@_@;
var intersects = '@_@_intersects_@_@';
var unions='@_@_unions_@_@';
var diffus='@_@_diffus_@_@';
var value = @_@_value_@_@;
var minusval = @_@_minusval_@_@;
var angle = @_@_angle_@_@;
var twiststeps = @_@_twiststeps_@_@;
var rotate = [@_@_rotate_@_@];
var translate = [@_@_translate_@_@];
var offset = [@_@_offset_@_@,value];
var Eintersects =makeUnion(intersects);
var Eunions=makeUnion(unions);
var Ediffus=makeUnion(diffus);
if (Eunions) {
if (!Eintersects) {if (Ediffus) {
var newobject = Eunions.subtract(Ediffus).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}
if (!Ediffus) { if (Eintersects) {
var newobject = Eintersects.intersect(Eunions).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}
if (Eintersects) {if (Ediffus) {
var newobject = Eintersects.intersect(Eunions).subtract(Ediffus).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}
if (!Eintersects) {if (!Ediffus) {
var newobject = Eunions.rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);;
}}
}
if(value === 0){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 1; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((360/value)*i)]);
}
}}}}}
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] === 0){
var endobject = newobject.scale([offset[0], 1, 1]);
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] !== 0){
var endobject = newobject.scale([1,offset[1], 1]);
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject.scale([offset[0],offset[1], 1]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject.scale([1,1, twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] !== 0){if(offset[1] === 0){
var endobject = newobject.scale([offset[0],1, twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] === 0){if(offset[1] !== 0){
var endobject = newobject.scale([1,offset[1], twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps !== 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject.scale([offset[0],offset[1], twiststeps]);
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 1){if(offset[1] === 0){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX();
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredY();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 0){if(offset[1] === 0){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 1){if(offset[1] === 0){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX().mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 0){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredY().mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 1){if(offset[0] === 1){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX().mirroredY().mirroredZ();
}}}}}
if(true){if(angle === 0){if(twiststeps === 0){if(offset[0] === 1){if(offset[1] === 1){
//console.log('value_true: '+value+' - '+angle+' - '+twiststeps+' - '+offset[0]+' - '+ offset[1]);
var endobject = newobject.mirroredX().mirroredY();
}}}}}
if(value !== 0){if(angle !== 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 1; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i)]);
}
}}}}}
if(value !== 0){if(angle !== 0){if(twiststeps !== 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 1; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i)]);
}
for(var i = 1; i !== value; i++)
{
for(var v = 1; v !== twiststeps; v++)
{
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i).rotateX((angle/twiststeps)*v)]);
}
var endobject = endobject.union([endobject,newobject.rotateZ((angle/value)*i).rotateX(angle)]);
}
}}}}}
if(value !== 0){if(true){if(twiststeps !== 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
for(var v = 0; v !== twiststeps; v++)
{
var endobject = endobject.union([endobject,newobject.translate([(offset[0]/(value-1))*i,((offset[1]/(twiststeps-1))*v),0])]);
}
}
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] === 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.translate([(offset[0]/(value-1))*i,0,0])]);
}
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] !== 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.translate([0,(offset[1]/(value-1))*i,0])]);
}
}}}}}
if(value !== 0){if(angle === 0){if(twiststeps === 0){if(offset[0] !== 0){if(offset[1] !== 0){
var endobject = newobject;
for(var i = 0; i !== value; i++)
{
var endobject = endobject.union([endobject,newobject.translate([(offset[0]/(value-1))*i,(offset[1]/(value-1))*i,0])]);
}
}}}}}
if(value === 0){if(angle !== 0){if(twiststeps === 0){if(offset[0] === 0){if(offset[1] === 0){
var endobject = CSG.sphere({center: [0, 0, 0],radius: angle, resolution: quality}).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}}}}}
return endobject;
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ object
var originid = '@_@_originid_@_@';
var translate = [@_@_translate_@_@];
var color = [@_@_color_@_@];
var rotate = [@_@_rotate_@_@];
var quality=@_@_quality_@_@;
if (originid.substr(0, 3)==='vid') {
if (color[3]) {
if (color[3]!==0) {
return makeUnion(originid).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate).setColor(color);
}
}
return makeUnion(originid).rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
}
@_@_vid_@_@ = function() {
// @_@_name_@_@ inclpart
var vod = '@_@_originid_@_@';
var translate = [@_@_translate_@_@];
var rotate = [@_@_rotate_@_@];
vod = vod.replace("vid", "vod");
var ncsgu = this['@_@_vid_@_@'+vod]();
return ncsgu.rotateX(rotate[0]).rotateY(rotate[1]).rotateZ(rotate[2]).translate(translate);
}
main = function() {
var csgu = this['@_@_activpart_@_@']();
return csgu;
}
function extrudeUnion(extrudeoptions,liststring) {
//console.log("liststring: "+liststring);
if(liststring===''){
return false;
}else{
var inters = liststring.split(',');
//console.log("length: "+inters.length);
//console.log("liststring: "+liststring);
//console.log(extrudeoptions);
//console.log(extrudeoptions['extrude']);
if (inters.length === 1) {
return this[liststring](extrudeoptions['extrude'],extrudeoptions,false);
} else {
var intersect = this[inters[0]](extrudeoptions['extrude'],extrudeoptions,false);
inters.shift();
return intersect.union(extrudeUnion(extrudeoptions,inters.join(',')));
}
}
}
function extrudeRotateUnion(extrudeoptions,liststring) {
//console.log("liststring: "+liststring);
if(liststring===''){
return false;
}else{
var inters = liststring.split(',');
//console.log("length: "+inters.length);
//console.log("liststring: "+liststring);
//console.log(extrudeoptions);
//console.log(extrudeoptions['extrude']);
if (inters.length === 1) {
return this[liststring](extrudeoptions['extrude'],extrudeoptions,true);
} else {
var intersect = this[inters[0]](extrudeoptions['extrude'],extrudeoptions,true);
inters.shift();
return intersect.union(extrudeRotateUnion(extrudeoptions,inters.join(',')));
}
}
}
function makeUnion(liststring) {
//console.log("if this do not stop, something is wrong in datalist: "+liststring);
if(liststring===''){
return false;
}else{
var inters = liststring.split(',');
//console.log("length: "+inters.length);
if (inters.length === 1) {
return this[liststring]();
} else {
var intersect = this[inters[0]]();
inters.shift();
return intersect.union(makeUnion(inters.join(',')));
}
}
}