@@ -380,14 +380,39 @@ window.OptiComputation.GPUController = class{
380
380
381
381
if ( parametros_execucao . matricial == true )
382
382
{
383
- if ( value . length === 4 ) {
384
- // Se for uma matriz 2x2, passe os 4 valores
385
- gl . uniformMatrix2fv ( location , false , new Float32Array ( value ) ) ;
383
+ //Se o "value" for um array ou uma matrix
384
+ if ( Array . isArray ( value ) || value instanceof Float32Array )
385
+ {
386
+ const lengthValue = value . length ;
387
+
388
+ if ( lengthValue === 4 ) {
389
+ // Se for uma matriz 2x2, passe os 4 valores
390
+ gl . uniformMatrix2fv ( location , false , new Float32Array ( value ) ) ;
391
+ } else if ( lengthValue === 9 ) {
392
+ // Matriz 3x3
393
+ gl . uniformMatrix3fv ( location , false , new Float32Array ( value ) ) ;
394
+ } else if ( lengthValue === 16 ) {
395
+ // Matriz 4x4
396
+ gl . uniformMatrix4fv ( location , false , new Float32Array ( value ) ) ;
397
+ } else {
398
+ console . warn ( `Formato de matriz não suportado para ${ name } : tamanho ${ length } ` ) ;
399
+ }
386
400
}
387
401
}
388
402
403
+ //Se "value" for um número
389
404
if ( typeof value === "number" ) {
390
405
gl . uniform1f ( location , value ) ;
406
+
407
+ //Se "value" for um array 32bits
408
+ } else if ( value instanceof Int32Array ) {
409
+ gl . uniform1iv ( location , value ) ;
410
+
411
+ //Se "value" for um array 32bits
412
+ } else if ( value instanceof Uint32Array ) {
413
+ gl . uniform1uiv ( location , value ) ;
414
+
415
+ // Caso constrário
391
416
} else if ( Array . isArray ( value ) ) {
392
417
if ( value . length === 2 ) gl . uniform2fv ( location , new Float32Array ( value ) ) ;
393
418
else if ( value . length === 3 ) gl . uniform3fv ( location , new Float32Array ( value ) ) ;
0 commit comments