With the below code, position of a mesh is returned as (0, 0, 0)
but it is not. So is the positioın vector calculated after render process?
me.scene.add(objMesh); //me is a project class
objMesh.updateMatrixWorld(true);
alert(objMesh.position.x + ',' + objMesh.position.y + ',' + objMesh.position.z);
objMesh is created from objfile, it is added to the scene correctly and centroid is approx (-8, 3, 0) but position vector of objMesh is (0, 0, 0) do we have to auto calculate something first or should i calculate it manually from geometry vertices of the mesh ?
http://81.214.75.32:8181/admin
is the url
the site is in Turkish so i will translate the UI items
in the site there is "Dosya" menu item oppen the menu item and select "Proje Aç" a dialog appears in that dialog select MUTFAK_1 scene will appear in that scene, every meshes position is (0, 0, 0) is that possible :)
Use mesh. position. set(x,y,z) because you will do not need force updating, if you set mesh. position = xxx, you only changing the object attribute, not always moving object in scene real time.
In three. js, an object's "center" is the origin in the object's local coordinate system. If your object is not rotating around the point you want, then you need to translate the vertices of your geometry so the desired center is at the origin. geometry.
A Three. js Mesh is a base class that inherits from Object3d and is used to instantiate polygonal objects by combining a Geometry with a Material. Mesh is also the base class for the more advanced MorphAnimMesh and SkinnedMesh classes.
object.position
is always local to the object. If you want to get the position in world space you need to get it from object.matrixWorld
.
Try with this:
scene.add(objMesh);
scene.updateMatrixWorld(true);
var position = new THREE.Vector3();
position.getPositionFromMatrix( objMesh.matrixWorld );
alert(position.x + ',' + position.y + ',' + position.z);
r58
The function getPositionFromMatrix()
has been renamed to setFromMatrixPosition()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With