Untitled

mail@pastecode.io avatar
unknown
javascript
a year ago
2.2 kB
2
Indexable
Never
function outputFrame(leftLeg, rightLeg, leftArm, rightArm, head) {
  // Get the current time of the composition
  var comp = app.project.activeItem;
  var currentTime = comp.time;

  // Loop through each layer in the composition
  for (var i = 1; i <= comp.numLayers; i++) {
    var layer = comp.layer(i);

    // Check if the layer is a puppet pin group
    if (layer instanceof AVLayer && layer.hasVideo && layer.property("ADBE Effect Parade") != null) {
      var pins = layer.property("ADBE Effect Parade").property("ADBE FreePin3").property("ADBE Pins").property("ADBE FreePin Group");
      if (pins != null) {
        // Loop through each puppet pin in the group
        for (var j = 1; j <= pins.numProperties; j++) {
          var pin = pins.property(j);

          // Check if the puppet pin has a position and rotation property
          if (pin.property("ADBE FreePin Position") != null && pin.property("ADBE FreePin Rotation") != null) {
            var pinPosition = pin.property("ADBE FreePin Position");
            var pinRotation = pin.property("ADBE FreePin Rotation");

            // Update the position and rotation of the puppet pin based on the new values
            if (pin.name == "Left Leg") {
              pinPosition.setValue([leftLeg.x, leftLeg.y]);
              pinRotation.setValue(leftLeg.rotation);
            } else if (pin.name == "Right Leg") {
              pinPosition.setValue([rightLeg.x, rightLeg.y]);
              pinRotation.setValue(rightLeg.rotation);
            } else if (pin.name == "Left Arm") {
              pinPosition.setValue([leftArm.x, leftArm.y]);
              pinRotation.setValue(leftArm.rotation);
            } else if (pin.name == "Right Arm") {
              pinPosition.setValue([rightArm.x, rightArm.y]);
              pinRotation.setValue(rightArm.rotation);
            } else if (pin.name == "Head") {
              pinPosition.setValue([head.x, head.y]);
              pinRotation.setValue(0);
            }

            // Add a keyframe for the position and rotation properties at the current time
            pinPosition.addKey(currentTime);
            pinRotation.addKey(currentTime);
          }
        }
      }
    }
  }
}