-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path4couls.jscad
20 lines (18 loc) · 4.33 KB
/
4couls.jscad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
volume = function () {
let faces =[[6,46,8],[7,9,6],[7,17,9],[8,46,18],[9,31,20],[9,45,6],[13,36,35],[16,33,32],[16,34,33],[16,35,34],[17,31,9],[18,32,8],[18,40,32],[20,44,9],[20,49,44],[29,40,30],[29,41,40],[29,55,41],[30,40,18],[33,37,32],[35,36,34],[35,60,13],[43,49,29],[44,49,43],[45,46,6],[49,55,29],[0,23,12],[0,50,23],[5,37,8],[6,51,7],[7,51,17],[8,32,5],[17,51,24],[23,53,12],[23,54,53],[24,51,6],[32,37,5],[50,54,23],[0,12,1],[0,26,21],[1,26,0],[3,56,4],[3,58,56],[4,55,3],[4,57,55],[12,38,1],[12,53,38],[19,54,39],[21,22,0],[22,50,0],[22,54,50],[25,28,27],[25,57,28],[28,59,27],[38,53,19],[39,54,22],[41,57,25],[53,54,19],[55,57,41],[2,47,11],[3,42,10],[3,55,42],[10,58,3],[11,52,2],[14,47,15],[15,47,2],[16,40,27],[17,52,31],[24,52,17],[27,35,16],[27,40,25],[27,59,35],[31,52,11],[32,40,16],[40,41,25],[42,55,49],[48,58,10],[48,61,58],[59,60,35],[1,44,26],[1,45,9],[2,36,15],[2,52,33],[8,24,6],[8,37,24],[9,44,1],[10,31,11],[10,42,31],[11,48,10],[14,15,13],[14,48,47],[14,61,48],[15,36,13],[18,39,30],[18,46,19],[19,39,18],[19,45,38],[19,46,45],[21,29,22],[21,43,29],[26,43,21],[26,44,43],[29,30,22],[30,39,22],[31,42,20],[33,34,2],[33,52,37],[34,36,2],[37,52,24],[38,45,1],[42,49,20],[47,48,11],[13,60,14],[28,57,56],[56,57,4],[56,58,28],[58,59,28],[58,61,59],[59,61,60],[60,61,14]],
vertices = [[2.18515314,-5.66906501,-10.77388586],[2.43210414,0.82779499,-10.30188186],[-0.29528786,6.25000799,5.47664414],[4.13009714,-3.01705901,0.69581914],[1.46449814,-11.05883601,1.48296114],[-4.20202986,11.74657899,-6.43274186],[1.76210314,9.44943799,-6.33619386],[3.19248914,8.52623199,-4.88176586],[-1.69497386,9.59488899,-6.39661086],[4.14186414,5.49562299,-7.26941186],[4.88347514,-1.36499801,3.64397014],[2.16482214,5.95683299,3.96508914],[1.84181014,-2.95060701,-14.17623386],[-1.25984886,-3.35124401,13.04639014],[1.10314414,-3.02590001,13.39368614],[0.047290145,-0.17638001,11.58252314],[-3.60132686,4.62640399,1.57291514],[2.73655714,8.41181199,-3.31748986],[-3.92215486,6.01013999,-7.92936786],[-1.59579286,4.76547699,-10.56344086],[3.58461014,3.87044599,-3.14977686],[0.38438314,-2.97141501,-7.31977486],[-1.80094486,-3.09396701,-8.84670486],[-0.79305486,-6.31723901,-12.98161186],[1.69175814,9.79957199,-4.17293186],[-4.07114686,-3.52512501,0.88831814],[2.43116114,-1.78938501,-8.77571186],[-4.94782986,-2.72556401,3.87805714],[-4.38850286,-9.47509201,4.26982414],[-0.33428886,-2.43236701,-4.60392386],[-3.66268086,-1.12694901,-5.73591086],[3.30817814,6.91763299,-2.09996286],[-3.30302786,7.95453699,-4.95989686],[-1.49345886,8.90576999,-0.33442386],[-1.91500986,6.27745099,3.90967314],[-4.33650886,-2.55702901,7.20820814],[-1.59560286,3.02654499,7.68190014],[-1.95584286,9.48761799,-3.58585986],[1.53664614,3.37955499,-10.80585686],[-2.56934586,0.95661999,-9.91045986],[-3.51885886,2.54441099,-2.16110486],[-1.57399686,-2.78087001,-1.74482786],[3.68439514,1.30763999,-1.31338186],[2.79857114,-2.18289301,-5.32179086],[3.74590714,0.27503999,-6.84499586],[2.92300714,5.71537799,-9.78312586],[0.37404214,8.71167199,-8.26816586],[1.25524414,2.44824599,8.69050614],[4.12591214,-1.94520301,7.06802914],[2.76914814,0.66925999,-2.95216986],[-1.19023086,-6.62480701,-10.39142486],[3.34262114,12.65198199,-7.36000086],[1.13191014,9.14929599,-0.64515886],[-0.0018628552,-3.30936801,-14.86011386],[-2.23563986,-3.10630801,-13.28313286],[0.50913914,-3.12659101,-2.25022586],[4.29845114,-9.14855201,4.07653214],[-1.47953986,-10.87022401,1.98925314],[5.45283414,-7.04318101,7.08779314],[-5.58808286,-7.64922001,7.05212814],[-3.81056786,-4.51207001,11.53466014],[3.77669014,-4.37932801,11.14128914]],
groups = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6],
faceCsg = faces.map(m => CSG.Polygon.createFromPoints(m.map(n => vertices[n]))),
csg = CSG.fromPolygons(faceCsg);
return {faces:faces, vertices:vertices, groups:groups, faceCsg:faceCsg, csg:csg};
};
function coloredVol(V, cols){
return [...new Set(V.groups)].map((x,index) => color(cols[index],
CSG.fromPolygons(V.faces.filter((el,index) => V.groups[index] == x)
.map(m => CSG.Polygon.createFromPoints(m.map(n => V.vertices[n]))))));
}
function main(){
V = volume();
cols = ["blue","maroon","violet", "green","yellow","beige"];
return coloredVol(V, cols);
}