Exemples pour gg-web-engine

VérifiéSûr

Création ou mise à jour de projets de démonstration dans examples/ de gg-web-engine, incluant des exemples webpack et des intégrations de frameworks. Utilisez pour ajouter de nouveaux exemples, pas pour le développement d'applications générales.

Spar Skills Guide Bot
DeveloppementIntermédiaire
29/08/2026
Claude Code
#examples#webpack#game-engine#typescript#framework-integration

Recommandé pour

Synthèse automatique

Ajoute ou met à jour un projet de démonstration sous examples/ dans le dépôt gg-web-engine, en copiant un modèle webpack ou framework et en enregistrant le nouvel exemple.

Points forts

  • Guide le choix du modèle selon la combinaison bibliothèque visuelle / moteur physique, avec une convention de nommage explicite
  • Documente le piège du target tsconfig en ES5 qui provoque l'erreur runtime « Class constructor cannot be invoked without 'new' » dans le bundle webpack
  • Rappelle les étapes d'enregistrement (examples-list.txt pour le bump de versions, index.html pour la galerie StackBlitz)
  • Explique comment lier localement le moteur pour tester des changements non publiés plutôt que de forger un faux numéro de version

Limites

  • Fortement spécifique au dépôt gg-web-engine : inutilisable ailleurs
  • Le snippet bash pour le lien local est tronqué dans le SKILL.md
  • Ne décrit aucune validation automatisée de l'exemple au-delà de l'exécution manuelle dans le navigateur
Quand l'utiliser

Quand il faut créer un nouvel exemple ou une démo dans le dépôt gg-web-engine.

Quand l'éviter

Quand on développe une application consommant une version publiée de @gg-web-engine en dehors du dépôt.

Analyse de sécurité

Sûr
Score qualité82/100

This is purely a documentation/instruction skill describing repository conventions for adding example projects. The only executable actions referenced are conventional npm install/build/start and helper bash scripts that link/unlink local packages by path — no curl|sh, rm -rf, secret exfiltration, base64 payloads, or safety-disabling instructions. Execution risk is minimal and confined to a local development repo.

Points d'attention
  • •Instructs running local repo scripts (`etc/switch_example_to_local_gg.sh`, `etc/restore_example_from_local_gg.sh`) and standard npm commands (`npm install`, `npm run start`, `npm run build`), but all operate on the local repo with no data exfiltration or destructive/obfuscated behavior.
Comment cette analyse est faite

Exemples

New plain webpack demo
Add a new plain webpack example under examples/ that demos collision groups with three.js and rapier3d, named collision-groups-three-rapier3d, and register it in examples-list.txt.
Framework integration sample
Create a React integration example for pixi.js + rapier2d under examples/, copying the existing framework-react-three-rapier3d template and wiring world creation/disposal in useEffect.
Debug class constructor error
My new example's production webpack bundle throws 'Class constructor cannot be invoked without new' in the browser — find out why and fix it.

name: gg-engine-examples description: Add or update a demo project under examples/ in gg-web-engine (webpack demos, framework integration samples, or the StackBlitz gallery). Use when the task is to create a new example app, not general app development against a published engine version outside this repo.

Adding an example project

examples/ holds one small, focused demo per feature/combination — they double as manual integration tests (rendering adapters have little automated testing, see gg-engine-visual-adapter) and as the tutorials linked from the README/StackBlitz gallery.

Pick a template

  • Plain webpack demo (most examples): copy the nearest existing example with a matching visual+physics combination, e.g. examples/primitives-three-ammo or examples/primitives-pixi-rapier2d. Contains index.html, index.ts, webpack.config.js (prod build), webpack.dev.config.js (dev server), tsconfig.json, package.json.
  • Framework integration sample: copy examples/framework-angular-three-ammo or examples/framework-react-three-rapier3d instead — these have framework-specific tooling and lifecycle wiring (create the world in ngOnInit/useEffect, dispose on teardown).

Naming convention: <feature-or-topic>-<visual-lib>-<physics-lib> (e.g. collision-groups-pool-three-rapier3d, glb-loader-three-ammo). Physics-only or render-only demos just omit the missing half.

package.json

Pin @gg-web-engine/* and underlying library (three/pixi.js/rapier compat build) versions to whatever packages/core/package.json's current version is — examples are not meant to float on version ranges. Copy the browser field ({"fs": false, "os": false, "path": false}) when the physics lib is Ammo (needed to stub Node built-ins the WASM glue references).

tsconfig target

Set compilerOptions.target in the example's tsconfig.json to ES2020 (the value already used by most examples) or higher — never ES5 and never leave it unset (tsc's default is lower still). packages/core and every adapter are published compiled at target: es2016 (tsconfig.base.json at the repo root), which keeps real ES2015+ class syntax (native classes aren't downleveled at that target, only newer syntax like async/await is). If an example compiles its own code at ES5, tsc/ts-loader downlevels any class ... extends <ImportedBaseClass> in the example (e.g. a custom entity extending IEntity, or Gg3dWorld itself if subclassed) into the ES5 __extends helper, which calls the parent via Base.call(this, ...) instead of new. Calling a real ES2015+ class without new throws TypeError: Class constructor X cannot be invoked without 'new' at runtime — in a webpack production bundle this surfaces minified as Class constructor E cannot be invoked without 'new' at new I, with no build-time error, since both tsc and webpack compile/bundle successfully; it only fails when the bundle actually runs in a browser. This bit essentially every plain-webpack example at once (they'd all copied an ES5 tsconfig.json from an older template) — if a fresh example's bundle throws this in the browser, check its tsconfig.json target before looking anywhere else.

Register the example

  1. Add the directory name (no examples/ prefix) as a new line in examples/examples-list.txt — etc/publish_new_version.sh reads this file to bulk-bump every example's dependency versions after a release. Skipping this means the example silently keeps pointing at an old version.
  2. Add an entry to examples/index.html (the StackBlitz gallery page) if the example should be publicly browsable; it references the same sbBranchSuffix release-branch mechanism used by the release script.

Developing against unpublished engine changes

If the example needs to exercise an in-progress change to core or an adapter (not yet published to npm), don't bump to a fake version — link locally instead:

bash etc/switch_example_to_local_gg.sh examples/<your-example-dir>

This strips the @gg-web-engine/* lines from the example's package.json, npm links the local packages/* builds in by path instead, and patches tsconfig.json path mappings for libraries whose types live under a linked package's own node_modules (three/pixi/ammo — see the fix_*_paths functions in the script). It's idempotent (safe to re-run) and reversible — undo it with bash etc/restore_example_from_local_gg.sh examples/<your-example-dir>. Run npm install at the repo root first if the local adapter packages themselves need to pick up local core changes; for the full "edit core, see it live in this example" watch-mode loop (tsc -b --watch + npm start), see gg-engine-core-development's local dev workflow section.

Running

cd examples/<your-example-dir>
npm install
npm run start   # webpack-dev-server, for plain webpack examples
npm run build   # produces dist/bundle.js for static hosting

Writing the demo itself

Examples are read as documentation — keep index.ts/src/ short, comment the non-obvious parts (why a controller is attached, what a collision group demonstrates), and prefer the same bootstrap shape used in the root README.md quickstart so readers can map one to the other. See gg-engine-app-development for the API surface to draw on.

Give world an explicit type annotation from the visual adapter package (e.g. const world: ThreeGgWorld = new Gg3dWorld({...}), imported from @gg-web-engine/three; pixi equivalents follow the same naming) whenever the demo reaches through world.visualScene for adapter-specific members like nativeScene. Gg3dWorld's generic inference from the constructor argument alone does not carry the concrete visual scene type through — world.visualScene infers as the base IVisualScene3dComponent interface, which doesn't declare adapter-specific members, so any access like world.visualScene.nativeScene fails with TS2339: Property 'nativeScene' does not exist on type 'IVisualScene3dComponent<...>' regardless of which physics adapter is paired with it. The explicit annotation sidesteps the inference entirely and is the pattern already used by examples like collision-groups-three-ammo.

Keep this skill current

This file is read by future agents adding examples to this repo, not by end users of the engine. If the registration steps here turn out incomplete (a build/CI/StackBlitz step this file doesn't mention), or the local-linking workflow needed an extra fix to actually work, add a short note (what went wrong, why, the fix) before finishing — folded into the relevant section rather than left as a loose log entry.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/gg-web-engine-examples-mte1lgaf' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/gg-web-engine-examples-mte1lgaf/download' --output '.skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md.part' && mv '.skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md.part' '.skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md' && test -s '.skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/gg-engine-examples' && cp -R '.skill-downloads/gg-web-engine-examples-mte1lgaf' '.claude/skills/gg-engine-examples'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/gg-web-engine-examples-mte1lgaf'

openskills read 'gg-web-engine-examples-mte1lgaf'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/gg-web-engine-examples-mte1lgaf/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires