Get position of object in scene

Hello,

I’m new to three.js and am having trouble with getting the position of objects in my scene. Currently, I have 2 scenes, one with an orthogonal camera with non moving sprites, and one with a 3D model loaded from blender, with orbit controls (only affects the model and not the sprites). I am currently trying to draw a line that goes from one of the sprites to a specific object in my model. However, when I load the position of the object inside the model it just returns 0,0,0 position.

function drawLine(width, height) {

// scene.updateMatrixWorld();
var obj = scene.getObjectByName("101"); // 101 is name of object in blender model
console.log("answer", obj.getWorldPosition(scene.position));
var point1 = new THREE.Vector3();
obj.updateMatrixWorld();
obj.getWorldPosition(point1);
console.log(point1);

var material = new THREE.LineBasicMaterial({ color: 0x0000ff });
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(?,?,?));
geometry.vertices.push(new THREE.Vector3(?,?,?));
var line = new THREE.Line(geometry, material);
scene.add(line);

}

I’ve had a look at some of the other questions about this but nothing seems to be working and it always returns 0,0,0.

Let me know if you need any more code, I tried to keep it quite concise.

Best

position, rotation and scale are relative to the parent object. So you need to apply transform of all the ancestors of an object to get, so called, “global transform”. Hope that helps. :mermaid:

Hi Usnul,

Sorry I’m quite new the Three.js so I’m not too sure what you mean. All the objects in the model are uploaded using the MTL and OBJ loader as shown below. How would I apply a transform for each object in the model when all the positions are pre determined as defined by the blender model?

Thanks for you help!

group = new THREE.Group();

var mtlLoader = new THREE.MTLLoader();
mtlLoader.load('basic.mtl', function (materials) {
	materials.preload();

	var objLoader = new THREE.OBJLoader();
	objLoader.setMaterials(materials);
	objLoader.load('basic.obj', function (object) {
		group.add(object);
		scene.traverse(function (children) {
			objects.push(children);
		});
	})
})

scene.add(group);

Hi!
Could you add explanatory pictures of what you get and what you want in the result?

Sure! So below is the basic model from blender. The 3D model enables orbit controls to scene1 with the perspective camera. The circles on the outside are sprites, added to scene2 with the orthogonal camera.
I have drawn the black line in paint which is essentially what I would like to do. When I move the model I would like the line to update and draw to the new location of the object inside the blender model. But I can’t get the positions of anything, it’s all returning 0. Again let me know if you need to see any more code.

Thanks!

Untitled

Here is an example
https://jsfiddle.net/prisoner849/9oymrn5c/

It’s just a concept, not the ultimate solution.
You need to know position of the desired sprite in normalized device coordinates {x: [-1..1], y: [-1..1]}, then use a raycaster to cast a ray, find a point on it at the distance of 2 (I took this value from a top of my head), thus you’ll get the first point of the line, then you just get a world position of the desired object in the scene, so you’ll get the second point of the line. That’s it :slight_smile:

Thank you for your help! It works with the sprites, but for the blender object it just points to the middle of the whole model, instead of to one of the children.
For example, I replaced the cubes that you added with the following:

var mtlLoader = new THREE.MTLLoader();
mtlLoader.load('basic.mtl', function (materials) {
	materials.preload();
	renderer.render(scene, camera);

	var objLoader = new THREE.OBJLoader();
	objLoader.setMaterials(materials);
	objLoader.load('basic.obj', function (object) {
		group = object.clone();
		scene.add(group);
		console.log("obj", group);
	})
})
scene.add(group);

And then I used the get world position:

group.children[2].getWorldPosition(point2);
console.log(group, group.children[2], point2);

And the point2 still returns 0,0,0. I would guess it’s because I never have to translate the nodes after I load them, as they are already set to the correct place. Any idea to get around this problem?

Thanks

Any chance to provide a live code example with your model, showing the problem?

hey Nadia, I think you might have no offset in your children and it’s the geometry vertices that are offset instead. You might want to get bounding box of your geometry and add center of that box to the position that you get - this way it will for sure be a center of the object.

1 Like

Hi, prisoner, I’ve tried on a few online rendering sites to upload my model but they don’t accept other files in the system.

But this is the full code using your tempplate:

var camera, scene, renderer;
var cameraOrtho, sceneOrtho;
var spriteTL, spriteTR, spriteBL, spriteBR, spriteC;
var mapC;
var group;
var line;
var raycaster = new THREE.Raycaster();

var topRightPos = new THREE.Vector2();
var point1 = new THREE.Vector3();
var point2 = new THREE.Vector3();

init();
animate();

function init() {
var width = window.innerWidth;
var height = window.innerHeight;
camera = new THREE.PerspectiveCamera(60, width / height, 1, 2100);
camera.position.z = 115;
cameraOrtho = new THREE.OrthographicCamera(-width / 2, width / 2, height / 2, -height / 2, 1, 10);
cameraOrtho.position.z = 10;
scene = new THREE.Scene();
scene.background = new THREE.Color(“gray”);
//scene.fog = new THREE.Fog(0x000000, 1500, 2100);
sceneOrtho = new THREE.Scene();

var light = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(light);

line = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]), new THREE.LineBasicMaterial({ color: "white" }));
scene.add(line);

var textureLoader = new THREE.TextureLoader();
textureLoader.load("https://threejs.org/examples/textures/sprite0.png", createHUDSprites);
var mapB = textureLoader.load("https://threejs.org/examples/textures/sprite1.png");
mapC = textureLoader.load("https://threejs.org/examples/textures/sprite2.png");

var geoms = [
	new THREE.SphereBufferGeometry(1, 18, 9),
	new THREE.BoxBufferGeometry(2, 2, 2)
];
// for (let i = 0; i < 10; i++) {
// 	let geom = geoms[i % 2];
// 	let mat = new THREE.MeshBasicMaterial({
// 		color: Math.random() * 0x888888 + 0x888888
// 	});
// 	let mesh = new THREE.Mesh(geom, mat);
// 	mesh.scale.setScalar(100);
// 	mesh.position.set(Math.random() - 0.5, Math.random() - 0.5, Math.random() - 0.5).normalize().multiplyScalar(2 * 250);
// 	mesh.rotation.set(Math.random() * Math.PI, Math.random() * Math.PI, Math.random() * Math.PI);
// 	group.add(mesh);
// }
var mtlLoader = new THREE.MTLLoader();
mtlLoader.load('basic.mtl', function (materials) {
	materials.preload();
	renderer.render(scene, camera);

	var objLoader = new THREE.OBJLoader();
	objLoader.setMaterials(materials);
	objLoader.load('basic.obj', function (object) {
		group = object.clone();
		scene.add(group);
		console.log("obj", group);
	})
})
scene.add(group);

// renderer
renderer = new THREE.WebGLRenderer();
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.autoClear = false; // To allow render overlay on top of sprited sphere
document.body.appendChild(renderer.domElement);


var controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.campingFactor = 0.25;
controls.enableZoom = true;
//
window.addEventListener('resize', onWindowResize, false);

}

function createHUDSprites(texture) {
var material = new THREE.SpriteMaterial({
map: texture
});
var width = material.map.image.width;
var height = material.map.image.height;
spriteTL = new THREE.Sprite(material);
spriteTL.center.set(0.0, 1.0);
spriteTL.scale.set(width, height, 1);
sceneOrtho.add(spriteTL);
spriteTR = new THREE.Sprite(material);
spriteTR.center.set(1.0, 1.0);
spriteTR.scale.set(width, height, 1);
sceneOrtho.add(spriteTR);
spriteBL = new THREE.Sprite(material);
spriteBL.center.set(0.0, 0.0);
spriteBL.scale.set(width, height, 1);
sceneOrtho.add(spriteBL);
spriteBR = new THREE.Sprite(material);
spriteBR.center.set(1.0, 0.0);
spriteBR.scale.set(width, height, 1);
sceneOrtho.add(spriteBR);
updateHUDSprites();
}

function updateHUDSprites() {
var width = window.innerWidth / 2;
var height = window.innerHeight / 2;
spriteTL.position.set(-width, height, 1); // top left
spriteTR.position.set(width, height, 1); // top right
spriteBL.position.set(-width, -height, 1); // bottom left
spriteBR.position.set(width, -height, 1); // bottom right

var sWidth = spriteTR.material.map.image.width / 2;
var sHeight = spriteTR.material.map.image.height / 2;
topRightPos.set(
	(width - sWidth) / width,
	(height - sHeight) / height
)

}

function onWindowResize() {
var width = window.innerWidth;
var height = window.innerHeight;
camera.aspect = width / height;
camera.updateProjectionMatrix();
cameraOrtho.left = -width / 2;
cameraOrtho.right = width / 2;
cameraOrtho.top = height / 2;
cameraOrtho.bottom = -height / 2;
cameraOrtho.updateProjectionMatrix();
updateHUDSprites();
renderer.setSize(window.innerWidth, window.innerHeight);
}

function animate() {
requestAnimationFrame(animate);
render();
}

function render() {

// find point at the sprite
raycaster.setFromCamera(topRightPos, camera);
raycaster.ray.at(2, point1);
line.geometry.attributes.position.setXYZ(0, point1.x, point1.y, point1.z);


// find point at the object
group.children[2].localToWorld(point2);
console.log(group, group.children[2], point2);
line.geometry.attributes.position.setXYZ(1, point2.x, point2.y, point2.z);

line.geometry.attributes.position.needsUpdate = true;

renderer.clear();
renderer.render(scene, camera);
renderer.clearDepth();
renderer.render(sceneOrtho, cameraOrtho);

}

And the beldner object:

basic.mtl

Blender MTL File: ‘basic.blend’

Material Count: 9

newmtl 1
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.031637 0.639282 0.091548
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 1.001
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.014530 0.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 101
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.008818 0.032027 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 2
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.031637 0.639282 0.091548
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 201
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.015540 0.000000 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 202
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.000000 0.033600 0.640000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 3
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.031637 0.639282 0.091548
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl 4
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.076122 0.640000 0.119792
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

newmtl None
Ns 0
Ka 0.000000 0.000000 0.000000
Kd 0.8 0.8 0.8
Ks 0.8 0.8 0.8
d 1
illum 2

basic.obj

Blender v2.79 (sub 0) OBJ File: ‘basic.blend’

www.blender.org

mtllib basic.mtl
o Cube.004_Cube
v 3.478498 0.678071 -1.530011
v 3.478498 1.571983 -1.530011
v 3.478498 0.678071 -2.585751
v 3.478498 1.571983 -2.585751
v 4.525196 0.678071 -1.530011
v 4.525196 1.571983 -1.530011
v 4.525196 0.678071 -2.585751
v 4.525196 1.571983 -2.585751
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 1//1 2//1 4//1 3//1
f 3//2 4//2 8//2 7//2
f 7//3 8//3 6//3 5//3
f 5//4 6//4 2//4 1//4
f 3//5 7//5 5//5 1//5
f 8//6 4//6 2//6 6//6
o Cube_wall
v -7.869982 0.023798 0.237665
v -7.869982 3.936242 0.237665
v -7.869982 0.023798 -0.354652
v -7.869982 3.936242 -0.354652
v -2.225870 0.023798 0.237665
v -2.225870 3.936242 0.237665
v -2.225870 0.023798 -0.354652
v -2.225870 3.936242 -0.354652
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl 1.001
s off
f 9//7 10//7 12//7 11//7
f 11//8 12//8 16//8 15//8
f 15//9 16//9 14//9 13//9
f 13//10 14//10 10//10 9//10
f 11//11 15//11 13//11 9//11
f 16//12 12//12 10//12 14//12
o 2
v -7.823242 0.006386 7.811970
v -2.226626 0.006386 7.811970
v -7.823242 0.006386 0.290693
v -2.226626 0.006386 0.290693
vn 0.0000 1.0000 0.0000
usemtl 2
s off
f 17//13 18//13 20//13 19//13
o 4
v -7.829771 0.013267 -0.362602
v -2.233155 0.013267 -0.362602
v -7.829771 0.013267 -7.883879
v -2.233155 0.013267 -7.883879
vn 0.0000 1.0000 0.0000
usemtl 4
s off
f 21//14 22//14 24//14 23//14
o 1
v 2.237090 0.064851 7.664445
v 7.833707 0.064851 7.664445
v 2.237090 0.064851 0.143168
v 7.833707 0.064851 0.143168
vn 0.0000 1.0000 0.0000
usemtl 1
s off
f 25//15 26//15 28//15 27//15
o 3
v 2.294181 0.013267 -0.362602
v 7.890798 0.013267 -0.362602
v 2.294181 0.013267 -7.883879
v 7.890798 0.013267 -7.883879
vn 0.0000 1.0000 0.0000
usemtl 3
s off
f 29//16 30//16 32//16 31//16
o Cube.001_Cube.002
v 2.313826 0.023775 0.237665
v 2.313826 3.954771 0.237665
v 2.313826 0.023775 -0.354652
v 2.313826 3.954771 -0.354652
v 7.957938 0.023775 0.237665
v 7.957938 3.954771 0.237665
v 7.957938 0.023775 -0.354652
v 7.957938 3.954771 -0.354652
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 33//17 34//17 36//17 35//17
f 35//18 36//18 40//18 39//18
f 39//19 40//19 38//19 37//19
f 37//20 38//20 34//20 33//20
f 35//21 39//21 37//21 33//21
f 40//22 36//22 34//22 38//22
o Cube.002_Cube.003
v -2.236832 -0.116833 -7.936278
v -2.236832 3.795611 -7.936278
v -1.644511 -0.116833 -7.935033
v -1.644511 3.795611 -7.935033
v -2.270053 -0.116833 7.877797
v -2.270053 3.795611 7.877797
v -1.677732 -0.116833 7.879041
v -1.677732 3.795611 7.879041
vn 0.0021 0.0000 -1.0000
vn 1.0000 0.0000 0.0021
vn -0.0021 0.0000 1.0000
vn -1.0000 0.0000 -0.0021
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 41//23 42//23 44//23 43//23
f 43//24 44//24 48//24 47//24
f 47//25 48//25 46//25 45//25
f 45//26 46//26 42//26 41//26
f 43//27 47//27 45//27 41//27
f 48//28 44//28 42//28 46//28
o Cube.003_Cube.004
v 1.732537 -0.116833 -7.936278
v 1.732537 3.795611 -7.936278
v 2.324858 -0.116833 -7.935033
v 2.324858 3.795611 -7.935033
v 1.699315 -0.116833 7.877797
v 1.699315 3.795611 7.877797
v 2.291636 -0.116833 7.879041
v 2.291636 3.795611 7.879041
vn 0.0021 0.0000 -1.0000
vn 1.0000 0.0000 0.0021
vn -0.0021 0.0000 1.0000
vn -1.0000 0.0000 -0.0021
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 49//29 50//29 52//29 51//29
f 51//30 52//30 56//30 55//30
f 55//31 56//31 54//31 53//31
f 53//32 54//32 50//32 49//32
f 51//33 55//33 53//33 49//33
f 56//34 52//34 50//34 54//34
o 201
v -4.670515 0.793187 -5.187165
v -4.670515 1.962853 -5.187165
v -4.670515 0.793187 -7.187165
v -4.670515 1.962853 -7.187165
v -3.623817 0.793187 -5.187165
v -3.623817 1.962853 -5.187165
v -3.623817 0.793187 -7.187165
v -3.623817 1.962853 -7.187165
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl 201
s off
f 57//35 58//35 60//35 59//35
f 59//36 60//36 64//36 63//36
f 63//37 64//37 62//37 61//37
f 61//38 62//38 58//38 57//38
f 59//39 63//39 61//39 57//39
f 64//40 60//40 58//40 62//40
o 301_Cube.005
v -4.670515 0.793187 -1.643110
v -4.670515 1.962853 -1.643110
v -4.670515 0.793187 -3.643110
v -4.670515 1.962853 -3.643110
v -3.623817 0.793187 -1.643110
v -3.623817 1.962853 -1.643110
v -3.623817 0.793187 -3.643110
v -3.623817 1.962853 -3.643110
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 65//41 66//41 68//41 67//41
f 67//42 68//42 72//42 71//42
f 71//43 72//43 70//43 69//43
f 69//44 70//44 66//44 65//44
f 67//45 71//45 69//45 65//45
f 72//46 68//46 66//46 70//46
o 101
v -7.190013 0.793187 -0.724297
v -7.190013 1.962853 -0.724297
v -7.190013 0.793187 -0.904204
v -7.190013 1.962853 -0.904204
v -6.143315 0.793187 -0.724297
v -6.143315 1.962853 -0.724297
v -6.143315 0.793187 -0.904204
v -6.143315 1.962853 -0.904204
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl 101
s off
f 73//47 74//47 76//47 75//47
f 75//48 76//48 80//48 79//48
f 79//49 80//49 78//49 77//49
f 77//50 78//50 74//50 73//50
f 75//51 79//51 77//51 73//51
f 80//52 76//52 74//52 78//52
o 202
v -4.670515 0.793187 6.758336
v -4.670515 1.962853 6.758336
v -4.670515 0.793187 4.758336
v -4.670515 1.962853 4.758336
v -3.623817 0.793187 6.758336
v -3.623817 1.962853 6.758336
v -3.623817 0.793187 4.758336
v -3.623817 1.962853 4.758336
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl 202
s off
f 81//53 82//53 84//53 83//53
f 83//54 84//54 88//54 87//54
f 87//55 88//55 86//55 85//55
f 85//56 86//56 82//56 81//56
f 83//57 87//57 85//57 81//57
f 88//58 84//58 82//58 86//58
o 203_Cube.008
v 4.056071 0.793187 6.758336
v 4.056071 1.962853 6.758336
v 4.056071 0.793187 4.758336
v 4.056071 1.962853 4.758336
v 5.102769 0.793187 6.758336
v 5.102769 1.962853 6.758336
v 5.102769 0.793187 4.758336
v 5.102769 1.962853 4.758336
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl None
s off
f 89//59 90//59 92//59 91//59
f 91//60 92//60 96//60 95//60
f 95//61 96//61 94//61 93//61
f 93//62 94//62 90//62 89//62
f 91//63 95//63 93//63 89//63
f 96//64 92//64 90//64 94//64

And the line still points at the center of the object like so:

Thanks Unsul for your help but I’m not sure what you mean by bounding box, would you mind giving an example?

Thanks again

Hey, sure, no problem. A bounding box is a rectangular 3D volume that defines boundaries (bounds) of a thing, in the case I was talking about - boundaries of a geometry. Here’s a 2D example of a bounding box(rectangle in this case) for a set of points:
image

The box is defined by min (lowest X and lowest Y) and max (highest X and highest Y), in the figure above that’s B1=min and B2=max.

Three.js can and does calculate those bounding boxes for all geometries automagically since it uses that info for culling (deciding what not to draw, based on camera position/direction/angle/etc).

Bounding volume is can be used to approximate center of an object, it’s you take B1 and B2, add them, and divide by 2:

Center = (B1+B2)/2

or in Three.js world:

center = boundingBox.min.clone().add(boundingBox.max).multiplyScalar(0.5);

hope that helps! :unicorn:

Just an addition.
As boundingBox is THREE.Box3(), then for simplicity you can call .getCenter().

In common case, it will be something like this:

var mesh = child_mesh_of_the_loaded_object;

mesh.geometry.computeBoundingBox();
var center = new THREE.Vector3();
mesh.geometry.boundingBox.getCenter(center);
mesh.geometry.center();
mesh.position.copy(center);

Hi Unsul,

Thanks for the explanation. I’m still unsure how it applies to my problem.
So I guess the bounding box would be around the full blender object and I would need to find the center of that. What do you mean by adding the center of that box to the position? How would I do that in the code?

Thanks,

Nadia

Those are good questions. It’s basics, so it’s a bit difficult to explain, since the concepts are quite broad. In three.js you have Object3D graph, what that means is that Object3D can have other Object3D inside of it, like a DOM tree in HTML, where a <div> can have another <div> inside of it. So, there’s a thing called Mesh, it’s a sub-class of Object3D. Your "blender object"s are Meshes grouped together in some kind of hierarchy. A Mesh is just a normal Object3D, but it also has 2 new things:

  • material
  • geometry

so let’s say you have following hierarchy:

scene{
   mesh{
       geometry,
       material
   }
}

to find the center of that mesh object, we will need to find it’s global position - that you already know how to do. But this will give you only it’s position, not the center of the object. Position is basically like point 0 on an axis plot, it can be anywhere relative to the object’s center, it can be even very very far away from any point on the object itself.

1 Like

Wooooo! Many thanks to you, I just saw this and it’s working.
Thanks Unsul too makes sense with the bounding box, gives me more info to how the structure works.

1 Like