How do I scale the primitive and save it origin


Problem 1.

I would like to scale the primitive using it’s model matrix, to dynamically change its size depending on distance to it from the The problem is when i apply the scale, primitive just disappears. Also I investigated that if applying the very small scale value, like 0.999999 it works properly.

Problem 2

When scaling the model it’s origin shifts. I think that may cause model disappearing when applying large scale values - so the primitive just shifts far far away from it’s origin and I can’t find it.

Here is my approach in [Sandcastle]Cesium Sandcastle)

Thank in advance,
Ilya Shevelev


I’ve got that the scale do not apply properly because it scale the primitive with respect to Cartesian system origin, while the actual primitive position is shifted. So my new approach is to translate the primitive by minus its position, scale it and then translate it back.

Here is updated sandcastle.

But it only works with scale values 2 or 0.5, when applying any other values primitive just disappears.

Appreciate any help.