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

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))
}
}