如何在Xcode 10的场景工具包中向材质添加色彩

时间:2018-12-27 04:08:21

标签: swift xcode colors 3d scenekit

我正在SceneKit中制作游戏,我需要为用作盒子材质的图像添加色彩。如何为材料/图像添加蓝色?

这是我的代码

let material = SCNMaterial()

let whiteSquare = UIImage(named: "whiteSquare.png")

let boxNode = SCNNode(geometry: SCNBox(width: 0.5, height: 0.2, length: 0.5, chamferRadius: 0))

material.diffuse.contents = whiteSquare
boxNode.position.z = -1.25
boxNode.position.y = 0.1
boxNode.name = "Block\(height)"
boxNode.geometry?.materials = [material]
scnScene.rootNode.addChildNode(boxNode)

0 个答案:

没有答案