Anyone know how to transform SCNMaterial to surface without change orientation of SCNMaterial contains an image?
I want to create ARKit SCNNode with contains an image and then it transforms to surface cause I want to show the image on a surface area on the selected position
I am using following code to transform my SCNNode
let planeGeometry = SCNPlane(width: CGFloat(Width), height: CGFloat(Height))
let material = SCNMaterial()
material.diffuse.contents = UIImage.init(named: “imgName”)
let matirials:[SCNMaterial] = [material]
planeGeometry.materials = matirials
let rectNode = SCNNode(geometry: planeGeometry)
var transform = SCNMatrix4MakeRotation(-Float.pi / 2.0, 1.0, 0.0, 0.0)
transform = SCNMatrix4Rotate(transform, Float(orientation), 0, 1, 0)
rectNode.transform = transform
self.addChildNode(rectNode)
self.position = position
An issue in the above code: Node transform successfully but it's flip my SCNMaterial image randomly based on orientation.
So any one help me to solve this issue?
The material transform can be adjusted by contentsTransform
of SCNMaterialProperty
material.diffuse.contentsTransform = SCNMatrix4.SCNMatrix4Identity
Or if you just need adjust the mirrored image, you can use either
material.diffuse.wrapS = .mirror
or material.diffuse.wrapT = .mirror
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.