DragGesture/Rotation is not working on custom Anchor only

To resume the rotation/dragGesture is working only on défaut xyz point

I tried to add a custom anchor and apply the same code but cannot be dragged My guess is that the red line is causing the issue (see screenshot)

Replies

Hello @SamuelCelestine,

Can you provide a focused sample project that reproduces the issue?

Hello



RealityView { content in 


//--------- Cannot be Dragged to rotate on TableAnchor Y axis ------
tableAnchor = AnchorEntity(.plane(.horizontal, classification: .table, minimumBounds: SIMD2<Float>(0.6,0.6)))
           let planeMesh = MeshResource.generatePlane(width: 3.75, depth: 2.625,cornerRadius: 0.1)
           let material = SimpleMaterial(color: .green, isMetallic: false)
           let planeEntity = ModelEntity(mesh: planeMesh , materials: [material])
           planeEntity.name = "canvas"

tableAnhor.addChild(entity)
content.add(tableAnchor)

//--------- Can be Dragged to rotate  only origin Y axis ------
cube2 = try! await Entity(named: "CubeTest", in: realityKitContentBundle)
content.add(entity2)

}.rotation3DEffect(.radians(rotateBy),axis: .y , anchor: .center )  // i tried to replace .center by the name of my tableAnchors and also like in my screenshot
        .gesture(DragGesture(minimumDistance: 0.0)
            .targetedToAnyEntity()
            .onChanged {value in
                let location3d = value.convert(value.location3D, from: .local, to: .scene)
                let startlocation = value.convert(value.startLocation3D, from: .local, to: .scene)
                
                let delta = location3d - startlocation
                let totalDistance = 30 
                self.rotateBy = Double(delta.x / Float(totalDistance) * 360.0)
                
              
                
            }
                 
        )
code-block