Model loading · function
withTangentsIfMapped
Derive a tangent frame for a welded mesh whose material declares a normal map.
Explained in Importing models.
function withTangentsIfMapped(mesh: MeshData, material: DrftMaterial | undefined): MeshDataimport { withTangentsIfMapped } from '@driftengine/assets';Parameters
| Parameter | Type | Description |
|---|---|---|
mesh | MeshData | |
material | DrftMaterial | undefined |
In depth
Deliberately here and not in the reader. A frame exists to sample a normal map, and there is
one place in this engine that reads one, so a material with no map wants no frame. What was wrong
before 3.30.0 is the order: generateTangents accumulates per index, and a file storing one
vertex per triangle corner gives every corner one triangle's frame, so no two corners at a point
agree and weldMesh — which keys on the frame — merges none of them. Measured on a rotationally
unwrapped corner soup: 9,600 corners weld to 1,681 vertices with no frame and to 9,482 with one
derived per corner.