drei icon indicating copy to clipboard operation
drei copied to clipboard

Points component's sizes prop doesn't seem to do anything with sizes array

Open sdl60660 opened this issue 3 years ago • 0 comments

  • three version: 0.137.5
  • @react-three/fiber version: 7.0.26
  • @react-three/drei version: 8.8.3
  • node version: 16.13.2
  • npm (or yarn) version: 8.1.2

Problem description:

Hi, no matter what I do, I can't seem to get the Points component to accept Float32Array of sizes for points. I'm not sure if this is a bug or if I'm just ingesting the array incorrectly, but I've been digging for a while trying to find documentation/examples of how to do it correctly, and can't find anything that seems like a clear issue here. I've dug through the source code on here too and can't find any reason that it wouldn't be taking in the sizes, except that maybe there's something incorrect in my pointsMaterial setup? Any help/direction is appreciated if this is not a bug, but sort of out of places to look at this point and suspect it's possible there's an issue?

Relevant code:

const positionsArray = new Float32Array(allSats.map((d) => d.startPosition).flat());
  const colorArray = new Float32Array(allSats.map((d) => d.color).flat());
  // This maps to a one-dimensional array of floats
  const sizesArray = new Float32Array(allSats.map((d) => d.size));

  return (
    <group visible={visible}>
      <Points
        ref={pointsRef}
        // geometry={geometry}
        positions={positionsArray}
        colors={colorArray}
        sizes={sizesArray}
        limit={allSats.length} // Optional: max amount of items (for calculating buffer size)
        range={allSats.length} // Optional: draw-range
      >
        <pointsMaterial vertexColors sizeAttenuation={false} />
      </Points>
    </group>
  );

Suggested solution:

sdl60660 avatar May 17 '22 16:05 sdl60660