package wow.doge.mygame.utils.wrappers.jme import com.jme3.bullet.collision.shapes.CollisionShape import com.jme3.bullet.{util => jmebu} import com.jme3.scene.Spatial import monix.bio.IO object CollisionShapeFactory { sealed trait Error case class WrongArgumentError(reason: String) extends Error def createMeshShape(subtree: Spatial): IO[Error, CollisionShape] = IO(jmebu.CollisionShapeFactory.createMeshShape(subtree)).onErrorHandleWith { case ex: IllegalArgumentException if (ex.getMessage.startsWith("The spatial must either be a Node")) => IO.raiseError(WrongArgumentError(ex.getMessage)) } }