![](/img/trans.png)
[英]Add a UIImage as Material to a SCNGeometry in ARKit with Swift
[英]Display white image material in ARKit with Swift
我已經用 SCNGeometryElement 創建了節點並應用圖像內容材料來顯示白色和應用顏色內容工作正常。 我附上了代碼。
func getsquareDrawnLineFrom(pos1: SCNVector3,
pos2: SCNVector3,
pos3: SCNVector3) -> SCNNode {
let square = SquareplanlineFrom(vector1: pos1, vector2: pos2, vector3: pos3)
let material = SCNMaterial()
// material.diffuse.contents = UIColor.red
material.diffuse.contents = UIImage(named: "grid")
square.materials = [material]
let square1 = SCNNode(geometry: square)
square1.name = "tringle"
return square1
}
// get line geometry between three vectors
func SquareplanlineFrom(vector1: SCNVector3,
vector2: SCNVector3,
vector3: SCNVector3) -> SCNGeometry {
let indices: [Int32] = [0, 1, 2]
let source = SCNGeometrySource(vertices: [vector1, vector2, vector3])
let element = SCNGeometryElement(indices: indices, primitiveType: .triangles)
return SCNGeometry(sources: [source], elements: [element])
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.