コード例 #1
0
        private void RotateAroundTransform(DragData drag)
        {
            // In order to add two quaternion rotations correctly you multiply them.
            // To subtract you need to multiply by the inverse.
            Quaternion rotationDelta = (
                Snap.LocalRotationOfWorldRotation(mesh.transform, drag.transform.rotation) *
                Quaternion.Inverse(Snap.LocalRotationOfWorldRotation(mesh.transform, drag.startTransformRotation))
                );
            Quaternion snappedRotationDelta = Snap.RotationDelta(rotationDelta);

            transform.position = Snap.RotateAroundPivot(mesh.transform, transform.position, drag.transform.position, snappedRotationDelta);
        }