# helper functions copied from 3dgs