Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the pivot point of my object? #1364

Closed
AppleTea opened this issue Feb 20, 2012 · 10 comments
Closed

Change the pivot point of my object? #1364

AppleTea opened this issue Feb 20, 2012 · 10 comments
Labels

Comments

@AppleTea
Copy link

I'm very new in this area, so excuse if it's a stupid question.

My problem:

I want to build a prism (polygon consits of 24 planes). So I have 24 planes, everyone of them is 15° degreed of each other and grouped. Because it is to complicated to calculate how much the x and z distance is, it would be easier if you set the pivot point in the bottom right for example? right? but how? or is there another possibility to create a circle which consists of planes?

sorry for my bad english :-/

@mrdoob
Copy link
Owner

mrdoob commented Feb 20, 2012

You have two options.

Offset all the vertices in your geometry:

geometry.applyMatrix( new THREE.Matrix4().setTranslation( 0, 10, 0 ) );

Create a object that will act as pivot:

mesh.position.y = 10;

var pivot = new THREE.Object3D();
pivot.add( mesh );

scene.add( pivot );

@mrdoob mrdoob closed this as completed Feb 21, 2012
@nkint
Copy link

nkint commented Apr 1, 2015

is there any pros or cons in those two methods?

@placegraphichere
Copy link

geometry.applyMatrix( new THREE.Matrix4().setTranslation( 0, 10, 0 ) );

is now

geometry.applyMatrix( new THREE.Matrix4().makeTranslation( 0, 10, 0 ) );

7f05ba1

@JimmyJangkrik
Copy link

the applyMatrix makeTranslation thing, doesnt work in my case. dont know why.
the pivot object works. and IMHO it's easier.
note:
use this

mesh.position.x = ###;
mesh.position.y = ###;
mesh.position.z = ###;

instead of:

mesh.position.set(###,###,###);

@Tyguy7
Copy link

Tyguy7 commented Sep 14, 2015

Thanks @placegraphichere, that helped.

@nylki
Copy link

nylki commented Jun 20, 2016

Something like this should work as well with three.js v78, if you wanted to eg. rotate around your objects edge instead if its center:

mesh.geometry.translate( -myObjectWidth/2, 0, 0 );

@mrdoob
Copy link
Owner

mrdoob commented Jun 20, 2016

But be aware that using geometry.translate() is going to modify the position of all the vertices. It's a good solution as long as you're not planning on changing the pivot again later.

@imguccho
Copy link

imguccho commented Feb 7, 2019

I want to translate my mesh (3d box container) origin from center to left bottom corner. So when I will add any other small mesh box inside the container mesh, it should gets placed inside the left bottom corner instead of placing at center.

mesh.geometry.translate( -myObjectWidth/2, 0, 0 );

When I am using this, my mesh position is also getting changed

@mrdoob
Copy link
Owner

mrdoob commented Feb 7, 2019

@imguccho please, use the forum for help.

@padmaaditazz

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants