├── .gitignore ├── README.md ├── csapp ├── README.md └── code │ ├── README.md │ ├── poc.c │ ├── poc.s │ ├── sum.c │ ├── sum.s │ ├── sys.c │ ├── sys.s │ ├── type.c │ └── type.s ├── essential-cpp ├── README.md └── basics │ ├── READMD.md │ ├── heap.c │ ├── hello.cpp │ ├── ref.cpp │ └── vector.cpp ├── toolchain ├── basics │ ├── README.md │ ├── Stack.h │ ├── StackFunc.c │ ├── StackFunc.s │ ├── StackMain.c │ ├── StackMain.s │ ├── StackType.c │ └── StackType.s └── mk │ ├── .gitignore │ ├── Makefile │ ├── hellofunc.c │ ├── hellomake.c │ └── hellomake.h └── video ├── README.md ├── ffmpeg ├── .gitignore ├── README.md ├── index.html ├── index.js ├── package.json └── yarn.lock ├── input-basics ├── index.html └── index.js ├── kazusa ├── gl-matrix-min.js └── prototype │ ├── README.md │ ├── buffers.js │ ├── canvas │ ├── index.html │ └── main.js │ ├── index.html │ ├── kazusa.mp4 │ ├── main.js │ ├── package.json │ ├── render.js │ ├── sea.mp4 │ ├── shaders.js │ ├── texture.js │ └── video.js ├── openshot ├── .gitignore └── upload.py ├── resources └── wa2.mp4 ├── tasks.md ├── wasm ├── ffmpeg.js ├── ffmpeg.wasm ├── index.html ├── main.js └── worker.js └── webm ├── README.md ├── index.html ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | a.out 2 | a.out.js 3 | .vscode 4 | *.o 5 | .cache 6 | dist 7 | node_modules 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # learn-cs 2 | Resources with basic prototypes. 3 | 4 | ## Content 5 | TODO 6 | -------------------------------------------------------------------------------- /csapp/README.md: -------------------------------------------------------------------------------- 1 | # CSAPP 2 | 3 | Examples learning CSAPP. 4 | -------------------------------------------------------------------------------- /csapp/code/README.md: -------------------------------------------------------------------------------- 1 | ## Compile 2 | 3 | ``` 4 | gcc -S filename.c 5 | ``` 6 | -------------------------------------------------------------------------------- /csapp/code/poc.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | printf("123\n"); 5 | return 0; 6 | } 7 | -------------------------------------------------------------------------------- /csapp/code/poc.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _main 4 | .p2align 4, 0x90 5 | _main: ## @main 6 | .cfi_startproc 7 | ## BB#0: 8 | pushq %rbp 9 | Lcfi0: 10 | .cfi_def_cfa_offset 16 11 | Lcfi1: 12 | .cfi_offset %rbp, -16 13 | movq %rsp, %rbp 14 | Lcfi2: 15 | .cfi_def_cfa_register %rbp 16 | subq $16, %rsp 17 | leaq L_.str(%rip), %rdi 18 | movl $0, -4(%rbp) 19 | movb $0, %al 20 | callq _printf 21 | xorl %ecx, %ecx 22 | movl %eax, -8(%rbp) ## 4-byte Spill 23 | movl %ecx, %eax 24 | addq $16, %rsp 25 | popq %rbp 26 | retq 27 | .cfi_endproc 28 | 29 | .section __TEXT,__cstring,cstring_literals 30 | L_.str: ## @.str 31 | .asciz "123\n" 32 | 33 | 34 | .subsections_via_symbols 35 | -------------------------------------------------------------------------------- /csapp/code/sum.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sum(int x, int y) { 4 | int t = x + y; 5 | return t; 6 | } 7 | 8 | int main() { 9 | int x; 10 | x = sum(2, 3); 11 | printf("%d\n", x); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /csapp/code/sum.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _sum 4 | .p2align 4, 0x90 5 | _sum: ## @sum 6 | .cfi_startproc 7 | ## BB#0: 8 | pushq %rbp 9 | Lcfi0: 10 | .cfi_def_cfa_offset 16 11 | Lcfi1: 12 | .cfi_offset %rbp, -16 13 | movq %rsp, %rbp 14 | Lcfi2: 15 | .cfi_def_cfa_register %rbp 16 | movl %edi, -4(%rbp) 17 | movl %esi, -8(%rbp) 18 | movl -4(%rbp), %esi 19 | addl -8(%rbp), %esi 20 | movl %esi, -12(%rbp) 21 | movl -12(%rbp), %eax 22 | popq %rbp 23 | retq 24 | .cfi_endproc 25 | 26 | .globl _main 27 | .p2align 4, 0x90 28 | _main: ## @main 29 | .cfi_startproc 30 | ## BB#0: 31 | pushq %rbp 32 | Lcfi3: 33 | .cfi_def_cfa_offset 16 34 | Lcfi4: 35 | .cfi_offset %rbp, -16 36 | movq %rsp, %rbp 37 | Lcfi5: 38 | .cfi_def_cfa_register %rbp 39 | subq $16, %rsp 40 | movl $2, %edi 41 | movl $3, %esi 42 | movl $0, -4(%rbp) 43 | callq _sum 44 | leaq L_.str(%rip), %rdi 45 | movl %eax, -8(%rbp) 46 | movl -8(%rbp), %esi 47 | movb $0, %al 48 | callq _printf 49 | xorl %esi, %esi 50 | movl %eax, -12(%rbp) ## 4-byte Spill 51 | movl %esi, %eax 52 | addq $16, %rsp 53 | popq %rbp 54 | retq 55 | .cfi_endproc 56 | 57 | .section __TEXT,__cstring,cstring_literals 58 | L_.str: ## @.str 59 | .asciz "%d\n" 60 | 61 | 62 | .subsections_via_symbols 63 | -------------------------------------------------------------------------------- /csapp/code/sys.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | write(1, "hello world\n", 13); 6 | exit(0); 7 | } 8 | -------------------------------------------------------------------------------- /csapp/code/sys.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _main 4 | .p2align 4, 0x90 5 | _main: ## @main 6 | .cfi_startproc 7 | ## BB#0: 8 | pushq %rbp 9 | Lcfi0: 10 | .cfi_def_cfa_offset 16 11 | Lcfi1: 12 | .cfi_offset %rbp, -16 13 | movq %rsp, %rbp 14 | Lcfi2: 15 | .cfi_def_cfa_register %rbp 16 | subq $16, %rsp 17 | movl $1, %edi 18 | leaq L_.str(%rip), %rsi 19 | movl $13, %eax 20 | movl %eax, %edx 21 | movl $0, -4(%rbp) 22 | callq _write 23 | xorl %edi, %edi 24 | movq %rax, -16(%rbp) ## 8-byte Spill 25 | callq _exit 26 | .cfi_endproc 27 | 28 | .section __TEXT,__cstring,cstring_literals 29 | L_.str: ## @.str 30 | .asciz "hello world\n" 31 | 32 | 33 | .subsections_via_symbols 34 | -------------------------------------------------------------------------------- /csapp/code/type.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct { 5 | int len; 6 | char *data; 7 | } Foo; 8 | 9 | int main() { 10 | Foo foo; 11 | char str[10]; 12 | strcpy(str, "demo"); 13 | foo.len = 4; 14 | foo.data = str; 15 | printf("%d\n%s\n", foo.len, foo.data); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /csapp/code/type.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _main 4 | .p2align 4, 0x90 5 | _main: ## @main 6 | .cfi_startproc 7 | ## BB#0: 8 | pushq %rbp 9 | Lcfi0: 10 | .cfi_def_cfa_offset 16 11 | Lcfi1: 12 | .cfi_offset %rbp, -16 13 | movq %rsp, %rbp 14 | Lcfi2: 15 | .cfi_def_cfa_register %rbp 16 | subq $64, %rsp 17 | leaq L_.str(%rip), %rsi 18 | movl $10, %eax 19 | movl %eax, %edx 20 | leaq -18(%rbp), %rdi 21 | movq ___stack_chk_guard@GOTPCREL(%rip), %rcx 22 | movq (%rcx), %rcx 23 | movq %rcx, -8(%rbp) 24 | movl $0, -24(%rbp) 25 | callq ___strcpy_chk 26 | leaq L_.str.1(%rip), %rdi 27 | leaq -18(%rbp), %rcx 28 | movl $4, -40(%rbp) 29 | movq %rcx, -32(%rbp) 30 | movl -40(%rbp), %esi 31 | movq -32(%rbp), %rdx 32 | movq %rax, -48(%rbp) ## 8-byte Spill 33 | movb $0, %al 34 | callq _printf 35 | movq ___stack_chk_guard@GOTPCREL(%rip), %rcx 36 | movq (%rcx), %rcx 37 | movq -8(%rbp), %rdx 38 | cmpq %rdx, %rcx 39 | movl %eax, -52(%rbp) ## 4-byte Spill 40 | jne LBB0_2 41 | ## BB#1: 42 | xorl %eax, %eax 43 | addq $64, %rsp 44 | popq %rbp 45 | retq 46 | LBB0_2: 47 | callq ___stack_chk_fail 48 | .cfi_endproc 49 | 50 | .section __TEXT,__cstring,cstring_literals 51 | L_.str: ## @.str 52 | .asciz "demo" 53 | 54 | L_.str.1: ## @.str.1 55 | .asciz "%d\n%s\n" 56 | 57 | 58 | .subsections_via_symbols 59 | -------------------------------------------------------------------------------- /essential-cpp/README.md: -------------------------------------------------------------------------------- 1 | # Essential C++ 2 | 3 | Notes learning 《Esstential C++》. 4 | -------------------------------------------------------------------------------- /essential-cpp/basics/READMD.md: -------------------------------------------------------------------------------- 1 | ## Compile 2 | 3 | ``` 4 | clang++ -std=c++11 filename.cpp 5 | ``` 6 | -------------------------------------------------------------------------------- /essential-cpp/basics/heap.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | typedef struct { 5 | float height; 6 | int age; 7 | char *name; 8 | } Person; 9 | 10 | Person *updatePerson(Person *person); 11 | 12 | Person *updatePerson(Person *person) { 13 | Person *newPerson = (Person *)malloc(sizeof(Person)); 14 | newPerson->age = person->age + 1; 15 | newPerson->height = person->height + 1; 16 | newPerson->name = person->name; 17 | return newPerson; 18 | } 19 | 20 | int main(int argc, char *argv[]) { 21 | Person person; 22 | person.age = 20; 23 | person.height = 180.0; 24 | person.name = "Foo"; 25 | 26 | Person *newPerson = updatePerson(&person); 27 | printf("%d %f %s\n", newPerson->age, newPerson->height, newPerson->name); 28 | 29 | free(newPerson); 30 | newPerson = NULL; 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /essential-cpp/basics/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | string user_name; 8 | cout << "Enter first name: "; 9 | cin >> user_name; 10 | cout << "Hello, " << user_name << "!\n"; 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /essential-cpp/basics/ref.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() { 6 | int ival = 1024; 7 | int *pi = &ival; 8 | int &rval = ival; 9 | 10 | cout << *pi; 11 | cout << rval; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /essential-cpp/basics/vector.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace std; 5 | 6 | int main() { 7 | vector fib = {1, 1, 2, 3, 5, 8, 13, 21}; 8 | vector luc = {1, 3, 4, 7, 11, 18, 29, 47}; 9 | vector pel = {1, 2, 5, 12, 29, 70, 169, 408}; 10 | vector tri = {1, 3, 6, 10, 15, 21, 28, 36}; 11 | vector squ = {1, 4, 9, 16, 25, 36, 49, 64}; 12 | vector pen = {1, 5, 12, 22, 35, 51, 70, 92}; 13 | 14 | vector *seq_addr[6] = {&fib, &luc, &pel, &tri, &squ, &pen}; 15 | vector *curr_vec = seq_addr[0]; 16 | int x = curr_vec->at(0); 17 | cout << x; 18 | } 19 | -------------------------------------------------------------------------------- /toolchain/basics/README.md: -------------------------------------------------------------------------------- 1 | # GNU Toolchain 2 | 3 | Practicing [GNU linker](http://sp1.wikidot.com/gnulinker). 4 | 5 | ``` 6 | gcc -I . -c StackType.c -o StackType.o 7 | gcc -I . -c StackFunc.c -o StackFunc.o 8 | gcc -I . -c StackMain.c -o StackMain.o 9 | gcc StackMain.o StackFunc.o StackType.o -o a.out 10 | ./a.out 11 | ``` 12 | -------------------------------------------------------------------------------- /toolchain/basics/Stack.h: -------------------------------------------------------------------------------- 1 | #ifndef _StackType_H_ 2 | #define _StackType_H_ 3 | #define STACK_SIZE 100 4 | 5 | extern int stack[]; 6 | extern int top; 7 | 8 | extern void push(int x); 9 | extern int pop(); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /toolchain/basics/StackFunc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void push(int x) { 5 | assert(top < STACK_SIZE); 6 | stack[top++] = x; 7 | } 8 | 9 | int pop() { 10 | assert(top > 0); 11 | return stack[--top]; 12 | } 13 | -------------------------------------------------------------------------------- /toolchain/basics/StackFunc.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _push 4 | .p2align 4, 0x90 5 | _push: ## @push 6 | .cfi_startproc 7 | ## BB#0: 8 | pushq %rbp 9 | Lcfi0: 10 | .cfi_def_cfa_offset 16 11 | Lcfi1: 12 | .cfi_offset %rbp, -16 13 | movq %rsp, %rbp 14 | Lcfi2: 15 | .cfi_def_cfa_register %rbp 16 | subq $16, %rsp 17 | movq _top@GOTPCREL(%rip), %rax 18 | movl %edi, -4(%rbp) 19 | cmpl $100, (%rax) 20 | setl %cl 21 | xorb $-1, %cl 22 | andb $1, %cl 23 | movzbl %cl, %edi 24 | movslq %edi, %rax 25 | cmpq $0, %rax 26 | je LBB0_2 27 | ## BB#1: 28 | leaq L___func__.push(%rip), %rdi 29 | leaq L_.str(%rip), %rsi 30 | movl $5, %edx 31 | leaq L_.str.1(%rip), %rcx 32 | callq ___assert_rtn 33 | LBB0_2: 34 | jmp LBB0_3 35 | LBB0_3: 36 | movq _stack@GOTPCREL(%rip), %rax 37 | movq _top@GOTPCREL(%rip), %rcx 38 | movl -4(%rbp), %edx 39 | movl (%rcx), %esi 40 | movl %esi, %edi 41 | addl $1, %edi 42 | movl %edi, (%rcx) 43 | movslq %esi, %rcx 44 | movl %edx, (%rax,%rcx,4) 45 | addq $16, %rsp 46 | popq %rbp 47 | retq 48 | .cfi_endproc 49 | 50 | .globl _pop 51 | .p2align 4, 0x90 52 | _pop: ## @pop 53 | .cfi_startproc 54 | ## BB#0: 55 | pushq %rbp 56 | Lcfi3: 57 | .cfi_def_cfa_offset 16 58 | Lcfi4: 59 | .cfi_offset %rbp, -16 60 | movq %rsp, %rbp 61 | Lcfi5: 62 | .cfi_def_cfa_register %rbp 63 | movq _top@GOTPCREL(%rip), %rax 64 | cmpl $0, (%rax) 65 | setg %cl 66 | xorb $-1, %cl 67 | andb $1, %cl 68 | movzbl %cl, %edx 69 | movslq %edx, %rax 70 | cmpq $0, %rax 71 | je LBB1_2 72 | ## BB#1: 73 | leaq L___func__.pop(%rip), %rdi 74 | leaq L_.str(%rip), %rsi 75 | movl $10, %edx 76 | leaq L_.str.2(%rip), %rcx 77 | callq ___assert_rtn 78 | LBB1_2: 79 | jmp LBB1_3 80 | LBB1_3: 81 | movq _stack@GOTPCREL(%rip), %rax 82 | movq _top@GOTPCREL(%rip), %rcx 83 | movl (%rcx), %edx 84 | addl $-1, %edx 85 | movl %edx, (%rcx) 86 | movslq %edx, %rcx 87 | movl (%rax,%rcx,4), %eax 88 | popq %rbp 89 | retq 90 | .cfi_endproc 91 | 92 | .section __TEXT,__cstring,cstring_literals 93 | L___func__.push: ## @__func__.push 94 | .asciz "push" 95 | 96 | L_.str: ## @.str 97 | .asciz "StackFunc.c" 98 | 99 | L_.str.1: ## @.str.1 100 | .asciz "top < STACK_SIZE" 101 | 102 | L___func__.pop: ## @__func__.pop 103 | .asciz "pop" 104 | 105 | L_.str.2: ## @.str.2 106 | .asciz "top > 0" 107 | 108 | 109 | .subsections_via_symbols 110 | -------------------------------------------------------------------------------- /toolchain/basics/StackMain.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() { 5 | int x; 6 | push(3); 7 | x = pop(); 8 | printf("x=%d\n", x); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /toolchain/basics/StackMain.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _main 4 | .p2align 4, 0x90 5 | _main: ## @main 6 | .cfi_startproc 7 | ## BB#0: 8 | pushq %rbp 9 | Lcfi0: 10 | .cfi_def_cfa_offset 16 11 | Lcfi1: 12 | .cfi_offset %rbp, -16 13 | movq %rsp, %rbp 14 | Lcfi2: 15 | .cfi_def_cfa_register %rbp 16 | subq $16, %rsp 17 | movl $3, %edi 18 | movl $0, -4(%rbp) 19 | callq _push 20 | movb $0, %al 21 | callq _pop 22 | leaq L_.str(%rip), %rdi 23 | movl %eax, -8(%rbp) 24 | movl -8(%rbp), %esi 25 | movb $0, %al 26 | callq _printf 27 | xorl %esi, %esi 28 | movl %eax, -12(%rbp) ## 4-byte Spill 29 | movl %esi, %eax 30 | addq $16, %rsp 31 | popq %rbp 32 | retq 33 | .cfi_endproc 34 | 35 | .section __TEXT,__cstring,cstring_literals 36 | L_.str: ## @.str 37 | .asciz "x=%d\n" 38 | 39 | 40 | .subsections_via_symbols 41 | -------------------------------------------------------------------------------- /toolchain/basics/StackType.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int stack[STACK_SIZE]; 4 | int top = 0; 5 | -------------------------------------------------------------------------------- /toolchain/basics/StackType.s: -------------------------------------------------------------------------------- 1 | .section __TEXT,__text,regular,pure_instructions 2 | .macosx_version_min 10, 13 3 | .globl _top ## @top 4 | .zerofill __DATA,__common,_top,4,2 5 | .comm _stack,400,4 ## @stack 6 | 7 | .subsections_via_symbols 8 | -------------------------------------------------------------------------------- /toolchain/mk/.gitignore: -------------------------------------------------------------------------------- 1 | hellomake -------------------------------------------------------------------------------- /toolchain/mk/Makefile: -------------------------------------------------------------------------------- 1 | hellomake: hellomake.c hellofunc.c hellomake.h 2 | gcc -o hellomake hellomake.c hellofunc.c -I. 3 | -------------------------------------------------------------------------------- /toolchain/mk/hellofunc.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | void myPrintHelloMake(void) { 5 | 6 | printf("Hello makefiles!\n"); 7 | 8 | return; 9 | } -------------------------------------------------------------------------------- /toolchain/mk/hellomake.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | // call a function in another file 5 | myPrintHelloMake(); 6 | 7 | return (0); 8 | } 9 | -------------------------------------------------------------------------------- /toolchain/mk/hellomake.h: -------------------------------------------------------------------------------- 1 | /* 2 | example include file 3 | */ 4 | 5 | void myPrintHelloMake(void); 6 | -------------------------------------------------------------------------------- /video/README.md: -------------------------------------------------------------------------------- 1 | # Web Video Demo 2 | 3 | This is a scaffold exploring video in browser. Start static web server in this directory to see examples: 4 | 5 | ``` 6 | npm install -g http-server 7 | http-server 8 | ``` 9 | -------------------------------------------------------------------------------- /video/ffmpeg/.gitignore: -------------------------------------------------------------------------------- 1 | bundle.js 2 | node_modules 3 | -------------------------------------------------------------------------------- /video/ffmpeg/README.md: -------------------------------------------------------------------------------- 1 | # ffmpeg.js POC 2 | 3 | Hacky ffmpeg.js example. Please use yarn to install dependencies. 4 | -------------------------------------------------------------------------------- /video/ffmpeg/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ffmpeg.js Example 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /video/ffmpeg/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | /* global ffmpeg */ 3 | const $btn = document.getElementById('btn') 4 | const $link = document.getElementById('link') 5 | const $video = document.getElementById('video') 6 | 7 | function fetchData (url) { 8 | return new Promise(function (resolve, reject) { 9 | var xhr = new XMLHttpRequest() 10 | xhr.open('GET', url, true) 11 | xhr.responseType = 'arraybuffer' 12 | xhr.onload = function () { 13 | if (this.status >= 200 && this.status < 400) { 14 | resolve(new Uint8Array(this.response)) 15 | } else { 16 | reject(new Error(this.responseText)) 17 | } 18 | } 19 | xhr.onerror = reject 20 | xhr.send() 21 | }) 22 | } 23 | 24 | function encode (file) { 25 | fetchData(file).then(data => { 26 | console.time('encode') 27 | const results = ffmpeg({ 28 | MEMFS: [{ name: 'input.mp4', data }], 29 | stdin: () => {}, 30 | arguments: [ 31 | '-i', 'input.mp4', 32 | 'out.webm' 33 | ] 34 | }) 35 | const videoBlob = new Blob([results.MEMFS[0].data]) 36 | const videoUrl = URL.createObjectURL(videoBlob) 37 | $video.src = videoUrl 38 | $link.href = videoUrl 39 | $link.hidden = false 40 | console.timeEnd('encode') 41 | }) 42 | } 43 | 44 | $btn.addEventListener('click', () => { 45 | encode('../resources/wa2.mp4') 46 | }, false) 47 | -------------------------------------------------------------------------------- /video/ffmpeg/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ffmpeg", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT", 6 | "dependencies": { 7 | "ffmpeg.js": "^3.1.9001" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /video/ffmpeg/yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | ffmpeg.js@^3.1.9001: 6 | version "3.1.9001" 7 | resolved "https://registry.yarnpkg.com/ffmpeg.js/-/ffmpeg.js-3.1.9001.tgz#3569b993027667feea22a2a6dc2b1350fbb9f9c1" 8 | -------------------------------------------------------------------------------- /video/input-basics/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Video Example 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /video/input-basics/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | const input = document.querySelector('input[type="file"]') 3 | const video = document.querySelector('video') 4 | 5 | input.onchange = e => { 6 | const file = input.files && input.files[0] 7 | playFile(file) 8 | } 9 | 10 | function playFile (file) { 11 | if (file) { 12 | const fileReader = new FileReader() 13 | fileReader.onload = evt => { 14 | if (fileReader.readyState === FileReader.DONE) { 15 | video.src = fileReader.result 16 | } else { 17 | console.log('FileReader Error:', evt) 18 | } 19 | } 20 | fileReader.readAsDataURL(file) 21 | } else { 22 | video.src = '' 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /video/kazusa/gl-matrix-min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @fileoverview gl-matrix - High performance matrix and vector operations 3 | * @author Brandon Jones 4 | * @author Colin MacKenzie IV 5 | * @version 2.4.0 6 | */ 7 | 8 | /* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. */ 27 | 28 | !function(t,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var r=n();for(var a in r)("object"==typeof exports?exports:t)[a]=r[a]}}(this,function(){return function(t){function n(a){if(r[a])return r[a].exports;var e=r[a]={i:a,l:!1,exports:{}};return t[a].call(e.exports,e,e.exports,n),e.l=!0,e.exports}var r={};return n.m=t,n.c=r,n.d=function(t,r,a){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:a})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="",n(n.s=4)}([function(t,n,r){"use strict";function a(t){n.ARRAY_TYPE=i=t}function e(t){return t*s}function u(t,n){return Math.abs(t-n)<=o*Math.max(1,Math.abs(t),Math.abs(n))}Object.defineProperty(n,"__esModule",{value:!0}),n.setMatrixArrayType=a,n.toRadian=e,n.equals=u;var o=n.EPSILON=1e-6,i=n.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,s=(n.RANDOM=Math.random,Math.PI/180)},function(t,n,r){"use strict";function a(){var t=new g.ARRAY_TYPE(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function e(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[4],t[4]=n[5],t[5]=n[6],t[6]=n[8],t[7]=n[9],t[8]=n[10],t}function u(t){var n=new g.ARRAY_TYPE(9);return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n}function o(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t}function i(t,n,r,a,e,u,o,i,s){var c=new g.ARRAY_TYPE(9);return c[0]=t,c[1]=n,c[2]=r,c[3]=a,c[4]=e,c[5]=u,c[6]=o,c[7]=i,c[8]=s,c}function s(t,n,r,a,e,u,o,i,s,c){return t[0]=n,t[1]=r,t[2]=a,t[3]=e,t[4]=u,t[5]=o,t[6]=i,t[7]=s,t[8]=c,t}function c(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function f(t,n){if(t===n){var r=n[1],a=n[2],e=n[5];t[1]=n[3],t[2]=n[6],t[3]=r,t[5]=n[7],t[6]=a,t[7]=e}else t[0]=n[0],t[1]=n[3],t[2]=n[6],t[3]=n[1],t[4]=n[4],t[5]=n[7],t[6]=n[2],t[7]=n[5],t[8]=n[8];return t}function M(t,n){var r=n[0],a=n[1],e=n[2],u=n[3],o=n[4],i=n[5],s=n[6],c=n[7],f=n[8],M=f*o-i*c,h=-f*u+i*s,l=c*u-o*s,v=r*M+a*h+e*l;return v?(v=1/v,t[0]=M*v,t[1]=(-f*a+e*c)*v,t[2]=(i*a-e*o)*v,t[3]=h*v,t[4]=(f*r-e*s)*v,t[5]=(-i*r+e*u)*v,t[6]=l*v,t[7]=(-c*r+a*s)*v,t[8]=(o*r-a*u)*v,t):null}function h(t,n){var r=n[0],a=n[1],e=n[2],u=n[3],o=n[4],i=n[5],s=n[6],c=n[7],f=n[8];return t[0]=o*f-i*c,t[1]=e*c-a*f,t[2]=a*i-e*o,t[3]=i*s-u*f,t[4]=r*f-e*s,t[5]=e*u-r*i,t[6]=u*c-o*s,t[7]=a*s-r*c,t[8]=r*o-a*u,t}function l(t){var n=t[0],r=t[1],a=t[2],e=t[3],u=t[4],o=t[5],i=t[6],s=t[7],c=t[8];return n*(c*u-o*s)+r*(-c*e+o*i)+a*(s*e-u*i)}function v(t,n,r){var a=n[0],e=n[1],u=n[2],o=n[3],i=n[4],s=n[5],c=n[6],f=n[7],M=n[8],h=r[0],l=r[1],v=r[2],d=r[3],b=r[4],m=r[5],p=r[6],P=r[7],E=r[8];return t[0]=h*a+l*o+v*c,t[1]=h*e+l*i+v*f,t[2]=h*u+l*s+v*M,t[3]=d*a+b*o+m*c,t[4]=d*e+b*i+m*f,t[5]=d*u+b*s+m*M,t[6]=p*a+P*o+E*c,t[7]=p*e+P*i+E*f,t[8]=p*u+P*s+E*M,t}function d(t,n,r){var a=n[0],e=n[1],u=n[2],o=n[3],i=n[4],s=n[5],c=n[6],f=n[7],M=n[8],h=r[0],l=r[1];return t[0]=a,t[1]=e,t[2]=u,t[3]=o,t[4]=i,t[5]=s,t[6]=h*a+l*o+c,t[7]=h*e+l*i+f,t[8]=h*u+l*s+M,t}function b(t,n,r){var a=n[0],e=n[1],u=n[2],o=n[3],i=n[4],s=n[5],c=n[6],f=n[7],M=n[8],h=Math.sin(r),l=Math.cos(r);return t[0]=l*a+h*o,t[1]=l*e+h*i,t[2]=l*u+h*s,t[3]=l*o-h*a,t[4]=l*i-h*e,t[5]=l*s-h*u,t[6]=c,t[7]=f,t[8]=M,t}function m(t,n,r){var a=r[0],e=r[1];return t[0]=a*n[0],t[1]=a*n[1],t[2]=a*n[2],t[3]=e*n[3],t[4]=e*n[4],t[5]=e*n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t}function p(t,n){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=n[0],t[7]=n[1],t[8]=1,t}function P(t,n){var r=Math.sin(n),a=Math.cos(n);return t[0]=a,t[1]=r,t[2]=0,t[3]=-r,t[4]=a,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function E(t,n){return t[0]=n[0],t[1]=0,t[2]=0,t[3]=0,t[4]=n[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function O(t,n){return t[0]=n[0],t[1]=n[1],t[2]=0,t[3]=n[2],t[4]=n[3],t[5]=0,t[6]=n[4],t[7]=n[5],t[8]=1,t}function x(t,n){var r=n[0],a=n[1],e=n[2],u=n[3],o=r+r,i=a+a,s=e+e,c=r*o,f=a*o,M=a*i,h=e*o,l=e*i,v=e*s,d=u*o,b=u*i,m=u*s;return t[0]=1-M-v,t[3]=f-m,t[6]=h+b,t[1]=f+m,t[4]=1-c-v,t[7]=l-d,t[2]=h-b,t[5]=l+d,t[8]=1-c-M,t}function A(t,n){var r=n[0],a=n[1],e=n[2],u=n[3],o=n[4],i=n[5],s=n[6],c=n[7],f=n[8],M=n[9],h=n[10],l=n[11],v=n[12],d=n[13],b=n[14],m=n[15],p=r*i-a*o,P=r*s-e*o,E=r*c-u*o,O=a*s-e*i,x=a*c-u*i,A=e*c-u*s,q=f*d-M*v,y=f*b-h*v,w=f*m-l*v,R=M*b-h*d,L=M*m-l*d,S=h*m-l*b,_=p*S-P*L+E*R+O*w-x*y+A*q;return _?(_=1/_,t[0]=(i*S-s*L+c*R)*_,t[1]=(s*w-o*S-c*y)*_,t[2]=(o*L-i*w+c*q)*_,t[3]=(e*L-a*S-u*R)*_,t[4]=(r*S-e*w+u*y)*_,t[5]=(a*w-r*L-u*q)*_,t[6]=(d*A-b*x+m*O)*_,t[7]=(b*E-v*A-m*P)*_,t[8]=(v*x-d*E+m*p)*_,t):null}function q(t,n,r){return t[0]=2/n,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function y(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"}function w(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))}function R(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t[3]=n[3]+r[3],t[4]=n[4]+r[4],t[5]=n[5]+r[5],t[6]=n[6]+r[6],t[7]=n[7]+r[7],t[8]=n[8]+r[8],t}function L(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t[3]=n[3]-r[3],t[4]=n[4]-r[4],t[5]=n[5]-r[5],t[6]=n[6]-r[6],t[7]=n[7]-r[7],t[8]=n[8]-r[8],t}function S(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=n[3]*r,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=n[7]*r,t[8]=n[8]*r,t}function _(t,n,r,a){return t[0]=n[0]+r[0]*a,t[1]=n[1]+r[1]*a,t[2]=n[2]+r[2]*a,t[3]=n[3]+r[3]*a,t[4]=n[4]+r[4]*a,t[5]=n[5]+r[5]*a,t[6]=n[6]+r[6]*a,t[7]=n[7]+r[7]*a,t[8]=n[8]+r[8]*a,t}function I(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&t[4]===n[4]&&t[5]===n[5]&&t[6]===n[6]&&t[7]===n[7]&&t[8]===n[8]}function N(t,n){var r=t[0],a=t[1],e=t[2],u=t[3],o=t[4],i=t[5],s=t[6],c=t[7],f=t[8],M=n[0],h=n[1],l=n[2],v=n[3],d=n[4],b=n[5],m=n[6],p=n[7],P=n[8];return Math.abs(r-M)<=g.EPSILON*Math.max(1,Math.abs(r),Math.abs(M))&&Math.abs(a-h)<=g.EPSILON*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(e-l)<=g.EPSILON*Math.max(1,Math.abs(e),Math.abs(l))&&Math.abs(u-v)<=g.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))&&Math.abs(o-d)<=g.EPSILON*Math.max(1,Math.abs(o),Math.abs(d))&&Math.abs(i-b)<=g.EPSILON*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(s-m)<=g.EPSILON*Math.max(1,Math.abs(s),Math.abs(m))&&Math.abs(c-p)<=g.EPSILON*Math.max(1,Math.abs(c),Math.abs(p))&&Math.abs(f-P)<=g.EPSILON*Math.max(1,Math.abs(f),Math.abs(P))}Object.defineProperty(n,"__esModule",{value:!0}),n.sub=n.mul=void 0,n.create=a,n.fromMat4=e,n.clone=u,n.copy=o,n.fromValues=i,n.set=s,n.identity=c,n.transpose=f,n.invert=M,n.adjoint=h,n.determinant=l,n.multiply=v,n.translate=d,n.rotate=b,n.scale=m,n.fromTranslation=p,n.fromRotation=P,n.fromScaling=E,n.fromMat2d=O,n.fromQuat=x,n.normalFromMat4=A,n.projection=q,n.str=y,n.frob=w,n.add=R,n.subtract=L,n.multiplyScalar=S,n.multiplyScalarAndAdd=_,n.exactEquals=I,n.equals=N;var Y=r(0),g=function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n.default=t,n}(Y);n.mul=v,n.sub=L},function(t,n,r){"use strict";function a(){var t=new Z.ARRAY_TYPE(3);return t[0]=0,t[1]=0,t[2]=0,t}function e(t){var n=new Z.ARRAY_TYPE(3);return n[0]=t[0],n[1]=t[1],n[2]=t[2],n}function u(t){var n=t[0],r=t[1],a=t[2];return Math.sqrt(n*n+r*r+a*a)}function o(t,n,r){var a=new Z.ARRAY_TYPE(3);return a[0]=t,a[1]=n,a[2]=r,a}function i(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t}function s(t,n,r,a){return t[0]=n,t[1]=r,t[2]=a,t}function c(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function f(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t}function M(t,n,r){return t[0]=n[0]*r[0],t[1]=n[1]*r[1],t[2]=n[2]*r[2],t}function h(t,n,r){return t[0]=n[0]/r[0],t[1]=n[1]/r[1],t[2]=n[2]/r[2],t}function l(t,n){return t[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t[2]=Math.ceil(n[2]),t}function v(t,n){return t[0]=Math.floor(n[0]),t[1]=Math.floor(n[1]),t[2]=Math.floor(n[2]),t}function d(t,n,r){return t[0]=Math.min(n[0],r[0]),t[1]=Math.min(n[1],r[1]),t[2]=Math.min(n[2],r[2]),t}function b(t,n,r){return t[0]=Math.max(n[0],r[0]),t[1]=Math.max(n[1],r[1]),t[2]=Math.max(n[2],r[2]),t}function m(t,n){return t[0]=Math.round(n[0]),t[1]=Math.round(n[1]),t[2]=Math.round(n[2]),t}function p(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t}function P(t,n,r,a){return t[0]=n[0]+r[0]*a,t[1]=n[1]+r[1]*a,t[2]=n[2]+r[2]*a,t}function E(t,n){var r=n[0]-t[0],a=n[1]-t[1],e=n[2]-t[2];return Math.sqrt(r*r+a*a+e*e)}function O(t,n){var r=n[0]-t[0],a=n[1]-t[1],e=n[2]-t[2];return r*r+a*a+e*e}function x(t){var n=t[0],r=t[1],a=t[2];return n*n+r*r+a*a}function A(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t}function q(t,n){return t[0]=1/n[0],t[1]=1/n[1],t[2]=1/n[2],t}function y(t,n){var r=n[0],a=n[1],e=n[2],u=r*r+a*a+e*e;return u>0&&(u=1/Math.sqrt(u),t[0]=n[0]*u,t[1]=n[1]*u,t[2]=n[2]*u),t}function w(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function R(t,n,r){var a=n[0],e=n[1],u=n[2],o=r[0],i=r[1],s=r[2];return t[0]=e*s-u*i,t[1]=u*o-a*s,t[2]=a*i-e*o,t}function L(t,n,r,a){var e=n[0],u=n[1],o=n[2];return t[0]=e+a*(r[0]-e),t[1]=u+a*(r[1]-u),t[2]=o+a*(r[2]-o),t}function S(t,n,r,a,e,u){var o=u*u,i=o*(2*u-3)+1,s=o*(u-2)+u,c=o*(u-1),f=o*(3-2*u);return t[0]=n[0]*i+r[0]*s+a[0]*c+e[0]*f,t[1]=n[1]*i+r[1]*s+a[1]*c+e[1]*f,t[2]=n[2]*i+r[2]*s+a[2]*c+e[2]*f,t}function _(t,n,r,a,e,u){var o=1-u,i=o*o,s=u*u,c=i*o,f=3*u*i,M=3*s*o,h=s*u;return t[0]=n[0]*c+r[0]*f+a[0]*M+e[0]*h,t[1]=n[1]*c+r[1]*f+a[1]*M+e[1]*h,t[2]=n[2]*c+r[2]*f+a[2]*M+e[2]*h,t}function I(t,n){n=n||1;var r=2*Z.RANDOM()*Math.PI,a=2*Z.RANDOM()-1,e=Math.sqrt(1-a*a)*n;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t[2]=a*n,t}function N(t,n,r){var a=n[0],e=n[1],u=n[2],o=r[3]*a+r[7]*e+r[11]*u+r[15];return o=o||1,t[0]=(r[0]*a+r[4]*e+r[8]*u+r[12])/o,t[1]=(r[1]*a+r[5]*e+r[9]*u+r[13])/o,t[2]=(r[2]*a+r[6]*e+r[10]*u+r[14])/o,t}function Y(t,n,r){var a=n[0],e=n[1],u=n[2];return t[0]=a*r[0]+e*r[3]+u*r[6],t[1]=a*r[1]+e*r[4]+u*r[7],t[2]=a*r[2]+e*r[5]+u*r[8],t}function g(t,n,r){var a=n[0],e=n[1],u=n[2],o=r[0],i=r[1],s=r[2],c=r[3],f=c*a+i*u-s*e,M=c*e+s*a-o*u,h=c*u+o*e-i*a,l=-o*a-i*e-s*u;return t[0]=f*c+l*-o+M*-s-h*-i,t[1]=M*c+l*-i+h*-o-f*-s,t[2]=h*c+l*-s+f*-i-M*-o,t}function T(t,n,r,a){var e=[],u=[];return e[0]=n[0]-r[0],e[1]=n[1]-r[1],e[2]=n[2]-r[2],u[0]=e[0],u[1]=e[1]*Math.cos(a)-e[2]*Math.sin(a),u[2]=e[1]*Math.sin(a)+e[2]*Math.cos(a),t[0]=u[0]+r[0],t[1]=u[1]+r[1],t[2]=u[2]+r[2],t}function j(t,n,r,a){var e=[],u=[];return e[0]=n[0]-r[0],e[1]=n[1]-r[1],e[2]=n[2]-r[2],u[0]=e[2]*Math.sin(a)+e[0]*Math.cos(a),u[1]=e[1],u[2]=e[2]*Math.cos(a)-e[0]*Math.sin(a),t[0]=u[0]+r[0],t[1]=u[1]+r[1],t[2]=u[2]+r[2],t}function D(t,n,r,a){var e=[],u=[];return e[0]=n[0]-r[0],e[1]=n[1]-r[1],e[2]=n[2]-r[2],u[0]=e[0]*Math.cos(a)-e[1]*Math.sin(a),u[1]=e[0]*Math.sin(a)+e[1]*Math.cos(a),u[2]=e[2],t[0]=u[0]+r[0],t[1]=u[1]+r[1],t[2]=u[2]+r[2],t}function V(t,n){var r=o(t[0],t[1],t[2]),a=o(n[0],n[1],n[2]);y(r,r),y(a,a);var e=w(r,a);return e>1?0:e<-1?Math.PI:Math.acos(e)}function z(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function F(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]}function Q(t,n){var r=t[0],a=t[1],e=t[2],u=n[0],o=n[1],i=n[2];return Math.abs(r-u)<=Z.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(a-o)<=Z.EPSILON*Math.max(1,Math.abs(a),Math.abs(o))&&Math.abs(e-i)<=Z.EPSILON*Math.max(1,Math.abs(e),Math.abs(i))}Object.defineProperty(n,"__esModule",{value:!0}),n.forEach=n.sqrLen=n.len=n.sqrDist=n.dist=n.div=n.mul=n.sub=void 0,n.create=a,n.clone=e,n.length=u,n.fromValues=o,n.copy=i,n.set=s,n.add=c,n.subtract=f,n.multiply=M,n.divide=h,n.ceil=l,n.floor=v,n.min=d,n.max=b,n.round=m,n.scale=p,n.scaleAndAdd=P,n.distance=E,n.squaredDistance=O,n.squaredLength=x,n.negate=A,n.inverse=q,n.normalize=y,n.dot=w,n.cross=R,n.lerp=L,n.hermite=S,n.bezier=_,n.random=I,n.transformMat4=N,n.transformMat3=Y,n.transformQuat=g,n.rotateX=T,n.rotateY=j,n.rotateZ=D,n.angle=V,n.str=z,n.exactEquals=F,n.equals=Q;var X=r(0),Z=function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n.default=t,n}(X);n.sub=f,n.mul=M,n.div=h,n.dist=E,n.sqrDist=O,n.len=u,n.sqrLen=x,n.forEach=function(){var t=a();return function(n,r,a,e,u,o){var i=void 0,s=void 0;for(r||(r=3),a||(a=0),s=e?Math.min(e*r+a,n.length):n.length,i=a;i0&&(o=1/Math.sqrt(o),t[0]=r*o,t[1]=a*o,t[2]=e*o,t[3]=u*o),t}function w(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]*n[3]}function R(t,n,r,a){var e=n[0],u=n[1],o=n[2],i=n[3];return t[0]=e+a*(r[0]-e),t[1]=u+a*(r[1]-u),t[2]=o+a*(r[2]-o),t[3]=i+a*(r[3]-i),t}function L(t,n){return n=n||1,t[0]=T.RANDOM(),t[1]=T.RANDOM(),t[2]=T.RANDOM(),t[3]=T.RANDOM(),y(t,t),m(t,t,n),t}function S(t,n,r){var a=n[0],e=n[1],u=n[2],o=n[3];return t[0]=r[0]*a+r[4]*e+r[8]*u+r[12]*o,t[1]=r[1]*a+r[5]*e+r[9]*u+r[13]*o,t[2]=r[2]*a+r[6]*e+r[10]*u+r[14]*o,t[3]=r[3]*a+r[7]*e+r[11]*u+r[15]*o,t}function _(t,n,r){var a=n[0],e=n[1],u=n[2],o=r[0],i=r[1],s=r[2],c=r[3],f=c*a+i*u-s*e,M=c*e+s*a-o*u,h=c*u+o*e-i*a,l=-o*a-i*e-s*u;return t[0]=f*c+l*-o+M*-s-h*-i,t[1]=M*c+l*-i+h*-o-f*-s,t[2]=h*c+l*-s+f*-i-M*-o,t[3]=n[3],t}function I(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}function N(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function Y(t,n){var r=t[0],a=t[1],e=t[2],u=t[3],o=n[0],i=n[1],s=n[2],c=n[3];return Math.abs(r-o)<=T.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(a-i)<=T.EPSILON*Math.max(1,Math.abs(a),Math.abs(i))&&Math.abs(e-s)<=T.EPSILON*Math.max(1,Math.abs(e),Math.abs(s))&&Math.abs(u-c)<=T.EPSILON*Math.max(1,Math.abs(u),Math.abs(c))}Object.defineProperty(n,"__esModule",{value:!0}),n.forEach=n.sqrLen=n.len=n.sqrDist=n.dist=n.div=n.mul=n.sub=void 0,n.create=a,n.clone=e,n.fromValues=u,n.copy=o,n.set=i,n.add=s,n.subtract=c,n.multiply=f,n.divide=M,n.ceil=h,n.floor=l,n.min=v,n.max=d,n.round=b,n.scale=m,n.scaleAndAdd=p,n.distance=P,n.squaredDistance=E,n.length=O,n.squaredLength=x,n.negate=A,n.inverse=q,n.normalize=y,n.dot=w,n.lerp=R,n.random=L,n.transformMat4=S,n.transformQuat=_,n.str=I,n.exactEquals=N,n.equals=Y;var g=r(0),T=function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n.default=t,n}(g);n.sub=c,n.mul=f,n.div=M,n.dist=P,n.sqrDist=E,n.len=O,n.sqrLen=x,n.forEach=function(){var t=a();return function(n,r,a,e,u,o){var i=void 0,s=void 0;for(r||(r=4),a||(a=0),s=e?Math.min(e*r+a,n.length):n.length,i=a;i0?(a=2*Math.sqrt(r+1),t[3]=.25*a,t[0]=(n[6]-n[9])/a,t[1]=(n[8]-n[2])/a,t[2]=(n[1]-n[4])/a):n[0]>n[5]&n[0]>n[10]?(a=2*Math.sqrt(1+n[0]-n[5]-n[10]),t[3]=(n[6]-n[9])/a,t[0]=.25*a,t[1]=(n[1]+n[4])/a,t[2]=(n[8]+n[2])/a):n[5]>n[10]?(a=2*Math.sqrt(1+n[5]-n[0]-n[10]),t[3]=(n[8]-n[2])/a,t[0]=(n[1]+n[4])/a,t[1]=.25*a,t[2]=(n[6]+n[9])/a):(a=2*Math.sqrt(1+n[10]-n[0]-n[5]),t[3]=(n[1]-n[4])/a,t[0]=(n[8]+n[2])/a,t[1]=(n[6]+n[9])/a,t[2]=.25*a),t}function _(t,n,r,a){var e=n[0],u=n[1],o=n[2],i=n[3],s=e+e,c=u+u,f=o+o,M=e*s,h=e*c,l=e*f,v=u*c,d=u*f,b=o*f,m=i*s,p=i*c,P=i*f,E=a[0],O=a[1],x=a[2];return t[0]=(1-(v+b))*E,t[1]=(h+P)*E,t[2]=(l-p)*E,t[3]=0,t[4]=(h-P)*O,t[5]=(1-(M+b))*O,t[6]=(d+m)*O,t[7]=0,t[8]=(l+p)*x,t[9]=(d-m)*x,t[10]=(1-(M+v))*x,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function I(t,n,r,a,e){var u=n[0],o=n[1],i=n[2],s=n[3],c=u+u,f=o+o,M=i+i,h=u*c,l=u*f,v=u*M,d=o*f,b=o*M,m=i*M,p=s*c,P=s*f,E=s*M,O=a[0],x=a[1],A=a[2],q=e[0],y=e[1],w=e[2];return t[0]=(1-(d+m))*O,t[1]=(l+E)*O,t[2]=(v-P)*O,t[3]=0,t[4]=(l-E)*x,t[5]=(1-(h+m))*x,t[6]=(b+p)*x,t[7]=0,t[8]=(v+P)*A,t[9]=(b-p)*A,t[10]=(1-(h+d))*A,t[11]=0,t[12]=r[0]+q-(t[0]*q+t[4]*y+t[8]*w),t[13]=r[1]+y-(t[1]*q+t[5]*y+t[9]*w),t[14]=r[2]+w-(t[2]*q+t[6]*y+t[10]*w),t[15]=1,t}function N(t,n){var r=n[0],a=n[1],e=n[2],u=n[3],o=r+r,i=a+a,s=e+e,c=r*o,f=a*o,M=a*i,h=e*o,l=e*i,v=e*s,d=u*o,b=u*i,m=u*s;return t[0]=1-M-v,t[1]=f+m,t[2]=h-b,t[3]=0,t[4]=f-m,t[5]=1-c-v,t[6]=l+d,t[7]=0,t[8]=h+b,t[9]=l-d,t[10]=1-c-M,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Y(t,n,r,a,e,u,o){var i=1/(r-n),s=1/(e-a),c=1/(u-o);return t[0]=2*u*i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*u*s,t[6]=0,t[7]=0,t[8]=(r+n)*i,t[9]=(e+a)*s,t[10]=(o+u)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*u*2*c,t[15]=0,t}function g(t,n,r,a,e){var u=1/Math.tan(n/2),o=1/(a-e);return t[0]=u/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=u,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(e+a)*o,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*e*a*o,t[15]=0,t}function T(t,n,r,a){var e=Math.tan(n.upDegrees*Math.PI/180),u=Math.tan(n.downDegrees*Math.PI/180),o=Math.tan(n.leftDegrees*Math.PI/180),i=Math.tan(n.rightDegrees*Math.PI/180),s=2/(o+i),c=2/(e+u);return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(o-i)*s*.5,t[9]=(e-u)*c*.5,t[10]=a/(r-a),t[11]=-1,t[12]=0,t[13]=0,t[14]=a*r/(r-a),t[15]=0,t}function j(t,n,r,a,e,u,o){var i=1/(n-r),s=1/(a-e),c=1/(u-o);return t[0]=-2*i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(n+r)*i,t[13]=(e+a)*s,t[14]=(o+u)*c,t[15]=1,t}function D(t,n,r,a){var e=void 0,u=void 0,o=void 0,i=void 0,s=void 0,c=void 0,f=void 0,M=void 0,h=void 0,l=void 0,v=n[0],d=n[1],b=n[2],m=a[0],p=a[1],P=a[2],E=r[0],O=r[1],x=r[2];return Math.abs(v-E)0&&(l=1/Math.sqrt(l),f*=l,M*=l,h*=l);var v=s*h-c*M,d=c*f-i*h,b=i*M-s*f;return t[0]=v,t[1]=d,t[2]=b,t[3]=0,t[4]=M*b-h*d,t[5]=h*v-f*b,t[6]=f*d-M*v,t[7]=0,t[8]=f,t[9]=M,t[10]=h,t[11]=0,t[12]=e,t[13]=u,t[14]=o,t[15]=1,t}function z(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function F(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))}function Q(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t[3]=n[3]+r[3],t[4]=n[4]+r[4],t[5]=n[5]+r[5],t[6]=n[6]+r[6],t[7]=n[7]+r[7],t[8]=n[8]+r[8],t[9]=n[9]+r[9],t[10]=n[10]+r[10],t[11]=n[11]+r[11],t[12]=n[12]+r[12],t[13]=n[13]+r[13],t[14]=n[14]+r[14],t[15]=n[15]+r[15],t}function X(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t[3]=n[3]-r[3],t[4]=n[4]-r[4],t[5]=n[5]-r[5],t[6]=n[6]-r[6],t[7]=n[7]-r[7],t[8]=n[8]-r[8],t[9]=n[9]-r[9],t[10]=n[10]-r[10],t[11]=n[11]-r[11],t[12]=n[12]-r[12],t[13]=n[13]-r[13],t[14]=n[14]-r[14],t[15]=n[15]-r[15],t}function Z(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=n[3]*r,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=n[7]*r,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=n[11]*r,t[12]=n[12]*r,t[13]=n[13]*r,t[14]=n[14]*r,t[15]=n[15]*r,t}function k(t,n,r,a){return t[0]=n[0]+r[0]*a,t[1]=n[1]+r[1]*a,t[2]=n[2]+r[2]*a,t[3]=n[3]+r[3]*a,t[4]=n[4]+r[4]*a,t[5]=n[5]+r[5]*a,t[6]=n[6]+r[6]*a,t[7]=n[7]+r[7]*a,t[8]=n[8]+r[8]*a,t[9]=n[9]+r[9]*a,t[10]=n[10]+r[10]*a,t[11]=n[11]+r[11]*a,t[12]=n[12]+r[12]*a,t[13]=n[13]+r[13]*a,t[14]=n[14]+r[14]*a,t[15]=n[15]+r[15]*a,t}function U(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]&&t[4]===n[4]&&t[5]===n[5]&&t[6]===n[6]&&t[7]===n[7]&&t[8]===n[8]&&t[9]===n[9]&&t[10]===n[10]&&t[11]===n[11]&&t[12]===n[12]&&t[13]===n[13]&&t[14]===n[14]&&t[15]===n[15]}function W(t,n){var r=t[0],a=t[1],e=t[2],u=t[3],o=t[4],i=t[5],s=t[6],c=t[7],f=t[8],M=t[9],h=t[10],l=t[11],v=t[12],d=t[13],b=t[14],m=t[15],p=n[0],P=n[1],E=n[2],O=n[3],x=n[4],A=n[5],q=n[6],y=n[7],w=n[8],R=n[9],L=n[10],S=n[11],_=n[12],I=n[13],N=n[14],Y=n[15];return Math.abs(r-p)<=C.EPSILON*Math.max(1,Math.abs(r),Math.abs(p))&&Math.abs(a-P)<=C.EPSILON*Math.max(1,Math.abs(a),Math.abs(P))&&Math.abs(e-E)<=C.EPSILON*Math.max(1,Math.abs(e),Math.abs(E))&&Math.abs(u-O)<=C.EPSILON*Math.max(1,Math.abs(u),Math.abs(O))&&Math.abs(o-x)<=C.EPSILON*Math.max(1,Math.abs(o),Math.abs(x))&&Math.abs(i-A)<=C.EPSILON*Math.max(1,Math.abs(i),Math.abs(A))&&Math.abs(s-q)<=C.EPSILON*Math.max(1,Math.abs(s),Math.abs(q))&&Math.abs(c-y)<=C.EPSILON*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(f-w)<=C.EPSILON*Math.max(1,Math.abs(f),Math.abs(w))&&Math.abs(M-R)<=C.EPSILON*Math.max(1,Math.abs(M),Math.abs(R))&&Math.abs(h-L)<=C.EPSILON*Math.max(1,Math.abs(h),Math.abs(L))&&Math.abs(l-S)<=C.EPSILON*Math.max(1,Math.abs(l),Math.abs(S))&&Math.abs(v-_)<=C.EPSILON*Math.max(1,Math.abs(v),Math.abs(_))&&Math.abs(d-I)<=C.EPSILON*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(b-N)<=C.EPSILON*Math.max(1,Math.abs(b),Math.abs(N))&&Math.abs(m-Y)<=C.EPSILON*Math.max(1,Math.abs(m),Math.abs(Y))}Object.defineProperty(n,"__esModule",{value:!0}),n.sub=n.mul=void 0,n.create=a,n.clone=e,n.copy=u,n.fromValues=o,n.set=i,n.identity=s,n.transpose=c,n.invert=f,n.adjoint=M,n.determinant=h,n.multiply=l,n.translate=v,n.scale=d,n.rotate=b,n.rotateX=m,n.rotateY=p,n.rotateZ=P,n.fromTranslation=E,n.fromScaling=O,n.fromRotation=x,n.fromXRotation=A,n.fromYRotation=q,n.fromZRotation=y,n.fromRotationTranslation=w,n.getTranslation=R,n.getScaling=L,n.getRotation=S,n.fromRotationTranslationScale=_,n.fromRotationTranslationScaleOrigin=I,n.fromQuat=N,n.frustum=Y,n.perspective=g,n.perspectiveFromFieldOfView=T,n.ortho=j,n.lookAt=D,n.targetTo=V,n.str=z,n.frob=F,n.add=Q,n.subtract=X,n.multiplyScalar=Z,n.multiplyScalarAndAdd=k,n.exactEquals=U,n.equals=W;var B=r(0),C=function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n.default=t,n}(B);n.mul=l,n.sub=X},function(t,n,r){"use strict";function a(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n.default=t,n}function e(){var t=new E.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function u(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function o(t,n,r){r*=.5;var a=Math.sin(r);return t[0]=a*n[0],t[1]=a*n[1],t[2]=a*n[2],t[3]=Math.cos(r),t}function i(t,n){var r=2*Math.acos(n[3]),a=Math.sin(r/2);return 0!=a?(t[0]=n[0]/a,t[1]=n[1]/a,t[2]=n[2]/a):(t[0]=1,t[1]=0,t[2]=0),r}function s(t,n,r){var a=n[0],e=n[1],u=n[2],o=n[3],i=r[0],s=r[1],c=r[2],f=r[3];return t[0]=a*f+o*i+e*c-u*s,t[1]=e*f+o*s+u*i-a*c,t[2]=u*f+o*c+a*s-e*i,t[3]=o*f-a*i-e*s-u*c,t}function c(t,n,r){r*=.5;var a=n[0],e=n[1],u=n[2],o=n[3],i=Math.sin(r),s=Math.cos(r);return t[0]=a*s+o*i,t[1]=e*s+u*i,t[2]=u*s-e*i,t[3]=o*s-a*i,t}function f(t,n,r){r*=.5;var a=n[0],e=n[1],u=n[2],o=n[3],i=Math.sin(r),s=Math.cos(r);return t[0]=a*s-u*i,t[1]=e*s+o*i,t[2]=u*s+a*i,t[3]=o*s-e*i,t}function M(t,n,r){r*=.5;var a=n[0],e=n[1],u=n[2],o=n[3],i=Math.sin(r),s=Math.cos(r);return t[0]=a*s+e*i,t[1]=e*s-a*i,t[2]=u*s+o*i,t[3]=o*s-u*i,t}function h(t,n){var r=n[0],a=n[1],e=n[2];return t[0]=r,t[1]=a,t[2]=e,t[3]=Math.sqrt(Math.abs(1-r*r-a*a-e*e)),t}function l(t,n,r,a){var e=n[0],u=n[1],o=n[2],i=n[3],s=r[0],c=r[1],f=r[2],M=r[3],h=void 0,l=void 0,v=void 0,d=void 0,b=void 0;return l=e*s+u*c+o*f+i*M,l<0&&(l=-l,s=-s,c=-c,f=-f,M=-M),1-l>1e-6?(h=Math.acos(l),v=Math.sin(h),d=Math.sin((1-a)*h)/v,b=Math.sin(a*h)/v):(d=1-a,b=a),t[0]=d*e+b*s,t[1]=d*u+b*c,t[2]=d*o+b*f,t[3]=d*i+b*M,t}function v(t,n){var r=n[0],a=n[1],e=n[2],u=n[3],o=r*r+a*a+e*e+u*u,i=o?1/o:0;return t[0]=-r*i,t[1]=-a*i,t[2]=-e*i,t[3]=u*i,t}function d(t,n){return t[0]=-n[0],t[1]=-n[1],t[2]=-n[2],t[3]=n[3],t}function b(t,n){var r=n[0]+n[4]+n[8],a=void 0;if(r>0)a=Math.sqrt(r+1),t[3]=.5*a,a=.5/a,t[0]=(n[5]-n[7])*a,t[1]=(n[6]-n[2])*a,t[2]=(n[1]-n[3])*a;else{var e=0;n[4]>n[0]&&(e=1),n[8]>n[3*e+e]&&(e=2);var u=(e+1)%3,o=(e+2)%3;a=Math.sqrt(n[3*e+e]-n[3*u+u]-n[3*o+o]+1),t[e]=.5*a,a=.5/a,t[3]=(n[3*u+o]-n[3*o+u])*a,t[u]=(n[3*u+e]+n[3*e+u])*a,t[o]=(n[3*o+e]+n[3*e+o])*a}return t}function m(t,n,r,a){var e=.5*Math.PI/180;n*=e,r*=e,a*=e;var u=Math.sin(n),o=Math.cos(n),i=Math.sin(r),s=Math.cos(r),c=Math.sin(a),f=Math.cos(a);return t[0]=u*s*f-o*i*c,t[1]=o*i*f+u*s*c,t[2]=o*s*c-u*i*f,t[3]=o*s*f+u*i*c,t}function p(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"}Object.defineProperty(n,"__esModule",{value:!0}),n.setAxes=n.sqlerp=n.rotationTo=n.equals=n.exactEquals=n.normalize=n.sqrLen=n.squaredLength=n.len=n.length=n.lerp=n.dot=n.scale=n.mul=n.add=n.set=n.copy=n.fromValues=n.clone=void 0,n.create=e,n.identity=u,n.setAxisAngle=o,n.getAxisAngle=i,n.multiply=s,n.rotateX=c,n.rotateY=f,n.rotateZ=M,n.calculateW=h,n.slerp=l,n.invert=v,n.conjugate=d,n.fromMat3=b,n.fromEuler=m,n.str=p;var P=r(0),E=a(P),O=r(1),x=a(O),A=r(2),q=a(A),y=r(3),w=a(y),R=(n.clone=w.clone,n.fromValues=w.fromValues,n.copy=w.copy,n.set=w.set,n.add=w.add,n.mul=s,n.scale=w.scale,n.dot=w.dot,n.lerp=w.lerp,n.length=w.length),L=(n.len=R,n.squaredLength=w.squaredLength),S=(n.sqrLen=L,n.normalize=w.normalize);n.exactEquals=w.exactEquals,n.equals=w.equals,n.rotationTo=function(){var t=q.create(),n=q.fromValues(1,0,0),r=q.fromValues(0,1,0);return function(a,e,u){var i=q.dot(e,u);return i<-.999999?(q.cross(t,n,e),q.len(t)<1e-6&&q.cross(t,r,e),q.normalize(t,t),o(a,t,Math.PI),a):i>.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(q.cross(t,e,u),a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=1+i,S(a,a))}}(),n.sqlerp=function(){var t=e(),n=e();return function(r,a,e,u,o,i){return l(t,a,o,i),l(n,e,u,i),l(r,t,n,2*i*(1-i)),r}}(),n.setAxes=function(){var t=x.create();return function(n,r,a,e){return t[0]=a[0],t[3]=a[1],t[6]=a[2],t[1]=e[0],t[4]=e[1],t[7]=e[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],S(n,b(n,t))}}()},function(t,n,r){"use strict";function a(){var t=new V.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t}function e(t){var n=new V.ARRAY_TYPE(2);return n[0]=t[0],n[1]=t[1],n}function u(t,n){var r=new V.ARRAY_TYPE(2);return r[0]=t,r[1]=n,r}function o(t,n){return t[0]=n[0],t[1]=n[1],t}function i(t,n,r){return t[0]=n,t[1]=r,t}function s(t,n,r){return t[0]=n[0]+r[0],t[1]=n[1]+r[1],t}function c(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t}function f(t,n,r){return t[0]=n[0]*r[0],t[1]=n[1]*r[1],t}function M(t,n,r){return t[0]=n[0]/r[0],t[1]=n[1]/r[1],t}function h(t,n){return t[0]=Math.ceil(n[0]),t[1]=Math.ceil(n[1]),t}function l(t,n){return t[0]=Math.floor(n[0]),t[1]=Math.floor(n[1]),t}function v(t,n,r){return t[0]=Math.min(n[0],r[0]),t[1]=Math.min(n[1],r[1]),t}function d(t,n,r){return t[0]=Math.max(n[0],r[0]),t[1]=Math.max(n[1],r[1]),t}function b(t,n){return t[0]=Math.round(n[0]),t[1]=Math.round(n[1]),t}function m(t,n,r){return t[0]=n[0]*r,t[1]=n[1]*r,t}function p(t,n,r,a){return t[0]=n[0]+r[0]*a,t[1]=n[1]+r[1]*a,t}function P(t,n){var r=n[0]-t[0],a=n[1]-t[1];return Math.sqrt(r*r+a*a)}function E(t,n){var r=n[0]-t[0],a=n[1]-t[1];return r*r+a*a}function O(t){var n=t[0],r=t[1];return Math.sqrt(n*n+r*r)}function x(t){var n=t[0],r=t[1];return n*n+r*r}function A(t,n){return t[0]=-n[0],t[1]=-n[1],t}function q(t,n){return t[0]=1/n[0],t[1]=1/n[1],t}function y(t,n){var r=n[0],a=n[1],e=r*r+a*a;return e>0&&(e=1/Math.sqrt(e),t[0]=n[0]*e,t[1]=n[1]*e),t}function w(t,n){return t[0]*n[0]+t[1]*n[1]}function R(t,n,r){var a=n[0]*r[1]-n[1]*r[0];return t[0]=t[1]=0,t[2]=a,t}function L(t,n,r,a){var e=n[0],u=n[1];return t[0]=e+a*(r[0]-e),t[1]=u+a*(r[1]-u),t}function S(t,n){n=n||1;var r=2*V.RANDOM()*Math.PI;return t[0]=Math.cos(r)*n,t[1]=Math.sin(r)*n,t}function _(t,n,r){var a=n[0],e=n[1];return t[0]=r[0]*a+r[2]*e,t[1]=r[1]*a+r[3]*e,t}function I(t,n,r){var a=n[0],e=n[1];return t[0]=r[0]*a+r[2]*e+r[4],t[1]=r[1]*a+r[3]*e+r[5],t}function N(t,n,r){var a=n[0],e=n[1];return t[0]=r[0]*a+r[3]*e+r[6],t[1]=r[1]*a+r[4]*e+r[7],t}function Y(t,n,r){var a=n[0],e=n[1];return t[0]=r[0]*a+r[4]*e+r[12],t[1]=r[1]*a+r[5]*e+r[13],t}function g(t){return"vec2("+t[0]+", "+t[1]+")"}function T(t,n){return t[0]===n[0]&&t[1]===n[1]}function j(t,n){var r=t[0],a=t[1],e=n[0],u=n[1];return Math.abs(r-e)<=V.EPSILON*Math.max(1,Math.abs(r),Math.abs(e))&&Math.abs(a-u)<=V.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))}Object.defineProperty(n,"__esModule",{value:!0}),n.forEach=n.sqrLen=n.sqrDist=n.dist=n.div=n.mul=n.sub=n.len=void 0,n.create=a,n.clone=e,n.fromValues=u,n.copy=o,n.set=i,n.add=s,n.subtract=c,n.multiply=f,n.divide=M,n.ceil=h,n.floor=l,n.min=v,n.max=d,n.round=b,n.scale=m,n.scaleAndAdd=p,n.distance=P,n.squaredDistance=E,n.length=O,n.squaredLength=x,n.negate=A,n.inverse=q,n.normalize=y,n.dot=w,n.cross=R,n.lerp=L,n.random=S,n.transformMat2=_,n.transformMat2d=I,n.transformMat3=N,n.transformMat4=Y,n.str=g,n.exactEquals=T,n.equals=j;var D=r(0),V=function(t){if(t&&t.__esModule)return t;var n={};if(null!=t)for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r]);return n.default=t,n}(D);n.len=O,n.sub=c,n.mul=f,n.div=M,n.dist=P,n.sqrDist=E,n.sqrLen=x,n.forEach=function(){var t=a();return function(n,r,a,e,u,o){var i=void 0,s=void 0;for(r||(r=2),a||(a=0),s=e?Math.min(e*r+a,n.length):n.length,i=a;i 2 | 3 | 4 | Canvas Video Demo 5 | 6 | 11 | 12 | 14 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /video/kazusa/prototype/canvas/main.js: -------------------------------------------------------------------------------- 1 | function main () { 2 | const videoA = document.getElementById('video-a') 3 | const videoB = document.getElementById('video-b') 4 | 5 | const tmpA = document.getElementById('tmp-a') 6 | const tmpACtx = tmpA.getContext('2d') 7 | 8 | const tmpB = document.getElementById('tmp-b') 9 | const tmpBCtx = tmpA.getContext('2d') 10 | 11 | const resultCanvas = document.getElementById('result') 12 | const resultCtx = resultCanvas.getContext('2d') 13 | 14 | function composite () { 15 | tmpACtx.drawImage(videoA, 0, 0, tmpA.width, tmpA.height) 16 | const pixelsA = tmpACtx.getImageData(0, 0, tmpA.width, tmpA.height) 17 | 18 | tmpBCtx.drawImage(videoB, 0, 0, tmpB.width, tmpB.height) 19 | const pixelsB = tmpACtx.getImageData(0, 0, tmpA.width, tmpA.height) 20 | 21 | pixelsB.data.forEach((x, i) => { 22 | const pxA = pixelsA.data[i] 23 | const pxB = x 24 | pixelsB.data[i] = 255 * (pxA / 255) * (pxB / 255) 25 | }) 26 | 27 | resultCtx.putImageData(pixelsB, 0, 0) 28 | } 29 | 30 | function loop () { 31 | window.requestAnimationFrame(() => { 32 | composite() 33 | loop() 34 | }) 35 | } 36 | loop() 37 | } 38 | 39 | window.onload = main 40 | -------------------------------------------------------------------------------- /video/kazusa/prototype/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Kazusa Video Demo 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /video/kazusa/prototype/kazusa.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doodlewind/learn-cs/d943759bf7898f677b6cafddb39c7d30d52bbf26/video/kazusa/prototype/kazusa.mp4 -------------------------------------------------------------------------------- /video/kazusa/prototype/main.js: -------------------------------------------------------------------------------- 1 | // Usage: `parcel index.html` 2 | 3 | import { loop } from './render' 4 | import { initBuffers } from './buffers' 5 | import { initProgram } from './shaders' 6 | import { initTextures } from './texture' 7 | import { initVideo } from './video' 8 | 9 | const gl = document.querySelector('#glcanvas').getContext('webgl') 10 | 11 | const programInfo = initProgram(gl) 12 | 13 | const buffers = initBuffers(gl) 14 | 15 | const videos = [ 16 | initVideo(require('./kazusa.mp4')), 17 | initVideo(require('./sea.mp4')) 18 | ] 19 | 20 | const textures = initTextures(gl) 21 | 22 | loop(gl, programInfo, buffers, textures, videos) 23 | -------------------------------------------------------------------------------- /video/kazusa/prototype/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kazusa", 3 | "version": "0.0.1", 4 | "main": "main.js", 5 | "license": "MIT" 6 | } 7 | -------------------------------------------------------------------------------- /video/kazusa/prototype/render.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | 3 | // Wrap render function. 4 | export function loop (gl, programInfo, buffers, textures, videos) { 5 | requestAnimationFrame(() => { 6 | draw(gl, programInfo, buffers, textures, videos) 7 | // Recursive render. 8 | loop(gl, programInfo, buffers, textures, videos) 9 | }) 10 | } 11 | 12 | function draw (gl, programInfo, buffers, textures, videos) { 13 | // Clear. 14 | gl.clearColor(0.0, 0.0, 0.0, 1.0) 15 | gl.clearDepth(1.0) 16 | gl.enable(gl.DEPTH_TEST) 17 | gl.depthFunc(gl.LEQUAL) 18 | gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT) 19 | 20 | // Positions. 21 | const { inPos } = programInfo.attributes 22 | gl.bindBuffer(gl.ARRAY_BUFFER, buffers.position) 23 | gl.vertexAttribPointer(inPos, 2, gl.FLOAT, false, 0, 0) 24 | gl.enableVertexAttribArray(inPos) 25 | 26 | gl.useProgram(programInfo.program) 27 | 28 | // Textures. 29 | gl.activeTexture(gl.TEXTURE0) 30 | gl.bindTexture(gl.TEXTURE_2D, textures[0]) 31 | gl.texImage2D( 32 | gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, videos[0] 33 | ) 34 | gl.activeTexture(gl.TEXTURE1) 35 | gl.bindTexture(gl.TEXTURE_2D, textures[1]) 36 | gl.texImage2D( 37 | gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, videos[1] 38 | ) 39 | 40 | // Pass uniforms. 41 | gl.uniform1i(programInfo.uniforms.uSampler0, 0) 42 | gl.uniform1i(programInfo.uniforms.uSampler1, 1) 43 | 44 | gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4) 45 | } 46 | -------------------------------------------------------------------------------- /video/kazusa/prototype/sea.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doodlewind/learn-cs/d943759bf7898f677b6cafddb39c7d30d52bbf26/video/kazusa/prototype/sea.mp4 -------------------------------------------------------------------------------- /video/kazusa/prototype/shaders.js: -------------------------------------------------------------------------------- 1 | const vsSource = ` 2 | precision mediump float; 3 | 4 | attribute vec2 inPos; 5 | varying vec2 vertPos; 6 | 7 | void main() { 8 | vertPos = inPos; 9 | gl_Position = vec4(inPos, 0.0, 1.0); 10 | } 11 | ` 12 | 13 | const fsSource = ` 14 | precision mediump float; 15 | 16 | varying vec2 vertPos; 17 | uniform sampler2D uSampler0; 18 | uniform sampler2D uSampler1; 19 | 20 | void main() { 21 | vec2 texCoord = vec2(vertPos.s, -vertPos.t) * 0.5 + 0.5; 22 | vec4 texColor0 = texture2D(uSampler0, texCoord.st); 23 | vec4 texColor1 = texture2D(uSampler1, texCoord.st); 24 | gl_FragColor = texColor0 * texColor1; 25 | } 26 | ` 27 | 28 | function loadShader (gl, type, source) { 29 | const shader = gl.createShader(type) 30 | 31 | gl.shaderSource(shader, source) 32 | gl.compileShader(shader) 33 | 34 | if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { 35 | console.log('Error compiling shaders', gl.getShaderInfoLog(shader)) 36 | gl.deleteShader(shader) 37 | return null 38 | } 39 | 40 | return shader 41 | } 42 | 43 | function initShaderProgram (gl, vsSource, fsSource) { 44 | const vertexShader = loadShader(gl, gl.VERTEX_SHADER, vsSource) 45 | const fragmentShader = loadShader(gl, gl.FRAGMENT_SHADER, fsSource) 46 | 47 | const program = gl.createProgram() 48 | gl.attachShader(program, vertexShader) 49 | gl.attachShader(program, fragmentShader) 50 | gl.linkProgram(program) 51 | 52 | if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { 53 | console.log( 54 | 'Error init shader program', gl.getProgramInfoLog(program) 55 | ) 56 | return null 57 | } 58 | 59 | return program 60 | } 61 | 62 | export function initProgram (gl) { 63 | const program = initShaderProgram(gl, vsSource, fsSource) 64 | 65 | const programInfo = { 66 | program, 67 | attributes: { 68 | inPos: gl.getAttribLocation(program, 'inPos') 69 | }, 70 | uniforms: { 71 | uSampler0: gl.getUniformLocation(program, 'uSampler0'), 72 | uSampler1: gl.getUniformLocation(program, 'uSampler1') 73 | } 74 | } 75 | return programInfo 76 | } 77 | -------------------------------------------------------------------------------- /video/kazusa/prototype/texture.js: -------------------------------------------------------------------------------- 1 | export function initTextures (gl) { 2 | const textures = [] 3 | for (let i = 0; i < 2; i++) { 4 | const texture = gl.createTexture() 5 | gl.bindTexture(gl.TEXTURE_2D, texture) 6 | 7 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE) 8 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE) 9 | gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) 10 | 11 | const pixel = new Uint8Array([0, 0, 255, 255]) 12 | gl.texImage2D( 13 | gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel 14 | ) 15 | textures.push(texture) 16 | } 17 | 18 | return textures 19 | } 20 | -------------------------------------------------------------------------------- /video/kazusa/prototype/video.js: -------------------------------------------------------------------------------- 1 | export function initVideo (url) { 2 | const video = document.createElement('video') 3 | video.autoplay = true 4 | video.muted = true 5 | video.loop = true 6 | video.src = url 7 | return video 8 | } 9 | -------------------------------------------------------------------------------- /video/openshot/.gitignore: -------------------------------------------------------------------------------- 1 | *.mp4 -------------------------------------------------------------------------------- /video/openshot/upload.py: -------------------------------------------------------------------------------- 1 | # Usage: python upload.py FILE_NAME 2 | 3 | import os 4 | import time 5 | import sys 6 | from requests import get, post 7 | from requests.auth import HTTPBasicAuth 8 | 9 | PATH = os.path.dirname(os.path.realpath(__file__)) 10 | CLOUD_URL = 'http://cloud.openshot.org' 11 | CLOUD_AUTH = HTTPBasicAuth('demo-cloud', 'demo-password') 12 | FILE_NAME = sys.argv[1] 13 | 14 | # Get list of projects 15 | end_point = '/projects/' 16 | r = get(CLOUD_URL + end_point, auth=CLOUD_AUTH) 17 | # print(r.json()) 18 | 19 | project_id = r.json().get("results")[0].get("id") 20 | project_url = r.json().get("results")[0].get("url") 21 | 22 | 23 | # Upload files to project 24 | end_point = '/projects/%s/files/' % project_id 25 | source_path = os.path.join(PATH, FILE_NAME) 26 | source_name = os.path.split(source_path)[1] 27 | file_data = { 28 | "media": None, 29 | "project": project_url, 30 | "json": "{}" 31 | } 32 | # print(file_data) 33 | 34 | r = post(CLOUD_URL + end_point, 35 | data=file_data, 36 | files={"media": (source_name, open(source_path, "rb"))}, 37 | auth=CLOUD_AUTH) 38 | file_url = r.json().get("url") 39 | print(r.json()) 40 | -------------------------------------------------------------------------------- /video/resources/wa2.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doodlewind/learn-cs/d943759bf7898f677b6cafddb39c7d30d52bbf26/video/resources/wa2.mp4 -------------------------------------------------------------------------------- /video/tasks.md: -------------------------------------------------------------------------------- 1 | ## 任务 2 | 3 | * [x] Emscripten 环境配置 4 | * [x] 调通 WASM 运行示例 5 | * [x] ffmpeg.js VP8 测试 6 | * [x] 构建出 ffmpeg.wasm 包 7 | * [x] FFmpeg WebM 测试 8 | 9 | -------------------------------------------------------------------------------- /video/wasm/ffmpeg.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/doodlewind/learn-cs/d943759bf7898f677b6cafddb39c7d30d52bbf26/video/wasm/ffmpeg.wasm -------------------------------------------------------------------------------- /video/wasm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WASM Example 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /video/wasm/main.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | const $input = document.querySelector('input') 3 | const $link = document.getElementById('link') 4 | // const $video = document.getElementById('video') 5 | 6 | // eslint-disable-next-line 7 | function arrayBufferToBase64 (buffer) { 8 | let binary = '' 9 | const bytes = new Uint8Array(buffer) 10 | const len = bytes.byteLength 11 | for (let i = 0; i < len; i++) { 12 | binary += String.fromCharCode(bytes[i]) 13 | } 14 | return window.btoa(binary) 15 | } 16 | 17 | $input.onchange = e => { 18 | const { files } = $input 19 | const worker = new Worker('worker.js') 20 | worker.postMessage(files) 21 | worker.addEventListener('message', e => { 22 | const blob = new Blob([new DataView(e.data)], { type: 'video/mp4' }) 23 | const url = URL.createObjectURL(blob) 24 | $link.href = url 25 | $link.hidden = false 26 | // FIXME 27 | // $video.src = arrayBufferToBase64(e.data) 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /video/wasm/worker.js: -------------------------------------------------------------------------------- 1 | /* eslint-env worker */ 2 | /* global ffmpeg_run */ 3 | 4 | self.importScripts('ffmpeg.js') 5 | 6 | onmessage = function (e) { 7 | const files = e.data 8 | console.time('encode') 9 | ffmpeg_run({ 10 | arguments: [ 11 | '-i', '/input/' + files[0].name, 12 | '-strict', '-2', 13 | '-b:v', '2M', 14 | 'out.mp4' 15 | ], 16 | files 17 | }, function (results) { 18 | console.log('len: ' + results[0].data.byteLength) 19 | console.timeEnd('encode') 20 | self.postMessage(results[0].data) 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /video/webm/README.md: -------------------------------------------------------------------------------- 1 | # WebM Encoding Example 2 | 3 | Please use [ParcelJS](https://parceljs.org) to run this example. 4 | 5 | ``` 6 | parcel index.html 7 | ``` 8 | -------------------------------------------------------------------------------- /video/webm/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WebM Encoding Example 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /video/webm/index.js: -------------------------------------------------------------------------------- 1 | /* eslint-env browser */ 2 | const input = document.querySelector('input[type="file"]') 3 | const video = document.querySelector('video') 4 | const canvas = document.getElementById('canvas') 5 | const ctx = canvas.getContext('2d') 6 | 7 | function playFile (file) { 8 | if (file) { 9 | const fileReader = new FileReader() 10 | fileReader.onload = evt => { 11 | if (fileReader.readyState === FileReader.DONE) { 12 | video.src = fileReader.result 13 | } else { 14 | console.log('FileReader Error:', evt) 15 | } 16 | } 17 | fileReader.readAsDataURL(file) 18 | } else { 19 | video.src = '' 20 | } 21 | } 22 | 23 | input.onchange = e => { 24 | const file = input.files && input.files[0] 25 | playFile(file) 26 | } 27 | 28 | video.addEventListener('play', function () { 29 | const _this = this 30 | const draw = () => { 31 | if (!_this.paused && !_this.ended) { 32 | ctx.drawImage(_this, 0, 0) 33 | requestAnimationFrame(draw) 34 | } 35 | } 36 | requestAnimationFrame(draw) 37 | }) 38 | -------------------------------------------------------------------------------- /video/webm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webm", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "license": "MIT" 6 | } 7 | --------------------------------------------------------------------------------