fix(battle-scene): animate counterattack + auto-preload GLBs + click-to-reset#360
Merged
fix(battle-scene): animate counterattack + auto-preload GLBs + click-to-reset#360
Conversation
…to-reset
Battle flow fixes from Cricket QA session:
- BattleSceneCanvas: replace hardcoded preload list (missing giant-spider,
hook-horror, basilisk) with auto-discovery over MONSTER_TEMPLATES_REDUX
via the new asGLBDrawFn narrower. Fixes the "old spider refreshes"
delay where the procedural fallback was shown until the GLB lazily
loaded mid-battle.
- triggerAttack: splice in-flight same-side attacks before pushing a new
one (click-to-reset so the player isn't queued behind a stale RAF).
Pushed out via spliceSameSideAttacks helper for unit testing.
- triggerAttack: monster counterattack now actually animates — looks up
the monster template via templateRef, calls playClip('attack') for GLB
creatures, or sets state.monsterAnim for ASCII-only (Ooze, Crawler).
Cleanup block in RAF loop clears monsterAnim once the duration window
elapses so the next attack starts from idle.
- MonsterAsciiRenderer: add 'attack' action to AnimAction with a 3-phase
windup/strike/recover curve. Monsters face LEFT, so windup pulls to
+X and strike lunges to -X. durationOverride support so ranged/spell
attacks honor WEAPON_SPEED instead of the 600ms melee default.
- glbCreatureLoader: export GLBDrawFn type + asGLBDrawFn narrower.
makeGLBDrawFn attaches glbUrl/glbGridW/glbGridH/glbYaw so the preload
loop can discover GLBs without a hardcoded list. playClip now restarts
LoopOnce clips when called with the same action (required so rapid
consecutive attacks replay instead of silently no-op'ing).
- glbItemLoader: fix Three.js warning from `emissive: undefined` — pass
a black Color when emissiveIntensity is 0.
Tests: +22 new tests across 4 files
- glbCreatureLoader.test.ts (5): asGLBDrawFn duck-typing
- BattleSceneCanvas.test.ts (6): spliceSameSideAttacks semantics
- MonsterAsciiRenderer.test.ts (8): 3-phase attack curve + boundaries
- monsterTemplatesRedux.test.ts (+3): glbUrl contract on every dynamic
template (guards the "silent preload skip" class of bug)
All 71 tests pass across the 8 touched test files.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
mokn
added a commit
that referenced
this pull request
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MONSTER_TEMPLATES_REDUXinstead of a hardcoded preload list — fixes the "old spider refreshes" delay where giant-spider, hook-horror, and basilisk were lazy-loading mid-battle.attackclip, ASCII-only creatures (Ooze, Carrion Crawler) run a new 3-phasecomputeAnimParamscurve (windup +X → strike -X → recover) since monsters face LEFT.playClipnow restarts LoopOnce clips when called with the same action, so rapid consecutive attacks replay instead of silently no-op'ing.glbItemLoader: fix Three.js warning fromemissive: undefinedat zero intensity.573a7ad1) via merge-forward.Test plan
glbCreatureLoader.test.ts(5) —asGLBDrawFnduck-typingBattleSceneCanvas.test.ts(6) —spliceSameSideAttacksbackwards iteration, same-side splicing, counter-side leave-aloneMonsterAsciiRenderer.test.ts(8) — 3-phase attack curve,durationOverride, windup→strike boundary continuitymonsterTemplatesRedux.test.ts(+3) — every dynamic template exposesglbUrl(guards the silent-preload-skip bug class)durationOverridehonorsWEAPON_SPEEDinstead of the 600 ms melee default🤖 Generated with Claude Code