I need to pass in an array of vectors as a uniform to my shader.
According to an answer on a related SO question says that the syntax is to do something like
const myUniform = [
new THREE.Vector3(1.0, 0.0, 0.0),
new THREE.Vector3(0.0, 1.0, 0.0),
];
const uniforms: {
"myUniform": { type: "v3v", value: myUniform },
};
const material = new THREE.ShaderMaterial({
uniforms: uniforms,
});
However, when I tried this, I got an error like below:
I played around a bit to find out what’s up, and noticed that the error actually goes away when I do the following:
const myUniform = [
new THREE.Vector3(1.0, 0.0, 0.0),
new THREE.Vector3(0.0, 1.0, 0.0),
];
const uniforms: {
"myUniform": myUniform, // assign the array of vectors directly??
};
I assigned the array of vectors directly as my uniform’s value.
Although this made the error disappear, I could not find any info on whether this is the correct syntax to use for passing in array of things as uniforms to the shaders.
Why did I get the error above when i tried the first syntax, but not with the second syntax?
Also, what is the correct way of passing in array of things as uniforms?