summaryrefslogtreecommitdiffabout
path: root/delta.jscad
authorMichael Krelin <hacker@klever.net>2016-01-06 23:46:44 (UTC)
committer Michael Krelin <hacker@klever.net>2016-01-06 23:46:44 (UTC)
commit740c971a9ebf663765e91eb84e2251d303ea4ceb (patch) (unidiff)
tree8ff1127eaaf754b37d74a13a19fc8f7f7090f301 /delta.jscad
parent4cb92354224641376d311adc7589ebb4bdc5639d (diff)
downloadredelta-740c971a9ebf663765e91eb84e2251d303ea4ceb.zip
redelta-740c971a9ebf663765e91eb84e2251d303ea4ceb.tar.gz
redelta-740c971a9ebf663765e91eb84e2251d303ea4ceb.tar.bz2
part selection machinery
Diffstat (limited to 'delta.jscad') (more/less context) (ignore whitespace changes)
-rw-r--r--delta.jscad12
1 files changed, 11 insertions, 1 deletions
diff --git a/delta.jscad b/delta.jscad
index b3bb3d3..5d40e26 100644
--- a/delta.jscad
+++ b/delta.jscad
@@ -537,125 +537,135 @@ var THREEWINDS = [0,120,240];
537 537
538function base_extrusions() { 538function base_extrusions() {
539 var rv = union( THREEWINDS.map(function(w) { 539 var rv = union( THREEWINDS.map(function(w) {
540 var e = E2020.extrusion({l:CONFIG.base.el}); 540 var e = E2020.extrusion({l:CONFIG.base.el});
541 e = e.connectTo(e.properties.c_midway, 541 e = e.connectTo(e.properties.c_midway,
542 new CSG.Connector([0,-CD.base.mid_inscription_r,CONFIG.extrusion.w/2],[1,0,0],[0,0,1]), 542 new CSG.Connector([0,-CD.base.mid_inscription_r,CONFIG.extrusion.w/2],[1,0,0],[0,0,1]),
543 false, 0); 543 false, 0);
544 return union( [0,CONFIG.extrusion.w+CONFIG.base.gap].map(function(z) { 544 return union( [0,CONFIG.extrusion.w+CONFIG.base.gap].map(function(z) {
545 return e.translate([0,0,z]); 545 return e.translate([0,0,z]);
546 }) ).rotateZ(w); 546 }) ).rotateZ(w);
547 }) ); 547 }) );
548 rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); 548 rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]);
549 return rv.setColor(CONFIG.color.extrusion); 549 return rv.setColor(CONFIG.color.extrusion);
550} 550}
551 551
552function column_extrusions() { 552function column_extrusions() {
553 var rv = union( THREEWINDS.map(function(w) { 553 var rv = union( THREEWINDS.map(function(w) {
554 return E2020.extrusion({l:CONFIG.column.h}).translate([0,CD.base.column_r,0]).rotateZ(w); 554 return E2020.extrusion({l:CONFIG.column.h}).translate([0,CD.base.column_r,0]).rotateZ(w);
555 }) ); 555 }) );
556 rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); 556 rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]);
557 return rv.setColor(CONFIG.color.extrusion); 557 return rv.setColor(CONFIG.color.extrusion);
558} 558}
559 559
560function duet() { 560function duet() {
561 var C = CONFIG.duet; 561 var C = CONFIG.duet;
562 var pholes = new CSG.Properties(); 562 var pholes = new CSG.Properties();
563 var hx = C.hole_spacing.x/2; 563 var hx = C.hole_spacing.x/2;
564 var hy = C.hole_spacing.y/2; 564 var hy = C.hole_spacing.y/2;
565 var hh = { nw: [1,-1], ne: [1,1], se: [-1,1], sw: [-1,-1] }; 565 var hh = { nw: [1,-1], ne: [1,1], se: [-1,1], sw: [-1,-1] };
566 var holes = []; 566 var holes = [];
567 for(w in hh) { 567 for(w in hh) {
568 var h = hh[w],_x=h[0]*hx,_y=h[1]*hy; 568 var h = hh[w],_x=h[0]*hx,_y=h[1]*hy;
569 holes.push(CSG.cylinder({start:[_x,_y,-1],end:[_x,_y,C.pcb_size.z+1],radius:3/2})); 569 holes.push(CSG.cylinder({start:[_x,_y,-1],end:[_x,_y,C.pcb_size.z+1],radius:3/2}));
570 pholes['c_'+w] = new CSG.Connector([_x,_y,0],[0,0,1],[1,0,0]); 570 pholes['c_'+w] = new CSG.Connector([_x,_y,0],[0,0,1],[1,0,0]);
571 } 571 }
572 rv = CSG.cube({ 572 rv = CSG.cube({
573 corner1: [-C.pcb_size.x/2, -C.pcb_size.y/2, 0], 573 corner1: [-C.pcb_size.x/2, -C.pcb_size.y/2, 0],
574 corner2: [ C.pcb_size.x/2, C.pcb_size.y/2, C.pcb_size.z] 574 corner2: [ C.pcb_size.x/2, C.pcb_size.y/2, C.pcb_size.z]
575 }).subtract(holes).setColor(CONFIG.color.pcb).union( 575 }).subtract(holes).setColor(CONFIG.color.pcb).union(
576 CSG.cube({ 576 CSG.cube({
577 corner1: [-C.pcb_size.x/2,-C.hole_spacing.y/2+3,C.pcb_size.z], 577 corner1: [-C.pcb_size.x/2,-C.hole_spacing.y/2+3,C.pcb_size.z],
578 corner2: [ C.pcb_size.x/2, C.hole_spacing.y/2-3,C.h] 578 corner2: [ C.pcb_size.x/2, C.hole_spacing.y/2-3,C.h]
579 }).setColor(CONFIG.color.bulk) 579 }).setColor(CONFIG.color.bulk)
580 ); 580 );
581 rv.properties.holes = pholes; 581 rv.properties.holes = pholes;
582 rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); 582 rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]);
583 rv.properties.vitamin = true; 583 rv.properties.vitamin = true;
584 return rv; 584 return rv;
585} 585}
586 586
587function refaxes(o) { 587function refaxes(o) {
588 if(!o) o = {}; 588 if(!o) o = {};
589 var l = o.l||20, g = o.g||0.7; 589 var l = o.l||20, g = o.g||0.7;
590 return union([ 590 return union([
591 CSG.cylinder({start:[0,0,0],end:[l,0,0]}).setColor([1,0,0,g]), 591 CSG.cylinder({start:[0,0,0],end:[l,0,0]}).setColor([1,0,0,g]),
592 CSG.cylinder({start:[0,0,0],end:[0,l,0]}).setColor([0,1,0,g]), 592 CSG.cylinder({start:[0,0,0],end:[0,l,0]}).setColor([0,1,0,g]),
593 CSG.cylinder({start:[0,0,0],end:[0,0,l]}).setColor([0,0,1,g]) 593 CSG.cylinder({start:[0,0,0],end:[0,0,l]}).setColor([0,0,1,g])
594 ]); 594 ]);
595} 595}
596 596
597function P(x) { 597function P(x) {
598 return x.connectTo(x.properties.P,new CSG.Connector([0,0,0],[0,0,1],[1,0,0]), false, 0); 598 return x.connectTo(x.properties.P,new CSG.Connector([0,0,0],[0,0,1],[1,0,0]), false, 0);
599} 599}
600 600
601var PARTS = {
602 wip: function(params) {
603 return union(base_extrusions(),column_extrusions(),duet());
604 }
605};
606
601function main(params) { 607function main(params) {
602 return refaxes().union(P(base_extrusions())); 608 var part = params.part && PARTS[params.part];
609 if(!part) return refaxes();
610 var rv = P(part(params));
611 if(true) rv = rv.union(refaxes());
612 return rv;
603} 613}
604 614
605function _main(params) { 615function _main(params) {
606 var e = EFFECTOR.effector(); 616 var e = EFFECTOR.effector();
607 var hs = E3DV6.heatsink(); 617 var hs = E3DV6.heatsink();
608 hs = hs.connectTo(hs.properties.grove_connector,e.properties.grove_connector,false,0); 618 hs = hs.connectTo(hs.properties.grove_connector,e.properties.grove_connector,false,0);
609 var ms = microswitch(); 619 var ms = microswitch();
610 var hd = EFFECTOR.hinged({ 620 var hd = EFFECTOR.hinged({
611 microswitch:ms,effector:e 621 microswitch:ms,effector:e
612 }); 622 });
613 ms = ms.connectTo( 623 ms = ms.connectTo(
614 ms.properties.screw_connector[0], 624 ms.properties.screw_connector[0],
615 hd.properties.microswitch_screw_connector[0], 625 hd.properties.microswitch_screw_connector[0],
616 false, 0); 626 false, 0);
617 var hdhd = EFFECTOR.split_hinged(hd); 627 var hdhd = EFFECTOR.split_hinged(hd);
618 var fh = EFFECTOR.fanholder(); 628 var fh = EFFECTOR.fanholder();
619 return union({ 629 return union({
620 platform: e, 630 platform: e,
621 hinged: hdhd[1], 631 hinged: hdhd[1],
622 clamp: hdhd[0], 632 clamp: hdhd[0],
623 fanholder: fh, 633 fanholder: fh,
624 alltogethernow: [e,hdhd[0],hdhd[1], columns(),hs,ms,fh] 634 alltogethernow: [e,hdhd[0],hdhd[1], columns(),hs,ms,fh]
625 }[params.part||'alltogethernow']) 635 }[params.part||'alltogethernow'])
626 var rv = union( 636 var rv = union(
627 e, 637 e,
628 hs, 638 hs,
629 columns(), 639 columns(),
630 ///hd, 640 ///hd,
631 hdhd[0], hdhd[1], 641 hdhd[0], hdhd[1],
632 ms); 642 ms);
633 return rv; 643 return rv;
634} 644}
635 645
636function getParameterDefinitions() { 646function getParameterDefinitions() {
637 return [{ 647 return [{
638 name: 'part', 648 name: 'part',
639 type: 'choice', 649 type: 'choice',
640 values: [ 650 values: [
641 'platform', 651 'platform',
642 'hinged', 652 'hinged',
643 'clamp', 653 'clamp',
644 'fanholder', 654 'fanholder',
645 'alltogethernow', 655 'alltogethernow',
646 'wip' 656 'wip'
647 ], 657 ],
648 captions: [ 658 captions: [
649 'Effector platform', 659 'Effector platform',
650 'Hinged part', 660 'Hinged part',
651 'Clamp', 661 'Clamp',
652 'Fan holder', 662 'Fan holder',
653 'All together now!', 663 'All together now!',
654 'Work in progress' 664 'Work in progress'
655 ], 665 ],
656 caption: 'Part', 666 caption: 'Part',
657 initial: 'wip' 667 initial: 'wip'
658 }]; 668 }];
659} 669}
660 670
661/* vim:set ft=javascript ai: */ 671/* vim:set ft=javascript ai: */