Scaling from pivot or offset not origin?

Hi!

QUESTION: How to scale up a tree from the roots, not the center origin? :grin:

Here is a PG showing attempts for box to “grow” from sphere

could animate position and scale at the same time, but is there a better way to scale from a pivot?

Thanks,
:pray:

I usually prefer to use a parent object as a pivot point.
See https://www.babylonjs-playground.com/#1ZK5I9#9

2 Likes

You can set the second argument of setPivotPoint to BABYLON.Space.WORLD:
https://www.babylonjs-playground.com/#1ZK5I9#10

1 Like

@trevordev and @Gijs - the solution was a mix of BOTH. : )

thank you.

1 Like

Here is an alternative https://www.babylonjs-playground.com/#1ZK5I9#11

Method

  • create tree (box);
  • position pivot at root position ( bottom centre of box)
  • position tree so that root is in correct position (move box position.y to 1 so pivot is on ground, plus any x, z)
  • place a marker with it centre at the pivot position (since the box position has been displaced by the positioning of the pivot you need to add(pivotPt) to wherever you position the COMPASS)
  • any transformation of tree now takes place from root (box from bottom).
1 Like

Interesting… like!