mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.76k stars 35.38k forks source link

Inaccurate interpolation curves with MMD motion data. #22282

Closed Kikasuru closed 3 weeks ago

Kikasuru commented 3 years ago

Describe the bug

Three.JS's MMDAnimationHelper produces incorrect interpolation curves compared to MikuMikuDance.

Code

Posted here.

Live example

Expected behavior

This is rendered straight from MMD. Download MP4

PMM and VMD files are also provided in the assets folder.

See how with MMD, her arms slowly go into place, as with the live example, they jolt when they're going to the next keyframe.

Platform:

takahirox commented 3 years ago

Hi, thanks for the report. I am the author of Three.js MMD stuffs.

Unfortunately I'm not really sure if I can make time for MMD soon. If you are in hurry, I'd be pleased if you or someone else investigates the problem.

By the way, do you like Touhou? If so, you are my friend.

Kikasuru commented 3 years ago

Hi, thanks for the report. I am the author of Three.js MMD stuffs.

Unfortunately I'm not really sure if I can make time for MMD soon. If you are in hurry, I'd be pleased if you or someone else investigates the problem.

No problem! I should probably focus on other parts of my project anyways lol

By the way, do you like Touhou? If so, you are my friend.

image

Kikasuru commented 3 years ago

Status update in this?

takahirox commented 3 years ago

I'm still busy

Usnul commented 3 years ago

Without knowing what code is used for interpolation here, I can't say for sure. But it looks like curve data is interpreted incorrectly, what the video suggests - is that a spline is used for animation, something like this: image

the implementation of MMD here seems to default to linear interpolation instead, resulting in sharp transitions where curves meet, like the up and down motion.

Kikasuru commented 3 years ago

That's what I presumed as well.

takahirox commented 2 years ago

the implementation of MMD here seems to default to linear interpolation instead,

No, IIRC I didn't implement the interpolation as linear, but I implemented it as cubic bezier interpolation.

https://blog.goo.ne.jp/torisu_tetosuki/e/bc9f1c4d597341b394bd02b64597499d

https://github.com/mrdoob/three.js/blob/0a4f02b86a98403cf63ec227bbcf77a05805a164/examples/jsm/loaders/MMDLoader.js#L1939-L2076

If it moves as linear, it's a bug for sure.

takahirox commented 1 year ago

Simpler model and animation data will help the investigation.

Kikasuru commented 1 year ago

I'd say to quickly whip one up using one of the default models that MMD comes with, showing different curves with each motion.

I would but I've been a little busy myself unfortunately...

Mugen87 commented 3 weeks ago

MMDLoader has been deprecated, see #29698.