更新时间:2023-02-02 17:46:00
此代码
gl.vertexAttribPointer(this.program.vertexPosAttrib, this.itemSize, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(this.program.vertexPosAttrib);
绘制每个网格时需要调用,而不是现在调用它。此外,在为 this.program.vertexPosAttrib
调用 gl.vertexAttribPointer
之前,您需要致电
Need to be called when drawing each mesh and not where it's called now. Additionally before calling gl.vertexAttribPointer
for this.program.vertexPosAttrib
you need to call
gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffers.vertexPosition);
因为 gl.vertexAttribPointer
当前绑定缓冲区绑定到 gl.ARRAY_BUFFER
到指定的属性。
Because gl.vertexAttribPointer
binds the buffer currently bound to gl.ARRAY_BUFFER
to the specified attribute.
换句话说
gl.bindBuffer(gl.ARRAY_BUFFER, mesh.buffers.vertexPosition);
gl.vertexAttribPointer(mesh.program.vertexPosAttrib, mesh.itemSize, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(mesh.program.vertexPosAttrib);