Skip to content

Instantly share code, notes, and snippets.

@unicomp21
Created April 25, 2023 12:36
Show Gist options
  • Save unicomp21/05a4634e6ea371e8fee7b77590da9992 to your computer and use it in GitHub Desktop.
Save unicomp21/05a4634e6ea371e8fee7b77590da9992 to your computer and use it in GitHub Desktop.
declare module 'xatlas.js' {
export const xatlas: XAtlas;
interface XAtlas {
create(): XAtlasInstance;
addMesh(instance: XAtlasInstance, positions: Float32Array, indices: Uint32Array): void;
generate(instance: XAtlasInstance, options?: Partial<GenerateOptions>): void;
destroy(instance: XAtlasInstance): void;
}
interface XAtlasInstance {
meshes: Mesh[];
}
interface Mesh {
charts: Chart[];
vertices: Float32Array;
}
interface Chart {
faces: Face[];
}
interface Face {
indices: number[];
}
interface GenerateOptions {
resolution: number;
padding: number;
maxChartSize: number;
progressCallback(progress: number): void;
cancelCallback(): boolean;
}
// Define the CalculateColorCallback type
type CalculateColorCallback = (lerpedVertexData: LerpedVertexData) => Color;
interface LerpedVertexData {
position: Vector3;
}
interface Vector3 {
x: number;
y: number;
z: number;
}
interface Color {
r: number;
g: number;
b: number;
a: number;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment