Mesh.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. function Mesh() {
  2. Object.defineProperties(this, {
  3. 'indexedMesh': { enumerable: true, configurable: true, get: Mesh.prototype.__get_indexedMesh, set: Mesh.prototype.__set_indexedMesh}
  4. })
  5. }
  6. Mesh.prototype.__get_indexedMesh = function() {
  7. return Polycode.Mesh__get_indexedMesh(this.__ptr)
  8. }
  9. Mesh.prototype.__set_indexedMesh = function(val) {
  10. Polycode.Mesh__set_indexedMesh(this.__ptr, val)
  11. }
  12. Mesh.prototype.loadMesh = function(fileName) {
  13. Polycode.Mesh_loadMesh(this.__ptr, fileName)
  14. }
  15. Mesh.prototype.clearMesh = function() {
  16. Polycode.Mesh_clearMesh(this.__ptr)
  17. }
  18. Mesh.prototype.saveToFile = function(fileName,writeNormals,writeTangents,writeColors,writeBoneWeights,writeUVs,writeSecondaryUVs) {
  19. Polycode.Mesh_saveToFile(this.__ptr, fileName,writeNormals,writeTangents,writeColors,writeBoneWeights,writeUVs,writeSecondaryUVs)
  20. }
  21. Mesh.prototype.loadFromFile = function(inFile) {
  22. Polycode.Mesh_loadFromFile(this.__ptr, inFile)
  23. }
  24. Mesh.prototype.getVertexCount = function() {
  25. return Polycode.Mesh_getVertexCount(this.__ptr)
  26. }
  27. Mesh.prototype.createPlane = function(w,h,tilingValue) {
  28. Polycode.Mesh_createPlane(this.__ptr, w,h,tilingValue)
  29. }
  30. Mesh.prototype.createVPlane = function(w,h,tilingValue) {
  31. Polycode.Mesh_createVPlane(this.__ptr, w,h,tilingValue)
  32. }
  33. Mesh.prototype.createCircle = function(w,h,numSegments,tilingValue) {
  34. Polycode.Mesh_createCircle(this.__ptr, w,h,numSegments,tilingValue)
  35. }
  36. Mesh.prototype.createLineCircle = function(w,h,numSegments,tilingValue) {
  37. Polycode.Mesh_createLineCircle(this.__ptr, w,h,numSegments,tilingValue)
  38. }
  39. Mesh.prototype.createTorus = function(radius,tubeRadius,segmentsW,segmentsH,tilingValue) {
  40. Polycode.Mesh_createTorus(this.__ptr, radius,tubeRadius,segmentsW,segmentsH,tilingValue)
  41. }
  42. Mesh.prototype.createBox = function(w,d,h,tilingValue) {
  43. Polycode.Mesh_createBox(this.__ptr, w,d,h,tilingValue)
  44. }
  45. Mesh.prototype.createSphere = function(radius,numRings,numSegments,tilingValue) {
  46. Polycode.Mesh_createSphere(this.__ptr, radius,numRings,numSegments,tilingValue)
  47. }
  48. Mesh.prototype.createIcosphere = function(radius,subdivisions) {
  49. Polycode.Mesh_createIcosphere(this.__ptr, radius,subdivisions)
  50. }
  51. Mesh.prototype.createOctosphere = function(radius,subdivisions) {
  52. Polycode.Mesh_createOctosphere(this.__ptr, radius,subdivisions)
  53. }
  54. Mesh.prototype.createCylinder = function(height,radius,numSegments,capped,tilingValue) {
  55. Polycode.Mesh_createCylinder(this.__ptr, height,radius,numSegments,capped,tilingValue)
  56. }
  57. Mesh.prototype.createCone = function(height,radius,numSegments,tilingValue) {
  58. Polycode.Mesh_createCone(this.__ptr, height,radius,numSegments,tilingValue)
  59. }
  60. Mesh.prototype.recenterMesh = function() {
  61. var retVal = new Vector3()
  62. retVal.__ptr = Polycode.Mesh_recenterMesh(this.__ptr)
  63. return retVal
  64. }
  65. Mesh.prototype.setVertexAtOffset = function(offset,x,y,z) {
  66. Polycode.Mesh_setVertexAtOffset(this.__ptr, offset,x,y,z)
  67. }
  68. Mesh.prototype.addVertexWithUVAndNormal = function(x,y,z,u,v,nx,ny,nz) {
  69. Polycode.Mesh_addVertexWithUVAndNormal(this.__ptr, x,y,z,u,v,nx,ny,nz)
  70. }
  71. Mesh.prototype.addTexCoord = function(u,v) {
  72. Polycode.Mesh_addTexCoord(this.__ptr, u,v)
  73. }
  74. Mesh.prototype.addTexCoord2 = function(u,v) {
  75. Polycode.Mesh_addTexCoord2(this.__ptr, u,v)
  76. }
  77. Mesh.prototype.addTangent = function(x,y,z) {
  78. Polycode.Mesh_addTangent(this.__ptr, x,y,z)
  79. }
  80. Mesh.prototype.addVertexWithUV = function(x,y,z,u,v) {
  81. Polycode.Mesh_addVertexWithUV(this.__ptr, x,y,z,u,v)
  82. }
  83. Mesh.prototype.addVertex = function(x,y,z) {
  84. Polycode.Mesh_addVertex(this.__ptr, x,y,z)
  85. }
  86. Mesh.prototype.addNormal = function(nx,ny,nz) {
  87. Polycode.Mesh_addNormal(this.__ptr, nx,ny,nz)
  88. }
  89. Mesh.prototype.addBoneAssignments = function(b1Weight,b1Index,b2Weight,b2Index,b3Weight,b3Index,b4Weight,b4Index) {
  90. Polycode.Mesh_addBoneAssignments(this.__ptr, b1Weight,b1Index,b2Weight,b2Index,b3Weight,b3Index,b4Weight,b4Index)
  91. }
  92. Mesh.prototype.addColor = function(r,g,b,a) {
  93. Polycode.Mesh_addColor(this.__ptr, r,g,b,a)
  94. }
  95. Mesh.prototype.getVertexPosition = function(vertexOffset) {
  96. var retVal = new Vector3()
  97. retVal.__ptr = Polycode.Mesh_getVertexPosition(this.__ptr, vertexOffset)
  98. return retVal
  99. }
  100. Mesh.prototype.getVertexPositionAtIndex = function(index) {
  101. var retVal = new Vector3()
  102. retVal.__ptr = Polycode.Mesh_getVertexPositionAtIndex(this.__ptr, index)
  103. return retVal
  104. }
  105. Mesh.prototype.getVertexTexCoord = function(vertexOffset) {
  106. var retVal = new Vector2()
  107. retVal.__ptr = Polycode.Mesh_getVertexTexCoord(this.__ptr, vertexOffset)
  108. return retVal
  109. }
  110. Mesh.prototype.getVertexTexCoordAtIndex = function(index) {
  111. var retVal = new Vector2()
  112. retVal.__ptr = Polycode.Mesh_getVertexTexCoordAtIndex(this.__ptr, index)
  113. return retVal
  114. }
  115. Mesh.prototype.Copy = function() {
  116. var retVal = new Mesh()
  117. retVal.__ptr = Polycode.Mesh_Copy(this.__ptr)
  118. return retVal
  119. }
  120. Mesh.prototype.getRadius = function() {
  121. return Polycode.Mesh_getRadius(this.__ptr)
  122. }
  123. Mesh.prototype.calculateNormals = function() {
  124. Polycode.Mesh_calculateNormals(this.__ptr)
  125. }
  126. Mesh.prototype.calculateTangents = function() {
  127. Polycode.Mesh_calculateTangents(this.__ptr)
  128. }
  129. Mesh.prototype.getMeshType = function() {
  130. return Polycode.Mesh_getMeshType(this.__ptr)
  131. }
  132. Mesh.prototype.setMeshType = function(newType) {
  133. Polycode.Mesh_setMeshType(this.__ptr, newType)
  134. }
  135. Mesh.prototype.getIndexGroupSize = function() {
  136. return Polycode.Mesh_getIndexGroupSize(this.__ptr)
  137. }
  138. Mesh.prototype.calculateBBox = function() {
  139. var retVal = new Vector3()
  140. retVal.__ptr = Polycode.Mesh_calculateBBox(this.__ptr)
  141. return retVal
  142. }
  143. Mesh.prototype.hasVertexBuffer = function() {
  144. return Polycode.Mesh_hasVertexBuffer(this.__ptr)
  145. }
  146. Mesh.prototype.addIndexedFace = function(i1,i2) {
  147. Polycode.Mesh_addIndexedFace(this.__ptr, i1,i2)
  148. }
  149. Mesh.prototype.addIndex = function(index) {
  150. Polycode.Mesh_addIndex(this.__ptr, index)
  151. }
  152. Mesh.prototype.removeVertexRange = function(beginRemoveVertex,vertexRemovalCount) {
  153. Polycode.Mesh_removeVertexRange(this.__ptr, beginRemoveVertex,vertexRemovalCount)
  154. }
  155. Mesh.prototype.removeFace = function(faceIndex) {
  156. Polycode.Mesh_removeFace(this.__ptr, faceIndex)
  157. }
  158. Mesh.prototype.removeUnusedVertices = function() {
  159. return Polycode.Mesh_removeUnusedVertices(this.__ptr)
  160. }
  161. Mesh.prototype.getIndexCount = function() {
  162. return Polycode.Mesh_getIndexCount(this.__ptr)
  163. }
  164. Mesh.prototype.subdivideToRadius = function(radius,subdivisions) {
  165. Polycode.Mesh_subdivideToRadius(this.__ptr, radius,subdivisions)
  166. }
  167. Mesh.prototype.saveAsOBJ = function(fileName) {
  168. Polycode.Mesh_saveAsOBJ(this.__ptr, fileName)
  169. }
  170. Mesh.prototype.normalizeBoneWeights = function() {
  171. Polycode.Mesh_normalizeBoneWeights(this.__ptr)
  172. }