Fix compiling edge-cases

This commit is contained in:
Andras Schmelczer 2026-06-10 21:36:52 +01:00
parent bd2307f782
commit 4a6a25a081
2 changed files with 21 additions and 9 deletions

View file

@ -3,5 +3,13 @@
*
* Returns non-numbers as is.
*/
export const numberToGlslFloat = (value: number | string): string =>
Number.isInteger(value) ? `${value}.0` : value.toString();
export const numberToGlslFloat = (value: number | string): string => {
if (typeof value !== 'number') {
return String(value);
}
const asString = value.toString();
// Very large integers stringify in exponent notation (1e21)
return Number.isInteger(value) && !asString.includes('e') ? `${asString}.0` : asString;
};