michalbe / cervus

:video_game: tiny WebGL 3d game engine
MIT License
28 stars 4 forks source link

Set/get scale relative to the initial (1,1,1) scaling #33

Closed stasm closed 7 years ago

stasm commented 7 years ago

Fix #30.

stasm commented 7 years ago

This turned out to be quite a ride. We can't rely exclusively on the local transformation matrix for getting canonical values for rotation and scale. By canonical I mean values that the user expects to see. The reason for that is the since both rotation and scale use the same matrix fields, the only order subsequent transformations that intuitively make sense is SRT (scale, rotation, translation). If we try to then apply another non-T transform, we're in trouble.

The solution is to always calculate the matrix from scratch using cached values for scale and rotation (as set by the user). I'll file a new PR for this.

Thanks again for catching the problem, @michalbe!

stasm commented 7 years ago

I filed #37.