0

I like to know how can we reset the scaling of a node on button click, I have added a TransformableNode with functionality to rotate and scale on users gesture

what I need is after all the transactions if the user clicks a button I need to reset the model to its initial size and rotation,

The rotation is working fine but the scaling doesn't have any effect, how can we do that? Following is the method I Used to reset the node

private fun resetModel(){
    modelDragTransformableNode.localRotation = Quaternion.axisAngle(Vector3(0f, 0f, 0f), 00f)
    modelDragTransformableNode.localScale = Vector3(1f, 1f, 1f)
}

The method used to add the node to sceneview

private fun addNodeToScene(model: ModelRenderable) {
    if (sceneView != null) {


        val transformationSystem = makeTransformationSystem()
         modelDragTransformableNode = NewDragTransformableNode(transformationSystem)


        modelDragTransformableNode.localPosition = Vector3(0f, -0.3f, -2.0f)
        modelDragTransformableNode?.renderable = model

        val collisionShape: Box = modelDragTransformableNode.collisionShape as Box
        sceneView.getScene().addChild(modelDragTransformableNode)

        val collisionShape2: Box = modelDragTransformableNode.collisionShape as Box
        modelDragTransformableNode.select()

        sceneView.getScene()
            .addOnPeekTouchListener { hitTestResult: HitTestResult?, motionEvent: MotionEvent? ->
                transformationSystem.onTouch(
                    hitTestResult,
                    motionEvent
                )
            }

    }
}
Renjith K N
  • 2,613
  • 2
  • 31
  • 53

1 Answers1

0

The scale is not updating because it's controlled by the ScaleController's onUpdated method. Try disabling the scale controller before setting the scale and then enable it again:

modelDragTransformableNode.getScaleController().setEnabled(false)

If it doesn't work you can always use a custom scale controller with exposed setScale method (see example).

Derek K
  • 2,756
  • 1
  • 21
  • 37