{"id":192,"date":"2025-11-11T13:52:58","date_gmt":"2025-11-11T05:52:58","guid":{"rendered":"http:\/\/103.236.53.242\/?p=192"},"modified":"2025-11-27T16:53:17","modified_gmt":"2025-11-27T08:53:17","slug":"trace-live2d","status":"publish","type":"post","link":"http:\/\/www.preluna.xyz\/index.php\/2025\/11\/11\/trace-live2d\/preluna\/technology\/career-skills\/open-source-analysis\/","title":{"rendered":"\u5173\u4e8elive2d\u770b\u677f\u5a18\u63d2\u4ef6\u7684\u6eaf\u6e90"},"content":{"rendered":"\n\n\n<p>\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u7ed9\u81ea\u5df1\u7b80\u5355\u7684\u89e3\u91ca\u4e86\u8fd9\u4e2alive2d\u770b\u677f\u5a18\u7684load.js\u548cpio.js\u4ee5\u53capio_sdk4.js\u4ee3\u7801,\u6211\u60f3\u54b1\u4eec\u5df2\u7ecf\u5927\u81f4\u7684\u4e86\u89e3\u8be5\u5982\u4f55\u628a\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u6dfb\u52a0\u66f4\u591a\u7684\u6a21\u5f62\uff0c\u4ee5\u53ca\u66f4\u591a\u7684\u52a8\u4f5c\u548c\u81ea\u5b9a\u4e49\u4ea4\u4e92\u3002\u4f46\u662f\u6211\u4eec\u60f3\u66f4\u8fdb\u4e00\u6b65\u53bb\u6df1\u5165\u4e86\u89e3\u8fd9\u4e9b\u4ee3\u7801\uff0c\u53bb\u627e\u5230\u8fd9\u4e2a\u4ee3\u7801\u5f53\u4e2d\u662f\u600e\u4e48\u8bbe\u7f6e\uff0c\u662f\u600e\u4e48\u6837\u53bb\u601d\u8003\uff1f\u7684\u4ed6\u4e3a\u4ec0\u4e48\u8fd9\u4e48\u5199\u4ed6\u662f\u5982\u4f55\u6784\u6210\u7684\uff1f\u6211\u4eec\u53ef\u4ee5\u4e00\u6b65\u4e00\u6b65\u5f80\u4e0a\u53bb\u63a2\u7d22\uff0c\u53bb\u627e\u5230\u8fd9\u4e2a\u4ee3\u7801\u6700\u65e9\u7684\u7248\u672c\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u5148\u6839\u636e\u8fd9\u4e2a\u7ad9\u70b9\u5f00\u59cb\u7684\u5730\u65b9\uff0c\u4ece\u4f5c\u8005\u4e0b\u65b9\u7ed3\u675f\u7684\u94fe\u63a5\u5f00\u59cb<\/p>\n\n\n\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u968f\u7740\u8fd9\u4e2a\u94fe\u63a5\u627e\u5230\u8fd9\u4e00\u7bc7\u6587\u7ae0\u3002<\/p>\n\n\n\n<p>\u7136\u540e\u6211\u4eec\u6839\u636e\u4ed6\u7684\u6587\u7ae0\uff0c\u7136\u540e\u4ece\u4ed6\u7684\u516c\u4f17\u53f7\u5e95\u4e0b\u4e0b\u8f7d\u4e86\u538b\u7f29\u5305\uff0c\u901a\u8fc7\u5206\u6790\u4e4b\u540e\uff0c\u6211\u4eec\u53d1\u73b0\u4ed6\u4e0e\u8fd9\u4e2a\u4e4b\u524d\u4f5c\u8005\u5728\u7f51\u7ad9\u4e0a\u4f20\u7684\u6ca1\u6709\u4efb\u4f55\u533a\u522b\uff0c\u4f46\u662f\u5462\uff0c\u6211\u4eec\u53c8\u627e\u5230\u4e86\u5728\u6587\u7ae0\u672b\u5c3e\u4f5c\u8005\u7ed9\u51fa\u7684\u53c2\u8003\u6587\u7ae0\u94fe\u63a5:<a href=\"https:\/\/gist.github.com\/journey-ad\/be8d977683297fd32d5680cdd6e914a7\">\u5728\u54d4\u7ad9\u53f3\u4e0b\u89d2\u6dfb\u52a0\u5609\u7136\u5c0f\u59d0\u7684live2d\u6a21\u578b<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/gist.github.com\/journey-ad\/be8d977683297fd32d5680cdd6e914a7#file-oh-my-diana-user-js\"><strong>oh-my-diana.user.js<\/strong><\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ ==UserScript==\n\/\/ @name                #\u76f8\u4eb2\u76f8\u7231\u4e00\u5609\u4eba#\n\/\/ @description         \u5728\u54d4\u7ad9\u53f3\u4e0b\u89d2\u6dfb\u52a0\u5609\u7136\u5c0f\u59d0\u7684live2d\u6a21\u578b\n\/\/ @version             1.0.1\n\/\/ @namespace           https:\/\/github.com\/journey-ad\n\/\/ @author              journey-ad\n\/\/ @include             \/^https:\\\/\\\/(www|live|space|t)\\.bilibili\\.com\\\/.*$\/\n\/\/ @icon                https:\/\/www.google.com\/s2\/favicons?domain=bilibili.com\n\/\/ @license             GPL v2\n\/\/ @run-at              document-end\n\/\/ @grant               none\n\/\/ ==\/UserScript==\n\n(async function () {\n  'use strict';\n\n  if (inIframe()) {\n    console.log('iframe\u4e2d\u4e0d\u52a0\u8f7d');\n    return false;\n  }\n\n  const \u5f15\u6d41 = &#91;\n    \"https:\/\/space.bilibili.com\/672328094\",\n    \"https:\/\/www.bilibili.com\/video\/BV1FZ4y1F7HH\",\n    \"https:\/\/www.bilibili.com\/video\/BV1FX4y1g7u8\",\n    \"https:\/\/www.bilibili.com\/video\/BV1aK4y1P7Cg\",\n    \"https:\/\/www.bilibili.com\/video\/BV17A411V7Uh\",\n    \"https:\/\/www.bilibili.com\/video\/BV1JV411b7Pc\",\n    \"https:\/\/www.bilibili.com\/video\/BV1AV411v7er\",\n    \"https:\/\/www.bilibili.com\/video\/BV1564y1173Q\",\n\n    \"https:\/\/www.bilibili.com\/video\/BV1MX4y1N75X\",\n    \"https:\/\/www.bilibili.com\/video\/BV17h411U71w\",\n    \"https:\/\/www.bilibili.com\/video\/BV1ry4y1Y71t\",\n    \"https:\/\/www.bilibili.com\/video\/BV1Sy4y1n7c4\",\n    \"https:\/\/www.bilibili.com\/video\/BV15y4y177uk\",\n    \"https:\/\/www.bilibili.com\/video\/BV1PN411X7QW\",\n    \"https:\/\/www.bilibili.com\/video\/BV1Dp4y1H7iB\",\n    \"https:\/\/www.bilibili.com\/video\/BV1bi4y1P7Eh\",\n    \"https:\/\/www.bilibili.com\/video\/BV1vQ4y1Z7C2\",\n    \"https:\/\/www.bilibili.com\/video\/BV1oU4y1h7Sc\",\n  ]\/*\u6211\u4eec\u53ef\u4ee5\u770b\u5230load.js\u5e76\u6ca1\u6709\u6539\u53d8\u5f15\u6d41\u90e8\u5206\u7684\u4ee3\u7801\u3002*\/\n\n  const CUSTOM_CSS = `#pio-container {\n  display: block !important;\n  bottom: -0.3rem;\n  z-index: 22637261;\n  transition: transform 0.3s;\n  cursor: grab;\n}\n\n#pio-container:hover {\n  transform: translateY(-0.3rem);\n}\n\n#pio-container:active {\n  cursor: grabbing;\n}\n\n#pio-container .pio-dialog {\n  right: 10%;\n  line-height: 1.5;\n  background: rgba(255, 255, 255, 0.9);\n}\n\n#pio {\n  height: 240px;\n}\n\n.pio-action .pio-home {\n  display: none;\n}\n\n.pio-action span {\n  background: none;\n  background-size: 100%;\n  border: 1px solid #fdcf7b;\n  border: 0;\n  width: 2em;\n  height: 2em;\n  margin-bottom: 0.6em;\n}\n\n.pio-action .pio-skin {\n  background: url(\"data:image\/svg+xml,%3Csvg class='icon' viewBox='0 0 1024 1024' xmlns='http:\/\/www.w3.org\/2000\/svg'%3E%3Cpath d='M0 512c0 282.774 229.226 512 512 512s512-229.226 512-512S794.774 0 512 0 0 229.226 0 512z' fill='%23FEC43C'\/%3E%3Cpath d='M1013.76 408.576C965.632 175.104 759.808 0 512 0 229.376 0 0 229.376 0 512c0 123.904 44.032 236.544 116.736 324.608 87.04 48.128 186.368 74.752 292.864 74.752 301.056 0 550.912-217.088 604.16-502.784z' fill='%23FFD73A'\/%3E%3Cpath d='M233.456 460.383a93.759 93.759 0 1 0 187.526 0c0-51.783-41.984-93.76-93.767-93.76s-93.759 41.977-93.759 93.76zm458.39 0c0 51.782 41.976 93.759 93.759 93.759s93.759-41.984 93.759-93.76c0-51.782-41.984-93.758-93.76-93.758-51.782 0-93.758 41.976-93.758 93.759z' fill='%23873A18'\/%3E%3Cpath d='M556.41 689.577H410.561c-17.707 0-31.256-13.548-31.256-31.255 0-17.715 13.549-31.256 31.256-31.256h145.85c17.714 0 31.255 13.548 31.255 31.256s-13.549 31.255-31.256 31.255zM320.97 429.127H156.357c-14.588 0-27.089-13.548-27.089-31.256s12.5-31.247 27.097-31.247H320.96c14.58 0 27.089 13.54 27.089 31.247 0 17.715-12.509 31.256-27.097 31.256zm454.215 0H618.92c-17.715 0-31.255-13.548-31.255-31.256s13.548-31.247 31.255-31.247h156.263c17.715 0 31.255 13.54 31.255 31.247 0 17.715-13.548 31.256-31.255 31.256z' fill='%23873A18'\/%3E%3Cpath d='M102.4 327.68C46.08 327.68 0 281.6 0 225.28 0 133.12 102.4 0 102.4 0s102.4 133.12 102.4 225.28c0 56.32-46.08 102.4-102.4 102.4z' fill='%2361A3E0'\/%3E%3C\/svg%3E\");\n}\n\n.pio-action .pio-info {\n  background: url(\"data:image\/svg+xml,%3Csvg viewBox='0 0 500 500' xmlns='http:\/\/www.w3.org\/2000\/svg'%3E%3Crect transform='rotate(45.001 238.211 363.575)' x='29.285' y='22.411' width='273.903' height='505.038' rx='70' ry='70' fill='%23dcdcdc'\/%3E%3Cpath d='M218.543 249.999l-47.186 47.186c-8.987 8.988-8.987 22.47 0 31.457 8.988 8.988 22.47 8.988 31.457 0L250 281.456l15.728 15.729c17.976 17.976 17.976 46.063 0 64.038l-64.037 64.038c-17.976 17.975-46.063 17.975-64.038 0l-64.038-64.038c-17.975-17.975-17.975-46.062 0-64.038l64.038-64.037c17.975-17.976 46.062-17.976 64.038 0l16.852 16.851z' fill='%23fff'\/%3E%3Cpath d='M281.457 249.999l47.186-47.186c8.988-8.987 8.988-22.469 0-31.457-8.987-8.987-22.469-8.987-31.457 0L250 218.542l-15.729-15.729c-17.975-17.975-17.975-46.062 0-64.037l64.038-64.038c17.975-17.975 46.062-17.975 64.038 0l64.037 64.038c17.977 17.975 17.977 46.062 0 64.037l-64.037 64.038c-17.976 17.976-46.063 17.976-64.038 0l-16.852-16.852z' fill='%2361a3e0'\/%3E%3C\/svg%3E\");\n}\n\n.pio-action .pio-top {\n  background-image: url(\"data:image\/svg+xml,%3Csvg viewBox='0 0 500 500' xmlns='http:\/\/www.w3.org\/2000\/svg'%3E%3Cpath d='M262.737 70.075c-3.175-2.89-8.439-5.365-12.737-5.365-4.29 0-9.448 2.37-12.632 5.263l-87.814 87.812c-2.921 3.255-5.23 8.518-5.23 12.73 0 4.203 2.196 9.353 5.118 12.617 3.246 2.915 8.621 5.345 12.842 5.345 4.203 0 9.353-2.197 12.617-5.118l75.093-74.848 74.992 74.993c3.175 2.889 8.433 5.359 12.731 5.359 4.29 0 9.448-2.371 12.632-5.263 2.918-3.247 5.329-8.61 5.329-12.827 0-4.204-2.197-9.354-5.118-12.616zm-103.97 233.514v-36.181H19.695v36.181h51.447v131.444h36.178V303.589zm126.788-35.923h-63.85c-8.732.187-18.571 3.868-25.539 10.451-6.579 6.961-10.367 16.85-10.557 25.589v95.488c.179 8.709 3.781 18.668 10.493 25.582 6.913 6.712 16.839 10.334 25.548 10.514h63.849c8.732-.187 18.571-3.868 25.538-10.45 6.581-6.962 10.368-16.852 10.558-25.59v-95.488c-.187-8.733-3.87-18.573-10.452-25.539-6.962-6.581-16.85-10.367-25.588-10.557zm-.14 131.589l.003.105.403.021a20.74 20.74 0 0 0-.322-.013h-.08c.006.172.014.313.021.414l-.027-.414h-.118l.01-.013.107.005-.007-.117-.033.025-.079.1h-63.648l-.106.003-.032.438c.007-.092.015-.243.021-.438-.163.005-.283.012-.365.017l.365-.023.003-.139-.055-.039-.301-.208.356.244.001-.029v-95.493a3.627 3.627 0 0 0-.004-.108l-.417-.028c.106.007.253.014.417.019a10.069 10.069 0 0 0-.023-.42l.031.42.123.004.016-.022.087-.113.036-.047-.137.182.044.001h63.551l.096.074.064.05-.001.049zm184.441-121.032c-6.963-6.58-16.852-10.367-25.59-10.557h-88.627V435.29h36.181v-68.165h52.39c8.732-.187 18.572-3.87 25.54-10.452 6.579-6.961 10.366-16.851 10.556-25.588v-27.323c-.187-8.733-3.868-18.572-10.45-25.539zm-25.471 52.609l.003.105.437.032a10.682 10.682 0 0 0-.437-.021c.007.211.017.355.023.436l-.033-.436a79.554 79.554 0 0 0-.142-.003l-.038.054-.112.166-.119.175.262-.396H391.82v-27.099h52.451l.112-.004.025-.405a14.96 14.96 0 0 0-.018.405c.171-.006.313-.015.416-.023l-.416.031-.004.122-.01-.008.007-.113-.119.008.041.054.081.062-.001.045z' fill='%234c4c4c'\/%3E%3C\/svg%3E\");\n}\n\n.pio-action .pio-close {\n  background: url(\"data:image\/svg+xml,%3Csvg viewBox='0 0 500 500' xmlns='http:\/\/www.w3.org\/2000\/svg'%3E%3Cpath d='M249.999 198.668L352.665 96c14.667-14.666 36.668-14.666 51.335 0 14.666 14.667 14.666 36.668 0 51.334L301.333 250 404 352.668c14.666 14.667 14.666 36.666 0 51.332-14.667 14.667-36.667 14.667-51.334 0L249.999 301.334 147.333 404c-14.668 14.667-36.666 14.667-51.334 0-14.666-14.666-14.666-36.665 0-51.332L198.666 250 95.999 147.334c-14.666-14.666-14.666-36.667 0-51.334 14.668-14.666 36.665-14.666 51.333 0l102.667 102.668z' fill='%23873a18'\/%3E%3C\/svg%3E\");\n}\n`\/\u8fd9\u91cc\u7684css\u6837\u5f0f\u4ee3\u7801\u6210\u4e86\u540e\u9762\u7684pio.css\u6587\u4ef6\/\n\/\n  \/\/ \u7528\u5230\u7684\u5e93\n  const LIBS = &#91;\n    'https:\/\/cdn.jsdelivr.net\/gh\/journey-ad\/blog-img@94eb7e2\/live2d\/lib\/pio.css',\n    'https:\/\/cdn.jsdelivr.net\/npm\/greensock@1.20.2\/dist\/TweenLite.js',\n    'https:\/\/cubism.live2d.com\/sdk-web\/cubismcore\/live2dcubismcore.min.js',\n    'https:\/\/cdn.jsdelivr.net\/npm\/pixi.js@5.3.6\/dist\/pixi.min.js',\n    'https:\/\/cdn.jsdelivr.net\/npm\/pixi-live2d-display@0.3.1\/dist\/cubism4.min.js',\n    'https:\/\/cdn.jsdelivr.net\/gh\/journey-ad\/blog-img@94eb7e2\/live2d\/lib\/pio_sdk4.js',\n    'https:\/\/cdn.jsdelivr.net\/gh\/journey-ad\/blog-img@94eb7e2\/live2d\/lib\/pio.js'\n  ]\n\/*\u8fd9\u4e32\u5b9e\u9645\u4e0a\u5c31\u662f\u628a\u5947\u8da3\u4fdd\u7f57\u7684\u4ee3\u7801\u7ed9\u4ee3\u7528\u8fc7\u6765\u4e86\u3002\u800c\u6211\u4eec\u8fd9\u91cc\u4e3a\u4e86\u7a33\u5b9a\u5c31\u76f4\u63a5\u5c31\u7ed9\u4fdd\u5b58\u5230\u672c\u673a\u4e0a\u4e86*\/\n  const reqArr = LIBS.map(src =&gt; loadSource(src))\n\n  \/\/ \u521b\u5efa\u987a\u5e8f\u52a0\u8f7d\u961f\u5217\n  const doTask = reqArr.reduce((prev, next) =&gt; prev.then(() =&gt; next()), Promise.resolve());\n\n  \/\/ \u961f\u5217\u6267\u884c\u5b8c\u6bd5\u540e\n  doTask.then(() =&gt; {\n    \/\/ \u79fb\u9664\u81ea\u5e26\u770b\u677f\u5a18\n    const haruna = document.getElementById('my-dear-haruna-vm')\n    haruna &amp;&amp; haruna.remove()\n\n    \/\/ \u521d\u59cb\u5316pio\n    _pio_initialize_pixi()\n\n    \/\/ \u6dfb\u52a0\u81ea\u5b9a\u4e49\u6837\u5f0f\n    addStyle(CUSTOM_CSS)\n\n    \u52a0\u8f7d\u5723\u00b7\u5609\u7136()\n\n    console.log(\"all done.\")\n  });\n\n  \/\/ \u521d\u59cb\u5316\u8bbe\u5b9a\n  const initConfig = {\n    mode: \"fixed\",\n    hidden: true,\n    content: {\n      link: \u5f15\u6d41&#91;Math.floor(Math.random() * \u5f15\u6d41.length)], \/\/ \u5f15\u6d41\u94fe\u63a5\n      referer: \"Hi!\", \/\/ \u5b58\u5728\u8bbf\u95ee\u6765\u6e90\u65f6\u7684\u6b22\u8fce\u6587\u672c\n      welcome: &#91;\"Hi!\"], \/\/ \u672a\u5f00\u542f\u65f6\u95f4\u95ee\u597d\u65f6\u7684\u6b22\u8fce\u6587\u672c\n      skin: &#91;\"\u8bf6\uff0c\u60f3\u770b\u770b\u5176\u4ed6\u56e2\u5458\u5417\uff1f\", \"\u66ff\u6362\u540e\u5165\u573a\u6587\u672c\"], \/\/ 0\u66f4\u6362\u6a21\u578b\u63d0\u793a\u6587\u6848  1\u66f4\u6362\u5b8c\u6bd5\u5165\u573a\u6587\u6848\n      custom: &#91;\n        \/\/ \u9f20\u6807\u79fb\u4e0a\u53bb\u63d0\u793a\u5143\u7d20\uff0c\u800c\u5728load.js\u7ed9\u4e86\u66f4\u591a\u7684\u9009\u62e9\u3002\n        { \"selector\": \".most-viewed-panel .most-viewed-item, .live-up-list .live-detail, .card .user-name, .user .name, .post-content .content-full a, .tag-list .content, .title, h2 a&#91;title]\", \"type\": \"link\" }\n      ],\n    },\n    model: &#91;\n      \/\/ \u5f85\u52a0\u8f7d\u7684\u6a21\u578b\u5217\u8868\n      \"https:\/\/cdn.jsdelivr.net\/gh\/journey-ad\/blog-img\/live2d\/Diana\/Diana.model3.json\",\n      \"https:\/\/cdn.jsdelivr.net\/gh\/journey-ad\/blog-img\/live2d\/Ava\/Ava.model3.json\",\n    ],\n    tips: true, \/\/ \u65f6\u95f4\u95ee\u597d\n    onModelLoad: onModelLoad \/\/ \u6a21\u578b\u52a0\u8f7d\u5b8c\u6210\u56de\u8c03\n  }\n\n  let pio_reference \/\/ pio\u5b9e\u4f8b\n\n  function \u52a0\u8f7d\u5723\u00b7\u5609\u7136() {\n    pio_reference = new Paul_Pio(initConfig)\n\n    pio_alignment = \"right\" \/\/ \u53f3\u4e0b\u89d2\uff0c\n\n    const closeBtn = document.querySelector(\".pio-container .pio-action .pio-close\")\n    closeBtn.insertAdjacentHTML('beforebegin', '&lt;span class=\"pio-top\"&gt;&lt;\/span&gt;')\n    const topBtn = document.querySelector(\".pio-container .pio-action .pio-top\")\n    \/\/ \u8fd4\u56de\u9876\u90e8\n    topBtn.onclick = function () {\n      window.scrollTo({ top: 0, behavior: 'smooth' });\n    };\n    topBtn.onmouseover = function () {\n      pio_reference.modules.render(\"\u60f3\u56de\u5230\u9875\u9762\u9876\u90e8\u5417\uff1f\");\n    };\n\n    \/\/ Then apply style\n    pio_refresh_style()\n  }\n\n  \/\/ \u6a21\u578b\u52a0\u8f7d\u5b8c\u6210\u56de\u8c03\uff0c\u8fd9\u662f\u4e24\u8005\u5e76\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\u3002\n  function onModelLoad(model) {\n    const canvas = document.getElementById(\"pio\")\n    const modelNmae = model.internalModel.settings.name\n    const coreModel = model.internalModel.coreModel\n    const motionManager = model.internalModel.motionManager\n\n    let touchList = &#91;\n      {\n        text: \"\u70b9\u51fb\u5c55\u793a\u6587\u672c1\",\n        motion: \"Idle\"\n      },\n      {\n        text: \"\u70b9\u51fb\u5c55\u793a\u6587\u672c2\",\n        motion: \"Idle\"\n      }\n    ]\n\n    \/\/ \u64ad\u653e\u52a8\u4f5c\n    function playAction(action) {\n      action.text &amp;&amp; pio_reference.modules.render(action.text) \/\/ \u5c55\u793a\u6587\u6848\n      action.motion &amp;&amp; pio_reference.model.motion(action.motion) \/\/ \u64ad\u653e\u52a8\u4f5c\n\n      if (action.from &amp;&amp; action.to) {\n        \/\/ \u6307\u5b9a\u90e8\u4ef6\u6e10\u5165\u6e10\u51fa\n        Object.keys(action.from).forEach(id =&gt; {\n          const hidePartIndex = coreModel._partIds.indexOf(id)\n          TweenLite.to(coreModel._partOpacities, 0.6, { &#91;hidePartIndex]: action.from&#91;id] });\n          \/\/ coreModel._partOpacities&#91;hidePartIndex] = action.from&#91;id]\n        })\n\n        motionManager.once(\"motionFinish\", (data) =&gt; {\n          Object.keys(action.to).forEach(id =&gt; {\n            const hidePartIndex = coreModel._partIds.indexOf(id)\n            TweenLite.to(coreModel._partOpacities, 0.6, { &#91;hidePartIndex]: action.to&#91;id] });\n            \/\/ coreModel._partOpacities&#91;hidePartIndex] = action.to&#91;id]\n          })\n        })\n      }\n    }\n\n    canvas.onclick = function () {\n      \/\/ \u9664\u95f2\u7f6e\u52a8\u4f5c\u5916\u4e0d\u6253\u65ad\n      if (motionManager.state.currentGroup !== \"Idle\") return\n\n      \/\/ \u968f\u673a\u9009\u62e9\u5e76\u64ad\u653e\u52a8\u4f5c\n      const action = pio_reference.modules.rand(touchList)\n      playAction(action)\n    }\n\n    if (modelNmae === \"Diana\") {\n      \/\/ \u5609\u7136\u5c0f\u59d0\n\n      \/\/ \u5165\u573a\u52a8\u4f5c\u53ca\u6587\u6848\n      initConfig.content.skin&#91;1] = &#91;\"\u6211\u662f\u5403\u8d27\u62c5\u5f53 \u5609\u7136 Diana~\", \"\u5609\u5fc3\u7cd6\u4eec \u60f3\u7136\u7136\u4e86\u6ca1\u6709\u5440~\", \"\u6709\u4eba\u5728\u5417\uff1f\"]\n      playAction({ motion: \"Tap\u62b1\u963f\u8349-\u5de6\u624b\" })\n\n      \/\/ \u70b9\u51fb\u52a8\u4f5c\u53ca\u6587\u6848\uff0c\u4e0d\u533a\u5206\u533a\u57df\n      touchList = &#91;\n        {\n          text: \"\u5609\u5fc3\u7cd6\u5c41\u7528\u6ca1\u6709\",\n          motion: \"Tap\u751f\u6c14 -\u9886\u7ed3\"\n        },\n        {\n          text: \"\u6709\u4eba\u6025\u4e86\uff0c\u4f46\u6211\u4e0d\u8bf4\u662f\u8c01~\",\n          motion: \"Tap= =  \u5de6\u8774\u8776\u7ed3\"\n        },\n        {\n          text: \"\u545c\u545c...\u545c\u545c\u545c....\",\n          motion: \"Tap\u54ed -\u773c\u89d2\"\n        },\n        {\n          text: \"\u60f3\u7136\u7136\u4e86\u6ca1\u6709\u5440~\",\n          motion: \"Tap\u5bb3\u7f9e-\u4e2d\u95f4\u5218\u6d77\"\n        },\n        {\n          text: \"\u963f\u8349\u597d\u8f6f\u5440~\",\n          motion: \"Tap\u62b1\u963f\u8349-\u5de6\u624b\"\n        },\n        {\n          text: \"\u4e0d\u8981\u518d\u6233\u5566\uff01\u597d\u75d2\uff01\",\n          motion: \"Tap\u6447\u5934- \u8eab\u4f53\"\n        },\n        {\n          text: \"\u55f7\u545c~~~\",\n          motion: \"Tap\u8033\u6735-\u53d1\u5361\"\n        },\n        {\n          text: \"zzZ\u3002\u3002\u3002\",\n          motion: \"Leave\"\n        },\n        {\n          text: \"\u54c7\uff01\u597d\u5403\u7684\uff01\",\n          motion: \"Tap\u53f3\u5934\u53d1\"\n        },\n      ]\n\n    } else if (modelNmae === \"Ava\") {\n      initConfig.content.skin&#91;1] = &#91;\"\u6211\u662f&lt;s&gt;\u62c9\u80ef&lt;\/s&gt;Gamer\u62c5\u5f53 \u5411\u665a AvA~\", \"\u600e\u4e48\u63a8\u6d41\u8fa3\uff01\", \"AAAAAAAAAAvvvvAAA \u5411\u665a\uff01\"]\n      playAction({\n        motion: \"Tap\u5de6\u773c\",\n        from: {\n          \"Part15\": 1\n        },\n        to: {\n          \"Part15\": 0\n        }\n      })\n\n      touchList = &#91;\n        {\n          text: \"\u6c34\u6bcd \u6c34\u6bcd~ \u53ea\u662f\u666e\u901a\u7684\u751f\u7269\",\n          motion: \"Tap\u53f3\u624b\"\n        },\n        {\n          text: \"\u53ef\u7231\u7684\u9e3d\u5b50\u9e3d\u5b50~\u6211\u559c\u6b22\u4f60~\",\n          motion: \"Tap\u80f8\u53e3\u9879\u94fe\",\n          from: {\n            \"Part12\": 1\n          },\n          to: {\n            \"Part12\": 0\n          }\n        },\n        {\n          text: \"\u597d...\u597d\u5144\u5f1f\u4e4b\u95f4\u559c\u6b22\u5f88\u6b63\u5e38\u5566\",\n          motion: \"Tap\u4e2d\u95f4\u5218\u6d77\",\n          from: {\n            \"Part12\": 1\n          },\n          to: {\n            \"Part12\": 0\n          }\n        },\n        {\n          text: \"\u554a\u554a\u554a\uff01\u600e\u4e48\u63a8\u6d41\u8fa3\",\n          motion: \"Tap\u53f3\u773c\",\n          from: {\n            \"Part16\": 1\n          },\n          to: {\n            \"Part16\": 0\n          }\n        },\n        {\n          text: \"\u4f60\u600e\u4e48\u8001\u6478\u6211\uff0c\u6211\u7684\u8eab\u4f53\u662f\u4e0d\u662f\u53ef\u6709\u9b45\u529b\",\n          motion: \"Tap\u5634\"\n        },\n        {\n          text: \"AAAAAAAAAAvvvvAAA \u5411\u665a\uff01\",\n          motion: \"Tap\u5de6\u773c\",\n          from: {\n            \"Part15\": 1\n          },\n          to: {\n            \"Part15\": 0\n          }\n        }\n      ]\n\n      \/\/ \u94bb\u5934\u6bd4\u8f83\u5927\uff0c\u5bbd\u5ea6*1.2\u500d\uff0c\u6a21\u578b\u4f4d\u79fb\u4e5f\u8981\u91cd\u65b0\u8ba1\u7b97\n      canvas.width = model.width * 1.2\n      model.x = canvas.width - model.width\n\n      \/\/ \u6a21\u578b\u95ee\u9898\uff0c\u624b\u52a8\u9690\u85cf\u6307\u5b9a\u90e8\u4ef6\n      const hideParts = &#91;\n        \"Part5\", \/\/ \u6655\n        \"neko\", \/\/ \u55b5\u55b5\u62f3\n        \"game\", \/\/ \u5de6\u624b\u6e38\u620f\u624b\u67c4\n        \"Part15\", \/\/ \u58a8\u955c\n        \"Part21\", \/\/ \u53f3\u624b\u5c0f\u81c2\n        \"Part22\", \/\/ \u5de6\u624b\u5782\u4e0b\n        \"Part\", \/\/ \u53cc\u624b\u62b1\u62f3\n        \"Part16\", \/\/ \u60ca\u8bb6\u7279\u6548\n        \"Part12\" \/\/ \u5c0f\u5fc3\u5fc3\n      ]\n      const hidePartsIndex = hideParts.map(id =&gt; coreModel._partIds.indexOf(id))\n      hidePartsIndex.forEach(idx =&gt; {\n        coreModel._partOpacities&#91;idx] = 0\n      })\n    }\n  }\n\n  \/\/ \u68c0\u6d4b\u662f\u5426\u5904\u4e8eiframe\u5185\u5d4c\u73af\u5883\n  function inIframe() {\n    try {\n      return window.self !== window.top;\n    } catch (e) {\n      return true;\n    }\n  }\n\n  \/\/ \u52a0\u8f7djs\u6216css\uff0c\u8fd4\u56de\u51fd\u6570\u5305\u88f9\u7684promise\u5b9e\u4f8b\uff0c\u7528\u4e8e\u987a\u5e8f\u52a0\u8f7d\u961f\u5217\n  function loadSource(src) { \/\/\u63a5\u6536\u53c2\u6570\u5e76\u8fd4\u56de\u65b0\u51fd\u6570\u3002\n    return () =&gt; {\n      return new Promise(function (resolve, reject) {\n          \/\/\u7c7b\u578b\u5224\u65ad\u903b\u8f91\n        const TYPE = src.split('.').pop()  \/\/ \u83b7\u53d6\u6587\u4ef6\u6269\u5c55\u540d\n        let s = null;\n        let r = false;\n        if (TYPE === 'js') {\n            \/\/ \u521b\u5efascript\u6807\u7b7e\u52a0\u8f7dJS\n          s = document.createElement('script');\n          s.type = 'text\/javascript';\n          s.src = src;\n          s.async = true;\n\n        } else if (TYPE === 'css') {\n            \/\/ \u521b\u5efalink\u6807\u7b7e\u52a0\u8f7dCSS\n          s = document.createElement('link');\n          s.rel = 'stylesheet';\n          s.type = 'text\/css';\n          s.href = src;\n\n        }\n        s.onerror = function (err) {\n          reject(err, s);  \/\/ \u52a0\u8f7d\u5931\u8d25\u65f6reject Promise\n        };\n        s.onload = s.onreadystatechange = function () {\n          \/\/ console.log(this.readyState); \/\/ uncomment this line to see which ready states are called.\n          if (!r &amp;&amp; (!this.readyState || this.readyState == 'complete')) {\n            r = true;   \/\/ \u9632\u91cd\u590d\u6267\u884c\u6807\u5fd7\n            console.log(src)   \/\/ \u8f93\u51fa\u52a0\u8f7d\u7684\u6587\u4ef6\u540d\n            resolve();   \/\/ \u52a0\u8f7d\u6210\u529f\u65f6resolve Promise\n          }\n        };\n        const t = document.getElementsByTagName('script')&#91;0];  \/\/ \u83b7\u53d6\u7b2c\u4e00\u4e2ascript\u6807\u7b7e\n        t.parentElement.insertBefore(s, t);   \/\/ \u5728\u7b2c\u4e00\u4e2ascript\u6807\u7b7e\u524d\u63d2\u5165\u65b0\u5143\u7d20\n      });\n    }\n  }\n  \/*\u8c03\u7528loadSource(src) \u2192 \u8fd4\u56de\u52a0\u8f7d\u51fd\u6570\n    \u6267\u884c\u8fd4\u56de\u7684\u51fd\u6570 \u2192 \u521b\u5efaPromise\n    \u6839\u636e\u6587\u4ef6\u7c7b\u578b\u521b\u5efa\u5bf9\u5e94DOM\u5143\u7d20\n    \u8bbe\u7f6e\u4e8b\u4ef6\u76d1\u542c\u5904\u7406\u6210\u529f\/\u5931\u8d25\n    \u63d2\u5165DOM\u5f00\u59cb\u52a0\u8f7d\n    \u8fd4\u56dePromise\u4f9b\u8c03\u7528\u8005\u4f7f\u7528\n    *\/\n\/\/\u4e00\u4e2a\u5178\u578b\u7684\u8d44\u6e90\u52a8\u6001\u52a0\u8f7d\u5668\uff0c\u652f\u6301JS\u548cCSS\u6587\u4ef6\u7684\u5f02\u6b65\u52a0\u8f7d\uff0c\u5e76\u901a\u8fc7Promise\u63d0\u4f9b\u66f4\u597d\u7684\u5f02\u6b65\u63a7\u5236\u3002\n\/*\n* \u4ee3\u7801\u7ed3\u6784\u5bf9\u6bd4\n* var pio_reference\nwindow.onload = \u52a0\u8f7d\u5723\u00b7\u5609\u7136\n* \n* \n* \u5ef6\u8fdf\u6267\u884c\u6a21\u5f0f\n* loadSource\uff1a\u8fd4\u56de\u4e00\u4e2a\u51fd\u6570\uff0c\u9700\u8981\u624b\u52a8\u8c03\u7528\u624d\u4f1a\u6267\u884c\u52a0\u8f7d\n* window.onload = \u52a0\u8f7d\u5723\u00b7\u5609\u7136\uff1a\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u81ea\u52a8\u6267\u884c\n* \u8d44\u6e90\u52a0\u8f7d\u65f6\u673a\u63a7\u5236\n* \/\/ loadSource - \u624b\u52a8\u63a7\u5236\u65f6\u673a\nconst loader = loadSource('file.js');\n\/\/ \u5728\u9700\u8981\u7684\u65f6\u5019\u8c03\u7528\nloader().then(...)\n\/\/ window.onload - \u81ea\u52a8\u5728\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u6267\u884c\nwindow.onload = \u52a0\u8f7d\u5723\u00b7\u5609\u7136\n* loadSource\uff0c\u624b\u52a8\u63a7\u5236\uff0c\u9ad8\uff0c\u53ef\u91cd\u590d\u4f7f\u7528\uff0c\u652f\u6301JS\/CSS\u52a8\u6001\u5224\u65ad\uff0cPromise\u673a\u5236\n* window.onload\uff0c\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u81ea\u52a8\uff0c\u4e00\u6b21\u6027\uff0c\u9875\u9762\u7ea7\uff0c\u53d6\u51b3\u4e8e\u5177\u4f53\u5b9e\u73b0\uff0c\u53d6\u51b3\u4e8e\u5177\u4f53\u5b9e\u73b0\n* \u8fd9\u4e24\u6bb5\u4ee3\u7801\u90fd\u4f53\u73b0\u4e86\u8d44\u6e90\u52a0\u8f7d\u7684\u5f02\u6b65\u63a7\u5236\u601d\u60f3\uff1a\n*loadSource\u63d0\u4f9b\u4e86\u7ec6\u7c92\u5ea6\u7684\u63a7\u5236\n* window.onload\u65b9\u6848\u63d0\u4f9b\u4e86\u9875\u9762\u7ea7\u7684\u81ea\u52a8\u5316\u52a0\u8f7d\n* \u90fd\u5904\u7406\u4e86\u4f55\u65f6\u52a0\u8f7d\u548c\u5982\u4f55\u52a0\u8f7d\u7684\u95ee\u9898\uff0c\u53ea\u662f\u5b9e\u73b0\u65b9\u5f0f\u548c\u63a7\u5236\u7c92\u5ea6\u4e0d\u540c\n* *\/   \n\n    \n  \/\/ \u6dfb\u52a0css\n  function addStyle(css) {\n    if (typeof GM_addStyle != \"undefined\") {\n      GM_addStyle(css);\n    } else if (typeof PRO_addStyle != \"undefined\") {\n      PRO_addStyle(css);\n    } else {\n      const node = document.createElement(\"style\");\n      node.type = \"text\/css\";\n      node.appendChild(document.createTextNode(css));\n      const heads = document.getElementsByTagName(\"head\");\n\n      if (heads.length &gt; 0) {\n        heads&#91;0].appendChild(node);\n      } else {\n        \/\/ no head yet, stick it whereever\n        document.documentElement.appendChild(node);\n      }\n    }\n  }\n\n})();<\/code><\/pre>\n\n\n\n<p>\u7ecf\u8fc7\u5206\u6790\u4e4b\u540e\uff0c\u6211\u4eec\u5927\u81f4\u53ef\u4ee5\u5224\u65adload.js\u7c7b\u4f3c\u4e8eoh-my-diana.user.js\u7684\u91cd\u6784\uff0c\u4f46\u662f\u5462\u628acss\u901a\u8fc7pio.css\u6587\u4ef6\u5b9e\u73b0\uff0c load.js\u4ec5\u4f5c\u4e3a\u5728\u6240\u6709\u8d44\u6e90\u4e0b\u8f7d\u5b8c\u6210,\u89e6\u53d1 window.onload \u4e8b\u4ef6\uff0c\u6267\u884c \u52a0\u8f7d\u5723\u00b7\u5609\u7136() \u51fd\u6570\uff0c\u521b\u5efaLive2D\u5b9e\u4f8b\u5e76\u663e\u793a\u770b\u677f\u5a18\uff0conModelLoad() [\u6a21\u578b\u52a0\u8f7d\u56de\u8c03]\uff0cplayAction() [\u7528\u6237\u4ea4\u4e92]<\/p>\n\n\n\n<p>\u5f53\u7136\u5982\u679c\u770b\u5230\u8fd9\u91cc\u4f60\u8fd8\u662f\u6709\u5174\u8da3\u7684\u8bdd,\u4e0d\u59a8\u54b1\u4eec\u63a5\u7740\u5f80\u4e0b\u6eaf\u6e90\u3002<\/p>\n\n\n\n<p>\u6839\u636e\u535a\u5ba2\u5185\u5bb9\u627e\u5230\u8fd9\u4e2agithub\u9879\u76ee\uff1a<a href=\"https:\/\/github.com\/Dreamer-Paul\/Pio\/blob\/master\/static\/l2d.js\">Pio\/static\/l2d.js at master \u00b7 Dreamer-Paul\/Pio<\/a>\u6700\u540e\u627e\u5230\u8fd9\u4e2a\u6587\u4ef6\uff0c\u5230\u6700\u540e\u6211\u60f3\u5c31\u518d\u4e5f\u65e0\u6cd5\u7ee7\u7eed\u5f80\u524d\u63a2\u7d22<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u4e0a\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u7ed9\u81ea\u5df1\u7b80\u5355\u7684\u89e3\u91ca\u4e86\u8fd9\u4e2alive2d\u770b\u677f\u5a18\u7684load.js\u548cpio.js\u4ee5\u53capio_sdk4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27,55],"tags":[],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-open-source-analysis","category-technology"],"_links":{"self":[{"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":13,"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":1070,"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/posts\/192\/revisions\/1070"}],"wp:attachment":[{"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.preluna.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}