Skip to content

Conversation

@Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Apr 2, 2020

Fixed https://discourse.threejs.org/t/reusing-instancedmesh-geometry-and-material/14008/.

When two or more InstancedMesh share the same geometry, it's still necessary to refresh the vertex attributes via setupVertexAttributes(). That is necessary since the vertex data not only depend on the used geometry and material but also on the 3D object (instanceMatrix).

Hence, it's safe to always call setupVertexAttributes() when an InstancedMesh is going to be rendered otherwise instanceMatrix might have a wrong buffer binding.

@mrdoob
Copy link
Owner

mrdoob commented Apr 2, 2020

Wouldn't this update things unneededly when rendering a single InstacedMesh?

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Apr 2, 2020

This happens anyway since all _currentGeometryProgram properties are cleared after a render call. Meaning updateBuffers is definitely set to true even in scenes like webgl_instancing_dynamic.

@mrdoob mrdoob added this to the r116 milestone Apr 24, 2020
@mrdoob mrdoob merged commit 49668a3 into mrdoob:dev Apr 24, 2020
@mrdoob
Copy link
Owner

mrdoob commented Apr 24, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants