mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-14 19:27:05 -04:00
fix(script): expose AVLayer transform property shortcuts (#816)
This commit is contained in:
1 parent
9a7d3e7699
commit
74b842cc45
2 files changed
+25
No files matched your search
@@ -1117,6 +1117,11 @@ AVLayer.prototype.constructor = AVLayer;
|
||||
var P = AVLayer.prototype;
|
||||
function def(name, get, set) { Object.defineProperty(P, name, { get: get, set: set }); }
|
||||
def("source", function () { return __item(this.__info().source); });
|
||||
// After Effects exposes the most common Transform properties directly on AVLayer.
|
||||
// Return the original Property object, not its current value: scripts can keyframe it.
|
||||
["anchorPoint", "position", "scale", "rotation", "opacity"].forEach(function (name) {
|
||||
def(name, function () { return this.transform[name]; });
|
||||
});
|
||||
def("width", function () { return this.__info().width; });
|
||||
def("height", function () { return this.__info().height; });
|
||||
def("threeDLayer", function () { return this.__info().threeDLayer; }, function (v) { this.__switch("threeD", v); });
|
||||
|
||||
@@ -730,3 +730,23 @@ fn import_options_sequence_picks_one_still_or_the_run() {
|
||||
assert_eq!(kind_of(&s, "shot_[0001-0003].png"), FootageKind::Sequence);
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn script_av_layer_transform_shortcuts_return_live_properties() {
|
||||
let mut s = session();
|
||||
let o = ok(
|
||||
&mut s,
|
||||
r#"
|
||||
var c = app.project.items.addComp("Shortcuts", 100, 100, 1, 5, 25);
|
||||
var l = c.layers.addSolid([1, 0, 0], "S", 10, 10, 1);
|
||||
l.position.setValue([30, 40]);
|
||||
l.rotation.setValueAtTime(1, 45);
|
||||
[l.position.value[0], l.transform.position.value[1], l.rotation.numKeys,
|
||||
l.opacity === undefined, l.scale === undefined, l.anchorPoint === undefined]
|
||||
"#,
|
||||
);
|
||||
assert_eq!(o.result, json!([30, 40, 1, false, false, false]));
|
||||
s.undo();
|
||||
let restored = ok(&mut s, "app.project.item(1).layer(1).rotation.numKeys");
|
||||
assert_eq!(restored.result, json!(0));
|
||||
}
|
||||
Reference in new issue
Block a user