|
| 1 | +import type { Geom3 } from '@jscad/modeling/src/geometries/types' |
| 2 | +import { |
| 3 | + intersect, |
| 4 | + subtract, |
| 5 | + union, |
| 6 | +} from '@jscad/modeling/src/operations/booleans' |
| 7 | +import { extrudeLinear } from '@jscad/modeling/src/operations/extrusions' |
| 8 | +import { |
| 9 | + rotateX, |
| 10 | + rotateZ, |
| 11 | + translateX, |
| 12 | + translateZ, |
| 13 | +} from '@jscad/modeling/src/operations/transforms' |
| 14 | +import { |
| 15 | + cuboid, |
| 16 | + cylinder, |
| 17 | + cylinderElliptic, |
| 18 | + triangle, |
| 19 | +} from '@jscad/modeling/src/primitives' |
| 20 | +import { degToRad } from '@jscad/modeling/src/utils' |
| 21 | + |
| 22 | +const holes: Geom3[] = [] |
| 23 | + |
| 24 | +const holeSizeX = 9.5 |
| 25 | +const holeSizeY = 7.5 |
| 26 | + |
| 27 | +for (let i = 0; i < 8; i++) { |
| 28 | + holes.push( |
| 29 | + rotateZ( |
| 30 | + degToRad((360 / 8) * i), |
| 31 | + translateX( |
| 32 | + 15, |
| 33 | + subtract( |
| 34 | + union( |
| 35 | + translateZ( |
| 36 | + 3, |
| 37 | + subtract( |
| 38 | + cylinderElliptic({ |
| 39 | + startRadius: [(holeSizeX * 1.05) / 2, (holeSizeY * 1.1) / 2], |
| 40 | + endRadius: [(holeSizeX * 1.05) / 2, (holeSizeY * 1.1) / 2], |
| 41 | + height: 1, |
| 42 | + }), |
| 43 | + cylinderElliptic({ |
| 44 | + startRadius: [(holeSizeX - 2) / 2, (holeSizeY - 2) / 2], |
| 45 | + endRadius: [(holeSizeX - 2) / 2, (holeSizeY - 2) / 2], |
| 46 | + height: 5, |
| 47 | + }), |
| 48 | + ), |
| 49 | + ), |
| 50 | + subtract( |
| 51 | + cylinderElliptic({ |
| 52 | + startRadius: [holeSizeX / 2, holeSizeY / 2], |
| 53 | + endRadius: [holeSizeX / 2, holeSizeY / 2], |
| 54 | + height: 5, |
| 55 | + }), |
| 56 | + cylinderElliptic({ |
| 57 | + startRadius: [(holeSizeX - 2) / 2, (holeSizeY - 2) / 2], |
| 58 | + endRadius: [(holeSizeX - 2) / 2, (holeSizeY - 2) / 2], |
| 59 | + height: 5, |
| 60 | + }), |
| 61 | + ), |
| 62 | + ), |
| 63 | + cuboid({ |
| 64 | + size: [12, 2, 10], |
| 65 | + }), |
| 66 | + ), |
| 67 | + ), |
| 68 | + ), |
| 69 | + ) |
| 70 | +} |
| 71 | + |
| 72 | +const grapper = () => |
| 73 | + translateZ( |
| 74 | + 20, |
| 75 | + intersect( |
| 76 | + union( |
| 77 | + subtract( |
| 78 | + cylinder({ |
| 79 | + radius: 29.8 / 2, |
| 80 | + height: 6, |
| 81 | + }), |
| 82 | + cylinder({ |
| 83 | + radius: 29.8 / 2 - 2, |
| 84 | + height: 6, |
| 85 | + }), |
| 86 | + ), |
| 87 | + translateZ( |
| 88 | + 2.5, |
| 89 | + subtract( |
| 90 | + cylinder({ |
| 91 | + radius: 29.8 / 2 + 1, |
| 92 | + height: 1, |
| 93 | + }), |
| 94 | + cylinder({ |
| 95 | + radius: 29.8 / 2, |
| 96 | + height: 1, |
| 97 | + }), |
| 98 | + ), |
| 99 | + ), |
| 100 | + ), |
| 101 | + translateZ( |
| 102 | + -5, |
| 103 | + extrudeLinear( |
| 104 | + { |
| 105 | + height: 10, |
| 106 | + }, |
| 107 | + triangle({ |
| 108 | + type: 'SSA', |
| 109 | + values: [20, 20, Math.PI / 3], |
| 110 | + }), |
| 111 | + ), |
| 112 | + ), |
| 113 | + ), |
| 114 | + ) |
| 115 | + |
| 116 | +export const robotWheelAdapter = () => |
| 117 | + union([ |
| 118 | + translateZ(5, union(holes)), |
| 119 | + translateZ( |
| 120 | + 2, |
| 121 | + subtract( |
| 122 | + cylinder({ |
| 123 | + radius: 20, |
| 124 | + height: 1, |
| 125 | + }), |
| 126 | + cylinder({ |
| 127 | + radius: 10, |
| 128 | + height: 2, |
| 129 | + }), |
| 130 | + ), |
| 131 | + ), |
| 132 | + translateZ( |
| 133 | + 19, |
| 134 | + rotateX( |
| 135 | + degToRad(180), |
| 136 | + union( |
| 137 | + grapper(), |
| 138 | + rotateZ(degToRad(120), grapper()), |
| 139 | + rotateZ(degToRad(-120), grapper()), |
| 140 | + ), |
| 141 | + ), |
| 142 | + ), |
| 143 | + ]) |
0 commit comments