MeshGeometry.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. function MeshGeometry() {
  2. if(arguments[0] != "__skip_ptr__") {
  3. this.__ptr = Polycode.MeshGeometry()
  4. }
  5. Object.defineProperties(this, {
  6. 'meshType': { enumerable: true, configurable: true, get: MeshGeometry.prototype.__get_meshType, set: MeshGeometry.prototype.__set_meshType},
  7. 'dataChanged': { enumerable: true, configurable: true, get: MeshGeometry.prototype.__get_dataChanged, set: MeshGeometry.prototype.__set_dataChanged},
  8. 'indexedMesh': { enumerable: true, configurable: true, get: MeshGeometry.prototype.__get_indexedMesh, set: MeshGeometry.prototype.__set_indexedMesh}
  9. })
  10. }
  11. MeshGeometry.TRISTRIP_MESH = 0
  12. MeshGeometry.TRI_MESH = 1
  13. MeshGeometry.TRIFAN_MESH = 2
  14. MeshGeometry.LINE_MESH = 4
  15. MeshGeometry.POINT_MESH = 5
  16. MeshGeometry.LINE_STRIP_MESH = 6
  17. MeshGeometry.LINE_LOOP_MESH = 7
  18. MeshGeometry.prototype.__get_meshType = function() {
  19. return Polycode.MeshGeometry__get_meshType(this.__ptr)
  20. }
  21. MeshGeometry.prototype.__set_meshType = function(val) {
  22. Polycode.MeshGeometry__set_meshType(this.__ptr, val)
  23. }
  24. MeshGeometry.prototype.__get_dataChanged = function() {
  25. return Polycode.MeshGeometry__get_dataChanged(this.__ptr)
  26. }
  27. MeshGeometry.prototype.__set_dataChanged = function(val) {
  28. Polycode.MeshGeometry__set_dataChanged(this.__ptr, val)
  29. }
  30. MeshGeometry.prototype.__get_indexedMesh = function() {
  31. return Polycode.MeshGeometry__get_indexedMesh(this.__ptr)
  32. }
  33. MeshGeometry.prototype.__set_indexedMesh = function(val) {
  34. Polycode.MeshGeometry__set_indexedMesh(this.__ptr, val)
  35. }
  36. Duktape.fin(MeshGeometry.prototype, function (x) {
  37. if (x === MeshGeometry.prototype) {
  38. return;
  39. }
  40. Polycode.MeshGeometry__delete(x.__ptr)
  41. })
  42. MeshGeometry.prototype.clearMesh = function() {
  43. Polycode.MeshGeometry_clearMesh(this.__ptr)
  44. }
  45. MeshGeometry.prototype.getVertexCount = function() {
  46. return Polycode.MeshGeometry_getVertexCount(this.__ptr)
  47. }
  48. MeshGeometry.prototype.createPlane = function(w,h,tilingValue) {
  49. Polycode.MeshGeometry_createPlane(this.__ptr, w, h, tilingValue)
  50. }
  51. MeshGeometry.prototype.createVPlane = function(w,h,tilingValue) {
  52. Polycode.MeshGeometry_createVPlane(this.__ptr, w, h, tilingValue)
  53. }
  54. MeshGeometry.prototype.createCircle = function(w,h,numSegments,tilingValue) {
  55. Polycode.MeshGeometry_createCircle(this.__ptr, w, h, numSegments, tilingValue)
  56. }
  57. MeshGeometry.prototype.createLineCircle = function(w,h,numSegments,tilingValue) {
  58. Polycode.MeshGeometry_createLineCircle(this.__ptr, w, h, numSegments, tilingValue)
  59. }
  60. MeshGeometry.prototype.createTorus = function(radius,tubeRadius,segmentsW,segmentsH,tilingValue) {
  61. Polycode.MeshGeometry_createTorus(this.__ptr, radius, tubeRadius, segmentsW, segmentsH, tilingValue)
  62. }
  63. MeshGeometry.prototype.createBox = function(w,d,h,tilingValue) {
  64. Polycode.MeshGeometry_createBox(this.__ptr, w, d, h, tilingValue)
  65. }
  66. MeshGeometry.prototype.createSphere = function(radius,numRings,numSegments,tilingValue) {
  67. Polycode.MeshGeometry_createSphere(this.__ptr, radius, numRings, numSegments, tilingValue)
  68. }
  69. MeshGeometry.prototype.createIcosphere = function(radius,subdivisions) {
  70. Polycode.MeshGeometry_createIcosphere(this.__ptr, radius, subdivisions)
  71. }
  72. MeshGeometry.prototype.createOctosphere = function(radius,subdivisions) {
  73. Polycode.MeshGeometry_createOctosphere(this.__ptr, radius, subdivisions)
  74. }
  75. MeshGeometry.prototype.createCylinder = function(height,radius,numSegments,capped,tilingValue) {
  76. Polycode.MeshGeometry_createCylinder(this.__ptr, height, radius, numSegments, capped, tilingValue)
  77. }
  78. MeshGeometry.prototype.createCone = function(height,radius,numSegments,tilingValue) {
  79. Polycode.MeshGeometry_createCone(this.__ptr, height, radius, numSegments, tilingValue)
  80. }
  81. MeshGeometry.prototype.recenterMesh = function() {
  82. var retVal = new Vector3("__skip_ptr__")
  83. retVal.__ptr = Polycode.MeshGeometry_recenterMesh(this.__ptr)
  84. return retVal
  85. }
  86. MeshGeometry.prototype.setVertexAtOffset = function(offset,x,y,z) {
  87. Polycode.MeshGeometry_setVertexAtOffset(this.__ptr, offset, x, y, z)
  88. }
  89. MeshGeometry.prototype.addVertexWithUVAndNormal = function(x,y,z,u,v,nx,ny,nz) {
  90. Polycode.MeshGeometry_addVertexWithUVAndNormal(this.__ptr, x, y, z, u, v, nx, ny, nz)
  91. }
  92. MeshGeometry.prototype.addTexCoord = function(u,v) {
  93. Polycode.MeshGeometry_addTexCoord(this.__ptr, u, v)
  94. }
  95. MeshGeometry.prototype.addTexCoord2 = function(u,v) {
  96. Polycode.MeshGeometry_addTexCoord2(this.__ptr, u, v)
  97. }
  98. MeshGeometry.prototype.addTangent = function(x,y,z) {
  99. Polycode.MeshGeometry_addTangent(this.__ptr, x, y, z)
  100. }
  101. MeshGeometry.prototype.addVertexWithUV = function(x,y,z,u,v) {
  102. Polycode.MeshGeometry_addVertexWithUV(this.__ptr, x, y, z, u, v)
  103. }
  104. MeshGeometry.prototype.addVertex = function(x,y,z) {
  105. Polycode.MeshGeometry_addVertex(this.__ptr, x, y, z)
  106. }
  107. MeshGeometry.prototype.addNormal = function(nx,ny,nz) {
  108. Polycode.MeshGeometry_addNormal(this.__ptr, nx, ny, nz)
  109. }
  110. MeshGeometry.prototype.addBoneAssignments = function(b1Weight,b1Index,b2Weight,b2Index,b3Weight,b3Index,b4Weight,b4Index) {
  111. Polycode.MeshGeometry_addBoneAssignments(this.__ptr, b1Weight, b1Index, b2Weight, b2Index, b3Weight, b3Index, b4Weight, b4Index)
  112. }
  113. MeshGeometry.prototype.addColor = function(r,g,b,a) {
  114. Polycode.MeshGeometry_addColor(this.__ptr, r, g, b, a)
  115. }
  116. MeshGeometry.prototype.getVertexPosition = function(vertexOffset) {
  117. var retVal = new Vector3("__skip_ptr__")
  118. retVal.__ptr = Polycode.MeshGeometry_getVertexPosition(this.__ptr, vertexOffset)
  119. return retVal
  120. }
  121. MeshGeometry.prototype.getVertexPositionAtIndex = function(index) {
  122. var retVal = new Vector3("__skip_ptr__")
  123. retVal.__ptr = Polycode.MeshGeometry_getVertexPositionAtIndex(this.__ptr, index)
  124. return retVal
  125. }
  126. MeshGeometry.prototype.getVertexTexCoord = function(vertexOffset) {
  127. var retVal = new Vector2("__skip_ptr__")
  128. retVal.__ptr = Polycode.MeshGeometry_getVertexTexCoord(this.__ptr, vertexOffset)
  129. return retVal
  130. }
  131. MeshGeometry.prototype.getVertexTexCoordAtIndex = function(index) {
  132. var retVal = new Vector2("__skip_ptr__")
  133. retVal.__ptr = Polycode.MeshGeometry_getVertexTexCoordAtIndex(this.__ptr, index)
  134. return retVal
  135. }
  136. MeshGeometry.prototype.getRadius = function() {
  137. return Polycode.MeshGeometry_getRadius(this.__ptr)
  138. }
  139. MeshGeometry.prototype.calculateNormals = function() {
  140. Polycode.MeshGeometry_calculateNormals(this.__ptr)
  141. }
  142. MeshGeometry.prototype.calculateTangents = function() {
  143. Polycode.MeshGeometry_calculateTangents(this.__ptr)
  144. }
  145. MeshGeometry.prototype.getMeshType = function() {
  146. return Polycode.MeshGeometry_getMeshType(this.__ptr)
  147. }
  148. MeshGeometry.prototype.setMeshType = function(newType) {
  149. Polycode.MeshGeometry_setMeshType(this.__ptr, newType)
  150. }
  151. MeshGeometry.prototype.getIndexGroupSize = function() {
  152. return Polycode.MeshGeometry_getIndexGroupSize(this.__ptr)
  153. }
  154. MeshGeometry.prototype.calculateBBox = function() {
  155. var retVal = new Vector3("__skip_ptr__")
  156. retVal.__ptr = Polycode.MeshGeometry_calculateBBox(this.__ptr)
  157. return retVal
  158. }
  159. MeshGeometry.prototype.addIndexedFace = function(i1,i2) {
  160. Polycode.MeshGeometry_addIndexedFace(this.__ptr, i1, i2)
  161. }
  162. MeshGeometry.prototype.addIndex = function(index) {
  163. Polycode.MeshGeometry_addIndex(this.__ptr, index)
  164. }
  165. MeshGeometry.prototype.removeVertexRange = function(beginRemoveVertex,vertexRemovalCount) {
  166. Polycode.MeshGeometry_removeVertexRange(this.__ptr, beginRemoveVertex, vertexRemovalCount)
  167. }
  168. MeshGeometry.prototype.removeFace = function(faceIndex) {
  169. Polycode.MeshGeometry_removeFace(this.__ptr, faceIndex)
  170. }
  171. MeshGeometry.prototype.removeUnusedVertices = function() {
  172. return Polycode.MeshGeometry_removeUnusedVertices(this.__ptr)
  173. }
  174. MeshGeometry.prototype.getIndexCount = function() {
  175. return Polycode.MeshGeometry_getIndexCount(this.__ptr)
  176. }
  177. MeshGeometry.prototype.subdivideToRadius = function(radius,subdivisions) {
  178. Polycode.MeshGeometry_subdivideToRadius(this.__ptr, radius, subdivisions)
  179. }
  180. MeshGeometry.prototype.calculateFaceTangent = function(v1,v2,v3,texCoord1,texCoord2,texCoord3) {
  181. var retVal = new Vector3("__skip_ptr__")
  182. retVal.__ptr = Polycode.MeshGeometry_calculateFaceTangent(v1, v2, v3, texCoord1, texCoord2, texCoord3)
  183. return retVal
  184. }
  185. MeshGeometry.prototype.saveAsOBJ = function(fileName) {
  186. Polycode.MeshGeometry_saveAsOBJ(this.__ptr, fileName)
  187. }
  188. MeshGeometry.prototype.normalizeBoneWeights = function() {
  189. Polycode.MeshGeometry_normalizeBoneWeights(this.__ptr)
  190. }