-
-
Save brunofarache/5853591 to your computer and use it in GitHub Desktop.
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
/** | |
* Click on the left canvas and then move camera with wasd keys. | |
* Use mouse wheel to zoom in and zoom out. | |
* | |
* https://gist.github.com/brunofarache/5853591 | |
*/ | |
YUI().use('y3d-anim', 'y3d-scene', 'y3d-camera', 'y3d-geometry-box', 'y3d-geometry-sphere', 'y3d-texture', function(Y) { | |
var camera = new Y.Camera({ | |
position: { | |
z: 20 | |
} | |
}); | |
var scene = new Y.Scene({ | |
camera: camera, | |
background: '#272822' | |
}); | |
var box = new Y.Box({ | |
texture: 'examples/images/grass.png', | |
position: { | |
x: 4, | |
z: -10 | |
} | |
}); | |
var sphere = new Y.Sphere({ | |
radius: 2, | |
texture: 'examples/images/moon.gif', | |
position: { | |
x: -4 | |
} | |
}); | |
scene.add(box); | |
scene.add(sphere); | |
var x = 0, y = 0; | |
var animFn = function() { | |
x = x + 3; | |
y = y + 1; | |
box.set('rotation', { x: x, y: y }); | |
sphere.set('rotation', { y: y }); | |
}; | |
// assign animation object to playground.anim, otherwise the editor won't | |
// stop animation before running a different template. | |
playground.anim = new Y.WebGLAnim(scene, animFn); | |
new Y.TextureLoader({ | |
onLoad: function() { | |
playground.anim.start(); | |
}, | |
textures: [box.get('texture'), sphere.get('texture')] | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment