The length of positions of LineSegmentsGeometry is fixed to 24?

Hello everyone! I’m trying to initialize a fat line with LineSegments2 with specific array length for later use, so the array is filled with 0, here’re how I did it:

import { LineSegmentsGeometry } from "three/examples/jsm/lines/LineSegmentsGeometry";
import { LineSegments2 } from "three/examples/jsm/lines/LineSegments2";
import { LineMaterial } from "three/examples/jsm/lines/LineMaterial";

  const points = new Float32Array(4096);

  const material = new LineMaterial({
    color: 0xffb24f,
    linewidth: 0.002,
    transparent: true,
    opacity: 1,
    depthWrite: false
  });
  const geometry = new LineSegmentsGeometry().setPositions(points);

  const line = new LineSegments2(geometry, material);

And if I try to access it after it’s created:

geometry.attributes.position.array.length

It will be 24 no wonder how long the original array is, what happened? Maybe I did something wrong?

Demo here:


BTW, I found this line of code in the repo. Does this means I can’t update the length of LineSegmentsGeometry?

LineSegmentsGeometry is derived from InstancedBufferGeometry. Meaning the same line mesh is rendered over and over again with small deviations. These are configured when you use the methods setPositions() or setColors(). If you look closely to the method’s implementations, you will see that the given data are configured as instanced data used for instanced rendering.

1 Like

Oh! I got it! Thank you!