-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GLTFLoader: Implement basic CUBICSPLINE support #12885
Conversation
One clarification — this PR adds "basic support" in the sense that CUBICSPLINE animation will actually play now, and will interpolate smoothly. However, it does not precisely match the authored splines — we'd need some changes to THREE.KeyframeTrack to do that. As a result, we also don't really get the efficiency benefits of cubic spline interpolation. |
So we need a custom interpolation to fully support CUBICSPLINE?
three.js/examples/js/loaders/MMDLoader.js Lines 1762 to 1773 in b66ff80
|
I believe that's correct. We'd need to write a version of CubicInterpolant that uses the tangents during evaluation, and set |
@donmccurdy I have no model other than what was committed to the model collection, but I’ve been meaning to hand-craft a very simplistic cubic-animated for my own dev work. I may as well accelerate that little undertaking. |
Ok, thanks - the Blender exporter can write CUBICSPLINE, that's probably where the current model came from. I'd be inclined to merge this in its current form and implement the more complex and precise interpolation when we have more models to test with, assuming that adding support for custom interpolants in THREE.KeyframeTrack sounds reasonable to everyone. |
Thanks! |
Yup, what I've done for MMD is very similar to what you mentioned, inherited keyframe track and overrode But this's a bit hacky so wandering if it'd be worth to provide a easier way to users for custom interpolants. Anyways, I think that tech would be good enough for CUBICSPLINE so far. |
This's my Cubic Spline WIP repo. Probably the impl would be like this. (I haven't tested because of no models tho!) |
@takahirox Nice! 😀 here's my one test model https://s3.amazonaws.com/bug-figures/v2-locrotscale-cube-embedded-buffers.gltf you can make more with the Blender exporter too |
Just in case, have you confirmed the animation with this PR expectedly works? |
Not sure what you mean — all of the official animated models still work (they don't use CUBICSPLINE) and the only test model I have (above) animates approximately correctly — only approximate because the tangent data is thrown out. So I wouldn't consider this implementation a reference, but it should work well enough for a starting point. |
Yes, that's as expected. |
I think these |
Using this: outputAccessorValues[ j / 3 + ? ] = outputAccessor.get?( j + 1 ); Because var outputAccessorValues = new TypedArray( outputAccessor.count * itemSize / 3 ); We're intentionally throwing away 2/3rds of the data in the |
indices of I suppose it should be...
|
Hm good point. 😅 I don't have the original Blender file for that model, so let me try making another model to test and verify this... |
Ok, yes I think you are correct then. Will make a new test model anyway for good measure. |
Yeah here's another example. Definitely need to multiply by |
Here's another example, working nicely with the new fix: |
Fixes #11761.
Also removes
CATMULLROMSPLINE
code, which has been removed from the glTF specification.This is approximate, and throws away some information in the animation samplers. In the future we can consider re-sampling at a higher framerate (as described in the comment) or providing a mechanism for setting tangents with
THREE.InterpolateSmooth
./cc @zellski I have exactly one model to test this, any chance you have others?