Search code examples
facebookinstagramspark-ar-studio

Rotate an object on XYZ while using the last rotation value in Spark AR


  • I have a scene with a single world object, a plane tracker, and am using the patch editor
  • I can pan, scale, and rotate the object on a single axis (xyz)
  • I have a button that allows the user to change the rotation axis from x > y > z
  • When pressing that button, the object rotation value gets replaced by a new value and moves the object, which is annoying. For example, I rotate on X, tap button to rotate on Y, the X rotation is lost and replaced by new coords
  • On button press, I'd like to use the last rotation value and only modify the axis that the user selected
  • For example, if I rotate my object on the X axis, tap the button to Y, then I should now rotate on the Y axis while keeping the previous X axis value
  • Here is an example from my patch:

enter image description here

I can't "get" the current rotation value of an object using the patch editor. I've tried a block that has a child object, using that child object's rotation value, and then feeding that back into my object but I get loop errors. Essentially, all I want to do is use the current rotation value and on button press, modify the vector column (x, y, or z). Should I use a combination of patch + scripting? Can I do this in scripting alone?


Solution

  • Ok this one was easy, but interesting.

    enter image description here