答案 0 :(得分:0)
遵循由Apple工程师创建的AR项目:Handling 3D Interaction and UI Controls in Augmented Reality,以了解如何以编程方式创建
Focus Square
。网页顶部有一个蓝色的下载按钮。
要在IKEA应用程序中创建一个
Focus Circle
,我建议您使用一个png
文件,并将其预乘以RGBA通道(将其拖放到桌面上进行测试):
要创建阴影,您需要在场景中添加directional
灯光。为此,请使用以下代码:
let lightFixture = SCNNode()
lightFixture.light = SCNLight()
lightFixture.light!.type = .directional
lightFixture.light!.castsShadow = true
lightFixture.light!.shadowMode = .deferred
lightFixture.light!.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
lightFixture.position = SCNVector3(x: 0, y: 20, z: 0)
lightFixture.rotation = SCNVector4(x: -1, y: 0, z: 0, w: .pi/2)
scene.rootNode.addChildNode(lightFixture)
然后,您需要为半透明阴影创建不可见平面:
let shadowPlane = SCNNode()
shadowPlane.geometry = SCNFloor()
shadowPlane.geometry?.firstMaterial!.colorBufferWriteMask = []
shadowPlane.geometry?.firstMaterial!.readsFromDepthBuffer = true
shadowPlane.geometry?.firstMaterial!.writesToDepthBuffer = true
shadowPlane.geometry?.firstMaterial!.lightingModel = .constant
scene.rootNode.addChildNode(shadowPlane)
就是这样。希望这会有所帮助。