* Creates, compiles, and links the shader based on its * sources for the vertex and fragment shaders (provided * to the constructor). Populates known attributes and * uniforms from the shader. * @chainable * @private
()
| 497 | * @private |
| 498 | */ |
| 499 | init() { |
| 500 | // If the shader is uninitialized or context was lost |
| 501 | if (!this._initialized) { |
| 502 | try { |
| 503 | this._renderer._initShader(this); // Backend-specific shader init |
| 504 | } catch (err) { |
| 505 | throw new Error( |
| 506 | `Whoops! Something went wrong initializing the shader:\n${err.message || err}` |
| 507 | ); |
| 508 | } |
| 509 | |
| 510 | if (this.shaderType !== 'compute') { |
| 511 | this._loadAttributes(); |
| 512 | } |
| 513 | this._loadUniforms(); |
| 514 | this._renderer._finalizeShader(this); |
| 515 | |
| 516 | this._initialized = true; |
| 517 | } |
| 518 | |
| 519 | return this; |
| 520 | } |
| 521 | |
| 522 | /** |
| 523 | * @private |
no test coverage detected