Vector4.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @author supereggbert / http://www.paulbrunt.co.uk/
  3. * @author philogb / http://blog.thejit.org/
  4. */
  5. THREE.Vector4 = function ( x, y, z, w ) {
  6. this.x = x || 0;
  7. this.y = y || 0;
  8. this.z = z || 0;
  9. this.w = w || 1;
  10. };
  11. THREE.Vector4.prototype = {
  12. set: function ( x, y, z, w ) {
  13. this.x = x;
  14. this.y = y;
  15. this.z = z;
  16. this.w = w;
  17. },
  18. copy: function ( v ) {
  19. this.x = v.x;
  20. this.y = v.y;
  21. this.z = v.z;
  22. this.w = v.w;
  23. },
  24. add: function ( v1, v2 ) {
  25. this.x = v1.x + v2.x;
  26. this.y = v1.y + v2.y;
  27. this.z = v1.z + v2.z;
  28. this.w = v1.w + v2.w;
  29. },
  30. addSelf: function ( v ) {
  31. this.x += v.x;
  32. this.y += v.y;
  33. this.z += v.z;
  34. this.w += v.w;
  35. },
  36. sub: function ( v1, v2 ) {
  37. this.x = v1.x - v2.x;
  38. this.y = v1.y - v2.y;
  39. this.z = v1.z - v2.z;
  40. this.w = v1.w - v2.w;
  41. },
  42. subSelf: function ( v ) {
  43. this.x -= v.x;
  44. this.y -= v.y;
  45. this.z -= v.z;
  46. this.w -= v.w;
  47. },
  48. clone: function () {
  49. return new THREE.Vector4( this.x, this.y, this.z, this.w );
  50. },
  51. toString: function () {
  52. return 'THREE.Vector4 (' + this.x + ', ' + this.y + ', ' + this.z + ', ' + this.w + ')';
  53. }
  54. };
粤ICP备19079148号