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

FOLD typescript definition #49

Closed
mayakraft opened this issue May 14, 2024 · 2 comments
Closed

FOLD typescript definition #49

mayakraft opened this issue May 14, 2024 · 2 comments

Comments

@mayakraft
Copy link
Contributor

Hello! Would you like a type definition for the FOLD format itself? This is not exactly #25 or #45, nothing to do with the API, only a type definition for a FOLD object. I imagine it could live inside of its own file, like fold.d.ts? Or, feel free to use it in any way you like!

I think this is valid for versions 1.2 and 1.1, but not 1.0.

The logic behind this structure arises from how a FOLD object can contain itself in file_frames. FOLD is the intended export. FOLDFrame is the intersection of the inner and top level frames, then the inner frames and top level frame contain inheritance info and file_ keys respectively.

fold.d.ts

type FOLDFrame = {
    frame_author?: string;
    frame_title?: string;
    frame_description?: string;
    frame_classes?: string[];
    frame_attributes?: string[];
    frame_unit?: string;
    vertices_coords?: [number, number][] | [number, number, number][];
    vertices_vertices?: number[][];
    vertices_edges?: number[][];
    vertices_faces?: (number | null | undefined)[][];
    edges_vertices?: [number, number][];
    edges_faces?: (number | null | undefined)[][];
    edges_assignment?: string[];
    edges_foldAngle?: number[];
    edges_length?: number[];
    faces_vertices?: number[][];
    faces_edges?: number[][];
    faces_faces?: (number | null | undefined)[][];
    faceOrders?: [number, number, number][];
    edgeOrders?: [number, number, number][];
};

type FOLDChildFrame = FOLDFrame & {
    frame_parent?: number;
    frame_inherit?: boolean;
};

type FOLD = FOLDFrame & {
    file_spec?: number;
    file_creator?: string;
    file_author?: string;
    file_title?: string;
    file_description?: string;
    file_classes?: string[];
    file_frames?: FOLDChildFrame[];
};
@edemaine
Copy link
Owner

Thank you! There is a definition along these lines in #47 which I really need to finish reviewing; I'll diff against this one. I agree it'll be nice to get a type definition in the exports.

@mayakraft
Copy link
Contributor Author

sounds great :) also, somebody ported it! very happy to see. I'll close this then so as not to clutter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants