Why does color keep changing when i assign a color to a buffer geometry point cloud?

Viewed 23

I am trying to assign a standardised color on each point on a 3d point cloud on load and the point cloud is represented with a Buffer Geometry using Three.js. The buffer geometry does not have an initial color attribute attached to it at load.

The issue I'm facing is that every time I reload the point cloud, the color of the point cloud changes even though the color is supposed to be hardcoded in. Even the rgb values in the color attribute array remained the same in the separate loads as seen in the following image.

screenshot of color readings

Thus, I am wondering where the additional shade of color came from that causes my buffer geometry to appear differently from the way I coded it. Thank you for your help.

The following is the code I used to assign the color to the points on the point cloud:

if (!points.geometry.attributes.color) {
    // set a default color attribute
    const colorsArr = []
    for (let i = 0, n = points.geometry.attributes.position.count; i < n; i++) {
      colorsArr.push(0.69, 0.78, 1)
    }
    points.geometry.setAttribute(
      'color',
      new THREE.Float32BufferAttribute(colorsArr, 3, false)
    )
  }
  points.geometry.attributes.color.needsUpdate = true
0 Answers
Related