176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
fix: keep the tilt on a shape change, slow the roll clock and correct the view vector in 3D Model Orbit
matindfc09480195c
diff --git a/animations/06-3d-advanced/3d-model-orbit/README.md b/animations/06-3d-advanced/3d-model-orbit/README.mdindex 2782a6ed..b5afda1a 100644--- a/animations/06-3d-advanced/3d-model-orbit/README.md+++ b/animations/06-3d-advanced/3d-model-orbit/README.md@@ -35,7 +35,7 @@ uniform vec3 uCol, uLight;void main() {vec3 L = normalize(uLight - vP);- vec3 V = normalize(vec3(0., 0., 4.) - vP);+ vec3 V = normalize(-vP);float d = max(dot(vN, L), 0.0);float s = pow(max(dot(reflect(-L, vN), V), 0.0), 48.0);gl_FragColor = vec4(0.15 * uCol + d * uCol + 0.7 * s, 1.0);diff --git a/animations/06-3d-advanced/3d-model-orbit/index.html b/animations/06-3d-advanced/3d-model-orbit/index.htmlindex b2f6a31f..97edd0bc 100644--- a/animations/06-3d-advanced/3d-model-orbit/index.html+++ b/animations/06-3d-advanced/3d-model-orbit/index.html@@ -265,7 +265,8 @@ function makeTetra(){const stage=document.getElementById('stage'),cvs=document.getElementById('cvs');const slowTog=document.getElementById('slow-tog');let W,H,gl,prog,posBuf,nrmBuf,idxBuf,lineBuf,idxCount,lineCount;-let raf=null,paused=false,last=null,clock=0,rx=.3,ry=0;+const TILT=.3; // the forward tilt it starts with, and returns to when the shape changes: at 0 a ring is seen edge-on+let raf=null,paused=false,last=null,clock=0,rx=TILT,ry=0;let MODE='orbit',WIRE=false,DIST=3,SX=.2,SY=.8,COLOR=[88/255,166/255,255/255];let rollSpeed=.2,tumbles=true;let mouseNX=0,mouseNY=0;@@ -338,14 +339,15 @@ function draw(){}// The loop keeps exactly one pending frame in raf. The page's own clock adds up the time of each drawn frame-// (at most 50 ms), so the forward roll carries on smoothly after a pause instead of jumping.+// (at most 50 ms, and a third of it while Slow motion is on, so the roll's speed wave slows down with the spin),+// so the forward roll carries on smoothly after a pause instead of jumping.function render(ts){raf=requestAnimationFrame(render);if(last===null){last=ts;return;} // the first frame after a start only takes the timeconst dt=ts-last;if(dt<16)return;- last=ts;clock+=Math.min(dt,50);+ const k=slowTog.checked?1/3:1;+ last=ts;clock+=Math.min(dt,50)*k;if(MODE==='orbit'){- const k=slowTog.checked?1/3:1;ry+=SY*.01*k;rx+=SX*.01*k*(Math.sin(clock*.0003)*.5+.5);}else{rx=mouseNY*1.2;ry=mouseNX*1.5;}draw();@@ -383,7 +385,7 @@ function choices(id,pick){}const speedSetting=document.getElementById('speed-setting'),tumbleSetting=document.getElementById('tumble-setting');function setRoll(){SX=tumbles?rollSpeed:0;}-choices('shape-seg',d=>{if(!gl)return;loadGeometry(d.shape);rx=0;ry=0;redraw();});+choices('shape-seg',d=>{if(!gl)return;loadGeometry(d.shape);rx=TILT;ry=0;redraw();});// Speed and Tumbles only matter while it spinschoices('move-seg',d=>{MODE=d.mode;speedSetting.hidden=tumbleSetting.hidden=MODE!=='orbit';});choices('speed-seg',d=>{SY=+d.sy;rollSpeed=+d.sx;setRoll();});