getTangents {rgl2gltf}R Documentation

Use the MikkTSpace code to generate tangent vectors.

Description

This function generates tangent vectors using the MikkTSpace code by Morten S. Mikkelsen.

Usage

getTangents(obj)

Arguments

obj

A triangles or quads object as returned by rgl::scene3d().

Details

glTF files include normal textures, which require the tangent space to be specified: the normals at each vertex are supplemented with a tangent vector and a bitangent vector that is their cross product. The standard recommends that if the glTF file doesn't specify tangents, they should be generated using the MikkTSpace code.

Note that a comment in ‘mikktspace.h’ indicates that indexing needs to be recalculated after computing the tangents, so this function works on unindexed inputs, and reapplies indexing at the end.

Value

A modified copy of the original object, adding a 4 column tangents entry. The order and number of indices may have changed.

Author(s)

Morten S. Mikkelsen, Johannes Kuehnel and Duncan Murdoch.

References

The MikkTSpace code was obtained from https://github.com/mmikk/MikkTSpace. The interface code is based on code from https://www.turais.de/using-mikktspace-in-your-project/ by Johannes Kuehnel.


[Package rgl2gltf version 1.0.3 Index]