-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfiguraConMallaT.html
824 lines (680 loc) · 23 KB
/
figuraConMallaT.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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
<style>
#bob_containerDiv{display:inline-block;
}
</style>
<head>
<script src="js/three.js"></script>
<script type="text/javascript" src="js/poly2tri.js"></script>
<!--script src="/scripts/conc/Detector.js"></script-->
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #f0f0f0;
margin: 0px;
overflow: hidden;
}
</style>
<body>
<script>
var cantidadTachuela = 0;
var puntoInicial = null;
var puntoFinal = null;
var puntos_figura = [];
var puntos_remuestreados =[];
var listaLineasFigura=[];
var listaTriangulosFigura=[];
var listaTriangulos =[];
var puntos_malla=[];
var list_lineas=[];
var lista_tachuelas = [];
var pressed = false;
var container;
var camera, scene, projector, renderer;
var particleMaterial;
var isRotating=false;
var nuevo=false;
var mover=false;
var tachuela = false;
var first_pos ;
var last_pos;
function get3dPointZAxis(event)
{
var vector = new THREE.Vector3(
( event.clientX / window.innerWidth ) * 2 - 1,
- ( event.clientY / window.innerHeight ) * 2 + 1,
0.5 );
vector.unproject(camera );
var dir = vector.sub( camera.position ).normalize();
var dist = - camera.position.z / dir.z;
var pos = camera.position.clone().add( dir.multiplyScalar( dist ) );
return pos;
}
function startDraw(event)
{
p = get3dPointZAxis(event);
var pos=new THREE.Vector3(p.x,p.y+70,0);
if (nuevo){
puntos_figura.length = 1;
puntos_figura[0] = new THREE.Vector3(pos.x, pos.y, 0);
first_pos = puntos_figura[0];
nuevo=false;
pressed=true;
}
if(tachuela && cantidadTachuela<1){
cantidadTachuela ++;
console.log("ingresando tachuela");
agregarTachuela(pos.x, pos.y);
//lista_tachuelas.push(punto);
tachuela = false
pressed = false
}
if(mover){
var tachue=lista_tachuelas[0];
var x= tachue.position.x;
var y= tachue.position.y;
if (pos.x<= (x+10) && pos.x>=(x-10) && pos.y<= (y+10) && pos.y>= (y-10)){
pressed=true;
}
}
}
function stopDraw(event)
{
punto = get3dPointZAxis(event);
if (pressed)
{
pressed=false;
//tachuela=true;
if(!nuevo && !mover){
last_pos= new THREE.Vector3(punto.x, punto.y+70, 0);
puntos_figura.push(last_pos);
//console.info(puntos_figura[puntos_figura.length-1]);
console.info(last_pos,"tamaño", puntos_figura.length );
roundline();
resample(80);
initState();
render();
encontrarCentroide();
//encontrarLineas();
encontrarTriangulos();
repaint();
//mover=true;
}
}
}
function doDraw(event)
{
if (pressed)
{
var p = get3dPointZAxis(event);
var pos=new THREE.Vector3(p.x,p.y+70,0);
var diferenciax, diferenciay;
console.info(pos);
if (!nuevo && mover){
moverFigura(pos);
}else{
puntos_figura.push(new THREE.Vector3(pos.x, pos.y, 0));
dibujarLinea(puntos_figura.length - 2, puntos_figura.length - 1);
}
}
}
function deformarTriangulo(v0,v1,v2,x ,y ){
var v0D, v1D, v2D;
var v0v1=[v1.x-v0.x , v1.y-v0.y];
var y0Rv0v1=[y*v0v1[1],y*(-v0v1[0])];
var x0v0v1=[x*v0v1[0],x*v0v1[1]];
v2D=[v0.x+x0v0v1[0]+y0Rv0v1[0], v0.y+x0v0v1[1]+y0Rv0v1[1]];
var v1v2=[v2.x-v1.x , v2.y-v1.y];
var y0Rv1v2=[y*v1v2[1],y*(-v1v2[0])];
var x0v1v2=[x*v1v2[0],x*v1v2[1]];
v0D=[v1.x+x0v1v2[0]+y0Rv1v2[0], v1.y+x0v1v2[1]+y0Rv1v2[1]];
var v0v2=[v2.x-v0.x , v2.y-v0.y];
var y0Rv0v2=[y*v0v2[1],y*(-v0v2[0])];
var x0v0v2=[x*v0v2[0],x*v0v2[1]];
v1D=[v0.x+x0v0v2[0]+y0Rv0v2[0], v0.y+x0v0v2[1]+y0Rv0v2[1]];
}
function moverFigura2D(x,y){
var i=0;
var nuevax, nuevay;
nuevax = x-lista_tachuelas[0].position.x;
nuevay = y-lista_tachuelas[0].position.y;
while(i < listaTriangulosFigura.length){
//var line=listaLineasFigura[i];
var line=listaTriangulosFigura[i];
//console.info(line, line.position.x , line.position.y);
p1=line.position.x;
p2=line.position.y;
//line.position.set(p1 + nuevax, p2 + nuevay, 0.0);
line.position.x = line.position.x + nuevax;
line.position.y = line.position.y + nuevay;
line.geometry.verticesNeedUpdate = true;
i=i+1;
}
}
function moverFigura(pos){
console.log("entro a mover figura vacia");
moverFigura2D(pos.x,pos.y);
//lista_tachuelas[0].x = pos.x;
lista_tachuelas[0].position.set(pos.x, pos.y, 0);
render();
}
function agregarTachuela(x, y){
i=0;
var p=new THREE.Vector3(x,y,0);
var distancia = 10000000000;
var d=0;
var punto
while(i < puntos_malla.length){
pos=puntos_malla[i];
d =pos.distanceTo(p) ;//distance(pos,p) ;
if(d < distancia){
distancia= d;
punto= pos;
}
i=i+1;
}
var sphere = new THREE.Mesh(
new THREE.SphereGeometry(7, 10, 10),
new THREE.MeshPhongMaterial({color: 0x000000})
);
sphere.position.set(punto.x, punto.y, 0);
lista_tachuelas.push(sphere);
scene.add(sphere);
render();
}
function repaint(){
console.log("entro al repaint")
var i=0;
//debugger;
console.info(listaTriangulosFigura.length);
while(i<listaTriangulosFigura.length){
var l=listaTriangulosFigura[i];
scene.add(l);
render();
i=i+1;
}
var i=0;
//debugger;
console.info(listaLineasFigura.length);
while(i<listaLineasFigura.length){
var l=listaLineasFigura[i];
scene.add(l);
render();
i=i+1;
}
console.log(" dibujo malla");
}
function encontrarTriangulos(){
var Material=new THREE.PointsMaterial({color:0XFF0000});
var material = new THREE.MeshBasicMaterial({color: 0xff0000, wireframe: true });
var i=0;
while(i<listaTriangulos.length){
l=listaTriangulos[i];
p1=l[0];
p2=l[1];
p3=l[2];
//redibujar(p1.X,p1.Y,p2.X,p2.Y);
var geometry = new THREE.Geometry();
geometry.vertices.push(p1);
geometry.vertices.push(p2);
geometry.vertices.push(p3);
geometry.faces.push(new THREE.Face3(0, 1, 2));
var triangulo = new THREE.Mesh(geometry, material);
listaTriangulosFigura.push(triangulo);
i=i+1;
}
for(var i=0 ; i<puntos_remuestreados.length-1 ; i++){
var geometry = new THREE.Geometry();
geometry.vertices.push(puntos_remuestreados[i]);
geometry.vertices.push(puntos_remuestreados[i+1]);
var linea = new THREE.Line(geometry,Material);
listaLineasFigura.push(linea);
}
var geometry1 = new THREE.Geometry();
geometry1.vertices.push(puntos_remuestreados[puntos_remuestreados.length-1]);
geometry1.vertices.push(puntos_remuestreados[0]);
var l1 = new THREE.Line(geometry1,Material);
listaLineasFigura.push(l1);
}
function encontrarLineas(){
var Material=new THREE.PointsMaterial({color:0XFF0000});
//Agrego la linea de la figura a la lista de lineas
for(var i=0 ; i<puntos_remuestreados.length-1 ; i++){
var geometry = new THREE.Geometry();
geometry.vertices.push(puntos_remuestreados[i]);
geometry.vertices.push(puntos_remuestreados[i+1]);
var linea = new THREE.Line(geometry,Material);
listaLineasFigura.push(linea);
}
//Agrego la linea de punto inicial a punto final a la lista de lineas
var geometry1 = new THREE.Geometry();
geometry1.vertices.push(puntos_remuestreados[puntos_remuestreados.length-1]);
geometry1.vertices.push(puntos_remuestreados[0]);
var l1 = new THREE.Line(geometry1,Material);
listaLineasFigura.push(l1);
//Agrego las lineas de la malla a la lista de lineas
var i=0;
console.info(list_lineas.length,puntos_remuestreados.length-1);
while(i<list_lineas.length){
l=list_lineas[i];
p1=l[0];
p2=l[1];
//redibujar(p1.X,p1.Y,p2.X,p2.Y);
var geometry = new THREE.Geometry();
geometry.vertices.push(p1);
geometry.vertices.push(p2);
var linea = new THREE.Line(geometry,Material);
listaLineasFigura.push(linea);
i=i+1;
}
console.log(listaLineasFigura);
}
function encontrarCentroide(){
var i =0 ;
var x =0;
var y =0;
var tam = puntos_remuestreados.length;
while( i< tam){
x = x + puntos_remuestreados[i].x;
y = y + puntos_remuestreados[i].y;
i=i+1;
//console.info(tam,x,y);
}
posx = parseInt(x/tam);
posy = parseInt(y/tam);
console.info("encontro centroide:",posx,posy);
malla(posx,posy);
console.info("salio de malla");
//console.log(listaTriangulos) , listaTriangulos.length;
}
function estaEnLista(Lista , posx, posy){
i=0;
while(i < Lista.length){
pos=Lista[i];
if (pos.x == posx && pos.y==posy){
return true;
}
i=i+1;
}
return false;
}
/**
* Funcion que determina si un punto(X,Y) se encuentra dentro de un poligono
*/
function insidePolygon( pointList , p )
{
var counter = 0;
var i;
var xinters;
var p1 ;
var p2;
var n = pointList.length;
p1 = pointList[0];
for (i = 1; i <= n; i++)
{
p2 = pointList[i % n];
if (p.y > Math.min(p1.y, p2.y))
{
if (p.y <= Math.max(p1.y, p2.y))
{
if (p.x <= Math.max(p1.x, p2.x))
{
if (p1.y != p2.y) {
xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x;
if (p1.x == p2.x || p.x <= xinters)
counter++;
}
}
}
}
p1 = p2;
}
if (counter % 2 == 0)
{
return(false);
}
else
{
return(true);
}
}
function malla(posx,posy){
//console.info("entro para crear malla");
var Puntos = [];
//[(-15,-26),(-30,0),(-15,26),(15,26),(30,0),(15,-26)]
Puntos.push(new THREE.Vector3(-10,-17,0));
Puntos.push(new THREE.Vector3(-20,0,0));
Puntos.push(new THREE.Vector3(-10,17,0));
Puntos.push(new THREE.Vector3(10,17,0));
Puntos.push(new THREE.Vector3(20,0,0));
Puntos.push(new THREE.Vector3(10,-17,0));
var nuevoPuntos = [];
//console.info(Puntos.length);
for(var i=0 ; i< Puntos.length ; i++){
nuevoPuntos.push(new THREE.Vector3(posx+Puntos[i].x,posy+Puntos[i].y,0)) ;
//console.info(Puntos[i][0],Puntos[i][1]);
}
//debugger;
//console.info("se lleno la lista de puntos");
//console.info(nuevoPuntos);
while(nuevoPuntos.length != 0){
var pos= nuevoPuntos.pop();
if (!estaEnLista(puntos_malla,pos.x,pos.y) && insidePolygon(puntos_remuestreados, pos)){
var indice=0;
puntos_malla.push(pos);
while(indice < Puntos.length-1){
var valor=Puntos[indice];
var valor2=Puntos[indice+1];
var v1,v2,v3;
v1 = pos ;
p=new THREE.Vector3(pos.x+valor.x,pos.y+valor.y,0);
p2=new THREE.Vector3(pos.x+valor2.x,pos.y+valor2.y,0);
if( insidePolygon(puntos_remuestreados, p)){
v2=p;
nuevoPuntos.push(p);
}else{
var pm1=new THREE.Vector3((v1.x+p.x)/2,(v1.y+p.y)/2,0);
var dis=1000000000000000;
for(var i=0; i<puntos_remuestreados.length-1; i++){
punt0=puntos_remuestreados[i];
punt1=puntos_remuestreados[i+1];
var pm2=new THREE.Vector3((punt0.x+punt1.x)/2 , (punt0.y+punt1.y)/2,0);
d=pm1.distanceTo(pm2);
if(d<dis){
dis=d;
v2=pm2;
}
}
}
if( insidePolygon(puntos_remuestreados, p2)){
var v3 = p2;
}else{
var pm=new THREE.Vector3((v1.x+p2.x)/2,(v1.y+p2.y)/2,0);
var dis=1000000000000000;
for(var i=0; i<puntos_remuestreados.length-1; i++){
punt0=puntos_remuestreados[i];
punt1=puntos_remuestreados[i+1];
var pm3=new THREE.Vector3((punt0.x+punt1.x)/2 , (punt0.y+punt1.y)/2,0);
d=pm.distanceTo(pm3);
if(d<dis){
dis=d;
v3=pm3;
}
}
}
t=[v1 ,v2 ,v3];
if (!existeTriangulo(t)){
listaTriangulos.push(t);
}
/*else{
i=0;
var distancia = 10000000000;
var d=0;
var punto
while(i < puntos_remuestreados.length){
pos1=puntos_remuestreados[i];
d =pos1.distanceTo( pos );
if(d < distancia){
distancia= d;
punto= pos1;
}
i=i+1;
}
var v1 = pos ;
var v2 = punto;
t1=[v1 ,v2];
if (!existeLinea(v1 ,v2)){
list_lineas.push(t1);
}
}*/
/*else{
i=0;
var distancia = 10000000000;
var d=0;
var punto2
while(i < puntos_remuestreados.length){
pos1=puntos_remuestreados[i];
d =pos1.distanceTo( pos );
if(d < distancia){
distancia= d;
punto2= pos1;
}
i=i+1;
}
var v1 = pos ;
var v2 = punto2;
t1=[v1 ,v2];
if (!existeLinea(v1 ,v2)){
list_lineas.push(t1);
}
}*/
indice=indice+1
}
}
}
}
function existeLinea(v1, v2){
var x1 = v1.x;
var y1 = v1.y;
var x2 = v2.x;
var y2 = v2.y;
i=0;
while(i<list_lineas.length){
l=list_lineas[i];
p1=l[0];
p2=l[1];
//console.log(l," los componentes son :" , p1, p2);
if ((x1 == p1.x && y1 == p1.y && x2 == p2.x && y2 == p2.y) || (x2 == p1.x && y2 == p1.y && x1 == p2.x && y1 == p2.y)){
return true;
}
i=i+1;
}
return false;
}
function existeTriangulo(t){
var v1=t[0];
var v2=t[1];
var v3=t[2];
var x1 = v1.x;
var y1 = v1.y;
var x2 = v2.x;
var y2 = v2.y;
var x3 = v3.x;
var y3 = v3.y;
i=0;
while(i<listaTriangulos.length){
t=listaTriangulos[i];
p1=t[0];
p2=t[1];
p3=t[2];
//console.log(l," los componentes son :" , p1, p2);
if ( (x1 == p1.x && y1 == p1.y && x2 == p2.x && y2 == p2.y && x3 == p3.x && y3 == p3.y)
|| (x2 == p1.x && y2 == p1.y && x1 == p2.x && y1 == p2.y && x3 == p3.x && y3 == p3.y)
|| (x3 == p1.x && y3 == p1.y && x1 == p2.x && y1 == p2.y && x2 == p3.x && y2 == p3.y)
|| (x2 == p1.x && y2 == p1.y && x3 == p2.x && y3 == p2.y && x1 == p3.x && y1 == p3.y)
|| (x3 == p1.x && y3 == p1.y && x2 == p2.x && y2 == p2.y && x1 == p3.x && y1 == p3.y)
|| (x1 == p1.x && y1 == p1.y && x3 == p2.x && y3 == p2.y && x2 == p3.x && y2 == p3.y)){
return true;
}
i=i+1;
}
return false;
}
function dibujarLinea(i1, i2)
{
var v1 = puntos_figura[i1];
var v2 = puntos_figura[i2];
var Material=new THREE.PointsMaterial({color:0XFF0000});
var geometry = new THREE.Geometry();
geometry.vertices.push(v1);
geometry.vertices.push(v2);
var line = new THREE.Line(geometry,Material);
//list_lineas.push(line);
scene.add(line);
render();
}
function roundline(){
console.info("ingreso en roundline");
//debugger;
var tam = puntos_figura.length-1;
var start=[puntos_figura[tam].x , puntos_figura[tam].y];
//console.info(start);
var end = [puntos_figura[0].x , puntos_figura[0].y];
console.info(start, end);
var dx = parseInt(end[0])- parseInt(start[0]);
var dy = parseInt(end[1])-parseInt(start[1]);
var distanc = Math.max(Math.abs(dx), Math.abs(dy));
console.info(distanc);
for(var i=0 ; i<distanc ; i=i+3){
var x = parseInt( start[0]+parseFloat(i)/distanc*dx);
var y = parseInt( start[1]+parseFloat(i)/distanc*dy);
puntos_figura.push(new THREE.Vector3(x, y, 0));
last_pos= new THREE.Vector3(x, y, 0);
console.info(last_pos, puntos_figura.length - 2,puntos_figura.length - 1 );
//dibujarLinea(puntos_figura.length - 2, puntos_figura.length - 1);
}
}
function distance(p1, p2){
return parseFloat(Math.sqrt(Math.pow((p2.x - p1.y),2) + Math.pow((p2.y - p1.y),2)));
}
function pathlength(points){
var d=0;
for(var i=0 ; i< points.length-1; i++){
var p = points[i];
var p2 = points[i+1];
d = d + p.distanceTo( p2 );
}
return d;
}
//funcion para remuestrear el numero de puntos
function resample(n){
var pathle= pathlength(puntos_figura);
console.info(pathle);
var I = pathle/ parseFloat(n-1);
console.info(pathle,puntos_figura.length );
var D = 0;
var i = 1
while( i< puntos_figura.length){
if (i==1){
puntos_remuestreados.push(new THREE.Vector3(parseInt(puntos_figura[0].x),parseInt(puntos_figura[0].y),0));
}
p1 = puntos_figura[i];
p2 = puntos_figura[i-1];
d = p2.distanceTo( p1 );
if( (D + d) >= I && d !=0){
qx = p2.x + ((I-D) / d) * (p1.x - p2.x);
qy = p2.y + ((I-D) / d) * (p1.y - p2.y);
puntos_remuestreados.push(new THREE.Vector3(parseInt(qx), parseInt(qy),0)); //qx.toFixed(2),qy.toFixed(2)));
//puntos_remuestreados.push(new THREE.Vector2(qx.toFixed(2),qy.toFixed(2)));
D = 0
}else{
D = D + d;
}
i+=1;
}
console.info(puntos_remuestreados);
}
init();
animate();
function initState(){
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
//camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 1, 1000 );
camera.position.set( 500, 500, 500 );
scene = new THREE.Scene();
}
function doNew(){
console.info("entro a doNew");
puntos_figura.splice(0,puntos_figura.length);
puntos_remuestreados.splice(0,puntos_remuestreados.length);
listaLineasFigura.splice(0,listaLineasFigura.length);
puntos_malla.splice(0,puntos_malla.length);
list_lineas.splice(0,list_lineas.length);
lista_tachuelas.splice(0,lista_tachuelas.length);
listaTriangulosFigura.splice(0,listaTriangulosFigura.length);
listaTriangulos.splice(0,listaTriangulos.length);
console.info(puntos_malla.length, puntos_remuestreados.length,puntos_malla.length,listaLineasFigura.length,list_lineas.length,lista_tachuelas.length);
cantidadTachuela=0;
nuevo = true;
mover=false;
tachuela = false;
pressed=false;
initState();
}
function putTach(){
tachuela = true;
mover = false;
nuevo = false;
pressed=false;
}
function moveTach(){
tachuela = false;
mover = true;
nuevo = false;
}
function init() {
var imgBnt1 = document.createElement('IMG')
imgBnt1.setAttribute('src','nuevoA.png')
var imgBnt2 = document.createElement('IMG')
imgBnt2.setAttribute('src','dibujarA.png')
var imgBnt3 = document.createElement('IMG')
imgBnt3.setAttribute('src','tachuelaA.png')
var imgBnt4 = document.createElement('IMG')
imgBnt4.setAttribute('src','moverA.png')
container = document.createElement( 'div' );
var container2 = document.createElement('div');
container2.setAttribute('style','margin-left: 40%;'); //style=" margin-left: 40%;
//var container2 = document.getElementById('container2');
var boton1 = document.createElement("BUTTON"); // Create a <button> element
//var boton2 = document.createElement("BUTTON");
var boton3 = document.createElement("BUTTON");
var boton4 = document.createElement("BUTTON");
boton1.appendChild(imgBnt1);
//boton1.setAttribute('onclick','doNew();')
boton1.onclick = function(){doNew();}
//boton2.appendChild(imgBnt2);
boton3.appendChild(imgBnt3);
boton3.onclick = function(){putTach();}
boton4.appendChild(imgBnt4);
boton4.onclick = function(){moveTach();}
container2.appendChild(boton1);
//container2.appendChild(boton2);
container2.appendChild(boton3);
container2.appendChild(boton4);
document.body.appendChild( container2 );
document.body.appendChild( container );
//projector = new THREE.Projector();
renderer = new THREE.WebGLRenderer( {antialias:true} );
/*if ( Detector.webgl )
renderer = new THREE.WebGLRenderer( {antialias:true} );
else
renderer = new THREE.CanvasRenderer();*/
renderer.setClearColor( 0xf0f0f0 );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
document.addEventListener( 'mousedown', startDraw, false );
document.addEventListener( 'mouseup', stopDraw, false );
document.addEventListener( 'mousemove', doDraw, false );
//
window.addEventListener( 'resize', onWindowResize, false );
initState();
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function animate() {
requestAnimationFrame( animate );
render();
}
var radius = 1000;
var theta = 90;
function render() {
renderer.render( scene, camera );
}
</script>
<!--
<div id="container2" style='display:block;position:absolute'>
</div>
-->
</body>