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.

27 lines
831 B

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