UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

89 lines 2.67 kB
import { TgdGeometry } from "../../geometry"; export interface TgdParserMeshWavefrontAttributes { vertex: number; normal?: number; uv?: number; } /** * This [Wavefront](https://en.wikipedia.org/wiki/Wavefront_.obj_file) * parser only finds the object name, * the vertices coords, the normals and the UVs. * * - There can be only one object per file. * - Normals and UVs are optional. * - All faces **must** be triangles. * * To export an obj file from blender, please use the following options: * * - Forward axis: **Y** * - Up axis: **Z** * - Object / Apply Modifiers: **True** * - Geometry / UV Coordinates: **True** * - Geometry / Normals: **True** * - Geometry / Triangulated Mesh: **True** */ export declare class TgdParserMeshWavefront { private name; private attPosition; private attNormal; private attUV; /** * Three consecutive elements define a triangle. * An element is a index on the attributes array. */ private elements; private elementIndex; /** * The key is `${pointIndex}/${normalIndex}/${uvIndex}`. * The value is the index of the vertex (used in `elements`). */ private readonly mapVertices; /** * A point ins not a vertex, but just a position in space * that can be used by several different vertices. * That's the case for faces sharing a vertex but having different * normals. A vertex is made of a position, a normal and an uv. */ private points; /** * A item of this array can be shared by different vertices. */ private normals; /** * List of vertices per face. * The vertices are represented by the index of the attribute. */ private verticesPerTriangle; /** * Here "normal" is an index on `this.normals` array. */ private normalPerTriangle; /** * The vertices are indexed per attribute. * The triangles are represented by indexes from `this.normalPerTriangle`. */ private trianglesPerVertex; /** * A item of this array can be shared by different vertices. */ private uvs; constructor(content: string); makeGeometry({ computeNormals }?: { computeNormals?: boolean; }): TgdGeometry; private computeNormals; private reset; private readonly onObject; private readonly onVertex; private readonly onNormal; private readonly onTexture; private readonly onFace; /** * Return the index of the vertex for the triplet * point/normal/uv. */ private readonly getElem; private key; private readVertexInto; } //# sourceMappingURL=wavefront.d.ts.map