3d-retina-resolution
できること
このスキルは、高密度の画面を含め、Web ページ上でぼやけた3Dのキャンバスを直す作業を案内します。最近の画面で、3Dのシーンが柔らかく、または粗く見える開発者向けです。
使う場面
- ✓WebGL の3D のシーンが、Retina や高密度の画面でぼやけるとき。
- ✓3D の出力を200パーセントで描画したいとき。
- ✓キャンバスのサイズを変えた後、3D のキャンバスのクリックが違う位置に当たるとき。
スキルのリンク
https://github.com/MengTo/Skills/blob/main/agent-skills/3d/3d-retina-resolution/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“ノートパソコンで、3D の製品ビューアがぼやけます。レイアウトを変えずに、200パーセントでくっきりさせてください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、描画のサイズとピクセル比を、ページのレイアウトとは別に設定します。描画のパイプラインのすべての部分を同期させ、性能を測定して、代替のオプションを用意します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
3D Retina Resolution
Treat an explicit 200% rendering request as two drawing-buffer pixels per CSS pixel in each dimension. A 1200 × 800 CSS canvas therefore uses a 2400 × 1600 drawing buffer, or four times the pixels of 100%. Layout and camera framing stay unchanged.
Choose the scale deliberately
- Fixed 200%: effective pixel ratio is
2, independent of device pixel ratio. This is the default when the user explicitly requests 200%. - Automatic Retina, capped at 2×: effective ratio is
Math.min(window.devicePixelRatio || 1, 2). This can render at 1× on an ordinary display; label it Auto rather than claiming it always renders at 200%. - Relative to native resolution: multiply native DPR only when the user explicitly wants that meaning. Native 2× multiplied by another 2 becomes 4× per dimension, or sixteen times the CSS pixel count.
Keep an explicit quality selection distinct from automatic adaptation. Inspect the project's renderer and post-processing architecture before changing sizing.
Synchronize the rendering pipeline
Use CSS to size the canvas and its container, then measure the container in CSS pixels. In Three.js WebGL, one consistent convention is logical sizes plus pixel ratio:
function resize3D(width, height, ratio = 2) {
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return;
if (!Number.isFinite(ratio) || ratio <= 0) throw new RangeError('Invalid render ratio');
renderer.setPixelRatio(ratio);
renderer.setSize(width, height, false); // CSS owns displayed dimensions
camera.aspect = width / height; // perspective camera
camera.updateProjectionMatrix();
if (composer) {
composer.setPixelRatio(ratio);
composer.setSize(width, height); // logical pixels; do not multiply again
}
const physicalWidth = renderer.domElement.width;
const physicalHeight = renderer.domElement.height;
resizeCustomTargets(physicalWidth, physicalHeight);
}
The snippet assumes an existing renderer, perspective camera, optional composer (or null), and a resizeCustomTargets adapter supplied by the app. For an orthographic camera, update its bounds according to the existing framing policy instead of setting aspect.
The adapter updates only app-owned targets and uniforms; composer-managed passes already receive sizing through the composer. Set full-resolution depth/normal targets to physical dimensions. Size lower-resolution AO, bloom, or ray targets by their deliberate scale factors. Set sampling-resolution uniforms to the dimensions of the texture actually sampled, including reciprocal resolution where the shader expects it.
The renderer and composer each maintain their own pixel ratio. Updating only the canvas can leave a lower-resolution intermediate image stretched to a Retina output. Conversely, passing already doubled dimensions into a composer that also has DPR 2 allocates 4× dimensions. See the renderer and composer sizing APIs.
Handle layout and display changes
Observe the canvas container with ResizeObserver, coalesce notifications, and resize only when dimensions or effective ratio change. Skip zero-sized hidden views and retry when they become visible. Re-evaluate native DPR on browser zoom or display changes in Auto mode, including when CSS dimensions remain unchanged. Recreate a resolution media-query listener after each DPR change if using that approach.
Use canvas.getBoundingClientRect() for pointer normalization: (clientX - rect.left) / rect.width, and likewise for Y. Raycasting uses normalized coordinates derived from CSS space, not drawing-buffer pixels. Convert to physical pixels separately only for APIs such as a pixel readback.
Retina output does not automatically improve a blurry texture, coarse model, shadow map, or low-resolution reflection. Check those sources independently. Avoid CSS scaling or image-rendering: pixelated as a substitute for the correct drawing buffer. Higher resolution and antialiasing solve related but different artifacts.
Budget and fallback
Measure the scene at 1× and 2× with the same camera. Track frame time, target dimensions, allocation failures, and total passes. Check GPU limits before allocating exceptionally large targets, including maximum texture/renderbuffer dimensions and viewport limits.
Reduce optional post-effect resolution o
よくある質問
200パーセントで描画するとレイアウトが変わりますか?
いいえ。レイアウトとカメラの構図は同じままで、描画の詳細だけが変わります。
自動モードは常に200パーセントですか?
いいえ。自動モードは比率を2倍までに抑え、普通の画面では1倍で描画することもあります。
解像度を上げると、シーンが遅くなりますか?
グラフィックスの処理能力を使うため、遅い機器には測定された代替策を使うようスキルは勧めています。
詳細
作者による元の説明
Render a 3D canvas sharply on Retina and HiDPI displays, including explicit 200 percent resolution, synchronized renderer and post-processing sizes, correct pointer coordinates, and measured quality fallbacks. Use for blurry WebGL output, 2x rendering, high-resolution previews, and display-density changes.
repo: MengTo/Skills
人気
- GitHubのスター
- 7.2k
- ランキング
- #13321
- ライセンス
- MIT
- 更新日
- 2026/11/1
コメント
- …
このリポジトリの他のスキル
3d-cloth-material
7.2kThree.js で、糸の織り、柔らかい光沢、自然な襞、裾、縫い目を持つ、本物の織物らしい布を作るようエージェントを支援します。
3d-falling-leaves
7.2k3D のシーンに、回転し、風に流され、カメラの動きに合わせて再利用される、本物らしい落ち葉を加えるようエージェントを支援します。
3d-four-seasons
7.2k3D のシーンに、春、夏、秋、冬の見た目を加え、シーン全体を作り直さずに、茂み、光、空、雪を変えるようエージェントを支援します。
3d-high-poly-models
7.2k滑らかな形と自然な縁をもつ、詳細な3Dモデルを作り、その後、Web で快適に動く軽いバージョンを準備するようエージェントを支援します。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。