I think this problem is the problem of our project, but I can’t locate the reason, so I would like to ask which may cause the failure of clearCoat.
I really don’t know why clearcoat would not work… Do you have a live link which shows the problem?
I found that THE varnish works in THE version deployed on the Internet!! Can pull the version to locate the problem!
Hello babylon, I have noticed that this problem has been modified on github and tested. I found this problem when only the parent of the mesh scales unevenly. Modified will updateGizmoRotationToMatchAttachedMesh = false, mesh itself rotation after a non-uniform scale can cause mesh scale was modified to uniform scale.
This is the test page, first change the ball to non-uniform scale and then rotate, the ball will be changed to uniform scale.
A Basic Scene | Babylon.js Playground (babylonjs.com)
Rotation does work for me in your Playground even after I have scaled the sphere in one direction:
Need more rotation Angle will appear problem, can use because the gizmo. Gizmos. RotationGizmo. UpdateGizmoRotationToMatchAttachedMesh = false, If the gizmo gizmos. RotationGizmo. UpdateGizmoRotationToMatchAttachedMesh = true will not be used.
I see! No idea why it’s doing that…
Summoning the king of Gizmo @Cedric, but be patient as it is vacation time these days.
@xiehangyun
Rotation with non uniform scaling is limited. instead of producing wrong orientation, it’s just disabled with a warning in the console.
This comes from the fact that it’s impossible to decompose properly a world matrix in that case with quaternion/scale/translation.
A solution would be to use translation/scale/rotation quaternion all along but it would be a nightmare and very, very bug prone when generalizing to Node and not only TransformNode.
Moreover, non uniform scaling and not a common case and adding a lot of potential bugs/back compatibility break for that case doesn’t seem like a win to me.
So, either set UpdateGizmoRotationToMatchAttachedMesh to the correct value or try to limit the potential to have non uniform scaling.
Thank you for your recovery. I know, but previously it was only the parent node that caused the problem, but now the node itself has been disabled. And there is no problem with rotation first and then scaling, so is there another solution?
I would set the gizmo node to be the last one in hte hierarchy with uniform scaling.
Basically, transforming a non uniform scaling is not allowed depending on UpdateGizmoRotationToMatchAttachedMesh
value.
Or, maybe even simpler, create a transform node at the absolute position of the node you want to transform and with the observables, set the rotation value of the node from that transient nodeTransform.
Basically, use a proxy transformNode.
If the non-uniform scaling of the node itself (the parent node is uniformly scaled) can be rotated properly, then creating a proxy node in world coordinates can be a good solution。
Hello babylon, since PlaneRotationGizmo modification last time, I find that the loaded gltf model cannot be rotated at all, so I rewrite the verification code of irregular scaling.As shown in the following code, the rotation error caused by non-uniform scaling is not because the node itself is non-uniform scaling, but because its parent is non-uniform scaling, so I relaxed the check criteria for non-uniform scaling. This also allows you to select a mesh and rotate it to world coordinates without any problems.
const nodeScale = new Vector3(1, 1, 1);
const nodeQuaternion = new Quaternion(0, 0, 0, 1);
const nodeTranslation = new Vector3(0, 0, 0);
this._handlePivot();
this.attachedNode.getWorldMatrix().decompose(nodeScale, nodeQuaternion, nodeTranslation);
let nodeParentScaleCheck = new Vector3(1, 1, 1);
if (this.attachedNode.parent) {
nodeParentScaleCheck = this.attachedNode.parent.absoluteScaling
}
const uniformScaling = Math.abs(Math.abs(nodeParentScaleCheck.x) - Math.abs(nodeParentScaleCheck.y)) <= Epsilon && Math.abs(Math.abs(nodeParentScaleCheck.x) - Math.abs(nodeParentScaleCheck.z)) <= Epsilon;
if (!uniformScaling && this.updateGizmoRotationToMatchAttachedMesh) {
Logger.Warn("Unable to use a rotation gizmo matching mesh rotation with non uniform scaling. Use uniform scaling or set updateGizmoRotationToMatchAttachedMesh to false.");
return;
}
This is something I’ve planed to rework in the coming weeks.
It should be possible to allow non-uniform scaling rotation at the price of a different decomposition. And/or transient transform.
In the mean time, can you do a PR for this change @xiehangyun ?
I understand. If there are any new problems after the modification of gizmo, I will ask new questions.