Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
639 B

3 years ago
  1. package wow.doge.mygame.utils.wrappers.jme
  2. import com.jme3.bullet.collision.shapes.CollisionShape
  3. import com.jme3.bullet.{util => jmebu}
  4. import com.jme3.scene.Spatial
  5. import monix.bio.IO
  6. object CollisionShapeFactory {
  7. sealed trait Error
  8. case class WrongArgumentError(reason: String) extends Error
  9. def createMeshShape(subtree: Spatial): IO[Error, CollisionShape] =
  10. IO(jmebu.CollisionShapeFactory.createMeshShape(subtree)).onErrorHandleWith {
  11. case ex: IllegalArgumentException
  12. if (ex.getMessage.startsWith("The spatial must either be a Node")) =>
  13. IO.raiseError(WrongArgumentError(ex.getMessage))
  14. }
  15. }