Skip to content

Instantly share code, notes, and snippets.

@neomatrixcode
Forked from apua/cube_split.rst
Created September 29, 2018 16:57
Show Gist options
  • Save neomatrixcode/d52110647064ec4cb7aea5fc1211ff74 to your computer and use it in GitHub Desktop.
Save neomatrixcode/d52110647064ec4cb7aea5fc1211ff74 to your computer and use it in GitHub Desktop.
Cube Split
// https://openjscad.org/
function top() { return polyhedron({
points: [
[0,4,4],[1,3,4],[3,3,4],[3,1,4],[0,1,4],
[0,3,3],[1,3,3],[3,3,3],[3,1,3],[0,1,3],
],
triangles: [
[0,1,4],[1,3,4],[1,2,3],
[0,6,1],[0,5,6],[1,6,7],[1,7,2],[2,7,3],[3,7,8],
[3,8,9],[4,3,9],[4,9,5],[0,4,5],
[5,8,7],[5,9,8]
],
}); }
function bottom() { return polyhedron({
points: [
[0,4,1],[3,4,1],[3,1,1],[0,1,1],
[0,4,0],[4,4,0],[4,0,0],[0,0,0],
],
triangles: [
[0,1,2],[0,2,3],
[0,4,5],[0,5,1],[2,1,5],[2,5,6],[3,2,6],[3,6,7],[3,7,4],[3,4,0],
[4,6,5],[4,7,6],
],
}); }
function pillar() { return polyhedron({
points: [
[1,1,3],[3,3,3],[3,1,3],
[1,1,1],[2,2,2],[2,2,1],
[2,1,2],[3,1,1],
],
triangles: [
[0,1,2],
[0,3,1],[3,5,4],
[0,2,3],[3,6,7],
[1,4,2],[2,4,6],[4,5,6],[6,5,7],
[3,7,5],
],
}); }
function main() {
//return pillar().translate([-2,-2,0]).scale(10);
return union(top(), bottom(), pillar()).translate([-2,-2,0]).scale(10);
}
Display the source blob
Display the rendered blob
Raw
solid csg.js
facet normal 0 0 1
outer loop
vertex 10 -10 40
vertex 10 10 40
vertex -10 10 40
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 10 -10 40
vertex -10 10 40
vertex -20 10 40
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 10 -10 40
vertex -20 10 40
vertex -20 -10 40
endloop
endfacet
facet normal 0 0 1
outer loop
vertex -10 10 40
vertex -20 20 40
vertex -20 10 40
endloop
endfacet
facet normal 0.7071067811865476 0.7071067811865476 0
outer loop
vertex -10 10 40
vertex -10 10 30
vertex -20 20 40
endloop
endfacet
facet normal 0 0.7071067811865474 -0.7071067811865476
outer loop
vertex -10 10 30
vertex -20 10 30
vertex -20 20 40
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 10 10 40
vertex 10 10 30
vertex -10 10 30
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 10 10 40
vertex -10 10 30
vertex -10 10 40
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 10 10 30
vertex 10 10 40
vertex 10 -10 40
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 10 10 30
vertex 10 -10 40
vertex 10 -10 30
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 10 -10 10
vertex 0 -10 20
vertex -10 -10 20
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 10 -10 10
vertex -10 -10 20
vertex -10 -10 10
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 0 -10 20
vertex 10 -10 30
vertex -10 -10 30
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex 0 -10 20
vertex -10 -10 30
vertex -10 -10 20
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex -10 -10 30
vertex 10 -10 30
vertex 10 -10 40
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex -10 -10 30
vertex 10 -10 40
vertex -20 -10 40
endloop
endfacet
facet normal 0 -1 0
outer loop
vertex -10 -10 30
vertex -20 -10 40
vertex -20 -10 30
endloop
endfacet
facet normal -1 0 0
outer loop
vertex -20 10 40
vertex -20 20 40
vertex -20 10 30
endloop
endfacet
facet normal -1 0 0
outer loop
vertex -20 10 40
vertex -20 10 30
vertex -20 -10 30
endloop
endfacet
facet normal -1 0 0
outer loop
vertex -20 10 40
vertex -20 -10 30
vertex -20 -10 40
endloop
endfacet
facet normal -1 0 0
outer loop
vertex -20 0 10
vertex -20 20 10
vertex -20 20 0
endloop
endfacet
facet normal -1 0 0
outer loop
vertex -20 0 10
vertex -20 20 0
vertex -20 -20 0
endloop
endfacet
facet normal -1 0 0
outer loop
vertex -20 0 10
vertex -20 -20 0
vertex -20 -10 10
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 10 20 10
vertex 20 20 0
vertex -20 20 0
endloop
endfacet
facet normal 0 1 0
outer loop
vertex 10 20 10
vertex -20 20 0
vertex -20 20 10
endloop
endfacet
facet normal 0.7071067811865475 0 0.7071067811865475
outer loop
vertex 20 20 0
vertex 10 20 10
vertex 10 0 10
endloop
endfacet
facet normal 0.7071067811865475 0 0.7071067811865475
outer loop
vertex 20 20 0
vertex 10 0 10
vertex 10 -10 10
endloop
endfacet
facet normal 0.7071067811865475 0 0.7071067811865475
outer loop
vertex 20 20 0
vertex 10 -10 10
vertex 20.000000000000007 -20 0
endloop
endfacet
facet normal 0 -0.7071067811865475 0.7071067811865475
outer loop
vertex 20.000000000000007 -20 0
vertex 10 -10 10
vertex -10 -10 10
endloop
endfacet
facet normal 0 -0.7071067811865475 0.7071067811865475
outer loop
vertex 20.000000000000007 -20 0
vertex -10 -10 10
vertex -20 -10 10
endloop
endfacet
facet normal 0 -0.7071067811865475 0.7071067811865475
outer loop
vertex 20.000000000000007 -20 0
vertex -20 -10 10
vertex -20 -20 0
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 20 20 0
vertex 20.000000000000007 -20 0
vertex -20 -20 0
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex 20 20 0
vertex -20 -20 0
vertex -20 20 0
endloop
endfacet
facet normal 0 0 1
outer loop
vertex -10 -10 10
vertex 0 0 10
vertex -20 0 10
endloop
endfacet
facet normal 0 0 1
outer loop
vertex -10 -10 10
vertex -20 0 10
vertex -20 -10 10
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 10 0 10
vertex 0 0 10
vertex 10 -10 10
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 0 0 10
vertex 10 0 10
vertex 10 20 10
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 0 0 10
vertex 10 20 10
vertex -20 20 10
endloop
endfacet
facet normal 0 0 1
outer loop
vertex 0 0 10
vertex -20 20 10
vertex -20 0 10
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex -10 10 30
vertex 10 10 30
vertex 4.440892098500626e-15 4.440892098500626e-15 30
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex -10 10 30
vertex 4.440892098500626e-15 4.440892098500626e-15 30
vertex -10 -10 30
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex -10 10 30
vertex -10 -10 30
vertex -20 -10 30
endloop
endfacet
facet normal 0 0 -1
outer loop
vertex -10 10 30
vertex -20 -10 30
vertex -20 10 30
endloop
endfacet
facet normal -0.7071067811865476 0.7071067811865476 0
outer loop
vertex -10 -10 20
vertex -10 -10 30
vertex 4.440892098500626e-15 4.440892098500626e-15 30
endloop
endfacet
facet normal -0.7071067811865476 0.7071067811865476 0
outer loop
vertex -10 -10 20
vertex 4.440892098500626e-15 4.440892098500626e-15 30
vertex 4.440892098500626e-15 4.440892098500626e-15 20
endloop
endfacet
facet normal -0.7071067811865476 0.7071067811865476 0
outer loop
vertex -10 -10 20
vertex 4.440892098500626e-15 4.440892098500626e-15 20
vertex 0 0 10
endloop
endfacet
facet normal -0.7071067811865476 0.7071067811865476 0
outer loop
vertex -10 -10 20
vertex 0 0 10
vertex -10 -10 10
endloop
endfacet
facet normal -0.7071067811865476 0.7071067811865476 0
outer loop
vertex 4.440892098500626e-15 4.440892098500626e-15 30
vertex 10 10 30
vertex 4.440892098500626e-15 4.440892098500626e-15 20
endloop
endfacet
facet normal 0.7071067811865476 0 -0.7071067811865474
outer loop
vertex 4.440892098500626e-15 4.440892098500626e-15 20
vertex 10 10 30
vertex 10 -10 30
endloop
endfacet
facet normal 0.7071067811865476 0 -0.7071067811865474
outer loop
vertex 4.440892098500626e-15 4.440892098500626e-15 20
vertex 10 -10 30
vertex 0 -10 20
endloop
endfacet
facet normal 1 0 0
outer loop
vertex 0 -10 20
vertex 0 0 10
vertex 4.440892098500626e-15 4.440892098500626e-15 20
endloop
endfacet
facet normal 0.5773502691896257 0.5773502691896256 0.5773502691896258
outer loop
vertex 10 -10 10
vertex 0 0 10
vertex 0 -10 20
endloop
endfacet
endsolid csg.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment