Mohit Chauhan
Mohit Chauhan

Reputation: 455

How to use TransformableNode in SceneView with all gestures?

TransformableNode gestures are not working on the object in SceneView.

I'm displaying a 3D object on SceneView. When I provide TransformableNode as first child to the scene of SceneView then no gesture is working. But when do the same thing with ArFragment, then everything works.

private fun createNode() {
    val transformationSystem = makeTransformationSystem()
    val transformableNode = TransformableNode(transformationSystem).apply {
        rotationController.isEnabled = true
        scaleController.isEnabled = true
        translationController.isEnabled = false // not support
        setParent(sceneView.scene)
        this.renderable = myRenderable // Build using CompletableFuture
    }

    sceneView.scene.addOnPeekTouchListener { hitTestResult, motionEvent ->
        transformationSystem.onTouch(hitTestResult, motionEvent)
    }
}

private fun makeTransformationSystem(): TransformationSystem {
    val selectionVisualizer = FootprintSelectionVisualizer()
    return TransformationSystem(resources.displayMetrics, selectionVisualizer)
}

I want my 3D object in SceneView can be able to rotate and scale using gestures which are used in TransformabelNode.

Upvotes: 1

Views: 996

Answers (1)

Cole Tomlinson
Cole Tomlinson

Reputation: 26

Try calling transformableNode.select() after you create your node (or simply call select() in your apply block).

Upvotes: 1

Related Questions