-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlane2_Node.swift
37 lines (27 loc) · 1.08 KB
/
Plane2_Node.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import UIKit
import SceneKit
import ARKit
class Plane2_Node: SCNNode {
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
init(anchor: ARPlaneAnchor) {
super.init()
let plane = SCNBox(width: CGFloat(anchor.extent.x), height: CGFloat(0.06), length: CGFloat(anchor.extent.z), chamferRadius: 0.0)
plane.firstMaterial?.diffuse.contents = UIColor.white.withAlphaComponent(0.5)
plane.widthSegmentCount = 10
plane.heightSegmentCount = 1
plane.lengthSegmentCount = 10
geometry = plane
//ポジション
position = SCNVector3Make(anchor.center.x, 0.17 , anchor.center.z)
// 物理ボディ
let bodyShape = SCNPhysicsShape(geometry: geometry!, options: [:])
physicsBody = SCNPhysicsBody(type: .static, shape: bodyShape)
physicsBody?.friction = 3.0
physicsBody?.restitution = 0.2
// 衝突
physicsBody?.categoryBitMask = 3
physicsBody?.collisionBitMask = 3
}
}