I still use BabylonJS 3. We want to use Babylon as a kind of CAD viewer and I’m trying to write a compliant framework for our application. So far that works just fine, but now I’m not hanging on for 3 days and I’ve got a headache from it …
I’m trying to rotate an imported object around its own axis. And so that the position does not change.
On mobile so cannot easily check playgrounds until later today. However playground is using version 4, so you are right and if issue is in playground it cannot be issue I linked to above.
When i show the Center Point like i do in the First example, the Dot is in the Center. After i use Rotation = Vector3(Rad(90))… All is moving out of the Middle And this is not only with the one mesh, it’s with all meshes even the Babylon meshes
I am not sure, you have to check this out somehow, but some time ago I was working with the mergeMesh function and I noticed that after the merging I cannot rotate the mesh properly. So maybe you have the same problem, maybe merge mesh somehow is breaking rotation functionality.
Try importing single object instead of that and test it out.
But as I said, I am really not sure and maybe I am completely wrong
Hey thank you for the Request
But unfortunately your Example is the same as mine First example ^^
With an createMesh it works fine. But i have to work with this what i get and this is a full .obj mesh. So i have to repair it with this
I am beginning to wonder if it your expectation of the final rotation given by the three options that is not fitting with the rotation seen. Here is a slightly simplified version of your PG. I have removed the ground and have applied a rotation around the y axis only.
Idea is that you have to set pivot position after merging meshes into one. Because i believe that without that, pivot position is taken from the position of the pivot of the some mesh that existed before the merging (i really am not sure if this is the case);
So at the line 69-70 I simply set the pivot point at the center of the “fullObject”. And at the line 84 I’ve set camera.target also at the center of the mesh (otherwise the effect of the rotation looks wrong, delete this line to check it out);
Ye, I’ve deleted it, I thought I found the solution but because camera target was somewhere else, I thought it wasn’t complete enough xD. But yes, that’s it.
Thank you very much!
I have prepare it a little bit cau’se i don’t use the fullObject by Natural. I use the Meshes and Combine it to full. But it’s all the same…
function setPivotPosition(mesh, mergedMesh){
var info = mergedMesh.getBoundingInfo().boundingBox[“centerWorld”];
mesh.setPivotMatrix(BABYLON.Matrix.Translation(-info.x, -info.y, -info.z));
}