0

if I generate Tubes in a loop like here

http://jsfiddle.net/crizzis/RYQty/1/

    for (var y = 0; y < 800; y++){...}

The loop is starting to hang and will not finish, despite the main memory seems ok (Task Manager) and the GPU Memory seems to be fine as well.

It hangs in the loop where the tube geometry is generated. It is not even rendered.

Does anyone know how this can happen?

Strange thing is 700 loops are Performing within 5 seconds, 800 loops not at all or really, really slow.

user1786641
  • 101
  • 13

1 Answers1

0

Well, i just looked at your fiddle and i am not sure about your whole loop. You are creating WAY too much stuff inside your loop. See for example the material. Just create it once outside the loop. Then move the vector[0] and [1] definitions outside of the loop and inside the loop do vector[0].y = . So you don't create 2 Three.Vector3()-objects for every run. Also, move all variable declarations outside your loop. Just something like var line; and inside, you do line = SPline... Next, why don't you just create the whole Spline inside the loop and then AFTER the loop, create ONE TubeGeometry afterwards instead of creating hundreds of meshes? Well, I don't know your usecase anyway.

GuyGood
  • 1,377
  • 1
  • 9
  • 12
  • thanky you for your answer. Main problem is that I cannot notice any memory Problem, and so I do not understand why the loop hangs. I tried experimenting setting the material outside the loop, did not help. I need several thousand of tubes rendered in different colors and with different Spline Vertexes. – user1786641 Aug 23 '13 at 07:06
  • Is there any 64k Limit on Javascript Objects? – user1786641 Aug 27 '13 at 07:35
  • well, yes. An index buffer for geometry can only adress 65k vertices. I Think there is also a bufferGeometry Particle example which shows how to use multiple blocks of 65k vertices with BufferGeometry. Also there is an extension for higher limits...see here: http://stackoverflow.com/questions/4998278/is-there-a-limit-of-vertices-in-webgl – GuyGood Aug 27 '13 at 09:52
  • how can i determin if the buffer is full? – user1786641 Aug 27 '13 at 12:05
  • strange is if there is a 64k limit somewhere hidden behind framework functions, why does google chrome hang on 800 drawn Splines while Firfox can draw more. – user1786641 Aug 27 '13 at 12:54