-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfractal.mjs
43 lines (41 loc) · 962 Bytes
/
fractal.mjs
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
///<reference path="../lib/phenomenon-1.5.1/index.d.ts" />
import Phenomenon from '../lib/phenomenon-1.5.1/phenomenon.mjs';
import { frag, vert } from './shaders.mjs'
const canvas = document.querySelector('canvas');
const phenomenon = new Phenomenon({
canvas,
contextType: 'webgl',
settings: {
devicePixelRatio: window.devicePixelRatio
}
});
phenomenon.add('first', {
uniforms: {
time: {
type: 'float',
value: 0.0
},
width: {
type: 'float',
value: canvas.width * window.devicePixelRatio
},
height: {
type: 'float',
value: canvas.height * window.devicePixelRatio
}
},
vertex: vert,
fragment: frag,
mode: 4,
geometry: {vertices: [
{x: -1, y: -1, z: 0},
{x: -1, y: 1, z: 0},
{x: 1, y: -1, z: 0},
{x: 1, y: -1, z: 0},
{x: -1, y: 1, z: 0},
{x: 1, y: 1, z: 0}
]},
onRender: instance => {
instance.uniforms.time.value += 0.1;
}
});