author | Michael Krelin <hacker@klever.net> | 2016-01-07 20:56:05 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2016-01-07 20:56:05 (UTC) |
commit | 8eb0d1b0f417ac889bad97a582377130e4603b3d (patch) (unidiff) | |
tree | 890b5a8116489ef23519cda3854a20f2a6f292aa | |
parent | fb43f676ec642311ebd214a21be4c960b008bcad (diff) | |
download | redelta-8eb0d1b0f417ac889bad97a582377130e4603b3d.zip redelta-8eb0d1b0f417ac889bad97a582377130e4603b3d.tar.gz redelta-8eb0d1b0f417ac889bad97a582377130e4603b3d.tar.bz2 |
alltogethernow part
-rw-r--r-- | delta.jscad | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/delta.jscad b/delta.jscad index 9c13528..ad19f88 100644 --- a/delta.jscad +++ b/delta.jscad | |||
@@ -562,169 +562,180 @@ function base_extrusions() { | |||
562 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); | 562 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); |
563 | return rv; | 563 | return rv; |
564 | } | 564 | } |
565 | 565 | ||
566 | function columns() { | 566 | function columns() { |
567 | return THREEWINDS.map(function(w) { | 567 | return THREEWINDS.map(function(w) { |
568 | return (E2020.extrusion({l:CONFIG.column.h}) | 568 | return (E2020.extrusion({l:CONFIG.column.h}) |
569 | .translate([0,CD.base.column_r,CONFIG.foot.h]) | 569 | .translate([0,CD.base.column_r,CONFIG.foot.h]) |
570 | .rotateZ(w).setColor(CONFIG.color.extrusion) | 570 | .rotateZ(w).setColor(CONFIG.color.extrusion) |
571 | ); | 571 | ); |
572 | }); | 572 | }); |
573 | } | 573 | } |
574 | function column_extrusions() { | 574 | function column_extrusions() { |
575 | var rv = union( columns() ); | 575 | var rv = union( columns() ); |
576 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); | 576 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); |
577 | return rv; | 577 | return rv; |
578 | } | 578 | } |
579 | 579 | ||
580 | function duet() { | 580 | function duet() { |
581 | var C = CONFIG.duet; | 581 | var C = CONFIG.duet; |
582 | var pholes = new CSG.Properties(); | 582 | var pholes = new CSG.Properties(); |
583 | var hx = C.hole_spacing.x/2; | 583 | var hx = C.hole_spacing.x/2; |
584 | var hy = C.hole_spacing.y/2; | 584 | var hy = C.hole_spacing.y/2; |
585 | var hh = { nw: [1,-1], ne: [1,1], se: [-1,1], sw: [-1,-1] }; | 585 | var hh = { nw: [1,-1], ne: [1,1], se: [-1,1], sw: [-1,-1] }; |
586 | var holes = []; | 586 | var holes = []; |
587 | for(w in hh) { | 587 | for(w in hh) { |
588 | var h = hh[w],_x=h[0]*hx,_y=h[1]*hy; | 588 | var h = hh[w],_x=h[0]*hx,_y=h[1]*hy; |
589 | holes.push(CSG.cylinder({start:[_x,_y,-1],end:[_x,_y,C.pcb_size.z+1],radius:3/2})); | 589 | holes.push(CSG.cylinder({start:[_x,_y,-1],end:[_x,_y,C.pcb_size.z+1],radius:3/2})); |
590 | pholes['c_'+w] = new CSG.Connector([_x,_y,0],[0,0,1],[1,0,0]); | 590 | pholes['c_'+w] = new CSG.Connector([_x,_y,0],[0,0,1],[1,0,0]); |
591 | } | 591 | } |
592 | rv = CSG.cube({ | 592 | rv = CSG.cube({ |
593 | corner1: [-C.pcb_size.x/2, -C.pcb_size.y/2, 0], | 593 | corner1: [-C.pcb_size.x/2, -C.pcb_size.y/2, 0], |
594 | corner2: [ C.pcb_size.x/2, C.pcb_size.y/2, C.pcb_size.z] | 594 | corner2: [ C.pcb_size.x/2, C.pcb_size.y/2, C.pcb_size.z] |
595 | }).subtract(holes).setColor(CONFIG.color.pcb).union( | 595 | }).subtract(holes).setColor(CONFIG.color.pcb).union( |
596 | CSG.cube({ | 596 | CSG.cube({ |
597 | corner1: [-C.pcb_size.x/2,-C.hole_spacing.y/2+3,C.pcb_size.z], | 597 | corner1: [-C.pcb_size.x/2,-C.hole_spacing.y/2+3,C.pcb_size.z], |
598 | corner2: [ C.pcb_size.x/2, C.hole_spacing.y/2-3,C.h] | 598 | corner2: [ C.pcb_size.x/2, C.hole_spacing.y/2-3,C.h] |
599 | }).setColor(CONFIG.color.bulk) | 599 | }).setColor(CONFIG.color.bulk) |
600 | ); | 600 | ); |
601 | rv.properties.holes = pholes; | 601 | rv.properties.holes = pholes; |
602 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); | 602 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); |
603 | rv.properties.vitamin = true; | 603 | rv.properties.vitamin = true; |
604 | return rv; | 604 | return rv; |
605 | } | 605 | } |
606 | 606 | ||
607 | function foot() { | 607 | function foot() { |
608 | var F = CONFIG.foot; | 608 | var F = CONFIG.foot; |
609 | var br = F.bolt.hd/2+F.margin; | 609 | var br = F.bolt.hd/2+F.margin; |
610 | var bh = F.zscalefactor*Math.sqrt(Math.pow(F.d/2,2)-Math.pow(br,2)); | 610 | var bh = F.zscalefactor*Math.sqrt(Math.pow(F.d/2,2)-Math.pow(br,2)); |
611 | var th = F.h-bh; | 611 | var th = F.h-bh; |
612 | var r = 2*F.d; | 612 | var r = 2*F.d; |
613 | var rv = CSG.sphere({ // botom contorted sphere | 613 | var rv = CSG.sphere({ // botom contorted sphere |
614 | center: [0,0,0], radius: F.d/2, resolution: r | 614 | center: [0,0,0], radius: F.d/2, resolution: r |
615 | }).scale([1,1,F.zscalefactor]).translate([0,0,bh]).union(CSG.cylinder({ // top hat | 615 | }).scale([1,1,F.zscalefactor]).translate([0,0,bh]).union(CSG.cylinder({ // top hat |
616 | start: [0,0,bh], end: [0,0,F.h], radius: F.d/2, resolution: r | 616 | start: [0,0,bh], end: [0,0,F.h], radius: F.d/2, resolution: r |
617 | })).intersect(CSG.cylinder({ // cut off excess | 617 | })).intersect(CSG.cylinder({ // cut off excess |
618 | start: [0,0,0], end: [0,0,F.h], radius: F.d | 618 | start: [0,0,0], end: [0,0,F.h], radius: F.d |
619 | })).subtract([ | 619 | })).subtract([ |
620 | CSG.cylinder({ // bolt hole | 620 | CSG.cylinder({ // bolt hole |
621 | start: [0,0,-1], end: [0,0,F.h+1], radius: F.bolt.d/2+PRINT.slide_tolerance | 621 | start: [0,0,-1], end: [0,0,F.h+1], radius: F.bolt.d/2+PRINT.slide_tolerance |
622 | }), CSG.cylinder({ // nut hole | 622 | }), CSG.cylinder({ // nut hole |
623 | start: [0,0,F.h-F.nut.h-PRINT.play_tolerance], | 623 | start: [0,0,F.h-F.nut.h-PRINT.play_tolerance], |
624 | end: [0,0,F.h], | 624 | end: [0,0,F.h], |
625 | radius: F.nut.d/2+PRINT.slide_tolerance, resolution: 6 | 625 | radius: F.nut.d/2+PRINT.slide_tolerance, resolution: 6 |
626 | }), CSG.cylinder({ // bolthead/washer hole | 626 | }), CSG.cylinder({ // bolthead/washer hole |
627 | start: [0,0,-1], end: [0,0,F.h-F.nut.h-PRINT.play_tolerance-F.shell], | 627 | start: [0,0,-1], end: [0,0,F.h-F.nut.h-PRINT.play_tolerance-F.shell], |
628 | radius: F.bolt.hd/2+PRINT.play_tolerance | 628 | radius: F.bolt.hd/2+PRINT.play_tolerance |
629 | }) | 629 | }) |
630 | ]).union(CSG.cylinder({ // bridging patch | 630 | ]).union(CSG.cylinder({ // bridging patch |
631 | start: [0,0,F.h-F.nut.h-PRINT.play_tolerance-PRINT.layer_height], | 631 | start: [0,0,F.h-F.nut.h-PRINT.play_tolerance-PRINT.layer_height], |
632 | end: [0,0,F.h-F.nut.h-PRINT.play_tolerance], | 632 | end: [0,0,F.h-F.nut.h-PRINT.play_tolerance], |
633 | radius: F.nut.d/2 | 633 | radius: F.nut.d/2 |
634 | })); | 634 | })); |
635 | rv.properties.c_column = new CSG.Connector([0,0,F.h],[0,0,1],[1,0,0]); | 635 | rv.properties.c_column = new CSG.Connector([0,0,F.h],[0,0,1],[1,0,0]); |
636 | rv.properties.P = new CSG.Connector([0,0,F.h],[0,0,-1],[1,0,0]); | 636 | rv.properties.P = new CSG.Connector([0,0,F.h],[0,0,-1],[1,0,0]); |
637 | return rv.setColor(CONFIG.color.parts); | 637 | return rv.setColor(CONFIG.color.parts); |
638 | } | 638 | } |
639 | 639 | ||
640 | function refaxes(o) { | 640 | function refaxes(o) { |
641 | if(!o) o = {}; | 641 | if(!o) o = {}; |
642 | var l = o.l||20, g = o.g||0.7; | 642 | var l = o.l||20, g = o.g||0.7; |
643 | return union([ | 643 | return union([ |
644 | CSG.roundedCylinder({start:[0,0,0],end:[l,0,0]}).setColor([1,0,0,g]), | 644 | CSG.roundedCylinder({start:[0,0,0],end:[l,0,0]}).setColor([1,0,0,g]), |
645 | CSG.roundedCylinder({start:[0,0,0],end:[0,l,0]}).setColor([0,1,0,g]), | 645 | CSG.roundedCylinder({start:[0,0,0],end:[0,l,0]}).setColor([0,1,0,g]), |
646 | CSG.roundedCylinder({start:[0,0,0],end:[0,0,l]}).setColor([0,0,1,g]) | 646 | CSG.roundedCylinder({start:[0,0,0],end:[0,0,l]}).setColor([0,0,1,g]) |
647 | ]); | 647 | ]); |
648 | } | 648 | } |
649 | 649 | ||
650 | function P(x) { | 650 | function P(x) { |
651 | return x.connectTo(x.properties.P,new CSG.Connector([0,0,0],[0,0,1],[1,0,0]), false, 0); | 651 | return x.connectTo(x.properties.P,new CSG.Connector([0,0,0],[0,0,1],[1,0,0]), false, 0); |
652 | } | 652 | } |
653 | 653 | ||
654 | var PARTS = { | 654 | var PARTS = { |
655 | wip: function(params) { | 655 | wip: function(params) { |
656 | return foot(); | 656 | return foot(); |
657 | return union(base_extrusions(),column_extrusions(),duet()); | 657 | return union(base_extrusions(),column_extrusions(),duet()); |
658 | alltogethernow: function(params) { | ||
659 | var cols = columns(); | ||
660 | var sides = base_sides(); | ||
661 | var feet = THREEWINDS.map(function(w,i) { | ||
662 | var rv = foot(); | ||
663 | rv = rv.connectTo(rv.properties.c_column,cols[i].properties.c_bottom,false,0); | ||
664 | return rv; | ||
665 | }); | ||
666 | var rv = union(cols).union(sides.map(union)).union(feet); | ||
667 | rv.properties.P = new CSG.Connector([0,0,0],[0,0,1],[1,0,0]); | ||
668 | return rv; | ||
658 | } | 669 | } |
659 | }; | 670 | }; |
660 | 671 | ||
661 | function main(params) { | 672 | function main(params) { |
662 | var part = params.part && PARTS[params.part]; | 673 | var part = params.part && PARTS[params.part]; |
663 | if(!part) return refaxes(); | 674 | if(!part) return refaxes(); |
664 | var rv = P(part(params)); | 675 | var rv = P(part(params)); |
665 | if(!params.print) rv = rv.union(refaxes()); | 676 | if(!params.print) rv = rv.union(refaxes()); |
666 | return rv; | 677 | return rv; |
667 | } | 678 | } |
668 | 679 | ||
669 | function _main(params) { | 680 | function _main(params) { |
670 | var e = EFFECTOR.effector(); | 681 | var e = EFFECTOR.effector(); |
671 | var hs = E3DV6.heatsink(); | 682 | var hs = E3DV6.heatsink(); |
672 | hs = hs.connectTo(hs.properties.grove_connector,e.properties.grove_connector,false,0); | 683 | hs = hs.connectTo(hs.properties.grove_connector,e.properties.grove_connector,false,0); |
673 | var ms = microswitch(); | 684 | var ms = microswitch(); |
674 | var hd = EFFECTOR.hinged({ | 685 | var hd = EFFECTOR.hinged({ |
675 | microswitch:ms,effector:e | 686 | microswitch:ms,effector:e |
676 | }); | 687 | }); |
677 | ms = ms.connectTo( | 688 | ms = ms.connectTo( |
678 | ms.properties.screw_connector[0], | 689 | ms.properties.screw_connector[0], |
679 | hd.properties.microswitch_screw_connector[0], | 690 | hd.properties.microswitch_screw_connector[0], |
680 | false, 0); | 691 | false, 0); |
681 | var hdhd = EFFECTOR.split_hinged(hd); | 692 | var hdhd = EFFECTOR.split_hinged(hd); |
682 | var fh = EFFECTOR.fanholder(); | 693 | var fh = EFFECTOR.fanholder(); |
683 | return union({ | 694 | return union({ |
684 | platform: e, | 695 | platform: e, |
685 | hinged: hdhd[1], | 696 | hinged: hdhd[1], |
686 | clamp: hdhd[0], | 697 | clamp: hdhd[0], |
687 | fanholder: fh, | 698 | fanholder: fh, |
688 | alltogethernow: [e,hdhd[0],hdhd[1], columns(),hs,ms,fh] | 699 | alltogethernow: [e,hdhd[0],hdhd[1], columns(),hs,ms,fh] |
689 | }[params.part||'alltogethernow']) | 700 | }[params.part||'alltogethernow']) |
690 | var rv = union( | 701 | var rv = union( |
691 | e, | 702 | e, |
692 | hs, | 703 | hs, |
693 | columns(), | 704 | columns(), |
694 | ///hd, | 705 | ///hd, |
695 | hdhd[0], hdhd[1], | 706 | hdhd[0], hdhd[1], |
696 | ms); | 707 | ms); |
697 | return rv; | 708 | return rv; |
698 | } | 709 | } |
699 | 710 | ||
700 | function getParameterDefinitions() { | 711 | function getParameterDefinitions() { |
701 | return [{ | 712 | return [{ |
702 | name: 'part', | 713 | name: 'part', |
703 | type: 'choice', | 714 | type: 'choice', |
704 | values: [ | 715 | values: [ |
705 | 'platform', | 716 | 'platform', |
706 | 'hinged', | 717 | 'hinged', |
707 | 'clamp', | 718 | 'clamp', |
708 | 'fanholder', | 719 | 'fanholder', |
709 | 'alltogethernow', | 720 | 'alltogethernow', |
710 | 'wip' | 721 | 'wip' |
711 | ], | 722 | ], |
712 | captions: [ | 723 | captions: [ |
713 | 'Effector platform', | 724 | 'Effector platform', |
714 | 'Hinged part', | 725 | 'Hinged part', |
715 | 'Clamp', | 726 | 'Clamp', |
716 | 'Fan holder', | 727 | 'Fan holder', |
717 | 'All together now!', | 728 | 'All together now!', |
718 | 'Work in progress' | 729 | 'Work in progress' |
719 | ], | 730 | ], |
720 | caption: 'Part', | 731 | caption: 'Part', |
721 | initial: 'wip' | 732 | initial: 'wip' |
722 | },{ | 733 | },{ |
723 | name: 'print', | 734 | name: 'print', |
724 | type: 'checkbox', | 735 | type: 'checkbox', |
725 | caption: 'For print, no nonsense', | 736 | caption: 'For print, no nonsense', |
726 | initial: false | 737 | initial: false |
727 | }]; | 738 | }]; |
728 | } | 739 | } |
729 | 740 | ||
730 | /* vim:set ft=javascript ai: */ | 741 | /* vim:set ft=javascript ai: */ |