77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.
Python agent-skillsai-agentsantigravityawesome-listclaude-codeclinecodexcursorgame-devgame-developmentgamedevgemini-cligithub-copilotgodotkirooh-my-piskillsunityunrealwindsurf
fix(threejs): update glTF decoder setup for r185+ defaults, meshopt, and cross-fades
Kiro Crewe79d2b37b4e8
diff --git a/skills/web-engines/threejs-gltf-loading/SKILL.md b/skills/web-engines/threejs-gltf-loading/SKILL.mdindex 76a3cb3..4fa63ee 100644--- a/skills/web-engines/threejs-gltf-loading/SKILL.md+++ b/skills/web-engines/threejs-gltf-loading/SKILL.md@@ -39,9 +39,10 @@ of scope; prefer glTF over OBJ/FBX for runtime.`traverse` / `getObjectByName` to find the parts you'll control.4. **Play animations with an `AnimationMixer`.** One mixer per animated root;`mixer.clipAction(clip).play()`; advance with `mixer.update(delta)` every frame.-5. **Decode compressed assets.** Attach a `DRACOLoader` (and/or `KTX2Loader` +- Meshopt) so DRACO meshes and KTX2 textures load; point the decoders at their- files.+5. **Decode compressed assets.** Attach a `DRACOLoader`, a `KTX2Loader`, and/or+ the Meshopt decoder so DRACO meshes, KTX2 textures, and meshopt-compressed+ buffers load. Since r185 the DRACO and KTX2 loaders find their bundled+ decoder files on their own.6. **Validate changed glTF files when the project already has the tool.** Run`gltf-transform validate path/to/model.glb` for each changed `.gltf` or `.glb`;fix reported errors before loading.@@ -64,7 +65,10 @@ loader.load(// Inspect: gltf.animations is an array of AnimationClip.console.log('clips:', gltf.animations.map((c) => c.name));},- (event) => console.log(`${(event.loaded / event.total) * 100}% loaded`),+ (event) => {+ // total is 0 when the server sends no Content-Length (e.g. compressed responses)+ if (event.total) console.log(`${(event.loaded / event.total) * 100}% loaded`);+ },(error) => console.error('glTF load failed:', error));```@@ -102,14 +106,15 @@ mixer = new THREE.AnimationMixer(gltf.scene);for (const clip of gltf.animations) {actions[clip.name] = mixer.clipAction(clip);}-actions['Idle'].play();+let current = actions['Idle'];+current.play();function transitionTo(name, duration = 0.3) {const next = actions[name];- next.reset().play();- for (const [n, action] of Object.entries(actions)) {- if (n !== name) action.crossFadeTo(next, duration, false);- }+ if (!next || next === current) return;+ next.reset().play(); // rewind and clear any old fade+ current.crossFadeTo(next, duration, false); // fade the old one out, new one in+ current = next;}```@@ -117,20 +122,27 @@ function transitionTo(name, duration = 0.3) {```jsimport { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';-import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';+import { DRACOLoader, DRACO_GLTF_CONFIG } from 'three/addons/loaders/DRACOLoader.js';-const draco = new DRACOLoader();-// Point at the decoder files you ship (or a pinned CDN copy of the same version).-draco.setDecoderPath('https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/draco/');+// r185+: DRACOLoader finds the decoder that ships next to it in+// three/examples/jsm/libs/draco/, so no path is required. DRACO_GLTF_CONFIG+// (also r185+) selects the smaller glTF-only WASM build in libs/draco/gltf/.+const draco = new DRACOLoader().setDecoderPath(DRACO_GLTF_CONFIG);const loader = new GLTFLoader();-loader.setDRACOLoader(draco);+loader.setDRACOLoader(draco); // share one DRACOLoader across loadsloader.load('assets/city-draco.glb', (gltf) => scene.add(gltf.scene));```+On releases before r185, or when your host does not serve those files, pass a+folder instead: `draco.setDecoderPath('/decoders/draco/')` with the files copied+from the same `three` version.+### 5. Find and animate a named part```js+const timer = new THREE.Timer();+new GLTFLoader().load('assets/car.glb', (gltf) => {scene.add(gltf.scene);const wheels = [];@@ -158,9 +170,16 @@ new GLTFLoader().load('assets/car.glb', (gltf) => {passed milliseconds instead of seconds (use `timer.getDelta()` after`timer.update(time)`), or you forgot`action.play()`.-- **DRACO/KTX2 model fails** → the decoder/transcoder path is wrong or version-- mismatched. `setDecoderPath`/`setTranscoderPath` must point at files matching your- three.js version.+- **DRACO/KTX2 model fails, or the network tab shows a 404 for `draco_*`/`basis_*`+ files** → the decoder/transcoder files are not being served, or come from a+ different three.js version. Since r185 the loaders default to the copies inside+ `three/examples/jsm/libs/`; if your bundler or host doesn't serve those, copy the+ folders from the installed `three` and point `setDecoderPath`/`setTranscoderPath`+ at them.+- **`setKTX2Loader must be called before loading KTX2 textures`** or+ **`setMeshoptDecoder must be called before loading compressed files`** → the+ asset uses `KHR_texture_basisu` or meshopt compression (`EXT_`/`KHR_meshopt_compression`);+ attach the missing decoder (see the reference).- **Multiple mixers fighting** → use **one** `AnimationMixer` per animated root andcreate all actions from it; don't make a new mixer per clip.- **Baked-in transforms surprise you** → exporters sometimes bake scale/rotation ontodiff --git a/skills/web-engines/threejs-gltf-loading/references/loaders-and-animation.md b/skills/web-engines/threejs-gltf-loading/references/loaders-and-animation.mdindex 6771b62..1d7f760 100644--- a/skills/web-engines/threejs-gltf-loading/references/loaders-and-animation.md+++ b/skills/web-engines/threejs-gltf-loading/references/loaders-and-animation.md@@ -1,7 +1,8 @@-# three.js glTF: loaders, compression & animation detail (r150+)+# three.js glTF: loaders, compression & animation detail (r186)Depth behind the glTF skill: combining decoders, async loading with progress,-cloning skinned meshes, and exporter hygiene.+cloning skinned meshes, and exporter hygiene. Notes call out where older releases+differ.## Compression: DRACO, Meshopt, KTX2@@ -10,29 +11,38 @@ textures (KTX2/Basis). Attach the matching loaders to `GLTFLoader`:```jsimport { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';-import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';+import { DRACOLoader, DRACO_GLTF_CONFIG } from 'three/addons/loaders/DRACOLoader.js';import { KTX2Loader } from 'three/addons/loaders/KTX2Loader.js';import { MeshoptDecoder } from 'three/addons/libs/meshopt_decoder.module.js';-const VERSION = '0.186.0';-const base = `https://cdn.jsdelivr.net/npm/three@${VERSION}/examples/jsm/libs/`;--const draco = new DRACOLoader().setDecoderPath(`${base}draco/`);-const ktx2 = new KTX2Loader().setTranscoderPath(`${base}basis/`).detectSupport(renderer);+// r185+: both loaders default to the decoder files bundled with three+// (examples/jsm/libs/draco/ and examples/jsm/libs/basis/).+const draco = new DRACOLoader().setDecoderPath(DRACO_GLTF_CONFIG); // glTF-only WASM build+const ktx2 = new KTX2Loader().detectSupport(renderer);const loader = new GLTFLoader().setDRACOLoader(draco).setKTX2Loader(ktx2)- .setMeshoptDecoder(MeshoptDecoder);+ .setMeshoptDecoder(MeshoptDecoder); // EXT_ and KHR_meshopt_compression (r183+)loader.load('assets/scene.glb', (gltf) => scene.add(gltf.scene));```Notes:-- The decoder/transcoder files must match your three.js version. Ship them with- your app or pin a CDN copy to the same version; a mismatch throws at load time.-- `ktx2.detectSupport(renderer)` requires the renderer to exist first.+- If the default files 404 (some bundler/host setups don't serve them), copy+ `examples/jsm/libs/draco/` and `examples/jsm/libs/basis/` from the installed+ `three` into your static assets and call `draco.setDecoderPath('/decoders/draco/')`+ and `ktx2.setTranscoderPath('/decoders/basis/')`. A pinned CDN folder such as+ `https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/libs/basis/` also works;+ on releases before r185 one of these paths is required.+- The decoder/transcoder files must match your three.js version; a mismatch throws+ at load time.+- `ktx2.detectSupport(renderer)` requires the renderer to exist first. With+ `WebGPURenderer`, `await renderer.init()` before calling it+ (`detectSupportAsync()` is deprecated since r181).+- `DRACOLoader.setDecoderConfig()` is deprecated since r185; the loader picks WASM+ or JS itself.- Compression shrinks downloads but adds CPU/Worker decode time; measure both.## Async loading with a progress bar@@ -67,17 +77,20 @@ so the skinned mesh and its skeleton are cloned correctly (a plain `.clone()` donot duplicate the skeleton):```js+import * as THREE from 'three';import { clone as skeletonClone } from 'three/addons/utils/SkeletonUtils.js';-const base = (await loader.loadAsync('assets/enemy.glb')).scene;+const enemy = await loader.loadAsync('assets/enemy.glb');+const mixers = [];for (let i = 0; i < 10; i++) {- const instance = skeletonClone(base);+ const instance = skeletonClone(enemy.scene);instance.position.x = i * 2;scene.add(instance);const mixer = new THREE.AnimationMixer(instance); // each clone needs its own mixer- mixer.clipAction(baseClips[0]).play();- mixers.push(mixer); // update all in the loop+ mixer.clipAction(enemy.animations[0]).play(); // clips can be shared+ mixers.push(mixer);}+// In the loop: for (const m of mixers) m.update(dt);```For static (non-skinned) meshes, prefer `InstancedMesh` for thousands of copies —