@onerjs/core 8.54.1 → 8.54.3

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 (238) hide show
  1. package/Animations/animatable.core.js.map +1 -1
  2. package/AudioV2/abstractAudio/abstractSoundSource.d.ts +26 -0
  3. package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
  4. package/AudioV2/webAudio/webAudioEngine.js +2 -0
  5. package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
  6. package/AudioV2/webAudio/webAudioSoundSource.d.ts +16 -0
  7. package/AudioV2/webAudio/webAudioSoundSource.js +43 -1
  8. package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
  9. package/Bones/skeleton.functions.js +1 -1
  10. package/Bones/skeleton.functions.js.map +1 -1
  11. package/Cameras/inputMapper.js.map +1 -1
  12. package/Collisions/gpuPicker.js +7 -6
  13. package/Collisions/gpuPicker.js.map +1 -1
  14. package/Debug/physicsViewer.pure.js +1 -1
  15. package/Debug/physicsViewer.pure.js.map +1 -1
  16. package/Engines/Extensions/engine.alphaToCoverage.d.ts +6 -0
  17. package/Engines/Extensions/engine.alphaToCoverage.js +9 -0
  18. package/Engines/Extensions/engine.alphaToCoverage.js.map +1 -0
  19. package/Engines/Extensions/engine.alphaToCoverage.pure.d.ts +6 -0
  20. package/Engines/Extensions/engine.alphaToCoverage.pure.js +54 -0
  21. package/Engines/Extensions/engine.alphaToCoverage.pure.js.map +1 -0
  22. package/Engines/Extensions/engine.alphaToCoverage.types.d.ts +21 -0
  23. package/Engines/Extensions/engine.alphaToCoverage.types.js +2 -0
  24. package/Engines/Extensions/engine.alphaToCoverage.types.js.map +1 -0
  25. package/Engines/Extensions/engine.texture2DArrayImageSource.d.ts +6 -0
  26. package/Engines/Extensions/engine.texture2DArrayImageSource.js +9 -0
  27. package/Engines/Extensions/engine.texture2DArrayImageSource.js.map +1 -0
  28. package/Engines/Extensions/engine.texture2DArrayImageSource.pure.d.ts +7 -0
  29. package/Engines/Extensions/engine.texture2DArrayImageSource.pure.js +40 -0
  30. package/Engines/Extensions/engine.texture2DArrayImageSource.pure.js.map +1 -0
  31. package/Engines/Extensions/engine.texture2DArrayImageSource.types.d.ts +21 -0
  32. package/Engines/Extensions/engine.texture2DArrayImageSource.types.js +2 -0
  33. package/Engines/Extensions/engine.texture2DArrayImageSource.types.js.map +1 -0
  34. package/Engines/Extensions/index.d.ts +1 -0
  35. package/Engines/Extensions/index.js +1 -0
  36. package/Engines/Extensions/index.js.map +1 -1
  37. package/Engines/Extensions/pure.d.ts +2 -0
  38. package/Engines/Extensions/pure.js +2 -0
  39. package/Engines/Extensions/pure.js.map +1 -1
  40. package/Engines/Native/nativeHelpers.js +6 -4
  41. package/Engines/Native/nativeHelpers.js.map +1 -1
  42. package/Engines/Native/nativeInterfaces.d.ts +1 -0
  43. package/Engines/Native/nativeInterfaces.js.map +1 -1
  44. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.d.ts +6 -0
  45. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.js +9 -0
  46. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.js.map +1 -0
  47. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.d.ts +6 -0
  48. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.js +34 -0
  49. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.js.map +1 -0
  50. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.d.ts +16 -0
  51. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.js +2 -0
  52. package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.js.map +1 -0
  53. package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.d.ts +6 -0
  54. package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.js +9 -0
  55. package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.js.map +1 -0
  56. package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.pure.d.ts +7 -0
  57. package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.pure.js +23 -0
  58. package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.pure.js.map +1 -0
  59. package/Engines/WebGPU/Extensions/index.d.ts +1 -0
  60. package/Engines/WebGPU/Extensions/index.js +1 -0
  61. package/Engines/WebGPU/Extensions/index.js.map +1 -1
  62. package/Engines/WebGPU/Extensions/pure.d.ts +2 -0
  63. package/Engines/WebGPU/Extensions/pure.js +2 -0
  64. package/Engines/WebGPU/Extensions/pure.js.map +1 -1
  65. package/Engines/WebGPU/webgpuCacheRenderPipeline.js +0 -1
  66. package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
  67. package/Engines/abstractEngine.pure.d.ts +0 -15
  68. package/Engines/abstractEngine.pure.js +2 -23
  69. package/Engines/abstractEngine.pure.js.map +1 -1
  70. package/Engines/constants.d.ts +4 -0
  71. package/Engines/constants.js +4 -0
  72. package/Engines/constants.js.map +1 -1
  73. package/Engines/engine.d.ts +32 -2
  74. package/Engines/engine.js +1 -0
  75. package/Engines/engine.js.map +1 -1
  76. package/Engines/engine.pure.js +1 -1
  77. package/Engines/engine.pure.js.map +1 -1
  78. package/Engines/thinEngine.pure.d.ts +0 -11
  79. package/Engines/thinEngine.pure.js +0 -19
  80. package/Engines/thinEngine.pure.js.map +1 -1
  81. package/Engines/thinNativeEngine.pure.js +4 -4
  82. package/Engines/thinNativeEngine.pure.js.map +1 -1
  83. package/Engines/webgpuEngine.d.ts +2 -0
  84. package/Engines/webgpuEngine.js +2 -0
  85. package/Engines/webgpuEngine.js.map +1 -1
  86. package/Engines/webgpuEngine.pure.d.ts +0 -5
  87. package/Engines/webgpuEngine.pure.js +1 -10
  88. package/Engines/webgpuEngine.pure.js.map +1 -1
  89. package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
  90. package/Lights/Clustered/clusteredLightContainer.pure.js +6 -0
  91. package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
  92. package/Loading/Plugins/babylonFileLoader.d.ts +10 -0
  93. package/Loading/Plugins/babylonFileLoader.js +18 -0
  94. package/Loading/Plugins/babylonFileLoader.js.map +1 -1
  95. package/Loading/Plugins/babylonFileLoader.pure.js +10 -2
  96. package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
  97. package/Loading/loadingScreen.pure.js +2 -0
  98. package/Loading/loadingScreen.pure.js.map +1 -1
  99. package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
  100. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +2 -1
  101. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
  102. package/Materials/Node/nodeMaterial.pure.d.ts +13 -5
  103. package/Materials/Node/nodeMaterial.pure.js +20 -2
  104. package/Materials/Node/nodeMaterial.pure.js.map +1 -1
  105. package/Materials/Textures/index.d.ts +1 -0
  106. package/Materials/Textures/index.js +1 -0
  107. package/Materials/Textures/index.js.map +1 -1
  108. package/Materials/Textures/ktx2decoderTypes.d.ts +14 -3
  109. package/Materials/Textures/ktx2decoderTypes.js +2 -0
  110. package/Materials/Textures/ktx2decoderTypes.js.map +1 -1
  111. package/Materials/Textures/pure.d.ts +1 -0
  112. package/Materials/Textures/pure.js +1 -0
  113. package/Materials/Textures/pure.js.map +1 -1
  114. package/Materials/Textures/rawTexture2DArray.functions.d.ts +95 -0
  115. package/Materials/Textures/rawTexture2DArray.functions.js +201 -0
  116. package/Materials/Textures/rawTexture2DArray.functions.js.map +1 -0
  117. package/Materials/Textures/renderTargetTexture.pure.js +7 -0
  118. package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
  119. package/Materials/material.pure.d.ts +1 -0
  120. package/Materials/material.pure.js +1 -0
  121. package/Materials/material.pure.js.map +1 -1
  122. package/Meshes/Builders/pure.d.ts +2 -2
  123. package/Meshes/Builders/pure.js +2 -2
  124. package/Meshes/Builders/pure.js.map +1 -1
  125. package/Meshes/Builders/textBuilder.js.map +1 -1
  126. package/Meshes/Builders/tiledBoxBuilder.d.ts +1 -83
  127. package/Meshes/Builders/tiledBoxBuilder.js +3 -215
  128. package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
  129. package/Meshes/Builders/tiledBoxBuilder.pure.d.ts +89 -0
  130. package/Meshes/Builders/tiledBoxBuilder.pure.js +229 -0
  131. package/Meshes/Builders/tiledBoxBuilder.pure.js.map +1 -0
  132. package/Meshes/Builders/tiledPlaneBuilder.d.ts +1 -79
  133. package/Meshes/Builders/tiledPlaneBuilder.js +3 -429
  134. package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
  135. package/Meshes/Builders/tiledPlaneBuilder.pure.d.ts +85 -0
  136. package/Meshes/Builders/tiledPlaneBuilder.pure.js +442 -0
  137. package/Meshes/Builders/tiledPlaneBuilder.pure.js.map +1 -0
  138. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +13 -0
  139. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +15 -0
  140. package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
  141. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +29 -9
  142. package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
  143. package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
  144. package/Meshes/meshBuilder.d.ts +21 -57
  145. package/Meshes/meshBuilder.js +21 -58
  146. package/Meshes/meshBuilder.js.map +1 -1
  147. package/Meshes/meshBuilder.pure.d.ts +58 -0
  148. package/Meshes/meshBuilder.pure.js +60 -0
  149. package/Meshes/meshBuilder.pure.js.map +1 -0
  150. package/Meshes/pure.d.ts +1 -1
  151. package/Meshes/pure.js +1 -1
  152. package/Meshes/pure.js.map +1 -1
  153. package/Misc/greasedLineTools.js.map +1 -1
  154. package/Misc/khronosTextureContainer2.d.ts +10 -0
  155. package/Misc/khronosTextureContainer2.js +23 -12
  156. package/Misc/khronosTextureContainer2.js.map +1 -1
  157. package/Misc/perfCounter.d.ts +2 -0
  158. package/Misc/perfCounter.js +17 -2
  159. package/Misc/perfCounter.js.map +1 -1
  160. package/Misc/rgbdTextureTools.js +1 -1
  161. package/Misc/rgbdTextureTools.js.map +1 -1
  162. package/Misc/snapshotRenderingHelper.js +2 -1
  163. package/Misc/snapshotRenderingHelper.js.map +1 -1
  164. package/Misc/tools.pure.js +1 -1
  165. package/Misc/tools.pure.js.map +1 -1
  166. package/Navigation/Plugins/recastJSPlugin.js +1 -1
  167. package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
  168. package/Physics/v2/Plugins/havokPlugin.js +15 -0
  169. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  170. package/Physics/v2/characterController.d.ts +17 -0
  171. package/Physics/v2/characterController.js +40 -0
  172. package/Physics/v2/characterController.js.map +1 -1
  173. package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js.map +1 -1
  174. package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
  175. package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
  176. package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +3 -0
  177. package/PostProcesses/volumetricLightScatteringPostProcess.js +3 -0
  178. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  179. package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +1 -0
  180. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +25 -6
  181. package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
  182. package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +3 -1
  183. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +25 -4
  184. package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
  185. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +6 -5
  186. package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
  187. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +3 -1
  188. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +16 -4
  189. package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
  190. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +6 -5
  191. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
  192. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +3 -1
  193. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +16 -4
  194. package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
  195. package/Rendering/depthRenderer.d.ts +2 -0
  196. package/Rendering/depthRenderer.js +2 -0
  197. package/Rendering/depthRenderer.js.map +1 -1
  198. package/Rendering/depthRenderer.pure.js +3 -2
  199. package/Rendering/depthRenderer.pure.js.map +1 -1
  200. package/Rendering/fluidRenderer/fluidRenderer.pure.js +6 -0
  201. package/Rendering/fluidRenderer/fluidRenderer.pure.js.map +1 -1
  202. package/Rendering/geometryBufferRenderer.pure.js +5 -5
  203. package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
  204. package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +6 -6
  205. package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
  206. package/ShadersWGSL/ShadersInclude/depthPrePass.js +2 -0
  207. package/ShadersWGSL/ShadersInclude/depthPrePass.js.map +1 -1
  208. package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js +7 -8
  209. package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
  210. package/ShadersWGSL/default.fragment.js +3 -0
  211. package/ShadersWGSL/default.fragment.js.map +1 -1
  212. package/ShadersWGSL/openpbr.fragment.js +3 -0
  213. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  214. package/ShadersWGSL/pbr.fragment.js +3 -0
  215. package/ShadersWGSL/pbr.fragment.js.map +1 -1
  216. package/ShadersWGSL/volumetricLightScattering.fragment.d.ts +5 -0
  217. package/ShadersWGSL/volumetricLightScattering.fragment.js +20 -0
  218. package/ShadersWGSL/volumetricLightScattering.fragment.js.map +1 -0
  219. package/ShadersWGSL/volumetricLightScatteringPass.fragment.d.ts +5 -0
  220. package/ShadersWGSL/volumetricLightScatteringPass.fragment.js +24 -0
  221. package/ShadersWGSL/volumetricLightScatteringPass.fragment.js.map +1 -0
  222. package/ShadersWGSL/volumetricLightScatteringPass.vertex.d.ts +5 -0
  223. package/ShadersWGSL/volumetricLightScatteringPass.vertex.js +67 -0
  224. package/ShadersWGSL/volumetricLightScatteringPass.vertex.js.map +1 -0
  225. package/SmartAssets/smartAssetManager.pure.js +9 -1
  226. package/SmartAssets/smartAssetManager.pure.js.map +1 -1
  227. package/States/alphaCullingState.d.ts +0 -9
  228. package/States/alphaCullingState.js +4 -31
  229. package/States/alphaCullingState.js.map +1 -1
  230. package/XR/features/WebXRBodyTracking.pure.d.ts +0 -28
  231. package/XR/features/WebXRBodyTracking.pure.js.map +1 -1
  232. package/XR/features/WebXRLayers.pure.js +4 -4
  233. package/XR/features/WebXRLayers.pure.js.map +1 -1
  234. package/node.d.ts +18 -1
  235. package/node.js +52 -1
  236. package/node.js.map +1 -1
  237. package/package.json +1 -1
  238. package/types.js.map +1 -1
@@ -0,0 +1,229 @@
1
+ /** This file must only contain pure code and pure imports */
2
+ import { Matrix, Vector3, Vector4 } from "../../Maths/math.vector.pure.js";
3
+ import { Color4 } from "../../Maths/math.color.pure.js";
4
+ import { Mesh } from "../mesh.pure.js";
5
+ import { VertexData } from "../mesh.vertexData.js";
6
+ import { CreateTiledPlaneVertexData, RegisterTiledPlaneBuilder } from "./tiledPlaneBuilder.pure.js";
7
+ import { useOpenGLOrientationForUV } from "../../Compat/compatibilityOptions.js";
8
+ const OP_ADD = 1;
9
+ const OP_SUB = -1;
10
+ /**
11
+ * Creates the VertexData for a tiled box
12
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
13
+ * @param options an object used to set the following optional parameters for the tiled box, required but can be empty
14
+ * * pattern sets the rotation or reflection pattern for the tiles,
15
+ * * size of the box
16
+ * * width of the box, overwrites size
17
+ * * height of the box, overwrites size
18
+ * * depth of the box, overwrites size
19
+ * * tileSize sets the size of a tile
20
+ * * tileWidth sets the tile width and overwrites tileSize
21
+ * * tileHeight sets the tile width and overwrites tileSize
22
+ * * faceUV an array of 6 Vector4 elements used to set different images to each box side
23
+ * * faceColors an array of 6 Color4 elements used to set different colors to each box side
24
+ * * alignHorizontal places whole tiles aligned to the center, left or right of a row
25
+ * * alignVertical places whole tiles aligned to the center, left or right of a column
26
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
27
+ * @returns the VertexData of the TiledBox
28
+ */
29
+ export function CreateTiledBoxVertexData(options) {
30
+ const nbFaces = 6;
31
+ const faceUV = options.faceUV || new Array(6);
32
+ const faceColors = options.faceColors;
33
+ const flipTile = options.pattern || Mesh.NO_FLIP;
34
+ const width = options.width || options.size || 1;
35
+ const height = options.height || options.size || 1;
36
+ const depth = options.depth || options.size || 1;
37
+ const tileWidth = options.tileWidth || options.tileSize || 1;
38
+ const tileHeight = options.tileHeight || options.tileSize || 1;
39
+ const alignH = options.alignHorizontal || 0;
40
+ const alignV = options.alignVertical || 0;
41
+ const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;
42
+ // default face colors and UV if undefined
43
+ for (let f = 0; f < nbFaces; f++) {
44
+ if (faceUV[f] === undefined) {
45
+ faceUV[f] = new Vector4(0, 0, 1, 1);
46
+ }
47
+ if (faceColors && faceColors[f] === undefined) {
48
+ faceColors[f] = new Color4(1, 1, 1, 1);
49
+ }
50
+ }
51
+ const halfWidth = width / 2;
52
+ const halfHeight = height / 2;
53
+ const halfDepth = depth / 2;
54
+ const faceVertexData = [];
55
+ for (let f = 0; f < 2; f++) {
56
+ //front and back
57
+ faceVertexData[f] = CreateTiledPlaneVertexData({
58
+ pattern: flipTile,
59
+ tileWidth: tileWidth,
60
+ tileHeight: tileHeight,
61
+ width: width,
62
+ height: height,
63
+ alignVertical: alignV,
64
+ alignHorizontal: alignH,
65
+ sideOrientation: sideOrientation,
66
+ });
67
+ }
68
+ for (let f = 2; f < 4; f++) {
69
+ //sides
70
+ faceVertexData[f] = CreateTiledPlaneVertexData({
71
+ pattern: flipTile,
72
+ tileWidth: tileWidth,
73
+ tileHeight: tileHeight,
74
+ width: depth,
75
+ height: height,
76
+ alignVertical: alignV,
77
+ alignHorizontal: alignH,
78
+ sideOrientation: sideOrientation,
79
+ });
80
+ }
81
+ let baseAlignV = alignV;
82
+ if (alignV === Mesh.BOTTOM) {
83
+ baseAlignV = Mesh.TOP;
84
+ }
85
+ else if (alignV === Mesh.TOP) {
86
+ baseAlignV = Mesh.BOTTOM;
87
+ }
88
+ for (let f = 4; f < 6; f++) {
89
+ //top and bottom
90
+ faceVertexData[f] = CreateTiledPlaneVertexData({
91
+ pattern: flipTile,
92
+ tileWidth: tileWidth,
93
+ tileHeight: tileHeight,
94
+ width: width,
95
+ height: depth,
96
+ alignVertical: baseAlignV,
97
+ alignHorizontal: alignH,
98
+ sideOrientation: sideOrientation,
99
+ });
100
+ }
101
+ const positions = [];
102
+ const normals = [];
103
+ let uvs = [];
104
+ let indices = [];
105
+ const colors = [];
106
+ const facePositions = [];
107
+ const faceNormals = [];
108
+ const newFaceUV = [];
109
+ let lu;
110
+ let li = 0;
111
+ for (let f = 0; f < nbFaces; f++) {
112
+ const len = faceVertexData[f].positions.length;
113
+ facePositions[f] = [];
114
+ faceNormals[f] = [];
115
+ for (let p = 0; p < len / 3; p++) {
116
+ facePositions[f].push(new Vector3(faceVertexData[f].positions[3 * p], faceVertexData[f].positions[3 * p + 1], faceVertexData[f].positions[3 * p + 2]));
117
+ faceNormals[f].push(new Vector3(faceVertexData[f].normals[3 * p], faceVertexData[f].normals[3 * p + 1], faceVertexData[f].normals[3 * p + 2]));
118
+ }
119
+ // uvs
120
+ lu = faceVertexData[f].uvs.length;
121
+ newFaceUV[f] = [];
122
+ for (let i = 0; i < lu; i += 2) {
123
+ newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs[i];
124
+ newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs[i + 1];
125
+ if (useOpenGLOrientationForUV) {
126
+ newFaceUV[f][i + 1] = 1.0 - newFaceUV[f][i + 1];
127
+ }
128
+ }
129
+ uvs = uvs.concat(newFaceUV[f]);
130
+ indices = indices.concat(faceVertexData[f].indices.map((x) => x + li));
131
+ li += facePositions[f].length;
132
+ if (faceColors) {
133
+ const color = faceColors[f];
134
+ for (let p = 0; p < facePositions[f].length; p++) {
135
+ colors.push(color.r, color.g, color.b, color.a);
136
+ }
137
+ }
138
+ }
139
+ // Define transforms for each face
140
+ const faceTransforms = [
141
+ // FRONT
142
+ { m: Matrix.RotationY(Math.PI), t: new Vector3(0, 0, halfDepth), op: OP_ADD },
143
+ // BACK
144
+ { m: Matrix.Identity(), t: new Vector3(0, 0, halfDepth), op: OP_SUB },
145
+ // RIGHT
146
+ { m: Matrix.RotationY(-Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_ADD },
147
+ // LEFT
148
+ { m: Matrix.RotationY(Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_SUB },
149
+ // TOP
150
+ { m: Matrix.RotationX(Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_ADD },
151
+ // BOTTOM
152
+ { m: Matrix.RotationX(-Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_SUB },
153
+ ];
154
+ // Assemble positions and normals
155
+ for (let f = 0; f < nbFaces; f++) {
156
+ const { m, t, op } = faceTransforms[f];
157
+ for (const v of facePositions[f]) {
158
+ const p = Vector3.TransformCoordinates(v, m);
159
+ const final = op === OP_ADD ? p.add(t) : p.subtract(t);
160
+ positions.push(final.x, final.y, final.z);
161
+ }
162
+ for (const n of faceNormals[f]) {
163
+ const nn = Vector3.TransformNormal(n, m);
164
+ normals.push(nn.x, nn.y, nn.z);
165
+ }
166
+ }
167
+ // Result
168
+ const vertexData = new VertexData();
169
+ vertexData.indices = indices;
170
+ vertexData.positions = positions;
171
+ vertexData.normals = normals;
172
+ vertexData.uvs = uvs;
173
+ if (faceColors) {
174
+ const totalColors = sideOrientation === VertexData.DOUBLESIDE ? colors.concat(colors) : colors;
175
+ vertexData.colors = totalColors;
176
+ }
177
+ return vertexData;
178
+ }
179
+ /**
180
+ * Creates a tiled box mesh
181
+ * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box
182
+ * @param name defines the name of the mesh
183
+ * @param options an object used to set the following optional parameters for the tiled box, required but can be empty
184
+ * * pattern sets the rotation or reflection pattern for the tiles,
185
+ * * size of the box
186
+ * * width of the box, overwrites size
187
+ * * height of the box, overwrites size
188
+ * * depth of the box, overwrites size
189
+ * * tileSize sets the size of a tile
190
+ * * tileWidth sets the tile width and overwrites tileSize
191
+ * * tileHeight sets the tile width and overwrites tileSize
192
+ * * faceUV an array of 6 Vector4 elements used to set different images to each box side
193
+ * * faceColors an array of 6 Color3 elements used to set different colors to each box side
194
+ * * alignHorizontal places whole tiles aligned to the center, left or right of a row
195
+ * * alignVertical places whole tiles aligned to the center, left or right of a column
196
+ * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
197
+ * @param scene defines the hosting scene
198
+ * @returns the box mesh
199
+ */
200
+ export function CreateTiledBox(name, options, scene = null) {
201
+ const box = new Mesh(name, scene);
202
+ options.sideOrientation = Mesh._GetDefaultSideOrientation(options.sideOrientation);
203
+ box._originalBuilderSideOrientation = options.sideOrientation;
204
+ const vertexData = CreateTiledBoxVertexData(options);
205
+ vertexData.applyToMesh(box, options.updatable);
206
+ return box;
207
+ }
208
+ /**
209
+ * Class containing static functions to help procedurally build meshes
210
+ * @deprecated use CreateTiledBox instead
211
+ */
212
+ export const TiledBoxBuilder = {
213
+ // eslint-disable-next-line @typescript-eslint/naming-convention
214
+ CreateTiledBox,
215
+ };
216
+ let _Registered = false;
217
+ /**
218
+ * Register side effects for the tiled box builder.
219
+ * Safe to call multiple times; only the first call has an effect.
220
+ */
221
+ export function RegisterTiledBoxBuilder() {
222
+ if (_Registered) {
223
+ return;
224
+ }
225
+ _Registered = true;
226
+ RegisterTiledPlaneBuilder();
227
+ VertexData.CreateTiledBox = CreateTiledBoxVertexData;
228
+ }
229
+ //# sourceMappingURL=tiledBoxBuilder.pure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tiledBoxBuilder.pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Meshes/Builders/tiledBoxBuilder.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAI7D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACjG,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,MAAM,GAAG,CAAC,CAAC,CAAC;AAElB;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAcxC;IACG,MAAM,OAAO,GAAG,CAAC,CAAC;IAElB,MAAM,MAAM,GAAc,OAAO,CAAC,MAAM,IAAI,IAAI,KAAK,CAAU,CAAC,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAEtC,MAAM,QAA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AAG,IAAI,CAAC,0BAA0B,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnF,GAAG,CAAC,+BAA+B,GAAG,OAAO,CAAC,eAAe,CAAC;IAE9D,MAAM,UAAU,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAErD,UAAU,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAE/C,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,gEAAgE;IAChE,cAAc;CACjB,CAAC;AAEF,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACnC,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,yBAAyB,EAAE,CAAC;IAC5B,UAAU,CAAC,cAAc,GAAG,wBAAwB,CAAC;AACzD,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { type Nullable } from \"../../types\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { Matrix, Vector3, Vector4 } from \"../../Maths/math.vector.pure\";\r\nimport { Color4 } from \"../../Maths/math.color.pure\";\r\nimport { Mesh } from \"../mesh.pure\";\r\nimport { VertexData } from \"../mesh.vertexData\";\r\nimport { CreateTiledPlaneVertexData, RegisterTiledPlaneBuilder } from \"./tiledPlaneBuilder.pure\";\r\nimport { useOpenGLOrientationForUV } from \"../../Compat/compatibilityOptions\";\r\n\r\nconst OP_ADD = 1;\r\nconst OP_SUB = -1;\r\n\r\n/**\r\n * Creates the VertexData for a tiled box\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\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 Color4 elements used to set different colors to each box side\r\n * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @returns the VertexData of the TiledBox\r\n */\r\nexport function CreateTiledBoxVertexData(options: {\r\n pattern?: number;\r\n size?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n sideOrientation?: number;\r\n}): VertexData {\r\n const nbFaces = 6;\r\n\r\n const faceUV: Vector4[] = options.faceUV || new Array<Vector4>(6);\r\n const faceColors = options.faceColors;\r\n\r\n const flipTile = options.pattern || Mesh.NO_FLIP;\r\n\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 tileWidth = options.tileWidth || options.tileSize || 1;\r\n const tileHeight = options.tileHeight || options.tileSize || 1;\r\n const alignH = options.alignHorizontal || 0;\r\n const alignV = options.alignVertical || 0;\r\n\r\n const sideOrientation = options.sideOrientation === 0 ? 0 : options.sideOrientation || VertexData.DEFAULTSIDE;\r\n\r\n // default face colors and UV if undefined\r\n for (let f = 0; f < nbFaces; 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 const halfWidth = width / 2;\r\n const halfHeight = height / 2;\r\n const halfDepth = depth / 2;\r\n\r\n const faceVertexData: Array<VertexData> = [];\r\n\r\n for (let f = 0; f < 2; f++) {\r\n //front and back\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n for (let f = 2; f < 4; f++) {\r\n //sides\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: depth,\r\n height: height,\r\n alignVertical: alignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n let baseAlignV = alignV;\r\n if (alignV === Mesh.BOTTOM) {\r\n baseAlignV = Mesh.TOP;\r\n } else if (alignV === Mesh.TOP) {\r\n baseAlignV = Mesh.BOTTOM;\r\n }\r\n\r\n for (let f = 4; f < 6; f++) {\r\n //top and bottom\r\n faceVertexData[f] = CreateTiledPlaneVertexData({\r\n pattern: flipTile,\r\n tileWidth: tileWidth,\r\n tileHeight: tileHeight,\r\n width: width,\r\n height: depth,\r\n alignVertical: baseAlignV,\r\n alignHorizontal: alignH,\r\n sideOrientation: sideOrientation,\r\n });\r\n }\r\n\r\n const positions: Array<number> = [];\r\n const normals: Array<number> = [];\r\n let uvs: Array<number> = [];\r\n let indices: Array<number> = [];\r\n const colors: Array<number> = [];\r\n const facePositions: Array<Array<Vector3>> = [];\r\n const faceNormals: Array<Array<Vector3>> = [];\r\n\r\n const newFaceUV: Array<Array<number>> = [];\r\n let lu: number;\r\n\r\n let li: number = 0;\r\n\r\n for (let f = 0; f < nbFaces; f++) {\r\n const len = faceVertexData[f].positions!.length;\r\n facePositions[f] = [];\r\n faceNormals[f] = [];\r\n for (let p = 0; p < len / 3; p++) {\r\n facePositions[f].push(new Vector3(faceVertexData[f].positions![3 * p], faceVertexData[f].positions![3 * p + 1], faceVertexData[f].positions![3 * p + 2]));\r\n faceNormals[f].push(new Vector3(faceVertexData[f].normals![3 * p], faceVertexData[f].normals![3 * p + 1], faceVertexData[f].normals![3 * p + 2]));\r\n }\r\n // uvs\r\n lu = faceVertexData[f].uvs!.length;\r\n newFaceUV[f] = [];\r\n for (let i = 0; i < lu; i += 2) {\r\n newFaceUV[f][i] = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * faceVertexData[f].uvs![i];\r\n newFaceUV[f][i + 1] = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * faceVertexData[f].uvs![i + 1];\r\n\r\n if (useOpenGLOrientationForUV) {\r\n newFaceUV[f][i + 1] = 1.0 - newFaceUV[f][i + 1];\r\n }\r\n }\r\n uvs = uvs.concat(newFaceUV[f]);\r\n\r\n indices = indices.concat(<Array<number>>faceVertexData[f].indices!.map((x: number) => x + li));\r\n li += facePositions[f].length;\r\n if (faceColors) {\r\n const color = faceColors[f];\r\n for (let p = 0; p < facePositions[f].length; p++) {\r\n colors.push(color.r, color.g, color.b, color.a);\r\n }\r\n }\r\n }\r\n\r\n // Define transforms for each face\r\n const faceTransforms = [\r\n // FRONT\r\n { m: Matrix.RotationY(Math.PI), t: new Vector3(0, 0, halfDepth), op: OP_ADD },\r\n // BACK\r\n { m: Matrix.Identity(), t: new Vector3(0, 0, halfDepth), op: OP_SUB },\r\n // RIGHT\r\n { m: Matrix.RotationY(-Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_ADD },\r\n // LEFT\r\n { m: Matrix.RotationY(Math.PI / 2), t: new Vector3(halfWidth, 0, 0), op: OP_SUB },\r\n // TOP\r\n { m: Matrix.RotationX(Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_ADD },\r\n // BOTTOM\r\n { m: Matrix.RotationX(-Math.PI / 2), t: new Vector3(0, halfHeight, 0), op: OP_SUB },\r\n ];\r\n\r\n // Assemble positions and normals\r\n for (let f = 0; f < nbFaces; f++) {\r\n const { m, t, op } = faceTransforms[f];\r\n\r\n for (const v of facePositions[f]) {\r\n const p = Vector3.TransformCoordinates(v, m);\r\n const final = op === OP_ADD ? p.add(t) : p.subtract(t);\r\n positions.push(final.x, final.y, final.z);\r\n }\r\n\r\n for (const n of faceNormals[f]) {\r\n const nn = Vector3.TransformNormal(n, m);\r\n normals.push(nn.x, nn.y, nn.z);\r\n }\r\n }\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 a tiled box mesh\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_box\r\n * @param name defines the name of the mesh\r\n * @param options an object used to set the following optional parameters for the tiled box, required but can be empty\r\n * * pattern sets the rotation or reflection pattern for the tiles,\r\n * * size of the box\r\n * * width of the box, overwrites size\r\n * * height of the box, overwrites size\r\n * * depth of the box, overwrites size\r\n * * tileSize sets the size of a tile\r\n * * tileWidth sets the tile width and overwrites tileSize\r\n * * tileHeight sets the tile width and overwrites tileSize\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 * * alignHorizontal places whole tiles aligned to the center, left or right of a row\r\n * * alignVertical places whole tiles aligned to the center, left or right of a column\r\n * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE\r\n * @param scene defines the hosting scene\r\n * @returns the box mesh\r\n */\r\nexport function CreateTiledBox(\r\n name: string,\r\n options: {\r\n pattern?: number;\r\n width?: number;\r\n height?: number;\r\n depth?: number;\r\n tileSize?: number;\r\n tileWidth?: number;\r\n tileHeight?: number;\r\n alignHorizontal?: number;\r\n alignVertical?: number;\r\n faceUV?: Vector4[];\r\n faceColors?: Color4[];\r\n sideOrientation?: 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 = CreateTiledBoxVertexData(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 use CreateTiledBox instead\r\n */\r\nexport const TiledBoxBuilder = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n CreateTiledBox,\r\n};\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for the tiled box builder.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterTiledBoxBuilder(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterTiledPlaneBuilder();\r\n VertexData.CreateTiledBox = CreateTiledBoxVertexData;\r\n}\r\n"]}
@@ -1,79 +1 @@
1
- import { type Nullable } from "../../types.js";
2
- import { type Scene } from "../../scene.js";
3
- import { type Vector4 } from "../../Maths/math.vector.js";
4
- import { Mesh } from "../mesh.pure.js";
5
- import { VertexData } from "../mesh.vertexData.js";
6
- /**
7
- * Creates the VertexData for a tiled plane
8
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_plane
9
- * @param options an object used to set the following optional parameters for the tiled plane, required but can be empty
10
- * * pattern a limited pattern arrangement depending on the number
11
- * * size of the box
12
- * * width of the box, overwrites size
13
- * * height of the box, overwrites size
14
- * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
15
- * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
16
- * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
17
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
18
- * * alignHorizontal places whole tiles aligned to the center, left or right of a row
19
- * * alignVertical places whole tiles aligned to the center, left or right of a column
20
- * * 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)
21
- * * 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)
22
- * @returns the VertexData of the tiled plane
23
- */
24
- export declare function CreateTiledPlaneVertexData(options: {
25
- pattern?: number;
26
- tileSize?: number;
27
- tileWidth?: number;
28
- tileHeight?: number;
29
- size?: number;
30
- width?: number;
31
- height?: number;
32
- alignHorizontal?: number;
33
- alignVertical?: number;
34
- sideOrientation?: number;
35
- frontUVs?: Vector4;
36
- backUVs?: Vector4;
37
- }): VertexData;
38
- /**
39
- * Creates a tiled plane mesh
40
- * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/set/tiled_plane
41
- * @param name defines the name of the mesh
42
- * @param options an object used to set the following optional parameters for the tiled plane, required but can be empty
43
- * * pattern a limited pattern arrangement depending on the number
44
- * * size of the box
45
- * * width of the box, overwrites size
46
- * * height of the box, overwrites size
47
- * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
48
- * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
49
- * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
50
- * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
51
- * * alignHorizontal places whole tiles aligned to the center, left or right of a row
52
- * * alignVertical places whole tiles aligned to the center, left or right of a column
53
- * * 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)
54
- * * 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)
55
- * @param scene defines the hosting scene
56
- * @returns the box mesh
57
- */
58
- export declare function CreateTiledPlane(name: string, options: {
59
- pattern?: number;
60
- tileSize?: number;
61
- tileWidth?: number;
62
- tileHeight?: number;
63
- size?: number;
64
- width?: number;
65
- height?: number;
66
- alignHorizontal?: number;
67
- alignVertical?: number;
68
- sideOrientation?: number;
69
- frontUVs?: Vector4;
70
- backUVs?: Vector4;
71
- updatable?: boolean;
72
- }, scene?: Nullable<Scene>): Mesh;
73
- /**
74
- * Class containing static functions to help procedurally build meshes
75
- * @deprecated use CreateTiledPlane instead
76
- */
77
- export declare const TiledPlaneBuilder: {
78
- CreateTiledPlane: typeof CreateTiledPlane;
79
- };
1
+ export * from "./tiledPlaneBuilder.pure.js";