|
@@ -102,7 +102,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
|
|
|
const uniform = uniformArray[ j ];
|
|
const uniform = uniformArray[ j ];
|
|
|
|
|
|
- if ( hasUniformChanged( uniform, i, cache ) === true ) {
|
|
|
|
|
|
+ if ( hasUniformChanged( uniform, i, j, cache ) === true ) {
|
|
|
|
|
|
const offset = uniform.__offset;
|
|
const offset = uniform.__offset;
|
|
|
|
|
|
@@ -110,9 +110,9 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
|
|
|
let arrayOffset = 0;
|
|
let arrayOffset = 0;
|
|
|
|
|
|
- for ( let i = 0; i < values.length; i ++ ) {
|
|
|
|
|
|
+ for ( let k = 0; k < values.length; k ++ ) {
|
|
|
|
|
|
- const value = values[ i ];
|
|
|
|
|
|
+ const value = values[ k ];
|
|
|
|
|
|
const info = getUniformSize( value );
|
|
const info = getUniformSize( value );
|
|
|
|
|
|
@@ -161,31 +161,22 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- function hasUniformChanged( uniform, index, cache ) {
|
|
|
|
|
|
+ function hasUniformChanged( uniform, index, indexArray, cache ) {
|
|
|
|
|
|
const value = uniform.value;
|
|
const value = uniform.value;
|
|
|
|
+ const indexString = index + '_' + indexArray;
|
|
|
|
|
|
- if ( cache[ index ] === undefined ) {
|
|
|
|
|
|
+ if ( cache[ indexString ] === undefined ) {
|
|
|
|
|
|
// cache entry does not exist so far
|
|
// cache entry does not exist so far
|
|
|
|
|
|
if ( typeof value === 'number' || typeof value === 'boolean' ) {
|
|
if ( typeof value === 'number' || typeof value === 'boolean' ) {
|
|
|
|
|
|
- cache[ index ] = value;
|
|
|
|
|
|
+ cache[ indexString ] = value;
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- const values = Array.isArray( value ) ? value : [ value ];
|
|
|
|
-
|
|
|
|
- const tempValues = [];
|
|
|
|
-
|
|
|
|
- for ( let i = 0; i < values.length; i ++ ) {
|
|
|
|
-
|
|
|
|
- tempValues.push( values[ i ].clone() );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- cache[ index ] = tempValues;
|
|
|
|
|
|
+ cache[ indexString ] = value.clone();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -193,41 +184,25 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
|
|
+ const cachedObject = cache[ indexString ];
|
|
|
|
+
|
|
// compare current value with cached entry
|
|
// compare current value with cached entry
|
|
|
|
|
|
if ( typeof value === 'number' || typeof value === 'boolean' ) {
|
|
if ( typeof value === 'number' || typeof value === 'boolean' ) {
|
|
|
|
|
|
- if ( cache[ index ] !== value ) {
|
|
|
|
|
|
+ if ( cachedObject !== value ) {
|
|
|
|
|
|
- cache[ index ] = value;
|
|
|
|
|
|
+ cache[ indexString ] = value;
|
|
return true;
|
|
return true;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- const cachedObjects = Array.isArray( cache[ index ] ) ? cache[ index ] : [ cache[ index ] ];
|
|
|
|
- const values = Array.isArray( value ) ? value : [ value ];
|
|
|
|
-
|
|
|
|
- for ( let i = 0; i < cachedObjects.length; i ++ ) {
|
|
|
|
-
|
|
|
|
- const cachedObject = cachedObjects[ i ];
|
|
|
|
|
|
+ if ( cachedObject.equals( value ) === false ) {
|
|
|
|
|
|
- if ( typeof cachedObject === 'number' || typeof cachedObject === 'boolean' ) {
|
|
|
|
-
|
|
|
|
- if ( cachedObject !== values[ i ] ) {
|
|
|
|
-
|
|
|
|
- cachedObjects[ i ] = values[ i ];
|
|
|
|
- return true;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- } else if ( cachedObject.equals( values[ i ] ) === false ) {
|
|
|
|
-
|
|
|
|
- cachedObject.copy( values[ i ] );
|
|
|
|
- return true;
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ cachedObject.copy( value );
|
|
|
|
+ return true;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|