Spaces:
Running
Running
File size: 931 Bytes
6cd9596 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
/**
* Uniform Utilities
*/
export function cloneUniforms( src ) {
var dst = {};
for ( var u in src ) {
dst[ u ] = {};
for ( var p in src[ u ] ) {
var property = src[ u ][ p ];
if ( property && ( property.isColor ||
property.isMatrix3 || property.isMatrix4 ||
property.isVector2 || property.isVector3 || property.isVector4 ||
property.isTexture ) ) {
dst[ u ][ p ] = property.clone();
} else if ( Array.isArray( property ) ) {
dst[ u ][ p ] = property.slice();
} else {
dst[ u ][ p ] = property;
}
}
}
return dst;
}
export function mergeUniforms( uniforms ) {
var merged = {};
for ( var u = 0; u < uniforms.length; u ++ ) {
var tmp = cloneUniforms( uniforms[ u ] );
for ( var p in tmp ) {
merged[ p ] = tmp[ p ];
}
}
return merged;
}
// Legacy
var UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };
export { UniformsUtils };
|