How do I pass an array of vec3 data to a vertex shader using ThreeJS?
air_parcel_pos: {
type: "???",
value: the array of data
}
The initialization value has to be an array of values which correspond to the GLSL data type.
e.g.
If the uniform variable is an array of vec3
uniform vec3 u_array[3];
then the initialization value can be an array of THREE.Vector3
var uniforms = {
u_array: {value: [
new THREE.Vector3(1, 0, 0),
new THREE.Vector3(0, 1, 0),
new THREE.Vector3(0, 0, 1)
] }
};
var material = new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: // ...
fragmentShader: // ...
});
Further data types are Vector2, Vector4 or Color. An array of float or int can be set by an array of values.
.typeis not used. three.js r.103.