Rotate a custom geometric mesh around its center point
When we add a CustomGeometry to a scene with vertex definitions and don't set a position, how can we make it rotate around its center point?
Script: http://jsfiddle.net/tezcancirakoglu/Ldt7z
In the example code, the object rotates around the X axis. I need to rotate it around its center point.
Hint: The red cubic grid is the starting center point of the rotating object. I need to rotate it around the x-axis of the red cube ... I tried a lot but still couldn't.
+3
source to share
2 answers
One solution is to translate the mesh geometry and compensate by changing the mesh position, for example:
var offset = objMesh.centroid.clone();
objMesh.geometry.applyMatrix(new THREE.Matrix4().makeTranslation( -offset.x, -offset.y, -offset.z ) );
objMesh.position.copy( objMesh.centroid );
updated script: http://jsfiddle.net/Ldt7z/165/
PS You don't need to save your violin before running it. There is no reason to have so many versions.
three.js r.55
+3
source to share