Loading...
Loading...
Compare original and translation side by side
ambient-section-particlesambient-section-particlesctx.save();
ctx.translate(l.x, l.y);
ctx.rotate(l.roll); // long axis drifting in-plane
ctx.scale(Math.cos(l.spin), 1); // the tumble: cos crosses 0, edge-on
ctx.globalAlpha = l.alpha;
ctx.drawImage(sprite, -w / 2, -h / 2, w, h);
ctx.restore();rollspinctx.save();
ctx.translate(l.x, l.y);
ctx.rotate(l.roll); // 长轴在平面内漂移
ctx.scale(Math.cos(l.spin), 1); // 翻滚效果:cos值跨越0,呈现侧立状态
ctx.globalAlpha = l.alpha;
ctx.drawImage(sprite, -w / 2, -h / 2, w, h);
ctx.restore();rollspinl.x += Math.sin(l.spin) * l.slip * dt; // fastest when cos(spin) ≈ 0
l.y += l.fall * dt;xl.x += Math.sin(l.spin) * l.slip * dt; // 当cos(spin)≈0时速度最快
l.y += l.fall * dt;xconst img = Math.cos(l.spin) < 0 ? sprite.back : sprite.face;const img = Math.cos(l.spin) < 0 ? sprite.back : sprite.face;camera.getWorldDirection(fwd); fwd.y = 0; fwd.normalize();
const cx = camera.position.x + fwd.x * AHEAD;
const cz = camera.position.z + fwd.z * AHEAD;
const a = Math.random() * TAU, r = Math.sqrt(Math.random()) * SPREAD;
l.x = cx + Math.cos(a) * r; l.z = cz + Math.sin(a) * r; l.y = camera.position.y + 16;camera.getWorldDirection(fwd); fwd.y = 0; fwd.normalize();
const cx = camera.position.x + fwd.x * AHEAD;
const cz = camera.position.z + fwd.z * AHEAD;
const a = Math.random() * TAU, r = Math.sqrt(Math.random()) * SPREAD;
l.x = cx + Math.cos(a) * r; l.z = cz + Math.sin(a) * r; l.y = camera.position.y + 16;const k = clamp(Math.sqrt((W * H) / (1440 * 900)), .5, 1.3);
const n = Math.round(authored * layerShare * k);const k = clamp(Math.sqrt((W * H) / (1440 * 900)), .5, 1.3);
const n = Math.round(authored * layerShare * k);| layer | scale | fall | opacity | note |
|---|---|---|---|---|
| far | 0.3–0.5 | slow | 0.22–0.40 | drawn first, may sit behind content |
| mid | 0.5–0.85 | medium | 0.46–0.78 | the body of the effect |
| near | 1.05–1.9 | fast | 0.50–0.82 | few, optionally blurred, drawn over content |
| 图层 | 缩放比例 | 下落速度 | 透明度 | 说明 |
|---|---|---|---|---|
| 远景 | 0.3–0.5 | 慢 | 0.22–0.40 | 最先绘制,可置于内容后方 |
| 中景 | 0.5–0.85 | 中等 | 0.46–0.78 | 效果主体 |
| 近景 | 1.05–1.9 | 快 | 0.50–0.82 | 数量少,可选择添加模糊,绘制在内容上方 |
0x7802000x8c14100x7802000x8c1410drawImageInstancedMeshMatrix4Matrix4QuaternionEulerVector3drawImageInstancedMeshMatrix4Matrix4QuaternionEulerVector3document.hiddenIntersectionObserverlastTimedtResizeObserverdocument.hiddenIntersectionObserverlastTimedtResizeObserverprefers-reduced-motion: reduceprefers-reduced-motion: reducedtdt