{"id":17828,"date":"2016-01-06T22:17:27","date_gmt":"2016-01-06T13:17:27","guid":{"rendered":"https:\/\/cg-method.com\/after-effects\/?p=17828"},"modified":"2026-01-12T18:00:02","modified_gmt":"2026-01-12T09:00:02","slug":"after-effects-3d-background-comp-size-script","status":"publish","type":"post","link":"https:\/\/cg-method.com\/after-effects\/after-effects-3d-background-comp-size-script\/","title":{"rendered":"After Effects\u25023D\u80cc\u666f\u3092\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u306e\u30b5\u30a4\u30ba\u306b\u8abf\u6574\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8"},"content":{"rendered":"\n<p>3D\u80cc\u666f\u3092\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u30b5\u30a4\u30ba\u306b\u5408\u308f\u305b\u305f\u3044<\/p>\n\n\n\n<p>\u305f\u3060\u30a4\u30e9\u30b9\u30c8\u3092\u30ba\u30fc\u30e0\u3059\u308b\u306e\u306f\u7d75\u7684\u306b\u3064\u307e\u3089\u306a\u3044\u306e\u3067\u3001\u3059\u3079\u30663D\u30ec\u30a4\u30e4\u30fc\u306b\u3057\u3066\u30ab\u30e1\u30e9\u306e\u30ba\u30fc\u30e0\u3067\u7a7a\u9593\u3092\u611f\u3058\u3064\u3064\u30ba\u30fc\u30e0\u3059\u308b\u624b\u6cd5\u306f\u3088\u304f\u3084\u308b\u306e\u3067\u3059\u304c\u3001Z\u4f4d\u7f6e\u306b\u5024\u3092\u5165\u308c\u305f\u5f8c\u306b\u76ee\u5408\u308f\u305b\u3067\u80cc\u666f\u306e\u30b9\u30b1\u30fc\u30eb\u3092\u8abf\u6574\u3059\u308b\u306e\u3082\u3042\u308c\u306a\u306e\u3067\u3001\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u30b5\u30a4\u30ba\u3092\u63a2\u308b\u65b9\u6cd5\u3067\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b7\u30fc\u30f3\u306e\u6e96\u5099<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img decoding=\"async\" src=\"https:\/\/cg-method.com\/after-effects\/wp-content\/uploads\/2019\/06\/Screenshot_2019_0601_02.png\" alt=\"\" class=\"wp-image-4662\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list is-style-num_circle\">\n<li>\u30ab\u30e1\u30e9\u3001\u4eba\u7269\u3001\u80cc\u666f\u3092\u914d\u7f6e\u3057\u307e\u3059<\/li>\n\n\n\n<li>\u4eba\u7269\u3068\u80cc\u666f\u30923D\u30ec\u30a4\u30e4\u30fc\u306b<\/li>\n\n\n\n<li>\u6700\u5f8c\u306b\u80cc\u666f\u3060\u3051\u9069\u5f53\u306bZ\u4f4d\u7f6e\u306b\u5024\u3092\u5165\u308c\u3066\u304a\u304d\u307e\u3059<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3<\/h2>\n\n\n\n<p>3D\u30ec\u30a4\u30e4\u30fc\u306e\u80cc\u666f\u306e\u30b9\u30b1\u30fc\u30eb\u306b\u4e0b\u8a18\u306e\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u633f\u5165\u3057\u307e\u3059\uff08\u203b\u30ab\u30e1\u30e9\u540d\u3092\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\uff09\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>camera = thisComp.layer(&quot;\u30ab\u30e1\u30e9 1&quot;);  \npoint1 = position;  \npoint2 = camera.position;  \ndistance = length(point1, point2);  \nsize = (distance\/camera.zoom) * 100;\n[size, size, 100]<\/code><\/pre><\/div>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img decoding=\"async\" src=\"https:\/\/cg-method.com\/after-effects\/wp-content\/uploads\/2019\/06\/bg.gif\" alt=\"\" class=\"wp-image-4661\"\/><\/figure>\n\n\n\n<p>Z\u65b9\u5411\u3092\u3044\u3058\u3063\u3066\u3082\u3001\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u306e\u30b5\u30a4\u30ba\u306b\u3074\u3063\u305f\u308a\u306e\u307e\u307e\u30b9\u30b1\u30fc\u30eb\u304c\u5909\u5316\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ed5\u4e0a\u3052<\/h2>\n\n\n\n<p>\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u304c\u5229\u3044\u305f\u307e\u307e\u3060\u3068\u3001\u30ba\u30fc\u30e0\u4e2d\u3082\u80cc\u666f\u306f\u540c\u3058\u30b5\u30a4\u30ba\u3092\u4fdd\u3063\u305f\u307e\u307e\u306b\u306a\u308b\u306e\u3067\u3001\u4e00\u756a\u80cc\u666f\u304c\u5f15\u3044\u3066\u3044\u308b\u6642\u306e\u72b6\u614b\u3067\u30ad\u30fc\u3092\u6253\u3061\u3001\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u5207\u3063\u3066\u30b9\u30b1\u30fc\u30eb\u306e\u5024\u3092\u56fa\u3081\u3066\u3057\u307e\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-border\"><img decoding=\"async\" src=\"https:\/\/cg-method.com\/after-effects\/wp-content\/uploads\/2019\/06\/bg2.gif\" alt=\"\" class=\"wp-image-4663\"\/><\/figure>\n\n\n\n<p>\u305f\u3060\u306e\u30b9\u30b1\u30fc\u30eb\u3088\u308a\u3001\u30ab\u30e1\u30e9\u306e\u30ba\u30fc\u30e0\u306e\u307b\u3046\u304c\u826f\u3044\u3067\u3059\u3088\u306d\uff01<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3D\u80cc\u666f\u3092\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u306e\u30b5\u30a4\u30ba\u306b\u8abf\u6574\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c8<\/h2>\n\n\n\n<p>\u30ab\u30e1\u30e9\u540d\u306f\u300c\u30ab\u30e1\u30e9 1\u300d\u306b\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>app.beginUndoGroup(&quot;3D\u80cc\u666f\u3092\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u306e\u30b5\u30a4\u30ba\u306b\u8abf\u6574&quot;);\n\/\/\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u306e\u633f\u5165\nvar myProperty = app.project.activeItem.selectedProperties;\nfor (var i = 0; i &lt; myProperty.length; i++) {\n  if (myProperty[i].canSetExpression) {\n    myProperty[i].expression = &quot;camera = thisComp.layer(&quot;\n    \u30ab\u30e1\u30e9 1 &quot;);\\rpoint1 = position;\\rpoint2 = camera.position;\\r distance = length(point1, point2);\\rsize = (distance\/camera.zoom) * 100;\\r[size, size, 100]  &quot;\n  }\n}\nfor (var i = 0; i &lt; myProperty.length; i++) {\n  \/\/\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u30ad\u30fc\u30d5\u30ec\u30fc\u30e0\u306b\u5909\u63db\n  convertToKeyframes(myProperty[i]);\n  var numKeys = myProperty[i].numKeys;\n  for (var j = numKeys; j &gt; 0; j--) {\n    \/\/\u30ad\u30fc\u30d5\u30ec\u30fc\u30e0\u306e\u524a\u9664\n    myProperty[i].removeKey(j);\n  }\n}\napp.endUndoGroup();\n\/\/\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u30ad\u30fc\u30d5\u30ec\u30fc\u30e0\u306b\u5909\u63db\nfunction convertToKeyframes(theProperty) {\n  if (theProperty.canSetExpression && theProperty.expressionEnabled) {\n    theProperty.selected = true;\n    app.executeCommand(2639); \/\/\u30ad\u30fc\u30d5\u30ec\u30fc\u30e0\u306b\u5909\u63db\n    myProperty = app.project.activeItem.selectedProperties;\n    \/\/\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u306e\u524a\u9664\n    for (var i = 0; i &lt; myProperty.length; i++) {\n      if (myProperty[i].canSetExpression) {\n        myProperty[i].expression = &quot;&quot;\n      }\n    }\n    theProperty.selected = false;\n  }\n}<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">3D\u80cc\u666f\u3092\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u306e\u30b5\u30a4\u30ba\u306b\u8abf\u6574\u3059\u308b\u30b9\u30af\u30ea\u30d7\u30c82<\/h2>\n\n\n\n<p>\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u308f\u306a\u3044\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-javascript\" data-lang=\"JavaScript\"><code>try {\n    var myLayer = app.project.activeItem.selectedLayers;\n    \/\/\u9078\u629e\u30ab\u30e1\u30e9\n    if (myLayer[0] instanceof CameraLayer) {\n        var camera = myLayer[0];\n        var camTrans = camera.transform.position.value;\n        var x2 = camTrans[0];\n        var y2 = camTrans[1];\n        var z2 = camTrans[2];\n        \/\/\u30ba\u30fc\u30e0\n        var camZoom = camera.zoom.value;\n    } else {\n        alert(&quot;\u30ab\u30e1\u30e9\u3092\u9078\u629e\u3057\u3066\u3001\u6b21\u306b\u30ec\u30a4\u30e4\u30fc\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044&quot;)\n    }\n\/\/\u9078\u629e\u30ec\u30a4\u30e4\u30fc\nvar selLayer = myLayer[1];\nvar selTrans = selLayer.transform.position.value;\nvar x1 = selTrans[0];\nvar y1 = selTrans[1];\nvar z1 = selTrans[2];\n\n\/\/2\u70b9\u9593\u306e\u8ddd\u96e2\nvar distance = z2 - z1;\n\nvar size = Math.abs((distance \/ camZoom) * 100);\n$.writeln(distance);\n$.writeln(camZoom);\n\n\/\/\u30b9\u30b1\u30fc\u30eb\u5024\u306e\u30bb\u30c3\u30c8\nmyLayer[1].transform.scale.setValue([size, size, 100]);\n} catch (e) {\nalert(&quot;\u30ab\u30e1\u30e9\u3092\u9078\u629e\u3057\u3066\u3001\u6b21\u306b\u30ec\u30a4\u30e4\u30fc\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044&quot;)\n}<\/code><\/pre><\/div>\n\n\n\n<p>\u4eca\u56de\u30b9\u30b1\u30fc\u30eb\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u3060\u3051\u306b\u30a8\u30af\u30b9\u30d7\u30ec\u30c3\u30b7\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u305f\u3002\u3061\u306a\u307f\u306b\u3082\u3063\u3068\u591a\u6a5f\u80fd\u306a\u306e\u304c\u300cpt_Multiplane\u300d\u3068\u3044\u3046\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\uff1a<a href=\"https:\/\/aescripts.com\/pt_multiplane\/\">https:\/\/aescripts.com\/pt_multiplane\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>3D\u80cc\u666f\u3092\u30b3\u30f3\u30dd\u30b8\u30b7\u30e7\u30f3\u30b5\u30a4\u30ba\u306b\u5408\u308f\u305b\u305f\u3044 \u305f\u3060\u30a4\u30e9\u30b9\u30c8\u3092\u30ba\u30fc\u30e0\u3059\u308b\u306e\u306f\u7d75\u7684\u306b\u3064\u307e\u3089\u306a\u3044\u306e\u3067\u3001\u3059\u3079\u30663D\u30ec\u30a4\u30e4\u30fc\u306b\u3057\u3066\u30ab\u30e1\u30e9\u306e\u30ba\u30fc\u30e0\u3067\u7a7a\u9593\u3092\u611f\u3058\u3064\u3064\u30ba\u30fc\u30e0\u3059\u308b\u624b\u6cd5\u306f\u3088\u304f\u3084\u308b\u306e\u3067\u3059\u304c\u3001Z\u4f4d\u7f6e\u306b\u5024\u3092\u5165\u308c\u305f\u5f8c\u306b\u76ee\u5408\u308f\u305b\u3067\u80cc\u666f\u306e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":17885,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[28],"tags":[],"class_list":["post-17828","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-expression-script"],"_links":{"self":[{"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/posts\/17828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/comments?post=17828"}],"version-history":[{"count":2,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/posts\/17828\/revisions"}],"predecessor-version":[{"id":17886,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/posts\/17828\/revisions\/17886"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/media\/17885"}],"wp:attachment":[{"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/media?parent=17828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/categories?post=17828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cg-method.com\/after-effects\/wp-json\/wp\/v2\/tags?post=17828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}