Related Noob Question: I'm trying to add color to my script, and I'm getting this error:
Uncaught TypeError: object.setColor is not a function
Line: 6919,col: 17
My current code is:
function main(params) {
sketches = [
square([10,2]),
square([3,10]),
new polygon([
[0,0],
[9,0],
[3,9],
],true),
];
return render(sketches,params.dimension);
}
function getParameterDefinitions() {
return [
{ name: 'dimension', type: 'checkbox', checked: false, caption: 'render in 3d?' },
];
}
function render(obj,dim,colors) {
if (dim){
extrudes =[];
for (var i of obj){
extrudes.push(rotate_extrude(i));
}
extrudes[0]=color(extrudes[0],"Red")
extrudes[1]=color(extrudes[1],"Red")
extrudes[2]=color(extrudes[2],"White")
return union(extrudes);
}
else {
return union(sketches);
}
}
The only difference between the fixed version of the code and this one is the added colors after I extrude. Based on the documentation, I don't see why this doesn't work.