question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blender export bones rotation pivot

See original GitHub issue
Description of the problem

In Blender I’ve created a mesh, attached armature and a simple rotation animation on one of the bones, called “head” (connected to another, named “stomach”).

When exporting to Three.js I get two issues. The first is that for position yz are flipped, similar for rotation. This was easy to solve by hacking the exported animationKeys to flip them to work with threejs. How I did that was inside the parseAnimation function, under the comment // ...assume skeletal animation I added this:

for (let i = 0; i < animationKeys.length; i++) {
  let keys = animationKeys[i]
  let diff = [keys.pos[0] - bones[h].pos[0], keys.pos[1] - bones[h].pos[1], keys.pos[2] - bones[h].pos[2]]
  keys.pos = bones[h].pos.slice()
  keys.pos[0] += diff[0]
  keys.pos[1] += -diff[2]
  keys.pos[2] += diff[1]

  diff = [keys.rot[0] - bones[h].rotq[0], keys.rot[1] - bones[h].rotq[1], keys.rot[2] - bones[h].rotq[2], keys.rot[3] - bones[h].rotq[3]]
  keys.rot = bones[h].rotq.slice()
  keys.rot[0] += diff[0]
  keys.rot[1] += -diff[2]
  keys.rot[2] += diff[1]
  keys.rot[3] += diff[3]
}

I suppose that is mostly a hack to get it to work for me, it should really be in the exporter python script, I’ll look into that later. That was just the context, the second issue is what this post is about.

When running the animation the pivot point for the “head” bone’s rotation looks to be at 0,0,0 while in Blender it’s relative to it’s position (parent?). The result is the following:

blender1 blender2 real1 real2

I tried to “hack” in a way to set pivot point myself, just to see if I could get it to work, but I couldn’t find how.

The export settings I use are the following (although I’ve tried pretty much every variation of settings I could think of): exportsettings

This is an issue but I’m not 100% sure how it’s supposed to work (regarding pivot points for bones).

Three.js version

0.82.1 (latest from npm at time of writing)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, May 31, 2018

The JSON Blender exporter has been removed with R93 (#14117).

Also see: https://threejs.org/docs/#manual/introduction/Loading-3D-models

0reactions
hesselbomcommented, Dec 3, 2016

Interesting! Looks like both animations and flipped values work well when just exporting the model and not the scene.

That’s good enough for me. I would still consider it a bug that it gets wrong when exporting scene/hierarchy but for my purposes I can get it to work like this.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I apply bones rotation to make sure it is 0 after export?
I rigged a model in blender and double-checked that the roll of each bone is 0. 3D Viewport showing model and armature. But...
Read more >
How to rotate Pivot point - Blender Developer Talk
Hi! When export, leave the axis as default and check apply transform. It will do the trick. Also set scale to fbx all....
Read more >
Blender FBX export -> wrong bone rotation relative to its ...
When I export bones from Blender via the fbx exporter the bones got wrong local rotation relative to their amature within unity.
Read more >
Blender to Unity Export - Correct Scale/Rotation
Option 2 - Counter-Rotate the Object, then Export · 1. Rotate the object -90 degrees on the X axis. Use the Transform panel...
Read more >
Exported rotation incorrect when objects are directly parented ...
When exporting, if you have top level objects parented to bones, the exported rotation is incorrect. ... Create an Armature with one or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found