swift - SCNGeometry 不使用数据
问题描述
我在网上找不到任何示例,显示正确创建SCNGeometry
不使用NSData
/ Data
API 的三角形。我正在尝试这样做,但没有任何渲染:
func
testTriangles()
-> SCNNode
{
// Vertices…
var vertices = [SCNVector3]()
vertices.append(SCNVector3(x: 0.0, y: 0.0, z: 0.0))
vertices.append(SCNVector3(x: 0.0, y: 0.0, z: 50.0))
vertices.append(SCNVector3(x: 50.0, y: 0.0, z: 50.0))
let vertexSource = SCNGeometrySource(vertices: vertices)
var normals = [SCNVector3]()
normals.append(SCNVector3(x: 0.0, y: 1.0, z: 0.0))
normals.append(SCNVector3(x: 0.0, y: 1.0, z: 0.0))
normals.append(SCNVector3(x: 0.0, y: 1.0, z: 0.0))
let normalSource = SCNGeometrySource(normals: normals)
// Indices…
var indices = [0, 1, 2]
let triangles = SCNGeometryElement(indices: indices, primitiveType: .triangles)
let geom = SCNGeometry(sources: [vertexSource, normalSource], elements: [triangles])
let node = SCNNode()
node.geometry = geom
let mat = SCNMaterial()
mat.diffuse.contents = NSColor.green
geom.materials = [mat]
return node
}
解决方案
推荐阅读
- javascript - 缓慢的第三方 API 阻塞 Express 服务器
- python - 如何通过 socks 代理访问 Azure Blob 存储?
- linear-programming - 如何解决 mathprog 中的域外错误?
- python-3.x - 在 Dash/Plotly 中显示 PIL 图像
- javascript - 在反应路由器中切换页面时未加载js文件
- netsuite - Netsuite - 发送电子邮件操作按钮不起作用
- r - 如何在 visNetwork 中显示非彩色图形且易于阅读的文本?
- python - Pyspark + Anaconda 上的 IllegalArgumentException
- c# - Azure webjob convert time to Universal time
- html - 如何控制在社交媒体或移动设备上分享网页时显示的图像?