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.
|
|
package wow.doge.mygame.utils.wrappers.jme
import cats.Show import cats.kernel.Eq 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
object Error { implicit val show = Show.fromToString[Error] implicit val eq = Eq.fromUniversalEquals[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)) } }
|