Skip to content

Instantly share code, notes, and snippets.

@peace098beat
Created August 23, 2014 09:57
Show Gist options
  • Save peace098beat/a682208f29bc10cdc21f to your computer and use it in GitHub Desktop.
Save peace098beat/a682208f29bc10cdc21f to your computer and use it in GitHub Desktop.
[AE Script] 選択したレイヤーのポジションを、カメラの焦点位置としてKeyに書き出す
/********************************************************
---- Deproy_CameraKeyPosition ver.1.0 ----
選択したレイヤーのポジションを、カメラの焦点位置としてKeyに書き出す
(注意)選択したレイヤーは3Dオプション(サイコロアイコン)をつけていないとカメラは対応しません。
by fifi 2014/03/22
/********************************************************/
var comp = app.project.activeItem;
// alert(comp.name)
// var actLayer = app.project.activeItem.selectedLayers[0];
var actLayer = app.project.activeItem.selectedLayers;
// alert(actLayer)
// alert(actLayer.length)
var camera1 = comp.layers.addCamera('Camera1',[0,0]);
var cycle = 0.5;
var ofset = 0.3*cycle;
// var i=0;
for ( var i=0; i<actLayer.length; i++){
var Cxy = actLayer[i].transform.position.value;
// alert(Cxy);
var Cx = Cxy[0]; // tmpLay.transform.position(1).value;
var Cy = Cxy[1]; // tmpLay.transform.yPosition.value;
var Cz = Cxy[2]; //comp1.layer(i).transform.zPosition.value;
// alert(Cx);alert(Cy);alert(Cz);
camera1.property("ADBE Transform Group").property("ADBE Anchor Point").setValueAtTime(i*cycle, [Cx,Cy,Cz]);
camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime(i*cycle, [Cx,Cy,-1000]);
camera1.property("カメラオプション").property("ADBE Camera Zoom").setValue(5000);
//ofset
camera1.property("ADBE Transform Group").property("ADBE Anchor Point").setValueAtTime( ((i+1)*cycle)-ofset, [Cx,Cy,Cz]);
camera1.property("ADBE Transform Group").property("ADBE Position").setValueAtTime( ((i+1)*cycle)-ofset, [Cx,Cy,-1000]);
// i+=cycle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment