Vector4.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. function Vector4(x,y,z,w) {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.Vector4(x,y,z,w)
  4. }
  5. Object.defineProperties(this, {
  6. 'x': { enumerable: true, configurable: true, get: Vector4.prototype.__get_x, set: Vector4.prototype.__set_x},
  7. 'y': { enumerable: true, configurable: true, get: Vector4.prototype.__get_y, set: Vector4.prototype.__set_y},
  8. 'z': { enumerable: true, configurable: true, get: Vector4.prototype.__get_z, set: Vector4.prototype.__set_z},
  9. 'w': { enumerable: true, configurable: true, get: Vector4.prototype.__get_w, set: Vector4.prototype.__set_w}
  10. })
  11. }
  12. Vector4.prototype.__get_x = function() {
  13. return Polycode.Vector4__get_x(this.__ptr)
  14. }
  15. Vector4.prototype.__set_x = function(val) {
  16. Polycode.Vector4__set_x(this.__ptr, val)
  17. }
  18. Vector4.prototype.__get_y = function() {
  19. return Polycode.Vector4__get_y(this.__ptr)
  20. }
  21. Vector4.prototype.__set_y = function(val) {
  22. Polycode.Vector4__set_y(this.__ptr, val)
  23. }
  24. Vector4.prototype.__get_z = function() {
  25. return Polycode.Vector4__get_z(this.__ptr)
  26. }
  27. Vector4.prototype.__set_z = function(val) {
  28. Polycode.Vector4__set_z(this.__ptr, val)
  29. }
  30. Vector4.prototype.__get_w = function() {
  31. return Polycode.Vector4__get_w(this.__ptr)
  32. }
  33. Vector4.prototype.__set_w = function(val) {
  34. Polycode.Vector4__set_w(this.__ptr, val)
  35. }
  36. Duktape.fin(Vector4.prototype, function (x) {
  37. if (x === Vector4.prototype) {
  38. return;
  39. }
  40. Polycode.Vector4__delete(x.__ptr)
  41. })
  42. Vector4.prototype.set = function(x,y,z,w) {
  43. Polycode.Vector4_set(this.__ptr, x, y, z, w)
  44. }
  45. Vector4.prototype.dot = function(u) {
  46. return Polycode.Vector4_dot(this.__ptr, u)
  47. }