// SmartGlass: part 0 = P0:SmartGlass (the assembled shape), part k = Pk:SmartGlass (one printable part, flat on z=0). // Flat-top acetate-style frame hiding a Seeed XIAO ESP32S3 Sense. Right end-piece: camera (behind the "rivet") + board. // Left end-piece: LiPo. USB-C sits in the right end-piece's back face: covered by the temple when open, exposed when folded. part = 0; // [0:Assembly, 1:Front, 2:DoorR, 3:DoorL, 4:TempleR, 5:TempleL] NAME = "SmartGlass"; $hl = 0; // set by the web app: the assembly draws only part $hl (red in P0); -1 = every part, lifted apart fold = 0; // [0:5:90] temple fold angle (assembly only) clash = false; // assembly only: draw ONLY where bought parts overlap printed parts (must be empty) $fn = 48; /* [Fit: measure your parts, these are assumptions] */ stack_t = 8.0; // ASSUMED: XIAO + Sense board thickness with the camera unfolded off the top board = [21, 17.8]; // XIAO footprint (length, width), from Seeed usb_off = 2.8; // ASSUMED: USB-C centre above the board's bottom face cam_hole = 3.0; // camera aperture; open up if the image vignettes in_w = 132; // clear width between the end-pieces (head width at the temples) /* [Style] */ lens_w = 52; lens_h = 38; dbl = 18; rim = 4; brow = 5; F = 5; wall = 1.2; door_t = 1.2; cap = 1.4; backw = 1.5; gap = 0.3; L = 32; // end-piece depth, front face to hinge face cav_x = stack_t + 0.6; cav_v = board.y + 0.6; T = wall + cav_x + door_t; // end-piece thickness (the number to minimise) lug_h = cav_v + 2 * cap; x_in = in_w / 2; x_out = x_in + T; cx = dbl / 2 + lens_w / 2; top = lens_h / 2 + brow; vb = top - lug_h; vmid = vb + lug_h / 2; pin_d = 1.1; kr = 1.6; kn = 3.5; // hinge: 1 mm steel wire (paperclip) pin, barrel radius, lug knuckle height ax = x_in + kr; aw = L + kr + gap; d0 = F + 1; d1 = L - backw + 0.5; v1 = top - cap; // door extents cam_x = x_out - wall - cav_x / 2; cam_v = v1 - 6.3; // 2 mm above the camera stays free for the battery wires usb_x = x_out - wall - usb_off; // board lies on the outer wall /** Wrap each part placed in the assembly (-1 lifts part k by k * 10 m so the web app can tell the parts apart) */ module show(k) if ($hl == 0 || $hl == k || $hl == -1) translate([0, 0, $hl == -1 ? k * 10000 : 0]) children(); /** "Pk:NAME" cut into the face at z=0 from below (mirrored so it reads correctly from underneath). */ module engrave(k, size = 4, depth = 0.4) translate([0, 0, -0.01]) linear_extrude(depth + 0.01) mirror([1, 0, 0]) text(str("P", k, ":", NAME), size = size, halign = "center", valign = "center"); module sides() for (s = [0, 1]) mirror([s, 0, 0]) children(); module yaxis(h, r) rotate([-90, 0, 0]) cylinder(r = r, h = h); /** print frame of the front -> worn position: front face towards -Y, up = +Z */ module worn() rotate([90, 0, 180]) children(); // ---- everything below is modelled in the front's print frame: x = sideways, y = up on the face, z = backwards ---- module lens2d() { hw = lens_w / 2; hh = lens_h / 2; hull() { translate([-hw + 5, hh - 5]) circle(5); translate([hw - 6, hh - 6]) circle(6); translate([hw - 14, -hh + 13]) circle(13); translate([-hw + 16, -hh + 14]) circle(14); } } module outline2d() offset(r = 1.5) offset(r = -4.5) offset(r = 3) { sides() { translate([cx, 0]) offset(r = rim) lens2d(); translate([x_in - 6, vb]) square([T + 6, lug_h]); } translate([-x_out, top - 7]) square([2 * x_out, 7]); // flat brow bar translate([-dbl / 2 - 1, top - 13]) square([dbl + 2, 13]); // bridge } /** door = the end-piece's skin-side wall; bevelled edges, slides up from below. c = clearance, v0 = bottom */ module door_body(c = 0, v0 = vb) hull() { translate([x_in + door_t - 0.01, v0, d0 - c]) cube([0.01, v1 + 0.6 + c - v0, d1 - d0 + 2 * c]); translate([x_in, v0, d0 + 0.6 - c]) cube([0.01, v1 + c - v0, d1 - d0 - 1.2 + 2 * c]); } /** click detent: a ridge on the bay's bottom wall snaps into a groove in the door, so the door cannot slide back down */ module detent(r, dx, z0, h) translate([x_in + door_t + dx, vb + 0.7, z0]) cylinder(r = r, h = h); module door() difference() { door_body(); detent(0.5, 0.1, 13.5, 9); } module front() { difference() { union() { linear_extrude(F) outline2d(); sides() { linear_extrude(L) intersection() { outline2d(); translate([x_in, vb]) square([T, lug_h]); } for (v = [vb, top - kn]) { // hinge knuckles (web only outboard: the temple sweeps the rest) translate([ax, v, aw]) yaxis(kn, kr); translate([ax, v, L - 0.5]) cube([kr, kn, aw - L + 0.5]); } translate([dbl / 2, -4.5, F - 0.1]) linear_extrude(5, scale = 0.75) translate([-dbl / 2, 4.5]) hull() { translate([dbl / 2 - 1.4, 2]) circle(1.8); translate([dbl / 2 + 1.6, -11]) circle(1.8); } // nose pads } } sides() { translate([cx, 0, -1]) linear_extrude(F + 2) lens2d(); translate([cx, 0, F / 2 - 0.6]) linear_extrude(1.2) offset(r = 0.5) lens2d(); // lens groove translate([x_in + door_t, vb + cap, wall]) cube([cav_x, cav_v, L - backw - wall]); // electronics bay door_body(0.15, vb - 1); translate([x_in - 1, vb - 1, d0 + 0.45]) cube([1.01, v1 + 1.15 - vb, d1 - d0 - 0.9]); translate([ax, vb - 1, aw]) yaxis(lug_h + 2, pin_d / 2); } translate([-x_in - door_t - 1, top - 3, F - 1.8]) cube([2 * (x_in + door_t + 1), 1.6, 1.81]); // battery wire groove translate([cam_x, cam_v, -0.01]) cylinder(d1 = cam_hole + 2.4, d2 = cam_hole, h = wall + 0.02); // camera "rivet" translate([-cam_x, cam_v, -0.01]) cylinder(d1 = cam_hole + 2.4, d2 = cam_hole + 1, h = 0.7); // dummy rivet translate([usb_x, vmid, L - backw - 0.1]) hull() for (d = [-1, 1]) translate([0, d * 2.9, 0]) cylinder(d = 3.6, h = backw + 0.2); translate([-x_out + wall - 0.3, vmid, 16]) rotate([0, 90, 0]) linear_extrude(0.31) // P1 mark, inside the battery bay text(str("P1:", NAME), size = 3, halign = "center", valign = "center"); } translate([x_in + door_t, cam_v - 4.3 - 1.2, wall - 0.1]) cube([cav_x, 1.2, 4]); // camera locating rib sides() detent(0.45, 0.15, 14, 8); } module rsec(t, h) hull() { square([t / 2, h]); for (y = [1.5, h - 1.5]) translate([t - 1.5, y]) circle(1.5); } module sec(w, t, v0, h) translate([x_in, v0, w]) linear_extrude(0.01) rsec(t, h); module temple() difference() { union() { difference() { union() { hull() { sec(L + gap, T, vb, lug_h); sec(L + 30, 4, vb + 4.5, 14); } hull() { sec(L + 30, 4, vb + 4.5, 14); sec(L + 80, 3.6, vb + 9, 9); } hull() { sec(L + 80, 3.6, vb + 9, 9); sec(L + 115, 3.6, vb - 14, 8); } } translate([x_in - 1, vb - 1, L]) cube([ax - x_in + 1, lug_h + 2, aw - L]); } translate([ax, vb, aw]) yaxis(lug_h, kr); } for (v = [vb - 1, top - kn - 0.2]) { // room for the front's knuckles translate([ax, v, aw]) yaxis(kn + 1.2, kr + 0.3); translate([x_in - 1, v, L]) cube([ax + kr + 0.3 - x_in + 1, kn + 1.2, aw - L]); } translate([ax, vb - 1, aw]) yaxis(lug_h + 2, pin_d / 2); } module hinge() translate([ax, 0, aw]) rotate([0, -fold, 0]) translate([-ax, 0, -aw]) children(); // ---- printable parts, flat on z=0 ---- module part1() front(); // front face down module door_flat() rotate([0, 90, 0]) translate([-x_in - door_t, -vb, -d0]) door(); module part2() difference() { door_flat(); translate([(d1 - d0) / 2, 10, 0]) engrave(2, 2.4); } module part3() difference() { mirror([0, 1, 0]) door_flat(); translate([(d1 - d0) / 2, -10, 0]) engrave(3, 2.4); } module temple_flat() rotate([0, -90, 0]) translate([-x_in, -vb, -L]) temple(); // skin side down module part4() difference() { temple_flat(); translate([-28, 12, 0]) engrave(4); } module part5() difference() { mirror([0, 1, 0]) temple_flat(); translate([-28, -12, 0]) engrave(5); } module assembly() { show(1) worn() front(); show(2) worn() translate([x_in + door_t, vb, d0]) rotate([0, -90, 0]) part2(); show(3) worn() mirror([1, 0, 0]) translate([x_in + door_t, vb, d0]) rotate([0, -90, 0]) mirror([0, 1, 0]) part3(); show(4) worn() hinge() translate([x_in, vb, L]) rotate([0, 90, 0]) part4(); show(5) worn() mirror([1, 0, 0]) hinge() translate([x_in, vb, L]) rotate([0, 90, 0]) mirror([0, 1, 0]) part5(); } /** bought parts the print must fit */ module ghosts() worn() { bx = x_out - wall - stack_t; bz = L - backw - board.x; lx = -x_out + wall + 0.3; difference() { union() { translate([bx, vmid - board.y / 2, bz]) cube([stack_t, board.y, board.x]); translate([usb_x, vmid, L - backw - 0.01]) hull() for (d = [-1, 1]) translate([0, d * 2.9, 0]) cylinder(d = 3.2, h = 1.3); } translate([bx + 0.6, vmid, bz + board.x / 2]) rotate([0, -90, 0]) linear_extrude(0.61) text("XIAO S3", size = 3, halign = "center", valign = "center"); } difference() { translate([cam_x - 4, cam_v - 4, wall + 0.1]) cube([8, 8, 5.5]); translate([cam_x, cam_v, wall + 5]) linear_extrude(0.61) text("CAM", size = 2, halign = "center", valign = "center"); } difference() { translate([lx, vmid - 8.5, wall + 1]) cube([6.5, 17, 27]); translate([lx + 5.9, vmid, wall + 14.5]) rotate([0, 90, 0]) linear_extrude(0.61) text("LIPO", size = 4, halign = "center", valign = "center"); } translate([-x_in - door_t - 0.5, top - 2.9, F - 1.6]) cube([2 * (x_in + door_t + 0.5), 1.4, 1.4]); // battery wire pair for (s = [-1, 1]) difference() { translate([s * cx, 0, F / 2 - 0.5]) scale([s, 1, 1]) linear_extrude(1) offset(r = 0.3) lens2d(); translate([s * cx, -8, F / 2 - 0.1]) linear_extrude(0.61) text("LENS", size = 3, halign = "center", valign = "center"); } } if (part == 0 && clash) intersection() { ghosts(); assembly(); } if (part == 0 && !clash) { assembly(); if ($hl <= 0) ghosts(); } if (part == 1) part1(); if (part == 2) part2(); if (part == 3) part3(); if (part == 4) part4(); if (part == 5) part5();