Created
August 16, 2016 00:04
-
-
Save mrdoob/7d75270a22b9d62da2e1e991ef846188 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
import { Layers } from './Layers.js'; | |
var test = new Layers(); | |
console.log( test ); |
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
/** | |
* @author mrdoob / http://mrdoob.com/ | |
*/ | |
function Layers() { | |
this.mask = 1; | |
} | |
Layers.prototype = { | |
constructor: Layers, | |
set: function ( channel ) { | |
this.mask = 1 << channel; | |
}, | |
enable: function ( channel ) { | |
this.mask |= 1 << channel; | |
}, | |
toggle: function ( channel ) { | |
this.mask ^= 1 << channel; | |
}, | |
disable: function ( channel ) { | |
this.mask &= ~ ( 1 << channel ); | |
}, | |
test: function ( layers ) { | |
return ( this.mask & layers.mask ) !== 0; | |
} | |
}; | |
export { Layers }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment