Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataUtils: Add toRGB9E5() and fromRGB9E5(). #887

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions types/three/src/extras/DataUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,26 @@ export function toHalfFloat(val: number): number;
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/extras/DataUtils.js | Source}
*/
export function fromHalfFloat(val: number): number;

/**
* This method packs three floats into a single Uint32 value which is required for the `RGB9E5` texture format.
* @param r A float representing the R channel.
* @param g A float representing the G channel.
* @param b A float representing the B channel.
* @param target An instance of `Uint32Array` with length `1`.
*/
export function toRGB9E5(r: number, g: number, b: number, target: Uint32Array): Uint32Array;

/**
* This method unpacks three floats from a single Uint32 value holding a `RGB9E5` texel.
* @param val An instance of `Uint32Array` with length `1`.
* @param target An array holding the three unpacked floats.
*/
export function fromRGB9E5(val: Uint32Array, target: number[]): number[];

export const DataUtils: {
toHalfFloat: typeof toHalfFloat;
fromHalfFloat: typeof fromHalfFloat;
toRGB9E5: typeof toRGB9E5;
fromRGB9E5: typeof fromRGB9E5;
};
Loading