Created
July 23, 2012 07:49
-
-
Save auz1111/3162460 to your computer and use it in GitHub Desktop.
Rotates the cube in the PlayCanvas demo...
This file contains hidden or 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
pc.script.create("spinner", function (context) { | |
var Spinner = function (entity) { | |
// Cache the entity that this script instance affects | |
this.entity = entity; | |
}; | |
Spinner.prototype.update = function (dt) { | |
// Retrieve the transformation matrix of the entity | |
var transform = this.entity.getLocalTransform(); | |
// Create rotation matrix of 1 degree around the y axis | |
var angle = Math.PI / 180.0; | |
var axis = pc.math.vec3.create(0, 1, 0); | |
var rotate = pc.math.mat4.makeRotate(angle, axis); | |
// Pre-multiply the rotation against the entity xform | |
pc.math.mat4.multiply(transform, rotate, transform); | |
}; | |
return Spinner; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After the API update, this now becomes:
Much simpler! :)