6

I try to write an export of an 3-d plant modelling software to Three.js but got stuck with the rotations and translations of the objects.

So far I tried to use quaternions and transformation matrices but both results are not satisfying. For my tests I use a simple binary tree that originally looks like this:

enter image description here

the results of my export are this:

enter image description here

You can find the code of both export under

http://ufgb966.forst.uni-goettingen.de/three/test2Quaternion.html

http://ufgb966.forst.uni-goettingen.de/three/test2Matrix.html

It seams that my rotations are made around the wrong point. Each rotation should be done around the origin of each geometry. What would be a method to achieve the result I'm looking for?

  • Consider the approach taken at (lines 54-73) at [threejs.org/examples/webgl_geometry_hierarchy.html](http://threejs.org/examples/webgl_geometry_hierarchy.html) – gallygator Jul 02 '16 at 15:50
  • @gallygator this approach is using Euler angles which I do not have and recalculating them from the matirx is normally not an good idea. – susis strolch Jul 02 '16 at 19:18
  • 1
    I think the issue is how you have constructed your object from its component parts. The goal would be establishing an _object hierarchy_ for your component geometries that would transform _together_ in world space. – gallygator Jul 02 '16 at 19:45

2 Answers2

5

Just in case you haven't already, you might want to take a look at this: Using Matrices & Object3Ds in THREE and this How to use matrix for transformation, it helped me out. Also note that three.js uses a right handed coordinate system which you probably know.

If you export from blender, try -Z Forward, Y up.

A.J.Bauer
  • 2,803
  • 1
  • 26
  • 35
  • It was a "right-handed vs. left-handed coordinate system" problem. Following this [matrix transformation](http://stackoverflow.com/a/1264880/2421048) solved my problem. – susis strolch Jul 08 '16 at 00:54
0

In my opinion you must change sequence of translation and rotation transformations - the problem is in transformations sequence.

Kamil Kiełczewski
  • 85,173
  • 29
  • 368
  • 345