question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Geometry does not update if Material.wireframe === true

See original GitHub issue

Describe the bug

When updating a geometry’s index buffer using setIndex the new geometry does not update if material.wireframe = true. It updates correctly if wireframe = false.

To Reproduce

  • Create a mesh with a geometry and material with wireframe set to true
  • Render the mesh once
  • Change the geometry’s index buffer using setIndex
  • Render the geometry again
  • Geometry is not updated

Code

geometry = new THREE.PlaneBufferGeometry( 0.2, 0.2, 1, 1 ).toNonIndexed();    
material = new THREE.MeshBasicMaterial( { side: 2, wireframe: true } );

geometry.setIndex( [ 0, 1, 2 ] );
setTimeout( () => {
    
  geometry.setIndex( [ 3, 4, 5 ] );
    
}, 1000 );

Live example

https://jsfiddle.net/fqx1mp3a/

NOTE: Set wireframe to false to see the expected behavior (updated geometry renders).

Expected behavior

The geometry is rendered with the updated index buffer whether or not wireframe is true. Platform:

  • Device: Desktop
  • OS: Windows
  • Browser: Chrome
  • Three.js version: r123

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Mugen87commented, Feb 20, 2022

Closing. As stated above using setIndex() multiple times to update the values of an index is a user error. The only valid approach is to update the existing index. If the range of data varies over time, it’s the responsibility of the application to allocated large enough buffers in the first place and use drawRange to define the effective drawing range of the geomtry.

1reaction
Mugen87commented, Dec 28, 2020

It was planned to introduce BufferAttribute.dispose(). Since VAOs are used, however, it becomes much harder to introduce this feature, see https://github.com/mrdoob/three.js/pull/17063#issuecomment-737993363. So you actually have to work on geometry level.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating Wireframe Geometry - javascript - Stack Overflow
I tried wireframeGeometry but i can't update its vertices. for example; i created this object with a displacement shader, and changing its ...
Read more >
Plane Geometric vertices not updating even after updating
Hello I am new to three.js and I've been trying to do this chunk of code it reads automatically the lines ignore certain...
Read more >
material - A-Frame
If the transparent property is not true , then the material will remain opaque and opacity ... wireframe, Whether to render just the...
Read more >
Wire frames in threejs the basic material and custom canvas ...
The built in wire frame mode will work okay for the most part, but many might not care for the look of it,...
Read more >
Materials - Three.js Journey
Some of these properties like wireframe or opacity can be used with other types of materials. We won't repeat those every time. Want...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found