In the Start() function, it tries to find if the 3D model has a BoxCollider attached or not, and if not, it will programmatically create one and attach this component to it.

In the Update() function, the code finds the BoxCollider’s center, and rotate the object around the center of this bounding box.

Note: You should attach this to the geometric models imported. Suppose you created a place holder gameObject named “3DModels”, and the geometric model is called “ObjModelImported”, you should attach the script to the latter!

Hi, this code works but can be improved. You should not rotate around the world axis for y, it is more intuitive and much less error prone to rotate about local axis for y. To do so, modify the two “RotateAround” lines to read:

Hello, I was glad to find your script. I applied it to my object .obj file which is a model of a brain. I was originally using KeyPress with vector3 up, down, left and right depending on the key actions and it would rotate fine along the ‘y’ axis but up or down it would not rotate just on the ‘x’ axis the ‘z’ axis would be involved. So the brain would not rotate in place on the ‘x’ axis it would go back or forward in space even though the ‘z’ axis was set to ‘0’. I thought your script would help this in viewing your letter Y example but when I applied your script to it and used the mouse the brain jumps all over the place and not rotate in place. My only thought of what it might be is the pivot for the brain is not exactly centered or at multiple verticies when it was created. Or the pivot on my scene is somewhere else even though I set it to ‘center” , ‘local’. Any thoughts?

Hi Mike, try checking your inspector window to see what level of the hierarchy is actually moving. There is also a plugin somewhere I think which renders pivot points in the unity editor window which may help (sorry its been lost on me). Apart from that I can’t see your web app, it says failed to download data for some reason.

Thank you, I was able to figure it out and actually moved the center point of the object to it’s center through the script using this “bound.center = new Vector3(0, 10, 0);” at line 32. Simple and effective.