Ray.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. function Ray() {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.Ray()
  4. }
  5. Object.defineProperties(this, {
  6. 'origin': { enumerable: true, configurable: true, get: Ray.prototype.__get_origin, set: Ray.prototype.__set_origin},
  7. 'direction': { enumerable: true, configurable: true, get: Ray.prototype.__get_direction, set: Ray.prototype.__set_direction},
  8. 'inv_direction': { enumerable: true, configurable: true, get: Ray.prototype.__get_inv_direction, set: Ray.prototype.__set_inv_direction}
  9. })
  10. }
  11. Ray.prototype.__get_origin = function() {
  12. var retVal = new Vector3()
  13. retVal.__ptr = Polycode.Ray__get_origin(this.__ptr)
  14. return retVal
  15. }
  16. Ray.prototype.__set_origin = function(val) {
  17. Polycode.Ray__set_origin(this.__ptr, val.__ptr)
  18. }
  19. Ray.prototype.__get_direction = function() {
  20. var retVal = new Vector3()
  21. retVal.__ptr = Polycode.Ray__get_direction(this.__ptr)
  22. return retVal
  23. }
  24. Ray.prototype.__set_direction = function(val) {
  25. Polycode.Ray__set_direction(this.__ptr, val.__ptr)
  26. }
  27. Ray.prototype.__get_inv_direction = function() {
  28. var retVal = new Vector3()
  29. retVal.__ptr = Polycode.Ray__get_inv_direction(this.__ptr)
  30. return retVal
  31. }
  32. Ray.prototype.__set_inv_direction = function(val) {
  33. Polycode.Ray__set_inv_direction(this.__ptr, val.__ptr)
  34. }
  35. Duktape.fin(Ray.prototype, function (x) {
  36. if (x === Ray.prototype) {
  37. return;
  38. }
  39. Polycode.Ray__delete(x.__ptr)
  40. })
  41. Ray.prototype.boxIntersect = function(box,transformMatrix,vnear,vfar) {
  42. return Polycode.Ray_boxIntersect(this.__ptr, box, transformMatrix, vnear, vfar)
  43. }
  44. Ray.prototype.planeIntersectPoint = function(planeNormal,planeDistance) {
  45. var retVal = new Vector3()
  46. retVal.__ptr = Polycode.Ray_planeIntersectPoint(this.__ptr, planeNormal, planeDistance)
  47. return retVal
  48. }
  49. Ray.prototype.tranformByMatrix = function(matrix) {
  50. var retVal = new Ray()
  51. retVal.__ptr = Polycode.Ray_tranformByMatrix(this.__ptr, matrix)
  52. return retVal
  53. }
  54. Ray.prototype.closestPointOnRay = function(point) {
  55. var retVal = new Vector3()
  56. retVal.__ptr = Polycode.Ray_closestPointOnRay(this.__ptr, point)
  57. return retVal
  58. }
  59. Ray.prototype.closestPointsBetween = function(ray2,point1,point2) {
  60. return Polycode.Ray_closestPointsBetween(this.__ptr, ray2, point1.__ptr, point2.__ptr)
  61. }
  62. Ray.prototype.polygonIntersect = function(v1,v2,v3) {
  63. return Polycode.Ray_polygonIntersect(this.__ptr, v1, v2, v3)
  64. }