Skip to content

LineSegmentsGeometry: Calling "setPositions" twice does not update the lines correctly #21488

@gkjohnson

Description

@gkjohnson

Describe the bug

Calling LineSegmentsGeometry.setPositions a second time with more line segments still only renders the amount of line segments specified in the first call. Everything works as expected if you call "dispose" before calling "setPositions" again.

I'm not exactly sure why it's happening. Perhaps it's an issue related to instanced geometry rendering?

To Reproduce

Steps to reproduce the behavior:

  1. Create a LineSegments2 object
  2. Call line.geometry.setPositions with 1 line segment
  3. See that it renders 1 line
  4. 1 second later call line.geometry.setPositions with 2 line segments
  5. See that it only renders the first of the two lines

Code

line = new LineSegments2();
line.geometry.setPositions( [ 0, -0.5, 0, 0, 0.5, 0 ] );

setTimeout( () => {

  // uncomment to display both lines
  // line.geometry.dispose();
  line.geometry.setPositions( [
    0, -0.5, 0, -0.5, 0.5, 0,
    0, 0, 0, 0.5, 0, 0,
  ] );

}, 1000 );

Live example

https://jsfiddle.net/rhjeL01n/

Expected behavior

The correct amount of lines are rendered after calling "setPositions".

Screenshots

If applicable, add screenshots to help explain your problem (drag and drop the image).

Platform:

  • Device: Desktop
  • OS: Windows
  • Browser: Chrome
  • Three.js version: latest (r126)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions