Skip to content

Commit a3697a1

Browse files
committedMar 1, 2025
Adicionei mais compatibiliadade de vários tipos de matrizes
1 parent c00f7aa commit a3697a1

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed
 

‎src/GPUController.js

+28-3
Original file line numberDiff line numberDiff line change
@@ -380,14 +380,39 @@ window.OptiComputation.GPUController = class{
380380

381381
if( parametros_execucao.matricial == true )
382382
{
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+
}
386400
}
387401
}
388402

403+
//Se "value" for um número
389404
if (typeof value === "number") {
390405
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
391416
} else if (Array.isArray(value)) {
392417
if (value.length === 2) gl.uniform2fv(location, new Float32Array(value));
393418
else if (value.length === 3) gl.uniform3fv(location, new Float32Array(value));

0 commit comments

Comments
 (0)
Please sign in to comment.