I’m trying to write an engine similar to the game Don’t Starve, basically a tiled ground with sprite “planted” on it.
It seems that Sprite does not support setting the origin used as the pivot for the sprite rotation toward the camera, so when the camera move and look more or less downward, the sprite appears to “float” over the ground.
I’m having hard time finding a workaround for that.
Is there any plan for including such feature to Sprite in Babylon? In the near future?
Should I start over using regular plane mesh, ditching all the cool stuff of the Sprite*Manager?
Is there anyone that have already achieved something similar? It would be nice to have some advices and feedbacks!
Hypothetically, would the Babylon.js team accept a PR for that? (not sure I’m skilled enough, I’m usually a back-end Node.js dev, I have limited knowledge in shader-programming, and no knowledge at all in low-level webGL)
Damn… even using mesh.setPivotMatrix(BABYLON.Matrix.Translation(-x, -y, -z), false), which is supposed to change the local origin along with the pivot point (when the 2nd parameter is set to false) has no effect on this… playground.
The thing is that when using billboard mode there’s no pivot used: the rotation part of the camera is simply copied into the rotation part of the billboard matrix (when billboard = all).
I finally found a workaround, using mesh.bakeTransformIntoVertices(BABYLON.Matrix.Translation(-x, -y, -z)), this way I really change the vertices position and can force the plane origin to be where I want it to be. See the last playground.
I wonder if we should add a usePivotForBillboardMode property that would do this automatically (the pivot point would come from the pivot matrix)? @Deltakosh / @sebavan ?