Geometry does not update if Material.wireframe === true
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:10 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 usedrawRange
to define the effective drawing range of the geomtry.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.