greggman / twgl.js

A Tiny WebGL helper Library
http://twgljs.org
MIT License
2.61k stars 258 forks source link

Documentation mistake in createBufferInfoFromArrays() #150

Closed iar5 closed 4 years ago

iar5 commented 4 years ago

In

(static) createBufferInfoFromArrays(gl, arrays, srcBufferInfoopt) → {module:twgl.BufferInfo}

is written that

var arrays = { position: { numComponents: 3, data: [0, 0, 0, 10, 0, 0, 0, 10, 0, 10, 10, 0], }, texcoord: { numComponents: 2, data: [0, 0, 0, 1, 1, 0, 1, 1], }, normal: { numComponents: 3, data: [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], }, indices: { numComponents: 3, data: [0, 1, 2, 1, 2, 3], }, }; Creates an BufferInfo like this bufferInfo = { numElements: 4, // or whatever the number of elements is indices: WebGLBuffer, // this property will not exist if there are no indices attribs: { a_position: { buffer: WebGLBuffer, numComponents: 3, }, a_normal: { buffer: WebGLBuffer, numComponents: 3, }, a_texcoord: { buffer: WebGLBuffer, numComponents: 2, }, }, };

Look at the attribute names. They should'nt change by default. Their names only change when twgl.setAttributePrefix("a_") is set, right?

greggman commented 4 years ago

https://github.com/greggman/twgl.js/commit/9d0911f788e5d0af32af5886ef771ea660f24d00