Hi everyone,
I want to change the pivot point of my polyhedron but i don’t know how to do that
Here’s my playground
I don’t know how to set the pivot point of my mesh in his corner.
Anyone could help me ?
Thanks
Boris
Hi everyone,
I want to change the pivot point of my polyhedron but i don’t know how to do that
Here’s my playground
I don’t know how to set the pivot point of my mesh in his corner.
Anyone could help me ?
Thanks
Boris
You can use setPivotPoint to set it to whichever corner you want, like below (I also added a sphere at the pivot point and set the mesh rotating to visualize it).
Another way is to change the order of the points in the array instead, like this:
PS: in your PG it said you wanted to change it to points[0], but that already is the pivot point, so I changed it to points[1] to show how you can change it to whichever corner you want.
Sorry, my question was not totally well worded.
I need not only the pivot point but also the position of the final mesh. In the playground, it’s positionned on [0,0,0] and i’d like that the position would be the first point which is the exact position. I don’t understand why the axes of the mesh are in the origin.
I changed the formulation of the question…
Anyone ?
maybe @JohnK ?
Oops sorry I didn’t get any notifications for your replies…
One approach is to subtract pts[0] from each point like below. For simplicity I used subtractInPlace in the existing for loop instead of changing the constants manually.
EDIT: this is just to fix the points since the pivot point is already pts[0] as wanted.
@bvaisman glad you found a solution that works, this is an alternative.
An alternative method of applying a pivot point and setting the mesh position to the pivot point
Ok, that works too.
I’m sorry but i have some problems with pivots and mesh positions. I don’t understand how it works everytime. For instance, in my example, i don’t know why the origin of the created mesh is [0,0,0] instead of the middle of the mesh like all the examples with polyhedrons in the playground.
I think it would be easier for a Babylon newbie to be able to simply define an origin point for a mesh instead of playing with matrices, translations and pivots.
May be an improvement in Babylon 6.0 @Deltakosh ???
Thanks for all
Here is a changeOriginTo prototype function you can use in future.