-
Notifications
You must be signed in to change notification settings - Fork 140
/
index.html
executable file
·2058 lines (1901 loc) · 129 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
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
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Origami Simulator</title>
<meta name="viewport" content="width=400">
<meta property="og:title" content="Origami Simulator ">
<meta property="og:description" content=" Real-time WebGL origami simulator app">
<meta property="og:image" content="https://origamisimulator.org/assets/doc/strain.jpg">
<meta property="og:url" content="https://origamisimulator.org/">
<meta name="twitter:site" content="@amandaghassaei">
<meta name="twitter:creator" content="Amanda Ghassaei">
<meta name="twitter:title" content="Origami Simulator">
<meta name="twitter:description" content=" Real-time WebGL origami simulator app">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://origamisimulator.org/assets/doc/strain.jpg">
<link href="dependencies/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" type="text/css" href="dependencies/flat-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="dependencies/jquery-ui.min.css"/>
<link rel="stylesheet" type="text/css" href="css/nav.css"/>
<link rel="stylesheet" type="text/css" href="css/main.css"/>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-3S37V84BNX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-3S37V84BNX');
</script>
<script id="vertexShader" type="x-shader/x-vertex">
attribute vec2 a_position;
void main() {
gl_Position = vec4(a_position, 0, 1);
}
</script>
<script id="packToBytesShader" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_floatTextureDim;
uniform sampler2D u_floatTexture;
uniform float u_vectorLength;
float shift_right (float v, float amt) {
v = floor(v) + 0.5;
return floor(v / exp2(amt));
}
float shift_left (float v, float amt) {
return floor(v * exp2(amt) + 0.5);
}
float mask_last (float v, float bits) {
return mod(v, shift_left(1.0, bits));
}
float extract_bits (float num, float from, float to) {
from = floor(from + 0.5); to = floor(to + 0.5);
return mask_last(shift_right(num, from), to - from);
}
vec4 encode_float (float val) {
if (val == 0.0) return vec4(0, 0, 0, 0);
float sign = val > 0.0 ? 0.0 : 1.0;
val = abs(val);
float exponent = floor(log2(val));
float biased_exponent = exponent + 127.0;
float fraction = ((val / exp2(exponent)) - 1.0) * 8388608.0;
float t = biased_exponent / 2.0;
float last_bit_of_biased_exponent = fract(t) * 2.0;
float remaining_bits_of_biased_exponent = floor(t);
float byte4 = extract_bits(fraction, 0.0, 8.0) / 255.0;
float byte3 = extract_bits(fraction, 8.0, 16.0) / 255.0;
float byte2 = (last_bit_of_biased_exponent * 128.0 + extract_bits(fraction, 16.0, 23.0)) / 255.0;
float byte1 = (sign * 128.0 + remaining_bits_of_biased_exponent) / 255.0;
return vec4(byte4, byte3, byte2, byte1);
}
void main(){
vec2 fragCoord = gl_FragCoord.xy;
float textureXcoord = floor((fragCoord.x - 0.5)/u_vectorLength+0.0001) + 0.5;
vec4 data = texture2D(u_floatTexture, vec2(textureXcoord, fragCoord.y)/u_floatTextureDim);
int textureIndex = int(floor(mod(fragCoord.x-0.5+0.0001, u_vectorLength)));
if (textureIndex == 0) gl_FragColor = encode_float(data[0]);
else if (textureIndex == 1) gl_FragColor = encode_float(data[1]);
else if (textureIndex == 2) gl_FragColor = encode_float(data[2]);
else if (textureIndex == 3) gl_FragColor = encode_float(data[3]);
}
</script>
<script id="zeroTexture" type="x-shader/x-fragment">
precision mediump float;
void main(){
gl_FragColor = vec4(0.0);
}
</script>
<script id="zeroThetaTexture" type="x-shader/x-fragment">
precision mediump float;
uniform sampler2D u_theta;
uniform vec2 u_textureDimCreases;
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDimCreases;
vec4 theta = texture2D(u_theta, scaledFragCoord);
gl_FragColor = vec4(0.0, 0.0, theta[2], theta[3]);
}
</script>
<script id="centerTexture" type="x-shader/x-fragment">
precision mediump float;
uniform sampler2D u_lastPosition;
uniform vec2 u_textureDim;
uniform vec3 u_center;
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDim;
vec3 position = texture2D(u_lastPosition, scaledFragCoord).xyz;
gl_FragColor = vec4(position-u_center, 0.0);
}
</script>
<script id="copyTexture" type="x-shader/x-fragment">
precision mediump float;
uniform sampler2D u_orig;
uniform vec2 u_textureDim;
void main(){
gl_FragColor = texture2D(u_orig, gl_FragCoord.xy/u_textureDim);
}
</script>
<script id="positionCalcShader" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_textureDim;
uniform float u_dt;
uniform sampler2D u_lastPosition;
uniform sampler2D u_velocity;
uniform sampler2D u_mass;
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDim;
vec3 lastPosition = texture2D(u_lastPosition, scaledFragCoord).xyz;
float isFixed = texture2D(u_mass, scaledFragCoord).y;
if (isFixed == 1.0){
gl_FragColor = vec4(lastPosition, 0.0);
return;
}
vec4 velocityData = texture2D(u_velocity, scaledFragCoord);
vec3 position = velocityData.xyz*u_dt + lastPosition;
gl_FragColor = vec4(position, velocityData.a);//velocity.a has error info
}
</script>
<script id="velocityCalcVerletShader" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_textureDim;
uniform float u_dt;
uniform sampler2D u_position;
uniform sampler2D u_lastPosition;
uniform sampler2D u_mass;
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDim;
float isFixed = texture2D(u_mass, scaledFragCoord).y;
if (isFixed == 1.0){
gl_FragColor = vec4(0.0);
return;
}
vec3 position = texture2D(u_position, scaledFragCoord).xyz;
vec3 lastPosition = texture2D(u_lastPosition, scaledFragCoord).xyz;
gl_FragColor = vec4((position-lastPosition)/u_dt,0.0);
}
</script>
<script id="velocityCalcShader" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_textureDim;
uniform vec2 u_textureDimEdges;
uniform vec2 u_textureDimFaces;
uniform vec2 u_textureDimCreases;
uniform vec2 u_textureDimNodeCreases;
uniform vec2 u_textureDimNodeFaces;
uniform float u_creasePercent;
uniform float u_dt;
uniform float u_axialStiffness;
uniform float u_faceStiffness;
uniform sampler2D u_lastPosition;
uniform sampler2D u_lastVelocity;
uniform sampler2D u_originalPosition;
uniform sampler2D u_externalForces;
uniform sampler2D u_mass;
uniform sampler2D u_meta;//[beamsIndex, numBeam, nodeCreaseMetaIndex, numCreases]
uniform sampler2D u_beamMeta;//[k, d, length, otherNodeIndex]
uniform sampler2D u_creaseMeta;//[k, d, targetTheta]
uniform sampler2D u_nodeCreaseMeta;//[creaseIndex, nodeIndex, -, -]
uniform sampler2D u_normals;
uniform sampler2D u_theta;//[theta, z, normal1Index, normal2Index]
uniform sampler2D u_creaseGeo;//[h1, h2, coef1, coef2]
uniform sampler2D u_meta2;//[nodesFaceIndex, numFaces]
uniform sampler2D u_nodeFaceMeta;//[faceIndex, a, b, c]
uniform sampler2D u_nominalTriangles;//[angleA, angleB, angleC]
uniform bool u_calcFaceStrain;
vec4 getFromArray(float index1D, vec2 dimensions, sampler2D tex){
vec2 index = vec2(mod(index1D, dimensions.x)+0.5, floor(index1D/dimensions.x)+0.5);
vec2 scaledIndex = index/dimensions;
return texture2D(tex, scaledIndex);
}
vec3 getPosition(float index1D){
vec2 index = vec2(mod(index1D, u_textureDim.x)+0.5, floor(index1D/u_textureDim.x)+0.5);
vec2 scaledIndex = index/u_textureDim;
return texture2D(u_lastPosition, scaledIndex).xyz + texture2D(u_originalPosition, scaledIndex).xyz;
}
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDim;
vec2 mass = texture2D(u_mass, scaledFragCoord).xy;
if (mass[1] == 1.0){//fixed
gl_FragColor = vec4(0.0);
return;
}
vec3 force = texture2D(u_externalForces, scaledFragCoord).xyz;
vec3 lastPosition = texture2D(u_lastPosition, scaledFragCoord).xyz;
vec3 lastVelocity = texture2D(u_lastVelocity, scaledFragCoord).xyz;
vec3 originalPosition = texture2D(u_originalPosition, scaledFragCoord).xyz;
vec4 neighborIndices = texture2D(u_meta, scaledFragCoord);
vec4 meta = texture2D(u_meta, scaledFragCoord);
vec2 meta2 = texture2D(u_meta2, scaledFragCoord).xy;
float nodeError = 0.0;
for (int j=0;j<100;j++){//for all beams (up to 100, had to put a const int in here)
if (j >= int(meta[1])) break;
vec4 beamMeta = getFromArray(meta[0]+float(j), u_textureDimEdges, u_beamMeta);
float neighborIndex1D = beamMeta[3];
vec2 neighborIndex = vec2(mod(neighborIndex1D, u_textureDim.x)+0.5, floor(neighborIndex1D/u_textureDim.x)+0.5);
vec2 scaledNeighborIndex = neighborIndex/u_textureDim;
vec3 neighborLastPosition = texture2D(u_lastPosition, scaledNeighborIndex).xyz;
vec3 neighborLastVelocity = texture2D(u_lastVelocity, scaledNeighborIndex).xyz;
vec3 neighborOriginalPosition = texture2D(u_originalPosition, scaledNeighborIndex).xyz;
vec3 nominalDist = neighborOriginalPosition-originalPosition;
vec3 deltaP = neighborLastPosition-lastPosition+nominalDist;
float deltaPLength = length(deltaP);
deltaP -= deltaP*(beamMeta[2]/deltaPLength);
if (!u_calcFaceStrain) nodeError += abs(deltaPLength/length(nominalDist) - 1.0);
vec3 deltaV = neighborLastVelocity-lastVelocity;
vec3 _force = deltaP*beamMeta[0] + deltaV*beamMeta[1];
force += _force;
}
if (!u_calcFaceStrain) nodeError /= meta[1];
for (int j=0;j<100;j++){//for all creases (up to 100, had to put a const int in here)
if (j >= int(meta[3])) break;
vec4 nodeCreaseMeta = getFromArray(meta[2]+float(j), u_textureDimNodeCreases, u_nodeCreaseMeta);
float creaseIndex1D = nodeCreaseMeta[0];
vec2 creaseIndex = vec2(mod(creaseIndex1D, u_textureDimCreases.x)+0.5, floor(creaseIndex1D/u_textureDimCreases.x)+0.5);
vec2 scaledCreaseIndex = creaseIndex/u_textureDimCreases;
vec4 thetas = texture2D(u_theta, scaledCreaseIndex);
vec3 creaseMeta = texture2D(u_creaseMeta, scaledCreaseIndex).xyz;//[k, d, targetTheta]
vec4 creaseGeo = texture2D(u_creaseGeo, scaledCreaseIndex);//[h1, h2, coef1, coef2]
if (creaseGeo[0]< 0.0) continue;//crease disabled bc it has collapsed too much
float targetTheta = creaseMeta[2] * u_creasePercent;
float angForce = creaseMeta[0]*(targetTheta-thetas[0]);// + creaseMeta[1]*thetas[1];
float nodeNum = nodeCreaseMeta[1];//1, 2, 3, 4
if (nodeNum > 2.0){//crease reaction, node is on a crease
//node #1
vec3 normal1 = getFromArray(thetas[2], u_textureDimFaces, u_normals).xyz;
//node #2
vec3 normal2 = getFromArray(thetas[3], u_textureDimFaces, u_normals).xyz;
float coef1 = creaseGeo[2];
float coef2 = creaseGeo[3];
if (nodeNum == 3.0){
coef1 = 1.0-coef1;
coef2 = 1.0-coef2;
}
vec3 _force = -angForce*(coef1/creaseGeo[0]*normal1 + coef2/creaseGeo[1]*normal2);
force += _force;
} else {
float normalIndex1D = thetas[2];//node #1
float momentArm = creaseGeo[0];//node #1
if (nodeNum == 2.0) {
normalIndex1D = thetas[3];//node #2
momentArm = creaseGeo[1];//node #2
}
vec3 normal = getFromArray(normalIndex1D, u_textureDimFaces, u_normals).xyz;
vec3 _force = angForce/momentArm*normal;
force += _force;
}
}
for (int j=0;j<100;j++){//for all faces (up to 100, had to put a const int in here)
if (j >= int(meta2[1])) break;
vec4 faceMeta = getFromArray(meta2[0]+float(j), u_textureDimNodeFaces, u_nodeFaceMeta);//[face index, a, b, c]
vec3 nominalAngles = getFromArray(faceMeta[0], u_textureDimFaces, u_nominalTriangles).xyz;//[angA, angB, angC]
int faceIndex = 0;
if (faceMeta[2] < 0.0) faceIndex = 1;
if (faceMeta[3] < 0.0) faceIndex = 2;
//get node positions
vec3 a = faceIndex == 0 ? lastPosition+originalPosition : getPosition(faceMeta[1]);
vec3 b = faceIndex == 1 ? lastPosition+originalPosition : getPosition(faceMeta[2]);
vec3 c = faceIndex == 2 ? lastPosition+originalPosition : getPosition(faceMeta[3]);
//calc angles
vec3 ab = b-a;
vec3 ac = c-a;
vec3 bc = c-b;
float lengthAB = length(ab);
float lengthAC = length(ac);
float lengthBC = length(bc);
float tol = 0.0000001;
if (abs(lengthAB) < tol || abs(lengthBC) < tol || abs(lengthAC) < tol) continue;
ab /= lengthAB;
ac /= lengthAC;
bc /= lengthBC;
vec3 angles = vec3(acos(dot(ab, ac)),
acos(-1.0*dot(ab, bc)),
acos(dot(ac, bc)));
vec3 anglesDiff = nominalAngles-angles;
vec3 normal = getFromArray(faceMeta[0], u_textureDimFaces, u_normals).xyz;
//calc forces
anglesDiff *= u_faceStiffness;
if (faceIndex == 0){//a
vec3 normalCrossAC = cross(normal, ac)/lengthAC;
vec3 normalCrossAB = cross(normal, ab)/lengthAB;
force -= anglesDiff[0]*(normalCrossAC - normalCrossAB);
if (u_calcFaceStrain) nodeError += abs((nominalAngles[0]-angles[0])/nominalAngles[0]);
force -= anglesDiff[1]*normalCrossAB;
force += anglesDiff[2]*normalCrossAC;
} else if (faceIndex == 1){
vec3 normalCrossAB = cross(normal, ab)/lengthAB;
vec3 normalCrossBC = cross(normal, bc)/lengthBC;
force -= anglesDiff[0]*normalCrossAB;
force += anglesDiff[1]*(normalCrossAB + normalCrossBC);
if (u_calcFaceStrain) nodeError += abs((nominalAngles[1]-angles[1])/nominalAngles[1]);
force -= anglesDiff[2]*normalCrossBC;
} else if (faceIndex == 2){
vec3 normalCrossAC = cross(normal, ac)/lengthAC;
vec3 normalCrossBC = cross(normal, bc)/lengthBC;
force += anglesDiff[0]*normalCrossAC;
force -= anglesDiff[1]*normalCrossBC;
force += anglesDiff[2]*(normalCrossBC - normalCrossAC);
if (u_calcFaceStrain) nodeError += abs((nominalAngles[2]-angles[2])/nominalAngles[2]);
}
}
if (u_calcFaceStrain) nodeError /= meta2[1];
vec3 velocity = force*u_dt/mass[0] + lastVelocity;
gl_FragColor = vec4(velocity,nodeError);
}
</script>
<script id="positionCalcVerletShader" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_textureDim;
uniform vec2 u_textureDimEdges;
uniform vec2 u_textureDimFaces;
uniform vec2 u_textureDimCreases;
uniform vec2 u_textureDimNodeCreases;
uniform vec2 u_textureDimNodeFaces;
uniform float u_creasePercent;
uniform float u_dt;
uniform float u_axialStiffness;
uniform float u_faceStiffness;
uniform sampler2D u_lastPosition;
uniform sampler2D u_lastLastPosition;
uniform sampler2D u_lastVelocity;
uniform sampler2D u_originalPosition;
uniform sampler2D u_externalForces;
uniform sampler2D u_mass;
uniform sampler2D u_meta;//[beamsIndex, numBeam, nodeCreaseMetaIndex, numCreases]
uniform sampler2D u_beamMeta;//[k, d, length, otherNodeIndex]
uniform sampler2D u_creaseMeta;//[k, d, targetTheta]
uniform sampler2D u_nodeCreaseMeta;//[creaseIndex, nodeIndex, -, -]
uniform sampler2D u_normals;
uniform sampler2D u_theta;//[theta, z, normal1Index, normal2Index]
uniform sampler2D u_creaseGeo;//[h1, h2, coef1, coef2]
uniform sampler2D u_meta2;//[nodesFaceIndex, numFaces]
uniform sampler2D u_nodeFaceMeta;//[faceIndex, a, b, c]
uniform sampler2D u_nominalTriangles;//[angleA, angleB, angleC]
vec4 getFromArray(float index1D, vec2 dimensions, sampler2D tex){
vec2 index = vec2(mod(index1D, dimensions.x)+0.5, floor(index1D/dimensions.x)+0.5);
vec2 scaledIndex = index/dimensions;
return texture2D(tex, scaledIndex);
}
vec3 getPosition(float index1D){
vec2 index = vec2(mod(index1D, u_textureDim.x)+0.5, floor(index1D/u_textureDim.x)+0.5);
vec2 scaledIndex = index/u_textureDim;
return texture2D(u_lastPosition, scaledIndex).xyz + texture2D(u_originalPosition, scaledIndex).xyz;
}
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDim;
vec3 lastPosition = texture2D(u_lastPosition, scaledFragCoord).xyz;
vec2 mass = texture2D(u_mass, scaledFragCoord).xy;
if (mass[1] == 1.0){//fixed
gl_FragColor = vec4(lastPosition, 0.0);
return;
}
vec3 force = texture2D(u_externalForces, scaledFragCoord).xyz;
vec3 lastLastPosition = texture2D(u_lastLastPosition, scaledFragCoord).xyz;
vec3 lastVelocity = texture2D(u_lastVelocity, scaledFragCoord).xyz;
vec3 originalPosition = texture2D(u_originalPosition, scaledFragCoord).xyz;
vec4 neighborIndices = texture2D(u_meta, scaledFragCoord);
vec4 meta = texture2D(u_meta, scaledFragCoord);
vec2 meta2 = texture2D(u_meta2, scaledFragCoord).xy;
float nodeError = 0.0;
for (int j=0;j<100;j++){//for all beams (up to 100, had to put a const int in here)
if (j >= int(meta[1])) break;
vec4 beamMeta = getFromArray(meta[0]+float(j), u_textureDimEdges, u_beamMeta);
float neighborIndex1D = beamMeta[3];
vec2 neighborIndex = vec2(mod(neighborIndex1D, u_textureDim.x)+0.5, floor(neighborIndex1D/u_textureDim.x)+0.5);
vec2 scaledNeighborIndex = neighborIndex/u_textureDim;
vec3 neighborLastPosition = texture2D(u_lastPosition, scaledNeighborIndex).xyz;
vec3 neighborLastVelocity = texture2D(u_lastVelocity, scaledNeighborIndex).xyz;
vec3 neighborOriginalPosition = texture2D(u_originalPosition, scaledNeighborIndex).xyz;
vec3 deltaP = neighborLastPosition+neighborOriginalPosition-lastPosition-originalPosition;
float deltaPLength = length(deltaP);
float nominalLength = beamMeta[2];
deltaP *= (1.0-nominalLength/deltaPLength);
nodeError += abs(deltaPLength/nominalLength - 1.0);
vec3 deltaV = neighborLastVelocity-lastVelocity;
vec3 _force = deltaP*beamMeta[0] + deltaV*beamMeta[1];
force += _force;
}
nodeError /= meta[1];
for (int j=0;j<100;j++){//for all creases (up to 100, had to put a const int in here)
if (j >= int(meta[3])) break;
vec4 nodeCreaseMeta = getFromArray(meta[2]+float(j), u_textureDimNodeCreases, u_nodeCreaseMeta);
float creaseIndex1D = nodeCreaseMeta[0];
vec2 creaseIndex = vec2(mod(creaseIndex1D, u_textureDimCreases.x)+0.5, floor(creaseIndex1D/u_textureDimCreases.x)+0.5);
vec2 scaledCreaseIndex = creaseIndex/u_textureDimCreases;
vec4 thetas = texture2D(u_theta, scaledCreaseIndex);
vec3 creaseMeta = texture2D(u_creaseMeta, scaledCreaseIndex).xyz;//[k, d, targetTheta]
vec4 creaseGeo = texture2D(u_creaseGeo, scaledCreaseIndex);//[h1, h2, coef1, coef2]
if (creaseGeo[0]< 0.0) continue;//crease disabled bc it has collapsed too much
float targetTheta = creaseMeta[2] * u_creasePercent;
float angForce = creaseMeta[0]*(targetTheta-thetas[0]);// + creaseMeta[1]*thetas[1];
float nodeNum = nodeCreaseMeta[1];//1, 2, 3, 4
if (nodeNum > 2.0){//crease reaction, node is on a crease
//node #1
vec3 normal1 = getFromArray(thetas[2], u_textureDimFaces, u_normals).xyz;
//node #2
vec3 normal2 = getFromArray(thetas[3], u_textureDimFaces, u_normals).xyz;
float coef1 = creaseGeo[2];
float coef2 = creaseGeo[3];
if (nodeNum == 3.0){
coef1 = 1.0-coef1;
coef2 = 1.0-coef2;
}
vec3 _force = -angForce*(coef1/creaseGeo[0]*normal1 + coef2/creaseGeo[1]*normal2);
force += _force;
} else {
float normalIndex1D = thetas[2];//node #1
float momentArm = creaseGeo[0];//node #1
if (nodeNum == 2.0) {
normalIndex1D = thetas[3];//node #2
momentArm = creaseGeo[1];//node #2
}
vec3 normal = getFromArray(normalIndex1D, u_textureDimFaces, u_normals).xyz;
vec3 _force = angForce/momentArm*normal;
force += _force;
}
}
for (int j=0;j<100;j++){//for all faces (up to 100, had to put a const int in here)
if (j >= int(meta2[1])) break;
vec4 faceMeta = getFromArray(meta2[0]+float(j), u_textureDimNodeFaces, u_nodeFaceMeta);//[face index, a, b, c]
vec3 nominalAngles = getFromArray(faceMeta[0], u_textureDimFaces, u_nominalTriangles).xyz;//[angA, angB, angC]
int faceIndex = 0;
if (faceMeta[2] < 0.0) faceIndex = 1;
if (faceMeta[3] < 0.0) faceIndex = 2;
//get node positions
vec3 a = faceIndex == 0 ? lastPosition+originalPosition : getPosition(faceMeta[1]);
vec3 b = faceIndex == 1 ? lastPosition+originalPosition : getPosition(faceMeta[2]);
vec3 c = faceIndex == 2 ? lastPosition+originalPosition : getPosition(faceMeta[3]);
//calc angles
vec3 ab = b-a;
vec3 ac = c-a;
vec3 bc = c-b;
float lengthAB = length(ab);
float lengthAC = length(ac);
float lengthBC = length(bc);
float tol = 0.0000001;
if (abs(lengthAB) < tol || abs(lengthBC) < tol || abs(lengthAC) < tol) continue;
ab /= lengthAB;
ac /= lengthAC;
bc /= lengthBC;
vec3 angles = vec3(acos(dot(ab, ac)),
acos(-1.0*dot(ab, bc)),
acos(dot(ac, bc)));
vec3 anglesDiff = nominalAngles-angles;
vec3 normal = getFromArray(faceMeta[0], u_textureDimFaces, u_normals).xyz;
//calc forces
anglesDiff *= u_faceStiffness;
if (faceIndex == 0){//a
vec3 normalCrossAC = cross(normal, ac)/lengthAC;
vec3 normalCrossAB = cross(normal, ab)/lengthAB;
force -= anglesDiff[0]*(normalCrossAC - normalCrossAB);
force -= anglesDiff[1]*normalCrossAB;
force += anglesDiff[2]*normalCrossAC;
} else if (faceIndex == 1){
vec3 normalCrossAB = cross(normal, ab)/lengthAB;
vec3 normalCrossBC = cross(normal, bc)/lengthBC;
force -= anglesDiff[0]*normalCrossAB;
force += anglesDiff[1]*(normalCrossAB + normalCrossBC);
force -= anglesDiff[2]*normalCrossBC;
} else if (faceIndex == 2){
vec3 normalCrossAC = cross(normal, ac)/lengthAC;
vec3 normalCrossBC = cross(normal, bc)/lengthBC;
force += anglesDiff[0]*normalCrossAC;
force -= anglesDiff[1]*normalCrossBC;
force += anglesDiff[2]*(normalCrossBC - normalCrossAC);
}
}
vec3 nextPosition = force*u_dt*u_dt/mass[0] + 2.0*lastPosition - lastLastPosition;
gl_FragColor = vec4(nextPosition,nodeError);//position.a has error info
}
</script>
<script id="thetaCalcShader" type="x-shader/x-fragment">
#define TWO_PI 6.283185307179586476925286766559
precision mediump float;
uniform vec2 u_textureDim;
uniform vec2 u_textureDimFaces;
uniform vec2 u_textureDimCreases;
uniform sampler2D u_normals;
uniform sampler2D u_lastTheta;
uniform sampler2D u_creaseVectors;
uniform sampler2D u_lastPosition;
uniform sampler2D u_originalPosition;
uniform float u_dt;
vec4 getFromArray(float index1D, vec2 dimensions, sampler2D tex){
vec2 index = vec2(mod(index1D, dimensions.x)+0.5, floor(index1D/dimensions.x)+0.5);
vec2 scaledIndex = index/dimensions;
return texture2D(tex, scaledIndex);
}
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDimCreases;
vec4 lastTheta = texture2D(u_lastTheta, scaledFragCoord);
if (lastTheta[2]<0.0){
gl_FragColor = vec4(lastTheta[0], 0.0, -1.0, -1.0);
return;
}
vec3 normal1 = getFromArray(lastTheta[2], u_textureDimFaces, u_normals).xyz;
vec3 normal2 = getFromArray(lastTheta[3], u_textureDimFaces, u_normals).xyz;
float dotNormals = dot(normal1, normal2);//normals are already normalized, no need to divide by length
if (dotNormals < -1.0) dotNormals = -1.0;
else if (dotNormals > 1.0) dotNormals = 1.0;
vec2 creaseVectorIndices = texture2D(u_creaseVectors, scaledFragCoord).xy;
vec2 creaseNodeIndex = vec2(mod(creaseVectorIndices[0], u_textureDim.x)+0.5, floor(creaseVectorIndices[0]/u_textureDim.x)+0.5);
vec2 scaledNodeIndex = creaseNodeIndex/u_textureDim;
vec3 node0 = texture2D(u_lastPosition, scaledNodeIndex).xyz + texture2D(u_originalPosition, scaledNodeIndex).xyz;
creaseNodeIndex = vec2(mod(creaseVectorIndices[1], u_textureDim.x)+0.5, floor(creaseVectorIndices[1]/u_textureDim.x)+0.5);
scaledNodeIndex = creaseNodeIndex/u_textureDim;
vec3 node1 = texture2D(u_lastPosition, scaledNodeIndex).xyz + texture2D(u_originalPosition, scaledNodeIndex).xyz;
//https://math.stackexchange.com/questions/47059/how-do-i-calculate-a-dihedral-angle-given-cartesian-coordinates
vec3 creaseVector = normalize(node1-node0);
float x = dotNormals;
float y = dot(cross(normal1, creaseVector), normal2);
float theta = atan(y, x);
float diff = theta-lastTheta[0];
float origDiff = diff;
if (diff < -5.0) {
diff += TWO_PI;
} else if (diff > 5.0) {
diff -= TWO_PI;
}
theta = lastTheta[0] + diff;
gl_FragColor = vec4(theta, diff, lastTheta[2], lastTheta[3]);//[theta, w, normal1Index, normal2Index]
}
</script>
<script id="normalCalc" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_textureDim;
uniform vec2 u_textureDimFaces;
uniform sampler2D u_faceVertexIndices;
uniform sampler2D u_lastPosition;
uniform sampler2D u_originalPosition;
vec3 getPosition(float index1D){
vec2 index = vec2(mod(index1D, u_textureDim.x)+0.5, floor(index1D/u_textureDim.x)+0.5);
vec2 scaledIndex = index/u_textureDim;
return texture2D(u_lastPosition, scaledIndex).xyz + texture2D(u_originalPosition, scaledIndex).xyz;
}
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDimFaces;
vec3 indices = texture2D(u_faceVertexIndices, scaledFragCoord).xyz;
vec3 a = getPosition(indices[0]);
vec3 b = getPosition(indices[1]);
vec3 c = getPosition(indices[2]);
vec3 normal = normalize(cross(b-a, c-a));
gl_FragColor = vec4(normal, 0.0);
}
</script>
<script id="updateCreaseGeo" type="x-shader/x-fragment">
precision mediump float;
uniform vec2 u_textureDim;
uniform vec2 u_textureDimCreases;
uniform sampler2D u_lastPosition;
uniform sampler2D u_originalPosition;
uniform sampler2D u_creaseMeta2;
vec3 getPosition(float index1D){
vec2 index = vec2(mod(index1D, u_textureDim.x)+0.5, floor(index1D/u_textureDim.x)+0.5);
vec2 scaledIndex = index/u_textureDim;
return texture2D(u_lastPosition, scaledIndex).xyz + texture2D(u_originalPosition, scaledIndex).xyz;
}
void main(){
vec2 fragCoord = gl_FragCoord.xy;
vec2 scaledFragCoord = fragCoord/u_textureDimCreases;
vec4 creaseMeta = texture2D(u_creaseMeta2, scaledFragCoord);
vec3 node1 = getPosition(creaseMeta[0]);
vec3 node2 = getPosition(creaseMeta[1]);
vec3 node3 = getPosition(creaseMeta[2]);
vec3 node4 = getPosition(creaseMeta[3]);
float tol = 0.000001;
vec3 creaseVector = node4-node3;
float creaseLength = length(creaseVector);
if (abs(creaseLength)<tol) {
gl_FragColor = vec4(-1);//disable crease
return;
}
creaseVector /= creaseLength;
vec3 vector1 = node1-node3;
vec3 vector2 = node2-node3;
float proj1Length = dot(creaseVector, vector1);
float proj2Length = dot(creaseVector, vector2);
float dist1 = sqrt(abs(vector1.x*vector1.x+vector1.y*vector1.y+vector1.z*vector1.z-proj1Length*proj1Length));
float dist2 = sqrt(abs(vector2.x*vector2.x+vector2.y*vector2.y+vector2.z*vector2.z-proj2Length*proj2Length));
if (dist1<tol || dist2<tol){
gl_FragColor = vec4(-1);//disable crease
return;
}
gl_FragColor = vec4(dist1, dist2, proj1Length/creaseLength, proj2Length/creaseLength);
}
</script>
<script type="text/javascript" src="dependencies/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="dependencies/jquery-ui.min.js"></script>
<script type="text/javascript" src="dependencies/flat-ui.min.js"></script>
<script type="text/javascript" src="dependencies/three.min.js"></script>
<script type="text/javascript" src="dependencies/binary_stl_writer.js"></script>
<script type="text/javascript" src="dependencies/TrackballControls.js"></script>
<!--<script type="text/javascript" src="dependencies/Projector.js"></script>-->
<!--<script type="text/javascript" src="dependencies/SVGRenderer.js"></script>-->
<script type="text/javascript" src="dependencies/underscore-min.js"></script>
<script type="text/javascript" src="dependencies/FileSaver.min.js"></script>
<script type="text/javascript" src="dependencies/SVGLoader.js"></script>
<script type="text/javascript" src="dependencies/OBJExporter.js"></script>
<script type="text/javascript" src="dependencies/path-data-polyfill.js"></script>
<script type="text/javascript" src="dependencies/earcut.js"></script>
<script type="text/javascript" src="dependencies/fold.js"></script>
<script type="text/javascript" src="dependencies/CCapture.all.min.js"></script>
<script type="text/javascript" src="dependencies/numeric-1.2.6.js"></script>
<!--<script type="text/javascript" src="dependencies/EffectComposer.js"></script>-->
<!--<script type="text/javascript" src="dependencies/MaskPass.js"></script>-->
<!--<script type="text/javascript" src="dependencies/ShaderPass.js"></script>-->
<!--<script type="text/javascript" src="dependencies/CopyShader.js"></script>-->
<!--<script type="text/javascript" src="dependencies/SSAOShader.js"></script>-->
<!--<script type="text/javascript" src="dependencies/Detector.js"></script>-->
<!--<script type="text/javascript" src="dependencies/RenderPass.js"></script>-->
<script type="text/javascript" src="dependencies/WebVR.js"></script>
<script type="text/javascript" src="dependencies/VRController.js"></script>
<script type="text/javascript" src="dependencies/datguivr.js"></script><!--made a lot of changes, don't replace with minified-->
<script type="text/javascript" src="js/dynamic/GLBoilerplate.js"></script>
<script type="text/javascript" src="js/dynamic/GPUMath.js"></script>
<script type="text/javascript" src="js/controls.js"></script>
<script type="text/javascript" src="js/threeView.js"></script>
<script type="text/javascript" src="js/globals.js"></script>
<script type="text/javascript" src="js/node.js"></script>
<script type="text/javascript" src="js/beam.js"></script>
<script type="text/javascript" src="js/crease.js"></script>
<script type="text/javascript" src="js/model.js"></script>
<script type="text/javascript" src="js/3dUI.js"></script>
<script type="text/javascript" src="js/staticSolver.js"></script>
<script type="text/javascript" src="js/dynamic/dynamicSolver.js"></script>
<script type="text/javascript" src="js/rigidSolver.js"></script>
<script type="text/javascript" src="js/pattern.js"></script>
<script type="text/javascript" src="js/saveSTL.js"></script>
<script type="text/javascript" src="js/saveFOLD.js"></script>
<script type="text/javascript" src="js/importer.js"></script>
<script type="text/javascript" src="js/VRInterface.js"></script>
<script type="text/javascript" src="js/videoAnimator.js"></script>
<script type="text/javascript" src="dependencies/cdt2d.js"></script><!-- constrained delaunay triangulation -->
<script type="text/javascript" src="dependencies/svgpath.js"></script>
<script type="text/javascript" src="js/curvedFolding.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</head>
<body>
<div class="modal fade" id="aboutModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<p>
<b>ORIGAMI SIMULATOR</b><br/>
<img style="width: 100%; max-width:500px" src="assets/doc/crane.gif" />
This app allows you to simulate how any origami crease pattern will fold. It may look a little different
from what you typically think of as "origami" - rather than folding paper in a set of sequential steps,
this simulation attempts to fold every crease simultaneously. It does this by iteratively solving for small displacements in the geometry of an initially flat sheet due to forces
exerted by creases.
You can read more about it in our paper:
<ul>
<li><a target="_blank" href="http://erikdemaine.org/papers/OrigamiSimulator_Origami7/">Fast, Interactive Origami Simulation using GPU Computation</a> by Amanda Ghassaei, Erik Demaine, and Neil Gershenfeld (7OSME)
</ul>
All simulation methods were written from scratch and are executed in parallel in several GPU fragment shaders for fast performance.
The solver extends work from the following sources:
<ul>
<li><a target="_blank" href="http://www2.eng.cam.ac.uk/~sdg/preprint/5OSME.pdf">Origami Folding: A Structural Engineering Approach</a> by Mark Schenk and Simon D. Guest<br/>
<li><a target="_blank" href="http://www.tsg.ne.jp/TT/cg/TachiFreeformOrigami2010.pdf">Freeform Variations of Origami</a> by Tomohiro Tachi<br/>
</ul>
<p>
This app also uses the methods described in <a href="http://www.cgg.cs.tsukuba.ac.jp/projects/2020/RulingAwareTriangulation/index.html" target="_blank">Simple Simulation of Curved Folds Based on Ruling-aware Triangulation</a> to import curved crease patterns and pre-process them in a way that realistically simulates the bending between the creases.
</p>
<p>
Originally built by <a href="https://amandaghassaei.com/" target="_blank">Amanda Ghassaei</a> as a final project for <a href="http://courses.csail.mit.edu/6.849/spring17/" target="_blank">Geometric Folding Algorithms</a>.
Other contributors include <a href="http://www.cgg.cs.tsukuba.ac.jp/~sasaki_k/" target="_blank">Sasaki Kosuke</a>, <a href="http://erikdemaine.org/" target="_blank">Erik Demaine</a>, and <a href="https://github.com/amandaghassaei/OrigamiSimulator/graphs/contributors" target="_blank">others</a>.
Code available on <a href="https://github.com/amandaghassaei/OrigamiSimulator" target="_blank">Github</a>. If you have interesting crease patterns that would
make good demo files, please send them to me (Amanda) so I can add them to the <b>Examples</b> menu. My email address is on my website. Thanks!<br/>
</p><br/>
<b>Instructions:</b><br/><br/>
<img style="width: 100%; max-width:600px" src="assets/doc/demoui.gif" /><br/>
<ul>
<li>Slide the <b>Fold Percent</b> slider to control the degree of folding of the pattern (100% is fully folded, 0% is unfolded,
and -100% is fully folded with the opposite mountain/valley assignments).</li>
<li>Drag to rotate the model, scroll to zoom.</li>
<li>Import other patterns under the <b>Examples</b> menu.</li>
<li>Upload your own crease patterns in SVG or <a href="https://github.com/edemaine/fold" target="_blank">FOLD</a> formats, following <a href="#" class="goToImportInstructions">these instructions</a>.</li>
<li>Export FOLD files or 3D models ( STL or OBJ ) of the folded state of your design ( <b>File > Save Simulation as...</b> ).</li>
</ul>
<img style="width: 100%;" src="assets/doc/strain.jpg" />
<ul>
<li>Visualize the internal strain of the origami as it folds using the <b>Strain Visualization</b> in the left menu of the <b>Advanced Options</b>.</li>
</ul>
<img style="width: 100%; max-width:600px" src="assets/doc/huffmanvr.jpg" /><br/>
<ul>
<li>If you are working from a computer connected to a VR headset and hand controllers, follow <a href="#" id="goToViveInstructions">these instructions</a>
to use this app in an interactive virtual reality mode. (sorry I think this may be deprecated now!)</li>
</ul>
<br/>
<b>External Libraries:</b><br/><br/>
<ul>
<li>All rendering and 3D interaction done with <a target="_blank" href="https://threejs.org/">three.js</a></li>
<li><a href="https://github.com/fontello/svgpath" target="_blank">svgpath</a> and <a href="https://www.npmjs.com/package/path-data-polyfill" target="_blank">path-data-polyfill</a> helps with SVG path parsing</li>
<li><a href="https://github.com/edemaine/fold" target="_blank">FOLD</a> is used as the internal data structure, methods from the
<a href="https://github.com/edemaine/fold/blob/master/doc/api.md" target="_blank">FOLD API</a> used for SVG parsing</li>
<li>Arbitrary polygonal faces of imported geometry are triangulated using the <a target="_blank" href="https://github.com/mapbox/earcut">Earcut Library</a> and <a href="https://github.com/mikolalysenko/cdt2d" target="_blank"></a>cdt2d</a></li>
<li><a href="http://www.numericjs.com/" target="_blank">numeric.js</a> for linear algebra operations</li>
<li>GIF and WebM video export uses <a target="_blank" href="https://github.com/spite/ccapture.js/">CCapture</a></li>
</ul>
<p>
<br/>
You can find additional information in <a href="http://erikdemaine.org/papers/OrigamiSimulator_Origami7/" target="_blank">our 7OSME paper</a> and <a href="http://www.amandaghassaei.com/projects/origami_simulator/" target="_blank">project website</a>.
If you have feedback about features you want to see in this app, please see <a href="https://github.com/amandaghassaei/OrigamiSimulator/discussions/41" target="_blank">this thread</a>.
<br/>
<br/>
</p>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<nav id="globalNav" class="navbar navbar-inverse navbar-embossed" role="navigation">
<div class="navbar-header">
<a id="logo" class="navbar-brand" target="_blank" href="https://amandaghassaei.com/">
<img id="inactiveLogo" src="assets/logo.png"/>
<img id="activeLogo" src="assets/logo-active.png"/>
</a>
</div>
<div class="collapse navbar-collapse" id="navbar-collapse-01">
<ul class="nav navbar-nav navbar-left">
<li class="dropdown navDropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">File <b class="caret"></b></a>
<span class="dropdown-arrow"></span>
<ul class="dropdown-menu">
<li><a class="loadFile" href="#">Import... (SVG / FOLD)</a></li>
<!--<li><a id="importSettings" href="#">SVG Import Settings...</a></li>-->
<li><a id="tips" href="#">Design Tips</a></li>
<li class="divider"></li>
<li><a id="createGif" href="#">Record animated GIF...</a></li>
<li><a id="createVideo" href="#">Record video...</a></li>
<li><a id="createPNG" href="#">Save PNG screenshot...</a></li>
<li class="divider"></li>
<li><a id="exportFOLD" href="#">Save Simulation as FOLD...</a></li>
<li><a id="exportSTL" href="#">Save Simulation as STL...</a></li>
<li><a id="exportOBJ" href="#">Save Simulation as OBJ...</a></li>
<li class="divider"></li>
<li><a id="saveSVG" href="#">Save Pattern as SVG...</a></li>
<!--<li><a id="saveSVGScreenshot" href="#">Save SVG screenshot</a></li>-->
</ul>
</li>
<li class="dropdown navDropdown">
<a href="#" id="exampleMenuButton" class="dropdown-toggle" data-toggle="dropdown">Examples <b class="caret"></b></a>
<span class="dropdown-arrow"></span>
<ul class="dropdown-menu" style="min-width: 200px;">
<li class="dropdown-submenu">
<a tabindex="-1">Origami<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="demo" data-url="Origami/flappingBird.svg">Flapping Bird</a></li>
<li><a href="#" class="demo author" data-author="randlett" data-url="Origami/randlettflappingbird.svg">Randlett Flapping Bird</a></li>
<li><a href="#" class="demo" data-url="Origami/traditionalCrane.svg">Crane (3D)</a></li>
<li><a href="#" class="demo" data-url="Origami/flat_crane.svg">Crane (flat)</a></li>
<li><a href="#" class="demo author" data-author="hypar" data-url="Origami/hypar.svg">Hypar</a></li>
<li><a href="#" class="demo author" data-author="hypar" data-url="Origami/6ptHypar-anti.svg">Hypar (6 point)</a></li>
<li><a href="#" class="demo" data-url="Origami/singlesquaretwist.svg">Square Twist (single)</a></li>
<li><a href="#" class="demo author" data-author="squareTwist" data-url="Origami/squaretwistManyAngles.svg">Square Twist (many angles)</a></li>
<li><a href="#" class="demo author" data-author="moosersTrain" data-url="Origami/MoosersTrainRigid-Gardner.svg">Mooser's Rigid Train</a></li>
<li><a href="#" class="demo author" data-author="pakin" data-url="Origami/airplane.svg">Paper Airplane</a></li>
<li class="divider"></li>
<li><a href="#" class="demo author" data-author="langTreemaker" data-url="Origami/langCardinal.svg">Lang Cardinal</a></li>
<li><a href="#" class="demo author" data-author="langTreemaker" data-url="Origami/langOrchid.svg">Lang Orchid</a></li>
<li><a href="#" class="demo author" data-author="langTreemaker" data-url="Origami/langKnlDragon.svg">Lang KNL Dragon</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1">Tessellations<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="demo author" data-author="miuraOri" data-url="Tessellations/miura-ori.svg">Miura-Ori</a></li>
<li><a href="#" class="demo author" data-author="miuraOri" data-url="Tessellations/miura_sharpangle.svg">Miura-Ori (sharp angle)</a></li>
<li><a href="#" class="demo" data-url="Tessellations/waterbomb.svg">Waterbomb</a></li>
<li><a href="#" class="demo author" data-author="whirlpool" data-url="Tessellations/whirlpool.svg">Whirlpool Spiral</a></li>
<li><a href="#" class="demo author" data-author="gardner" data-url="Tessellations/FTpoly7.svg">Flower Tower (flat foldable)</a></li>
<li><a href="#" class="demo author" data-author="fellerSmocked" data-url="Tessellations/HexTriFlatFoldableTess.svg">Hex/Tri Tessellation (flat foldable)</a></li>
<li class="divider"></li>
<li><a href="#" class="demo author" data-author="huffmanTessellations" data-url="Tessellations/huffmanExtrudedBoxes.svg">Huffman Extruded Boxes</a></li>
<li><a href="#" class="demo author" data-author="huffmanTessellations" data-url="Tessellations/huffmanWaterbomb.svg">Huffman Waterbombs</a></li>
<li><a href="#" class="demo author" data-author="huffmanTessellations" data-url="Tessellations/huffmanRectangularWeave.svg">Huffman Rect Weave</a></li>
<li><a href="#" class="demo author" data-author="huffmanTessellations" data-url="Tessellations/huffmanStarsTriangles.svg">Huffman Stars-Triangles</a></li>
<li><a href="#" class="demo author" data-author="huffmanTessellations" data-url="Tessellations/huffmanExdentedBoxes.svg">Huffman Exdented Boxes</a></li>
<li class="divider"></li>
<li><a href="#" class="demo author" data-author="langTessellations" data-url="Tessellations/langHoneycomb.svg">Lang Honeycomb Tessellation</a></li>
<li><a href="#" class="demo author" data-author="langTessellations" data-url="Tessellations/langWedgeDoubleFaced.svg">Lang Wedged Double Faced Tessellation</a></li>
<li><a href="#" class="demo author" data-author="langTessellations" data-url="Tessellations/langOvalTessellation.svg">Lang Oval Tessellation</a></li>
<li><a href="#" class="demo author" data-author="langTessellations" data-url="Tessellations/langHyperbolicLimit.svg">Lang Hyperbolic Limit</a></li>
<li class="divider"></li>
<li><a href="#" class="demo author" data-author="reschTessellations" data-url="Tessellations/reschTriTessellation.svg">Resch Triangle Tessellation</a></li>
<li><a href="#" class="demo author" data-author="reschTessellations" data-url="Tessellations/reschBarbell.svg">Resch Barbell Tessellation</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1">Curved Creases<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<!-- Using class "cc" causes the example to be loaded with the curved crease checkbox enabled -->
<!-- Some examples already have rulings drawn in and don't need the cc importer -->
<li><a href="#" class="demo author cc" data-author="mitani" data-url="Curved/wavy_pleats.svg">Wavy Pleats</a></li>
<li><a href="#" class="demo author cc" data-author="mitaniCCbook" data-url="Curved/Tri-Wing_Boomerang_Tiling.svg">Boomerang Tessellation</a></li>
<li><a href="#" class="demo author cc" data-author="mitani3Dbook" data-url="Curved/Origami_Sphere_16Flaps.svg">Origami Sphere</a></li>
<li><a href="#" class="demo author cc" data-author="mitani" data-url="Curved/comet.svg">Comet</a></li>
<li><a href="#" class="demo author cc" data-author="mitani" data-url="Curved/scale.svg">Scale Tessellation</a></li>
<li><a href="#" class="demo author cc" data-author="mitaniCCbook" data-url="Curved/Carved_Cylinder.svg">Carved Cylinder</a></li>
<li><a href="#" class="demo author cc" data-author="mitaniCCbook" data-url="Curved/Rotating_Star.svg">Rotating Star</a></li>
<li><a href="#" class="demo author cc" data-author="mitaniCCbook" data-url="Curved/Crossing_curves.svg">Crossing Curves</a></li>
<li><a href="#" class="demo author cc" data-author="mitaniCCbook" data-url="Curved/Treble_Clef.svg">Treble Clef</a></li>
<li class="divider"></li>
<li><a href="#" class="demo author cc" data-author="lukashevaCCbook" data-url="Curved/Leafy_Opus_T-69.svg">Leafy (Opus T-69)</a></li>
<li><a href="#" class="demo author cc" data-author="lukasheva" data-url="Curved/Sweet_Dreams_Opus_T-41.svg">Sweet Dreams (Opus T-41)</a></li>
<li><a href="#" class="demo author cc" data-author="lukasheva" data-url="Curved/Improvisation-62.svg">Improvisation 62</a></li>
<li class="divider"></li>
<li><a href="#" class="demo author" data-author="huffmanCurved" data-url="Curved/huffmanTower.svg">Huffman Tower</a></li>
<li><a href="#" class="demo author cc" data-author="fellerKwan" data-url="Curved/HexSpiralTess.svg">Hex Spiral Tessellation</a></li>
<li><a href="#" class="demo" data-url="Curved/CircularPleat-antiFacet.svg">Circular Pleat</a></li>
<li><a href="#" class="demo author" data-author="sam" data-url="Curved/shell14.svg">14 Panel Shell</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1">Kirigami<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="demo author" data-author="miyamotoHappy" data-url="Kirigami/miyamotoTower.svg">Miyamoto Tower</a></li>
<li><a href="#" class="demo" data-url="Kirigami/honeycombKiri.svg">Kirigami Honeycomb</a></li>
<li><a href="#" class="demo author" data-author="milliron" data-url="Kirigami/auxetic_triangle.svg">Auxetic Triangle Tessellation</a></li>
<li><a href="#" class="demo author" data-author="kreuter" data-url="Kirigami/triPerfTess.svg">Perforated Triangle Tessellation</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1">Popups<span class="pull-right fui-arrow-right"></span></a>
<ul class="dropdown-menu">
<li><a href="#" class="demo author" data-author="ullagami" data-url="Popup/geometricPopup.svg">Geometric Pattern</a></li>
<li><a href="#" class="demo author" data-author="popupology" data-url="Popup/castlePopup.svg">Castle</a></li>
<li><a href="#" class="demo author" data-author="popupology" data-url="Popup/housePopup.svg">House</a></li>