Search code examples
javascriptspark-ar-studio

How to make a model rotatable and scalable via gestures (SparkAR, planar image tracking)?


I have a simple SparkAR app, there is a 3D model, attached to the planar tracker, which tracks an image target. How can I make this 3D model rotatable and scalable via gestures?


What I tried:

I tried code from this tutorial, it works in case of just planar tracking, but for some reason doesn't work if the tracker has an image target. It allows me to scale a model ones and doesn't work after it.

I also tried this solution, it allows rotation and scaling, but it makes the model "detached" from the tracked image, so when I move my phone the model also moves around.


How can I make a 3D model, (attached to the planar tracker which tracks image target) rotatable and scalable via finger gestures?


Solution

  • Ok, this one actually is super easy! "Dancing" is my model, it is a child of imageTracker:

    enter image description here

    You need to create this graph, and thats it!

    enter image description here

    Yellow ones created by clicking on "position" and "rotation" in the inspector panel of you model.