Layers.js 525 B

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