diff --git a/__init__.py b/__init__.py index 839cee39..5a271749 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +1 @@ -__version__ = "0.3.0-alpha.1" \ No newline at end of file +__version__ = "0.3.1" \ No newline at end of file diff --git a/doc/live2d.md b/doc/live2d.md index c8f2589d..c91d7ded 100644 --- a/doc/live2d.md +++ b/doc/live2d.md @@ -30,6 +30,8 @@ A configuration may look like this: "description": "Orange-Haired Girl, locally available. no internet required.", "url": "/live2d-models/shizuku/shizuku.model.json", "kScale": 0.000625, + "initialXshift": 0, + "initialYshift": 0, "kXOffset": 1150, "idleMotionGroupName": "Idle", "emotionMap": { @@ -52,10 +54,13 @@ Something you want to change - If the model files are hosted somewhere, you can just paste the url. The url should starts with `http://` or `https://`. - If the model you are trying to load is on your computer, put the model folder into the `live2d-models` directory and enter the relative path for the `url`. Like this `/live2d-models/UG/ugofficial.model3.json`. Keep the `/live2d-models` intact and don't change it nor add dots before it like `./live2d-models`. - `KScale`: How big the model should be. Make it smaller if the model is too big. Vice versa. +- `initialXshift` and `initialYshift` (added in `v0.3.1`): The initial position for the Live2D model. Position (0, 0) is the center. Use this to calibrate the initial position for the Live2D model. If these two parameters are absent, they will be assumed 0, which is the center of the screen. - `emotionMap`: a dictionary of facial expressions available. - The key (text left to the semicolon) is the name of the emotion. You can put any words into it, and the LLM will use these keywords to control the expression of the live2d model. - The value (text right to the semicolon) is the emotion index. This is the index that specify the emotion of the live2d model. After loading the model in the server, you can try running the function `setExpression(index)` in the console of the browser. Put some numbers into the function, see what the live2d model would do, and edit the emotion map according to the behavior and the index. + - `kXOffset` and `kYOffset`: deprecated and useless. Feel free to delete them. + ### Load the model diff --git a/model_dict.json b/model_dict.json index 6282ce2b..f37764aa 100644 --- a/model_dict.json +++ b/model_dict.json @@ -4,6 +4,8 @@ "description": "Orange-Haired Girl, locally available. no internet required.", "url": "/live2d-models/shizuku/shizuku.model.json", "kScale": 0.000625, + "initialXshift": 0, + "initialYshift": 0, "kXOffset": 1150, "idleMotionGroupName": "Idle", "emotionMap": { @@ -22,6 +24,8 @@ "description": "Orange-Haired Girl. Will fetch from CDN.", "url": "https://cdn.jsdelivr.net/gh/guansss/pixi-live2d-display/test/assets/shizuku/shizuku.model.json", "kScale": 0.000625, + "initialXshift": 0, + "initialYshift": 0, "kXOffset": 1150, "idleMotionGroupName": "Idle", "emotionMap": { @@ -40,6 +44,8 @@ "description": "Knight Mommy", "url": "https://cdn.jsdelivr.net/gh/Eikanya/Live2d-model/VenusScramble/otherunits/other_unit_90001/live2d/model.json", "kScale": 0.0011, + "initialXshift": 0, + "initialYshift": 0, "kXOffset": 1500, "kYOffset": -150, "idleMotionGroupName": "idle", @@ -58,6 +64,8 @@ "description": "Angel", "url": "https://cdn.jsdelivr.net/gh/Eikanya/Live2d-model/VenusScramble/playerunits/player_unit_00003/live2d/model.json", "kScale": 0.0011, + "initialXshift": 0, + "initialYshift": 0, "kXOffset": 1500, "kYOffset": -150, "idleMotionGroupName": "idle", @@ -83,6 +91,8 @@ "description": "Mashiro Shiina", "url": "https://cdn.jsdelivr.net/gh/artulloss/live2d/Sakurasou/mashiro/ryoufuku.model.json", "kScale": 0.0007, + "initialXshift": 0, + "initialYshift": 0, "kXOffset": 1000, "kYOffset": -200, "idleMotionGroupName": "idle", diff --git a/static/live2d.js b/static/live2d.js index 6b83df0e..516a465a 100644 --- a/static/live2d.js +++ b/static/live2d.js @@ -37,7 +37,12 @@ const live2dModule = (function() { }); model2 = models[0]; - model2.x = app.view.width / 2 - model2.width / 2; + + if (!modelInfo.initialXshift) modelInfo.initialXshift = 0; + if (!modelInfo.initialYshift) modelInfo.initialYshift = 0; + + model2.x = app.view.width / 2 - model2.width / 2 + modelInfo["initialXshift"]; + model2.y = app.view.height / 2 - model2.height / 2 + modelInfo["initialYshift"]; // model2.on("hit", (hitAreas) => { // if (hitAreas.includes("body")) {