forked from kaansoral/3DKeyboardBuilder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
142 lines (136 loc) · 4.78 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<title>3D Keyboard Builder [Boilerplate] [Prototype]</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta property="og:title" content="3D Keyboard Builder [Boilerplate] [Prototype]" />
<meta property="og:url" content="https://kaansoral.github.io/3DKeyboardBuilder/" />
<meta property="og:image" content="https://kaansoral.github.io/3DKeyboardBuilder/logo.jpg" />
<script src="js/lib/three.min.js"></script>
<script src="js/lib/orbitcontrols.js"></script>
<!-- fallback if no WebGL -->
<script src="js/lib/projector.js"></script>
<script src="js/lib/canvasrenderer.js"></script>
<script src="js/lib/jquery-2.1.3.min.js"></script>
<script src="js/cad/csg.js"></script>
<script src="js/cad/threecsg.js"></script>
<script src="js/cad/openjscad.js"></script>
<script src="js/cad/formats.js"></script>
<script src="js/functions.js"></script>
<link rel="stylesheet" href="css/main.css" type="text/css">
<script>
var gProcessor=null;
OpenJsCad.AlertUserOfUncaughtExceptions();
function onload()
{
gProcessor = new OpenJsCad.Processor(document.getElementById("viewer"));
updateSolid();
}
function updateSolid()
{
// console.log(document.getElementById('code').value);
gProcessor.setJsCad(document.getElementById('code').value);
}
</script>
</head>
<body onload="onload()">
<b>3D Keyboard Builder [Boilerplate] [Prototype]</b>
<div style='float:right; color:#3B8DF1'>
<a href="https://github.com/kaansoral/3DKeyboardBuilder" class="cancela"><b>More Info on GitHub!</b></a>
</div>
<div id="viewer"></div>
<textarea id="code">//Paste your http://www.keyboard-layout-editor.com/ "Raw Data" below inside an Array i.e. []
//If it's not a 60% keyboard, manually change the width/height values below
var data=[
[{c:"#1c1c1a",t:"#d9d9d9",a:6},"Esc",{c:"#525249",a:4,f:4},"!\n1","@\n2","#\n3","$\n4","%\n5","^\n6","&\n7","*\n8","(\n9",")\n0","_\n-","+\n=",{c:"#1c1c1a",a:7,f:3,w:2},"← Backspace"],
[{a:4,w:1.5},"⇤\n⇥\n\n\n\n\nTab",{c:"#525249",f:5},"Q","W","E","R","T","Y","U","I","O","P",{f:4},"{\n[","}\n]",{w:1.5},"|\n\\"],
[{c:"#1c1c1a",t:"#f7f7f7",a:5,f:3,w:1.25,w2:1.75,l:true},"\n■\n\n\n■",{x:0.5,c:"#525249",t:"#d9d9d9",a:4,f:5},"A","S","D",{n:true},"F","G","H",{n:true},"J","K","L",{f:4},":\n;","\"\n'",{c:"#1c1c1a",a:6,f:3,w:2.25},"⏎ Enter"],
[{w:2.25},"⇧ Shift",{c:"#525249",a:4,f:5},"Z","X","C","V","B","N","M",{f:4},"<\n,",">\n.","?\n/",{x:0.375,c:"#ba2b70",f:6},"↑",{x:0.375,c:"#c9b50e",a:6,f:3},"Fn"],
[{x:1,c:"#309ba1",w:1.25},"Alt",{x:0.25,c:"#8f8d8d",a:7,w:1.25},"",{c:"#525249",w:6.25},"",{c:"#8f8d8d",w:1.25},"",{x:0.3,c:"#ba2b70",a:4,f:6},"←",{x:0.075},"↓",{x:0.075},"→"]
];
var kerf=0.1;
var width=285;
var height=95;
function main() {
var result=CSG.cube({
center: [0, 0, 0],
radius: [width/2,height/2,5/2]
});
var line=0;
data.forEach(function(line_def){
var w=1,dx=14,cx=0,h=1;
line_def.forEach(function(current){
if(is_object(current))
{
if(current.x) cx+=current.x*19;
if(current.w) w=current.w;
if(current.h) error=horizontal_switches_arent_handled_yet;
}
else
{
var x=-(width/2-1)+cx+(w-1)*19/2+9;
var y=-(height/2-1)+line*19+8.5;
result=result.subtract(cherry_mx().translate([x,y,0]));
if(w>=2 && w<5) result=result.subtract(costar(2).translate([x,y,0]));
else if(w>=5) result=result.subtract(costar(6.25).translate([x,y,0]));
cx+=dx+5+(w-1)*19;
w=1;
x=14;
}
});
line++;
});
result=result.setColor([0.8, 0.8, 0.8]);
return result;
}
function costar(size)
{
var xd=11.95; // 2u
if(size==3) xd=19.05;
else if(size==4) xd=28.575;
else if(size==4.5) xd=34.671;
else if(size==5.5) xd=42.8625;
else if(size==6.25) xd=50;
else if(size==6.5) xd=52.38;
else if(size==7) xd=57.15;
// -10.3 -13.6
// -6.45 7.75
var result=CSG.cube({
center: [xd, 1.3/2, 0],
radius: [1.65+kerf,14.20/2+kerf,5/2]
});
result=result.union(CSG.cube({
center: [xd, 1.3/2, 1],
radius: [1.65+0.8+kerf,14.20/2+0.8+kerf,2]
}));
result=result.union(CSG.cube({
center: [-xd, 1.3/2, 0],
radius: [1.65+kerf,14.20/2+kerf,5/2]
}));
result=result.union(CSG.cube({
center: [-xd, 1.3/2, 1],
radius: [1.65+0.8+kerf,14.20/2+0.8+kerf,2]
}));
return result;
}
function cherry_mx()
{
var result=CSG.cube({
center: [0, 0, 0],
radius: [7+kerf,7+kerf,5/2]
});
result=result.union(CSG.cube({
center: [0, 7, 1.5/2],
radius: [3.2+kerf,2+kerf,2/2]
}));
result=result.union(CSG.cube({
center: [0,-7, 1.5/2],
radius: [3.2+kerf,2+kerf,2/2]
}));
return result;
}
// Known bugs: If radius includes a 0, it causes the rendering to halt indefinitely [08/10/18]</textarea>
<button style="display: inline; float:right" onclick="updateSolid()" >Update Rendering</button>
<div style='margin-bottom:20px'></div>
</body>
</html>