How to create Mario Galaxy's gravity for cubic surface?

How to create Mario Galaxy’s gravity for cubic surface alerting this script that reproduces gravity in sphere?