zMatrix()
With this type, you can visually edit a matrix in the Props Editor.
The matrix has to be "flat", for example a 2x2 matrix has to be represented as an array of 4 numbers: [0, 1, 1, 0].
The matrix has to be a square matrix, for example a 2x2, 3x3, 4x4, etc.
const myCompSchema = z.object({
matrix: zMatrix(),
});
// Two-dimensional matrix
myCompSchema.parse({
matrix: [0, 1, 1, 0],
});
// Three-dimensional matrix
myCompSchema.parse({
matrix: [1, 0, 0, 0, 1, 0, 0, 0, 1],
});
// Four-dimensional matrix
myCompSchema.parse({
matrix: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
});