Layers.js 639 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. enableAll: function () {
  15. this.mask = 0xffffffff | 0;
  16. },
  17. toggle: function ( channel ) {
  18. this.mask ^= 1 << channel | 0;
  19. },
  20. disable: function ( channel ) {
  21. this.mask &= ~ ( 1 << channel | 0 );
  22. },
  23. disableAll: function () {
  24. this.mask = 0;
  25. },
  26. test: function ( layers ) {
  27. return ( this.mask & layers.mask ) !== 0;
  28. }
  29. } );
  30. export { Layers };
粤ICP备19079148号