How do you preserve original index for reference when using KDtree

I have set of positions in a float32array and set of corresponding colors in a separate array indexed the same way. but when i pass the positions thru the kdtree it reshuffles the position array, causing the positions and the color indexes to no longer match up. So when I go on to lookup the index of the nearest node using the ‘pos’ property, it gives me the index of the shuffled array not the original one that actually matches the colors. The nearestneighbor example seems to successfully reference the correct original blocks (, just instead using an array of alphas instead of color. I can’t figure out what I’m doing different.

I made a fiddle:
what i expect to happen is that the raycastID and the knearestID match up when hovering over a point but they don’t. they only match on the first three points on the bottom left and after that they diverge. This can also be seen in the console where i print out the positions array before passing it to kdtree and after. I understand the positions would need to be reordered as part of building the tree, but I don’t understand whats going on with the ‘pos’ property that the example seems to use to reference the original object successfully. In my fiddle the ‘pos’ corresponds to position in the new shuffled kdtree.
Id also expect to be able to drag the mouse around the outside of the grid and just the edge blocks nearest the pointer change color, but instead its pulling the id’s from the shuffled array so random blocks are changing.
I can’t see what im doing different from the example outside of not using a frustum cull. any ideas?