Layers.js 657 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. clone: function ( ) {
  25. return new Layers().copy( this );
  26. },
  27. copy: function ( source ) {
  28. this.mask = source.mask;
  29. return this;
  30. }
  31. };
  32. export { Layers };