Created
March 9, 2019 00:19
-
-
Save thelucre/66be040506007c021e161de2eea0f992 to your computer and use it in GitHub Desktop.
AutoRotate script for Snapchat Lens Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -----JS CODE----- | |
//@input vec3 Rotation | |
//@input float Speed | |
// Equivalent to GameObject | |
var object = script.getSceneObject(); | |
// Just like Unity Transform! | |
var transform = script.getTransform(); | |
function onUpdate(ev) { | |
var transform = script.getTransform(); | |
var rotation = transform.getLocalRotation(); | |
var amt = script.Rotation.uniformScale(getDeltaTime() * script.Speed); | |
var rotateY = quat.angleAxis(amt.x, vec3.up()); | |
var rotateX = quat.angleAxis(amt.y, vec3.left()); | |
var rotateZ = quat.angleAxis(amt.z, vec3.forward()); | |
rotation = rotation | |
.multiply(rotateY) | |
.multiply(rotateX) | |
.multiply(rotateZ); | |
transform.setLocalRotation(rotation); | |
} | |
var updateEvent = script.createEvent("UpdateEvent"); | |
updateEvent.bind(onUpdate); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment