Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getParameterDefinitions( )
- {
- return [
- { name: 'rows', type: 'int', initial: 2, caption: "Number of rows:" },
- { name: 'pins', type: 'int', initial: 13, caption: "Number of pins:" },
- { name: 'shape', type: 'choice', caption: "Shape of hole:", values: [ 0, 1 ], captions: [ "Cube", "Cylinder" ], initial: 0 },
- { name: 'length', type: 'float', initial: 8, caption: "Depth of the cube:" },
- { name: 'left', type: 'float', initial: 0.0, caption: "Padding on left:" },
- { name: 'right', type: 'float', initial: 0.0, caption: "Padding on right:" },
- { name: 'hole', type: 'float', initial: 1.5, caption: "Dimensions of hole:" },
- { name: 'gap', type: 'float', initial: 0.5, caption: "Gap around the hole:" },
- ];
- }
- function main( p )
- {
- var width = p.left + p.pins * ( p.hole + p.gap * 2 ) + p.right;
- var height = p.rows * ( p.hole + p.gap * 2 );
- var hole_x = p.gap * 2 + p.hole;
- var hole_z = p.gap * 2 + p.hole;
- var obj = cube( { size: [ width, p.length, height ] } );
- var hole = cube( { size: [ p.hole, p.length, p.hole ] } );
- if ( p.shape == 1 )
- hole = cylinder( { r: p.hole / 2, h: p.length } ).rotateX( -90 ).translate( [ p.hole / 2, 0, p.hole / 2 ]);
- for ( var i = 0; i < p.pins; i ++ )
- for ( var j = 0; j < p.rows ; j ++ )
- obj = difference( obj, hole.translate( [ p.left + p.gap + hole_x * i, 0, p.gap + hole_z * j ] ) );
- return obj;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement