A lower level function to compile either a vertex or fragment shader.

Code Example

const gl = renderer.getContext(); const glVertexShader = new THREE.WebGLShader( gl, gl.VERTEX_SHADER, vertexSourceCode ); const glFragmentShader = new THREE.WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentSourceCode ); const program = gl.createProgram(); gl.attachShader( program, glVertexShader ); gl.attachShader( program, glFragmentShader ); gl.linkProgram( program );


[page:WebGLShader objects]([page:WebGLContext gl], [page:WebGLEnum type], [page:String source])

gl -- The current WebGL context type -- The WebGL type, either gl.VERTEX_SHADER or gl.FRAGMENT_SHADER source -- The source code for the shader

This will compile an individual shader, but won't link it to be a complete [page:WebGLProgram]. Note: this is a function so the new operator should not be used.


[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]