ProxyVector2.js 656 B

1234567891011121314151617181920212223242526
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author jbaicoianu / http://baicoianu.com/
  4. */
  5. THREE.ProxyVector2 = function ( array, offset ) {
  6. this.array = array;
  7. this.offset = offset;
  8. };
  9. THREE.ProxyVector2.prototype = Object.create( THREE.Vector2.prototype );
  10. THREE.ProxyVector2.prototype.constructor = THREE.ProxyVector2;
  11. Object.defineProperties( THREE.ProxyVector2.prototype, {
  12. 'x': {
  13. get: function () { return this.array[ this.offset ]; },
  14. set: function ( v ) { this.array[ this.offset ] = v; }
  15. },
  16. 'y': {
  17. get: function () { return this.array[ this.offset + 1 ]; },
  18. set: function ( v ) { this.array[ this.offset + 1 ] = v; }
  19. }
  20. } );