Get the cordinates of object center


i have got sword object, which is the child of player component.
Mt question is, how i can get the center cordinates of blade.

I have no idea how I can get it. MatrixWorld only shows me where connect to the parent. :frowning:

any ideas?

You should be able to use getCenter from the geometry bounding box…

const targetV3 = new Vector3() 

If the geometry doesn’t have a boundingBox (it should do) you can use geometry. computeBoundingBox() or if the geometry has been explicitly translated you can create a new box3 set it from the object and do the same…

const targetV3 = new Vector3()
const box3 = new Box3() 

but using the geometry bounding box will not show me the start of my weapon, only the representation of the coordinate system in space.
I would like the blue red and green spheres to be perfectly at the beginning, middle and end of my weapon.

This is my code, how can I achieve this?:

const logPos = new THREE.Vector3();
    const corr = logPos.setFromMatrixPosition(this.player.weapon.matrixWorld);
    this.skillEffect.position.x = corr.x;
    this.skillEffect.position.y = corr.y;
    this.skillEffect.position.z = corr.z;

    const polowa = new Vector3();
    const test22 = this.player.geometryWeapon.geometry.computeBoundingBox();
    const min = this.player.geometryWeapon.geometry.boundingBox.min;
    const max = this.player.geometryWeapon.geometry.boundingBox.max;
    console.log(this.player.geometryWeapon, "ww");

    const geometry = new THREE.SphereGeometry(0.03, 16, 16);
    const material = new THREE.MeshLambertMaterial({ color: 0x00ff00 });
    const cube = new THREE.Mesh(geometry, material);

    const geometry1 = new THREE.SphereGeometry(0.05, 16, 16);
    const material1 = new THREE.MeshLambertMaterial({ color: 0xff0000 });
    const cube1 = new THREE.Mesh(geometry1, material1);

    const geometry2 = new THREE.SphereGeometry(0.1, 16, 16);
    const material2 = new THREE.MeshLambertMaterial({ color: 0x0000ff });
    const cube2 = new THREE.Mesh(geometry2, material2);

    const geometry3 = new THREE.SphereGeometry(0.1, 16, 16);
    const material3 = new THREE.MeshLambertMaterial({ color: 0xff00ff });
    const cube3 = new THREE.Mesh(geometry3, material3);
    cube.position.x = max.x;
    cube.position.y = max.y;
    cube.position.z = max.z;
    cube1.position.x = polowa.x;
    cube1.position.y = polowa.y;
    cube1.position.z = polowa.z;

    cube2.position.x = min.x;
    cube2.position.y = min.y;
    cube2.position.z = min.z;

    cube3.position.x = corr.x;
    cube3.position.y = corr.y;
    cube3.position.z = corr.z;

    const boundingBox = new THREE.Box3().setFromObject(this.player.weapon);

    const xSize = boundingBox.max.x - boundingBox.min.x;
    const ySize = boundingBox.max.y - boundingBox.min.y;
    const zSize = boundingBox.max.z - boundingBox.min.z;


What is the start of your weapon anyway, you mean the very edges of your sword ? Bounding box will give you the model minimum/maximum (you can consider them start/end on your model) of x, y, z and from there you can calculate the center. If you want to put the balls on your specific 3 points, simply move them with world coordinates and then parent them to your weapon. But adjusting these things is better to do in a 3D program, since you can export them as a done product.

The min and max of the geometry bounding box is the min and max bounds in units of the object, it’s not related to the position of the object so you’d need to factor that in eg…