Browse Source

Examples: Avoid NaN values in data textures in webgl_gpgpu_birds_gltf.

Mugen87 5 years ago
parent
commit
b901758a00
1 changed files with 17 additions and 4 deletions
  1. 17 4
      examples/webgl_gpgpu_birds_gltf.html

+ 17 - 4
examples/webgl_gpgpu_birds_gltf.html

@@ -261,13 +261,26 @@
 
 
 						if ( j < durationAnimation ) {
 						if ( j < durationAnimation ) {
 
 
-							tData[ offset + i * 3 ] = Math.lerp( morphAttributes[ curMorph ].array[ i * 3 ], morphAttributes[ nextMorph ].array[ i * 3 ], lerpAmount );
-							tData[ offset + i * 3 + 1 ] = Math.lerp( morphAttributes[ curMorph ].array[ i * 3 + 1 ], morphAttributes[ nextMorph ].array[ i * 3 + 1 ], lerpAmount );
-							tData[ offset + i * 3 + 2 ] = Math.lerp( morphAttributes[ curMorph ].array[ i * 3 + 2 ], morphAttributes[ nextMorph ].array[ i * 3 + 2 ], lerpAmount );
+							var d0, d1;
+
+							d0 = morphAttributes[ curMorph ].array[ i * 3 ];
+							d1 = morphAttributes[ nextMorph ].array[ i * 3 ];
+
+							if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 3 ] = Math.lerp( d0, d1, lerpAmount );
+
+							d0 = morphAttributes[ curMorph ].array[ i * 3 + 1 ];
+							d1 = morphAttributes[ nextMorph ].array[ i * 3 + 1 ];
+
+							if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 3 + 1 ] = Math.lerp( d0, d1, lerpAmount );
+
+							d0 = morphAttributes[ curMorph ].array[ i * 3 + 2 ];
+							d1 = morphAttributes[ nextMorph ].array[ i * 3 + 2 ];
+
+							if ( d0 !== undefined && d1 !== undefined ) tData[ offset + i * 3 + 2 ] = Math.lerp( d0, d1, lerpAmount );
 
 
 						}
 						}
 
 
-		}
+					}
 
 
 				}
 				}