Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

Commit

Permalink
fix ts
Browse files Browse the repository at this point in the history
  • Loading branch information
slmjkdbtl committed Feb 1, 2024
1 parent 907c93f commit 3826cfd
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/gfx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,15 @@ export class Shader {
} else if (Array.isArray(val)) {
const first = val[0]
if (typeof first === "number") {
gl.uniform1fv(loc, val)
gl.uniform1fv(loc, val as number[])
} else if (first instanceof Vec2) {
gl.uniform2fv(loc, val.map(v => [v.x, v.y]).flat())
} else if (first instanceof Color) {
gl.uniform3fv(loc, val.map(v => [v.r, v.g, v.b]).flat())
}
} else if (typeof val === "object") {
throw new Error("Unsupported uniform data type.")
// TODO allow for struct like objects to be sent as a uniform
}
} else {
throw new Error("Unsupported uniform data type")
}
}
}

Expand Down

0 comments on commit 3826cfd

Please sign in to comment.