1

Possible Duplicate:
Rotating a custom geometry mesh around its center point

JSFiddle of this code is here...

I have a geometry loaded with ObjLoader in to the scene with theese vertices (A Simple double sided mat. triange) (I have manually defined vertices to re-create the sample, not used ObjLoader in the fiddle)

var geom = new THREE.Geometry();
geom.vertices.push(new THREE.Vector3(-4.77353, 2.7, 0.660501));
geom.vertices.push(new THREE.Vector3(-0.521001, 2.7, 0.660501));
geom.vertices.push(new THREE.Vector3(-0.521, 2.7, -2.065922));

In the world its position is (0, 0, 0) but according to its vertices i calculated its center point and now try to rotate this triagle around this centroid.

As you see in the fiddle, when i rotate the object on x asis by giving rotation value, it is rotated on x, y and z axis with 0.1 radians in each render. But i only need it to be rotated on x axis.

Note: Please check the fiddle first, before you answer the question.

Thanks for further helps

Community
  • 1
  • 1
Tezcan
  • 690
  • 2
  • 6
  • 16
  • What is your question? Update your fiddle and ask a simple question. – WestLangley Jan 21 '13 at 14:46
  • Fiddle allready updated. My question is, triangle is rotating on x, y and z axis by 0.1 radians per render func. I need it to be rotaed only on x axis... Thanks – Tezcan Jan 21 '13 at 14:52
  • What does the statement "it is rotated on x, y and z axis" mean? An object can only be rotated on one axis at a time. – WestLangley Jan 21 '13 at 15:14
  • See fiddle updated to r.55: http://jsfiddle.net/Ldt7z/137/ and ask your question in another way. – WestLangley Jan 21 '13 at 15:19
  • ı checked the fiddle of yours. What i am asking is, i need this triangle to spin, not orbit the red cube. – Tezcan Jan 21 '13 at 15:22
  • This is one solution: http://jsfiddle.net/Ldt7z/146/. If it is what you are looking for, I will post an answer. (I changed it back to r.50 and forgot to update it back to r.55) – WestLangley Jan 21 '13 at 17:19
  • Yes! This was just i was looking for. Thanks alot. Just one question. We applied translation to the triangle geometry and set its position to its centroid. But it did not move anywhere. Without translation matrix, i had tried to set the position of the triangle, but it moved and it was not a good choice for me. Can you explain why changing position of it not made it move. Also please post your answer and i will mark it as answered. – Tezcan Jan 22 '13 at 07:16

0 Answers0