我正在尝试基于2D jpg图像在场景工具包中创建SCNNode。此图像将放置在另一个3D SCNNode中。我尝试在我的场景中使用.background.contents,但这不是我正在寻找的。知道如何做到这一点?谢谢!
这是我的代码:
@IBOutlet weak var sceneView: ARSCNView!
viewDidLoad方法中的:
let scene = SCNScene()
sceneView.scene = scene
在viewWillAppear中:
let ship = SpaceShip()
ship.loadModal()
ship.position = SCNVector3(0, 0, Double(-1.5))
sceneView.scene.rootNode.addChildNode(ship)
这是太空飞船课程:
class SpaceShip: SCNNode {
func loadModal(){
let virtualObjectScene = SCNScene(named: "ship.scn")!
let wrapperNode = SCNNode()
for child in virtualObjectScene.rootNode.childNodes{
wrapperNode.addChildNode(child)
}
self.addChildNode(wrapperNode)
}
}
答案 0 :(得分:1)
答案 1 :(得分:1)
它适合我
let node = SCNNode(geometry: SCNSphere(radius: 0.01))
node.geometry?.materials.first?.diffuse.contents = color
node.physicsBody? = .static()
node.name = name
node.physicsBody?.categoryBitMask = MaskNum.barrier.rawValue
node.geometry?.materials.first?.diffuse.contents = UIImage(named: "Circle")
node.position = SCNVector3(0.0, 0.0, -5.0)
sceneView.pointOfView?.addChildNode(node)