Control diameter of sphere on the ground

How to make the sphere on the ground during controlling the diameter on this example https://www.babylonjs-playground.com/#GX8A2Y (by each update of values, the sphere has to be on the ground)

The center of the sphere is it’s position, to workaround this you can either update the position of the sphere to of set this or use a parent node for scaling at the bottom of the sphere.

See: https://www.babylonjs-playground.com/#GX8A2Y#1

1 Like

I believe you might be overthinking this a bit, although a transform node will do the trick most of the time. However looking at your other post, I see you want to add physics. Here’s the simplest solution:

https://www.babylonjs-playground.com/#GX8A2Y#2

Galen

2 Likes

@Galen Why when I am changing the shape to box https://www.babylonjs-playground.com/#GX8A2Y#4 it doesn’t match on the ground? Which postion you think has to be after changing the value of the slider?

The diameter of a box is not the same as a sphere. I would have to make more attempts, but perhaps this PG scene will show you a bit more.

https://www.babylonjs-playground.com/#GX8A2Y#6

Galen

1 Like

@Lokanath_Bagh

Is this what you’re looking for?

https://www.babylonjs-playground.com/#GX8A2Y#8

It’s important to understand the transforms of a primitive mesh. It’s all in the math - simple math, that is.

Galen

2 Likes

@Galen yup! I see it’s simple math! thank you:)

Is it possible to add a dashed lines to show the diameter of the sphere? https://www.babylonjs-playground.com/#GX8A2Y#9

Something like this? https://www.babylonjs-playground.com/#GX8A2Y#10

1 Like