donmccurdy/glTF-Transform

Deprecate hexadecimal getters/setters

donmccurdy opened this issue · 1 comments

For baseColorFactor and all other material color inputs (including extensions), I've provided getters/setters for both factors and hexadecimal values. This affects most new material extensions, has started to feel like an unnecessary bit of clutter.

/**
* Base color / albedo factor; Linear-sRGB components.
* See {@link Material.getBaseColorTexture getBaseColorTexture}.
*/
public getBaseColorFactor(): vec4 {
return this.get('baseColorFactor');
}
/**
* Base color / albedo factor; Linear-sRGB components.
* See {@link Material.getBaseColorTexture getBaseColorTexture}.
*/
public setBaseColorFactor(baseColorFactor: vec4): this {
return this.set('baseColorFactor', baseColorFactor);
}
/**
* Base color / albedo; sRGB hexadecimal color. See {@link Material.getBaseColorTexture getBaseColorTexture}.
*/
public getBaseColorHex(): number {
return ColorUtils.factorToHex(this.get('baseColorFactor'));
}
/**
* Base color / albedo; sRGB hexadecimal color. See {@link Material.getBaseColorTexture getBaseColorTexture}.
*/
public setBaseColorHex(hex: number): this {
const factor = this.get('baseColorFactor').slice() as vec4;
return this.set('baseColorFactor', ColorUtils.hexToFactor(hex, factor));
}

In v4, perhaps the hexadecimal-based getters/setters should be deprecated or removed, leaving just factors. Conversion to/from hex is easy with https://gltf-transform.dev/modules/core/classes/ColorUtils.

I'll deprecate these methods in v3.10, and remove them in v4.0.