Posts

Post not yet marked as solved
2 Replies
1.6k Views
I would like to make text change size as I move towards/away from the image anchor I created. as I move towards the image, the text gets smaller as I move away from the image, the gets bigger My current function to create the text is below: func addTitleToAnchor(text:String, color:SimpleMaterial.Color, isMetallic:Bool, anchor: AnchorEntity, height: Float) {   let mesh = MeshResource.generateText(         text,         extrusionDepth: 0.02,         font: .init(descriptor: .init(name: "Helvetica", size: 1), size: 1),         containerFrame: .zero,         alignment: .center,         lineBreakMode: .byWordWrapping)   let material = SimpleMaterial(color: color, isMetallic: isMetallic)   let entity = ModelEntity(mesh: mesh, materials: [material])   entity.name = "title"   entity.setScale(SIMD3<Float>(0.015 ,0.015,0.015), relativeTo: anchor)   anchor.addChild(entity)   entity.setPosition(SIMD3<Float>(-0.05, 0.03, -height), relativeTo: anchor)   entity.transform.rotation = simd_quatf(angle: -.pi/2, axis: [1,0,0])   return }
Posted
by LT13.
Last updated
.
Post marked as solved
3 Replies
2.8k Views
I am wondering how I can edit the func session(_ session: ARSession, didAdd anchors: [ARAnchor]) in the arView.session.delegate. I would like to run a function when the image is recognized. struct ARViewWrapper: UIViewRepresentable {   let title: String   typealias UIViewType = ARView       func makeUIView(context: Context) -> ARView {     print("detected?")     let arView = ARView(frame: .zero, cameraMode: .ar, automaticallyConfigureSession: true)     let target = AnchorEntity(.image(group: "AR Resources", name: "qr1"))     arView.scene.anchors.append(target)     addARObjs(anchor: target, title: title, planeColor: .blue)     return arView   }       func updateUIView(_ uiView: ARView, context: Context) {     print("update!")     return()   } } Any and all guidance is appreciated! Thanks in advance.
Posted
by LT13.
Last updated
.
Post not yet marked as solved
0 Replies
337 Views
How do I detect multiple instances of the same ARReferenceObject using RealityKit. I can detect one of the objects, but when I move the camera to a second instance of the object, the anchoring persists on the first instance of the object. Ideally, I would like to remove the anchor from the first object, then create a new anchoring on the second one.
Posted
by LT13.
Last updated
.
Post not yet marked as solved
0 Replies
421 Views
I would like to stop tracking an object that has been anchored with AnchorEntity(.object(group: "AR Resources", name: "obj")) when the camera pans away from it. I almost want to the remove the anchor from ARView.scene.anchors? But I am not sure what the best way to d that is. It might be in one of the following: func session(_ session: ARSession, didUpdate anchors: [ARAnchor]) or func session(_ session: ARSession, didAdd anchors: [ARAnchor]) Thanks in advance for the help!
Posted
by LT13.
Last updated
.
Post not yet marked as solved
0 Replies
476 Views
Below is my function that adds text to an Anchor. In my case the Anchor is an image anchor and I am wondering how to remove the lag when the text is added. func addTextToAnchor(anchor: AnchorEntity, text:String, fontSize: CGFloat, color:SimpleMaterial.Color, x: Float, y: Float, z: Float, scale: SIMD3<Float>) {   let mesh = MeshResource.generateText(         text,         extrusionDepth: 0.0,         font: .init(descriptor: .init(name: "Consolas", size: fontSize), size: fontSize),         containerFrame: .zero,         alignment: .center,         lineBreakMode: .byWordWrapping)   let position = SIMD3<Float>(x,y,z)   let material = UnlitMaterial(color: color)   let entity = ModelEntity(mesh: mesh, materials: [material])       entity.name = "title"   entity.setScale(scale, relativeTo: anchor)   anchor.addChild(entity)   entity.position = position   entity.transform.rotation = simd_quatf(angle: -.pi/2, axis: [1,0,0])   return }
Posted
by LT13.
Last updated
.
Post not yet marked as solved
0 Replies
1k Views
I am trying to detect and object using RealityKit's AnchorEntity. Detecting images works perfectly, but when I try to detect an object I can't find it. Works great: AnchorEntity(.image(group: "AR Resources", name: "BE")) Does not work: AnchorEntity(.object(group: "AR Resources", name: "bottle")) I used the app below to scan an object and create a .arobject file: https://developer.apple.com/documentation/arkit/scanning_and_detecting_3d_objects Other information: I am using SwiftUI to wrap an ARView in a UIViewRepresentable I created a Coordinator to be the ARSessionDelegate I am using an iPhone 8 on iOS 13.6
Posted
by LT13.
Last updated
.
Post not yet marked as solved
2 Replies
1k Views
I am looking to run a function when an a reference image is detected in an ARView. I am using RealityKit. The process would be as follows: create ARView with image detection detect image run function to fetch data (changes based on time image is found at) produce AR object in ARView using data retrieved How do I run the function to fetch data?
Posted
by LT13.
Last updated
.
Post not yet marked as solved
2 Replies
2.4k Views
I am building an iOS app using RealityKit. I would like to read a QR Code within ARView but cannot find any documentation/tutorials on it. Any advice/guidance on doing this would be much appreciated! Thanks in advance.
Posted
by LT13.
Last updated
.