Last active
August 29, 2015 14:00
-
-
Save ukris/01194a36f98b52feb212 to your computer and use it in GitHub Desktop.
Rotate Cube in FAMO.US - NOT WORKING Replicate this //http://codepen.io/AllanDennis/pen/enaIj in FAMO.US- Demonstrate Transform and Touch Event
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
//http://codepen.io/AllanDennis/pen/enaIj | |
// Replicate the above coeepen in FAMO.US | |
//This should enable understanding of FAMO.US perspective, rotation and event handling | |
// ** NOT WORKING | |
define(function(require, exports, module) { | |
var matrix; | |
var x,y,rot,scale; | |
var rotate = [ | |
[0,0,0], | |
[0, 90,0], | |
[0, -90,0], | |
[0,0,0], | |
[90,0,0], | |
[-90,0,0] | |
]; | |
var xlate = [ | |
[0,0,150], | |
[150, 0,0], | |
[-150, 0,0], | |
[0, 0,-150], | |
[0,150,0], | |
[0,-150,0] | |
]; | |
var xlt,rot; | |
function originalCube() { | |
for (var i=0;i<colors.length;i++) { | |
xlt = xlate[i] | |
rot = rotate[i] | |
matrix = Transform.multiply( | |
Transform.translate(xlt[0],xlt[1],xlt[2]), | |
Transform.rotate(rot[0],rot[1],rot[2]) | |
) | |
// matrix = Transform.aboutOrigin([0.5,0.5,0],matrix) | |
_smod[i].setTransform( | |
matrix, | |
{ duration : 1000, curve: 'easeInOut' } | |
); | |
} | |
} | |
function rotateCube() { | |
for (var i=0;i<colors.length;i++) { | |
matrix = Transform.rotate(0,360,1080) | |
_smod[i].setTransform( | |
matrix, | |
{ duration : 1000, curve: 'easeInOut' } | |
); | |
} | |
} | |
var Engine = require('famous/core/Engine'); | |
var Surface = require('famous/core/Surface'); | |
var Transform = require('famous/core/Transform'); | |
var Modifier = require('famous/core/Modifier'); | |
// var StateModifier = require('famous/modifiers/StateModifier'); | |
var Timer = require('famous/utilities/Timer'); | |
var _ctx = Engine.createContext(); | |
var colors = ['red','blue','violet','green','yellow','aqua']; | |
var _surface = []; | |
var _smod = []; | |
for (var i=0;i<colors.length;i++) { | |
_surface[i] = new Surface({ | |
size: [200, 200], | |
properties: { | |
backgroundColor: colors[i], | |
opacity:0.5 | |
} | |
}); | |
_smod[i] = new Modifier({origin:[0.5,0.5]}); | |
_ctx.add(_smod[i]).add(_surface[i]); | |
} | |
originalCube() | |
Timer.setInterval(rotateCube,500) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment