How to bake transformations correctly?

First of all, here is my PG of my problem https://playground.babylonjs.com/#LET49V#7, when you press R you enter on rotation mode and then when you press enter you are supposed bake or apply the rotation the user made.

The problem is that the rotation goes a bit off after baking the vertices after the rotation, and in my real project that is too big for a playground doesn’t even apply rotation at all sometimes, what am I doing wrong here?, do I need to set more parameters to the bakeCurrentTransformIntoVertices function?

The idea is to set the current rotation after you press enter.

Not sure if I understood your problem, but I believe you were having accumulated rotations there.

So, I made another PG for you, that maybe solves your problem:

sample of error (fix?) | Babylon.js Playground (babylonjs.com)

Note that instead of rotating the parent rotationNodeForBlock there, I rotated referenceMesh itself. Then cleared all rotations after baking.

Not sure if it really solves your problem, as honestly I am not sure if I understood it properly.

3 Likes

Ok it solved the problem on the PG, I need to implement it on my project now.

I forgot to rename the rotation Node there but this function is a reimplementation of a multiple mesh rotation algorithm, the problem now was that this ground (that I’m using as a reference image plane) used the same algorithm and I thought that it would work the same way, I’ll guess it wasn’t this case in this time.

But well, I’ll implement this fix on my current project and if it works I’ll put the answer as solution.

Worked like a charm on the official project, thanks!