Last active
December 12, 2015 02:28
-
-
Save AlexJWayne/4699145 to your computer and use it in GitHub Desktop.
Example of a very simple Echotron layer
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
| # The Constructor/Class that is your layer needs | |
| # to be assigned to module.exports in node.js style. | |
| module.exports = class Example extends Echotron.Echo | |
| # Setup up the layer. Called for you when the | |
| # layer is created. | |
| initialize: -> | |
| # Make a mesh that is a simple cube. | |
| @mesh = new THREE.Mesh( | |
| new THREE.CubeGeometry(10, 10, 10) | |
| new THREE.MeshBasicMaterial() | |
| ) | |
| # Add the cube mesh to the layer. | |
| @add @mesh | |
| # Called per frame, update the objects in the layer | |
| # however you want. | |
| update: (elapsed) -> | |
| # In this case, spin the cube on each axis at 1 | |
| # radian per second. | |
| @mesh.rotation.x += elapsed | |
| @mesh.rotation.y += elapsed | |
| @mesh.rotation.z += elapsed | |
| # Called on every beat of the song. Use it to change | |
| # state to show it reacting to the beat. | |
| onBeat: -> | |
| # In this case, set the cube to a random color | |
| @mesh.material.color = new THREE.Color().setRGB( | |
| Math.random(), Math.random(), Math.random() | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment