1

I created an AR scene with RealityComposer.

let boxScene = try! Experience.loadBox()

But I don't like the gestures that Apple has provided for this method.

boxScene.generateCollisionShapes(recursive: true)
let box = boxScene.box as? Entity & Has Collision
arView.installGestures(for:box!) //Add gestures
  

I would like to use the same gestures as in SceneKit. I created a cube with the help of RealityKit and added a textEntity to each of its faces.

let textEntity_0: Entity = boxScene.self.children[0].children[0].children[0].children[0].children[0].children[0]
var textModelComp_0: ModelComponent = (textEntity_0.components[ModelComponent])!
var material_0 = SimpleMaterial()
material_0.baseColor = .color(.red)
textModelComp_0.materials[0] = material_0
textModelComp_0.mesh = .generateText("testText", 
                        extrusionDepth: 0.001
                                  font: .systemFont(ofSize: 0.03),
                        containerFrame: CGRect(),
                         lineBreakMode: .byCharWrapping) 

boxScene.self.children[0].children[0].children[0].children[0].children[0].children[0].components.set(textModelComp_0)

I do not need it to stand on the surface or be strictly attached to the surface, but it is necessary that all its faces be visible during rotation. It is also necessary to implement the method:

arView.scene.anchors.append(boxScene)
let anchor = AnchorEntity(.image(group: "LogoTypes", name: "logo")) 
anchor.addChild(boxScene)

This method is from RealityKit. It only shows my 3D cube when it sees a marker. I need the surrounding space from the camera in the background, like in AR. How can I use SceneKit gestures in this case?

S Kiselev
  • 23
  • 4
  • Hey @SKiselev, what SceneKit gestures are you referring to? – Andy Jazz Mar 28 '22 at 09:42
  • Hello, thanks for answering my problem. Gestures like in this tutorial: https://www.youtube.com/watch?v=3rpNDENQgPM – S Kiselev Mar 28 '22 at 09:58
  • 1
    As far as I understand, you're talking about SceneKit's `.allowsCameraControl` property. Look at this post – https://stackoverflow.com/questions/71516286/realitykit-as-a-framework-to-build-3d-nonar-apps/71516339#71516339 – Andy Jazz Mar 28 '22 at 11:40
  • 1
    This post will be helpful for you too – https://stackoverflow.com/questions/71528947/how-can-i-move-a-modelentity-along-the-y-axis-using-gesture/71531053#71531053 – Andy Jazz Mar 28 '22 at 11:50

0 Answers0