'Add UIImage as texture to a Plane in RealityKit
I was trying out the new RealityKit framework in swift and I want to place a 2D image in on an ARAnchor. I managed to create a mesh plane and I tried to add the image as a texture to this plane. I found out that I can give a local image to a material. How can I use a UIImage instead?
let resource = try? TextureResource.load(named: "restart")
var material = UnlitMaterial()
material.baseColor = MaterialColorParameter.texture(resource!)
material.tintColor = UIColor.white.withAlphaComponent(0.99)
let imagePlane = ModelEntity(mesh: MeshResource.generatePlane(width: 0.25, height: 0.25), materials: [SimpleMaterial(color: color, isMetallic: true)])
Solution 1:[1]
There is not currently a way to take a UIImage and apply it to a Material directly (as of June 2020).
You could first write the UIImage to disk, then load it by name in a similar way you have done with your "restart" texture.
Solution 2:[2]
That should not happen... JobRunr is doing optimistic locking so it tries to lock a job before it starts processing it. Only if it can acquire the lock, it will process the job. Can you create a Github repo that reproduces the issue and create a Github issue in the JobRunr repo?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | rdehuyss |