ProxyColor.js 840 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author jbaicoianu / http://baicoianu.com/
  4. */
  5. THREE.ProxyColor = function ( array, offset ) {
  6. this.array = array;
  7. this.offset = offset;
  8. }
  9. THREE.ProxyColor.prototype = Object.create( THREE.Color.prototype );
  10. THREE.ProxyColor.prototype.constructor = THREE.ProxyColor;
  11. Object.defineProperties( THREE.ProxyColor.prototype, {
  12. 'r': {
  13. enumerable: true,
  14. get: function () { return this.array[ this.offset ]; },
  15. set: function ( v ) { this.array[ this.offset ] = v; }
  16. },
  17. 'g': {
  18. enumerable: true,
  19. get: function () { return this.array[ this.offset + 1 ]; },
  20. set: function ( v ) { this.array[ this.offset + 1 ] = v; }
  21. },
  22. 'b': {
  23. enumerable: true,
  24. get: function () { return this.array[ this.offset + 2 ]; },
  25. set: function ( v ) { this.array[ this.offset + 2 ] = v; }
  26. }
  27. } );