File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515
1616 function getDimensions ( x , pad ) {
1717 var ret ;
18- if ( Array . isArray ( x ) ) {
18+ if ( GPUUtils . isArray ( x ) ) {
1919 var dim = [ ] ;
2020 var temp = x ;
21- while ( Array . isArray ( temp ) ) {
21+ while ( GPUUtils . isArray ( temp ) ) {
2222 dim . push ( temp . length ) ;
2323 temp = temp [ 0 ] ;
2424 }
5757 return ret ;
5858 }
5959
60- function flatten ( arr , padding ) {
61- if ( Array . isArray ( arr [ 0 ] ) ) {
62- if ( Array . isArray ( arr [ 0 ] [ 0 ] ) ) {
60+ function flatten ( arr ) {
61+ if ( GPUUtils . isArray ( arr [ 0 ] ) ) {
62+ if ( GPUUtils . isArray ( arr [ 0 ] [ 0 ] ) ) {
6363 return [ ] . concat . apply ( [ ] , [ ] . concat . apply ( [ ] , arr ) ) ;
6464 } else {
6565 return [ ] . concat . apply ( [ ] , arr ) ;
6666 }
6767 } else {
68- return GPUUtils . clone ( arr ) ;
68+ return arr ;
6969 }
7070 }
7171
509509 gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MIN_FILTER , gl . NEAREST ) ;
510510 gl . texParameteri ( gl . TEXTURE_2D , gl . TEXTURE_MAG_FILTER , gl . NEAREST ) ;
511511
512- var paramArray = flatten ( arguments [ textureCount ] ) ;
513512 var paramLength = paramSize [ 0 ] * paramSize [ 1 ] ;
514513 if ( opt . floatTextures ) {
515514 paramLength *= 4 ;
516515 }
517- while ( paramArray . length < paramLength ) {
518- paramArray . push ( 0 ) ;
519- }
516+
517+ var paramArray = new Float32Array ( paramLength ) ;
518+ paramArray . set ( flatten ( arguments [ textureCount ] ) )
520519
521520 var argBuffer ;
522521 if ( opt . floatTextures ) {
Original file line number Diff line number Diff line change @@ -210,6 +210,23 @@ var GPUUtils = (function() {
210210 }
211211 GPUUtils . functionBinder = functionBinder ;
212212
213+ ///
214+ /// Function: isArray
215+ ///
216+ /// Checks if is an array or Array-like object
217+ ///
218+ /// Parameters:
219+ /// arg - {Object} The argument object to check if is array
220+ ///
221+ /// Returns:
222+ /// {Boolean} true if is array or Array-like object
223+ ///
224+ function isArray ( arr ) {
225+ var tag = Object . prototype . toString . call ( arr ) ;
226+ return tag . indexOf ( 'Array]' , tag . length - 6 ) !== - 1 ;
227+ }
228+ GPUUtils . isArray = isArray ;
229+
213230 ///
214231 /// Function: getArgumentType
215232 ///
@@ -222,7 +239,7 @@ var GPUUtils = (function() {
222239 /// {String} Argument type Array/Number/Texture/Unknown
223240 ///
224241 function getArgumentType ( arg ) {
225- if ( Array . isArray ( arg ) ) {
242+ if ( GPUUtils . isArray ( arg ) ) {
226243 return 'Array' ;
227244 } else if ( typeof arg == "number" ) {
228245 return 'Number' ;
You can’t perform that action at this time.
0 commit comments