Răsfoiți Sursa

WebGLObjects: Optimize `InstancedMesh` updates. (#26300)

* WebGLObjects: Optimize `InstancedMesh` updates.

* Skeleton: Clean up.
Michael Herzog 2 ani în urmă
părinte
comite
7b419c9aeb
2 a modificat fișierele cu 15 adăugiri și 8 ștergeri
  1. 0 2
      src/objects/Skeleton.js
  2. 15 6
      src/renderers/webgl/WebGLObjects.js

+ 0 - 2
src/objects/Skeleton.js

@@ -23,8 +23,6 @@ class Skeleton {
 		this.boneTexture = null;
 		this.boneTextureSize = 0;
 
-		this.frame = - 1;
-
 		this.init();
 
 	}

+ 15 - 6
src/renderers/webgl/WebGLObjects.js

@@ -27,11 +27,17 @@ 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 );
 
 			}
 
@@ -39,10 +45,13 @@ function WebGLObjects( gl, geometries, attributes, info ) {
 
 		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 );
 
 			}