Capítulo 851 de 859
Rules for matching a ShaderMaterial/RawShaderMaterial uniform's JavaScript value to its GLSL type, including how to represent arrays of primitives and structured (struct-shaped) uniforms so three.js can process them correctly.
value: and that value's type/shape must correspond to the GLSL variable's declared type.vec2[5]) must be supplied as either an array of the matching THREE object (five Vector2s) or as one flat array of numbers (ten numbers) — not an array of arrays for that innermost primitive dimension.vec2[5] arrays is legitimately an array of arrays, each containing five Vector2s (or ten flat numbers).struct in JS, uniform data must be organized as plain objects with matching field names, so three.js can walk and upload the structure correctly.const entry1 = { position: new THREE.Vector3(), direction: new THREE.Vector3(0, 0, 1) };
const entry2 = { position: new THREE.Vector3(1, 1, 1), direction: new THREE.Vector3(0, 1, 0) };
const uniforms = {
data: { value: [entry1, entry2] },
};
value type must exactly match its GLSL declaration's type/shape.uniforms option this chapter's rules apply to.