@babylonjs/core 7.20.0 → 7.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/Bones/bone.js +3 -3
  2. package/Bones/bone.js.map +1 -1
  3. package/Bones/boneLookController.js +3 -3
  4. package/Bones/boneLookController.js.map +1 -1
  5. package/Compat/compatibilityOptions.d.ts +13 -6
  6. package/Compat/compatibilityOptions.js +20 -4
  7. package/Compat/compatibilityOptions.js.map +1 -1
  8. package/Compat/index.d.ts +1 -1
  9. package/Compat/index.js +1 -1
  10. package/Compat/index.js.map +1 -1
  11. package/Culling/boundingBox.js +5 -5
  12. package/Culling/boundingBox.js.map +1 -1
  13. package/Culling/boundingInfo.js +2 -2
  14. package/Culling/boundingInfo.js.map +1 -1
  15. package/Culling/boundingSphere.js +2 -2
  16. package/Culling/boundingSphere.js.map +1 -1
  17. package/Culling/ray.js +2 -2
  18. package/Culling/ray.js.map +1 -1
  19. package/Debug/debugLayer.d.ts +3 -0
  20. package/Debug/debugLayer.js +15 -0
  21. package/Debug/debugLayer.js.map +1 -1
  22. package/Engines/abstractEngine.js +2 -2
  23. package/Engines/abstractEngine.js.map +1 -1
  24. package/Engines/engine.js +11 -2
  25. package/Engines/engine.js.map +1 -1
  26. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +2 -2
  27. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +1 -1
  28. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
  29. package/Layers/highlightLayer.js +0 -1
  30. package/Layers/highlightLayer.js.map +1 -1
  31. package/Materials/Textures/Loaders/hdrTextureLoader.js +3 -3
  32. package/Materials/Textures/Loaders/hdrTextureLoader.js.map +1 -1
  33. package/Materials/Textures/hdrCubeTexture.js +2 -2
  34. package/Materials/Textures/hdrCubeTexture.js.map +1 -1
  35. package/Materials/Textures/renderTargetTexture.js +2 -2
  36. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  37. package/Materials/Textures/texture.js +3 -3
  38. package/Materials/Textures/texture.js.map +1 -1
  39. package/Maths/math.color.js +3 -3
  40. package/Maths/math.color.js.map +1 -1
  41. package/Maths/math.vector.js +13 -14
  42. package/Maths/math.vector.js.map +1 -1
  43. package/Meshes/Builders/boxBuilder.js +5 -5
  44. package/Meshes/Builders/boxBuilder.js.map +1 -1
  45. package/Meshes/Builders/capsuleBuilder.js +4 -4
  46. package/Meshes/Builders/capsuleBuilder.js.map +1 -1
  47. package/Meshes/Builders/cylinderBuilder.js +8 -8
  48. package/Meshes/Builders/cylinderBuilder.js.map +1 -1
  49. package/Meshes/Builders/decalBuilder.js +3 -3
  50. package/Meshes/Builders/decalBuilder.js.map +1 -1
  51. package/Meshes/Builders/discBuilder.js +3 -3
  52. package/Meshes/Builders/discBuilder.js.map +1 -1
  53. package/Meshes/Builders/goldbergBuilder.js +2 -2
  54. package/Meshes/Builders/goldbergBuilder.js.map +1 -1
  55. package/Meshes/Builders/groundBuilder.js +2 -2
  56. package/Meshes/Builders/groundBuilder.js.map +1 -1
  57. package/Meshes/Builders/icoSphereBuilder.js +2 -2
  58. package/Meshes/Builders/icoSphereBuilder.js.map +1 -1
  59. package/Meshes/Builders/planeBuilder.js +5 -5
  60. package/Meshes/Builders/planeBuilder.js.map +1 -1
  61. package/Meshes/Builders/polygonBuilder.js +4 -4
  62. package/Meshes/Builders/polygonBuilder.js.map +1 -1
  63. package/Meshes/Builders/polyhedronBuilder.js +3 -3
  64. package/Meshes/Builders/polyhedronBuilder.js.map +1 -1
  65. package/Meshes/Builders/ribbonBuilder.js +4 -4
  66. package/Meshes/Builders/ribbonBuilder.js.map +1 -1
  67. package/Meshes/Builders/sphereBuilder.js +2 -2
  68. package/Meshes/Builders/sphereBuilder.js.map +1 -1
  69. package/Meshes/Builders/tiledBoxBuilder.js +2 -2
  70. package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
  71. package/Meshes/Builders/torusBuilder.js +2 -2
  72. package/Meshes/Builders/torusBuilder.js.map +1 -1
  73. package/Meshes/Builders/torusKnotBuilder.js +2 -2
  74. package/Meshes/Builders/torusKnotBuilder.js.map +1 -1
  75. package/Meshes/geometry.js +7 -7
  76. package/Meshes/geometry.js.map +1 -1
  77. package/Misc/HighDynamicRange/hdr.d.ts +40 -42
  78. package/Misc/HighDynamicRange/hdr.js +209 -202
  79. package/Misc/HighDynamicRange/hdr.js.map +1 -1
  80. package/Misc/HighDynamicRange/index.d.ts +1 -1
  81. package/Misc/HighDynamicRange/index.js +1 -1
  82. package/Misc/HighDynamicRange/index.js.map +1 -1
  83. package/Misc/arrayTools.d.ts +12 -17
  84. package/Misc/arrayTools.js +18 -23
  85. package/Misc/arrayTools.js.map +1 -1
  86. package/Misc/dumpTools.d.ts +50 -47
  87. package/Misc/dumpTools.js +153 -143
  88. package/Misc/dumpTools.js.map +1 -1
  89. package/Misc/environmentTextureTools.js +2 -2
  90. package/Misc/environmentTextureTools.js.map +1 -1
  91. package/Misc/equirectangularCapture.js +2 -2
  92. package/Misc/equirectangularCapture.js.map +1 -1
  93. package/Misc/index.d.ts +2 -1
  94. package/Misc/index.js +2 -1
  95. package/Misc/index.js.map +1 -1
  96. package/Misc/rgbdTextureTools.js +1 -0
  97. package/Misc/rgbdTextureTools.js.map +1 -1
  98. package/Misc/screenshotTools.js +3 -3
  99. package/Misc/screenshotTools.js.map +1 -1
  100. package/Physics/v1/physicsImpostor.js +2 -2
  101. package/Physics/v1/physicsImpostor.js.map +1 -1
  102. package/Physics/v2/Plugins/havokPlugin.js +2 -2
  103. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  104. package/PostProcesses/blurPostProcess.js +0 -1
  105. package/PostProcesses/blurPostProcess.js.map +1 -1
  106. package/PostProcesses/passPostProcess.js +0 -2
  107. package/PostProcesses/passPostProcess.js.map +1 -1
  108. package/PostProcesses/postProcess.d.ts +6 -0
  109. package/PostProcesses/postProcess.js +22 -1
  110. package/PostProcesses/postProcess.js.map +1 -1
  111. package/Shaders/ShadersInclude/pbrDebug.js +1 -1
  112. package/Shaders/ShadersInclude/pbrDebug.js.map +1 -1
  113. package/ShadersWGSL/ShadersInclude/pbrDebug.js +1 -1
  114. package/ShadersWGSL/ShadersInclude/pbrDebug.js.map +1 -1
  115. package/ShadersWGSL/background.fragment.js +1 -1
  116. package/ShadersWGSL/background.fragment.js.map +1 -1
  117. package/package.json +1 -1
@@ -2,7 +2,7 @@ import { Matrix, Vector4 } from "../../Maths/math.vector.js";
2
2
  import { Color4 } from "../../Maths/math.color.js";
3
3
  import { Mesh } from "../mesh.js";
4
4
  import { VertexData } from "../mesh.vertexData.js";
5
- import { CompatibilityOptions } from "../../Compat/compatibilityOptions.js";
5
+ import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
6
6
  import { CreateGroundVertexData } from "./groundBuilder.js";
7
7
  /**
8
8
  * Creates the VertexData for a box
@@ -95,10 +95,10 @@ export function CreateBoxVertexData(options) {
95
95
  }
96
96
  // Create each face in turn.
97
97
  for (let index = 0; index < nbFaces; index++) {
98
- uvs.push(faceUV[index].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);
99
- uvs.push(faceUV[index].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);
100
- uvs.push(faceUV[index].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);
101
- uvs.push(faceUV[index].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);
98
+ uvs.push(faceUV[index].z, useOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);
99
+ uvs.push(faceUV[index].x, useOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);
100
+ uvs.push(faceUV[index].x, useOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);
101
+ uvs.push(faceUV[index].z, useOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);
102
102
  if (faceColors) {
103
103
  for (let c = 0; c < 4; c++) {
104
104
  colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
@@ -1 +1 @@
1
- {"version":3,"file":"boxBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/boxBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAanC;IACG,MAAM,OAAO,GAAG,CAAC,CAAC;IAClB,IAAI,OAAO,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAChJ,MAAM,OAAO,GAAG;QACZ,CAAC,EAAE,CAAC,EAAE,CAAC,E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S,CAAC,eAAe,CAAC,CAAC;IAErC,SAAS;IACT,WAAW,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,IAAI,CAAC,CAAC;IAEhF,OAAO,WAAW,CAAC;AACvB,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,SAAS,CACrB,IAAY,EACZ,UAcI,EAAE,EACN,QAAyB,IAAI;IAE7B,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAElC,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnF,GAAG,CAAC,+BAA+B,GAAG,OAAO,CAAC,eAAe,CAAC;IAE9D,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAEhD,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAE/C,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,gEAAgE;IAChE,SAAS;CACZ,CAAC;AAEF,eAAe;AACf,UAAU,CAAC,SAAS,GAAG,mBAAmB,CAAC;AAE3C,IAAI,CAAC,SAAS,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,SAAmB,EAAE,eAAwB,EAAQ,EAAE;IAChI,MAAM,OAAO,GAAG;QACZ,IAAI;QACJ,eAAe;QACf,SAAS;KACZ,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector4 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\nimport { CreateGroundVertexData } from \"./groundBuilder\";\r\n\r\n/**\r\n * Creates the VertexData for a box\r\n * @param options an object used to set the following optional parameters for the box, required but can be empty\r\n * * size sets the width, height and depth of the box to the value of size, optional default 1\r\n * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size\r\n * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size\r\n * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color3 elements used to set different colors to each box side\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @returns the VertexData of the box\r\n */\r\nexport function CreateBoxVertexData(options: {\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n wrap?: boolean;\r\n topBaseAt?: number;\r\n bottomBaseAt?: number;\r\n}): VertexData {\r\n const nbFaces = 6;\r\n let indices = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23];\r\n const normals = [\r\n 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0,\r\n 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,\r\n ];\r\n const uvs = [];\r\n let positions = [];\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const wrap = options.wrap || false;\r\n let topBaseAt = options.topBaseAt === void 0 ? 1 : options.topBaseAt;\r\n let bottomBaseAt = options.bottomBaseAt === void 0 ? 0 : options.bottomBaseAt;\r\n topBaseAt = (topBaseAt + 4) % 4; // places values as 0 to 3\r\n bottomBaseAt = (bottomBaseAt + 4) % 4; // places values as 0 to 3\r\n const topOrder = [2, 0, 3, 1];\r\n const bottomOrder = [2, 0, 1, 3];\r\n let topIndex = topOrder[topBaseAt];\r\n let bottomIndex = bottomOrder[bottomBaseAt];\r\n let basePositions = [\r\n 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1,\r\n 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1,\r\n ];\r\n if (wrap) {\r\n indices = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14];\r\n basePositions = [\r\n -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1,\r\n ];\r\n let topFaceBase: any = [\r\n [1, 1, 1],\r\n [-1, 1, 1],\r\n [-1, 1, -1],\r\n [1, 1, -1],\r\n ];\r\n let bottomFaceBase: any = [\r\n [-1, -1, 1],\r\n [1, -1, 1],\r\n [1, -1, -1],\r\n [-1, -1, -1],\r\n ];\r\n const topFaceOrder: any = [17, 18, 19, 16];\r\n const bottomFaceOrder: any = [22, 23, 20, 21];\r\n while (topIndex > 0) {\r\n topFaceBase.unshift(topFaceBase.pop());\r\n topFaceOrder.unshift(topFaceOrder.pop());\r\n topIndex--;\r\n }\r\n while (bottomIndex > 0) {\r\n bottomFaceBase.unshift(bottomFaceBase.pop());\r\n bottomFaceOrder.unshift(bottomFaceOrder.pop());\r\n bottomIndex--;\r\n }\r\n topFaceBase = topFaceBase.flat();\r\n bottomFaceBase = bottomFaceBase.flat();\r\n basePositions = basePositions.concat(topFaceBase).concat(bottomFaceBase);\r\n indices.push(topFaceOrder[0], topFaceOrder[2], topFaceOrder[3], topFaceOrder[0], topFaceOrder[1], topFaceOrder[2]);\r\n indices.push(bottomFaceOrder[0], bottomFaceOrder[2], bottomFaceOrder[3], bottomFaceOrder[0], bottomFaceOrder[1], bottomFaceOrder[2]);\r\n }\r\n const scaleArray = [width / 2, height / 2, depth / 2];\r\n positions = basePositions.reduce((accumulator: Array<number>, currentValue, currentIndex) => accumulator.concat(currentValue * scaleArray[currentIndex % 3]), []);\r\n\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(6);\r\n const faceColors = options.faceColors;\r\n const colors = [];\r\n\r\n // default face colors and UV if undefined\r\n for (let f = 0; f < 6; f++) {\r\n if (faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n\r\n // Create each face in turn.\r\n for (let index = 0; index < nbFaces; index++) {\r\n uvs.push(faceUV[index].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);\r\n uvs.push(faceUV[index].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);\r\n uvs.push(faceUV[index].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);\r\n uvs.push(faceUV[index].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);\r\n if (faceColors) {\r\n for (let c = 0; c < 4; c++) {\r\n colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);\r\n }\r\n }\r\n }\r\n\r\n // sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n\r\n if (faceColors) {\r\n const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;\r\n vertexData.colors = totalColors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates the VertexData for a segmented box\r\n * @param options an object used to set the following optional parameters for the box, required but can be empty\r\n * * size sets the width, height and depth of the box to the value of size, optional default 1\r\n * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size\r\n * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size\r\n * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size\r\n * * segments sets the number of segments on the all axis (1 by default)\r\n * * widthSegments sets the number of segments on the x axis (1 by default)\r\n * * heightSegments sets the number of segments on the y axis (1 by default)\r\n * * depthSegments sets the number of segments on the z axis (1 by default)\r\n * @returns the VertexData of the box\r\n */\r\nexport function CreateSegmentedBoxVertexData(options: {\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n segments?: number;\r\n widthSegments?: number;\r\n heightSegments?: number;\r\n depthSegments?: number;\r\n}): VertexData {\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const widthSegments = (options.widthSegments || options.segments || 1) | 0;\r\n const heightSegments = (options.heightSegments || options.segments || 1) | 0;\r\n const depthSegments = (options.depthSegments || options.segments || 1) | 0;\r\n const rotationMatrix = new Matrix();\r\n const translationMatrix = new Matrix();\r\n const transformMatrix = new Matrix();\r\n\r\n const bottomPlane = CreateGroundVertexData({ width: width, height: depth, subdivisionsX: widthSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(0, -height / 2, 0, translationMatrix);\r\n Matrix.RotationZToRef(Math.PI, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n bottomPlane.transform(transformMatrix);\r\n\r\n const topPlane = CreateGroundVertexData({ width: width, height: depth, subdivisionsX: widthSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(0, height / 2, 0, transformMatrix);\r\n topPlane.transform(transformMatrix);\r\n\r\n const negXPlane = CreateGroundVertexData({ width: height, height: depth, subdivisionsX: heightSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(-width / 2, 0, 0, translationMatrix);\r\n Matrix.RotationZToRef(Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n negXPlane.transform(transformMatrix);\r\n\r\n const posXPlane = CreateGroundVertexData({ width: height, height: depth, subdivisionsX: heightSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(width / 2, 0, 0, translationMatrix);\r\n Matrix.RotationZToRef(-Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n posXPlane.transform(transformMatrix);\r\n\r\n const negZPlane = CreateGroundVertexData({ width: width, height: height, subdivisionsX: widthSegments, subdivisionsY: heightSegments });\r\n Matrix.TranslationToRef(0, 0, -depth / 2, translationMatrix);\r\n Matrix.RotationXToRef(-Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n negZPlane.transform(transformMatrix);\r\n\r\n const posZPlane = CreateGroundVertexData({ width: width, height: height, subdivisionsX: widthSegments, subdivisionsY: heightSegments });\r\n Matrix.TranslationToRef(0, 0, depth / 2, translationMatrix);\r\n Matrix.RotationXToRef(Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n posZPlane.transform(transformMatrix);\r\n\r\n // Result\r\n bottomPlane.merge([topPlane, posXPlane, negXPlane, negZPlane, posZPlane], true);\r\n\r\n return bottomPlane;\r\n}\r\n\r\n/**\r\n * Creates a box mesh\r\n * * The parameter `size` sets the size (float) of each box side (default 1)\r\n * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)\r\n * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)\r\n * * Please read this tutorial : https://doc.babylonjs.com/features/featuresDeepDive/materials/using/texturePerBoxFace\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#box\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the box mesh\r\n */\r\nexport function CreateBox(\r\n name: string,\r\n options: {\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n wrap?: boolean;\r\n topBaseAt?: number;\r\n bottomBaseAt?: number;\r\n updatable?: boolean;\r\n } = {},\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const box = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n box._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateBoxVertexData(options);\r\n\r\n vertexData.applyToMesh(box, options.updatable);\r\n\r\n return box;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use CreateBox directly\r\n */\r\nexport const BoxBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateBox,\r\n};\r\n\r\n// Side effects\r\nVertexData.CreateBox = CreateBoxVertexData;\r\n\r\nMesh.CreateBox = (name: string, size: number, scene: Nullable<Scene> = null, updatable?: boolean, sideOrientation?: number): Mesh => {\r\n const options = {\r\n size,\r\n sideOrientation,\r\n updatable,\r\n };\r\n\r\n return CreateBox(name, options, scene);\r\n};\r\n"]}
1
+ {"version":3,"file":"boxBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/boxBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAanC;IACG,MAAM,OAAO,GAAG,CAAC,CAAC;IAClB,IAAI,OAAO,GAAG,CAAC,CAAC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AAC,SAAS,GAAG,mBAAmB,CAAC;AAE3C,IAAI,CAAC,SAAS,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,QAAyB,IAAI,EAAE,SAAmB,EAAE,eAAwB,EAAQ,EAAE;IAChI,MAAM,OAAO,GAAG;QACZ,IAAI;QACJ,eAAe;QACf,SAAS;KACZ,CAAC;IAEF,OAAO,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, Vector4 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\nimport { CreateGroundVertexData } from \"./groundBuilder\";\r\n\r\n/**\r\n * Creates the VertexData for a box\r\n * @param options an object used to set the following optional parameters for the box, required but can be empty\r\n * * size sets the width, height and depth of the box to the value of size, optional default 1\r\n * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size\r\n * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size\r\n * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size\r\n * * faceUV an array of 6 Vector4 elements used to set different images to each box side\r\n * * faceColors an array of 6 Color3 elements used to set different colors to each box side\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @returns the VertexData of the box\r\n */\r\nexport function CreateBoxVertexData(options: {\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n wrap?: boolean;\r\n topBaseAt?: number;\r\n bottomBaseAt?: number;\r\n}): VertexData {\r\n const nbFaces = 6;\r\n let indices = [0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23];\r\n const normals = [\r\n 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0,\r\n 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,\r\n ];\r\n const uvs = [];\r\n let positions = [];\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const wrap = options.wrap || false;\r\n let topBaseAt = options.topBaseAt === void 0 ? 1 : options.topBaseAt;\r\n let bottomBaseAt = options.bottomBaseAt === void 0 ? 0 : options.bottomBaseAt;\r\n topBaseAt = (topBaseAt + 4) % 4; // places values as 0 to 3\r\n bottomBaseAt = (bottomBaseAt + 4) % 4; // places values as 0 to 3\r\n const topOrder = [2, 0, 3, 1];\r\n const bottomOrder = [2, 0, 1, 3];\r\n let topIndex = topOrder[topBaseAt];\r\n let bottomIndex = bottomOrder[bottomBaseAt];\r\n let basePositions = [\r\n 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1,\r\n 1, 1, -1, 1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, -1, -1, -1, 1,\r\n ];\r\n if (wrap) {\r\n indices = [2, 3, 0, 2, 0, 1, 4, 5, 6, 4, 6, 7, 9, 10, 11, 9, 11, 8, 12, 14, 15, 12, 13, 14];\r\n basePositions = [\r\n -1, 1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1,\r\n ];\r\n let topFaceBase: any = [\r\n [1, 1, 1],\r\n [-1, 1, 1],\r\n [-1, 1, -1],\r\n [1, 1, -1],\r\n ];\r\n let bottomFaceBase: any = [\r\n [-1, -1, 1],\r\n [1, -1, 1],\r\n [1, -1, -1],\r\n [-1, -1, -1],\r\n ];\r\n const topFaceOrder: any = [17, 18, 19, 16];\r\n const bottomFaceOrder: any = [22, 23, 20, 21];\r\n while (topIndex > 0) {\r\n topFaceBase.unshift(topFaceBase.pop());\r\n topFaceOrder.unshift(topFaceOrder.pop());\r\n topIndex--;\r\n }\r\n while (bottomIndex > 0) {\r\n bottomFaceBase.unshift(bottomFaceBase.pop());\r\n bottomFaceOrder.unshift(bottomFaceOrder.pop());\r\n bottomIndex--;\r\n }\r\n topFaceBase = topFaceBase.flat();\r\n bottomFaceBase = bottomFaceBase.flat();\r\n basePositions = basePositions.concat(topFaceBase).concat(bottomFaceBase);\r\n indices.push(topFaceOrder[0], topFaceOrder[2], topFaceOrder[3], topFaceOrder[0], topFaceOrder[1], topFaceOrder[2]);\r\n indices.push(bottomFaceOrder[0], bottomFaceOrder[2], bottomFaceOrder[3], bottomFaceOrder[0], bottomFaceOrder[1], bottomFaceOrder[2]);\r\n }\r\n const scaleArray = [width / 2, height / 2, depth / 2];\r\n positions = basePositions.reduce((accumulator: Array<number>, currentValue, currentIndex) => accumulator.concat(currentValue * scaleArray[currentIndex % 3]), []);\r\n\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(6);\r\n const faceColors = options.faceColors;\r\n const colors = [];\r\n\r\n // default face colors and UV if undefined\r\n for (let f = 0; f < 6; f++) {\r\n if (faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n\r\n // Create each face in turn.\r\n for (let index = 0; index < nbFaces; index++) {\r\n uvs.push(faceUV[index].z, useOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);\r\n uvs.push(faceUV[index].x, useOpenGLOrientationForUV ? 1.0 - faceUV[index].w : faceUV[index].w);\r\n uvs.push(faceUV[index].x, useOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);\r\n uvs.push(faceUV[index].z, useOpenGLOrientationForUV ? 1.0 - faceUV[index].y : faceUV[index].y);\r\n if (faceColors) {\r\n for (let c = 0; c < 4; c++) {\r\n colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);\r\n }\r\n }\r\n }\r\n\r\n // sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\r\n\r\n // Result\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n\r\n if (faceColors) {\r\n const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;\r\n vertexData.colors = totalColors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates the VertexData for a segmented box\r\n * @param options an object used to set the following optional parameters for the box, required but can be empty\r\n * * size sets the width, height and depth of the box to the value of size, optional default 1\r\n * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size\r\n * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size\r\n * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size\r\n * * segments sets the number of segments on the all axis (1 by default)\r\n * * widthSegments sets the number of segments on the x axis (1 by default)\r\n * * heightSegments sets the number of segments on the y axis (1 by default)\r\n * * depthSegments sets the number of segments on the z axis (1 by default)\r\n * @returns the VertexData of the box\r\n */\r\nexport function CreateSegmentedBoxVertexData(options: {\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n segments?: number;\r\n widthSegments?: number;\r\n heightSegments?: number;\r\n depthSegments?: number;\r\n}): VertexData {\r\n const width = options.width || options.size || 1;\r\n const height = options.height || options.size || 1;\r\n const depth = options.depth || options.size || 1;\r\n const widthSegments = (options.widthSegments || options.segments || 1) | 0;\r\n const heightSegments = (options.heightSegments || options.segments || 1) | 0;\r\n const depthSegments = (options.depthSegments || options.segments || 1) | 0;\r\n const rotationMatrix = new Matrix();\r\n const translationMatrix = new Matrix();\r\n const transformMatrix = new Matrix();\r\n\r\n const bottomPlane = CreateGroundVertexData({ width: width, height: depth, subdivisionsX: widthSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(0, -height / 2, 0, translationMatrix);\r\n Matrix.RotationZToRef(Math.PI, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n bottomPlane.transform(transformMatrix);\r\n\r\n const topPlane = CreateGroundVertexData({ width: width, height: depth, subdivisionsX: widthSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(0, height / 2, 0, transformMatrix);\r\n topPlane.transform(transformMatrix);\r\n\r\n const negXPlane = CreateGroundVertexData({ width: height, height: depth, subdivisionsX: heightSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(-width / 2, 0, 0, translationMatrix);\r\n Matrix.RotationZToRef(Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n negXPlane.transform(transformMatrix);\r\n\r\n const posXPlane = CreateGroundVertexData({ width: height, height: depth, subdivisionsX: heightSegments, subdivisionsY: depthSegments });\r\n Matrix.TranslationToRef(width / 2, 0, 0, translationMatrix);\r\n Matrix.RotationZToRef(-Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n posXPlane.transform(transformMatrix);\r\n\r\n const negZPlane = CreateGroundVertexData({ width: width, height: height, subdivisionsX: widthSegments, subdivisionsY: heightSegments });\r\n Matrix.TranslationToRef(0, 0, -depth / 2, translationMatrix);\r\n Matrix.RotationXToRef(-Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n negZPlane.transform(transformMatrix);\r\n\r\n const posZPlane = CreateGroundVertexData({ width: width, height: height, subdivisionsX: widthSegments, subdivisionsY: heightSegments });\r\n Matrix.TranslationToRef(0, 0, depth / 2, translationMatrix);\r\n Matrix.RotationXToRef(Math.PI / 2, rotationMatrix);\r\n rotationMatrix.multiplyToRef(translationMatrix, transformMatrix);\r\n posZPlane.transform(transformMatrix);\r\n\r\n // Result\r\n bottomPlane.merge([topPlane, posXPlane, negXPlane, negZPlane, posZPlane], true);\r\n\r\n return bottomPlane;\r\n}\r\n\r\n/**\r\n * Creates a box mesh\r\n * * The parameter `size` sets the size (float) of each box side (default 1)\r\n * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)\r\n * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)\r\n * * Please read this tutorial : https://doc.babylonjs.com/features/featuresDeepDive/materials/using/texturePerBoxFace\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#box\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the box mesh\r\n */\r\nexport function CreateBox(\r\n name: string,\r\n options: {\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n wrap?: boolean;\r\n topBaseAt?: number;\r\n bottomBaseAt?: number;\r\n updatable?: boolean;\r\n } = {},\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const box = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n box._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateBoxVertexData(options);\r\n\r\n vertexData.applyToMesh(box, options.updatable);\r\n\r\n return box;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use CreateBox directly\r\n */\r\nexport const BoxBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateBox,\r\n};\r\n\r\n// Side effects\r\nVertexData.CreateBox = CreateBoxVertexData;\r\n\r\nMesh.CreateBox = (name: string, size: number, scene: Nullable<Scene> = null, updatable?: boolean, sideOrientation?: number): Mesh => {\r\n const options = {\r\n size,\r\n sideOrientation,\r\n updatable,\r\n };\r\n\r\n return CreateBox(name, options, scene);\r\n};\r\n"]}
@@ -1,7 +1,7 @@
1
1
  import { VertexData } from "../mesh.vertexData.js";
2
2
  import { Vector2, Vector3, Matrix } from "../../Maths/math.vector.js";
3
3
  import { Mesh } from "../mesh.js";
4
- import { CompatibilityOptions } from "../../Compat/compatibilityOptions.js";
4
+ import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
5
5
  /**
6
6
  * Scripts based off of https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
7
7
  * @param options the constructors options used to shape the mesh.
@@ -71,7 +71,7 @@ export function CreateCapsuleVertexData(options = {
71
71
  normal.set(cosA * sinTheta, sinA, cosA * cosTheta);
72
72
  normals.push(normal.x, normal.y, normal.z);
73
73
  // uv
74
- uvs.push(u, CompatibilityOptions.UseOpenGLOrientationForUV ? v / vl : 1 - v / vl);
74
+ uvs.push(u, useOpenGLOrientationForUV ? v / vl : 1 - v / vl);
75
75
  // save index of vertex in respective row
76
76
  indexRow.push(index);
77
77
  // increase index
@@ -101,7 +101,7 @@ export function CreateCapsuleVertexData(options = {
101
101
  normal.set(sinTheta, slope, cosTheta).normalize();
102
102
  normals.push(normal.x, normal.y, normal.z);
103
103
  // uv
104
- uvs.push(u, CompatibilityOptions.UseOpenGLOrientationForUV ? v / vl : 1 - v / vl);
104
+ uvs.push(u, useOpenGLOrientationForUV ? v / vl : 1 - v / vl);
105
105
  // save index of vertex in respective row
106
106
  indexRow.push(index);
107
107
  // increase index
@@ -132,7 +132,7 @@ export function CreateCapsuleVertexData(options = {
132
132
  normal.set(cosA * sinTheta, sinA, cosA * cosTheta);
133
133
  normals.push(normal.x, normal.y, normal.z);
134
134
  // uv
135
- uvs.push(u, CompatibilityOptions.UseOpenGLOrientationForUV ? v / vl : 1 - v / vl);
135
+ uvs.push(u, useOpenGLOrientationForUV ? v / vl : 1 - v / vl);
136
136
  // save index of vertex in respective row
137
137
  indexRow.push(index);
138
138
  // increase index
@@ -1 +1 @@
1
- {"version":3,"file":"capsuleBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/capsuleBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,E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Q,EAAE;IACjG,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,UAAU,CAAC,aAAa,GAAG,uBAAuB,CAAC","sourcesContent":["import { VertexData } from \"../mesh.vertexData\";\r\nimport { Vector2, Vector3, Matrix } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\n/**\r\n * Scripts based off of https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js\r\n * @param options the constructors options used to shape the mesh.\r\n * @returns the capsule VertexData\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/capsule\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function CreateCapsuleVertexData(\r\n options: ICreateCapsuleOptions = {\r\n subdivisions: 2,\r\n tessellation: 16,\r\n height: 1,\r\n radius: 0.25,\r\n capSubdivisions: 6,\r\n }\r\n): VertexData {\r\n const subdivisions = Math.max(options.subdivisions ? options.subdivisions : 2, 1) | 0;\r\n const tessellation = Math.max(options.tessellation ? options.tessellation : 16, 3) | 0;\r\n const height = Math.max(options.height ? options.height : 1, 0);\r\n const radius = Math.max(options.radius ? options.radius : 0.25, 0);\r\n const capDetail = Math.max(options.capSubdivisions ? options.capSubdivisions : 6, 1) | 0;\r\n\r\n const radialSegments = tessellation;\r\n const heightSegments = subdivisions;\r\n\r\n const radiusTop = Math.max(options.radiusTop ? options.radiusTop : radius, 0);\r\n const radiusBottom = Math.max(options.radiusBottom ? options.radiusBottom : radius, 0);\r\n\r\n const heightMinusCaps = height - (radiusTop + radiusBottom);\r\n\r\n const thetaStart = 0.0;\r\n const thetaLength = 2.0 * Math.PI;\r\n\r\n const capsTopSegments = Math.max(options.topCapSubdivisions ? options.topCapSubdivisions : capDetail, 1);\r\n const capsBottomSegments = Math.max(options.bottomCapSubdivisions ? options.bottomCapSubdivisions : capDetail, 1);\r\n\r\n const alpha = Math.acos((radiusBottom - radiusTop) / height);\r\n\r\n let indices = [];\r\n const vertices = [];\r\n const normals = [];\r\n const uvs = [];\r\n\r\n let index = 0;\r\n const indexArray = [],\r\n halfHeight = heightMinusCaps * 0.5;\r\n const pi2 = Math.PI * 0.5;\r\n\r\n let x, y;\r\n const normal = Vector3.Zero();\r\n const vertex = Vector3.Zero();\r\n\r\n const cosAlpha = Math.cos(alpha);\r\n const sinAlpha = Math.sin(alpha);\r\n\r\n const coneLength = new Vector2(radiusTop * sinAlpha, halfHeight + radiusTop * cosAlpha)\r\n .subtract(new Vector2(radiusBottom * sinAlpha, -halfHeight + radiusBottom * cosAlpha))\r\n .length();\r\n\r\n // Total length for v texture coord\r\n const vl = radiusTop * alpha + coneLength + radiusBottom * (pi2 - alpha);\r\n\r\n let v = 0;\r\n for (y = 0; y <= capsTopSegments; y++) {\r\n const indexRow = [];\r\n\r\n const a = pi2 - alpha * (y / capsTopSegments);\r\n\r\n v += (radiusTop * alpha) / capsTopSegments;\r\n\r\n const cosA = Math.cos(a);\r\n const sinA = Math.sin(a);\r\n\r\n // calculate the radius of the current row\r\n const _radius = cosA * radiusTop;\r\n\r\n for (x = 0; x <= radialSegments; x++) {\r\n const u = x / radialSegments;\r\n const theta = u * thetaLength + thetaStart;\r\n const sinTheta = Math.sin(theta);\r\n const cosTheta = Math.cos(theta);\r\n // vertex\r\n vertex.x = _radius * sinTheta;\r\n vertex.y = halfHeight + sinA * radiusTop;\r\n vertex.z = _radius * cosTheta;\r\n vertices.push(vertex.x, vertex.y, vertex.z);\r\n // normal\r\n normal.set(cosA * sinTheta, sinA, cosA * cosTheta);\r\n normals.push(normal.x, normal.y, normal.z);\r\n // uv\r\n uvs.push(u, CompatibilityOptions.UseOpenGLOrientationForUV ? v / vl : 1 - v / vl);\r\n // save index of vertex in respective row\r\n indexRow.push(index);\r\n // increase index\r\n index++;\r\n }\r\n // now save vertices of the row in our index array\r\n indexArray.push(indexRow);\r\n }\r\n\r\n const coneHeight = height - radiusTop - radiusBottom + cosAlpha * radiusTop - cosAlpha * radiusBottom;\r\n const slope = (sinAlpha * (radiusBottom - radiusTop)) / coneHeight;\r\n\r\n for (y = 1; y <= heightSegments; y++) {\r\n const indexRow = [];\r\n v += coneLength / heightSegments;\r\n // calculate the radius of the current row\r\n const _radius = sinAlpha * ((y * (radiusBottom - radiusTop)) / heightSegments + radiusTop);\r\n for (x = 0; x <= radialSegments; x++) {\r\n const u = x / radialSegments;\r\n const theta = u * thetaLength + thetaStart;\r\n const sinTheta = Math.sin(theta);\r\n const cosTheta = Math.cos(theta);\r\n // vertex\r\n vertex.x = _radius * sinTheta;\r\n vertex.y = halfHeight + cosAlpha * radiusTop - (y * coneHeight) / heightSegments;\r\n vertex.z = _radius * cosTheta;\r\n vertices.push(vertex.x, vertex.y, vertex.z);\r\n // normal\r\n normal.set(sinTheta, slope, cosTheta).normalize();\r\n normals.push(normal.x, normal.y, normal.z);\r\n // uv\r\n uvs.push(u, CompatibilityOptions.UseOpenGLOrientationForUV ? v / vl : 1 - v / vl);\r\n // save index of vertex in respective row\r\n indexRow.push(index);\r\n // increase index\r\n index++;\r\n }\r\n // now save vertices of the row in our index array\r\n indexArray.push(indexRow);\r\n }\r\n\r\n for (y = 1; y <= capsBottomSegments; y++) {\r\n const indexRow = [];\r\n const a = pi2 - alpha - (Math.PI - alpha) * (y / capsBottomSegments);\r\n v += (radiusBottom * alpha) / capsBottomSegments;\r\n const cosA = Math.cos(a);\r\n const sinA = Math.sin(a);\r\n // calculate the radius of the current row\r\n const _radius = cosA * radiusBottom;\r\n for (x = 0; x <= radialSegments; x++) {\r\n const u = x / radialSegments;\r\n const theta = u * thetaLength + thetaStart;\r\n const sinTheta = Math.sin(theta);\r\n const cosTheta = Math.cos(theta);\r\n // vertex\r\n vertex.x = _radius * sinTheta;\r\n vertex.y = -halfHeight + sinA * radiusBottom;\r\n vertex.z = _radius * cosTheta;\r\n vertices.push(vertex.x, vertex.y, vertex.z);\r\n // normal\r\n normal.set(cosA * sinTheta, sinA, cosA * cosTheta);\r\n normals.push(normal.x, normal.y, normal.z);\r\n // uv\r\n uvs.push(u, CompatibilityOptions.UseOpenGLOrientationForUV ? v / vl : 1 - v / vl);\r\n // save index of vertex in respective row\r\n indexRow.push(index);\r\n // increase index\r\n index++;\r\n }\r\n // now save vertices of the row in our index array\r\n indexArray.push(indexRow);\r\n }\r\n // generate indices\r\n for (x = 0; x < radialSegments; x++) {\r\n for (y = 0; y < capsTopSegments + heightSegments + capsBottomSegments; y++) {\r\n // we use the index array to access the correct indices\r\n const i1 = indexArray[y][x];\r\n const i2 = indexArray[y + 1][x];\r\n const i3 = indexArray[y + 1][x + 1];\r\n const i4 = indexArray[y][x + 1];\r\n // face one\r\n indices.push(i1);\r\n indices.push(i2);\r\n indices.push(i4);\r\n // face two\r\n indices.push(i2);\r\n indices.push(i3);\r\n indices.push(i4);\r\n }\r\n }\r\n\r\n indices = indices.reverse();\r\n\r\n if (options.orientation && !options.orientation.equals(Vector3.Up())) {\r\n const m = new Matrix();\r\n options.orientation\r\n .clone()\r\n .scale(Math.PI * 0.5)\r\n .cross(Vector3.Up())\r\n .toQuaternion()\r\n .toRotationMatrix(m);\r\n const v = Vector3.Zero();\r\n for (let i = 0; i < vertices.length; i += 3) {\r\n v.set(vertices[i], vertices[i + 1], vertices[i + 2]);\r\n Vector3.TransformCoordinatesToRef(v.clone(), m, v);\r\n vertices[i] = v.x;\r\n vertices[i + 1] = v.y;\r\n vertices[i + 2] = v.z;\r\n }\r\n }\r\n\r\n const vDat = new VertexData();\r\n vDat.positions = vertices;\r\n vDat.normals = normals;\r\n vDat.uvs = uvs;\r\n vDat.indices = indices;\r\n\r\n return vDat;\r\n}\r\n\r\n/**\r\n * The options Interface for creating a Capsule Mesh\r\n */\r\nexport interface ICreateCapsuleOptions {\r\n /** The Orientation of the capsule. Default : Vector3.Up() */\r\n orientation?: Vector3;\r\n\r\n /** Number of sub segments on the tube section of the capsule running parallel to orientation. */\r\n subdivisions?: number;\r\n\r\n /** Number of cylindrical segments on the capsule. */\r\n tessellation?: number;\r\n\r\n /** Height or Length of the capsule. */\r\n height?: number;\r\n\r\n /** Radius of the capsule. */\r\n radius?: number;\r\n\r\n /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */\r\n capSubdivisions?: number;\r\n\r\n /** Overwrite for the top radius. */\r\n radiusTop?: number;\r\n\r\n /** Overwrite for the bottom radius. */\r\n radiusBottom?: number;\r\n\r\n /** Overwrite for the top capSubdivisions. */\r\n topCapSubdivisions?: number;\r\n\r\n /** Overwrite for the bottom capSubdivisions. */\r\n bottomCapSubdivisions?: number;\r\n\r\n /** Internal geometry is supposed to change once created. */\r\n updatable?: boolean;\r\n}\r\n\r\n/**\r\n * Creates a capsule or a pill mesh\r\n * @param name defines the name of the mesh\r\n * @param options The constructors options.\r\n * @param scene The scene the mesh is scoped to.\r\n * @returns Capsule Mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function CreateCapsule(\r\n name: string,\r\n options: ICreateCapsuleOptions = {\r\n orientation: Vector3.Up(),\r\n subdivisions: 2,\r\n tessellation: 16,\r\n height: 1,\r\n radius: 0.25,\r\n capSubdivisions: 6,\r\n updatable: false,\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const capsule = new Mesh(name, scene);\r\n const vertexData = CreateCapsuleVertexData(options);\r\n vertexData.applyToMesh(capsule, options.updatable);\r\n return capsule;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use CreateCapsule directly\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const CapsuleBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateCapsule,\r\n};\r\n\r\n/**\r\n * Creates a capsule or a pill mesh\r\n * @param name defines the name of the mesh.\r\n * @param options the constructors options used to shape the mesh.\r\n * @param scene defines the scene the mesh is scoped to.\r\n * @returns the capsule mesh\r\n * @see https://doc.babylonjs.com/how_to/capsule_shape\r\n */\r\nMesh.CreateCapsule = (name: string, options: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh => {\r\n return CreateCapsule(name, options, scene);\r\n};\r\n\r\nVertexData.CreateCapsule = CreateCapsuleVertexData;\r\n"]}
1
+ {"version":3,"file":"capsuleBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/capsuleBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E;;;;;GAKG;AACH,gEAAgE;AAChE,MAAM,UAAU,uBAAuB,CACnC,UAAiC;IAC7B,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,EAAE;IAChB,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,IAAI;IACZ,eAAe,EAAE,CAAC;CACrB;IAED,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACtF,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CA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IAAI,EAAE,KAAK,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACpD,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IACnD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,gEAAgE;IAChE,aAAa;CAChB,CAAC;AAEF;;;;;;;GAOG;AACH,IAAI,CAAC,aAAa,GAAG,CAAC,IAAY,EAAE,OAA8B,EAAE,KAAuB,EAAQ,EAAE;IACjG,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC/C,CAAC,CAAC;AAEF,UAAU,CAAC,aAAa,GAAG,uBAAuB,CAAC","sourcesContent":["import { VertexData } from \"../mesh.vertexData\";\r\nimport { Vector2, Vector3, Matrix } from \"../../Maths/math.vector\";\r\nimport { Mesh } from \"../mesh\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n/**\r\n * Scripts based off of https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js\r\n * @param options the constructors options used to shape the mesh.\r\n * @returns the capsule VertexData\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/capsule\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function CreateCapsuleVertexData(\r\n options: ICreateCapsuleOptions = {\r\n subdivisions: 2,\r\n tessellation: 16,\r\n height: 1,\r\n radius: 0.25,\r\n capSubdivisions: 6,\r\n }\r\n): VertexData {\r\n const subdivisions = Math.max(options.subdivisions ? options.subdivisions : 2, 1) | 0;\r\n const tessellation = Math.max(options.tessellation ? options.tessellation : 16, 3) | 0;\r\n const height = Math.max(options.height ? options.height : 1, 0);\r\n const radius = Math.max(options.radius ? options.radius : 0.25, 0);\r\n const capDetail = Math.max(options.capSubdivisions ? options.capSubdivisions : 6, 1) | 0;\r\n\r\n const radialSegments = tessellation;\r\n const heightSegments = subdivisions;\r\n\r\n const radiusTop = Math.max(options.radiusTop ? options.radiusTop : radius, 0);\r\n const radiusBottom = Math.max(options.radiusBottom ? options.radiusBottom : radius, 0);\r\n\r\n const heightMinusCaps = height - (radiusTop + radiusBottom);\r\n\r\n const thetaStart = 0.0;\r\n const thetaLength = 2.0 * Math.PI;\r\n\r\n const capsTopSegments = Math.max(options.topCapSubdivisions ? options.topCapSubdivisions : capDetail, 1);\r\n const capsBottomSegments = Math.max(options.bottomCapSubdivisions ? options.bottomCapSubdivisions : capDetail, 1);\r\n\r\n const alpha = Math.acos((radiusBottom - radiusTop) / height);\r\n\r\n let indices = [];\r\n const vertices = [];\r\n const normals = [];\r\n const uvs = [];\r\n\r\n let index = 0;\r\n const indexArray = [],\r\n halfHeight = heightMinusCaps * 0.5;\r\n const pi2 = Math.PI * 0.5;\r\n\r\n let x, y;\r\n const normal = Vector3.Zero();\r\n const vertex = Vector3.Zero();\r\n\r\n const cosAlpha = Math.cos(alpha);\r\n const sinAlpha = Math.sin(alpha);\r\n\r\n const coneLength = new Vector2(radiusTop * sinAlpha, halfHeight + radiusTop * cosAlpha)\r\n .subtract(new Vector2(radiusBottom * sinAlpha, -halfHeight + radiusBottom * cosAlpha))\r\n .length();\r\n\r\n // Total length for v texture coord\r\n const vl = radiusTop * alpha + coneLength + radiusBottom * (pi2 - alpha);\r\n\r\n let v = 0;\r\n for (y = 0; y <= capsTopSegments; y++) {\r\n const indexRow = [];\r\n\r\n const a = pi2 - alpha * (y / capsTopSegments);\r\n\r\n v += (radiusTop * alpha) / capsTopSegments;\r\n\r\n const cosA = Math.cos(a);\r\n const sinA = Math.sin(a);\r\n\r\n // calculate the radius of the current row\r\n const _radius = cosA * radiusTop;\r\n\r\n for (x = 0; x <= radialSegments; x++) {\r\n const u = x / radialSegments;\r\n const theta = u * thetaLength + thetaStart;\r\n const sinTheta = Math.sin(theta);\r\n const cosTheta = Math.cos(theta);\r\n // vertex\r\n vertex.x = _radius * sinTheta;\r\n vertex.y = halfHeight + sinA * radiusTop;\r\n vertex.z = _radius * cosTheta;\r\n vertices.push(vertex.x, vertex.y, vertex.z);\r\n // normal\r\n normal.set(cosA * sinTheta, sinA, cosA * cosTheta);\r\n normals.push(normal.x, normal.y, normal.z);\r\n // uv\r\n uvs.push(u, useOpenGLOrientationForUV ? v / vl : 1 - v / vl);\r\n // save index of vertex in respective row\r\n indexRow.push(index);\r\n // increase index\r\n index++;\r\n }\r\n // now save vertices of the row in our index array\r\n indexArray.push(indexRow);\r\n }\r\n\r\n const coneHeight = height - radiusTop - radiusBottom + cosAlpha * radiusTop - cosAlpha * radiusBottom;\r\n const slope = (sinAlpha * (radiusBottom - radiusTop)) / coneHeight;\r\n\r\n for (y = 1; y <= heightSegments; y++) {\r\n const indexRow = [];\r\n v += coneLength / heightSegments;\r\n // calculate the radius of the current row\r\n const _radius = sinAlpha * ((y * (radiusBottom - radiusTop)) / heightSegments + radiusTop);\r\n for (x = 0; x <= radialSegments; x++) {\r\n const u = x / radialSegments;\r\n const theta = u * thetaLength + thetaStart;\r\n const sinTheta = Math.sin(theta);\r\n const cosTheta = Math.cos(theta);\r\n // vertex\r\n vertex.x = _radius * sinTheta;\r\n vertex.y = halfHeight + cosAlpha * radiusTop - (y * coneHeight) / heightSegments;\r\n vertex.z = _radius * cosTheta;\r\n vertices.push(vertex.x, vertex.y, vertex.z);\r\n // normal\r\n normal.set(sinTheta, slope, cosTheta).normalize();\r\n normals.push(normal.x, normal.y, normal.z);\r\n // uv\r\n uvs.push(u, useOpenGLOrientationForUV ? v / vl : 1 - v / vl);\r\n // save index of vertex in respective row\r\n indexRow.push(index);\r\n // increase index\r\n index++;\r\n }\r\n // now save vertices of the row in our index array\r\n indexArray.push(indexRow);\r\n }\r\n\r\n for (y = 1; y <= capsBottomSegments; y++) {\r\n const indexRow = [];\r\n const a = pi2 - alpha - (Math.PI - alpha) * (y / capsBottomSegments);\r\n v += (radiusBottom * alpha) / capsBottomSegments;\r\n const cosA = Math.cos(a);\r\n const sinA = Math.sin(a);\r\n // calculate the radius of the current row\r\n const _radius = cosA * radiusBottom;\r\n for (x = 0; x <= radialSegments; x++) {\r\n const u = x / radialSegments;\r\n const theta = u * thetaLength + thetaStart;\r\n const sinTheta = Math.sin(theta);\r\n const cosTheta = Math.cos(theta);\r\n // vertex\r\n vertex.x = _radius * sinTheta;\r\n vertex.y = -halfHeight + sinA * radiusBottom;\r\n vertex.z = _radius * cosTheta;\r\n vertices.push(vertex.x, vertex.y, vertex.z);\r\n // normal\r\n normal.set(cosA * sinTheta, sinA, cosA * cosTheta);\r\n normals.push(normal.x, normal.y, normal.z);\r\n // uv\r\n uvs.push(u, useOpenGLOrientationForUV ? v / vl : 1 - v / vl);\r\n // save index of vertex in respective row\r\n indexRow.push(index);\r\n // increase index\r\n index++;\r\n }\r\n // now save vertices of the row in our index array\r\n indexArray.push(indexRow);\r\n }\r\n // generate indices\r\n for (x = 0; x < radialSegments; x++) {\r\n for (y = 0; y < capsTopSegments + heightSegments + capsBottomSegments; y++) {\r\n // we use the index array to access the correct indices\r\n const i1 = indexArray[y][x];\r\n const i2 = indexArray[y + 1][x];\r\n const i3 = indexArray[y + 1][x + 1];\r\n const i4 = indexArray[y][x + 1];\r\n // face one\r\n indices.push(i1);\r\n indices.push(i2);\r\n indices.push(i4);\r\n // face two\r\n indices.push(i2);\r\n indices.push(i3);\r\n indices.push(i4);\r\n }\r\n }\r\n\r\n indices = indices.reverse();\r\n\r\n if (options.orientation && !options.orientation.equals(Vector3.Up())) {\r\n const m = new Matrix();\r\n options.orientation\r\n .clone()\r\n .scale(Math.PI * 0.5)\r\n .cross(Vector3.Up())\r\n .toQuaternion()\r\n .toRotationMatrix(m);\r\n const v = Vector3.Zero();\r\n for (let i = 0; i < vertices.length; i += 3) {\r\n v.set(vertices[i], vertices[i + 1], vertices[i + 2]);\r\n Vector3.TransformCoordinatesToRef(v.clone(), m, v);\r\n vertices[i] = v.x;\r\n vertices[i + 1] = v.y;\r\n vertices[i + 2] = v.z;\r\n }\r\n }\r\n\r\n const vDat = new VertexData();\r\n vDat.positions = vertices;\r\n vDat.normals = normals;\r\n vDat.uvs = uvs;\r\n vDat.indices = indices;\r\n\r\n return vDat;\r\n}\r\n\r\n/**\r\n * The options Interface for creating a Capsule Mesh\r\n */\r\nexport interface ICreateCapsuleOptions {\r\n /** The Orientation of the capsule. Default : Vector3.Up() */\r\n orientation?: Vector3;\r\n\r\n /** Number of sub segments on the tube section of the capsule running parallel to orientation. */\r\n subdivisions?: number;\r\n\r\n /** Number of cylindrical segments on the capsule. */\r\n tessellation?: number;\r\n\r\n /** Height or Length of the capsule. */\r\n height?: number;\r\n\r\n /** Radius of the capsule. */\r\n radius?: number;\r\n\r\n /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */\r\n capSubdivisions?: number;\r\n\r\n /** Overwrite for the top radius. */\r\n radiusTop?: number;\r\n\r\n /** Overwrite for the bottom radius. */\r\n radiusBottom?: number;\r\n\r\n /** Overwrite for the top capSubdivisions. */\r\n topCapSubdivisions?: number;\r\n\r\n /** Overwrite for the bottom capSubdivisions. */\r\n bottomCapSubdivisions?: number;\r\n\r\n /** Internal geometry is supposed to change once created. */\r\n updatable?: boolean;\r\n}\r\n\r\n/**\r\n * Creates a capsule or a pill mesh\r\n * @param name defines the name of the mesh\r\n * @param options The constructors options.\r\n * @param scene The scene the mesh is scoped to.\r\n * @returns Capsule Mesh\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function CreateCapsule(\r\n name: string,\r\n options: ICreateCapsuleOptions = {\r\n orientation: Vector3.Up(),\r\n subdivisions: 2,\r\n tessellation: 16,\r\n height: 1,\r\n radius: 0.25,\r\n capSubdivisions: 6,\r\n updatable: false,\r\n },\r\n scene: Nullable<Scene> = null\r\n): Mesh {\r\n const capsule = new Mesh(name, scene);\r\n const vertexData = CreateCapsuleVertexData(options);\r\n vertexData.applyToMesh(capsule, options.updatable);\r\n return capsule;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated please use CreateCapsule directly\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const CapsuleBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateCapsule,\r\n};\r\n\r\n/**\r\n * Creates a capsule or a pill mesh\r\n * @param name defines the name of the mesh.\r\n * @param options the constructors options used to shape the mesh.\r\n * @param scene defines the scene the mesh is scoped to.\r\n * @returns the capsule mesh\r\n * @see https://doc.babylonjs.com/how_to/capsule_shape\r\n */\r\nMesh.CreateCapsule = (name: string, options: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh => {\r\n return CreateCapsule(name, options, scene);\r\n};\r\n\r\nVertexData.CreateCapsule = CreateCapsuleVertexData;\r\n"]}
@@ -4,7 +4,7 @@ import { Mesh } from "../mesh.js";
4
4
  import { VertexData } from "../mesh.vertexData.js";
5
5
  import { Scene } from "../../scene.js";
6
6
  import { Axis } from "../../Maths/math.axis.js";
7
- import { CompatibilityOptions } from "../../Compat/compatibilityOptions.js";
7
+ import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
8
8
  /**
9
9
  * Creates the VertexData for a cylinder, cone or prism
10
10
  * @param options an object used to set the following optional parameters for the box, required but can be empty
@@ -122,7 +122,7 @@ export function CreateCylinderVertexData(options) {
122
122
  else {
123
123
  v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
124
124
  }
125
- uvs.push(faceUV[s].x + ((faceUV[s].z - faceUV[s].x) * j) / tessellation, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
125
+ uvs.push(faceUV[s].x + ((faceUV[s].z - faceUV[s].x) * j) / tessellation, useOpenGLOrientationForUV ? 1 - v : v);
126
126
  if (faceColors) {
127
127
  colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
128
128
  }
@@ -145,16 +145,16 @@ export function CreateCylinderVertexData(options) {
145
145
  else {
146
146
  v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
147
147
  }
148
- uvs.push(faceUV[s + 1].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
149
- uvs.push(faceUV[s + 1].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
148
+ uvs.push(faceUV[s + 1].x, useOpenGLOrientationForUV ? 1 - v : v);
149
+ uvs.push(faceUV[s + 1].z, useOpenGLOrientationForUV ? 1 - v : v);
150
150
  if (hasRings) {
151
151
  v = cs !== s ? faceUV[s + 2].y : faceUV[s + 2].w;
152
152
  }
153
153
  else {
154
154
  v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
155
155
  }
156
- uvs.push(faceUV[s + 2].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
157
- uvs.push(faceUV[s + 2].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
156
+ uvs.push(faceUV[s + 2].x, useOpenGLOrientationForUV ? 1 - v : v);
157
+ uvs.push(faceUV[s + 2].z, useOpenGLOrientationForUV ? 1 - v : v);
158
158
  if (faceColors) {
159
159
  colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
160
160
  colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
@@ -214,7 +214,7 @@ export function CreateCylinderVertexData(options) {
214
214
  positions.push(center.x, center.y, center.z);
215
215
  normals.push(0, isTop ? 1 : -1, 0);
216
216
  const v = u.y + (u.w - u.y) * 0.5;
217
- uvs.push(u.x + (u.z - u.x) * 0.5, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
217
+ uvs.push(u.x + (u.z - u.x) * 0.5, useOpenGLOrientationForUV ? 1 - v : v);
218
218
  if (c) {
219
219
  colors.push(c.r, c.g, c.b, c.a);
220
220
  }
@@ -228,7 +228,7 @@ export function CreateCylinderVertexData(options) {
228
228
  positions.push(circleVector.x, circleVector.y, circleVector.z);
229
229
  normals.push(0, isTop ? 1 : -1, 0);
230
230
  const v = u.y + (u.w - u.y) * textureCoordinate.y;
231
- uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
231
+ uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, useOpenGLOrientationForUV ? 1 - v : v);
232
232
  if (c) {
233
233
  colors.push(c.r, c.g, c.b, c.a);
234
234
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cylinderBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/cylinderBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE;;;;;;;;;;;;;;;;;;GAkBG;AACH,gEAAgE;AAChE,MAAM,UAAU,wBAAwB,CAAC,OAgBxC;IACG,MAAM,MAAM,GAAW,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;IAC3C,IAAI,WAAW,GAAW,OAAO,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC,CAAC;IACvG,IAAI,cAAc,GAAW,OAAO,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cesContent":["import { Vector4, Vector3, Vector2 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Axis } from \"../../Maths/math.axis\";\r\nimport { CompatibilityOptions } from \"../../Compat/compatibilityOptions\";\r\n\r\n/**\r\n * Creates the VertexData for a cylinder, cone or prism\r\n * @param options an object used to set the following optional parameters for the box, required but can be empty\r\n * * height sets the height (y direction) of the cylinder, optional, default 2\r\n * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter\r\n * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter\r\n * * diameter sets the diameter of the top and bottom of the cone, optional default 1\r\n * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24\r\n * * subdivisions` the number of rings along the cylinder height, optional, default 1\r\n * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1\r\n * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively\r\n * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively\r\n * * hasRings when true makes each subdivision independently treated as a face for faceUV and faceColors, optional, default false\r\n * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @returns the VertexData of the cylinder, cone or prism\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function CreateCylinderVertexData(options: {\r\n height?: number;\r\n diameterTop?: number;\r\n diameterBottom?: number;\r\n diameter?: number;\r\n tessellation?: number;\r\n subdivisions?: number;\r\n arc?: number;\r\n faceColors?: Color4[];\r\n faceUV?: Vector4[];\r\n hasRings?: boolean;\r\n enclose?: boolean;\r\n cap?: number;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n}): VertexData {\r\n const height: number = options.height || 2;\r\n let diameterTop: number = options.diameterTop === 0 ? 0 : options.diameterTop || options.diameter || 1;\r\n let diameterBottom: number = options.diameterBottom === 0 ? 0 : options.diameterBottom || options.diameter || 1;\r\n diameterTop = diameterTop || 0.00001; // Prevent broken normals\r\n diameterBottom = diameterBottom || 0.00001; // Prevent broken normals\r\n const tessellation: number = (options.tessellation || 24) | 0;\r\n const subdivisions: number = (options.subdivisions || 1) | 0;\r\n const hasRings: boolean = options.hasRings ? true : false;\r\n const enclose: boolean = options.enclose ? true : false;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.CAP_ALL;\r\n const arc: number = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;\r\n const sideOrientation: number = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(3);\r\n const faceColors = options.faceColors;\r\n // default face colors and UV if undefined\r\n const quadNb: number = arc !== 1 && enclose ? 2 : 0;\r\n const ringNb: number = hasRings ? subdivisions : 1;\r\n const surfaceNb: number = 2 + (1 + quadNb) * ringNb;\r\n let f: number;\r\n\r\n for (f = 0; f < surfaceNb; f++) {\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n for (f = 0; f < surfaceNb; f++) {\r\n if (faceUV && faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n }\r\n\r\n const indices: number[] = [];\r\n const positions: number[] = [];\r\n const normals: number[] = [];\r\n const uvs: number[] = [];\r\n const colors: number[] = [];\r\n\r\n const angleStep = (Math.PI * 2 * arc) / tessellation;\r\n let angle: number;\r\n let h: number;\r\n let radius: number;\r\n const tan = (diameterBottom - diameterTop) / 2 / height;\r\n const ringVertex: Vector3 = Vector3.Zero();\r\n const ringNormal: Vector3 = Vector3.Zero();\r\n const ringFirstVertex: Vector3 = Vector3.Zero();\r\n const ringFirstNormal: Vector3 = Vector3.Zero();\r\n const quadNormal: Vector3 = Vector3.Zero();\r\n const Y: Vector3 = Axis.Y;\r\n\r\n // positions, normals, uvs\r\n let i: number;\r\n let j: number;\r\n let r: number;\r\n let ringIdx: number = 1;\r\n let s: number = 1; // surface index\r\n let cs: number = 0;\r\n let v: number = 0;\r\n\r\n for (i = 0; i <= subdivisions; i++) {\r\n h = i / subdivisions;\r\n radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;\r\n ringIdx = hasRings && i !== 0 && i !== subdivisions ? 2 : 1;\r\n for (r = 0; r < ringIdx; r++) {\r\n if (hasRings) {\r\n s += r;\r\n }\r\n if (enclose) {\r\n s += 2 * r;\r\n }\r\n for (j = 0; j <= tessellation; j++) {\r\n angle = j * angleStep;\r\n\r\n // position\r\n ringVertex.x = Math.cos(-angle) * radius;\r\n ringVertex.y = -height / 2 + h * height;\r\n ringVertex.z = Math.sin(-angle) * radius;\r\n\r\n // normal\r\n if (diameterTop === 0 && i === subdivisions) {\r\n // if no top cap, reuse former normals\r\n ringNormal.x = normals[normals.length - (tessellation + 1) * 3];\r\n ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];\r\n ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];\r\n } else {\r\n ringNormal.x = ringVertex.x;\r\n ringNormal.z = ringVertex.z;\r\n ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;\r\n ringNormal.normalize();\r\n }\r\n\r\n // keep first ring vertex values for enclose\r\n if (j === 0) {\r\n ringFirstVertex.copyFrom(ringVertex);\r\n ringFirstNormal.copyFrom(ringNormal);\r\n }\r\n\r\n positions.push(ringVertex.x, ringVertex.y, ringVertex.z);\r\n normals.push(ringNormal.x, ringNormal.y, ringNormal.z);\r\n if (hasRings) {\r\n v = cs !== s ? faceUV[s].y : faceUV[s].w;\r\n } else {\r\n v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;\r\n }\r\n uvs.push(faceUV[s].x + ((faceUV[s].z - faceUV[s].x) * j) / tessellation, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n if (faceColors) {\r\n colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);\r\n }\r\n }\r\n\r\n // if enclose, add four vertices and their dedicated normals\r\n if (arc !== 1 && enclose) {\r\n positions.push(ringVertex.x, ringVertex.y, ringVertex.z);\r\n positions.push(0, ringVertex.y, 0);\r\n positions.push(0, ringVertex.y, 0);\r\n positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);\r\n Vector3.CrossToRef(Y, ringNormal, quadNormal);\r\n quadNormal.normalize();\r\n normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);\r\n Vector3.CrossToRef(ringFirstNormal, Y, quadNormal);\r\n quadNormal.normalize();\r\n normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);\r\n if (hasRings) {\r\n v = cs !== s ? faceUV[s + 1].y : faceUV[s + 1].w;\r\n } else {\r\n v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;\r\n }\r\n uvs.push(faceUV[s + 1].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n uvs.push(faceUV[s + 1].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n if (hasRings) {\r\n v = cs !== s ? faceUV[s + 2].y : faceUV[s + 2].w;\r\n } else {\r\n v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;\r\n }\r\n uvs.push(faceUV[s + 2].x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n uvs.push(faceUV[s + 2].z, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n if (faceColors) {\r\n colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);\r\n colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);\r\n colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);\r\n colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);\r\n }\r\n }\r\n if (cs !== s) {\r\n cs = s;\r\n }\r\n }\r\n }\r\n\r\n // indices\r\n const e: number = arc !== 1 && enclose ? tessellation + 4 : tessellation; // correction of number of iteration if enclose\r\n i = 0;\r\n for (s = 0; s < subdivisions; s++) {\r\n let i0: number = 0;\r\n let i1: number = 0;\r\n let i2: number = 0;\r\n let i3: number = 0;\r\n for (j = 0; j < tessellation; j++) {\r\n i0 = i * (e + 1) + j;\r\n i1 = (i + 1) * (e + 1) + j;\r\n i2 = i * (e + 1) + (j + 1);\r\n i3 = (i + 1) * (e + 1) + (j + 1);\r\n indices.push(i0, i1, i2);\r\n indices.push(i3, i2, i1);\r\n }\r\n if (arc !== 1 && enclose) {\r\n // if enclose, add two quads\r\n indices.push(i0 + 2, i1 + 2, i2 + 2);\r\n indices.push(i3 + 2, i2 + 2, i1 + 2);\r\n indices.push(i0 + 4, i1 + 4, i2 + 4);\r\n indices.push(i3 + 4, i2 + 4, i1 + 4);\r\n }\r\n i = hasRings ? i + 2 : i + 1;\r\n }\r\n\r\n // Caps\r\n const createCylinderCap = (isTop: boolean) => {\r\n const radius = isTop ? diameterTop / 2 : diameterBottom / 2;\r\n if (radius === 0) {\r\n return;\r\n }\r\n\r\n // Cap positions, normals & uvs\r\n let angle;\r\n let circleVector;\r\n let i: number;\r\n const u: Vector4 = isTop ? faceUV[surfaceNb - 1] : faceUV[0];\r\n let c: Nullable<Color4> = null;\r\n if (faceColors) {\r\n c = isTop ? faceColors[surfaceNb - 1] : faceColors[0];\r\n }\r\n // cap center\r\n const vbase = positions.length / 3;\r\n const offset = isTop ? height / 2 : -height / 2;\r\n const center = new Vector3(0, offset, 0);\r\n positions.push(center.x, center.y, center.z);\r\n normals.push(0, isTop ? 1 : -1, 0);\r\n const v = u.y + (u.w - u.y) * 0.5;\r\n uvs.push(u.x + (u.z - u.x) * 0.5, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n if (c) {\r\n colors.push(c.r, c.g, c.b, c.a);\r\n }\r\n\r\n const textureScale = new Vector2(0.5, 0.5);\r\n for (i = 0; i <= tessellation; i++) {\r\n angle = (Math.PI * 2 * i * arc) / tessellation;\r\n const cos = Math.cos(-angle);\r\n const sin = Math.sin(-angle);\r\n circleVector = new Vector3(cos * radius, offset, sin * radius);\r\n const textureCoordinate = new Vector2(cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);\r\n positions.push(circleVector.x, circleVector.y, circleVector.z);\r\n normals.push(0, isTop ? 1 : -1, 0);\r\n const v = u.y + (u.w - u.y) * textureCoordinate.y;\r\n uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);\r\n if (c) {\r\n colors.push(c.r, c.g, c.b, c.a);\r\n }\r\n }\r\n // Cap indices\r\n for (i = 0; i < tessellation; i++) {\r\n if (!isTop) {\r\n indices.push(vbase);\r\n indices.push(vbase + (i + 1));\r\n indices.push(vbase + (i + 2));\r\n } else {\r\n indices.push(vbase);\r\n indices.push(vbase + (i + 2));\r\n indices.push(vbase + (i + 1));\r\n }\r\n }\r\n };\r\n\r\n // add caps to geometry based on cap parameter\r\n if (cap === Mesh.CAP_START || cap === Mesh.CAP_ALL) {\r\n createCylinderCap(false);\r\n }\r\n if (cap === Mesh.CAP_END || cap === Mesh.CAP_ALL) {\r\n createCylinderCap(true);\r\n }\r\n\r\n // Sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n if (faceColors) {\r\n vertexData.colors = colors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a cylinder or a cone mesh\r\n * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).\r\n * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).\r\n * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter \"diameterBottom\" can't be zero.\r\n * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.\r\n * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).\r\n * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.\r\n * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.\r\n * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).\r\n * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.\r\n * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).\r\n * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3\r\n * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7\r\n * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17\r\n * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.\r\n * * If `enclose` is false, a ring surface is one element.\r\n * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.\r\n * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the cylinder mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#cylinder-or-cone\r\n */\r\nexport function CreateCylinder(\r\n name: string,\r\n options: {\r\n height?: number;\r\n diameterTop?: number;\r\n diameterBottom?: number;\r\n diameter?: number;\r\n tessellation?: number;\r\n subdivisions?: number;\r\n arc?: number;\r\n faceColors?: Color4[];\r\n faceUV?: Vector4[];\r\n updatable?: boolean;\r\n hasRings?: boolean;\r\n enclose?: boolean;\r\n cap?: number;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n } = {},\r\n scene?: Nullable<Scene>\r\n): Mesh {\r\n const cylinder = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n cylinder._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateCylinderVertexData(options);\r\n\r\n vertexData.applyToMesh(cylinder, options.updatable);\r\n\r\n return cylinder;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated Please use CreateCylinder directly\r\n */\r\nexport const CylinderBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateCylinder,\r\n};\r\n\r\nVertexData.CreateCylinder = CreateCylinderVertexData;\r\n\r\nMesh.CreateCylinder = (\r\n name: string,\r\n height: number,\r\n diameterTop: number,\r\n diameterBottom: number,\r\n tessellation: number,\r\n subdivisions: any,\r\n scene?: Scene,\r\n updatable?: any,\r\n sideOrientation?: number\r\n): Mesh => {\r\n if (scene === undefined || !(scene instanceof Scene)) {\r\n if (scene !== undefined) {\r\n sideOrientation = updatable || Mesh.DEFAULTSIDE;\r\n updatable = scene;\r\n }\r\n scene = <Scene>subdivisions;\r\n subdivisions = 1;\r\n }\r\n\r\n const options = {\r\n height,\r\n diameterTop,\r\n diameterBottom,\r\n tessellation,\r\n subdivisions,\r\n sideOrientation,\r\n updatable,\r\n };\r\n\r\n return CreateCylinder(name, options, scene);\r\n};\r\n"]}
1
+ {"version":3,"file":"cylinderBuilder.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/cylinderBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E;;;;;;;;;;;;;;;;;;GAkBG;AACH,gEAAgE;AAChE,MAAM,UAAU,wBAAwB,CAAC,OAgBxC;IACG,MAAM,MAAM,GA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AY;QACZ,eAAe;QACf,SAAS;KACZ,CAAC;IAEF,OAAO,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC,CAAC","sourcesContent":["import { Vector4, Vector3, Vector2 } from \"../../Maths/math.vector\";\r\nimport { Color4 } from \"../../Maths/math.color\";\r\nimport { Mesh } from \"../mesh\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { Scene } from \"../../scene\";\r\nimport type { Nullable } from \"../../types\";\r\nimport { Axis } from \"../../Maths/math.axis\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n\r\n/**\r\n * Creates the VertexData for a cylinder, cone or prism\r\n * @param options an object used to set the following optional parameters for the box, required but can be empty\r\n * * height sets the height (y direction) of the cylinder, optional, default 2\r\n * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter\r\n * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter\r\n * * diameter sets the diameter of the top and bottom of the cone, optional default 1\r\n * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24\r\n * * subdivisions` the number of rings along the cylinder height, optional, default 1\r\n * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1\r\n * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively\r\n * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively\r\n * * hasRings when true makes each subdivision independently treated as a face for faceUV and faceColors, optional, default false\r\n * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)\r\n * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)\r\n * @returns the VertexData of the cylinder, cone or prism\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function CreateCylinderVertexData(options: {\r\n height?: number;\r\n diameterTop?: number;\r\n diameterBottom?: number;\r\n diameter?: number;\r\n tessellation?: number;\r\n subdivisions?: number;\r\n arc?: number;\r\n faceColors?: Color4[];\r\n faceUV?: Vector4[];\r\n hasRings?: boolean;\r\n enclose?: boolean;\r\n cap?: number;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n}): VertexData {\r\n const height: number = options.height || 2;\r\n let diameterTop: number = options.diameterTop === 0 ? 0 : options.diameterTop || options.diameter || 1;\r\n let diameterBottom: number = options.diameterBottom === 0 ? 0 : options.diameterBottom || options.diameter || 1;\r\n diameterTop = diameterTop || 0.00001; // Prevent broken normals\r\n diameterBottom = diameterBottom || 0.00001; // Prevent broken normals\r\n const tessellation: number = (options.tessellation || 24) | 0;\r\n const subdivisions: number = (options.subdivisions || 1) | 0;\r\n const hasRings: boolean = options.hasRings ? true : false;\r\n const enclose: boolean = options.enclose ? true : false;\r\n const cap = options.cap === 0 ? 0 : options.cap || Mesh.CAP_ALL;\r\n const arc: number = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;\r\n const sideOrientation: number = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(3);\r\n const faceColors = options.faceColors;\r\n // default face colors and UV if undefined\r\n const quadNb: number = arc !== 1 && enclose ? 2 : 0;\r\n const ringNb: number = hasRings ? subdivisions : 1;\r\n const surfaceNb: number = 2 + (1 + quadNb) * ringNb;\r\n let f: number;\r\n\r\n for (f = 0; f < surfaceNb; f++) {\r\n if (faceColors && faceColors[f] === undefined) {\r\n faceColors[f] = new Color4(1, 1, 1, 1);\r\n }\r\n }\r\n for (f = 0; f < surfaceNb; f++) {\r\n if (faceUV && faceUV[f] === undefined) {\r\n faceUV[f] = new Vector4(0, 0, 1, 1);\r\n }\r\n }\r\n\r\n const indices: number[] = [];\r\n const positions: number[] = [];\r\n const normals: number[] = [];\r\n const uvs: number[] = [];\r\n const colors: number[] = [];\r\n\r\n const angleStep = (Math.PI * 2 * arc) / tessellation;\r\n let angle: number;\r\n let h: number;\r\n let radius: number;\r\n const tan = (diameterBottom - diameterTop) / 2 / height;\r\n const ringVertex: Vector3 = Vector3.Zero();\r\n const ringNormal: Vector3 = Vector3.Zero();\r\n const ringFirstVertex: Vector3 = Vector3.Zero();\r\n const ringFirstNormal: Vector3 = Vector3.Zero();\r\n const quadNormal: Vector3 = Vector3.Zero();\r\n const Y: Vector3 = Axis.Y;\r\n\r\n // positions, normals, uvs\r\n let i: number;\r\n let j: number;\r\n let r: number;\r\n let ringIdx: number = 1;\r\n let s: number = 1; // surface index\r\n let cs: number = 0;\r\n let v: number = 0;\r\n\r\n for (i = 0; i <= subdivisions; i++) {\r\n h = i / subdivisions;\r\n radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;\r\n ringIdx = hasRings && i !== 0 && i !== subdivisions ? 2 : 1;\r\n for (r = 0; r < ringIdx; r++) {\r\n if (hasRings) {\r\n s += r;\r\n }\r\n if (enclose) {\r\n s += 2 * r;\r\n }\r\n for (j = 0; j <= tessellation; j++) {\r\n angle = j * angleStep;\r\n\r\n // position\r\n ringVertex.x = Math.cos(-angle) * radius;\r\n ringVertex.y = -height / 2 + h * height;\r\n ringVertex.z = Math.sin(-angle) * radius;\r\n\r\n // normal\r\n if (diameterTop === 0 && i === subdivisions) {\r\n // if no top cap, reuse former normals\r\n ringNormal.x = normals[normals.length - (tessellation + 1) * 3];\r\n ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];\r\n ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];\r\n } else {\r\n ringNormal.x = ringVertex.x;\r\n ringNormal.z = ringVertex.z;\r\n ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;\r\n ringNormal.normalize();\r\n }\r\n\r\n // keep first ring vertex values for enclose\r\n if (j === 0) {\r\n ringFirstVertex.copyFrom(ringVertex);\r\n ringFirstNormal.copyFrom(ringNormal);\r\n }\r\n\r\n positions.push(ringVertex.x, ringVertex.y, ringVertex.z);\r\n normals.push(ringNormal.x, ringNormal.y, ringNormal.z);\r\n if (hasRings) {\r\n v = cs !== s ? faceUV[s].y : faceUV[s].w;\r\n } else {\r\n v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;\r\n }\r\n uvs.push(faceUV[s].x + ((faceUV[s].z - faceUV[s].x) * j) / tessellation, useOpenGLOrientationForUV ? 1 - v : v);\r\n if (faceColors) {\r\n colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);\r\n }\r\n }\r\n\r\n // if enclose, add four vertices and their dedicated normals\r\n if (arc !== 1 && enclose) {\r\n positions.push(ringVertex.x, ringVertex.y, ringVertex.z);\r\n positions.push(0, ringVertex.y, 0);\r\n positions.push(0, ringVertex.y, 0);\r\n positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);\r\n Vector3.CrossToRef(Y, ringNormal, quadNormal);\r\n quadNormal.normalize();\r\n normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);\r\n Vector3.CrossToRef(ringFirstNormal, Y, quadNormal);\r\n quadNormal.normalize();\r\n normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);\r\n if (hasRings) {\r\n v = cs !== s ? faceUV[s + 1].y : faceUV[s + 1].w;\r\n } else {\r\n v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;\r\n }\r\n uvs.push(faceUV[s + 1].x, useOpenGLOrientationForUV ? 1 - v : v);\r\n uvs.push(faceUV[s + 1].z, useOpenGLOrientationForUV ? 1 - v : v);\r\n if (hasRings) {\r\n v = cs !== s ? faceUV[s + 2].y : faceUV[s + 2].w;\r\n } else {\r\n v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;\r\n }\r\n uvs.push(faceUV[s + 2].x, useOpenGLOrientationForUV ? 1 - v : v);\r\n uvs.push(faceUV[s + 2].z, useOpenGLOrientationForUV ? 1 - v : v);\r\n if (faceColors) {\r\n colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);\r\n colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);\r\n colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);\r\n colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);\r\n }\r\n }\r\n if (cs !== s) {\r\n cs = s;\r\n }\r\n }\r\n }\r\n\r\n // indices\r\n const e: number = arc !== 1 && enclose ? tessellation + 4 : tessellation; // correction of number of iteration if enclose\r\n i = 0;\r\n for (s = 0; s < subdivisions; s++) {\r\n let i0: number = 0;\r\n let i1: number = 0;\r\n let i2: number = 0;\r\n let i3: number = 0;\r\n for (j = 0; j < tessellation; j++) {\r\n i0 = i * (e + 1) + j;\r\n i1 = (i + 1) * (e + 1) + j;\r\n i2 = i * (e + 1) + (j + 1);\r\n i3 = (i + 1) * (e + 1) + (j + 1);\r\n indices.push(i0, i1, i2);\r\n indices.push(i3, i2, i1);\r\n }\r\n if (arc !== 1 && enclose) {\r\n // if enclose, add two quads\r\n indices.push(i0 + 2, i1 + 2, i2 + 2);\r\n indices.push(i3 + 2, i2 + 2, i1 + 2);\r\n indices.push(i0 + 4, i1 + 4, i2 + 4);\r\n indices.push(i3 + 4, i2 + 4, i1 + 4);\r\n }\r\n i = hasRings ? i + 2 : i + 1;\r\n }\r\n\r\n // Caps\r\n const createCylinderCap = (isTop: boolean) => {\r\n const radius = isTop ? diameterTop / 2 : diameterBottom / 2;\r\n if (radius === 0) {\r\n return;\r\n }\r\n\r\n // Cap positions, normals & uvs\r\n let angle;\r\n let circleVector;\r\n let i: number;\r\n const u: Vector4 = isTop ? faceUV[surfaceNb - 1] : faceUV[0];\r\n let c: Nullable<Color4> = null;\r\n if (faceColors) {\r\n c = isTop ? faceColors[surfaceNb - 1] : faceColors[0];\r\n }\r\n // cap center\r\n const vbase = positions.length / 3;\r\n const offset = isTop ? height / 2 : -height / 2;\r\n const center = new Vector3(0, offset, 0);\r\n positions.push(center.x, center.y, center.z);\r\n normals.push(0, isTop ? 1 : -1, 0);\r\n const v = u.y + (u.w - u.y) * 0.5;\r\n uvs.push(u.x + (u.z - u.x) * 0.5, useOpenGLOrientationForUV ? 1 - v : v);\r\n if (c) {\r\n colors.push(c.r, c.g, c.b, c.a);\r\n }\r\n\r\n const textureScale = new Vector2(0.5, 0.5);\r\n for (i = 0; i <= tessellation; i++) {\r\n angle = (Math.PI * 2 * i * arc) / tessellation;\r\n const cos = Math.cos(-angle);\r\n const sin = Math.sin(-angle);\r\n circleVector = new Vector3(cos * radius, offset, sin * radius);\r\n const textureCoordinate = new Vector2(cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);\r\n positions.push(circleVector.x, circleVector.y, circleVector.z);\r\n normals.push(0, isTop ? 1 : -1, 0);\r\n const v = u.y + (u.w - u.y) * textureCoordinate.y;\r\n uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, useOpenGLOrientationForUV ? 1 - v : v);\r\n if (c) {\r\n colors.push(c.r, c.g, c.b, c.a);\r\n }\r\n }\r\n // Cap indices\r\n for (i = 0; i < tessellation; i++) {\r\n if (!isTop) {\r\n indices.push(vbase);\r\n indices.push(vbase + (i + 1));\r\n indices.push(vbase + (i + 2));\r\n } else {\r\n indices.push(vbase);\r\n indices.push(vbase + (i + 2));\r\n indices.push(vbase + (i + 1));\r\n }\r\n }\r\n };\r\n\r\n // add caps to geometry based on cap parameter\r\n if (cap === Mesh.CAP_START || cap === Mesh.CAP_ALL) {\r\n createCylinderCap(false);\r\n }\r\n if (cap === Mesh.CAP_END || cap === Mesh.CAP_ALL) {\r\n createCylinderCap(true);\r\n }\r\n\r\n // Sides\r\n VertexData._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);\r\n\r\n const vertexData = new VertexData();\r\n\r\n vertexData.indices = indices;\r\n vertexData.positions = positions;\r\n vertexData.normals = normals;\r\n vertexData.uvs = uvs;\r\n if (faceColors) {\r\n vertexData.colors = colors;\r\n }\r\n\r\n return vertexData;\r\n}\r\n\r\n/**\r\n * Creates a cylinder or a cone mesh\r\n * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).\r\n * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).\r\n * * The parameters `diameterTop` and `diameterBottom` overwrite the parameter `diameter` and set respectively the top cap and bottom cap diameter (floats, default 1). The parameter \"diameterBottom\" can't be zero.\r\n * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.\r\n * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).\r\n * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.\r\n * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.\r\n * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).\r\n * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.\r\n * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of n Color3 elements) and `faceUV` (an array of n Vector4 elements).\r\n * * The value of n is the number of cylinder faces. If the cylinder has only 1 subdivisions, n equals : top face + cylinder surface + bottom face = 3\r\n * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7\r\n * * Finally, if the cylinder has 5 independent subdivisions and is enclose, n equals : top face + 5 x (stripe surface + 2 closing faces) + bottom face = 2 + 5 * 3 = 17\r\n * * Each array (color or UVs) is always ordered the same way : the first element is the bottom cap, the last element is the top cap. The other elements are each a ring surface.\r\n * * If `enclose` is false, a ring surface is one element.\r\n * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.\r\n * * Example how to set colors and textures on a sliced cylinder : https://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379\r\n * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE\r\n * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#side-orientation\r\n * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.\r\n * @param name defines the name of the mesh\r\n * @param options defines the options used to create the mesh\r\n * @param scene defines the hosting scene\r\n * @returns the cylinder mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set#cylinder-or-cone\r\n */\r\nexport function CreateCylinder(\r\n name: string,\r\n options: {\r\n height?: number;\r\n diameterTop?: number;\r\n diameterBottom?: number;\r\n diameter?: number;\r\n tessellation?: number;\r\n subdivisions?: number;\r\n arc?: number;\r\n faceColors?: Color4[];\r\n faceUV?: Vector4[];\r\n updatable?: boolean;\r\n hasRings?: boolean;\r\n enclose?: boolean;\r\n cap?: number;\r\n sideOrientation?: number;\r\n frontUVs?: Vector4;\r\n backUVs?: Vector4;\r\n } = {},\r\n scene?: Nullable<Scene>\r\n): Mesh {\r\n const cylinder = new Mesh(name, scene);\r\n\r\n options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);\r\n cylinder._originalBuilderSideOrientation = options.sideOrientation;\r\n\r\n const vertexData = CreateCylinderVertexData(options);\r\n\r\n vertexData.applyToMesh(cylinder, options.updatable);\r\n\r\n return cylinder;\r\n}\r\n\r\n/**\r\n * Class containing static functions to help procedurally build meshes\r\n * @deprecated Please use CreateCylinder directly\r\n */\r\nexport const CylinderBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateCylinder,\r\n};\r\n\r\nVertexData.CreateCylinder = CreateCylinderVertexData;\r\n\r\nMesh.CreateCylinder = (\r\n name: string,\r\n height: number,\r\n diameterTop: number,\r\n diameterBottom: number,\r\n tessellation: number,\r\n subdivisions: any,\r\n scene?: Scene,\r\n updatable?: any,\r\n sideOrientation?: number\r\n): Mesh => {\r\n if (scene === undefined || !(scene instanceof Scene)) {\r\n if (scene !== undefined) {\r\n sideOrientation = updatable || Mesh.DEFAULTSIDE;\r\n updatable = scene;\r\n }\r\n scene = <Scene>subdivisions;\r\n subdivisions = 1;\r\n }\r\n\r\n const options = {\r\n height,\r\n diameterTop,\r\n diameterBottom,\r\n tessellation,\r\n subdivisions,\r\n sideOrientation,\r\n updatable,\r\n };\r\n\r\n return CreateCylinder(name, options, scene);\r\n};\r\n"]}
@@ -3,7 +3,7 @@ import { Scalar } from "../../Maths/math.scalar.js";
3
3
  import { Mesh } from "../mesh.js";
4
4
  import { VertexBuffer } from "../../Buffers/buffer.js";
5
5
  import { VertexData } from "../mesh.vertexData.js";
6
- import { CompatibilityOptions } from "../../Compat/compatibilityOptions.js";
6
+ import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
7
7
  const xpAxis = new Vector3(1, 0, 0);
8
8
  const xnAxis = new Vector3(-1, 0, 0);
9
9
  const ypAxis = new Vector3(0, 1, 0);
@@ -98,7 +98,7 @@ export function CreateDecal(name, sourceMesh, options) {
98
98
  Vector3.TransformNormalToRef(result.normal, transformMatrix, result.normal);
99
99
  if (options.captureUVS && uvs) {
100
100
  const v = uvs[vertexId * 2 + 1];
101
- result.uv = new Vector2(uvs[vertexId * 2], CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
101
+ result.uv = new Vector2(uvs[vertexId * 2], useOpenGLOrientationForUV ? 1 - v : v);
102
102
  }
103
103
  return result;
104
104
  };
@@ -400,7 +400,7 @@ export function CreateDecal(name, sourceMesh, options) {
400
400
  if (!options.captureUVS) {
401
401
  vertexData.uvs.push(0.5 + vertex.position.x / size.x);
402
402
  const v = 0.5 + vertex.position.y / size.y;
403
- vertexData.uvs.push(CompatibilityOptions.UseOpenGLOrientationForUV ? 1 - v : v);
403
+ vertexData.uvs.push(useOpenGLOrientationForUV ? 1 - v : v);
404
404
  }
405
405
  else {
406
406
  vertex.uv.toArray(vertexData.uvs, currentVertexDataIndex * 2);