Last active
August 2, 2023 20:22
-
-
Save nicklockwood/c2026937a8fb9c88c2a7b8bd0b82a0f3 to your computer and use it in GitHub Desktop.
A reusable ShapeScript block for drawing a rounded cube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ShapeScript document | |
detail 32 | |
define roundedcube { | |
option radius 0.25 | |
option size 1 1 1 | |
detail max(4 detail) | |
define size_ size | |
define diameter radius * 2 / size_ | |
define offset 0.5 - diameter / 2 | |
union { | |
size size_ | |
cube { size 1 offset.height * 2 offset.depth * 2 } | |
cube { size offset.width * 2 1 offset.depth * 2 } | |
cube { size offset.width * 2 offset.height * 2 1 } | |
for y in (-1 1) { | |
for x in (-1 1) { | |
cylinder { | |
position offset.width * x 0 offset.depth * y | |
size diameter.width offset.height * 2 diameter.depth | |
} | |
cylinder { | |
orientation 0.5 | |
position 0 offset.height * x offset.depth * y | |
size diameter.height offset.width * 2 diameter.depth | |
} | |
cylinder { | |
orientation 0 0 0.5 | |
position offset.width * x offset.height * y 0 | |
size diameter.width offset.depth * 2 diameter.height | |
} | |
for z in (-1 1) { | |
sphere { | |
position offset.width * x offset.height * y offset.depth * z | |
size diameter | |
} | |
} | |
} | |
} | |
} | |
} | |
roundedcube { | |
radius 0.5 | |
size 1 2 3 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment