Matrix4.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. function Matrix4() {
  2. }
  3. Duktape.fin(Matrix4.prototype, function (x) {
  4. if (x === Matrix4.prototype) {
  5. return;
  6. }
  7. Polycode.Matrix4__delete(x.__ptr)
  8. })
  9. Matrix4.prototype.identity = function() {
  10. Polycode.Matrix4_identity(this.__ptr)
  11. }
  12. Matrix4.prototype.rotateVector = function(v2) {
  13. var retVal = new Vector3()
  14. retVal.__ptr = Polycode.Matrix4_rotateVector(this.__ptr, v2)
  15. return retVal
  16. }
  17. Matrix4.prototype.getPosition = function() {
  18. var retVal = new Vector3()
  19. retVal.__ptr = Polycode.Matrix4_getPosition(this.__ptr)
  20. return retVal
  21. }
  22. Matrix4.prototype.multiplyWithPerspective = function(v2) {
  23. var retVal = new Vector3()
  24. retVal.__ptr = Polycode.Matrix4_multiplyWithPerspective(this.__ptr, v2)
  25. return retVal
  26. }
  27. Matrix4.prototype.multVector3 = function(v2) {
  28. var retVal = new Vector3()
  29. retVal.__ptr = Polycode.Matrix4_multVector3(this.__ptr, v2)
  30. return retVal
  31. }
  32. Matrix4.prototype.multVector4 = function(v2) {
  33. var retVal = new Vector4()
  34. retVal.__ptr = Polycode.Matrix4_multVector4(this.__ptr, v2)
  35. return retVal
  36. }
  37. Matrix4.prototype.Translate = function(x,y,z) {
  38. Polycode.Matrix4_Translate(this.__ptr, x,y,z)
  39. }
  40. Matrix4.prototype.setPosition = function(x,y,z) {
  41. Polycode.Matrix4_setPosition(this.__ptr, x,y,z)
  42. }
  43. Matrix4.prototype.setScale = function(scale) {
  44. Polycode.Matrix4_setScale(this.__ptr, scale)
  45. }
  46. Matrix4.prototype.getEulerAngles = function(ax,ay,az) {
  47. Polycode.Matrix4_getEulerAngles(this.__ptr, ax,ay,az)
  48. }
  49. Matrix4.prototype.transpose = function() {
  50. var retVal = new Matrix4()
  51. retVal.__ptr = Polycode.Matrix4_transpose(this.__ptr)
  52. return retVal
  53. }
  54. Matrix4.prototype.Inverse = function() {
  55. var retVal = new Matrix4()
  56. retVal.__ptr = Polycode.Matrix4_Inverse(this.__ptr)
  57. return retVal
  58. }
  59. Matrix4.prototype.inverseAffine = function() {
  60. var retVal = new Matrix4()
  61. retVal.__ptr = Polycode.Matrix4_inverseAffine(this.__ptr)
  62. return retVal
  63. }
  64. Matrix4.prototype.determinant = function() {
  65. return Polycode.Matrix4_determinant(this.__ptr)
  66. }
  67. Matrix4.prototype.setOrthoProjection = function(left,right,bottom,top,zNear,zFar) {
  68. Polycode.Matrix4_setOrthoProjection(this.__ptr, left,right,bottom,top,zNear,zFar)
  69. }
  70. Matrix4.prototype.setProjectionFrustum = function(left,right,bottom,top,zNear,zFar) {
  71. Polycode.Matrix4_setProjectionFrustum(this.__ptr, left,right,bottom,top,zNear,zFar)
  72. }
  73. Matrix4.prototype.setProjection = function(fov,aspect,zNear,zFar) {
  74. Polycode.Matrix4_setProjection(this.__ptr, fov,aspect,zNear,zFar)
  75. }