Layers.js 512 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. function Layers() {
  5. this.mask = 1;
  6. }
  7. Layers.prototype = {
  8. constructor: Layers,
  9. set: function ( channel ) {
  10. this.mask = 1 << channel;
  11. },
  12. enable: function ( channel ) {
  13. this.mask |= 1 << channel;
  14. },
  15. toggle: function ( channel ) {
  16. this.mask ^= 1 << channel;
  17. },
  18. disable: function ( channel ) {
  19. this.mask &= ~ ( 1 << channel );
  20. },
  21. test: function ( layers ) {
  22. return ( this.mask & layers.mask ) !== 0;
  23. }
  24. };
  25. export { Layers };