Ray.js 2.2 KB

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