seasick/openscad-web-gui

Incorrect rendering

Closed this issue · 3 comments

braid
braid1
Should produce a frame, flat background for the frame and a 3 filament bride that is rounded on top and flat on the bottom.

The background should be smaller than the frame and sit inside. The braid should be smaller than the frame and sit inside.

$fn=30;
$EC=.3; 

/* [Parts] */
Braid = true;
Frame = true;
Back  = true;
Separate = true;

/* [Body] */

Len      = 50;   // [10:300] 
Height   = 10;   // [3:100]
Base_Thk = 2;



/* [Border] */

Brdr    = 1.6;    // [2:20]



/* [Braid] */

Cycles  = 1;    // [1:20]
StpSiz   = 15;   // [1,5,10,15,30,45,60,90]
Rope_R = 1.6;    // [1:.01:5]
Braid_OvLp  = 1.6;    // [1:10]
ThkScale = .5;  // [.1:1]

Hit=Height/2;
CL = Len/(Cycles*360);

Frm_Hit=Base_Thk+2*(Braid_OvLp+Rope_R)*ThkScale;

if (Separate) {

translate([-(Len+Brdr+10),0,-Base_Thk]) IBraid();

translate([0,0,Frm_Hit]) mirror([0,0,1]) IFrame();

translate([0,Height+Brdr+10]) IBack(dx=-$EC);

} else {
   if (Braid) { IBraid(); }
   if (Frame) { IFrame(); }
   if (Back)  { IBack(dx=-$EC); }
}


//render()
module IBraid() {
   intersection() {
      color("orange")
      translate([0,0,Base_Thk]) 
      scale([1,1,ThkScale]) {
         One();
         One(120);
         One(240);
      }
      cube([Len,2*(Hit+Rope_R),100],center=true);
   }
}



module IFrame() {

   color("red")
   difference() {
   translate([0,0,Frm_Hit/2]) 
   difference() {
         cube([Len+2*Brdr,2*(Hit+Brdr+Rope_R),Frm_Hit],center=true);
         cube([Len+2*$EC,2*(Hit+Rope_R+$EC),Frm_Hit+4],center=true);
      }
      IBack();
   }
}



module IBack(dx=0) {
   color("wheat")
   translate([0,0,Base_Thk/2-.01])
   cube([Len+Brdr-dx,2*(Hit+Rope_R)+Brdr-dx,Base_Thk+.01],center=true);
}



module One(Phase=0) {
t=Base_Thk+(Braid_OvLp+Rope_R)*ThkScale;
   for (a = [-180*Cycles+StpSiz:StpSiz:180*Cycles]) {
      hull() {
         Seg(a,t);
         linear_extrude(.1)
         projection(cut=false)
         Seg(a,t);
      }
   }


module Seg(a,t) {
      translate([0,0,t])
      hull() {
         translate([CL*(a-StpSiz),Hit*sin(a-StpSiz+Phase),Braid_OvLp*cos(a-StpSiz+Phase)])
         sphere(Rope_R);
         translate([CL*a,Hit*sin(a+Phase),Braid_OvLp*cos(a+Phase)])
         sphere(Rope_R);
      }
   }

}

@ScottNudds, what are you seeing or what is incorrect? Are you referring to the different colors?
Also: Which browser are you using?

With your script I see the following:
image

I did a lot of fixing after posting it to Reddit - I guess that got fixed somewhere along the line. I'm closing this issue.
Thank you for your feedback!