ProxyVector3.js 791 B

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. * @author jbaicoianu / http://baicoianu.com/
  4. */
  5. THREE.ProxyVector3 = function ( array, offset ) {
  6. this.array = array;
  7. this.offset = offset;
  8. };
  9. THREE.ProxyVector3.prototype = Object.create( THREE.Vector3.prototype );
  10. THREE.ProxyVector3.prototype.constructor = THREE.ProxyVector3;
  11. Object.defineProperties( THREE.ProxyVector3.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. 'z': {
  21. get: function () { return this.array[ this.offset + 2 ]; },
  22. set: function ( v ) { this.array[ this.offset + 2 ] = v; }
  23. }
  24. } );