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

A Vector3 has only X, Y and Z components. The Vector3ComponentControlPointViewModel constructor rejects VectorComponent.W with ArgumentException, since there is no fourth component to bind on a Vector3 keyframe.

Solutions

  1. Pass only X, Y or Z to this constructor
  2. Make the factory enumerate 3 components for Vector3 curves
  3. Trim W entries from component lists when curves change dimension
  4. Catch ArgumentException to skip invalid components gracefully

Example fix

// before
new Vector3ComponentControlPointViewModel(curve, key, value, tangent, VectorComponent.W);
// after
new Vector3ComponentControlPointViewModel(curve, key, value, tangent, VectorComponent.Z);
Defensive patterns

Strategy: validation

Validate before calling

if (component == VectorComponent.W) return null; // invalid for Vector3
var vm = new Vector3ComponentControlPointViewModel(curve, key, value, tangent, component);

Type guard

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

Try / catch

try { vm = new Vector3ComponentControlPointViewModel(curve, key, value, tangent, component); }
catch (ArgumentException) { vm = null; }

Prevention

When it happens

Trigger: Constructing new Vector3ComponentControlPointViewModel(curve, keyNode, valueNode, tangentTypeNode, VectorComponent.W) — e.g. a generic factory iterating all four components for any vector curve.

Common situations: Shared component loops written for Vector4 reused for Vector3; asset channels that include W while the curve was converted to Vector3; editor templates listing 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/abbe8eccae042fff. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/CurveEditor/ViewModels/ControlPoints/VectorComponentControlPointViewModel.cs:80

                    ValueBinding.Value = new Vector2(current.X, (float)value);
                    break;

                case VectorComponent.Z:
                case VectorComponent.W:
                    throw new NotSupportedException();

                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
    }

    public sealed class Vector3ComponentControlPointViewModel : VectorComponentControlPointViewModel<Vector3>
    {
        public Vector3ComponentControlPointViewModel([NotNull] CurveViewModelBase curve, [NotNull] IMemberNode keyNode, [NotNull] IMemberNode valueNode, [NotNull] IMemberNode tangentTypeNode, VectorComponent component)
            : base(curve, keyNode, valueNode, tangentTypeNode, component)
        {
            if (component == VectorComponent.W) throw new ArgumentException("Vector component 'W' is invalid, only 'X', 'Y' and 'Z' are supported.", nameof(component));
        }
        
        protected override double GetValue()
        {
            switch (Component)
            {
                case VectorComponent.X:
                    return ValueBinding.Value.X;

                case VectorComponent.Y:
                    return ValueBinding.Value.Y;

                case VectorComponent.Z:
                    return ValueBinding.Value.Z;

                case VectorComponent.W:
                    throw new NotSupportedException();

View on GitHub (pinned to 96fad776d2)