stride3d/stride · error · ArgumentException

Vector component 'W' is invalid, only 'X', 'Y' and 'Z' are…

Error message

Vector component 'W' is invalid, only 'X', 'Y' and 'Z' are supported.

What it means

Vector3ComponentCurveViewModel edits one component of a Vector3 compute animation curve. Its constructor throws ArgumentException when given VectorComponent.W, since Vector3 has only X, Y and Z channels.

Solutions

  1. Pass only X, Y or Z to this constructor
  2. Make the factory enumerate three components for Vector3 curves
  3. Drop W entries from component lists when the curve type changes
  4. Catch ArgumentException and skip unsupported components

Example fix

// before
new Vector3ComponentCurveViewModel(editor, parent, curve3D, VectorComponent.W);
// after
new Vector3ComponentCurveViewModel(editor, parent, curve3D, VectorComponent.Z);
Defensive patterns

Strategy: validation

Validate before calling

if (component == VectorComponent.W) return null; // invalid for Vector3
var curveVm = new Vector3ComponentCurveViewModel(editor, parent, curve, component);

Type guard

bool IsValidVector3Component(VectorComponent c) => c is VectorComponent.X or VectorComponent.Y or VectorComponent.Z;

Try / catch

try { vm = new Vector3ComponentCurveViewModel(editor, parent, curve, component); }
catch (ArgumentException) { vm = null; }

Prevention

When it happens

Trigger: Constructing new Vector3ComponentCurveViewModel(editor, parent, computeCurve, VectorComponent.W), e.g. from a generic factory iterating all four components for any vector curve.

Common situations: Shared X..W component loops designed for Vector4; asset metadata listing a W channel while the curve is Vector3; templates enumerating all components.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/6127469b9d718d26. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/CurveEditor/ViewModels/VectorComponentCurveViewModel.cs:132

                    value.Y = realPoint.Y;
                    break;

                default:
                    throw new NotSupportedException(); // This should never happen
            }
        }
    }


    /// <summary>
    /// Represents the curve of one component of a <see cref="Vector3"/>.
    /// </summary>
    public sealed class Vector3ComponentCurveViewModel : VectorComponentCurveViewModel<Vector3, Vector3ComponentControlPointViewModel>
    {
        public Vector3ComponentCurveViewModel([NotNull] CurveEditorViewModel editor, CurveViewModelBase parent, [NotNull] ComputeAnimationCurve<Vector3> computeCurve, VectorComponent component)
            : base(editor, parent, computeCurve, component)
        {
            if (component == VectorComponent.W) throw new ArgumentException("Vector component 'W' is invalid, only 'X', 'Y' and 'Z' are supported.", nameof(component));
        }
        
        /// <inheritdoc/>
        protected override void UpdateComponent(ref Vector3 value, Vector2 realPoint)
        {
            // Update the component that is handled by this curve
            switch (Component)
            {
                case VectorComponent.X:
                    value.X = realPoint.Y;
                    break;

                case VectorComponent.Y:
                    value.Y = realPoint.Y;
                    break;

                case VectorComponent.Z:
                    value.Z = realPoint.Y;

View on GitHub (pinned to 96fad776d2)