-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
glTF Loader animation bug #10754
Comments
/cc @takahirox |
I've confirmed this problem. /cc @donmccurdy |
BTW does this animation work correctly on other libraries? |
Do you mean other than 3js? I couldn't find anywhere else to load and test glTF files, but I exported the animation as an FBX from Maya and it works when reimporting into Maya - I then converted it to glTF with assimp. |
According to acquaintance Maya user |
I was able to export my Maya file using OpenCOLLADA, but I get a segfault when trying to convert that .dae file using COLLADA2GLTF. I've added my .ma and .dae files to the dropbox link, if that might help someone who is more familiar with the pipeline. |
/cc @pjcozzi |
This problem seems being caused by sharing a material An easy workaround so far is separating materials in glTF file.
I'm thinking how to solve this problem on Three.js... |
Sounds like a bug in |
I'll make soon. I speculate skinning related uniforms and attributes for |
I made an example. https://takahirox.github.io/gltf-animation-bug/index.html See here for workarounds. The root issue seems how to share a material between This's my speculation. The corresponding attributes and uniforms to these properties three.js/src/renderers/webgl/WebGLState.js Lines 449 to 462 in 0aaf85c
three.js/src/renderers/WebGLRenderer.js Lines 1846 to 1869 in 8afa08d
Then the attribute and uniform values used to previously render another object To solve this, I have three ideas in my mind.
|
BTW, mesh_0 ~ mesh_10, mesh_12 ~ mesh_15 in this glTF file look weird. (This isn't root issue. Even if we fix this, the reported animation bug probably remains.) |
Good catch, I can file an assimp issue. Just to clarify, are the other hands most likely being animated because they're reusing the skinning from the first hand then? |
Yep, I think so. |
@takahirox Thanks for wading through all of this! 👏
If I understand correctly, this option won't help when there are two SkinnedMesh instances using the same material, but one has animation playing and the other does not? |
Probably it won't be problem. This problem occurs if an object doesn't have skinning properties |
How about we remove I'll give a it a try. |
I think it should be fixed now? |
Not yet. https://takahirox.github.io/gltf-animation-bug/index.html (This example uses the latest dev three.js via rawgit) |
As I wrote the above, the problem is occurred by non-updating skinning attribute/uniform values. The skinning GLSL code is kinda hardcoded. https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLProgram.js#L348 If it sets, the GLSL code expects that skinning attribute/uniform values are uploaded for rendered object. Even though we see |
I'll keep trying! 😁 |
Cool! The key is how we can share skinning material (GLSL code with The problem is, in current implementation, if For example, if we replace from
to
|
BTW, do you keep deprecating |
Yes, I can't see any reason for keeping it. |
Interestingly, there is no shader crash when using http://threejs.org/build/three.js... |
I've hacked this code in the test: loader.load( './handsWithPlane.gltf', function ( gltf ) {
var object = gltf.scene !== undefined ? gltf.scene : gltf.scenes[ 0 ];
object.traverse( function ( child ) {
if ( child.isSkinnedMesh ) {
var skeleton = child.skeleton;
var size = Math.sqrt( skeleton.bones.length * 4 );
size = THREE.Math.nextPowerOfTwo( Math.ceil( size ) );
size = Math.max( size, 4 );
skeleton.boneTextureWidth = size;
skeleton.boneTextureHeight = size;
skeleton.boneMatrices = new Float32Array( skeleton.boneTextureWidth * skeleton.boneTextureHeight * 4 ); // 4 floats per RGBA pixel
skeleton.boneTexture = new THREE.DataTexture( skeleton.boneMatrices, skeleton.boneTextureWidth, skeleton.boneTextureHeight, THREE.RGBAFormat, THREE.FloatType );
skeleton.useVertexTexture = true;
}
} );
var animations = gltf.animations;
... And that gives me this: Note that this is what I get with the builds pre- |
Ok, now |
I guess everything I've done so far is fixing issues that are only popping on my limited GPU (MacBook Air). Now I can finally see the plane rotation issue you guys are talking about. |
Have we confirmed that the animation plays correctly with other libraries? |
I've tried some other libraries but they couldn't load. As I wrote, this glTF file has some problems. |
This issue isn't glTF specific. I made a simpler example. (Demo) https://takahirox.github.io/gltf-animation-bug/index2.html The left one is normal Rotating a If we separate material by replacing this line
with
then we get an expected result, non-rotation normal Refer to my previous posts why sharing material causes this issue. |
This reverts commit c326466.
I just noticed that |
Yep. Noticed that too... Reverting! |
…ebgl_animation_skinning_morph. See #10754.
@leerichard42 any chance you could export to GLTF2? I had a quick look again and I'm getting this: |
@mrdoob the warning can be ignored there; GLTF2Loader does still accept multiple nodes per mesh. Not sure if that result is related to gltf 2.0 or not. |
Basically the problem (as @takahirox has explained) is that GLTF*Loader is creating I've also noticed that I hope to clean this up eventually, but it's a hard problem that needs more clean up first. |
@mrdoob we're hoping to get character animation through gltf but this is one of our roadblocks - what timeline are you looking at for this? |
@bhaux I think we need more samples. |
I'm happy to produce some - what specifications/properties do you need for these samples? |
We basically need samples that do not load correctly. So basically any roadblock you find. |
Ran into this problem. Could not rig this box as follows -- With even just the top flap rigged, the entire box rotates: Rigging the side flaps results in distorted geometry. Workaround appears to setting different materials on anything that is rigged with, say, a "skinned_" prefix and traversing through the model and setting any material without that prefix to Blender file here: |
... the structure is interesting: Not sure why Blender writes two meshes here. Does there need to be a bone anchoring the box or something? Could be broken skin weights/indices or how we're loading them... |
@donmccurdy Not sure, here's what the outliner looks like for convenience -- I can stabilize the box by using code to turn off material's skinning Interested in learning all I can about this, PBR & animations working on the web is really exciting. |
@enesser what are the names of the nodes in the three.js scene that you are disabling skinning on? I'm trying on the Cube_0 and Cube_1 meshes, with https://gltf-viewer.donmccurdy.com/#model=https://s3-us-west-2.amazonaws.com/s.cdpn.io/168282/rigged-gift-simple-v2.gltf, and not seeing the right results. Were there any other changes? |
@enesser I've found the issue. There seems to be an expectation somewhere that the skin weights are normalized, or at least that there be a bone assigned to each vertex. In the Anyway it's pretty easily fixed by adding a bone for the base, and assigning the remaining vertices. Result: rigged-simple-edit.zip I believe we've fixed the original bug (via #12791), so I'll close this issue. |
Description of the problem
When loading the animated handsWithPlane.gltf file found here: https://www.dropbox.com/sh/dvprkyj2ly782jn/AABLjwQLiOSWfr2VDdtlzjYCa?dl=0
The plane, which should not be animated, seems to be taking animation values from the hands, even though the plane is not attached to any skeleton.

There are two additional test models in the folder, which are isolated versions of the animated hand and non-animated plane.
Three.js version
Browser
OS
The text was updated successfully, but these errors were encountered: