Vector3.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. function Vector3() {
  2. Object.defineProperties(this, {
  3. 'x': { enumerable: true, configurable: true, get: Vector3.prototype.__get_x, set: Vector3.prototype.__set_x},
  4. 'y': { enumerable: true, configurable: true, get: Vector3.prototype.__get_y, set: Vector3.prototype.__set_y},
  5. 'z': { enumerable: true, configurable: true, get: Vector3.prototype.__get_z, set: Vector3.prototype.__set_z}
  6. })
  7. }
  8. Vector3.prototype.__get_x = function() {
  9. return Polycode.Vector3__get_x(this.__ptr)
  10. }
  11. Vector3.prototype.__set_x = function(val) {
  12. Polycode.Vector3__set_x(this.__ptr, val)
  13. }
  14. Vector3.prototype.__get_y = function() {
  15. return Polycode.Vector3__get_y(this.__ptr)
  16. }
  17. Vector3.prototype.__set_y = function(val) {
  18. Polycode.Vector3__set_y(this.__ptr, val)
  19. }
  20. Vector3.prototype.__get_z = function() {
  21. return Polycode.Vector3__get_z(this.__ptr)
  22. }
  23. Vector3.prototype.__set_z = function(val) {
  24. Polycode.Vector3__set_z(this.__ptr, val)
  25. }
  26. Vector3.prototype.set = function(x,y,z) {
  27. Polycode.Vector3_set(this.__ptr, x,y,z)
  28. }
  29. Vector3.prototype.distance = function(vec2) {
  30. return Polycode.Vector3_distance(this.__ptr, vec2)
  31. }
  32. Vector3.prototype.angleBetween = function(dest) {
  33. return Polycode.Vector3_angleBetween(this.__ptr, dest)
  34. }
  35. Vector3.prototype.length = function() {
  36. return Polycode.Vector3_length(this.__ptr)
  37. }
  38. Vector3.prototype.lengthSquared = function() {
  39. return Polycode.Vector3_lengthSquared(this.__ptr)
  40. }
  41. Vector3.prototype.setLength = function(newLength) {
  42. var retVal = new Vector3()
  43. retVal.__ptr = Polycode.Vector3_setLength(this.__ptr, newLength)
  44. return retVal
  45. }
  46. Vector3.prototype.dot = function(u) {
  47. return Polycode.Vector3_dot(this.__ptr, u)
  48. }
  49. Vector3.prototype.crossProduct = function(vec2) {
  50. var retVal = new Vector3()
  51. retVal.__ptr = Polycode.Vector3_crossProduct(this.__ptr, vec2)
  52. return retVal
  53. }
  54. Vector3.prototype.Normalize = function() {
  55. Polycode.Vector3_Normalize(this.__ptr)
  56. }