Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js rotating and positioning of geometries

Tags:

three.js

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?

like image 264
susis strolch Avatar asked Jul 01 '16 18:07

susis strolch


People also ask

How do I rotate an image in 3 JS?

rotation = Math. PI/4; texture. center = new Vector2d(0.5, 0.5); // center of texture. Save this answer.

How do you make an object orbit another three Js?

One way to do is to create a Three. js object representing the orbit an add the circle and the planet to this orbit. This way, you just need to change the rotation of the orbit to make the planet revolving around the sun. var orbit = new THREE.

Can three Js do 2D?

The way that Three. js structures its rendering means that the learning curve won't be too steep. It organizes all of the renders you'll do, whether 3D or 2D, under a “Scene” container.


1 Answers

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.

like image 165
A.J.Bauer Avatar answered Sep 30 '22 19:09

A.J.Bauer