@bigmistqke/view.gl 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +94 -27
  2. package/dev/dist/404.html +19 -0
  3. package/dev/dist/assets/bezier-DrA4cU_H.js +292 -0
  4. package/dev/dist/assets/game-of-life-BYlzWhEL.js +186 -0
  5. package/dev/dist/assets/glsl-composition-D_BaFFij.js +97 -0
  6. package/dev/dist/assets/grid-DfXHNLBm.js +181 -0
  7. package/dev/dist/assets/index-C2N3u8wj.css +12 -0
  8. package/dev/dist/assets/index-D-N0FDYs.js +110 -0
  9. package/dev/dist/assets/main-CSE2fki3.js +32 -0
  10. package/dev/dist/assets/overview-IeUhUflE.js +80 -0
  11. package/dev/dist/assets/pix-sim-DMJJA_WO.js +500 -0
  12. package/dev/dist/assets/ray-casting-DTQetDPd.js +411 -0
  13. package/dev/dist/assets/ray-casting-modules-Dkfw4tdc.js +765 -0
  14. package/dev/dist/assets/sdf-CS0uBonx.js +66 -0
  15. package/dev/dist/assets/symbol-BL_7GJ0M.js +67 -0
  16. package/dev/dist/assets/tag-C0Vskpp8.js +833 -0
  17. package/dev/dist/assets/tetris-D8mokodr.js +344 -0
  18. package/dev/dist/assets/utils-2dzuv_bW.js +62 -0
  19. package/dev/dist/index.html +51 -0
  20. package/dist/chunk-BZDGEIOT.mjs +278 -0
  21. package/dist/chunk-BZDGEIOT.mjs.map +1 -0
  22. package/dist/{chunk-EYXOSM7B.mjs → chunk-H56LJYS5.mjs} +63 -133
  23. package/dist/chunk-H56LJYS5.mjs.map +1 -0
  24. package/dist/gl.d.mts +2 -2
  25. package/dist/gl.mjs +1 -1
  26. package/dist/index.d.mts +13 -4
  27. package/dist/index.mjs +7 -2
  28. package/dist/tag.d.mts +6 -1
  29. package/dist/tag.mjs +19 -6
  30. package/dist/tag.mjs.map +1 -1
  31. package/dist/{types-CyGyGi18.d.mts → types-k1Xz1iO3.d.mts} +44 -2
  32. package/package.json +1 -1
  33. package/src/gl.ts +13 -2
  34. package/src/index.ts +63 -39
  35. package/src/tag.ts +23 -2
  36. package/src/types.ts +43 -1
  37. package/src/utils.ts +45 -10
  38. package/test/index.test.ts +145 -29
  39. package/test/mocks/webgl.ts +14 -0
  40. package/test/tag.test.ts +41 -0
  41. package/dist/chunk-CJTT7WPV.mjs +0 -75
  42. package/dist/chunk-CJTT7WPV.mjs.map +0 -1
  43. package/dist/chunk-EYXOSM7B.mjs.map +0 -1
@@ -0,0 +1,97 @@
1
+ import { g as glsl, u as uniform, a as attribute, c as compile } from './tag-C0Vskpp8.js';
2
+ import { d as dom } from './utils-2dzuv_bW.js';
3
+
4
+ const canvas = dom("canvas", {
5
+ width: window.innerWidth,
6
+ height: window.innerHeight,
7
+ parentElement: document.body,
8
+ style: { width: "100%" }
9
+ });
10
+ const gl = canvas.getContext("webgl2");
11
+ gl.viewport(0, 0, canvas.width, canvas.height);
12
+ console.log("gl is", gl);
13
+ const mathUtils = glsl`
14
+ float wave(float x, float speed, float frequency) {
15
+ return sin(x * frequency + u_time * speed);
16
+ }
17
+ `;
18
+ const transforms = glsl`
19
+ ${uniform.float("u_time")}
20
+ ${mathUtils}
21
+
22
+ mat2 rotation2D(float angle) {
23
+ float c = cos(angle);
24
+ float s = sin(angle);
25
+ return mat2(c, -s, s, c);
26
+ }
27
+ `;
28
+ const colors = glsl`
29
+ ${uniform.vec3("u_color")}
30
+
31
+ vec3 rainbow(float t) {
32
+ return 0.5 + 0.5 * cos(6.28318 * (t + vec3(0.0, 0.33, 0.67)));
33
+ }
34
+ `;
35
+ const vertex = glsl`
36
+ precision highp float;
37
+
38
+ ${attribute.vec2("a_position")}
39
+ ${transforms}
40
+
41
+ void main() {
42
+ vec2 pos = a_position;
43
+
44
+ // Rotate based on time
45
+ float angle = u_time;
46
+ pos = rotation2D(angle) * pos;
47
+
48
+ // Add wave motion
49
+ pos.y += wave(pos.x, 2.0, 5.0) * 0.1;
50
+
51
+ gl_Position = vec4(pos, 0.0, 1.0);
52
+ }
53
+ `;
54
+ const fragment = glsl`
55
+ precision highp float;
56
+
57
+ ${colors}
58
+ ${[uniform.float("u_time")]}
59
+
60
+ void main() {
61
+ // Animated rainbow color
62
+ vec3 color = rainbow(u_time * 0.5);
63
+
64
+ // Mix with base color
65
+ color = mix(u_color, color, 0.7);
66
+
67
+ gl_FragColor = vec4(color, 1.0);
68
+ }
69
+ `;
70
+ const {
71
+ program,
72
+ view: { attributes, uniforms }
73
+ } = compile(gl, vertex, fragment);
74
+ gl.useProgram(program);
75
+ uniforms.u_color.set(1, 0.5, 0.2);
76
+ attributes.a_position.set(
77
+ new Float32Array([
78
+ // Triangle
79
+ 0,
80
+ 0.5,
81
+ // top
82
+ -0.5,
83
+ -0.5,
84
+ // bottom left
85
+ 0.5,
86
+ -0.5
87
+ // bottom right
88
+ ])
89
+ ).bind();
90
+ function draw(delta) {
91
+ requestAnimationFrame(draw);
92
+ uniforms.u_time.set(delta / 1e3);
93
+ gl.clearColor(0.1, 0.1, 0.2, 1);
94
+ gl.clear(gl.COLOR_BUFFER_BIT);
95
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
96
+ }
97
+ requestAnimationFrame(draw);
@@ -0,0 +1,181 @@
1
+ import { a as attribute, u as uniform, g as glsl, c as compile } from './tag-C0Vskpp8.js';
2
+ import { d as dom, c as cursor } from './utils-2dzuv_bW.js';
3
+
4
+ const canvas = dom("canvas", {
5
+ width: window.innerWidth,
6
+ height: window.innerHeight,
7
+ parentElement: document.body
8
+ });
9
+ const gl = canvas.getContext("webgl2", { antialias: false });
10
+ if (!gl) {
11
+ throw new Error("WebGL not supported");
12
+ }
13
+ const state = {
14
+ position: { x: 0, y: 0 },
15
+ scale: 1,
16
+ elements: []
17
+ };
18
+ const container = dom("div", { parentElement: document.body });
19
+ state.elements.push(createGridElement({ x: 100, y: 100 }));
20
+ function createGridElement(position = { x: 0, y: 0 }) {
21
+ position = {
22
+ x: (position.x - state.position.x) / state.scale,
23
+ y: (position.y - state.position.y) / state.scale
24
+ };
25
+ const div = dom("div", {
26
+ innerText: "HALLO WORLD",
27
+ style: {
28
+ position: "fixed",
29
+ zIndex: "10",
30
+ left: "0px",
31
+ top: "0px",
32
+ transformOrigin: "top left",
33
+ background: "white",
34
+ padding: "2px",
35
+ borderRadius: "2px"
36
+ },
37
+ parentElement: container
38
+ });
39
+ function update() {
40
+ div.style.transform = `translate3d(${state.position.x + position.x * state.scale}px,${state.position.y + position.y * state.scale}px,0) scale(${state.scale})`;
41
+ }
42
+ update();
43
+ return {
44
+ element: div,
45
+ position,
46
+ update
47
+ };
48
+ }
49
+ canvas.addEventListener("pointerdown", (event) => {
50
+ cursor(event, (event2) => {
51
+ state.position.x -= event2.deltaX;
52
+ state.position.y -= event2.deltaY;
53
+ render();
54
+ });
55
+ });
56
+ canvas.addEventListener("dblclick", (event) => {
57
+ state.elements.push(
58
+ createGridElement({
59
+ x: event.clientX,
60
+ y: event.clientY
61
+ })
62
+ );
63
+ });
64
+ window.addEventListener(
65
+ "wheel",
66
+ (event) => {
67
+ const rect = canvas.getBoundingClientRect();
68
+ const mouseX = event.clientX - rect.left;
69
+ const mouseY = event.clientY - rect.top;
70
+ const scaleFactor = event.deltaY > 0 ? 0.95 : 1.05;
71
+ const oldScale = state.scale;
72
+ const newScale = Math.max(0.1, Math.min(10, oldScale * scaleFactor));
73
+ const gridX = (mouseX - state.position.x) / oldScale;
74
+ const gridY = (mouseY - state.position.y) / oldScale;
75
+ state.scale = newScale;
76
+ state.position.x = mouseX - gridX * newScale;
77
+ state.position.y = mouseY - gridY * newScale;
78
+ render();
79
+ },
80
+ { passive: true }
81
+ );
82
+ window.addEventListener("resize", render);
83
+ const vertex = glsl`#version 300 es
84
+ ${attribute.vec2("a_vertex")}
85
+ ${uniform.vec2("u_screenSize")}
86
+ ${uniform.vec2("u_pos")}
87
+ ${uniform.float("u_scale")}
88
+ out vec2 v_gridCoord;
89
+
90
+ // Direct mapping: (-1,-1) is bottom-left, (1,1) is top-right in clip space
91
+ // We want (0,0) to be top-left in pixel space
92
+ vec2 project(vec2 pos, vec2 size){
93
+ return vec2(
94
+ (pos.x + 1.0),
95
+ (1.0 - pos.y)
96
+ ) * size * 0.5;
97
+ }
98
+
99
+ void main() {
100
+ vec2 pixelPos = project(a_vertex, u_screenSize);
101
+
102
+ // Apply offset and scale to get grid coordinates
103
+ v_gridCoord = (pixelPos - u_pos) / u_scale;
104
+
105
+ gl_Position = vec4(a_vertex, 0, 1);
106
+ }`;
107
+ const renderFragment = glsl`#version 300 es
108
+ precision highp float;
109
+ in vec2 v_gridCoord;
110
+ out vec4 fragColor;
111
+ ${uniform.float("u_thickness")}
112
+
113
+ float grid(vec2 coord, float thickness) {
114
+ vec2 cell = mod(coord, 100.0);
115
+ vec2 derivative = fwidth(coord);
116
+
117
+ // Convert thickness from screen pixels to grid space
118
+ vec2 screenThickness = derivative * thickness;
119
+
120
+ // Ensure minimum thickness to prevent lines from disappearing
121
+ vec2 minThickness = max(screenThickness, derivative * 0.5);
122
+
123
+ // Create hard edges by checking if we're within thickness of a grid line
124
+ float lineX = step(cell.x, minThickness.x) + step(100.0 - minThickness.x, cell.x);
125
+ float lineY = step(cell.y, minThickness.y) + step(100.0 - minThickness.y, cell.y);
126
+
127
+ // Clamp to 0-1 range and return maximum (union of lines)
128
+ return max(min(lineX, 1.0), min(lineY, 1.0));
129
+ }
130
+
131
+ void main() {
132
+ // Create grid pattern with adjustable thickness
133
+ float gridPattern = grid(v_gridCoord, u_thickness);
134
+
135
+ // Grid colors
136
+ vec3 backgroundColor = vec3(0.1, 0.1, 0.15);
137
+ vec3 gridColor = vec3(0.3, 0.3, 0.4);
138
+ vec3 color = mix(backgroundColor, gridColor, gridPattern);
139
+
140
+ fragColor = vec4(color, 1.0);
141
+ }`;
142
+ const {
143
+ program,
144
+ view: { attributes, uniforms }
145
+ } = compile(gl, vertex, renderFragment);
146
+ attributes.a_vertex.set(new Float32Array([
147
+ -1,
148
+ -1,
149
+ // bottom-left
150
+ 1,
151
+ -1,
152
+ // bottom-right
153
+ -1,
154
+ 1,
155
+ // top-left
156
+ -1,
157
+ 1,
158
+ // top-left
159
+ 1,
160
+ -1,
161
+ // bottom-right
162
+ 1,
163
+ 1
164
+ // top-right
165
+ ]));
166
+ function render() {
167
+ gl.useProgram(program);
168
+ canvas.width = window.innerWidth;
169
+ canvas.height = window.innerHeight;
170
+ gl.viewport(0, 0, canvas.width, canvas.height);
171
+ gl.clearColor(0, 0, 0, 1);
172
+ gl.clear(gl.COLOR_BUFFER_BIT);
173
+ attributes.a_vertex.bind();
174
+ uniforms.u_screenSize.set(canvas.width, canvas.height);
175
+ uniforms.u_pos.set(state.position.x, state.position.y);
176
+ uniforms.u_scale.set(state.scale);
177
+ uniforms.u_thickness.set(1);
178
+ state.elements.forEach((element) => element.update());
179
+ gl.drawArrays(gl.TRIANGLES, 0, 6);
180
+ }
181
+ render();
@@ -0,0 +1,12 @@
1
+ body {
2
+ display: flex;
3
+ justify-content: center;
4
+ align-items: center;
5
+ margin: 0px;
6
+ height: 100%;
7
+ overscroll-behavior-y: none;
8
+ }
9
+ canvas {
10
+ margin: auto;
11
+ image-rendering: pixelated;
12
+ }
@@ -0,0 +1,110 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/bezier-DrA4cU_H.js","assets/tag-C0Vskpp8.js","assets/utils-2dzuv_bW.js","assets/game-of-life-BYlzWhEL.js","assets/glsl-composition-D_BaFFij.js","assets/grid-DfXHNLBm.js","assets/overview-IeUhUflE.js","assets/pix-sim-DMJJA_WO.js","assets/ray-casting-modules-Dkfw4tdc.js","assets/ray-casting-DTQetDPd.js","assets/sdf-CS0uBonx.js","assets/symbol-BL_7GJ0M.js","assets/tetris-D8mokodr.js"])))=>i.map(i=>d[i]);
2
+ import { d as dom } from './utils-2dzuv_bW.js';
3
+
4
+ const scriptRel = 'modulepreload';const assetsURL = function(dep) { return "/"+dep };const seen = {};const __vitePreload = function preload(baseModule, deps, importerUrl) {
5
+ let promise = Promise.resolve();
6
+ if (true && deps && deps.length > 0) {
7
+ document.getElementsByTagName("link");
8
+ const cspNonceMeta = document.querySelector("meta[property=csp-nonce]");
9
+ const cspNonce = cspNonceMeta?.nonce || cspNonceMeta?.getAttribute("nonce");
10
+ function allSettled(promises$2) {
11
+ return Promise.all(promises$2.map((p$1) => Promise.resolve(p$1).then((value$1) => ({
12
+ status: "fulfilled",
13
+ value: value$1
14
+ }), (reason) => ({
15
+ status: "rejected",
16
+ reason
17
+ }))));
18
+ }
19
+ promise = allSettled(deps.map((dep) => {
20
+ dep = assetsURL(dep);
21
+ if (dep in seen) return;
22
+ seen[dep] = true;
23
+ const isCss = dep.endsWith(".css");
24
+ const cssSelector = isCss ? "[rel=\"stylesheet\"]" : "";
25
+ if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) return;
26
+ const link = document.createElement("link");
27
+ link.rel = isCss ? "stylesheet" : scriptRel;
28
+ if (!isCss) link.as = "script";
29
+ link.crossOrigin = "";
30
+ link.href = dep;
31
+ if (cspNonce) link.setAttribute("nonce", cspNonce);
32
+ document.head.appendChild(link);
33
+ if (isCss) return new Promise((res, rej) => {
34
+ link.addEventListener("load", res);
35
+ link.addEventListener("error", () => rej(/* @__PURE__ */ new Error(`Unable to preload CSS for ${dep}`)));
36
+ });
37
+ }));
38
+ }
39
+ function handlePreloadError(err$2) {
40
+ const e$1 = new Event("vite:preloadError", { cancelable: true });
41
+ e$1.payload = err$2;
42
+ window.dispatchEvent(e$1);
43
+ if (!e$1.defaultPrevented) throw err$2;
44
+ }
45
+ return promise.then((res) => {
46
+ for (const item of res || []) {
47
+ if (item.status !== "rejected") continue;
48
+ handlePreloadError(item.reason);
49
+ }
50
+ return baseModule().catch(handlePreloadError);
51
+ });
52
+ };
53
+
54
+ const css = "/assets/index-C2N3u8wj.css";
55
+
56
+ const iframe = document.querySelector("iframe");
57
+ const nav = document.querySelector("nav");
58
+ nav.append(dom("h3", { innerText: "Examples" }));
59
+ const urls = Object.fromEntries(
60
+ Object.entries(/* #__PURE__ */ Object.assign({"./examples/bezier.ts": () => __vitePreload(() => import('./bezier-DrA4cU_H.js'),true ?__vite__mapDeps([0,1,2]):void 0),"./examples/game-of-life.ts": () => __vitePreload(() => import('./game-of-life-BYlzWhEL.js'),true ?__vite__mapDeps([3,1,2]):void 0),"./examples/glsl-composition.ts": () => __vitePreload(() => import('./glsl-composition-D_BaFFij.js'),true ?__vite__mapDeps([4,1,2]):void 0),"./examples/grid.ts": () => __vitePreload(() => import('./grid-DfXHNLBm.js'),true ?__vite__mapDeps([5,1,2]):void 0),"./examples/overview.ts": () => __vitePreload(() => import('./overview-IeUhUflE.js'),true ?__vite__mapDeps([6,1]):void 0),"./examples/pix-sim.ts": () => __vitePreload(() => import('./pix-sim-DMJJA_WO.js'),true ?__vite__mapDeps([7,1,2]):void 0),"./examples/ray-casting-modules.ts": () => __vitePreload(() => import('./ray-casting-modules-Dkfw4tdc.js'),true ?__vite__mapDeps([8,1,2]):void 0),"./examples/ray-casting.ts": () => __vitePreload(() => import('./ray-casting-DTQetDPd.js'),true ?__vite__mapDeps([9,1,2]):void 0),"./examples/sdf.ts": () => __vitePreload(() => import('./sdf-CS0uBonx.js'),true ?__vite__mapDeps([10,1,2]):void 0),"./examples/symbol.ts": () => __vitePreload(() => import('./symbol-BL_7GJ0M.js'),true ?__vite__mapDeps([11,1,2]):void 0),"./examples/tetris.ts": () => __vitePreload(() => import('./tetris-D8mokodr.js'),true ?__vite__mapDeps([12,1]):void 0)})).map(([key, entry]) => {
61
+ const name = key.split("/").pop().replace(".ts", "");
62
+ const chunk = entry.toString().match(/import\(['"]([^'"]+)['"]/)[1];
63
+ return [name, chunk];
64
+ })
65
+ );
66
+ Object.entries(urls).forEach(([name, localUrl]) => {
67
+ nav.append(
68
+ dom("button", {
69
+ onclick(event) {
70
+ event.preventDefault();
71
+ load(name, localUrl);
72
+ },
73
+ innerHTML: name.replaceAll("-", " "),
74
+ "data-route": name
75
+ })
76
+ );
77
+ });
78
+ function load(name, url) {
79
+ window.location.hash = name;
80
+ URL.revokeObjectURL(iframe.src);
81
+ nav.querySelectorAll("button").forEach((button) => {
82
+ if (button.getAttribute("data-route") === name) {
83
+ button.classList.add("active");
84
+ } else {
85
+ button.classList.remove("active");
86
+ }
87
+ });
88
+ iframe.src = URL.createObjectURL(
89
+ new Blob(
90
+ [
91
+ `<head>
92
+ <link rel="stylesheet" href="${new URL(css, import.meta.url).href}"></link>
93
+ <script type="module" src="${new URL(url, import.meta.url).href}"><\/script></head>`
94
+ ],
95
+ {
96
+ type: "text/html"
97
+ }
98
+ )
99
+ );
100
+ }
101
+ const hash = window.location.hash.slice(1);
102
+ if (hash && hash in urls) {
103
+ load(hash, urls[hash]);
104
+ }
105
+ window.addEventListener("hashchange", () => {
106
+ const hash2 = window.location.hash.slice(1);
107
+ if (hash2 && hash2 in urls) {
108
+ load(hash2, urls[hash2]);
109
+ }
110
+ });
@@ -0,0 +1,32 @@
1
+ import './index-D-N0FDYs.js';
2
+ import './utils-2dzuv_bW.js';
3
+
4
+ true &&(function polyfill() {
5
+ const relList = document.createElement("link").relList;
6
+ if (relList && relList.supports && relList.supports("modulepreload")) return;
7
+ for (const link of document.querySelectorAll("link[rel=\"modulepreload\"]")) processPreload(link);
8
+ new MutationObserver((mutations) => {
9
+ for (const mutation of mutations) {
10
+ if (mutation.type !== "childList") continue;
11
+ for (const node of mutation.addedNodes) if (node.tagName === "LINK" && node.rel === "modulepreload") processPreload(node);
12
+ }
13
+ }).observe(document, {
14
+ childList: true,
15
+ subtree: true
16
+ });
17
+ function getFetchOpts(link) {
18
+ const fetchOpts = {};
19
+ if (link.integrity) fetchOpts.integrity = link.integrity;
20
+ if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
21
+ if (link.crossOrigin === "use-credentials") fetchOpts.credentials = "include";
22
+ else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
23
+ else fetchOpts.credentials = "same-origin";
24
+ return fetchOpts;
25
+ }
26
+ function processPreload(link) {
27
+ if (link.ep) return;
28
+ link.ep = true;
29
+ const fetchOpts = getFetchOpts(link);
30
+ fetch(link.href, fetchOpts);
31
+ }
32
+ }());
@@ -0,0 +1,80 @@
1
+ import { i as interleave, a as attribute, u as uniform, g as glsl, c as compile } from './tag-C0Vskpp8.js';
2
+
3
+ const canvas = document.createElement("canvas");
4
+ canvas.width = 800;
5
+ canvas.height = 600;
6
+ document.body.append(canvas);
7
+ const gl = canvas.getContext("webgl2");
8
+ gl.viewport(0, 0, canvas.width, canvas.height);
9
+ const vertex = glsl`
10
+ precision mediump float;
11
+
12
+ ${interleave("instancedData", [attribute.vec2("a_pos"), attribute.vec3("a_color")], {
13
+ instanced: true
14
+ })}
15
+ ${attribute.vec2("a_vertex")}
16
+ ${uniform.float("u_time")}
17
+
18
+ varying vec3 v_color;
19
+
20
+ void main() {
21
+ float s = sin(u_time);
22
+ float c = cos(u_time);
23
+ mat2 rotation = mat2(
24
+ c, -s,
25
+ s, c
26
+ );
27
+ vec2 position = a_pos + a_vertex * rotation;
28
+ gl_Position = vec4(position, 0.0, 1.0);
29
+
30
+ v_color = a_color;
31
+ }`;
32
+ const fragment = glsl`
33
+ precision mediump float;
34
+
35
+ varying vec3 v_color;
36
+
37
+ void main() {
38
+ gl_FragColor = vec4(v_color, 1.0);
39
+ }`;
40
+ const {
41
+ program,
42
+ view: {
43
+ attributes: { a_vertex },
44
+ uniforms: { u_time },
45
+ interleavedAttributes: { instancedData }
46
+ }
47
+ } = compile(gl, vertex, fragment);
48
+ instancedData.set(
49
+ new Float32Array(
50
+ function* () {
51
+ for (let i = 0; i < 100; i++) {
52
+ yield (Math.random() - 0.5) * 2;
53
+ yield (Math.random() - 0.5) * 2;
54
+ yield Math.random();
55
+ yield Math.random();
56
+ yield Math.random();
57
+ }
58
+ }()
59
+ )
60
+ );
61
+ instancedData.bind();
62
+ a_vertex.set(
63
+ new Float32Array([
64
+ // top
65
+ 0,
66
+ 1,
67
+ // bottom left
68
+ -1,
69
+ -1,
70
+ // bottom right
71
+ 1,
72
+ -1
73
+ ])
74
+ ).bind();
75
+ gl.useProgram(program);
76
+ requestAnimationFrame(function draw(delta) {
77
+ requestAnimationFrame(draw);
78
+ u_time.set(delta / 1e3);
79
+ gl.drawArraysInstanced(gl.TRIANGLES, 0, 3, 100);
80
+ });