call mesh.Optimize() before applying
use meshData object to simplify code
refactor to reduce code size