File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -910,19 +910,25 @@ export class EditorGraph extends Component<IEditorGraphProps, IEditorGraphState>
910910 // Store the current world transform
911911 const worldPosition = node . getAbsolutePosition ( ) ;
912912 const worldRotation = node . rotationQuaternion || node . rotation . toQuaternion ( ) ;
913- const worldScaling = node . absoluteScaling ;
913+ const worldScaling = node . absoluteScaling . clone ( ) ;
914914
915915 // Set the new parent
916916 node . parent = newParent ;
917917
918918 // Restore the world transform
919919 node . setAbsolutePosition ( worldPosition ) ;
920920
921+ // Compute the local rotation based on the parent's rotation
922+ let localRotation = worldRotation ;
923+ if ( newParent instanceof TransformNode ) {
924+ const parentRotation = newParent . absoluteRotationQuaternion ;
925+ localRotation = parentRotation . conjugate ( ) . multiply ( worldRotation ) ;
926+ }
927+
921928 if ( node . rotationQuaternion ) {
922- node . absoluteRotationQuaternion . copyFrom ( worldRotation ) ;
929+ node . rotationQuaternion . copyFrom ( localRotation ) ;
923930 } else {
924- const rotationVector = worldRotation . toEulerAngles ( ) ;
925- node . rotation . copyFrom ( rotationVector ) ;
931+ node . rotation . copyFrom ( localRotation . toEulerAngles ( ) ) ;
926932 }
927933
928934 node . scaling . copyFrom ( worldScaling ) ;
You can’t perform that action at this time.
0 commit comments