I have made the following material shader below but I constantly get the following error and cannot figure out why this is happening:
Uncaught TypeError: Cannot read property 'toArray' of undefined
at Rb (three-r94.min.js:42)
at Te.jg [as setValue] (three-r94.min.js:48)
at Function.eb.upload (three-r94.min.js:614)
at n (three-r94.min.js:173)
at m (three-r94.min.js:162)
at l (three-r94.min.js:161)
at ae.render (three-r94.min.js:196)
Here is the shader:
'multicolor' : {
uniforms: {
"colChoice":{type: "v3v", value:[new THREE.Color( 0xef5350 ), // pink
new THREE.Color( 0xffffff ), // white
]},
"allPos":{type: "v3v",value:[new THREE.Vector3(0., 0., 0.),
new THREE.Vector3(0., 0., 0.),
]}, // filled with 450 vals from main js
"numBlobs":{type: "i",value: 2 },
//
"bStrength":{type: "f",value: 0.61 },
"bSubstract":{type: "f",value: 25. },
"bDistance":{type: "f",value: 0.12 },
},
//______________________________________________________________________________________________
vertexShader: [
"uniform vec3 colChoice[450];",
"varying vec3 vNormal;",
"uniform float bStrength;",
"uniform float bSubstract;",
"uniform float bDistance;",
"varying float mixScale;",
"varying vec3 blobColor;",
"varying vec3 otherColor;",
"uniform vec3 allPos[450];",
"uniform int numBlobs;",
"float rand(vec2 n){",
"return 0.5 + 0.5 * fract(sin(dot(n.xy, vec2(12.9898, 78.233)))* 43758.5453);",
"}",
"void main() {",
"vec4 worldPosition = modelMatrix * vec4( position, 1.0 );",
"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
"vec3 worldNormal = normalize ( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );",
"vNormal = normalize( normalMatrix * normal );",
"gl_Position = projectionMatrix * mvPosition;",
"vec3 otherColor = colChoice[0];",
"float distMin = 100000000000000000000000000000000000000.;",
"float secondDistMin = 100000000000000000000000000000000000000.;",
"float distV = 0.;",
"for (int i=0;i<450;i++){",
"if (i<numBlobs){",
"distV = distance(allPos[i]/1200., position);",
"if (distV<distMin){",
"secondDistMin = distMin;",
"distMin=distV;",
"otherColor = blobColor;",
"blobColor = colChoice[i];",
"}",
"}",
"else{",
"break;",
"}",
"}",
"float mixScale = smoothstep(0.12,secondDistMin*1.12,distMin);",
"blobColor = mix(blobColor,otherColor,mixScale);",
"}",
].join( "\n" ),
//______________________________________________________________________________________________
fragmentShader: [
"varying vec3 blobColor;",
"varying vec3 otherColor;",
"varying vec3 vNormal;",
"varying float mixScale;",
"void main() {",
"vec3 finalColor = (vNormal*0.35)+ mix(blobColor,otherColor,mixScale);",
"gl_FragColor = vec4(finalColor,1.0);",
"}",
].join( "\n" )
}