本文へ移動
cccskills
無料GitHub で公開

godot-platform-web

Expert blueprint for HTML5/web export on Compatibility (WebGL 2.0): JavaScriptBridge, localStorage wrapper, custom loading shells, COOP/COEP hosts, relative paths, beforeunload, visibility pause, and size optimization. WebGPU is out of scope. Keywords: web, HTML5, WebGL, Compatibility, JavaScriptBridge, localStorage, COOP, COEP, canvas, browser API.

インストール方法を見る

含まれるファイル(16)

  • SKILL.md11.2 KB
  • references/migration-notes.md2.3 KB
  • references/web-elite-patterns.md1.8 KB
  • scripts/platform_web_patterns.gd4.2 KB
  • scripts/web_bridge_sync.gd2.6 KB
  • scripts/web_browser_input_guard.gd1.4 KB
  • scripts/web_clipboard_interface.gd1.7 KB
  • scripts/web_external_url_opener.gd1.4 KB
  • scripts/web_javascript_bridge_callback.gd1.6 KB
  • scripts/web_json_rpc_bridge.gd1.1 KB
  • scripts/web_local_storage_wrapper.gd2.2 KB
  • scripts/web_navigation_guard.gd1.5 KB
  • scripts/web_performance_profiler.gd1.5 KB
  • scripts/web_resource_lazy_loader.gd1.6 KB
  • scripts/web_responsive_canvas_adaptor.gd1.6 KB
  • scripts/web_visibility_auto_pause.gd1.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

NEVER Do (Expert Web Rules)

Persistence & Storage

  • NEVER use FileAccess alone for persistent web saves — Prefer web_local_storage_wrapper.gd (localStorage / IndexedDB via JavaScriptBridge).
  • NEVER assume localStorage is permanent — Implement cloud-save fallback for production.

Rendering & Logic

  • NEVER use the Forward+ renderer for web — Use Compatibility (WebGL 2.0).
  • NEVER block the browser event loop — Long sync work → "Kill the Page." Use await / threaded workers where available.
  • NEVER ignore COOP/COEP — Threads/SharedArrayBuffer need cross-origin isolation.

UX & Security

  • NEVER forget tab focus loss — Pause audio on visibilitychange.
  • NEVER trigger Fullscreen/Mouse Lock without a click — Must be inside a user gesture.
  • NEVER use absolute paths in HTML shells — Relative paths for subdirectory hosting.

Host checklist (procedure)

  1. HTTPS — Required for many browser APIs (clipboard, some storage policies, secure contexts).
  2. COOP / COEP — Serve isolation headers when enabling threads / SharedArrayBuffer (see exporting-for-web docs).
  3. Relative shell paths — Custom index.html / PCK/WASM URLs must be relative so /game/ subpaths work.
  4. beforeunload — Wire web_navigation_guard.gd when unsaved progress exists.
  5. Compatibility renderer + texture compression — Desktop browsers: S3TC/BPTC as appropriate; keep particle/draw budgets low.

Available Scripts

MANDATORY: For saves, load web_local_storage_wrapper.gd — do not paste JavaScriptBridge.eval("localStorage.setItem...") string recipes.

web_local_storage_wrapper.gd

Quota-safe localStorage via get_interface + JSON (no eval string interpolation).

web_javascript_bridge_callback.gd

Two-way JS↔GD with create_callback (keep callback refs alive).

web_responsive_canvas_adaptor.gd

Canvas resize to browser viewport.

web_browser_input_guard.gd

Suppress context menu / spacebar scroll defaults.

web_resource_lazy_loader.gd

Remote PCK/resource fetch patterns.

web_clipboard_interface.gd

Async clipboard via Navigator API.

web_visibility_auto_pause.gd

Pause engine/audio on tab hide.

web_navigation_guard.gd

beforeunload unsaved-progress guard.

web_external_url_opener.gd

window.open with noopener.

web_performance_profiler.gd

VRAM/draw stats to JS console.

Also in scripts/

Expert WHY (critical)

CAUTION: Never persist via JavaScriptBridge.eval("localStorage.setItem('%s')" % data) — injection/escaping bugs. Use web_local_storage_wrapper.gd.

  • PWA updates — pwa_update_available → pwa_update() when pwa_needs_update().
  • WebGPU — not a Godot 4.x web renderer; ship Compatibility (WebGL 2.0).
  • JSON-RPC host page — structured bidirectional bridge: web_json_rpc_bridge.gd.

Deep dive (load on demand)

PWA lifecycle, JSON-RPC bridge, localStorage anti-patterns, size knobs — references/web-elite-patterns.md.

Loading shell (custom HTML)

<!-- index.html custom loading — keep asset URLs relative -->
<div id="loading-screen">
    <div class="progress-bar"><div id="progress" style="width: 0%"></div></div>
    <p id="status-text">Loading...</p>
</div>
<script>
const engine = new Engine(CONFIG);
engine.startGame({
    onProgress: function(current, total) {
        const percent = Math.floor((current / total) * 100);
        document.getElementById('progress').style.width = percent + '%';
        document.getElementById('status-text').innerText = `Loading ${percent}%`;
    }
}).then(() => {
    document.getElementById('loading-screen').style.display = 'none';
});
</script>

Feature gate

if OS.has_feature("web"):
    # Web-only: storage wrapper, visibility pause, navigation guard
    pass

Size / perf knobs

[rendering]
textures/vram_compression/import_s3tc_bptc=true
textures/vram_compression/import_etc2_astc=true
  • Target ~60 FPS mid-range browsers; cut particles, draw calls, huge textures.
  • Keep download under a practical budget (~50MB) via exclude filters on docs/source.

PWA update hook

func _ready() -> void:
    if OS.has_feature("web"):
        JavaScriptBridge.pwa_update_available.connect(_on_pwa_update)

func _on_pwa_update() -> void:
    if JavaScriptBridge.pwa_needs_update():
        JavaScriptBridge.pwa_update()

Reference

Progressive disclosure: open Official Documentation links only when researching a specific API; load Related Skills when routing work to a peer domain — do not preload the whole lattice.

Official Documentation

Related Skills

Prerequisites

  • godot-project-foundations — Feature tags (web), Compatibility renderer defaults, and display stretch settings every HTML5 export branch depends on.
  • godot-input-handling — InputEvent ownership before suppressing browser defaults (context menu, spacebar scroll) or remapping canvas focus.
  • godot-save-load-systems — Versioned save ownership and cloud-fallback hooks that localStorage wrappers must not invent ad hoc.

Complements

Downstream / consumers

  • godot-export-builds — CI presets, artifact hosting, and size gates after browser APIs and Compatibility settings are locked in.

Master

  • godot-master — Library router and mirrored module entry for discovering this platform skill beside sibling domains.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Bevy ECS skill for 2D sprite animation. Keywords: Bevy, sprite, animation, AnimationPlayer, AnimationClip, 2D.

日本語の概要は準備中です。原文の説明を表示しています。

thedivergentai/Game-Design-Agentic-Skills8452026年10月13日 更新

Bevy ECS skill for 3D lights. Keywords: Bevy, lighting, directional, point, spot, bevy_light, PBR.

日本語の概要は準備中です。原文の説明を表示しています。

thedivergentai/Game-Design-Agentic-Skills8452026年10月13日 更新

Bevy ECS skill for PBR materials. Keywords: Bevy, StandardMaterial, PBR, material, ExtendedMaterial.

日本語の概要は準備中です。原文の説明を表示しています。

thedivergentai/Game-Design-Agentic-Skills8452026年10月13日 更新

Bevy ECS skill for 3D level assembly. Keywords: Bevy, level, scene, mesh, world, ECS.

日本語の概要は準備中です。原文の説明を表示しています。

thedivergentai/Game-Design-Agentic-Skills8452026年10月13日 更新

Bevy ECS skill for abilities. Keywords: Bevy, ability, cooldown, ECS, gameplay.

日本語の概要は準備中です。原文の説明を表示しています。

thedivergentai/Game-Design-Agentic-Skills8452026年10月13日 更新

Bevy ECS skill for moving a Bevy game from 2D to 3D. Keywords: Bevy, 2D, 3D, adapt, camera, sprite.

日本語の概要は準備中です。原文の説明を表示しています。

thedivergentai/Game-Design-Agentic-Skills8452026年10月13日 更新

thedivergentai のスキルをすべて見る

このスキルの問題を報告する