-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathicon3d.html
458 lines (396 loc) · 12.5 KB
/
icon3d.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<!--
EVERYTHING IS PHYSICAL
EVERYTHING IS FRACTAL
EVERYTHING IS RECURSIVE
NO MONEY
MO MINING
NO PROPERTY
LOOK AT THE INSECTS
LOOK AT THE FUNGI
LANGUAGE IS HOW THE MIND PARSES REALITY
-->
<!--Stop Google:-->
<META NAME="robots" CONTENT="noindex,nofollow">
<script src="jscode/geometron.js"></script>
<link href="data:image/x-icon;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAgAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAA/wAAAAD/AAAAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAiIAAAAAARAAIAAAAAABEAAgAAAAAAABACAAAAAAAAAQIAAAAAAwAAEgAAADAzMzMwMzMzMwMAAAIQAAAwAAAAAgEAAAAAAAACABAAAAAAAAIAAQAAAAAAAgAAEQAAAAACAAARAAAAACIgAAAAAAAAAgAAAAD+/wAA/H8AAM7/AADO/wAA9v8AAPr/AAC8/QAAAAAAAL59AAD+vwAA/t8AAP7vAAD+8wAA/vMAAPx/AAD+/wAA" rel="icon" type="image/x-icon" />
<script src="https://cdn.jsdelivr.net/npm/x3dom@1.7.2/x3dom.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/x3dom@1.7.2/x3dom.css">
</head>
<body>
<!--
geometron 3d for trash robot voxel programming
symbol.html:
this is a custom language, specific to this node in the Universe of Things. Hypercube BUILDS languages. This is apure implementation of
ONE language, with absolute minimum number of actions, cleaned up glyphs, large and simple buttons, just a few.
-->
<div id = "square">
<x3d id = "mainx3d">
<scene id = "main">
</scene>
</x3d>
</div>
<input id = "actioninput"/>
<input id = "spellinput"/>
<div id = "spellcanvasbox">
<canvas id = "spellcanvas"></canvas>
</div>
<div id = "feed">
</div>
<textarea id = "textio"></textarea>
<table id = "linktable">
<tr>
<td><a href= "three.html">three.html</a></td>
<td><a href= "threejs.html">threejs.html</a></td>
<td><a href = "threejsinvert.html">threejsinvert.html</a></td>
<td><a href= "index.html">index.html</a></td>
<td><a href= "voxel.html">voxel.html</a></td>
</tr>
</table>
<div id = "savebutton" class = "button">SAVE</div>
<script>
feedwidth = 100;
feedlinkwidth = feedwidth;
mainsize = 0.5*innerWidth - 10;
if(innerWidth > innerHeight){
marginWidth = innerWidth - innerHeight;
document.getElementById("square").style.width = innerHeight.toString() + "px";
document.getElementById("square").style.height = innerHeight.toString() + "px";
document.getElementById("feed").style.left = innerHeight.toString() + "px";
}
else{
document.getElementById("square").style.width = innerWidth.toString() + "px";
document.getElementById("square").style.height = innerWidth.toString() + "px";
document.getElementById("feed").style.top = (innerWidth + 10).toString() + "px";
}
mainGVM = new GVM(document.getElementById("spellcanvas"),100,100);
mainGVM.x0 = 5;
mainGVM.y0 = 25;
mainGVM.unit = 20;
mainGVM.glyph = "0207,";
x = 0.0;
y = 0.0;
z = 0.0;
side = 0.25;
solidColor = "1 0 0";
currentTrans = 0.0;
main = document.getElementById("main");
var httpcHypercube = new XMLHttpRequest();
httpcHypercube.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200) {
hypercube = JSON.parse(this.responseText);
mainGVM.importbytecode(hypercube);
var httpcFeed = new XMLHttpRequest();
httpcFeed.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200) {
robotfeed = JSON.parse(this.responseText);
loadfeed();
}
};
httpcFeed.open("GET", "fileloader.php?filename=data/robotfeed.txt", true);
httpcFeed.send();
}
};
httpcHypercube.open("GET", "fileloader.php?filename=data/hypercube.txt", true);
httpcHypercube.send();
function redraw(){
main.innerHTML = "";
x = 0.0;
y = 0.0;
z = 0.0;
side = 0.25;
solidColor = "1 0 0";
currentTrans = 0.0;
drawGlyph(mainGVM.glyph);
mainGVM.spellGlyph(mainGVM.glyph);
}
function drawGlyph(localString){
var tempArray = localString.split(',');
for(var index = 0;index < tempArray.length;index++){
action(parseInt(tempArray[index],8));
}
}
editmode = true;
function action(localCommand){
if(localCommand >= 0500 && localCommand < 0700){
drawGlyph(mainGVM.hypercube[localCommand]);
}
if(localCommand > 01000){
drawGlyph(mainGVM.hypercube[localCommand]);
}
if(localCommand >= 0220 && localCommand < 0300){
drawGlyph(mainGVM.hypercube[localCommand]);
}
if(localCommand == 0207){
if(editmode){
drawcursor();
}
}
if(localCommand == 0700){
x += side;
}
if(localCommand == 0701){
x -= side;
}
if(localCommand == 0702){
y += side;
}
if(localCommand == 0703){
y -= side;
}
if(localCommand == 0704){
z += side;
}
if(localCommand == 0705){
z -= side;
}
if(localCommand == 0706){
side /= 2;
}
if(localCommand == 0707){
side *= 2;
}
if(localCommand == 0710){
drawsphere();
}
if(localCommand == 0711){
drawcube();
}
if(localCommand == 0720){
//red
solidColor = "1 0 0";
}
if(localCommand == 0721){
//orange
solidColor = "1 0.5 0";
}
if(localCommand == 0722){
solidColor = "1 1 0";
//yellow
}
if(localCommand == 0723){
//green
solidColor = "0 1 0";
}
if(localCommand == 0724){
//blue
solidColor = "0 0 1";
}
if(localCommand == 0725){
//purple
solidColor = "1 0 1";
}
}
function drawsphere(){
var news = document.createElement("shape");
var newt = document.createElement("transform");
main.appendChild(newt);
newt.setAttribute("translation",x.toString() + " " + y.toString() + " " + z.toString() );
var newt2 = document.createElement("transform");
newt.appendChild(newt2);
newt2.setAttribute("scale",(side).toString() + " " + (side).toString() + " " + (side).toString());
newt2.appendChild(news);
var newa = document.createElement("appearance");
news.appendChild(newa);
var newm = document.createElement("material");
newm.setAttribute("diffuseColor",solidColor);
newm.setAttribute("transparency",currentTrans);
newa.appendChild(newm);
var newb = document.createElement("sphere");
news.appendChild(newb);
}
function drawcube(){
var news = document.createElement("shape");
var newt = document.createElement("transform");
main.appendChild(newt);
newt.setAttribute("translation",x.toString() + " " + y.toString() + " " + z.toString() );
var newt2 = document.createElement("transform");
newt.appendChild(newt2);
newt2.setAttribute("scale",(0.5*side).toString() + " " + (0.5*side).toString() + " " + (0.5*side).toString());
newt2.appendChild(news);
var newa = document.createElement("appearance");
news.appendChild(newa);
var newm = document.createElement("material");
newm.setAttribute("diffuseColor",solidColor);
newm.setAttribute("transparency",currentTrans);
newa.appendChild(newm);
var newb = document.createElement("box");
news.appendChild(newb);
}
function drawcursor(){
var news = document.createElement("shape");
var newt = document.createElement("transform");
main.appendChild(newt);
newt.setAttribute("translation",x.toString() + " " + y.toString() + " " + z.toString() );
var newt2 = document.createElement("transform");
newt.appendChild(newt2);
newt2.setAttribute("scale",(side).toString() + " " + (side).toString() + " " + (side).toString());
newt2.appendChild(news);
var newa = document.createElement("appearance");
news.appendChild(newa);
var newm = document.createElement("material");
newm.setAttribute("diffuseColor","0 0 1");
newm.setAttribute("transparency","0.85");
newa.appendChild(newm);
var newb = document.createElement("box");
news.appendChild(newb);
}
filetop = "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\"/><script src=\"https://cdn.jsdelivr.net/npm/x3dom@1.7.2/x3dom.js\">";
filetop += "<\/script><link rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/x3dom@1.7.2/x3dom.css\"></head><body><x3d style = \"position:absolute;left:0px;right:0px;top:0px;bottom:0px;z-index:-1;\">";
function save(){
mainGVM.clean();
editmode = false;
redraw();
x3dcode = main.innerHTML;
//this is an html file not an x3d file, because xml is the language of Mordor, which I shall not utter here
document.getElementById("textio").value = filetop + "<scene>" + x3dcode + "</scene></x3d>\n<a style = \"position:absolute;right:0px;bottom:0px;\" href = \"voxel.html\">back to voxel</a></body></html>";
var url = "filesaver.php";
var httpc = new XMLHttpRequest();
httpc.open("POST", url, true);
httpc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpc.send("data="+encodeURIComponent(filetop + "<scene>" + x3dcode + "</scene></x3d>" + "</scene></x3d>\n<a style = \"position:absolute;right:0px;bottom:0px;font-size:2em;\" href = \"voxel.html\">back to voxel</a>\n<a style = \"position:absolute;right:0px;bottom:3em;font-size:2em;\" href = \"icon3d.html\">back to icon3d</a></body></html>")+"&filename=three.html");//send text to filesaver.php
editmode = true;
redraw();
saveglyph();
}
document.getElementById("savebutton").onclick = function(){
save();
}
function loadfeed(){
gvmArray = [];
document.getElementById("feed").innerHTML = "";
for(var index = 0;index < robotfeed.length;index++){
var newdiv = document.createElement("span");
var newcan = document.createElement("CANVAS");
newcan.className = "feedcan";
newdiv.style.marginTop = 0.05*feedwidth + "px";
newdiv.style.marginBottom = 0.05*feedwidth + "px";
newdiv.appendChild(newcan);
newdiv.className = "feedelement";
newcan.classList.add("button");
document.getElementById("feed").appendChild(newdiv);
var newGVM = new GVM(newcan,feedlinkwidth,feedlinkwidth);
newGVM.hypercube = mainGVM.hypercube;
gvmArray.push(newGVM);
newGVM.drawGlyph(robotfeed[index]);
var datadiv = document.createElement("DIV");
datadiv.innerHTML = robotfeed[index];
datadiv.className = "data";
newdiv.appendChild(datadiv);
newdiv.onclick = function(){
glyph = "0600," + this.getElementsByClassName("data")[0].innerHTML;
mainGVM.glyph = glyph;
redraw();
//load glyph and print to examine prior to saving
document.getElementById("spellinput").value = glyph;
}
}
}
document.getElementById("spellinput").value = "";
function saveglyph(){
mainGVM.clean();
var url = "filesaver.php";
var httpc = new XMLHttpRequest();
httpc.open("POST", url, true);
httpc.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
httpc.send("data=" + mainGVM.cleanGlyph + "&filename=data/glyph3d.txt");//send text to filesaver.php
}
</script>
<style>
body{
overflow:hidden;
}
input{
font-family:courier;
}
#square{
position:absolute;
left:0px;
top:0px;
border:solid;
border-width:0.1px;
border-color:blue;
overflow:hidden;
width:500px;
height:500px;
}
#maincanvas{
border:solid;
}
#spellcanvas{
border:solid;
}
#actioninput{
position:absolute;
right:0px;
top:0px;
width:1em;
}
#spellinput{
position:absolute;
right:2em;
top:0px;
width:300px;
}
.button:hover{
background-color:green;
}
.button:active{
background-color:yellow;
}
.button{
cursor:pointer;
}
#mainx3d{
position:absolute;
left:0px;
top:0px;
right:0px;
bottom:0px;
background-color:grey;
}
#spellcanvasbox{
position:absolute;
right:0px;
top:60px;
width:300px;
height:300px;
display:none;
}
#textio{
position:absolute;
right:0px;
bottom:0px;
display:none;
z-index:-1;
}
#linktable{
position:absolute;
bottom:0px;
right:130px;
}
#savebutton{
position:absolute;
right:0px;
bottom:0px;
border:solid;
font-size:2em;
}
#feed{
border:solid;
border-width:3px;
position:absolute;
right:0px;
top:100px;
bottom:100px;
overflow:scroll;
}
.data{
display:none;
}
</style>
</body>
</html>