You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>Rainbow triangle together with a transparent circle. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/triangle.c">demos/triangle.c</a></p>
<p>A bunch of 3D dots projected onto your 2D screen plus a text with a builtin monospaced font. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/dots3d.c">demos/dots3d.c</a></p>
<p>Rotating rainbow triangle in 3D. Unlike <ahref="#demo-3d">3D dots above</a> this is a solid shape. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/triangle3d.c">demos/triangle3d.c</a></p>
<h2id="demo-triangle3dTex"><ahref="#demo-triangle3dTex">Rotating 3D Textures</a></h2>
45
45
<p>Textures by <ahref="https://opengameart.org/content/handpainted-stone-texture">MELLE</a>. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/triangle3dTex.c">demos/triangle3dTex.c</a></p>
<p>Design by <ahref="https://github.com/rexim">rexim</a>. 3D model by <ahref="https://github.com/kolumb">kolumb</a>. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/cup3d.c">demos/cup3d.c</a></p>
<p>Famous <ahref="https://en.wikipedia.org/wiki/Utah_teapot">Utah Teapot</a>. Model by <ahref="https://graphics.stanford.edu/courses/cs148-10-summer/as3/code/as3/teapot.obj">Standford University</a>. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/teapot3d.c">demos/teapot3d.c</a></p>
58
58
<p>(I have no idea why it runs with a reasonable FPS)</p>
<p><ahref="https://penger.neocities.org/">Penger</a> - The Mascot of Tsoding Discord Community. The character design by <ahref="https://github.com/LainLayer">LainLayer</a>. The model by <ahref="https://github.com/Max-Kawula">Max-Kawula</a>. Source: <ahref="https://github.com/tsoding/olive.c/blob/master/demos/penger3d.c">demos/penger3d.c</a></p>
// TODO: maybe we can preallocate a Uint8ClampedArray on JavaScript side and just copy the canvas data there to bring width and stride to the same value?
72
61
console.error(`Canvas width (${canvas.width}) is not equal to its stride (${canvas.stride}). Unfortunately we can't easily support that in a browser because ImageData simply does not accept stride. Welcome to 2022.`);
73
62
return;
@@ -87,8 +76,46 @@ async function startDemo(elementId, wasmPath) {
87
76
functionloop(timestamp){
88
77
constdt=timestamp-prev;
89
78
prev=timestamp;
90
-
if(!paused)render(dt);
79
+
if(app.dataset['visible']==='true')render(dt);
91
80
window.requestAnimationFrame(loop);
92
81
}
93
82
window.requestAnimationFrame(first);
94
83
}
84
+
85
+
classOliveCanvasextendsHTMLElement{
86
+
constructor(){
87
+
super();
88
+
}
89
+
90
+
connectedCallback(){
91
+
constwasmPath=this.getAttribute('src');
92
+
if(!wasmPath){
93
+
console.error(`Should define a src attribute on olive-canvas`)
94
+
return;
95
+
}
96
+
97
+
constcanvas=document.createElement("canvas");
98
+
this.appendChild(canvas);
99
+
100
+
// Create an observer that monitors entering/exiting the viewport
0 commit comments