Skip to content

Commit

Permalink
WebGLObjects: Optimize InstancedMesh updates. (#26300)
Browse files Browse the repository at this point in the history
* WebGLObjects: Optimize `InstancedMesh` updates.

* Skeleton: Clean up.
  • Loading branch information
Mugen87 authored Jun 20, 2023
1 parent 356d648 commit 7b419c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/objects/Skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class Skeleton {
this.boneTexture = null;
this.boneTextureSize = 0;

this.frame = - 1;

this.init();

}
Expand Down
21 changes: 15 additions & 6 deletions src/renderers/webgl/WebGLObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,31 @@ function WebGLObjects( gl, geometries, attributes, info ) {

}

attributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );
if ( updateMap.get( object ) !== frame ) {

if ( object.instanceColor !== null ) {
attributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );

attributes.update( object.instanceColor, gl.ARRAY_BUFFER );
if ( object.instanceColor !== null ) {

attributes.update( object.instanceColor, gl.ARRAY_BUFFER );

}

updateMap.set( object, frame );

}

}

if ( object.isSkinnedMesh ) {

if ( object.skeleton.frame !== info.render.frame ) {
const skeleton = object.skeleton;

if ( updateMap.get( skeleton ) !== frame ) {

skeleton.update();

object.skeleton.update();
object.skeleton.frame = info.render.frame;
updateMap.set( skeleton, frame );

}

Expand Down

0 comments on commit 7b419c9

Please sign in to comment.