title: How to pass an array of objects as uniforms to custom shader in Three.js
body: <p>I would like to pass an array of Javascript objects to my custom shader written with <code>THREE.RawShaderMaterial</code> but still haven't been able to figure out how to achieve this.</p>
  
  <p>Specifically, I would like to manually perform the same thing as <code>THREE.PointLightSource</code>. I am currently achieving this by using Three.js's functionality:</p>
  
  <pre><code>var matrixUniforms = {
  
      projectionMat: { value: new THREE.Matrix4() },
  
      modelViewMat: { value: new THREE.Matrix4() },
  
      normalMat: { value: new THREE.Matrix3() },
  
  };
  
  var material = new THREE.RawShaderMaterial( {
  
      uniforms: THREE.UniformsUtils.merge( [
  
          matrixUniforms,
  
          THREE.UniformsLib[ "lights" ],
  
      ] ),
  
      vertexShader: $( "#" + vShader ).text(),
  
      fragmentShader: $( "#" + fShader ).text(),
  
      lights: true,
  
  } );
  </code></pre>
  
  <p>Let's say I have</p>
  
  <pre><code>var pointLights = [ 
                     { position: new THREE.Vector3(0,0,0),
  
                       color: new THREE.Vector3(1,1,1) },
  
                     { position: new THREE.Vector3(10,10,10),
  
                       color: new THREE.Vector3(2,2,2) }
                    ];
  </code></pre>
  
  <p>How can I add it to uniforms of <code>THREE.RawShaderMaterial</code>? Is there any easy way to pass an array of objects that has the same properties? I may have found its solution for the older version of Three.js but couldn't find a way to do it with the latest version (r84).</p>
  
  <p>EDIT:
  I found <a href="https://github.com/mrdoob/three.js/issues/10759" rel="nofollow noreferrer">this thread</a> and <a href="https://github.com/mrdoob/three.js/issues/2720" rel="nofollow noreferrer">this thread</a>. However, it seems that it is not documented anywhere...</p>