Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

233
Views
How to rotate an object by genericTweenValue in Lens Studio

I have an object that I want to rotate on the y-axis by 90 degrees every time I tap on the screen, and I would like to use the easing functions from the tween manager using genericTweenValue. In the code below I try to do that but the angles seem to be wrong.

Expected outcome: Object rotates by an angle of 90 degrees on each tap. Actual outcome: Makes multiple rotations on each tap, that are not 90 degrees.

global.turn = function() {
    var updateEvent = script.createEvent("UpdateEvent");

    var transform = object.getTransform();
    var rotation = transform.getLocalRotation();

    tweenManager.setStartValue(object, "y_rot_", rotation.y);
    tweenManager.setEndValue(object, "y_rot_", rotation.y + 90);

    updateEvent.bind(function(eventData) {
        var rotY = tweenManager.getGenericTweenValue(object, "y_rot_");
        var rotationToApply = quat.angleAxis(rotY, vec3.up());
        var oldRotation = object.getTransform().getLocalRotation();
        var newRotation = rotationToApply.multiply(oldRotation);
        transform.setLocalRotation(newRotation);
    });

    tweenManager.startTween(object, "y_rot_", function() {
        script.removeEvent(updateEvent);
    });
}

var touchEvent = script.createEvent("TapEvent");
touchEvent.bind(function(eventData) {global.turn()});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!