Trying to make a simple triangle in SceneKit.
Anyone able to tell me where I’ve gone wrong?
I’m able to add spheres, cubes, images, planes and the likes, but a simple triangle has defeated me. And I want a triangle, not a pyramid.
Here is what I’ve tried. I found a SceneKit tutorial online and replicated it exactly.
[code]Var e As SCNGeometryElementMBS
Var v1, v2, v3 As SCNVector3MBS
v1 = New SCNVector3MBS( 0,0,0)
v2 = New SCNVector3MBS( 0,0,100)
v2 = New SCNVector3MBS( 0,100,100)
Var s As SCNGeometrySourceMBS = SCNGeometrySourceMBS.geometrySourceWithVertices(Array(v1, v2, v3))
e = SCNGeometryElementMBS.geometryElementWithData(s.data, SCNGeometryElementMBS.PrimitiveTypeTriangles, 1, 8)
Var g As SCNGeometryMBS = SCNGeometryMBS.geometryWithSources( Array(s), Array(e))
Var node As SCNNodeMBS
node = New SCNNodeMBS(g)
MyScene.rootNode.addChildNode(node)
[/code]