-
Notifications
You must be signed in to change notification settings - Fork 2
/
web3d_projects_20240216.html
2215 lines (2120 loc) · 268 KB
/
web3d_projects_20240216.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-US"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0"><meta name="apple-mobile-web-app-capable" content="yes"><meta http-equiv="X-UA-Compatible" content="ie=edge"><meta property="og:type" content="website"><meta name="twitter:card" content="summary"><style>@media screen{body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button{-webkit-tap-highlight-color:transparent;-webkit-appearance:none;appearance:none;background-color:transparent;border:0;color:inherit;cursor:pointer;font-size:inherit;opacity:.8;outline:none;padding:0;transition:opacity .2s linear}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button:disabled,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button:disabled,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button:disabled,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button:disabled{cursor:not-allowed;opacity:.15!important}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button:hover,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button:hover,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button:hover,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button:hover{opacity:1}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button:hover:active,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button:hover:active,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button:hover:active,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button:hover:active{opacity:.6}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button:hover:not(:disabled),body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button:hover:not(:disabled),body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button:hover:not(:disabled),body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button:hover:not(:disabled){transition:none}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=prev],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=prev],body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button.bespoke-marp-presenter-info-page-prev{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSI1IiBkPSJNNjggOTAgMjggNTBsNDAtNDAiLz48L3N2Zz4=") no-repeat 50%;background-size:contain;overflow:hidden;text-indent:100%;white-space:nowrap}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=next],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=next],body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button.bespoke-marp-presenter-info-page-next{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSI1IiBkPSJtMzIgOTAgNDAtNDAtNDAtNDAiLz48L3N2Zz4=") no-repeat 50%;background-size:contain;overflow:hidden;text-indent:100%;white-space:nowrap}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=fullscreen],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=fullscreen]{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48ZGVmcz48c3R5bGU+LmF7ZmlsbDpub25lO3N0cm9rZTojZmZmO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2Utd2lkdGg6NXB4fTwvc3R5bGU+PC9kZWZzPjxyZWN0IHdpZHRoPSI4MCIgaGVpZ2h0PSI2MCIgeD0iMTAiIHk9IjIwIiBjbGFzcz0iYSIgcng9IjUuNjciLz48cGF0aCBkPSJNNDAgNzBIMjBWNTBtMjAgMEwyMCA3MG00MC00MGgyMHYyMG0tMjAgMCAyMC0yMCIgY2xhc3M9ImEiLz48L3N2Zz4=") no-repeat 50%;background-size:contain;overflow:hidden;text-indent:100%;white-space:nowrap}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button.exit[data-bespoke-marp-osc=fullscreen],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button.exit[data-bespoke-marp-osc=fullscreen]{background-image:url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48ZGVmcz48c3R5bGU+LmF7ZmlsbDpub25lO3N0cm9rZTojZmZmO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2Utd2lkdGg6NXB4fTwvc3R5bGU+PC9kZWZzPjxyZWN0IHdpZHRoPSI4MCIgaGVpZ2h0PSI2MCIgeD0iMTAiIHk9IjIwIiBjbGFzcz0iYSIgcng9IjUuNjciLz48cGF0aCBkPSJNMjAgNTBoMjB2MjBtLTIwIDAgMjAtMjBtNDAgMEg2MFYzMG0yMCAwTDYwIDUwIiBjbGFzcz0iYSIvPjwvc3ZnPg==")}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=presenter],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=presenter]{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSI1IiBkPSJNODcuOCA0Ny41Qzg5IDUwIDg3LjcgNTIgODUgNTJIMzVhOC43IDguNyAwIDAgMS03LjItNC41bC0xNS42LTMxQzExIDE0IDEyLjIgMTIgMTUgMTJoNTBhOC44IDguOCAwIDAgMSA3LjIgNC41ek02MCA1MnYzNm0tMTAgMGgyME00NSA0MmgyMCIvPjwvc3ZnPg==") no-repeat 50%;background-size:contain;overflow:hidden;text-indent:100%;white-space:nowrap}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button.bespoke-marp-presenter-note-bigger{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSI1IiBkPSJNMTIgNTBoODBNNTIgOTBWMTAiLz48L3N2Zz4=") no-repeat 50%;background-size:contain;overflow:hidden;text-indent:100%;white-space:nowrap}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button.bespoke-marp-presenter-note-smaller{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48cGF0aCBmaWxsPSJub25lIiBzdHJva2U9IiNmZmYiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSI1IiBkPSJNMTIgNTBoODAiLz48L3N2Zz4=") no-repeat 50%;background-size:contain;overflow:hidden;text-indent:100%;white-space:nowrap}}@keyframes __bespoke_marp_transition_reduced_outgoing__{0%{opacity:1}to{opacity:0}}@keyframes __bespoke_marp_transition_reduced_incoming__{0%{mix-blend-mode:plus-lighter;opacity:0}to{mix-blend-mode:plus-lighter;opacity:1}}.bespoke-marp-note,.bespoke-marp-osc,.bespoke-progress-parent{display:none;transition:none}@media screen{::view-transition-group(*){animation-duration:var(--marp-bespoke-transition-animation-duration,.5s);animation-timing-function:ease}::view-transition-new(*),::view-transition-old(*){animation-delay:0s;animation-direction:var(--marp-bespoke-transition-animation-direction,normal);animation-duration:var(--marp-bespoke-transition-animation-duration,.5s);animation-fill-mode:both;animation-name:var(--marp-bespoke-transition-animation-name,var(--marp-bespoke-transition-animation-name-fallback,__bespoke_marp_transition_no_animation__));mix-blend-mode:normal}::view-transition-old(*){--marp-bespoke-transition-animation-name-fallback:__bespoke_marp_transition_reduced_outgoing__;animation-timing-function:ease}::view-transition-new(*){--marp-bespoke-transition-animation-name-fallback:__bespoke_marp_transition_reduced_incoming__;animation-timing-function:ease}::view-transition-new(root),::view-transition-old(root){animation-timing-function:linear}::view-transition-new(__bespoke_marp_transition_osc__),::view-transition-old(__bespoke_marp_transition_osc__){animation-duration:0s!important;animation-name:__bespoke_marp_transition_osc__!important}::view-transition-new(__bespoke_marp_transition_osc__){opacity:0!important}.bespoke-marp-transition-warming-up::view-transition-group(*),.bespoke-marp-transition-warming-up::view-transition-new(*),.bespoke-marp-transition-warming-up::view-transition-old(*){animation-play-state:paused!important}body,html{height:100%;margin:0}body{background:#000;overflow:hidden}svg.bespoke-marp-slide{content-visibility:hidden;opacity:0;pointer-events:none;z-index:-1}svg.bespoke-marp-slide:not(.bespoke-marp-active) *{view-transition-name:none!important}svg.bespoke-marp-slide.bespoke-marp-active{content-visibility:visible;opacity:1;pointer-events:auto;z-index:0}svg.bespoke-marp-slide.bespoke-marp-active.bespoke-marp-active-ready *{animation-name:__bespoke_marp__!important}@supports not (content-visibility:hidden){svg.bespoke-marp-slide[data-bespoke-marp-load=hideable]{display:none}svg.bespoke-marp-slide[data-bespoke-marp-load=hideable].bespoke-marp-active{display:block}}}@media screen and (prefers-reduced-motion:reduce){svg.bespoke-marp-slide *{view-transition-name:none!important}}@media screen{[data-bespoke-marp-fragment=inactive]{visibility:hidden}body[data-bespoke-view=""] .bespoke-marp-parent,body[data-bespoke-view=next] .bespoke-marp-parent{inset:0;position:absolute}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc{view-transition-name:__bespoke_marp_transition_osc__;background:rgba(0,0,0,.65);border-radius:7px;bottom:50px;color:#fff;contain:paint;display:block;font-family:Helvetica,Arial,sans-serif;font-size:16px;left:50%;line-height:0;opacity:1;padding:12px;position:absolute;touch-action:manipulation;transform:translateX(-50%);transition:opacity .2s linear;-webkit-user-select:none;user-select:none;white-space:nowrap;will-change:transform;z-index:1}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>*,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>*{margin-left:6px}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>:first-child,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>:first-child{margin-left:0}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>span,body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>span{opacity:.8}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>span[data-bespoke-marp-osc=page],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>span[data-bespoke-marp-osc=page]{display:inline-block;min-width:140px;text-align:center}body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=fullscreen],body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=next],body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=presenter],body[data-bespoke-view=""] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=prev],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=fullscreen],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=next],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=presenter],body[data-bespoke-view=next] .bespoke-marp-parent>.bespoke-marp-osc>button[data-bespoke-marp-osc=prev]{height:32px;line-height:32px;width:32px}body[data-bespoke-view=""] .bespoke-marp-parent.bespoke-marp-inactive,body[data-bespoke-view=next] .bespoke-marp-parent.bespoke-marp-inactive{cursor:none}body[data-bespoke-view=""] .bespoke-marp-parent.bespoke-marp-inactive>.bespoke-marp-osc,body[data-bespoke-view=next] .bespoke-marp-parent.bespoke-marp-inactive>.bespoke-marp-osc{opacity:0;pointer-events:none}body[data-bespoke-view=""] svg.bespoke-marp-slide,body[data-bespoke-view=next] svg.bespoke-marp-slide{height:100%;left:0;position:absolute;top:0;width:100%}body[data-bespoke-view=""] .bespoke-progress-parent{background:#222;display:flex;height:5px;width:100%}body[data-bespoke-view=""] .bespoke-progress-parent+.bespoke-marp-parent{top:5px}body[data-bespoke-view=""] .bespoke-progress-parent .bespoke-progress-bar{background:#0288d1;flex:0 0 0;transition:flex-basis .2s cubic-bezier(0,1,1,1)}body[data-bespoke-view=next]{background:transparent}body[data-bespoke-view=presenter]{background:#161616}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container{display:grid;font-family:Helvetica,Arial,sans-serif;grid-template:"current dragbar next" minmax(140px,1fr) "current dragbar note" 2fr "info dragbar note" 3em;grid-template-columns:minmax(3px,var(--bespoke-marp-presenter-split-ratio,66%)) 0 minmax(3px,1fr);height:100%;left:0;position:absolute;top:0;width:100%}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-parent{grid-area:current;overflow:hidden;position:relative}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-parent svg.bespoke-marp-slide{height:calc(100% - 40px);left:20px;pointer-events:none;position:absolute;top:20px;-webkit-user-select:none;user-select:none;width:calc(100% - 40px)}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-parent svg.bespoke-marp-slide.bespoke-marp-active{filter:drop-shadow(0 3px 10px rgba(0,0,0,.5))}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-dragbar-container{background:#0288d1;cursor:col-resize;grid-area:dragbar;margin-left:-3px;opacity:0;position:relative;transition:opacity .4s linear .1s;width:6px;z-index:10}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-dragbar-container:hover{opacity:1}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-dragbar-container.active{opacity:1;transition-delay:0s}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-next-container{background:#222;cursor:pointer;display:none;grid-area:next;overflow:hidden;position:relative}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-next-container.active{display:block}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-next-container iframe.bespoke-marp-presenter-next{background:transparent;border:0;display:block;filter:drop-shadow(0 3px 10px rgba(0,0,0,.5));height:calc(100% - 40px);left:20px;pointer-events:none;position:absolute;top:20px;-webkit-user-select:none;user-select:none;width:calc(100% - 40px)}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container{background:#222;color:#eee;grid-area:note;position:relative;z-index:1}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container button{height:1.5em;line-height:1.5em;width:1.5em}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-presenter-note-wrapper{display:block;inset:0;position:absolute}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-presenter-note-buttons{background:rgba(0,0,0,.65);border-radius:4px;bottom:0;display:flex;gap:4px;margin:12px;opacity:0;padding:6px;pointer-events:none;position:absolute;right:0;transition:opacity .2s linear}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-presenter-note-buttons:focus-within,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-presenter-note-wrapper:focus-within+.bespoke-marp-presenter-note-buttons,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container:hover .bespoke-marp-presenter-note-buttons{opacity:1;pointer-events:auto}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note{word-wrap:break-word;box-sizing:border-box;font-size:calc(1.1em*var(--bespoke-marp-note-font-scale, 1));height:calc(100% - 40px);margin:20px;overflow:auto;padding-right:3px;scrollbar-color:hsla(0,0%,93%,.5) transparent;scrollbar-width:thin;white-space:pre-wrap;width:calc(100% - 40px)}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note::-webkit-scrollbar{width:6px}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note::-webkit-scrollbar-track{background:transparent}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note::-webkit-scrollbar-thumb{background:hsla(0,0%,93%,.5);border-radius:6px}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note:empty{pointer-events:none}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note.active{display:block}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note p:first-child{margin-top:0}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-note-container .bespoke-marp-note p:last-child{margin-bottom:0}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container{align-items:center;box-sizing:border-box;color:#eee;display:flex;flex-wrap:nowrap;grid-area:info;justify-content:center;overflow:hidden;padding:0 10px}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-page,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-time,body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-timer{box-sizing:border-box;display:block;padding:0 10px;white-space:nowrap;width:100%}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container button{height:1.5em;line-height:1.5em;width:1.5em}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-page{order:2;text-align:center}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-page .bespoke-marp-presenter-info-page-text{display:inline-block;min-width:120px;text-align:center}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-time{color:#999;order:1;text-align:left}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-timer{color:#999;order:3;text-align:right}body[data-bespoke-view=presenter] .bespoke-marp-presenter-container .bespoke-marp-presenter-info-container .bespoke-marp-presenter-info-timer:hover{cursor:pointer}}@media print{.bespoke-marp-presenter-info-container,.bespoke-marp-presenter-next-container,.bespoke-marp-presenter-note-container{display:none}}</style><style>@charset "UTF-8";@import "https://fonts.bunny.net/css?family=Lato:400,900|Roboto+Mono:400,700&display=swap";div#\:\$p>svg>foreignObject>section{width:1280px;height:720px;box-sizing:border-box;overflow:hidden;position:relative;scroll-snap-align:center center}div#\:\$p>svg>foreignObject>section:after{bottom:0;content:attr(data-marpit-pagination);padding:inherit;pointer-events:none;position:absolute;right:0}div#\:\$p>svg>foreignObject>section:not([data-marpit-pagination]):after{display:none}/* Normalization */div#\:\$p>svg>foreignObject>section :is(h1,marp-h1){font-size:2em;margin:0.67em 0}div#\:\$p>svg>foreignObject>section video::-webkit-media-controls{will-change:transform}@page{size:1280px 720px;margin:0}@media print{body,html{background-color:#fff;margin:0;page-break-inside:avoid;break-inside:avoid-page}div#\:\$p>svg>foreignObject>section{page-break-before:always;break-before:page}div#\:\$p>svg>foreignObject>section,div#\:\$p>svg>foreignObject>section *{-webkit-print-color-adjust:exact!important;animation-delay:0s!important;animation-duration:0s!important;color-adjust:exact!important;transition:none!important}div#\:\$p>svg[data-marpit-svg]{display:block;height:100vh;width:100vw}}div#\:\$p>svg>foreignObject>:where(section){container-type:size}div#\:\$p>svg>foreignObject>section img[data-marp-twemoji]{background:transparent;height:1em;margin:0 .05em 0 .1em;vertical-align:-.1em;width:1em}
/*!
* Marp / Marpit Gaia theme.
*
* @theme gaia
* @author Yuki Hattori
*
* @auto-scaling true
* @size 16:9 1280px 720px
* @size 4:3 960px 720px
*/div#\:\$p>svg>foreignObject>section :is(pre,marp-pre) code.hljs{display:block;overflow-x:auto;padding:1em}div#\:\$p>svg>foreignObject>section code.hljs{padding:3px 5px}div#\:\$p>svg>foreignObject>section .hljs{background:#000;color:#f8f8f8}div#\:\$p>svg>foreignObject>section .hljs-comment,div#\:\$p>svg>foreignObject>section .hljs-quote{color:#aeaeae;font-style:italic}div#\:\$p>svg>foreignObject>section .hljs-keyword,div#\:\$p>svg>foreignObject>section .hljs-selector-tag,div#\:\$p>svg>foreignObject>section .hljs-type{color:#e28964}div#\:\$p>svg>foreignObject>section .hljs-string{color:#65b042}div#\:\$p>svg>foreignObject>section .hljs-subst{color:#daefa3}div#\:\$p>svg>foreignObject>section .hljs-link,div#\:\$p>svg>foreignObject>section .hljs-regexp{color:#e9c062}div#\:\$p>svg>foreignObject>section .hljs-name,div#\:\$p>svg>foreignObject>section .hljs-section,div#\:\$p>svg>foreignObject>section .hljs-tag,div#\:\$p>svg>foreignObject>section .hljs-title{color:#89bdff}div#\:\$p>svg>foreignObject>section .hljs-class .hljs-title,div#\:\$p>svg>foreignObject>section .hljs-doctag,div#\:\$p>svg>foreignObject>section .hljs-title.class_{text-decoration:underline}div#\:\$p>svg>foreignObject>section .hljs-bullet,div#\:\$p>svg>foreignObject>section .hljs-number,div#\:\$p>svg>foreignObject>section .hljs-symbol{color:#3387cc}div#\:\$p>svg>foreignObject>section .hljs-params,div#\:\$p>svg>foreignObject>section .hljs-template-variable,div#\:\$p>svg>foreignObject>section .hljs-variable{color:#3e87e3}div#\:\$p>svg>foreignObject>section .hljs-attribute{color:#cda869}div#\:\$p>svg>foreignObject>section .hljs-meta{color:#8996a8}div#\:\$p>svg>foreignObject>section .hljs-formula{background-color:#0e2231;color:#f8f8f8;font-style:italic}div#\:\$p>svg>foreignObject>section .hljs-addition{background-color:#253b22;color:#f8f8f8}div#\:\$p>svg>foreignObject>section .hljs-deletion{background-color:#420e09;color:#f8f8f8}div#\:\$p>svg>foreignObject>section .hljs-selector-class{color:#9b703f}div#\:\$p>svg>foreignObject>section .hljs-selector-id{color:#8b98ab}div#\:\$p>svg>foreignObject>section .hljs-emphasis{font-style:italic}div#\:\$p>svg>foreignObject>section .hljs-strong{font-weight:700}div#\:\$p>svg>foreignObject>section :is(h1,marp-h1),div#\:\$p>svg>foreignObject>section :is(h2,marp-h2),div#\:\$p>svg>foreignObject>section :is(h3,marp-h3),div#\:\$p>svg>foreignObject>section :is(h4,marp-h4),div#\:\$p>svg>foreignObject>section :is(h5,marp-h5),div#\:\$p>svg>foreignObject>section :is(h6,marp-h6){margin:.5em 0 0}div#\:\$p>svg>foreignObject>section :is(h1,marp-h1) strong,div#\:\$p>svg>foreignObject>section :is(h2,marp-h2) strong,div#\:\$p>svg>foreignObject>section :is(h3,marp-h3) strong,div#\:\$p>svg>foreignObject>section :is(h4,marp-h4) strong,div#\:\$p>svg>foreignObject>section :is(h5,marp-h5) strong,div#\:\$p>svg>foreignObject>section :is(h6,marp-h6) strong{font-weight:inherit}div#\:\$p>svg>foreignObject>section :is(h1,marp-h1)::part(auto-scaling),div#\:\$p>svg>foreignObject>section :is(h2,marp-h2)::part(auto-scaling),div#\:\$p>svg>foreignObject>section :is(h3,marp-h3)::part(auto-scaling),div#\:\$p>svg>foreignObject>section :is(h4,marp-h4)::part(auto-scaling),div#\:\$p>svg>foreignObject>section :is(h5,marp-h5)::part(auto-scaling),div#\:\$p>svg>foreignObject>section :is(h6,marp-h6)::part(auto-scaling){max-height:580px}div#\:\$p>svg>foreignObject>section :is(h1,marp-h1){font-size:1.8em}div#\:\$p>svg>foreignObject>section :is(h2,marp-h2){font-size:1.5em}div#\:\$p>svg>foreignObject>section :is(h3,marp-h3){font-size:1.3em}div#\:\$p>svg>foreignObject>section :is(h4,marp-h4){font-size:1.1em}div#\:\$p>svg>foreignObject>section :is(h5,marp-h5){font-size:1em}div#\:\$p>svg>foreignObject>section :is(h6,marp-h6){font-size:.9em}div#\:\$p>svg>foreignObject>section blockquote,div#\:\$p>svg>foreignObject>section p{margin:1em 0 0}div#\:\$p>svg>foreignObject>section ol>li,div#\:\$p>svg>foreignObject>section ul>li{margin:.3em 0 0}div#\:\$p>svg>foreignObject>section ol>li>p,div#\:\$p>svg>foreignObject>section ul>li>p{margin:.6em 0 0}div#\:\$p>svg>foreignObject>section code{display:inline-block;font-family:Roboto Mono,monospace;font-size:.8em;letter-spacing:0;margin:-.1em .15em;padding:.1em .2em;vertical-align:baseline}div#\:\$p>svg>foreignObject>section :is(pre,marp-pre){display:block;margin:1em 0 0;overflow:visible}div#\:\$p>svg>foreignObject>section :is(pre,marp-pre) code{box-sizing:border-box;font-size:.7em;margin:0;min-width:100%;padding:.5em}div#\:\$p>svg>foreignObject>section :is(pre,marp-pre)::part(auto-scaling){max-height:calc(580px - 1em)}div#\:\$p>svg>foreignObject>section blockquote{margin:1em 0 0;padding:0 1em;position:relative}div#\:\$p>svg>foreignObject>section blockquote:after,div#\:\$p>svg>foreignObject>section blockquote:before{content:"“";display:block;font-family:Times New Roman,serif;font-weight:700;position:absolute}div#\:\$p>svg>foreignObject>section blockquote:before{left:0;top:0}div#\:\$p>svg>foreignObject>section blockquote:after{bottom:0;right:0;transform:rotate(180deg)}div#\:\$p>svg>foreignObject>section blockquote>:first-child{margin-top:0}div#\:\$p>svg>foreignObject>section mark{background:transparent}div#\:\$p>svg>foreignObject>section table{border-collapse:collapse;border-spacing:0;margin:1em 0 0}div#\:\$p>svg>foreignObject>section table td,div#\:\$p>svg>foreignObject>section table th{border-style:solid;border-width:1px;padding:.2em .4em}div#\:\$p>svg>foreignObject>section footer,div#\:\$p>svg>foreignObject>section header,div#\:\$p>svg>foreignObject>section:after{box-sizing:border-box;font-size:66%;height:70px;line-height:50px;overflow:hidden;padding:10px 25px;position:absolute}div#\:\$p>svg>foreignObject>section:after{--marpit-root-font-size:66%}div#\:\$p>svg>foreignObject>section header{top:0}div#\:\$p>svg>foreignObject>section footer,div#\:\$p>svg>foreignObject>section header{left:0;right:0}div#\:\$p>svg>foreignObject>section footer{bottom:0}div#\:\$p>svg>foreignObject>section{word-wrap:break-word;--color-background:#fff8e1;--color-background-stripe:rgba(69,90,100,.1);--color-foreground:#455a64;--color-dimmed:#6a7a7d;--color-highlight:#0288d1;background-color:var(--color-background);background-image:linear-gradient(135deg,hsla(0,0%,53%,0),hsla(0,0%,53%,.02) 50%,hsla(0,0%,100%,0) 0,hsla(0,0%,100%,.05));color:var(--color-foreground);font-family:Lato,Avenir Next,Avenir,Trebuchet MS,Segoe UI,sans-serif;font-size:35px;height:720px;letter-spacing:1.25px;line-height:1.35;padding:70px;width:1280px}div#\:\$p>svg>foreignObject>section{--marpit-root-font-size:35px}div#\:\$p>svg>foreignObject>section:after{bottom:0;font-size:80%;right:0}div#\:\$p>svg>foreignObject>section:after{--marpit-root-font-size:80%}div#\:\$p>svg>foreignObject>section a,div#\:\$p>svg>foreignObject>section mark{color:var(--color-highlight)}div#\:\$p>svg>foreignObject>section code{background:var(--color-dimmed);color:var(--color-background)}div#\:\$p>svg>foreignObject>section :is(h1,marp-h1) strong,div#\:\$p>svg>foreignObject>section :is(h2,marp-h2) strong,div#\:\$p>svg>foreignObject>section :is(h3,marp-h3) strong,div#\:\$p>svg>foreignObject>section :is(h4,marp-h4) strong,div#\:\$p>svg>foreignObject>section :is(h5,marp-h5) strong,div#\:\$p>svg>foreignObject>section :is(h6,marp-h6) strong{color:var(--color-highlight)}div#\:\$p>svg>foreignObject>section :is(pre,marp-pre){background:var(--color-foreground)}div#\:\$p>svg>foreignObject>section :is(pre,marp-pre)>code{background:transparent}div#\:\$p>svg>foreignObject>section blockquote:after,div#\:\$p>svg>foreignObject>section blockquote:before,div#\:\$p>svg>foreignObject>section footer,div#\:\$p>svg>foreignObject>section header,div#\:\$p>svg>foreignObject>section section:after{color:var(--color-dimmed)}div#\:\$p>svg>foreignObject>section table td,div#\:\$p>svg>foreignObject>section table th{border-color:var(--color-foreground)}div#\:\$p>svg>foreignObject>section table thead th{background:var(--color-foreground);color:var(--color-background)}div#\:\$p>svg>foreignObject>section table tbody>tr:nth-child(odd) td,div#\:\$p>svg>foreignObject>section table tbody>tr:nth-child(odd) th{background:var(--color-background-stripe,transparent)}div#\:\$p>svg>foreignObject>section>:first-child,div#\:\$p>svg>foreignObject>section>header:first-child+*{margin-top:0}div#\:\$p>svg>foreignObject>section:where(.invert){--color-background:#455a64;--color-background-stripe:rgba(255,248,225,.1);--color-foreground:#fff8e1;--color-dimmed:#dad8c8;--color-highlight:#81d4fa}div#\:\$p>svg>foreignObject>section:where(.gaia){--color-background:#0288d1;--color-background-stripe:rgba(255,248,225,.1);--color-foreground:#fff8e1;--color-dimmed:#cce2de;--color-highlight:#81d4fa}div#\:\$p>svg>foreignObject>section:where(.lead){display:flex;flex-flow:column nowrap;justify-content:center}div#\:\$p>svg>foreignObject>section:where(.lead) :is(h1,marp-h1),div#\:\$p>svg>foreignObject>section:where(.lead) :is(h2,marp-h2),div#\:\$p>svg>foreignObject>section:where(.lead) :is(h3,marp-h3),div#\:\$p>svg>foreignObject>section:where(.lead) :is(h4,marp-h4),div#\:\$p>svg>foreignObject>section:where(.lead) :is(h5,marp-h5),div#\:\$p>svg>foreignObject>section:where(.lead) :is(h6,marp-h6){text-align:center}div#\:\$p>svg>foreignObject>section:where(.lead) p{text-align:center}div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>:is(h1,marp-h1),div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>:is(h2,marp-h2),div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>:is(h3,marp-h3),div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>:is(h4,marp-h4),div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>:is(h5,marp-h5),div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>:is(h6,marp-h6),div#\:\$p>svg>foreignObject>section:where(.lead) blockquote>p{text-align:left}div#\:\$p>svg>foreignObject>section:where(.lead) ol>li>p,div#\:\$p>svg>foreignObject>section:where(.lead) ul>li>p{text-align:left}div#\:\$p>svg>foreignObject>section:where(.lead) table{margin-left:auto;margin-right:auto}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]{columns:initial!important;display:block!important;padding:0!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:before,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:before{display:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]{all:initial;display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container][data-marpit-advanced-background-direction=vertical]{flex-direction:column}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split]>div[data-marpit-advanced-background-container]{width:var(--marpit-advanced-background-split,50%)}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split=right]>div[data-marpit-advanced-background-container]{margin-left:calc(100% - var(--marpit-advanced-background-split, 50%))}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure{all:initial;background-position:center;background-repeat:no-repeat;background-size:cover;flex:auto;margin:0}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure>figcaption{position:absolute;border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content],div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo]{background:transparent!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo],div#\:\$p>svg[data-marpit-svg]>foreignObject[data-marpit-advanced-background=pseudo]{pointer-events:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background-split]{width:100%;height:100%}</style></head><body><div class="bespoke-marp-osc"><button data-bespoke-marp-osc="prev" tabindex="-1" title="Previous slide">Previous slide</button><span data-bespoke-marp-osc="page"></span><button data-bespoke-marp-osc="next" tabindex="-1" title="Next slide">Next slide</button><button data-bespoke-marp-osc="fullscreen" tabindex="-1" title="Toggle fullscreen (f)">Toggle fullscreen</button><button data-bespoke-marp-osc="presenter" tabindex="-1" title="Open presenter view (p)">Open presenter view</button></div><div id=":$p"><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="1" data-background-color="#eee8e9" data-theme="gaia" lang="en-US" style="--background-color:#eee8e9;--theme:gaia;background-color:#eee8e9;background-image:none;">
<h1 id="3d-web-app-creation"><strong>3D Web App Creation</strong></h1>
<p>Fivos Doganis<br />
<a href="mailto:fivos.doganis@gmail.com">fivos.doganis@gmail.com</a></p>
<iframe frameborder="0" scrolling="no" marginheight="0" marginwidth="0" allowfullscreen style=
"position: absolute;
padding-top: 0px;
padding-left: 0px;
margin-top: 0px;
margin-left: 0px;
top: 0px;
bottom: 0px;
left: 0px;
right: 0px;
width: 100%;
height: 100%;
border: 0;
overflow: hidden;
pointer-events: none;
z-index: -1" srcdoc ="
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<video width='1440' height='900' autoplay muted loop>
<source src='https://cdn.epic.net/uploads/2022/07/epic-moments_of_happiness-chill_the_lion-loop-ld.mp4' type='video/mp4'>
<img src='https://cdn.dribbble.com/users/2813/screenshots/2123957/media/984bf5be1f6853bac7a9b9f110e9cc9a.gif'
</video>
</body>
</html>" >
</iframe>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="2" data-theme="gaia" lang="en-US" style="--theme:gaia;">
<h2 id="contents">Contents</h2>
<ul>
<li><img class="emoji" draggable="false" alt="➡️" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/27a1.svg" data-marp-twemoji=""/> <a href="#16"><strong>WebGL</strong></a>
<ul>
<li><a href="#22">Basic</a>, <a href="#62">Advanced</a></li>
<li><a href="#67">Optimizations</a>, <a href="#73">Shaders</a></li>
<li><a href="#79">Other APIs</a>, <a href="#80">WebAssembly</a></li>
</ul>
</li>
<li><img class="emoji" draggable="false" alt="➡️" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/27a1.svg" data-marp-twemoji=""/> <a href="#88"><strong>THREE.js</strong></a>
<ul>
<li><a href="#91">Theory</a></li>
<li><a href="#97">Setup</a></li>
<li><a href="#109">Basic</a>, <a href="#111">Advanced</a>, <a href="#117">Physics</a>, <a href="#118">3D Models</a>, <a href="#119">Editor</a></li>
<li><a href="#123">Projects</a>, <a href="#133">Wrappers</a></li>
</ul>
</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="3" data-footer="cover art : "Chill the lion" by Karim Maaloul https://codepen.io/Yakudoo/details/YXxmYR/" data-theme="gaia" lang="en-US" style="--footer:cover art : "Chill the lion" by Karim Maaloul https://codepen.io/Yakudoo/details/YXxmYR/;--theme:gaia;">
<h1 id="why-use-web-technologies-for-3d">Why use Web technologies for 3D?</h1>
<ul>
<li><strong>mobile</strong> experiences</li>
<li><strong>open</strong> technology stack
<ul>
<li><strong>cross-platform</strong>, no installation, no app store</li>
<li>open source</li>
<li><strong>non-proprietary</strong> (unlike Unity or Unreal Engine)</li>
<li><strong>free</strong></li>
</ul>
</li>
<li>leverage many other existing web APIs</li>
</ul>
<footer>cover art : "Chill the lion" by Karim Maaloul <a href="https://codepen.io/Yakudoo/details/YXxmYR/">https://codepen.io/Yakudoo/details/YXxmYR/</a></footer>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="4" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="4" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="steps">Steps</h1>
<ul>
<li>Run</li>
<li>Debug</li>
<li>Build</li>
<li>Modify</li>
<li>Create</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="5" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="5" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="run-check-your-drivers">Run: check your drivers</h1>
<ul>
<li>Update your graphics card drivers if possible</li>
<li><strong>Linux</strong>: if your GPU is not properly detected, <a href="https://askubuntu.com/questions/206283/how-can-i-uninstall-a-nvidia-driver-completely#206289">uninstall NVIDIA drivers</a> and use the default ones provided by Ubuntu</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">sudo apt-get remove --purge <span class="hljs-string">'^nvidia-.*'</span>
sudo apt-get install ubuntu-desktop
sudo <span class="hljs-built_in">rm</span> /etc/X11/xorg.conf
<span class="hljs-built_in">echo</span> <span class="hljs-string">'nouveau'</span> | sudo <span class="hljs-built_in">tee</span> -a /etc/modules
reboot
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="6" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="6" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="run-testing-on-your-mobile">Run: testing on your mobile</h1>
<ul>
<li>Check that your smartphone can read <a href="https://en.wikipedia.org/wiki/QR_code">QR codes</a></li>
<li>iOS : default Camera app</li>
<li>Android
<ul>
<li>use Google Chrome + scan button</li>
<li>or install a <strong>trustworthy</strong> QR code scanning app like <strong><a href="https://play.google.com/store/apps/details?id=com.trendmicro.qrscan">Trend Micro</a></strong></li>
</ul>
</li>
<li>Other 100% web based alternatives
<ul>
<li>webqr.com</li>
<li>qrcodescan.in</li>
</ul>
</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="7" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="7" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="debug">Debug</h1>
<ul>
<li>There will be bugs :) <img class="emoji" draggable="false" alt="🐛" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/1f41b.svg" data-marp-twemoji=""/></li>
<li>F12</li>
<li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger"><code>debugger</code> statement</a></li>
<li>Tips:
<ul>
<li><a href="https://webglfundamentals.org/webgl/lessons/webgl-setup-and-installation.html">https://webglfundamentals.org/webgl/lessons/webgl-setup-and-installation.html</a></li>
<li><a href="https://threejs.org/manual/en/debugging-javascript.html">https://threejs.org/manual/en/debugging-javascript.html</a></li>
<li><a href="https://www.khronos.org/webgl/wiki/Debugging">https://www.khronos.org/webgl/wiki/Debugging</a></li>
</ul>
</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="8" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="8" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="build-tools">Build: tools</h1>
<ul>
<li>
<p>Web development</p>
<ul>
<li>browser (Firefox, Chrome, Safari Mobile)</li>
<li>Git (optional yet extremely useful)</li>
<li>editor (VSCode), or <a href="https://glitch.com/">Glitch</a> (slow, but no installation needed!)</li>
</ul>
</li>
<li>
<p>Technologies: HTML, JS, CSS, WebGL, THREE.js</p>
</li>
<li>
<p>Optional:</p>
<ul>
<li>OpenStreetMap, OpenLayers, CesiumJS, <a href="https://geoservices.ign.fr/documentation/diffusion/telechargement-donnees-libres.html">Géoservices IGN</a></li>
</ul>
</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="9" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="9" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="browser-installation">Browser installation</h1>
<ul>
<li>Firefox installed by default
<ul>
<li>should be enough!</li>
</ul>
</li>
<li>Chrome
<ul>
<li>to test compatibility as well as some special features</li>
<li>install latest version (97+) on mobile</li>
<li>you may install Chromium on your desktop
<ul>
<li>open-source without proprietary services</li>
</ul>
</li>
</ul>
</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">sudo apt-get install chromium-browser
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="10" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="10" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="git-installation">Git installation</h1>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code>sudo apt-get install git
git config --global user.name "myusername"
git config --global user.email myname@mymailprovider.com
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="11" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="11" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="vscode-installation"><a href="https://linuxize.com/post/how-to-install-visual-studio-code-on-ubuntu-18-04/">VSCode installation</a></h1>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash">sudo apt update
sudo apt install software-properties-common apt-transport-https wget
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository <span class="hljs-string">"deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"</span>
sudo apt install code
</code></pre>
<p><a href="https://unix.stackexchange.com/questions/452020/">Remove GPG warnings</a></p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code>sudo gpgconf --kill dirmngr
sudo chown -R $USER:$USER ~/.gnupg
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="12" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="12" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="customization">Customization</h1>
<ul>
<li>Avoid blinking UI by changing the following setting:</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-bash"><span class="hljs-built_in">set</span> window.titleBarStyle to custom
</code></pre>
<ul>
<li>Recommended extensions
<ul>
<li><a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer">Live Server</a> of <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.live-server">Live Preview</a> (we'll see other alternatives)</li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=mhutchie.git-graph"><strong>Git Graph</strong></a></li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=cesium.gltf-vscode"><strong>glTF Tools</strong></a></li>
<li><a href="https://github.com/racz16/WebGL-GLSL-Editor">WebGL GLSL Editor</a>,</li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=circledev.glsl-canvas">glsl-canvas</a></li>
</ul>
</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-paginate="true" data-class="invert" data-background-color="black" data-theme="gaia" lang="en-US" class="invert" data-marpit-pagination="13" style="--paginate:true;--class:invert;--background-color:black;--theme:gaia;background-color:black;background-image:none;" data-marpit-pagination-total="138" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("https://i.stack.imgur.com/H8fpQ.png");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="13" data-paginate="true" data-class="invert" data-background-color="black" data-theme="gaia" lang="en-US" class="invert" data-marpit-pagination="13" style="--paginate:true;--class:invert;--background-color:black;--theme:gaia;background-color:black;background-image:none;" data-marpit-pagination-total="138" data-marpit-advanced-background="content">
<ul>
<li>File > Settings > Format on Save <img class="emoji" draggable="false" alt="⭐" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/2b50.svg" data-marp-twemoji=""/></li>
</ul>
</section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-paginate="true" data-class="invert" data-background-color="black" data-theme="gaia" lang="en-US" class="invert" data-marpit-pagination="13" style="" data-marpit-pagination-total="138" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="14" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="14" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="development-environment-setup">Development environment setup</h1>
<ul>
<li>Files cannot be loaded from disk without a user action</li>
<li><strong>CORS</strong>: <a href="https://developer.mozilla.org/fr/docs/Web/HTTP/CORS">Cross Origin Resource Sharing</a>
<ul>
<li>one of the many web browser security measures</li>
</ul>
</li>
</ul>
<p><img class="emoji" draggable="false" alt="➡️" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/27a1.svg" data-marp-twemoji=""/> need to run a server like <a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer">Live Server</a>, or:</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-shell"><span class="hljs-meta prompt_">$ </span><span class="language-bash"><span class="hljs-built_in">cd</span> /home/somedir</span>
<span class="hljs-meta prompt_">$ </span><span class="language-bash">python -m SimpleHTTPServer</span>
</code></pre>
<p>And then point your browser at <code>http://localhost:8000</code></p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="15" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="15" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="glitch-online-interactive-editor">Glitch: online interactive editor</h1>
<p><img src="https://aws1.discourse-cdn.com/business6/uploads/glitch/original/2X/6/63bf00cd3adcc2f2d9ee808d52941634f26e01bc.png" alt="" /></p>
<ul>
<li><a href="https://glitch.com/">https://glitch.com/</a></li>
<li><a href="https://glitch.com/~threejs">THREE.js example</a></li>
</ul>
<p>But also <a href="https://vscode.dev">VSCode.dev</a>, Codepen.io, Repl.it etc.</p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="16" data-paginate="true" data-class="invert lead" data-theme="gaia" lang="en-US" class="invert lead" data-marpit-pagination="16" style="--paginate:true;--class:invert lead;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="webgl-exercices">WebGL Exercices</h1>
<p>inspired by</p>
<ul>
<li><a href="http://www.webglacademy.com">webglacademy</a></li>
<li><a href="https://webglfundamentals.org">webglfundamentals</a> <img class="emoji" draggable="false" alt="⭐" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/2b50.svg" data-marp-twemoji=""/></li>
<li><a href="https://webgl2fundamentals.org">webgl2fundamentals</a></li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="17" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="17" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="check-that-webgl-is-supported">Check that WebGL is supported</h1>
<ul>
<li><a href="https://caniuse.com/webgl">https://caniuse.com/webgl</a></li>
<li><a href="https://webglreport.com/">https://webglreport.com/</a></li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="18" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="18" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<p><strong>Reminder</strong>: Minimalistic web page</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-html"><span class="hljs-meta"><!DOCTYPE <span class="hljs-keyword">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">'utf-8'</span>></span>
<span class="hljs-tag"></<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">body</span>></span>
<span class="hljs-tag"></<span class="hljs-name">body</span>></span>
<span class="hljs-tag"></<span class="hljs-name">html</span>></span>
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="19" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="19" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<p><strong>Reminder</strong>: Minimalistic drawing program using the <strong><a href="https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API">Canvas</a></strong> API</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-html"><span class="hljs-meta"><!DOCTYPE <span class="hljs-keyword">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">'utf-8'</span>></span>
<span class="hljs-tag"></<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">body</span>></span>
<span class="hljs-tag"><<span class="hljs-name">canvas</span> <span class="hljs-attr">width</span>=<span class="hljs-string">'640'</span> <span class="hljs-attr">height</span>=<span class="hljs-string">'480'</span>></span><span class="hljs-tag"></<span class="hljs-name">canvas</span>></span>
<span class="hljs-tag"><<span class="hljs-name">script</span>></span><span class="language-javascript">
<span class="hljs-keyword">const</span> canvas = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">querySelector</span>(<span class="hljs-string">'canvas'</span>);
<span class="hljs-keyword">const</span> ctx = canvas.<span class="hljs-title function_">getContext</span>(<span class="hljs-string">'2d'</span>); <span class="hljs-comment">// get 2D rendering context, on which we'll draw</span>
ctx.<span class="hljs-property">fillStyle</span> = <span class="hljs-string">'rgba(255, 0, 0, 1)'</span>; <span class="hljs-comment">// a.k.a. 'red': opaque red</span>
ctx.<span class="hljs-title function_">fillRect</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, canvas.<span class="hljs-property">width</span>, canvas.<span class="hljs-property">height</span>); <span class="hljs-comment">// uses current color</span>
</span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
<span class="hljs-tag"></<span class="hljs-name">body</span>></span>
<span class="hljs-tag"></<span class="hljs-name">html</span>></span>
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="20" data-theme="gaia" lang="en-US" style="--theme:gaia;"><iframe style=
"position: absolute;
top: 110px;
bottom: 110px;
left: 320px;
right: 320px;
width:100%;
height: 100%;
border: 0;" srcdoc ="
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<canvas width='640' height='480'></canvas>
<script>
const canvas = document.querySelector('canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgba(255, 0, 0, 1)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
</script>
</body>
</html>" >
</iframe>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-paginate="true" data-class="invert" data-theme="gaia" lang="en-US" class="invert" data-marpit-pagination="21" style="--paginate:true;--class:invert;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("https://brunoimbrizi.github.io/webexpo-2016/dist/img/history-05.gif");"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="21" data-paginate="true" data-class="invert" data-theme="gaia" lang="en-US" class="invert" data-marpit-pagination="21" style="--paginate:true;--class:invert;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="content">
<h1 id="there-is-also-canvas"><a href="https://brunoimbrizi.github.io/webexpo-2016/dist/">"There Is Also Canvas"</a></h1>
<h2 id="bruno-imbrizi">Bruno Imbrizi</h2>
</section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-paginate="true" data-class="invert" data-theme="gaia" lang="en-US" class="invert" data-marpit-pagination="21" style="" data-marpit-pagination-total="138" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="22" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="22" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<p><strong>Minimalistic WebGL program</strong>: to ensure that everything works fine<br />
<img class="emoji" draggable="false" alt="⚠️" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/26a0.svg" data-marp-twemoji=""/> <strong>no error checks</strong>, for clarity reasons (<em>don't do this at home!</em> <img class="emoji" draggable="false" alt="😉" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/1f609.svg" data-marp-twemoji=""/>)</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-html"><span class="hljs-meta"><!DOCTYPE <span class="hljs-keyword">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">html</span>></span>
<span class="hljs-tag"><<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">'utf-8'</span>></span>
<span class="hljs-tag"></<span class="hljs-name">head</span>></span>
<span class="hljs-tag"><<span class="hljs-name">body</span>></span>
<span class="hljs-tag"><<span class="hljs-name">canvas</span> <span class="hljs-attr">width</span>=<span class="hljs-string">'640'</span> <span class="hljs-attr">height</span>=<span class="hljs-string">'480'</span>></span><span class="hljs-tag"></<span class="hljs-name">canvas</span>></span>
<span class="hljs-tag"><<span class="hljs-name">script</span>></span><span class="language-javascript">
<span class="hljs-keyword">const</span> canvas = <span class="hljs-variable language_">document</span>.<span class="hljs-title function_">querySelector</span>(<span class="hljs-string">'canvas'</span>);
<span class="hljs-comment">/** <span class="hljs-doctag">@type</span> {<span class="hljs-type">WebGLRenderingContext</span>} */</span>
<span class="hljs-keyword">const</span> gl = canvas.<span class="hljs-title function_">getContext</span>(<span class="hljs-string">'webgl'</span>); <span class="hljs-comment">// instead of '2d'</span>
gl.<span class="hljs-title function_">clearColor</span>(<span class="hljs-number">1.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>); <span class="hljs-comment">// RGBA: opaque red</span>
gl.<span class="hljs-title function_">clear</span>(gl.<span class="hljs-property">COLOR_BUFFER_BIT</span>); <span class="hljs-comment">// uses current color (state machine)</span>
</span><span class="hljs-tag"></<span class="hljs-name">script</span>></span>
<span class="hljs-tag"></<span class="hljs-name">body</span>></span>
<span class="hljs-tag"></<span class="hljs-name">html</span>></span>
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="23" data-theme="gaia" lang="en-US" style="--theme:gaia;"><iframe style=
"position: absolute;
top: 110px;
bottom: 110px;
left: 320px;
right: 320px;
width:100%;
height: 100%;
border: 0;" srcdoc ="
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<canvas width='640' height='480'></canvas>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl');
gl.clearColor(1., 0., 0., 1.);
gl.clear(gl.COLOR_BUFFER_BIT);
</script>
</body>
</html>" >
</iframe>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="24" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("https://webglfundamentals.org/webgl/lessons/resources/webglfundamentals-webgl-state-diagram.jpg");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="24" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="24" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="content">
<p><a href="https://webglfundamentals.org/webgl/lessons/resources/webgl-state-diagram.html?exampleId=smallest#no-help">States</a></p>
</section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="24" style="" data-marpit-pagination-total="138" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="25" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="25" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<p><a href="https://webglfundamentals.org/webgl/lessons/webgl-smallest-programs.html"><strong>Minimalistic "useful" program</strong></a>: <strong>shaders</strong>, but no vertex buffer yet</p>
<p>Add this code after <code>gl.clear</code>:</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-comment">// vertex shader</span>
<span class="hljs-keyword">const</span> vs_source = <span class="hljs-string">`
void main() {
gl_Position = vec4(0., 0., 0., 1.); // center
gl_PointSize = 120.0;
}`</span>;
<span class="hljs-comment">// fragment shader</span>
<span class="hljs-keyword">const</span> fs_source = <span class="hljs-string">`
precision mediump float;
void main() {
gl_FragColor = vec4(0., 1., 0., 1.); // green
}`</span>;
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="26" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="26" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<p>Additional code: <a href="https://github.com/gfxfundamentals/webgl-fundamentals/blob/master/webgl/resources/webgl-utils.js">useful functions</a> (still no error checks!)</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-keyword">function</span> <span class="hljs-title function_">buildShader</span>(<span class="hljs-params">gl, shaderSource, shaderType</span>) {
<span class="hljs-keyword">const</span> shader = gl.<span class="hljs-title function_">createShader</span>(shaderType); <span class="hljs-comment">// Create the shader object</span>
gl.<span class="hljs-title function_">shaderSource</span>(shader, shaderSource); <span class="hljs-comment">// Load the shader source</span>
gl.<span class="hljs-title function_">compileShader</span>(shader); <span class="hljs-comment">// Compile the shader</span>
<span class="hljs-keyword">return</span> shader;
}
<span class="hljs-keyword">function</span> <span class="hljs-title function_">createProgram</span>(<span class="hljs-params">gl, shaders</span>) {
<span class="hljs-keyword">const</span> program = gl.<span class="hljs-title function_">createProgram</span>();
shaders.<span class="hljs-title function_">forEach</span>(<span class="hljs-keyword">function</span>(<span class="hljs-params">shader</span>) {
gl.<span class="hljs-title function_">attachShader</span>(program, shader);
});
gl.<span class="hljs-title function_">linkProgram</span>(program);
<span class="hljs-keyword">return</span> program;
}
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="27" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="27" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<p><strong>Finally</strong> : load shaders, program and render</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-comment">// load and compile the shaders</span>
<span class="hljs-keyword">const</span> vs = <span class="hljs-title function_">buildShader</span>(gl, vs_source, gl.<span class="hljs-property">VERTEX_SHADER</span>);
<span class="hljs-keyword">const</span> fs = <span class="hljs-title function_">buildShader</span>(gl, fs_source, gl.<span class="hljs-property">FRAGMENT_SHADER</span>);
<span class="hljs-comment">// Create program on the GPU!</span>
<span class="hljs-keyword">const</span> program = <span class="hljs-title function_">createProgram</span>(gl, [vs, fs]);
<span class="hljs-comment">// Set current program (WebGL is a state machine!)</span>
gl.<span class="hljs-title function_">useProgram</span>(program);
<span class="hljs-comment">// Draw 1 big point, see shaders </span>
<span class="hljs-keyword">const</span> offset = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> count = <span class="hljs-number">1</span>;
gl.<span class="hljs-title function_">drawArrays</span>(gl.<span class="hljs-property">POINTS</span>, offset, count);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="28" data-theme="gaia" lang="en-US" style="--theme:gaia;"><iframe style=
"position: absolute;
top: 110px;
bottom: 110px;
left: 320px;
right: 320px;
width:100%;
height: 100%;
border: 0;" srcdoc ="
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<canvas width='640' height='480'></canvas>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl'); // instead of '2d'
gl.clearColor(1., 0., 0., 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
// vertex shader
const vs_source = `
void main() {
gl_Position = vec4(0., 0., 0., 1.); // center
gl_PointSize = 120.0;
}`;
// fragment shader
const fs_source = `
precision mediump float;
void main() {
gl_FragColor = vec4(0., 1., 0., 1.); // green
}`;
function buildShader(gl, shaderSource, shaderType) {
const shader = gl.createShader(shaderType); // Create the shader object
gl.shaderSource(shader, shaderSource); // Load the shader source
gl.compileShader(shader); // Compile the shader
return shader;
}
function createProgram(gl, shaders) {
const program = gl.createProgram();
shaders.forEach(function(shader) {
gl.attachShader(program, shader);
});
gl.linkProgram(program);
return program;
}
// load and compile the shaders
const vs = buildShader(gl, vs_source, gl.VERTEX_SHADER);
const fs = buildShader(gl, fs_source, gl.FRAGMENT_SHADER);
// setup GLSL program
const program = createProgram(gl, [vs, fs]);
gl.useProgram(program);
// Draw 1 big point, see shaders
const offset = 0;
const count = 1;
gl.drawArrays(gl.POINTS, offset, count);
</script>
</body>
</html>" >
</iframe>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="29" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("https://webglfundamentals.org/webgl/lessons/resources/webglfundamentals-webgl-state-diagram.jpg");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="29" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="29" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="content">
<p><a href="https://webglfundamentals.org/webgl/lessons/resources/webgl-state-diagram.html?exampleId=smallest-glsl#no-help">States</a></p>
</section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="29" style="" data-marpit-pagination-total="138" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-background-color="#000000" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" style="--background-color:#000000;--class:lead invert;--theme:gaia;background-color:#000000;background-image:none;" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("http://webglworkshop.com/presentations/images/iknowwebgl.jpg");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="30" data-background-color="#000000" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" style="--background-color:#000000;--class:lead invert;--theme:gaia;background-color:#000000;background-image:none;" data-marpit-advanced-background="content"></section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-background-color="#000000" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" style="" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-background-color="#000000" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" style="--background-color:#000000;--class:lead invert;--theme:gaia;background-color:#000000;background-image:none;" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("http://webglworkshop.com/presentations/images/showme.jpg");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="31" data-background-color="#000000" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" style="--background-color:#000000;--class:lead invert;--theme:gaia;background-color:#000000;background-image:none;" data-marpit-advanced-background="content"></section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-background-color="#000000" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" style="" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-class="lead" data-theme="gaia" lang="en-US" class="lead" style="--class:lead;--theme:gaia;" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("http://webglworkshop.com/presentations/images/result.gif");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="32" data-class="lead" data-theme="gaia" lang="en-US" class="lead" style="--class:lead;--theme:gaia;" data-marpit-advanced-background="content"></section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-class="lead" data-theme="gaia" lang="en-US" class="lead" style="" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="33" data-paginate="true" data-class="lead invert" data-theme="gaia" lang="en-US" class="lead invert" data-marpit-pagination="33" style="--paginate:true;--class:lead invert;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="my-first-triangle"><a href="http://webglworkshop.com/presentations/Workshop28-webgl2.html">My first triangle</a></h1>
<p>see <a href="https://webglfundamentals.org/webgl/lessons/webgl-fundamentals.html">webglfundamentals</a></p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="34" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="34" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="initialization">Initialization</h1>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="35" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="35" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="1--data">1 . Data</h2>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="36" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="36" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Describe triangle geometry with <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array">Float32Array</a> in <a href="https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/projection-matrix-GPU-rendering-pipeline-clipping.html">clip space</a></li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-keyword">const</span> vertices = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Float32Array</span>([
<span class="hljs-number">0.5</span>, <span class="hljs-number">0.5</span>,
-<span class="hljs-number">0.5</span>, <span class="hljs-number">0.5</span>,
-<span class="hljs-number">0.5</span>, -<span class="hljs-number">0.5</span>]); <span class="hljs-comment">// 2D points: 3 * (x, y) coordinates </span>
</code></pre>
<ul>
<li>Create Vertex Buffer Object (VBO) + <strong>UPLOAD</strong> to the GPU</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-keyword">const</span> vbo = gl.<span class="hljs-title function_">createBuffer</span>(); <span class="hljs-comment">// create Vertex Buffer Object (VBO) id</span>
<span class="hljs-comment">// Set current VBO: bind 'vbo' to the ARRAY_BUFFER bind point,</span>
<span class="hljs-comment">// a global variable internal to WebGL (state machine!)</span>
gl.<span class="hljs-title function_">bindBuffer</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, vbo);
<span class="hljs-comment">// UPLOAD current VBO to GPU, where it will be processed by the shaders</span>
<span class="hljs-comment">// <span class="hljs-doctag">NOTE:</span> STATIC_DRAW: optimization hint for WebGL: our data won't change</span>
gl.<span class="hljs-title function_">bufferData</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, vertices, gl.<span class="hljs-property">STATIC_DRAW</span>);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="37" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="37" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="2--shaders">2 . Shaders</h2>
<p>which will use buffer data</p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="38" data-paginate="true" data-footer="https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html)" data-theme="gaia" lang="en-US" data-marpit-pagination="38" style="--paginate:true;--footer:https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html);--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Vertex Shader: gl_Position will be used by the fragment shader</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-glsl"><span class="hljs-keyword">attribute</span> <span class="hljs-type">vec2</span> a_position; <span class="hljs-comment">// IN, from buffer: 2D point</span>
<span class="hljs-type">void</span> main() {
<span class="hljs-built_in">gl_Position</span> = <span class="hljs-type">vec4</span>(a_position, <span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>); <span class="hljs-comment">// a_position.x, a_position.y, 0, 1, used by the fragment shader</span>
}
</code></pre>
<ul>
<li>Fragment Shader: gl_FragColor is the final fragment color</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-glsl"><span class="hljs-keyword">precision</span> <span class="hljs-keyword">mediump</span> <span class="hljs-type">float</span>; <span class="hljs-comment">// float accuracy: lowp, mediump, highp</span>
<span class="hljs-keyword">uniform</span> <span class="hljs-type">vec4</span> u_color; <span class="hljs-comment">// UNIFORM == CONSTANT for entire shader program</span>
<span class="hljs-type">void</span> main() {
<span class="hljs-built_in">gl_FragColor</span> = u_color; <span class="hljs-comment">// final framebuffer color: RGBA</span>
}
</code></pre>
<footer><a href="https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html">https://webglfundamentals.org/webgl/lessons/webgl-precision-issues.html</a>)</footer>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="39" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="39" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="detecting-shader-compilation-errors">Detecting shader compilation errors</h1>
<p>Call this before <code>gl.useProgram</code> (optional, slow, but often useful <img class="emoji" draggable="false" alt="😉" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/1f609.svg" data-marp-twemoji=""/>)</p>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-keyword">function</span> <span class="hljs-title function_">checkShaders</span>(<span class="hljs-params">gl, vs, fs, program</span>) {
<span class="hljs-keyword">if</span> (!gl.<span class="hljs-title function_">getShaderParameter</span>(vs, gl.<span class="hljs-property">COMPILE_STATUS</span>))
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(gl.<span class="hljs-title function_">getShaderInfoLog</span>(vs));
<span class="hljs-keyword">if</span> (!gl.<span class="hljs-title function_">getShaderParameter</span>(fs, gl.<span class="hljs-property">COMPILE_STATUS</span>))
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(gl.<span class="hljs-title function_">getShaderInfoLog</span>(fs));
<span class="hljs-keyword">if</span> (!gl.<span class="hljs-title function_">getProgramParameter</span>(program, gl.<span class="hljs-property">LINK_STATUS</span>))
<span class="hljs-variable language_">console</span>.<span class="hljs-title function_">error</span>(gl.<span class="hljs-title function_">getProgramInfoLog</span>(program));
}
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="40" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="40" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="3--connecting-buffer-and-shaders">3 . Connecting Buffer and Shaders</h2>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="41" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="41" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>
<p>Retrieve the variables declared in the shaders</p>
<ul>
<li>costly call (like most <code>gl.getXXX</code> calls)</li>
<li>only do this during initialization</li>
<li>will be used during rendering</li>
</ul>
</li>
<li>
<p><img class="emoji" draggable="false" alt="⚠️" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/26a0.svg" data-marp-twemoji=""/> use the exact same name that has been defined in the shader</p>
<ul>
<li>arbitrary name, chosen by the developer! (<code>u_</code> for <code>uniform</code>, <code>a_</code> for <code>attribute</code>, <code>v_</code> for <code>varying</code> are common conventions)</li>
</ul>
</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-comment">// Retrieve 'u_color' shader UNIFORM variable as an id</span>
<span class="hljs-keyword">const</span> u_colorLoc = gl.<span class="hljs-title function_">getUniformLocation</span>(program, <span class="hljs-string">'u_color'</span>);
<span class="hljs-comment">// Retrieve 'a_position' shader ATTRIBUTE variable as an id</span>
<span class="hljs-keyword">const</span> a_positionLoc = gl.<span class="hljs-title function_">getAttribLocation</span>(program, <span class="hljs-string">'a_position'</span>);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="42" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="42" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="4--rendering">4 . Rendering!</h2>
<p>Buffers and Shaders are ready, we still need to:</p>
<ul>
<li>define states</li>
<li>describe buffer layout (often complex since it is very flexible!)</li>
<li>draw the scene</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="43" data-paginate="true" data-footer="https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer" data-theme="gaia" lang="en-US" data-marpit-pagination="43" style="--paginate:true;--footer:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer;--theme:gaia;" data-marpit-pagination-total="138">
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript">gl.<span class="hljs-title function_">clearColor</span>(<span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>); <span class="hljs-comment">// Set current clear color (black)</span>
gl.<span class="hljs-title function_">clear</span>(gl.<span class="hljs-property">COLOR_BUFFER_BIT</span>); <span class="hljs-comment">// Clear the canvas to current color</span>
gl.<span class="hljs-title function_">useProgram</span>(program); <span class="hljs-comment">// Set current program (pair of shaders)</span>
<span class="hljs-comment">// Set the color (constant triangle color, see shader)</span>
gl.<span class="hljs-title function_">uniform4fv</span>(u_colorLoc, [<span class="hljs-number">1.0</span>, <span class="hljs-number">0.0</span>, <span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>]);
<span class="hljs-comment">// Tell WebGL how to take data from the VBO</span>
<span class="hljs-comment">// and supply it to the attribute in the shader.</span>
gl.<span class="hljs-title function_">enableVertexAttribArray</span>(a_positionLoc); <span class="hljs-comment">// Turn the attribute on</span>
gl.<span class="hljs-title function_">bindBuffer</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, vbo); <span class="hljs-comment">// set current vbo</span>
<span class="hljs-comment">// Tell the attribute how to get data out of positionBuffer</span>
<span class="hljs-comment">// (ARRAY_BUFFER)</span>
<span class="hljs-keyword">const</span> size = <span class="hljs-number">2</span>; <span class="hljs-comment">// 2 components per iteration</span>
<span class="hljs-keyword">const</span> type = gl.<span class="hljs-property">FLOAT</span>; <span class="hljs-comment">// the data is 32bit floats</span>
<span class="hljs-keyword">const</span> normalize = <span class="hljs-literal">false</span>; <span class="hljs-comment">// don't normalize the data</span>
<span class="hljs-comment">// stride: 0 = move forward size * sizeof(type) each iteration</span>
<span class="hljs-comment">// to get the next position</span>
<span class="hljs-keyword">const</span> stride = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> offset = <span class="hljs-number">0</span>; <span class="hljs-comment">// start at the beginning of the buffer</span>
gl.<span class="hljs-title function_">vertexAttribPointer</span>(a_positionLoc, size, type, normalize, stride, offset);
</code></pre>
<footer><a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer">https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/vertexAttribPointer</a></footer>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="44" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="44" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Draw: here we'll be using <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/drawArrays"><code>gl.drawArrays</code></a></li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-comment">// primitiveType == gl.TRIANGLES:</span>
<span class="hljs-comment">// each time our vertex shader is run 3 times,</span>
<span class="hljs-comment">// WebGL will draw a triangle</span>
<span class="hljs-comment">// based on the 3 values we set gl_Position to (see shader)</span>
<span class="hljs-keyword">const</span> primitiveType = gl.<span class="hljs-property">TRIANGLES</span>;
<span class="hljs-comment">// Start index of the first vertex</span>
<span class="hljs-comment">// Must be a valid multiple of the size of the given type.</span>
<span class="hljs-keyword">const</span> startIndex = <span class="hljs-number">0</span>;
<span class="hljs-comment">// Execute our vertex shader 3 times,</span>
<span class="hljs-comment">// using 2 elements from the array (see size 2 above)</span>
<span class="hljs-comment">// setting a_position.x and a_position.y</span>
<span class="hljs-keyword">const</span> count = <span class="hljs-number">3</span>;
gl.<span class="hljs-title function_">drawArrays</span>(primitiveType, startIndex, count);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="45" data-class="lead" data-theme="gaia" lang="en-US" class="lead" style="--class:lead;--theme:gaia;"><iframe style=
"position: absolute;
top: 110px;
bottom: 110px;
left: 320px;
right: 320px;
width:100%;
height: 100%;
border: 0;" srcdoc ="
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<canvas width='640' height='480'></canvas>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl'); // instead of '2d'
gl.clearColor(0., 0., 0., 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
// vertex shader
const vs_source = `
attribute vec2 a_position; // in, from buffer: 2D point
void main() {
gl_Position = vec4(a_position, 0.0, 1.0); // a_position.x, a_position.y, 0, 1
}
`;
// fragment shader
const fs_source = `
precision mediump float; // float accuracy: lowp, mediump, highp
uniform vec4 u_color; // UNIFORM == CONSTANT for entire shader program
void main() {
gl_FragColor = u_color; // final framebuffer color: RGBA
}
`;
function buildShader(gl, shaderSource, shaderType) {
const shader = gl.createShader(shaderType); // Create the shader object
gl.shaderSource(shader, shaderSource); // Load the shader source
gl.compileShader(shader); // Compile the shader
return shader;
}
function createProgram(gl, shaders) {
const program = gl.createProgram();
shaders.forEach(function(shader) {
gl.attachShader(program, shader);
});
gl.linkProgram(program);
return program;
}
// load and compile the shaders
const vs = buildShader(gl, vs_source, gl.VERTEX_SHADER);
const fs = buildShader(gl, fs_source, gl.FRAGMENT_SHADER);
// setup GLSL program
const program = createProgram(gl, [vs, fs]);
function checkShaders(gl, vs, fs, program) {
if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) {
console.error(gl.getShaderInfoLog(vs));
}
if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) {
console.error(gl.getShaderInfoLog(fs));
}
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
console.error(gl.getProgramInfoLog(program));
}
}
checkShaders(gl, vs, fs, program);
const vertices = new Float32Array([
0.5, 0.5,
-0.5, 0.5,
-0.5, -0.5]); // 2D points: 3 * (x, y) coordinates
const vbo = gl.createBuffer(); // create Vertex Buffer Object (VBO) id
gl.bindBuffer(gl.ARRAY_BUFFER, vbo); // set current VBO (WebGL is a state machine!)
// UPLOAD current VBO to GPU,
// where it will be processed by the shaders
// NOTE: STATIC_DRAW: hint for WebGL: our data won't change
gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
// Retrieve 'u_color' shader UNIFORM variable as an id
const u_colorLoc = gl.getUniformLocation(program, 'u_color');
// Retrieve 'a_position' shader ATTRIBUTE variable as an id
const a_positionLoc = gl.getAttribLocation(program, 'a_position');
gl.clearColor(0., 0., 0., 1.); // Set current clear color (black)
gl.clear(gl.COLOR_BUFFER_BIT); // Clear the canvas to current color
gl.useProgram(program); // Set current program (pair of shaders)
// Set the color (constant triangle color, see shader)
gl.uniform4fv(u_colorLoc, [1.0, 0.0, 0.0, 1.0]);
// Tell WebGL how to take data from the VBO
// and supply it to the attribute in the shader.
gl.enableVertexAttribArray(a_positionLoc); // Turn the attribute on
gl.bindBuffer(gl.ARRAY_BUFFER, vbo); // set current vbo
// Tell the attribute how to get data out of positionBuffer
// (ARRAY_BUFFER)
const size = 2; // 2 components per iteration
const type = gl.FLOAT; // the data is 32bit floats
const normalize = false; // don't normalize the data
// stride: 0 = move forward size * sizeof(type) each iteration
// to get the next position
const stride = 0;
const offset = 0; // start at the beginning of the buffer
gl.vertexAttribPointer(a_positionLoc, size, type, normalize, stride, offset);
// primitiveType == gl.TRIANGLES:
// each time our vertex shader is run 3 times,
// WebGL will draw a triangle
// based on the 3 values we set gl_Position to (see shader)
const primitiveType = gl.TRIANGLES;
// Start index of the first vertex
const startIndex = 0;
// Execute our vertex shader 3 times,
// using 2 elements from the array (see size 2 above)
// setting a_position.x and a_position.y
const count = 3;
gl.drawArrays(primitiveType, startIndex, count);
</script>
</body>
</html>" >
</iframe>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="46" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="background"><div data-marpit-advanced-background-container="true" data-marpit-advanced-background-direction="horizontal"><figure style="background-image:url("https://webglfundamentals.org/webgl/lessons/resources/webglfundamentals-webgl-state-diagram.jpg");background-size:contain;"></figure></div></section></foreignObject><foreignObject width="1280" height="720"><section id="46" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="46" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138" data-marpit-advanced-background="content">
<p><a href="https://webglfundamentals.org/webgl/lessons/resources/webgl-state-diagram.html?exampleId=rainbow-triangle#no-help">States</a></p>
</section>
</foreignObject><foreignObject width="1280" height="720" data-marpit-advanced-background="pseudo"><section data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="46" style="" data-marpit-pagination-total="138" data-marpit-advanced-background="pseudo"></section></foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="47" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="47" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h1 id="almost-there">Almost there!</h1>
<p>We still need to define one color per vertex instead of the constant <code>uniform</code> color<br />
cf. <a href="https://webglfundamentals.org/webgl/lessons/webgl-how-it-works.html">webglfundamentals</a></p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="48" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="48" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="1--data-1">1 . Data</h2>
<p>adding a color attribute per vertex, with a new array and a new buffer!</p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="49" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="49" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"> <span class="hljs-comment">// 2D points: 3 * (x, y) coordinates </span>
<span class="hljs-comment">// (sqrt(3) / 2 - 0.5) * 640 / 480 == 0.4880338..</span>
<span class="hljs-keyword">const</span> vertices = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Float32Array</span>([-<span class="hljs-number">0.75</span>, -<span class="hljs-number">0.5</span>,
<span class="hljs-number">0.75</span>, -<span class="hljs-number">0.5</span>,
<span class="hljs-number">0.</span>, <span class="hljs-number">0.49</span>]);
<span class="hljs-comment">// create Vertex Buffer Object (VBO) id</span>
<span class="hljs-keyword">const</span> vertexBuffer = gl.<span class="hljs-title function_">createBuffer</span>();
<span class="hljs-comment">// set current VBO (WebGL is a state machine!)</span>
gl.<span class="hljs-title function_">bindBuffer</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, vertexBuffer);
<span class="hljs-comment">// UPLOAD vertexBuffer VBO to GPU,</span>
gl.<span class="hljs-title function_">bufferData</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, vertices, gl.<span class="hljs-property">STATIC_DRAW</span>);
<span class="hljs-comment">// ** NEW **</span>
<span class="hljs-comment">// RGB colors: 3 * (r, g, b, a) values</span>
<span class="hljs-keyword">const</span> colors = <span class="hljs-keyword">new</span> <span class="hljs-title class_">Float32Array</span>([ <span class="hljs-number">1.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>,
<span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>,
<span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>, <span class="hljs-number">1.</span>]);
<span class="hljs-comment">// create Vertex Buffer Object (VBO) id</span>
<span class="hljs-keyword">const</span> colorBuffer = gl.<span class="hljs-title function_">createBuffer</span>();
<span class="hljs-comment">// set current VBO (WebGL is a state machine!)</span>
gl.<span class="hljs-title function_">bindBuffer</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, colorBuffer);
<span class="hljs-comment">// UPLOAD colorBuffer VBO to GPU,</span>
gl.<span class="hljs-title function_">bufferData</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, colors, gl.<span class="hljs-property">STATIC_DRAW</span>);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="50" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="50" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="2--shaders-1">2 . Shaders</h2>
<p>we use the new color attribute that we choose to name <code>a_color</code><br />
(we could name it <code>mylittlevertexcolor</code> but it looks less professional)</p>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="51" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="51" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Vertex Shader: new <code>varying</code> variable, will be <strong>interpolated</strong></li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-glsl"><span class="hljs-keyword">attribute</span> <span class="hljs-type">vec2</span> a_position; <span class="hljs-comment">// IN, from buffer: 2D point</span>
<span class="hljs-keyword">attribute</span> <span class="hljs-type">vec4</span> a_color; <span class="hljs-comment">// IN, from buffer: RGB color</span>
<span class="hljs-keyword">varying</span> <span class="hljs-type">vec4</span> v_color; <span class="hljs-comment">// OUT, to fragment shader</span>
<span class="hljs-type">void</span> main() {
v_color = a_color; <span class="hljs-comment">// color passthrough, sent to fragment shader (interpolated)</span>
<span class="hljs-built_in">gl_Position</span> = <span class="hljs-type">vec4</span>(a_position, <span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>); <span class="hljs-comment">// used by the fragment shader</span>
}
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="52" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="52" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Fragment Shader</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-glsl"><span class="hljs-keyword">precision</span> <span class="hljs-keyword">mediump</span> <span class="hljs-type">float</span>; <span class="hljs-comment">// float accuracy: lowp, mediump, highp</span>
<span class="hljs-keyword">varying</span> <span class="hljs-type">vec4</span> v_color; <span class="hljs-comment">// IN, INTERPOLATED color from vertex shader</span>
<span class="hljs-type">void</span> main() {
<span class="hljs-built_in">gl_FragColor</span> = <span class="hljs-type">vec4</span>(v_color); <span class="hljs-comment">// final framebuffer color: RGBA</span>
}
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="53" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="53" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="3--connecting-buffer-and-shaders-1">3 . Connecting Buffer and Shaders</h2>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="54" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="54" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>
<p>Retrieve the variables declared in the shaders</p>
<ul>
<li>costly call (like most <code>gl.getXXX</code> calls)</li>
<li>only do this during initialization</li>
<li>will be used during rendering</li>
</ul>
</li>
<li>
<p><img class="emoji" draggable="false" alt="⚠️" src="https://cdn.jsdelivr.net/gh/jdecked/twemoji@14.1.2/assets/svg/26a0.svg" data-marp-twemoji=""/> use the exact same name that has been defined in the shader</p>
</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-comment">// Retrieve 'a_color' shader ATTRIBUTE variable as an id</span>
<span class="hljs-keyword">const</span> a_colorLoc = gl.<span class="hljs-title function_">getAttribLocation</span>(program, <span class="hljs-string">'a_color'</span>);
<span class="hljs-comment">// Retrieve 'a_position' shader ATTRIBUTE variable as an id</span>
<span class="hljs-keyword">const</span> a_positionLoc = gl.<span class="hljs-title function_">getAttribLocation</span>(program, <span class="hljs-string">'a_position'</span>);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="55" data-paginate="true" data-class="lead" data-theme="gaia" lang="en-US" class="lead" data-marpit-pagination="55" style="--paginate:true;--class:lead;--theme:gaia;" data-marpit-pagination-total="138">
<h2 id="4--rendering-1">4 . Rendering!</h2>
<p>Buffers and Shaders are ready, we still need to:</p>
<ul>
<li>define states</li>
<li>describe buffer layout (often complex since it is very flexible!)</li>
<li>draw the scene</li>
</ul>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="56" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="56" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"> gl.<span class="hljs-title function_">clearColor</span>(<span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">0.</span>, <span class="hljs-number">1.</span>);
gl.<span class="hljs-title function_">clear</span>(gl.<span class="hljs-property">COLOR_BUFFER_BIT</span>);
gl.<span class="hljs-title function_">useProgram</span>(program); <span class="hljs-comment">// Set current program</span>
{
<span class="hljs-comment">// Turn the attribute on</span>
gl.<span class="hljs-title function_">enableVertexAttribArray</span>(a_positionLoc);
gl.<span class="hljs-title function_">bindBuffer</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, vertexBuffer); <span class="hljs-comment">// set current vbo</span>
<span class="hljs-comment">// Tell the attribute how to get data out of positionBuffer</span>
<span class="hljs-comment">// (ARRAY_BUFFER)</span>
<span class="hljs-keyword">const</span> size = <span class="hljs-number">2</span>; <span class="hljs-comment">// 2 components per iteration</span>
<span class="hljs-keyword">const</span> type = gl.<span class="hljs-property">FLOAT</span>; <span class="hljs-comment">// the data is 32bit floats</span>
<span class="hljs-keyword">const</span> normalize = <span class="hljs-literal">false</span>; <span class="hljs-comment">// don't normalize the data</span>
<span class="hljs-comment">// stride: 0 = move forward size * sizeof(type) each iteration</span>
<span class="hljs-comment">// to get the next position</span>
<span class="hljs-keyword">const</span> stride = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> offset = <span class="hljs-number">0</span>; <span class="hljs-comment">// start at the beginning of the buffer</span>
gl.<span class="hljs-title function_">vertexAttribPointer</span>(a_positionLoc, size, type, normalize, stride, offset);
}
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="57" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="57" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Same steps for <code>colorBuffer</code><br />
<strong>NOTE</strong>: Refactoring! In real life we try and avoid repetition: <a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a></li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript">{
<span class="hljs-comment">// Tell WebGL how to take data from the VBO</span>
<span class="hljs-comment">// and supply it to the attribute in the shader.</span>
gl.<span class="hljs-title function_">enableVertexAttribArray</span>(a_colorLoc); <span class="hljs-comment">// Turn the attribute on</span>
gl.<span class="hljs-title function_">bindBuffer</span>(gl.<span class="hljs-property">ARRAY_BUFFER</span>, colorBuffer);
<span class="hljs-comment">// Tell the color attribute how to get data out of colorBuffer (ARRAY_BUFFER)</span>
<span class="hljs-keyword">const</span> size = <span class="hljs-number">4</span>; <span class="hljs-comment">// <span class="hljs-doctag">NOTE:</span> 4 components per iteration</span>
<span class="hljs-keyword">const</span> type = gl.<span class="hljs-property">FLOAT</span>; <span class="hljs-comment">// the data is 32bit floats</span>
<span class="hljs-keyword">const</span> normalize = <span class="hljs-literal">false</span>; <span class="hljs-comment">// don't normalize the data</span>
<span class="hljs-comment">// stride: 0 = move forward size * sizeof(type) each iteration</span>
<span class="hljs-comment">// to get the next position</span>
<span class="hljs-keyword">const</span> stride = <span class="hljs-number">0</span>;
<span class="hljs-keyword">const</span> offset = <span class="hljs-number">0</span>; <span class="hljs-comment">// start at the beginning of the buffer</span>
gl.<span class="hljs-title function_">vertexAttribPointer</span>( a_colorLoc, size, type, normalize, stride, offset);
}
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="58" data-paginate="true" data-theme="gaia" lang="en-US" data-marpit-pagination="58" style="--paginate:true;--theme:gaia;" data-marpit-pagination-total="138">
<ul>
<li>Draw: same code as before!</li>
</ul>
<pre is="marp-pre" data-auto-scaling="downscale-only"><code class="language-javascript"><span class="hljs-comment">// primitiveType == gl.TRIANGLES:</span>
<span class="hljs-comment">// each time our vertex shader is run 3 times,</span>
<span class="hljs-comment">// WebGL will draw a triangle</span>
<span class="hljs-comment">// based on the 3 values we set gl_Position to (see shader)</span>
<span class="hljs-keyword">const</span> primitiveType = gl.<span class="hljs-property">TRIANGLES</span>;
<span class="hljs-comment">// Start index of the first vertex</span>
<span class="hljs-comment">// Must be a valid multiple of the size of the given type.</span>
<span class="hljs-keyword">const</span> startIndex = <span class="hljs-number">0</span>;
<span class="hljs-comment">// Execute our vertex shader 3 times,</span>
<span class="hljs-comment">// using 2 elements from the array (see size 2 above)</span>
<span class="hljs-comment">// setting a_position.x and a_position.y</span>
<span class="hljs-keyword">const</span> count = <span class="hljs-number">3</span>;
gl.<span class="hljs-title function_">drawArrays</span>(primitiveType, startIndex, count);
</code></pre>
</section>
</foreignObject></svg><svg data-marpit-svg="" viewBox="0 0 1280 720"><foreignObject width="1280" height="720"><section id="59" data-theme="gaia" lang="en-US" style="--theme:gaia;"><iframe style=
"position: absolute;
top: 110px;
bottom: 110px;
left: 320px;
right: 320px;
width:100%;
height: 100%;
border: 0;" srcdoc ="
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<canvas width='640' height='480'></canvas>
<script>
const canvas = document.querySelector('canvas');
const gl = canvas.getContext('webgl'); // instead of '2d'
gl.clearColor(0., 0., 0., 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
// vertex shader
const vs_source = `
attribute vec2 a_position; // IN, from buffer: 2D point
attribute vec3 a_color; // IN, from buffer: RGB color
varying vec3 v_color; // OUT, to fragment shader
void main() {
v_color = a_color; // color passthrough, sent to fragment shader
gl_Position = vec4(a_position, 0.0, 1.0); // used by the fragment shader
}
`;
// fragment shader
const fs_source = `
precision mediump float; // float accuracy: lowp, mediump, highp
varying vec3 v_color; // IN, INTERPOLATED color from vertex shader
void main() {
gl_FragColor = vec4(v_color, 1.); // final framebuffer color: RGBA
}
`;
function buildShader(gl, shaderSource, shaderType) {
const shader = gl.createShader(shaderType); // Create the shader object