Animation rows can target behavior variables and shader parameters (#104)
game-maker / gate (push) Successful in 1m33s
game-maker / suite (push) Successful in 5m38s

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5 committed 2026-09-17 09:04:29 +02:00
1 parent b278605c53
commit beeea355d9
9 files changed
+273 -77

No files matched your search

+15 -17
View File
@@ -5,9 +5,9 @@
*/
import {
animatableDefs,
animatedKind,
animatableDefsOf,
frameCount,
isPositionKey,
isPositionRow,
PLACED_ROOT_ID,
placedRoot,
playbackOf,
@@ -16,9 +16,7 @@ import {
import type { AnimationAsset, AnimationTrack, Asset } from './Asset';
import { instanceChildId, objectRef } from './instance';
import { findAsset, type ObjectHolder, type Project } from './Project';
import type { PropertyValue } from './Properties';
import { resolveSceneObjectProps } from '../properties/resolve';
import type { SceneObject } from './SceneObject';
/** The one object the preview places the root on – what a row aimed at the root itself writes to. */
export const PREVIEW_ROOT_ID = PLACED_ROOT_ID;
@@ -91,17 +89,17 @@ function writeObject(
): void {
const ref = objectRef(project, holder, id);
const asset = ref && findAsset(project, ref.object.assetId);
const kind = asset && animatedKind(asset.type, track.property);
if (!ref || !asset || !kind) return;
const value = trackWriteAt(track, kind, frame, baseOf(project, asset, ref.object, track.property), reverse);
if (value === undefined) return;
if (isPositionKey(track.property))
ref.setPosition({ ...ref.object.position, [track.property]: Number(value) });
else ref.setOverride(track.property, value);
}
/** What the target holds before the animation writes it: the zero of a relative row. */
function baseOf(project: Project, asset: Asset, object: SceneObject, key: string): PropertyValue | undefined {
if (isPositionKey(key)) return object.position[key];
return resolveSceneObjectProps(project, asset, object)[key];
if (!ref || !asset) return;
// Resolved, so a shader worn through an override or an instance edit brings its parameters (#104).
const props = resolveSceneObjectProps(project, asset, ref.object);
const kind = animatableDefsOf(project, asset, props).find((d) => d.key === track.property)?.kind;
if (!kind) return;
const key = track.property;
if (isPositionRow(asset.type, key)) {
const value = trackWriteAt(track, kind, frame, ref.object.position[key], reverse);
if (value !== undefined) ref.setPosition({ ...ref.object.position, [key]: Number(value) });
return;
}
const value = trackWriteAt(track, kind, frame, props[key], reverse);
if (value !== undefined) ref.setOverride(key, value);
}