Here is the original playground from the html5gamedevs forum created in 2016:
http://babylonjs-playground.com/#DKROG%234
Here is the original forum link:
How to rotate mesh instead of the camera?
Thanks.
Here is the original playground from the html5gamedevs forum created in 2016:
http://babylonjs-playground.com/#DKROG%234
Here is the original forum link:
How to rotate mesh instead of the camera?
Thanks.
Hiya Ian, good to see you again.
After some changes in core a while ago, line 102 needs an extra parameter… under certain circumstances.
meshmodel.setPivotMatrix(newMtx, false);
[Adjusted playground]
That parameter is sort-of a “Adjust mesh transformations after pivotMatrix adjust? true/false”… and line 102 is inside-of a onPointerMove block. What I think WAS happening… is that pointer is trying to move the mesh, but then the bad line meshmodel.setPivotMatrix(newMtx);
defaults the 2nd parameter… to TRUE. I think… this causes the mesh to make the exact OPPOSITE move that the pointer made.
In other words, pointer makes move, but then setPivotMatrix UN-moves it back to original transform (rotation/position). By adding the false… we disallow the un-move. Just a theory.
Great! Thank you.
Another question:
Any ideas on how to add inertia to Nockawa’s code? He states “…that it’s not that hard to do…” Umm…yeah
heh. Yeah, Nockawa has “the force” with him. The rest of us… well, you know… we have to work at it.
Want to see a really BAD attempt? I knew ya did. https://www.babylonjs-playground.com/#DKROG#16
First, notice that I moved deltaPos declaration… to a global level… line 40.
Then… in pointerUp block, I went crazy. it contains MOST of the same code as pointerMove block, but I also added a renderLooper… to gradually down-scale deltaPos - lines 131/132 area. The down-scaling works almost-well the first drag… but then works less-well the next drag, and less-well the next drag, etc. Watch console… deltaPos is down-scaling faster… each drag-release. Not sure why.
And… it’s just bad coding. Mister skull is jerking all over hell, getting a head-ache. Notice line 151 has an extra .invert() that was not seen in line 104. It was a Wingnut addition… which means it’s likely a mistake.
All in all, it’s just a mess… but it MIGHT be GENERALLY going in the right direction. Just add intelligence, and it MIGHT start working.
Thanks Wingnut. I’ll look into this.