internal static Vector3 DoScaleHandle(ScaleHandleIds ids, Vector3 scale, Vector3 position, Quaternion rotation, float handleSize, ScaleHandleParam param)
        {
            // Calculate the camera view vector in Handle draw space
            // this handle the case where the matrix is skewed
            var handlePosition       = matrix.MultiplyPoint3x4(position);
            var drawToWorldMatrix    = matrix * Matrix4x4.TRS(position, rotation, Vector3.one);
            var invDrawToWorldMatrix = drawToWorldMatrix.inverse;
            var viewVectorDrawSpace  = GetCameraViewFrom(handlePosition, invDrawToWorldMatrix);

            var isDisabled = !GUI.enabled;

            var isHot = ids.Has(GUIUtility.hotControl);

            var axisOffset    = param.axisOffset;
            var axisLineScale = param.axisLineScale;

            // When an axis is hot, draw the line from the center to the handle
            // So ignore the offset
            if (isHot)
            {
                axisLineScale += axisOffset;
                axisOffset     = Vector3.zero;
            }

            var isCenterIsHot = ids.xyz == GUIUtility.hotControl;

            switch (Event.current.type)
            {
            case EventType.MouseDown:
                s_InitialScale = scale;
                break;
            }

            for (var i = 0; i < 3; ++i)
            {
                if (!param.ShouldShow(i))
                {
                    continue;
                }

                if (!currentlyDragging)
                {
                    switch (param.orientation)
                    {
                    case ScaleHandleParam.Orientation.Signed:
                        s_DoScaleHandle_AxisHandlesOctant[i] = 1;
                        break;

                    case ScaleHandleParam.Orientation.Camera:
                        s_DoScaleHandle_AxisHandlesOctant[i] = viewVectorDrawSpace[i] > 0.01f ? -1 : 1;
                        break;
                    }
                }


                var id            = ids[i];
                var isThisAxisHot = isHot && id == GUIUtility.hotControl;

                var axisDir    = GetAxisVector(i);
                var axisColor  = GetColorByAxis(i);
                var offset     = axisOffset[i];
                var cameraLerp = id == GUIUtility.hotControl ? 0 : GetCameraViewLerpForWorldAxis(viewVectorDrawSpace, axisDir);
                // If we are here and is hot, then this axis is hot and must be opaque
                cameraLerp = isHot ? 0 : cameraLerp;
                color      = isDisabled ? Color.Lerp(axisColor, staticColor, staticBlend) : axisColor;

                axisDir *= s_DoScaleHandle_AxisHandlesOctant[i];

                if (cameraLerp <= kCameraViewThreshold)
                {
                    color = Color.Lerp(color, Color.clear, cameraLerp);

                    if (isHot && !isThisAxisHot)
                    {
                        color = s_DisabledHandleColor;
                    }
                    if (isCenterIsHot)
                    {
                        color = selectedColor;
                    }

                    color = ToActiveColorSpace(color);

                    scale[i] = UnityEditorInternal.SliderScale.DoAxis(
                        id,
                        scale[i],
                        position,
                        rotation * axisDir,
                        rotation,
                        handleSize * param.axisSize[i],
                        EditorSnapSettings.scale,
                        offset,
                        axisLineScale[i]);
                }
            }

            if (param.ShouldShow(ScaleHandleParam.Handle.XYZ) && (isHot && ids.xyz == GUIUtility.hotControl || !isHot))
            {
                color = ToActiveColorSpace(centerColor);
                EditorGUI.BeginChangeCheck();
                var s = ScaleValueHandle(ids.xyz, scale.x, position, rotation, handleSize * param.xyzSize, CubeHandleCap, EditorSnapSettings.scale);
                if (EditorGUI.EndChangeCheck())
                {
                    scale = s_InitialScale * s;
                }
            }

            return(scale);
        }
 public bool Has(int id)
 {
     return(position.Has(id) ||
            rotation.Has(id) ||
            scale.Has(id));
 }