Ray.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. Ray.prototype.boxIntersect = function(box,transformMatrix,near,far) {
  33. return Polycode.Ray_boxIntersect(this.__ptr, box,transformMatrix,near,far)
  34. }
  35. Ray.prototype.planeIntersectPoint = function(planeNormal,planeDistance) {
  36. var retVal = new Vector3()
  37. retVal.__ptr = Polycode.Ray_planeIntersectPoint(this.__ptr, planeNormal,planeDistance)
  38. return retVal
  39. }
  40. Ray.prototype.tranformByMatrix = function(matrix) {
  41. var retVal = new Ray()
  42. retVal.__ptr = Polycode.Ray_tranformByMatrix(this.__ptr, matrix)
  43. return retVal
  44. }
  45. Ray.prototype.closestPointOnRay = function(point) {
  46. var retVal = new Vector3()
  47. retVal.__ptr = Polycode.Ray_closestPointOnRay(this.__ptr, point)
  48. return retVal
  49. }
  50. Ray.prototype.closestPointsBetween = function(ray2,point1,point2) {
  51. return Polycode.Ray_closestPointsBetween(this.__ptr, ray2,point1,point2)
  52. }
  53. Ray.prototype.polygonIntersect = function(v1,v2,v3) {
  54. return Polycode.Ray_polygonIntersect(this.__ptr, v1,v2,v3)
  55. }