declension/elm-obj-loader/1.0.1

OBJ.Types

These are the types used by the obj loader.

type alias ObjFile =
Dict String (Dict String Mesh)

A .obj file is optionally divided into different groups/objects. Each group/object is optionally made up of different meshes, each with it's own material.

So the keys of this dictionary are:

Dict GroupNameOrObjectName (Dict MaterialName Mesh)

If no name is specified in the input file, "default" will be used instead.

type Mesh
= WithoutTexture (MeshWith Vertex)
| WithTexture (MeshWith VertexWithTexture)
| WithTextureAndTangent (MeshWith VertexWithTextureAndTangent)

A Mesh loaded by the obj loader is a record with a list of vertices and a list of indices. Depending on the mesh type and the loading options you get a different kind of mesh. They differ on what information a vertex contains.

These meshes are meant to be used with WebGL.indexedTriangles mesh.vertices mesh.indices.

type alias MeshWith a =
{ vertices : List a
, indices : List ( Int, Int, Int )
}

Defines a mesh: vertices of any type, and a list of their integer indices

--

type alias Vertex =
{ position : Vec3
, normal : Vec3
}

A 3D position with a normal

type alias VertexWithTexture =
{ position : Vec3
, texCoord : Vec2
, normal : Vec3
}

A 3D position with a normal and a 2D texture position.

{ position : Vec3
, texCoord : Vec2
, normal : Vec3
, tangent : Vec4
}

The tangent is a vector pointing tangential to the object surface, in the direction of the u texture coordinate. This is needed for doing tangent space normal mapping. The 4th component is either 1 or -1 and has to be used to get the bitangent in the glsl shader, e.g: vec3 bitangent = cross(normal, tangent.xyz) * tangent.w

more info here: https://web.archive.org/web/20160409104130/http://www.terathon.com/code/tangent.html