forked from kyletmartinez/after-effects-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate Eye Rig.jsx
75 lines (73 loc) · 3.47 KB
/
Create Eye Rig.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* @name Create Eye Rig
* @version 1.2
* @author Kyle Martinez <www.kyle-martinez.com>
*
* @description Used specifically for a current project. Creates an eye rig for a selected eye
* layer. Probably pretty usless outside of this specific use case but has some nice code to
* steal for future scripts.
*
* @license This script is provided "as is," without warranty of any kind, expressed or implied. In
* no event shall the author be held liable for any damages arising in any way from the use of this
* script.
*
* In other words, I'm just trying to help make life as an animator easier
* "A rising tide lifts all boats." - John F. Kennedy, 1963
*/
(function createEyeRig() {
var prefix = prompt("Which side?", "Left");
if (prefix !== null && prefix !== "") {
app.beginUndoGroup("Create Eye Rig");
var comp = app.project.activeItem;
comp.time = 0;
var eyeLayer = comp.selectedLayers[0];
eyeLayer.name = prefix + " Eye";
var eyelidLayer = eyeLayer.duplicate();
eyeLayer.selected = false;
eyelidLayer.selected = true;
eyelidLayer.label = 16;
eyelidLayer.name = prefix + " Eyelid";
var effects = eyelidLayer.property("ADBE Effect Parade");
var blinkEffect = effects.addProperty("ADBE Slider Control");
blinkEffect.name = "Blink";
var expression = [
"valueAtTime(linear(effect(\"Blink\")(\"Slider\").value,",
"0,",
"100,",
"key(1).time,",
"key(numKeys).time));"
].join(" ");
eyelidLayer.transform.position.dimensionsSeparated = false;
eyelidLayer.transform.position.addKey(0);
eyelidLayer.transform.position.expression = expression;
eyelidLayer.transform.position.expressionEnabled = false;
eyelidLayer.transform.position.addKey(1);
eyelidLayer.transform.scale.addKey(0);
eyelidLayer.transform.scale.expression = expression;
eyelidLayer.transform.scale.expressionEnabled = false;
eyelidLayer.transform.scale.addKey(1);
eyelidLayer.transform.scale.setValueAtKey(1, [150, 0]);
eyelidLayer.transform.scale.setValueAtKey(2, [150, 100]);
eyeLayer.setTrackMatte(eyelidLayer, TrackMatteType.ALPHA_INVERTED);
blinkEffect.property(1).addToMotionGraphicsTemplateAs(comp, prefix + " Blink");
var containingComp = comp.usedIn[0];
var containingCompLayers = containingComp.layers;
var numContainingCompLayers = containingCompLayers.length;
for (var l = 1; l <= numContainingCompLayers; l++) {
var layer = containingCompLayers[l];
if (layer.source === comp) {
var blinkProperty = layer.essentialProperty(prefix + " Blink");
var inTemporalEase = new KeyframeEase(0, 88);
var outTemporalEase = new KeyframeEase(0, 66);
blinkProperty.setValueAtTime(comp.frameDuration * 0, 0);
blinkProperty.setTemporalEaseAtKey(1, [inTemporalEase], [outTemporalEase]);
blinkProperty.setValueAtTime(comp.frameDuration * 8, 100);
blinkProperty.setTemporalEaseAtKey(2, [inTemporalEase], [outTemporalEase]);
blinkProperty.setValueAtTime(comp.frameDuration * 16, 0);
blinkProperty.setTemporalEaseAtKey(3, [inTemporalEase], [outTemporalEase]);
blinkProperty.expression = "posterizeTime(12); value;";
}
}
app.endUndoGroup();
}
})();