MeshGeometry.js 7.9 KB

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