概要
plunkerでopenjscadやってみる。
練習問題やってみた。
練習問題
getParameterDefinitionsを、使え。
写真
サンプルコード
function getParameterDefinitions() {
return [{
name: 'width',
type: 'float',
initial: 10,
caption: "Width of the cube:",
}, {
name: 'height',
type: 'float',
initial: 14,
caption: "Height of the cube:",
}, {
name: 'depth',
type: 'float',
initial: 7,
caption: "Depth of the cube:",
}, {
name: 'rounded',
type: 'choice',
caption: 'Round the corners?',
values: [0, 1],
captions: ["No thanks", "Yes please"],
initial: 0,
}];
}
function main(params) {
var result;
if(params.rounded == 1)
{
result = CSG.roundedCube({radius: [params.width, params.depth, params.height], roundradius: 2, resolution: 32});
}
else
{
result = CSG.cube({radius: [params.width, params.depth, params.height]});
}
return result;
}
成果物
以上。