Ajout douteuse des meeples sur le board, il faudrait tester avec les tablettes pour etre sur :wheel_chair:

ARKit
Pierre FERREIRA 1 year ago
parent f0800dc01b
commit 9bc66e01ba

@ -22,6 +22,7 @@ class MyARView : ARView{
convenience init() { convenience init() {
self.init(frame: UIScreen.main.bounds) self.init(frame: UIScreen.main.bounds)
addBoardToTheFloor() addBoardToTheFloor()
addMeepleToBoard()
} }
@ -52,9 +53,32 @@ class MyARView : ARView{
} }
} }
func addMeepleToBoard(){ func addMeepleToBoard(){ //boardAnchor : AnchorEntity
let configuration = ARWorldTrackingConfiguration() let configuration = ARWorldTrackingConfiguration()
session.run(configuration) session.run(configuration)
let objectsName = [ "rat", "cat", "dog", "wolf", "leopard", "tiger", "lion", "elephant"]
var iterator : Int = 0
let anchor = AnchorEntity(.plane(.horizontal, classification: .any, minimumBounds: SIMD2<Float>(0.3, 0.3))) //Une anchor par case ou une pour tout le plateau ?
scene.addAnchor(anchor)
/// TODO : Lier au model ?
for row in 0...7{
for col in 0...7{
if (col % 2 == row % 2 ){
let meeple = try? Entity.load(named: objectsName[iterator % 7]) //miteux
iterator += 1
if let meeple {
meeple.position.x += 0.1145 * Float(row)
meeple.position.y += 0.1145 * Float(col)
anchor.addChild(meeple)
}
}
}
}
} }
// func createAnchor(){ // func createAnchor(){

Loading…
Cancel
Save