How three.js pass color attribute to shader

I’m beginner in webgl, and recently I’ve been learning how to pass color attribute to shaders, and I’m thinking about how three.js dose it.

Here are two ways I can guess:

  1. pass color attribute by use gl.vertexAttribPointer, but first need an array which contains color information to bind

  2. pass color attribute by use gl.vertexAttrib3f , only one set of data needs to be passed in.

And I also found some code in threejs, but it’s hard to figure out: