Float32Array[] works like number[][] for CreateGreasedLine with multiple seperate lines

The title is what it says it. Float32Array[] works like number[][], probably because both are still arrays after all, with usual index stuff and length props.

Why would this be useful? I dont know. Kimi K2.6 Instant High actually suggested this in a response:

For CreateGreasedLine’s points parameter, yes — if you want multiple disconnected lines in one mesh, number[][] or Vector3[][] are the documented formats. There’s no “indexed” mode (single flat buffer + break indices).

But you have alternatives:

  1. Float32Array[] — likely works in place of number[][] and avoids boxed numbers. Much less GC pressure.

  2. instance parameter — build one GreasedLineMesh incrementally:

   const master = CreateGreasedLine("synapses", { points: firstBatch }, { width: 0.02 }, scene);
   CreateGreasedLine(null, { points: secondBatch, instance: master }, { width: 0.02 });

Still needs [][] per batch, but you don’t create new mesh objects.

  1. Raw vertex data — GreasedLineMesh is just a mesh. You can access its vertex buffers via mesh.getVerticesData() / updateVerticesData() and push line segments directly. Bypasses the points API entirely, but you need to understand its internal vertex layout (position + width + color interleaved).

  2. Single continuous line with zero-width segments — pass one flat number[] and set width to 0 for the “jump” segments. Hacky, but avoids [][].

For your scale (potentially millions of synapses), option 2 with pooled Float32Array inner arrays is the pragmatic middle ground. Option 3 is the nuclear option if profiling shows CreateGreasedLine itself is the bottleneck.

What does your new test code layout look like? I can write newSynapseBatch to match whatever fts shape you settle on.

Yeah I would like to have a human reason to do it :wink: we are already under heavy pressure due to AI “helping” :smiley:

What is YOUR take :wink: ?

Ah fair enough. No this is just a niche thing. I’m using it because it increases performance by a bit on a realme Pad 2. You don’t necessarily need to do this, just, if you’re very desperate.

1 Like