Camera.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. require('Polycode/Entity')
  2. function Camera(parentScene) {
  3. if(arguments[0] != "__skip_ptr__") {
  4. this.__ptr = Polycode.Camera(parentScene)
  5. }
  6. Object.defineProperties(this, {
  7. 'frustumCulling': { enumerable: true, configurable: true, get: Camera.prototype.__get_frustumCulling, set: Camera.prototype.__set_frustumCulling},
  8. 'topLeftOrtho': { enumerable: true, configurable: true, get: Camera.prototype.__get_topLeftOrtho, set: Camera.prototype.__set_topLeftOrtho},
  9. 'cameraShift': { enumerable: true, configurable: true, get: Camera.prototype.__get_cameraShift, set: Camera.prototype.__set_cameraShift}
  10. })
  11. }
  12. Camera.ORTHO_SIZE_MANUAL = 0
  13. Camera.ORTHO_SIZE_LOCK_HEIGHT = 1
  14. Camera.ORTHO_SIZE_LOCK_WIDTH = 2
  15. Camera.ORTHO_SIZE_VIEWPORT = 3
  16. Camera.PERSPECTIVE_FOV = 4
  17. Camera.PERSPECTIVE_FRUSTUM = 5
  18. Camera.MANUAL_MATRIX = 6
  19. Camera.prototype = Object.create(Entity.prototype)
  20. Camera.prototype.__get_frustumCulling = function() {
  21. return Polycode.Camera__get_frustumCulling(this.__ptr)
  22. }
  23. Camera.prototype.__set_frustumCulling = function(val) {
  24. Polycode.Camera__set_frustumCulling(this.__ptr, val)
  25. }
  26. Camera.prototype.__get_topLeftOrtho = function() {
  27. return Polycode.Camera__get_topLeftOrtho(this.__ptr)
  28. }
  29. Camera.prototype.__set_topLeftOrtho = function(val) {
  30. Polycode.Camera__set_topLeftOrtho(this.__ptr, val)
  31. }
  32. Camera.prototype.__get_cameraShift = function() {
  33. var retVal = new Vector2()
  34. retVal.__ptr = Polycode.Camera__get_cameraShift(this.__ptr)
  35. return retVal
  36. }
  37. Camera.prototype.__set_cameraShift = function(val) {
  38. Polycode.Camera__set_cameraShift(this.__ptr, val.__ptr)
  39. }
  40. Camera.prototype.buildFrustumPlanes = function() {
  41. Polycode.Camera_buildFrustumPlanes(this.__ptr)
  42. }
  43. Camera.prototype.isSphereInFrustum = function(pos,fRadius) {
  44. return Polycode.Camera_isSphereInFrustum(this.__ptr, pos, fRadius)
  45. }
  46. Camera.prototype.isAABBInFrustum = function(aabb) {
  47. return Polycode.Camera_isAABBInFrustum(this.__ptr, aabb)
  48. }
  49. Camera.prototype.setOrthoMode = function(mode) {
  50. Polycode.Camera_setOrthoMode(this.__ptr, mode)
  51. }
  52. Camera.prototype.setOrthoSize = function(orthoSizeX,orthoSizeY) {
  53. Polycode.Camera_setOrthoSize(this.__ptr, orthoSizeX, orthoSizeY)
  54. }
  55. Camera.prototype.setFrustumMode = function(left,right,bottom,top,front,back) {
  56. Polycode.Camera_setFrustumMode(this.__ptr, left, right, bottom, top, front, back)
  57. }
  58. Camera.prototype.getOrthoMode = function() {
  59. return Polycode.Camera_getOrthoMode(this.__ptr)
  60. }
  61. Camera.prototype.getOrthoSizeX = function() {
  62. return Polycode.Camera_getOrthoSizeX(this.__ptr)
  63. }
  64. Camera.prototype.getOrthoSizeY = function() {
  65. return Polycode.Camera_getOrthoSizeY(this.__ptr)
  66. }
  67. Camera.prototype.setFOV = function(fov) {
  68. Polycode.Camera_setFOV(this.__ptr, fov)
  69. }
  70. Camera.prototype.getFOV = function() {
  71. return Polycode.Camera_getFOV(this.__ptr)
  72. }
  73. Camera.prototype.setClippingPlanes = function(nearClipPlane,farClipPlane) {
  74. Polycode.Camera_setClippingPlanes(this.__ptr, nearClipPlane, farClipPlane)
  75. }
  76. Camera.prototype.getNearClippingPlane = function() {
  77. return Polycode.Camera_getNearClippingPlane(this.__ptr)
  78. }
  79. Camera.prototype.getFarClippingPlane = function() {
  80. return Polycode.Camera_getFarClippingPlane(this.__ptr)
  81. }
  82. Camera.prototype.setParentScene = function(parentScene) {
  83. Polycode.Camera_setParentScene(this.__ptr, parentScene.__ptr)
  84. }
  85. Camera.prototype.getParentScene = function() {
  86. var retVal = new Scene()
  87. retVal.__ptr = Polycode.Camera_getParentScene(this.__ptr)
  88. return retVal
  89. }
  90. Camera.prototype.createProjectionMatrix = function() {
  91. var retVal = new Matrix4()
  92. retVal.__ptr = Polycode.Camera_createProjectionMatrix(this.__ptr)
  93. return retVal
  94. }
  95. Camera.prototype.hasFilterShader = function() {
  96. return Polycode.Camera_hasFilterShader(this.__ptr)
  97. }
  98. Camera.prototype.drawFilter = function(targetBuffer) {
  99. Polycode.Camera_drawFilter(this.__ptr, targetBuffer)
  100. }
  101. Camera.prototype.setPostFilter = function(material) {
  102. Polycode.Camera_setPostFilter(this.__ptr, material)
  103. }
  104. Camera.prototype.setPostFilterByName = function(shaderName) {
  105. Polycode.Camera_setPostFilterByName(this.__ptr, shaderName)
  106. }
  107. Camera.prototype.removePostFilter = function() {
  108. Polycode.Camera_removePostFilter(this.__ptr)
  109. }
  110. Camera.prototype.getScreenShaderMaterial = function() {
  111. var retVal = new Material()
  112. retVal.__ptr = Polycode.Camera_getScreenShaderMaterial(this.__ptr)
  113. return retVal
  114. }
  115. Camera.prototype.Clone = function(deepClone,ignoreEditorOnly) {
  116. var retVal = new Entity()
  117. retVal.__ptr = Polycode.Camera_Clone(this.__ptr, deepClone, ignoreEditorOnly)
  118. return retVal
  119. }
  120. Camera.prototype.applyClone = function(clone,deepClone,ignoreEditorOnly) {
  121. Polycode.Camera_applyClone(this.__ptr, clone.__ptr, deepClone, ignoreEditorOnly)
  122. }
  123. Camera.prototype.getProjectionMatrix = function() {
  124. var retVal = new Matrix4()
  125. retVal.__ptr = Polycode.Camera_getProjectionMatrix(this.__ptr)
  126. return retVal
  127. }
  128. Camera.prototype.setCustomProjectionMatrix = function(matrix) {
  129. Polycode.Camera_setCustomProjectionMatrix(this.__ptr, matrix)
  130. }
  131. Camera.prototype.getViewport = function() {
  132. var retVal = new Rectangle()
  133. retVal.__ptr = Polycode.Camera_getViewport(this.__ptr)
  134. return retVal
  135. }
  136. Camera.prototype.setViewport = function(viewport) {
  137. Polycode.Camera_setViewport(this.__ptr, viewport)
  138. }
  139. Camera.prototype.setOrthoSizeMode = function(orthoSizeMode) {
  140. Polycode.Camera_setOrthoSizeMode(this.__ptr, orthoSizeMode)
  141. }
  142. Camera.prototype.getOrthoSizeMode = function() {
  143. return Polycode.Camera_getOrthoSizeMode(this.__ptr)
  144. }
  145. Camera.prototype.setProjectionMode = function(mode) {
  146. Polycode.Camera_setProjectionMode(this.__ptr, mode)
  147. }
  148. Camera.prototype.getProjectionMode = function() {
  149. return Polycode.Camera_getProjectionMode(this.__ptr)
  150. }
  151. Camera.prototype.projectRayFrom2DCoordinate = function(coordinate,viewport) {
  152. var retVal = new Vector3()
  153. retVal.__ptr = Polycode.Camera_projectRayFrom2DCoordinate(this.__ptr, coordinate, viewport)
  154. return retVal
  155. }
  156. Camera.prototype.renderFullScreenQuad = function(drawBuffer,shaderPass) {
  157. Polycode.Camera_renderFullScreenQuad(this.__ptr, drawBuffer.__ptr, shaderPass)
  158. }
  159. Camera.prototype.getShaderPass = function(index) {
  160. var retVal = new ShaderPass()
  161. retVal.__ptr = Polycode.Camera_getShaderPass(this.__ptr, index)
  162. return retVal
  163. }
  164. Camera.prototype.getNumShaderPasses = function() {
  165. return Polycode.Camera_getNumShaderPasses(this.__ptr)
  166. }