How to rotate object around its center?

Hey there! Three.js beginner here. So, I have a question. This is the code I use:
{
const mtlLoader = new MTLLoader();
mtlLoader.load(‘model.mtl’, (mtl) => {
mtl.preload();
const objLoader = new OBJLoader();
objLoader.setMaterials(mtl);
objLoader.load(‘model.obj’, (root) => {
scene.add(root);
window.myObject = root;

                    });
                });
            }

Later, on button click in separate JS function I rotate the object like this:
myObject.rotation.z -= 0.1;
My problem is it’s rotating against it’s base (bottom part), not against object’s actual center.

Now I’ve searched and searched and tried number of solutions, but I guess I’m still missing how it supposed to work. Any help would be really appreciated!

1 Like

Look there BeginnerExample step 3 and LoadGLTFmove
from the Collection of examples from discourse.threejs.org

1 Like

Thank you! That’s definitely a step in the right direction! But I have a question, what if I use OBJLoader and notGLTFLoader? Using myObject.scene throws error:
OBJLoader.js:464 TypeError: Cannot read properties of undefined (reading ‘updateWorldMatrix’)

Nevermind! Fixed it!