guansss / pixi-live2d-display

A PixiJS plugin to display Live2D models of any kind.
https://guansss.github.io/pixi-live2d-display/
MIT License
870 stars 132 forks source link

Weird interval between every idle motion play. #21

Closed dannylin0711 closed 3 years ago

dannylin0711 commented 3 years ago

Already set the motionFadingDuration and idleMotionFadingDuration to 0, but it doesn't work like the idle motion interval in Cubism Viewer, which is continuous and would not stop the previous idle animation before the next idle animation play.

guansss commented 3 years ago

I don't get it, that sounds like it's working as expected, since setting the fading duration to 0 means there will be an instant transition between two motions.

dannylin0711 commented 3 years ago

The idle animations should not have any transition between it, I think. It should loop smoothly, instead of looping with transition between every individual animation.

guansss commented 3 years ago

I'm still not clear, hmm, isn't "smoothly" equivalent to "with transition"? Or perhaps, did you mean to let the model loop a single idle motion instead of looping between multiple idle motions?

dannylin0711 commented 3 years ago

Ummm, yeah that's probably what I mean, there is a weird interval the model just stop animating when transition between the idle motion(one idle animation only)

dannylin0711 commented 3 years ago

Example

dannylin0711 commented 3 years ago

Example of looping single idle motion without interval using offical cubism viewer

guansss commented 3 years ago

OK I get it, this is a problem indeed, I'll investigate it.

guansss commented 3 years ago

Well, I realized setting the duration to 0 can actually fix this problem. The reason it doesn't work in your case is probably because the durations are overwritten by the ones that the idle motion defines. You can check if the idle motion in your model's settings file looks like this:

{"file": "abc.mtn", "fade_in": 2000, "fade_out": 2000}

If so, removing the fade_in and fade_out should fix it.

And if it's a model of Cubism 3 or 4, the keys will instead be FadeInTime and FadeOutTime.

dannylin0711 commented 3 years ago

Ok, I will look into that,thanks!

dannylin0711 commented 3 years ago
截圖 2021-03-05 上午8 28 16

OK, so I open up the motion.json, and the FadeInTime and FadeOutTime are both 0.0.

guansss commented 3 years ago

You need to check the model.json as well, because the durations will only be read from the model.json, and those in motion.json will be ignored. This is basically another bug that I'll fix later.

dannylin0711 commented 3 years ago

I didn't see that two parameters in my model.json , hmmm.

guansss commented 3 years ago

That's strange, I've tested various models and they all behaved well.

Could you share the model you used so I can test with it? If it's a proprietary model, you can replace the textures with solid black images before sharing, in order to prevent any potential abuse.

dannylin0711 commented 3 years ago

left_sen.zip I've also test the models with the viewer in the readme.md, the problem stills happen.

guansss commented 3 years ago

Thanks.

During the test, I can still see that it makes difference when setting 0 durations, as the picture below, the left model gets 0 durations applied and the right model remains default.

Honeycam 2021-03-06 22-24-23

Here's how the config should be set up, did you do it like this?

import { config } from 'pixi-live2d-display';

config.idleMotionFadingDuration = 0;
dannylin0711 commented 3 years ago

Yes, that's what I did. This set of models' motion changes expression(not using the expressions in Live2D), so some models would stop at the end of the motion and give a weird face in the time between the motions.

dannylin0711 commented 3 years ago

I'm not sure if this is the correct usage

const live2d = PIXI.live2d;

and use it as

live2d.config.motionFadingDuration = 0;
live2d.config.idleMotionFadingDuration = 0;
live2d.config.expressionFadingDuration = 0;

I did not use nodeJS.

dannylin0711 commented 3 years ago

https://github.com/dannylin0711/SDVX-Wallpaper This is the project, the code is open to public, but not the model.

dannylin0711 commented 3 years ago

Okay so I actually made some idiot error I initialize the model before I change the config BEFORE

let modelData = await live2d.Live2DModel.from(jsonPath, { idleMotionGroup: 'Idle', motionPreload: "ALL" });
...
live2d.config.motionFadingDuration = 0;
live2d.config.idleMotionFadingDuration = 0;
live2d.config.expressionFadingDuration = 0;

AFTER

live2d.config.motionFadingDuration = 0;
live2d.config.idleMotionFadingDuration = 0;
live2d.config.expressionFadingDuration = 0;
...
let modelData = await live2d.Live2DModel.from(jsonPath, { idleMotionGroup: 'Idle', motionPreload: "ALL" });

I firstly thought that model have the duration time set already, so I should edit the time after I initialize the model, however I just figure out while I was taking a shower that the config should be changed before I initialize the model if the model didn't specify a fadein/out value.

dannylin0711 commented 3 years ago

Hope that the fade in/out timing would implement in the future, good work and thanks for helping

guansss commented 3 years ago

Even I didn't think of this possibility, it's good to see it works.

dannylin0711 commented 3 years ago

Sorry, I would like to ask if there's a way to custom the auto focus function(e.g. disable the auto focus, and add my own event listener) on cursor?

guansss commented 3 years ago

Sure, you can disable the autoInteract option like this

dannylin0711 commented 3 years ago

Thanks!