MeshGeometry.js 7.6 KB

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