{"record":{"id":"b6ea29ec0b3a8c0d","repo":"stride3d/stride","slug":"there-must-be-three-and-only-three-input-values-for-half3","errorCode":null,"errorMessage":"There must be three and only three input values for Half3.","messagePattern":"There must be three and only three input values for Half3\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/Half3.cs","lineNumber":120,"sourceCode":"    /// <param name=\"value\">The value to set for the X, Y, and Z components.</param>\n    public Half3(Half value)\n    {\n        X = value;\n        Y = value;\n        Z = value;\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Half3\"/> struct.\n    /// </summary>\n    /// <param name=\"values\">The values to assign to the X, Y, and Z components of the vector. This must be an array with three elements.</param>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"values\"/> is <c>null</c>.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when <paramref name=\"values\"/> contains more or less than three elements.</exception>\n    public Half3(Half[] values)\n    {\n        ArgumentNullException.ThrowIfNull(values);\n        if (values.Length != 3)\n            throw new ArgumentOutOfRangeException(nameof(values), \"There must be three and only three input values for Half3.\");\n\n        X = values[0];\n        Y = values[1];\n        Z = values[2];\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Half3\"/> structure.\n    /// </summary>\n    /// <param name=\"x\">The X component.</param>\n    /// <param name=\"y\">The Y component.</param>\n    /// <param name=\"z\">The Z component.</param>\n    public Half3(float x, float y, float z)\n    {\n        X = (Half)x;\n        Y = (Half)y;\n        Z = (Half)z;\n    }","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/Half3.cs#L102-L138","documentation":"Thrown by the Half3(Half[]) constructor when the input array does not contain exactly three elements. Half3 is a fixed-size 3-component vector (X, Y, Z), so it can only be built from exactly three Half values. Thrown as ArgumentOutOfRangeException for the 'values' parameter.","triggerScenarios":"Calling new Half3(Half[]) with an array of length 0, 1, 2, or 4+ — e.g. passing a Half2 array or a Half4 array without slicing.","commonSituations":"Mesh vertex data where positions sometimes carry a W or padding component; packed half-float attribute streams with miscomputed offsets; mixing 2D and 3D attribute data paths.","solutions":["Ensure the array has exactly 3 elements before constructing","Slice the exact three components out of a larger packed buffer","Use Half2 or Half4 for data that genuinely has 2 or 4 components"],"exampleFix":"// before\nvar n = new Half3(halfs); // halfs.Length == 4 -> throws\n// after\nvar n = new Half3(new[] { halfs[0], halfs[1], halfs[2] });","handlingStrategy":"validation","validationCode":"if (values is null) throw new ArgumentNullException(nameof(values));\nif (values.Length != 3) throw new ArgumentException($\"Half3 requires exactly 3 values, got {values.Length}.\", nameof(values));","typeGuard":"static bool IsValidHalf3Source(Half[]? values) => values is { Length: 3 };","tryCatchPattern":"try { var v = new Half3(values); }\ncatch (ArgumentOutOfRangeException ex) when (ex.ParamName == \"values\")\n{\n    // handle malformed attribute data\n    var v = new Half3(Half.Zero, Half.Zero, Half.Zero);\n}","preventionTips":["Validate array length is exactly 3 before constructing","Slice exactly three components out of packed/interleaved buffers","Use Half2/Half4 for data with a different component count"],"tags":["argument-out-of-range","mathematics","vector","half-float","constructor"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}