2
votes

Experimenting again with Three.js and buffer geometry. I thought I had things set up properly when I was drawing 1000 lines. Turns out, something is wrong and I'm only drawing half of them.

http://jsfiddle.net/EVYJv/

I should see 10 lines drawn but I only see 5.

I suspect it's the buffer_geometry.attributes set up - that looks wrong - but any change I make to that which seems sensible (e.g. itemSize: 6) causes a flood of OpenGL errors in the console.

What am I doing wrong?

1

1 Answers

1
votes

What law of nature is it that means you struggle for hours with an issue then find the answer yourself as soon as you post it here...

Working version: http://jsfiddle.net/EVYJv/1/

The answer was to set up buffer_geometry.attributes with itemSize: 3, array: new Float32Array(lines * 6) and numItems: lines * 6.

That doesn't entirely make sense - I thought an 'item' was a line with start and end positions but maybe that's a vertex.

Edit: WestLangly pointed out that you no longer need to specify numItems - working version with that change here: http://jsfiddle.net/EVYJv/3/