{"id":61,"date":"2022-05-11T10:21:05","date_gmt":"2022-05-11T10:21:05","guid":{"rendered":"https:\/\/noirccc.net\/blog\/?p=61"},"modified":"2023-07-06T02:59:01","modified_gmt":"2023-07-06T02:59:01","slug":"%e8%87%aa%e7%94%b1%e7%9b%b8%e6%9c%ba%ef%bc%8c%e4%b8%89%e8%bd%b4%e7%8b%ac%e7%ab%8b%e7%a7%bb%e5%8a%a8-%e6%97%8b%e8%bd%ac-%e5%b9%b3%e6%bb%91","status":"publish","type":"post","link":"https:\/\/noirccc.net\/blog\/zh\/posts\/61","title":{"rendered":"\u81ea\u7531\u76f8\u673a\uff0c\u4e09\u8f74\u72ec\u7acb\u79fb\u52a8\/\u65cb\u8f6c\/\u5e73\u6ed1"},"content":{"rendered":"\n<p><a rel=\"noreferrer noopener\" href=\"https:\/\/github.com\/NoiRC256\/CameraWorks\" data-type=\"URL\" data-id=\"https:\/\/github.com\/NoiRC256\/CameraWorks\" target=\"_blank\">CameraWorks<\/a> \u4e24\u79cd\u65cb\u8f6c\u6a21\u5f0f\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p><strong>\u6a21\u5f0fA<\/strong><\/p>\n\n\n\n<p>\u4fef\u4ef0\uff0c\u504f\u822a\uff0c\u72ec\u7acb\u4e8e\u7ffb\u6eda\uff0c\u5e73\u884c\u4e8e\u4e16\u754c\u5e73\u9762\uff1a\u5f53\u524d\u65cb\u8f6c + delta\u65cb\u8f6c\u3002<\/p>\n\n\n\n<p>\u9002\u5408\u7c7b\u4f3c\u7b2c\u4e00\u4eba\u79f0\u5c04\u51fb\u6e38\u620f\u7684\u64cd\u4f5c<\/p>\n\n\n\n<p><strong>\u6a21\u5f0fB<\/strong><\/p>\n\n\n\n<p>\u4fef\u4ef0\uff0c\u504f\u822a\uff0c\u7ffb\u6eda\u76f8\u4e92\u72ec\u7acb\uff1a\u5f53\u524d\u65cb\u8f6c\u56db\u5143\u6570 * delta\u65cb\u8f6c\u56db\u5143\u6570\u3002<\/p>\n\n\n\n<p>\u53ef\u4ee5\u505a\u5230\u7c7b\u4f3c Planetside2 \u7684\u98de\u884c\u63a7\u5236\u6548\u679c<\/p>\n\n\n\n<p>\uff08\u8fd9\u91cc\u7684 Lerp \u4e3a\u4e86\u5b9e\u73b0\u975e\u7ebf\u6027\u63d2\u503c\u8d70\u4e86\u4e2a\u6377\u5f84\u3002\u6b63\u5e38\u7ebf\u6027\u63d2\u503c\u8bf7<a href=\"https:\/\/medium.com\/@yousafzai.kamran60\/unity-how-to-properly-lerp-b84d7383b996\">\u53c2\u8003\u8fd9\u4e2a<\/a>\u3002\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protected virtual void HandleRotationInput()\n{\n    Vector3 input = CalculateDesiredRotationInput();\n    smoothedDeltaPitch = Mathf.Lerp(smoothedDeltaPitch, input.x, Time.unscaledDeltaTime * lookSmooth);\n    smoothedDeltaYaw = Mathf.Lerp(smoothedDeltaYaw, input.y, Time.unscaledDeltaTime * lookSmooth);\n    smoothedDeltaRoll = Mathf.Lerp(smoothedDeltaRoll, input.z, Time.unscaledDeltaTime * rollSmooth);\n\n    if(lookByWorldPlane) {\n        curEuler += new Vector3(smoothedDeltaPitch, smoothedDeltaYaw, smoothedDeltaRoll);\n        targetQuaternion = Quaternion.Euler(curAngles);\n    } else {\n        deltaQuaternion = Quaternion.Euler(new Vector3(smoothedDeltaPitch, smoothedDeltaYaw, smoothedDeltaRoll));\n        targetQuaternion *= deltaQuaternion.\n    }\n}<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u662f\u5728\u6700\u7ec8\u8f6c\u6362\u6210 Quaternion \u524d\uff0c\u5148\u5c06\u8f93\u5165\u5e73\u6ed1\u3002\u5982\u679c\u62c5\u5fc3\u6548\u679c\u4e0d\u7a33\u5b9a\uff08e.g. \u6839\u636e\u5e27\u7387\uff0c\u540c\u6837\u5927\u5c0f\u7684\u8f93\u5165\u53ef\u80fd\u4f1a\u9020\u6210\u4e0d\u540c\u7a0b\u5ea6\u7684\u65cb\u8f6c\uff09\u53ef\u4ee5\u5148\u83b7\u53d6\u76ee\u6807\u65cb\u8f6c\uff0c\u518d\u5e73\u6ed1\u8fc7\u6e21\u5230\u76ee\u6807\u65cb\u8f6c\u3002\u4e00\u822c\u53ef\u4ee5\u76f4\u63a5\u7528 Quaternion.Slerp\uff0c\u4f46\u5982\u679c\u4ecd\u8981\u72ec\u7acb\u5e73\u6ed1\u5404\u8f74\uff0c\u8fd8\u662f\u9700\u8981\u6b27\u62c9\u89d2\u3002*\u6a21\u5f0fB\u7531\u4e8e\u8f6c\u6362\u539f\u56e0\u4f3c\u4e4e\u65e0\u6cd5\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\u72ec\u7acb\u5e73\u6ed1\u5404\u8f74\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protected virtual void HandleRotationInput()\n{\n    Vector3 input = CalculateDesiredRotationInput();\n\n    if(lookByWorldPlane) {\n        curEuler += input;\n        targetEuler = curAngles;\n    } else {\n        Quaternion targetQuanternion = Quaternion.Euler(targetEuler) * Quaternion.Euler(input);\n        targetEuler = targetQuaternion.\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>protected virtual void UpdateRotation()\n{\n    if (LookByWorldPlane) {\n        smoothedEuler.x = Mathf.Lerp(smoothedEuler.x, targetEuler.x, LookSmooth * Time.unscaledDeltaTime);\n        smoothedEuler.y = Mathf.Lerp(smoothedEuler.y, targetEuler.y, LookSmooth * Time.unscaledDeltaTime);\n        smoothedEuler.z = Mathf.Lerp(smoothedEuler.z, targetEuler.z, RollSmooth * Time.unscaledDeltaTime);\n        transform.localEulerAngles = smoothedEuler;\n    } else {\n        smoothedQuaternion = Quaternion.Slerp(transform.localRotation, targetRotation, LookSmooth * Time.unscaledDeltaTime);\n        transform.localRotation = smoothedQuaternion;\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CameraWorks \u4e24\u79cd\u65cb\u8f6c\u6a21\u5f0f\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002 \u6a21\u5f0fA \u4fef\u4ef0\uff0c\u504f\u822a\uff0c\u72ec\u7acb\u4e8e\u7ffb\u6eda\uff0c\u5e73\u884c\u4e8e\u4e16\u754c\u5e73\u9762\uff1a\u5f53\u524d\u65cb\u8f6c + delta\u65cb\u8f6c\u3002 \u9002\u5408\u7c7b\u4f3c\u7b2c\u4e00\u4eba\u79f0\u5c04\u51fb\u6e38\u620f\u7684\u64cd\u4f5c \u6a21\u5f0fB \u4fef\u4ef0\uff0c\u504f\u822a\uff0c\u7ffb\u6eda\u76f8\u4e92\u72ec\u7acb\uff1a\u5f53\u524d\u65cb\u8f6c\u56db\u5143\u6570 * delta\u65cb\u8f6c\u56db\u5143\u6570\u3002 \u53ef\u4ee5\u505a\u5230\u7c7b\u4f3c Planetside2 \u7684\u98de\u884c\u63a7\u5236\u6548\u679c \uff08\u8fd9\u91cc\u7684 Lerp \u4e3a\u4e86\u5b9e\u73b0\u975e\u7ebf\u6027\u63d2\u503c\u8d70\u4e86\u4e2a\u6377\u5f84\u3002\u6b63\u5e38\u7ebf\u6027\u63d2\u503c\u8bf7\u53c2\u8003\u8fd9\u4e2a\u3002\uff09 \u4ee5\u4e0a\u662f\u5728\u6700\u7ec8\u8f6c\u6362\u6210 Quaternion \u524d\uff0c\u5148\u5c06\u8f93\u5165\u5e73\u6ed1\u3002\u5982\u679c\u62c5\u5fc3\u6548\u679c\u4e0d\u7a33\u5b9a\uff08e.g. \u6839\u636e\u5e27\u7387\uff0c\u540c\u6837\u5927\u5c0f\u7684\u8f93\u5165\u53ef\u80fd\u4f1a\u9020\u6210\u4e0d\u540c\u7a0b\u5ea6\u7684\u65cb\u8f6c\uff09\u53ef\u4ee5\u5148\u83b7\u53d6\u76ee\u6807\u65cb\u8f6c\uff0c\u518d\u5e73\u6ed1\u8fc7\u6e21\u5230\u76ee\u6807\u65cb\u8f6c\u3002\u4e00\u822c\u53ef\u4ee5\u76f4\u63a5\u7528 Quaternion.Slerp\uff0c\u4f46\u5982\u679c\u4ecd\u8981\u72ec\u7acb\u5e73\u6ed1\u5404\u8f74\uff0c\u8fd8\u662f\u9700\u8981\u6b27\u62c9\u89d2\u3002*\u6a21\u5f0fB\u7531\u4e8e\u8f6c\u6362\u539f\u56e0\u4f3c\u4e4e\u65e0\u6cd5\u901a\u8fc7\u8fd9\u79cd\u65b9\u6cd5\u72ec\u7acb\u5e73\u6ed1\u5404\u8f74\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[47,56],"tags":[63],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/posts\/61"}],"collection":[{"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":6,"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":772,"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/posts\/61\/revisions\/772"}],"wp:attachment":[{"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/noirccc.net\/blog\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}