imported from jeromeetienne/threex