Let an animation key Z so an object can pass behind another
The timeline offered X and Y as position rows but never Z. The list of position rows was simply written without it when animations came in with #97. A swinging weapon could therefore not go behind its character. - Z is the third position row, after X and Y, on every placed root or object. A scene and a behavior still offer no position. - Play and preview already read and write any position row by name, so the one entry in POSITION_KEYS is all the code change. - The draw order is sorted on every render, and play writes z back into the scene each frame. A keyed Z therefore takes effect at once. A blended 4.5 sits above 4 and below 5. Tests: - ./check.sh: 165 files, 2416 tests, CHECK EXIT 0. - 3 new unit tests in tests/core/animation.test.ts: Z is offered after X and Y and not on a behavior or scene, a running game moves the object from behind to in front of another one, and play, scene write-back and preview agree on z. - e2e 25: ALL PASSED, 29 checks. The new check reads X, Y, Z as the first rows of the row dialog. Check sum 1396 -> 1397. - Counter-check: without z in the list all 3 new unit tests fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
147f8ffbea
commit
fae827c087
4 files changed
+75
-4
No files matched your search
@@ -25,8 +25,11 @@ export type Playback = (typeof PLAYBACKS)[number];
|
||||
/** What an animation can be built over: something placed, or a whole scene. */
|
||||
export const ANIMATION_ROOT_TYPES: readonly AssetType[] = ['sprite', 'text', 'container', 'scene'];
|
||||
|
||||
/** Position lives on the object, not in its property bag, so the timeline offers it by name. */
|
||||
const POSITION_KEYS = ['x', 'y'] as const;
|
||||
/**
|
||||
* Position lives on the object, not in its property bag, so the timeline offers it by name. `z` is
|
||||
* the draw order, which is sorted on every render, so a keyed `z` moves the object in front or behind.
|
||||
*/
|
||||
const POSITION_KEYS = ['x', 'y', 'z'] as const;
|
||||
|
||||
function isPositionKey(key: string): key is (typeof POSITION_KEYS)[number] {
|
||||
return (POSITION_KEYS as readonly string[]).includes(key);
|
||||
|
||||
Reference in new issue
Block a user