[SOLVED] Scale object from custom pivot point

In 3dstudio Max or Maya you can change the pivot point of say a 2d plane to be in the bottom right hand corner instead of the centre of the object which is the typical default in most software including playcanvas when you create a new 3d object.

In Max/Maya when you change the pivot point and scale the object up or down this scaling happens from the corner of the object outwards/inwards instead of from the centre of the object.

How could I re-create this behaviour in playcanvas?

I have tried to export a .obj file where the pivot point has been changed but playcanvas does not seem to respect this.

I also need to be able to duplicate the object and do the same thing with the child by selecting the new object with something like this:

this.app.root.children[this.app.root.children.length-1]

The easiest way would be to make the model a child of another (blank) entity that acts as the root and apply all the transformations on that root entity.

1 Like

Good old fashioned Unity trick that. I do the same.

Thanks @yaustar I tried that and although it’s not working exactly how I need it to solve my problem I think I can hack it.

Info below if anyone is interested.
—The problem—
I want to create a marquee selection box when the user drags along the screen. Any image editing people will know what I am talking about.

So trying your suggestion I have a two cubes, CUBE1 + CUBE2 … CUBE2 is a child of the CUBE1.

So on mousedown I duplicate CUBE1 and place it where the cursor is… which in turn makes a copy of CUBE2 which is offset to try and fix the pivot problem… ok cool, so far so good.

BUT as I move the mouse I am scaling CUBE1 along the x and y axis based on the mouse cursor co-ordinates to scale the cube up and down. Unfortunately this also scales up CUBE2 AND it moves CUBE2 along the x axis which is exactly what I am trying to avoid.

If the cube width data is the same metric as the 3d world space then I can get the cube width divide by 2 and feed that into the position of CUBE1 x position. So will try that next.

Ah - what you need to do is position the child cube so that it’s bottom left corner is at 0,0,0 rather than the middle. Then the scaling should work.

Aaah a much easier (better) solution, thank you @whydoidoit … that worked perfectly :slight_smile: