@@ -764,8 +764,26 @@ export class BoundingBoxGizmo extends Gizmo implements IBoundingBoxGizmo {
764
764
765
765
return this . _cornerMesh . clone ( ) ;
766
766
}
767
+
768
+ /**
769
+ * returns true if the combination of non uniform scaling and rotation of the attached mesh is not supported
770
+ * In that case, the matrix is skewed and the bounding box gizmo will not work correctly
771
+ * @returns True if the combination is not supported, otherwise false.
772
+ */
773
+ protected _hasInvalidNonUniformScaling ( ) {
774
+ return (
775
+ this . _attachedMesh ?. parent instanceof TransformNode &&
776
+ this . _attachedMesh ?. parent . absoluteScaling . isNonUniformWithinEpsilon ( 0.001 ) &&
777
+ ( ( this . _attachedMesh ?. rotationQuaternion && ! this . _attachedMesh ?. rotationQuaternion . equalsWithEpsilon ( Quaternion . Identity ( ) , Epsilon ) ) ||
778
+ this . _attachedMesh ?. rotation . equalsWithEpsilon ( Vector3 . Zero ( ) , Epsilon ) === false )
779
+ ) ;
780
+ }
767
781
protected override _attachedNodeChanged ( value : Nullable < AbstractMesh > ) {
768
782
if ( value ) {
783
+ if ( this . _hasInvalidNonUniformScaling ( ) ) {
784
+ Logger . Warn ( "BoundingBoxGizmo controls are not supported on meshes with non-uniform scaling and rotation" ) ;
785
+ return ;
786
+ }
769
787
// Reset anchor mesh to match attached mesh's scale
770
788
// This is needed to avoid invalid box/anchor position on first drag
771
789
this . _anchorMesh . scaling . setAll ( 1 ) ;
@@ -814,7 +832,7 @@ export class BoundingBoxGizmo extends Gizmo implements IBoundingBoxGizmo {
814
832
* Updates the bounding box information for the Gizmo
815
833
*/
816
834
public updateBoundingBox ( ) {
817
- if ( this . attachedMesh ) {
835
+ if ( this . attachedMesh && ! this . _hasInvalidNonUniformScaling ( ) ) {
818
836
PivotTools . _RemoveAndStorePivotPoint ( this . attachedMesh ) ;
819
837
820
838
// Store original parent
0 commit comments