Animation rows can target behavior variables and shader parameters (#104)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b278605c53
commit
beeea355d9
9 files changed
+273
-77
No files matched your search
@@ -2,7 +2,7 @@ import {
|
||||
AddAnimationTrackCommand,
|
||||
RetargetAnimationTrackCommand,
|
||||
} from '../../core/commands/animationCommands';
|
||||
import { animatableDefs, animatedKind, animationTargets, targetAssetOf } from '../../core/model/animation';
|
||||
import { animationTargets, targetDefs, trackDef } from '../../core/model/animation';
|
||||
import type { AnimationAsset, AnimationTrack } from '../../core/model/Asset';
|
||||
import { findAsset } from '../../core/model/Project';
|
||||
import type { PropertyDef } from '../../core/properties/PropertySchema';
|
||||
@@ -135,10 +135,10 @@ export class RowDialog extends Popup {
|
||||
|
||||
/** The properties the picked object offers, less those another row already animates. */
|
||||
private properties(): PropertyDef[] {
|
||||
const aimed = targetAssetOf(this.state.project, this.asset, this.target);
|
||||
if (!aimed) return [];
|
||||
const defs = targetDefs(this.state.project, this.asset, this.target);
|
||||
if (!defs) return [];
|
||||
const was = this.trackKind();
|
||||
return animatableDefs(aimed.type).filter((def) => {
|
||||
return defs.filter((def) => {
|
||||
if (was !== null && def.kind !== was) return false;
|
||||
return !this.asset.tracks.some(
|
||||
(t) => t.id !== this.track?.id && t.target === this.target && t.property === def.key,
|
||||
@@ -146,11 +146,9 @@ export class RowDialog extends Popup {
|
||||
});
|
||||
}
|
||||
|
||||
/** The kind the row being changed has; null when its target is gone, so it may go anywhere. */
|
||||
/** The kind the row being changed has; null when its target or property is gone, so it may go anywhere. */
|
||||
private trackKind(): string | null {
|
||||
if (!this.track) return null;
|
||||
const aimed = targetAssetOf(this.state.project, this.asset, this.track.target);
|
||||
return aimed ? (animatedKind(aimed.type, this.track.property) ?? null) : null;
|
||||
return this.track ? (trackDef(this.state.project, this.asset, this.track)?.kind ?? null) : null;
|
||||
}
|
||||
|
||||
private openTargets(): void {
|
||||
|
||||
@@ -5,11 +5,10 @@ import {
|
||||
SetAnimationKeyCommand,
|
||||
} from '../../core/commands/animationCommands';
|
||||
import {
|
||||
animatedKind,
|
||||
animationPlayheadAt,
|
||||
frameCount,
|
||||
interpolationOf,
|
||||
targetAssetOf,
|
||||
trackDef,
|
||||
trackLabel,
|
||||
} from '../../core/model/animation';
|
||||
import type { AnimationAsset, AnimationTrack, KeyInterpolation } from '../../core/model/Asset';
|
||||
@@ -297,8 +296,7 @@ export class TimelineCanvas extends Widget {
|
||||
|
||||
/** A double click: a key with the value the row has there, picked so the inspector shows it. */
|
||||
private setKey(asset: AnimationAsset, track: AnimationTrack, frame: number): void {
|
||||
const aimed = targetAssetOf(this.state.project, asset, track.target);
|
||||
if (!aimed || !animatedKind(aimed.type, track.property)) {
|
||||
if (!trackDef(this.state.project, asset, track)) {
|
||||
this.state.setNotice('This row aims at something that is gone – change its target first.');
|
||||
return;
|
||||
}
|
||||
@@ -526,7 +524,7 @@ export class TimelineCanvas extends Widget {
|
||||
this.labels.set(track.id, label);
|
||||
this.labelLayer.addChild(label);
|
||||
}
|
||||
const missing = !asset || !targetAssetOf(this.state.project, asset, track.target);
|
||||
const missing = !asset || !trackDef(this.state.project, asset, track);
|
||||
const text = asset ? trackLabel(this.state.project, asset, track) : '';
|
||||
if (label.text !== text) label.text = text;
|
||||
label.style = textStyle(missing ? 'warning' : track.id === selectedRow ? 'accent' : 'body');
|
||||
|
||||
@@ -7,11 +7,10 @@ import {
|
||||
SetTrackRelativeCommand,
|
||||
} from '../../core/commands/animationCommands';
|
||||
import {
|
||||
animatableDefs,
|
||||
blends,
|
||||
interpolationOf,
|
||||
KEY_INTERPOLATIONS,
|
||||
targetAssetOf,
|
||||
trackDef,
|
||||
trackLabel,
|
||||
} from '../../core/model/animation';
|
||||
import type { AnimationAsset, AnimationKey, AnimationTrack, KeyInterpolation } from '../../core/model/Asset';
|
||||
@@ -201,8 +200,7 @@ export function refreshTrackSection(
|
||||
}
|
||||
|
||||
function defOf(project: Project, asset: AnimationAsset, track: AnimationTrack) {
|
||||
const aimed = targetAssetOf(project, asset, track.target);
|
||||
return aimed ? animatableDefs(aimed.type).find((d) => d.key === track.property) : undefined;
|
||||
return trackDef(project, asset, track);
|
||||
}
|
||||
|
||||
function kindOf(project: Project, asset: AnimationAsset, track: AnimationTrack): string | undefined {
|
||||
|
||||
Reference in new issue
Block a user