initial translation from jzy3d demo